diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index b054ef4e..e97a3f10 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -1384,9 +1384,11 @@ void MenuStateConnectedGame::reloadFactions(bool keepExistingSelectedItem) { for(int idx = 0; idx < techPaths.size(); idx++) { string &techPath = techPaths[idx]; endPathWithSlash(techPath); - //findAll(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false); - findDirs(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/", results, false, false); + if(listBoxTechTree.getSelectedItemIndex() >= 0 && listBoxTechTree.getSelectedItemIndex() < techTreeFiles.size()) { + //findAll(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false); + findDirs(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/", results, false, false); + } if(results.empty() == false) { break; } @@ -2560,6 +2562,9 @@ void MenuStateConnectedGame::update() { std::for_each(techtree.begin(), techtree.end(), FormatString()); if(std::find(techTreeFiles.begin(),techTreeFiles.end(),gameSettings->getTech()) != techTreeFiles.end()) { + + //printf("gameSettings->getTech() [%s]\n",gameSettings->getTech().c_str()); + lastMissingTechtree = ""; getMissingTechtreeFromFTPServer = ""; //techtree.push_back(formatString(gameSettings->getTech())); @@ -2631,6 +2636,9 @@ void MenuStateConnectedGame::update() { if(getMissingMapFromFTPServerInProgress == false && gameSettings->getMap() != "") { // map + string mapFile = gameSettings->getMap(); + mapFile = formatString(mapFile); + maps = formattedMapFiles; if(currentMap != gameSettings->getMap()) {// load the setup again @@ -2656,14 +2664,12 @@ void MenuStateConnectedGame::update() { } } maps.push_back(ITEM_MISSING); + mapFile = ITEM_MISSING; } listBoxMap.setItems(maps); - string mapFile = gameSettings->getMap(); - mapFile = formatString(mapFile); listBoxMap.setSelectedItem(mapFile); - labelMapInfo.setText(mapInfo.desc); } diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index cfab09b4..9a5b689c 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -2648,13 +2648,14 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force if( serverInterface->getSlot(i) != NULL && serverInterface->getSlot(i)->isConnected()) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); - //printf("slot = %d serverInterface->getSlot(i)->getConnectedTime() = %d\n",i,serverInterface->getSlot(i)->getConnectedTime()); + //printf("slot = %d serverInterface->getSlot(i)->getConnectedTime() = %d session key [%d]\n",i,serverInterface->getSlot(i)->getConnectedTime(),serverInterface->getSlot(i)->getSessionKey()); - if(clientConnectedTime == 0 || serverInterface->getSlot(i)->getConnectedTime() < clientConnectedTime) { + if(clientConnectedTime == 0 || + (serverInterface->getSlot(i)->getConnectedTime() > 0 && serverInterface->getSlot(i)->getConnectedTime() < clientConnectedTime)) { clientConnectedTime = serverInterface->getSlot(i)->getConnectedTime(); gameSettings->setMasterserver_admin(serverInterface->getSlot(i)->getSessionKey()); - //printf("slot = %d, admin key [%d]\n",i,gameSettings->getMasterserver_admin()); + //printf("slot = %d, admin key [%d] slot connected time[%lu] clientConnectedTime [%lu]\n",i,gameSettings->getMasterserver_admin(),serverInterface->getSlot(i)->getConnectedTime(),clientConnectedTime); } } } @@ -2836,21 +2837,25 @@ void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettin //printf("In [%s::%s line %d] map [%s]\n",__FILE__,__FUNCTION__,__LINE__,gameSettings.getMap().c_str()); string mapFile = gameSettings.getMap(); - mapFile = formatString(mapFile); - listBoxMap.setSelectedItem(mapFile); + if(find(mapFiles.begin(),mapFiles.end(),mapFile) != mapFiles.end()) { + mapFile = formatString(mapFile); + listBoxMap.setSelectedItem(mapFile); - loadMapInfo(Map::getMapPath(getCurrentMapFile()), &mapInfo, true); - labelMapInfo.setText(mapInfo.desc); + loadMapInfo(Map::getMapPath(getCurrentMapFile()), &mapInfo, true); + labelMapInfo.setText(mapInfo.desc); + } string tilesetFile = gameSettings.getTileset(); - tilesetFile = formatString(tilesetFile); - - listBoxTileset.setSelectedItem(tilesetFile); + if(find(tilesetFiles.begin(),tilesetFiles.end(),tilesetFile) != tilesetFiles.end()) { + tilesetFile = formatString(tilesetFile); + listBoxTileset.setSelectedItem(tilesetFile); + } string techtreeFile = gameSettings.getTech(); - techtreeFile = formatString(techtreeFile); - - listBoxTechTree.setSelectedItem(techtreeFile); + if(find(techTreeFiles.begin(),techTreeFiles.end(),techtreeFile) != techTreeFiles.end()) { + techtreeFile = formatString(techtreeFile); + listBoxTechTree.setSelectedItem(techtreeFile); + } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index 6ac15943..e20c3ad8 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -362,8 +362,11 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { //send intro message when connected if(socket != NULL) { - RandomGen random; - sessionKey = random.randRange(-100000, 100000); + //RandomGen random; + //sessionKey = random.randRange(-100000, 100000); + srand(time(NULL)); + sessionKey = rand() % 1000000; + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] accepted new client connection, serverInterface->getOpenSlotCount() = %d, sessionKey = %d\n",__FILE__,__FUNCTION__,__LINE__,serverInterface->getOpenSlotCount(),sessionKey); if(hasOpenSlots == false) {