diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 87c80348..ae23b09b 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -1572,10 +1572,29 @@ void Game::setupPopupMenus(bool checkClientAdminOverrideOnly) { NetworkManager &networkManager= NetworkManager::getInstance(); NetworkRole role = networkManager.getNetworkRole(); ClientInterface *clientInterface = NULL; + ServerInterface *serverInterface = NULL; bool allowAdminMenuItems = false; + bool forceJoinInProgressUpdate = false; if(role == nrServer) { allowAdminMenuItems = true; + + if(disconnectPlayerPopupMenuIndex == -1) { + serverInterface = dynamic_cast(networkManager.getServerInterface()); + if(serverInterface != NULL && checkClientAdminOverrideOnly == true) { + for(int i = 0; i < world.getFactionCount(); ++i) { + Faction *faction = world.getFaction(i); + ConnectionSlot *slot = serverInterface->getSlot(faction->getStartLocationIndex()); + if(slot != NULL && slot->getConnectHasHandshaked() == true && + slot->getCurrentFrameCount() <= 0) { + //printf("Connected slot can be disconnected: %d\n",slot->getPlayerIndex()); + + forceJoinInProgressUpdate = true; + break; + } + } + } + } } else if(role == nrClient) { clientInterface = dynamic_cast(networkManager.getClientInterface()); @@ -1588,6 +1607,7 @@ void Game::setupPopupMenus(bool checkClientAdminOverrideOnly) { } if(checkClientAdminOverrideOnly == false || + forceJoinInProgressUpdate == true || (clientInterface != NULL && (gameSettings.getMasterserver_admin() != clientInterface->getSessionKey() && clientInterface->isMasterServerAdminOverride() == true))) { @@ -1599,7 +1619,7 @@ void Game::setupPopupMenus(bool checkClientAdminOverrideOnly) { keyboardSetupPopupMenuIndex = -1; disconnectPlayerPopupMenuIndex = -1; - if(checkClientAdminOverrideOnly == true) { + if(checkClientAdminOverrideOnly == true && clientInterface != NULL) { gameSettings.setMasterserver_admin(clientInterface->getSessionKey()); gameSettings.setMasterserver_admin_faction_index(clientInterface->getPlayerIndex()); } @@ -3531,6 +3551,13 @@ void Game::mouseDownLeft(int x, int y) { } else if(result.first == disconnectPlayerPopupMenuIndex) { Lang &lang= Lang::getInstance(); + + NetworkManager &networkManager= NetworkManager::getInstance(); + NetworkRole role = networkManager.getNetworkRole(); + ServerInterface *serverInterface = NULL; + if(role == nrServer) { + serverInterface = dynamic_cast(networkManager.getServerInterface()); + } disconnectPlayerIndexMap.clear(); std::vector menuItems; for(unsigned int i = 0; i < world.getFactionCount(); ++i) { @@ -3538,10 +3565,19 @@ void Game::mouseDownLeft(int x, int y) { //printf("faction->getPersonalityType() = %d index [%d,%d] control [%d] networkstatus [%d]\n",faction->getPersonalityType(),world.getThisFaction()->getIndex(),faction->getIndex(),faction->getControlType(),this->gameSettings.getNetworkPlayerStatuses(i)); - if(faction->getPersonalityType() != fpt_Observer && + bool isSlotJoinInProgressClient = false; + if(serverInterface != NULL) { + ConnectionSlot *slot = serverInterface->getSlot(faction->getStartLocationIndex()); + if(slot != NULL && slot->getConnectHasHandshaked() == true && + slot->getCurrentFrameCount() <= 0) { + isSlotJoinInProgressClient = true; + } + } + if(isSlotJoinInProgressClient == true || + (faction->getPersonalityType() != fpt_Observer && world.getThisFaction()->getIndex() != faction->getIndex() && faction->getControlType() == ctNetwork && - this->gameSettings.getNetworkPlayerStatuses(i) != npst_Disconnected) { + this->gameSettings.getNetworkPlayerStatuses(i) != npst_Disconnected)) { char szBuf[8096]=""; if(lang.hasString("DisconnectNetorkPlayerIndex") == true) { diff --git a/source/glest_game/network/client_interface.cpp b/source/glest_game/network/client_interface.cpp index f0aed3ac..02d172a3 100644 --- a/source/glest_game/network/client_interface.cpp +++ b/source/glest_game/network/client_interface.cpp @@ -867,6 +867,20 @@ void ClientInterface::updateLobby() { } break; + case nmtQuit: + { + time_t receiveTimeElapsed = time(NULL); + NetworkMessageQuit networkMessageQuit; + bool gotCmd = receiveMessage(&networkMessageQuit); + if(gotCmd == false) { + throw megaglest_runtime_error("error retrieving nmtQuit returned false!"); + } + + quit= true; + close(); + } + break; + default: { string sErr = string(extractFileFromDirectoryPath(__FILE__).c_str()) + "::" + string(__FUNCTION__) + " Unexpected network message: " + intToStr(networkMessageType); diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index d71b1fc3..f28624b8 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -924,6 +924,12 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { this->serverInterface->addClientToServerIPAddress(this->getSocket()->getConnectedIPAddress(this->getSocket()->getIpAddress()),this->connectedRemoteIPAddress); + if(serverInterface->getGameHasBeenInitiated() == true && + serverInterface->getAllowInGameConnections() == true) { + int factionIndex = this->serverInterface->gameSettings.getFactionIndexForStartLocation(playerIndex); + this->serverInterface->gameSettings.setNetworkPlayerStatuses(factionIndex,npst_None); + } + if(getAllowGameDataSynchCheck() == true && serverInterface->getGameSettings() != NULL) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] sending NetworkMessageSynchNetworkGameData\n",__FILE__,__FUNCTION__,__LINE__); @@ -935,8 +941,6 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { serverInterface->getAllowInGameConnections() == true) { //printf("Sent intro to client connection on slot!\n"); - //this->skipLagCheck = true; - //this->joinGameInProgress = true; setJoinGameInProgressFlags(); this->setPauseForInGameConnection(true); @@ -1037,7 +1041,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { int factionIndex = this->serverInterface->gameSettings.getFactionIndexForStartLocation(playerIndex); this->serverInterface->gameSettings.setFactionControl(factionIndex,ctNetwork); this->serverInterface->gameSettings.setNetworkPlayerName(factionIndex,this->name); - this->serverInterface->gameSettings.setNetworkPlayerStatuses(factionIndex,npst_None); + //this->serverInterface->gameSettings.setNetworkPlayerStatuses(factionIndex,npst_None); this->serverInterface->broadcastGameSetup(&this->serverInterface->gameSettings, true);