diff --git a/source/glest_game/game/commander.cpp b/source/glest_game/game/commander.cpp index eaae0f7f..07c2c1d3 100644 --- a/source/glest_game/game/commander.cpp +++ b/source/glest_game/game/commander.cpp @@ -485,7 +485,7 @@ void Commander::tryResumeGame() const { } void Commander::tryNetworkPlayerDisconnected(int factionIndex) const { - NetworkCommand command(this->world,nctPlayerStatusChange, factionIndex, 1); + NetworkCommand command(this->world,nctPlayerStatusChange, factionIndex, npst_Disconnected); pushNetworkCommand(&command); } @@ -882,9 +882,15 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const { int factionIndex = networkCommand->getUnitId(); int playerStatus = networkCommand->getCommandTypeId(); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"nctPlayerStatusChange factionIndex = %d playerStatus = %d\n",factionIndex,playerStatus); + GameSettings *settings = world->getGameSettingsPtr(); - if(playerStatus == 1) { - settings->setNetworkPlayerGameStatus(factionIndex,1); + if(playerStatus == npst_Disconnected) { + settings->setNetworkPlayerStatuses(factionIndex,npst_Disconnected); + + //printf("nctPlayerStatusChange -> faction->getPersonalityType() = %d index [%d] control [%d] networkstatus [%d]\n", + // world->getFaction(factionIndex)->getPersonalityType(),world->getFaction(factionIndex)->getIndex(),world->getFaction(factionIndex)->getControlType(),settings->getNetworkPlayerStatuses(factionIndex)); + if(!world->getGame()->getGameOver()&& !this->world->getGame()->factionLostGame(factionIndex)){ // use the fallback multiplier here settings->setResourceMultiplierIndex(factionIndex,settings->getFallbackCpuMultiplier()); diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 4722ca07..af204757 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -2233,11 +2233,12 @@ void Game::mouseDownLeft(int x, int y) { for(unsigned int i = 0; i < world.getFactionCount(); ++i) { Faction *faction = world.getFaction(i); - //printf("faction->getPersonalityType() = %d index [%d,%d] control [%d]\n",faction->getPersonalityType(),world.getThisFaction()->getIndex(),faction->getIndex(),faction->getControlType()); + //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 && world.getThisFaction()->getIndex() != faction->getIndex() && - faction->getControlType() == ctNetwork) { + faction->getControlType() == ctNetwork && + this->gameSettings.getNetworkPlayerStatuses(i) != npst_Disconnected) { char szBuf[1024]=""; if(lang.hasString("DisconnectNetorkPlayerIndex") == true) { diff --git a/source/glest_game/game/game_settings.h b/source/glest_game/game/game_settings.h index 8d04fdae..fe371288 100644 --- a/source/glest_game/game/game_settings.h +++ b/source/glest_game/game/game_settings.h @@ -41,6 +41,13 @@ enum FlagTypes1 { //ft1_xx = 0x10, }; +enum NetworkPlayerStatusType { + npst_None = 0, + npst_PickSettings = 1, + npst_BeRightBack = 2, + npst_Ready = 3, + npst_Disconnected = 4 +}; class GameSettings { private: @@ -114,7 +121,7 @@ public: for(int i = 0; i < GameConstants::maxPlayers; ++i) { factionTypeNames[i] = ""; networkPlayerNames[i] = ""; - networkPlayerStatuses[i] = 0; + networkPlayerStatuses[i] = npst_None; networkPlayerLanguages[i] = DEFAULT_LANG; factionControls[i] = ctClosed; resourceMultiplierIndex[i] = 1.0f; @@ -147,7 +154,7 @@ public: const string &getFactionTypeName(int factionIndex) const {return factionTypeNames[factionIndex];} string getNetworkPlayerName(int factionIndex) const { string result = networkPlayerNames[factionIndex]; - if(networkPlayerGameStatus[factionIndex] == 1) { + if(networkPlayerStatuses[factionIndex] == npst_Disconnected) { result = playerDisconnectedText + result; } return result; diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 9fec60c3..9ee07c5e 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -4309,7 +4309,7 @@ int glestMain(int argc, char** argv) { for(int i = 0; i < GameConstants::maxPlayers; ++i) { ControlType ct= ctClosed; - gameSettings->setNetworkPlayerStatuses(i, 0); + gameSettings->setNetworkPlayerStatuses(i, npst_None); gameSettings->setFactionControl(i, ct); gameSettings->setStartLocationIndex(i, i); gameSettings->setResourceMultiplierIndex(i, 10); @@ -4318,7 +4318,7 @@ int glestMain(int argc, char** argv) { ControlType ct= ctHuman; - gameSettings->setNetworkPlayerStatuses(0, 0); + gameSettings->setNetworkPlayerStatuses(0, npst_None); gameSettings->setFactionControl(0, ct); gameSettings->setFactionTypeName(0, formatString(GameConstants::OBSERVER_SLOTNAME)); gameSettings->setTeam(0, GameConstants::maxPlayers + fpt_Observer - 1); diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 6222c64b..4e5d6832 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -1565,7 +1565,7 @@ void MenuStateConnectedGame::loadGameSettings(GameSettings *gameSettings) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, factionFiles[listBoxFactions[i].getSelectedItemIndex()] [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,factionFiles[listBoxFactions[i].getSelectedItemIndex()].c_str()); gameSettings->setFactionTypeName(slotIndex, factionFiles[listBoxFactions[i].getSelectedItemIndex()]); - gameSettings->setNetworkPlayerStatuses(slotIndex, 0); + gameSettings->setNetworkPlayerStatuses(slotIndex, npst_Disconnected); gameSettings->setNetworkPlayerName(slotIndex, "Closed"); closedCount++; @@ -3709,6 +3709,10 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings, labelPlayerStatus[slot].setText(lang.get("PlayerStatusSetup")); labelPlayerStatus[slot].setTextColor(Vec3f(1.f, 0.f, 0.f)); break; + case npst_Disconnected: + labelPlayerStatus[slot].setText(lang.get("Closed")); + break; + default: labelPlayerStatus[slot].setText(""); break; diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 902bf9bf..6bcefd9c 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -2305,6 +2305,10 @@ void MenuStateCustomGame::update() { labelPlayerStatus[i].setText(lang.get("PlayerStatusSetup")); labelPlayerStatus[i].setTextColor(Vec3f(1.f, 0.f, 0.f)); break; + case npst_Disconnected: + labelPlayerStatus[i].setText(lang.get("Closed")); + break; + default: labelPlayerStatus[i].setText(""); break; @@ -3220,7 +3224,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force } else { //gameSettings->setNetworkPlayerName(""); - gameSettings->setNetworkPlayerStatuses(factionCount, 0); + gameSettings->setNetworkPlayerStatuses(factionCount, npst_Disconnected); labelPlayerNames[i].setText(""); } } diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index bab32c43..ebd06a56 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -250,7 +250,7 @@ ConnectionSlot::ConnectionSlot(ServerInterface* serverInterface, int playerIndex this->sessionKey = 0; this->serverInterface = serverInterface; this->playerIndex = playerIndex; - this->playerStatus = 0; + this->playerStatus = npst_None; this->playerLanguage = ""; this->currentFrameCount = 0; this->currentLagCount = 0; diff --git a/source/glest_game/network/network_message.h b/source/glest_game/network/network_message.h index 62e328c9..5e9d751c 100644 --- a/source/glest_game/network/network_message.h +++ b/source/glest_game/network/network_message.h @@ -601,13 +601,6 @@ enum SwitchSetupRequestFlagType { ssrft_PlayerStatus = 0x20 }; -enum NetworkPlayerStatusType { - npst_None = 0x00, - npst_PickSettings = 0x01, - npst_BeRightBack = 0x02, - npst_Ready = 0x04 -}; - #pragma pack(push, 1) class SwitchSetupRequest: public NetworkMessage{ private: