diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index af2177f8..d0f262f5 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -1021,6 +1021,7 @@ void MenuStateConnectedGame::update() { //needToSetChangedGameSettings = false; //lastSetChangedGameSettings = time(NULL); clientInterface->sendSwitchSetupRequest("",clientInterface->getPlayerIndex(),-1,-1,getHumanPlayerName(),switchSetupRequestFlagType); + switchSetupRequestFlagType=ssrft_None; } @@ -1262,7 +1263,7 @@ void MenuStateConnectedGame::keyUp(char key) { void MenuStateConnectedGame::setActiveInputLabel(GraphicLabel *newLable) { -/* + if(newLable != NULL) { string text= newLable->getText(); size_t found = text.find_last_of("_"); @@ -1280,13 +1281,13 @@ void MenuStateConnectedGame::setActiveInputLabel(GraphicLabel *newLable) { activeInputLabel->setText(text); } activeInputLabel = newLable; -*/ + } string MenuStateConnectedGame::getHumanPlayerName() { string result = defaultPlayerName; -/* + NetworkManager &networkManager= NetworkManager::getInstance(); ClientInterface* clientInterface= networkManager.getClientInterface(); for(int j=0; jgetText(); size_t found = text.find_last_of("_"); @@ -2424,7 +2424,7 @@ void MenuStateCustomGame::setActiveInputLabel(GraphicLabel *newLable) { activeInputLabel->setText(text); } activeInputLabel = newLable; -*/ + } string MenuStateCustomGame::getHumanPlayerName(int index) { @@ -2433,7 +2433,7 @@ string MenuStateCustomGame::getHumanPlayerName(int index) { //printf("\nIn [%s::%s Line: %d] index = %d\n",__FILE__,__FUNCTION__,__LINE__,index); //fflush(stdout); -/* + if(index < 0) { for(int j = 0; j < GameConstants::maxPlayers; ++j) { if(listBoxControls[j].getSelectedItemIndex() >= 0) { @@ -2461,7 +2461,7 @@ string MenuStateCustomGame::getHumanPlayerName(int index) { } } } -*/ + return result; } diff --git a/source/glest_game/network/client_interface.cpp b/source/glest_game/network/client_interface.cpp index d1c21e35..12aeaf06 100755 --- a/source/glest_game/network/client_interface.cpp +++ b/source/glest_game/network/client_interface.cpp @@ -181,7 +181,7 @@ void ClientInterface::updateLobby() { playerIndex= networkMessageIntro.getPlayerIndex(); serverName= networkMessageIntro.getName(); - SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got NetworkMessageIntro, networkMessageIntro.getGameState() = %d, versionString [%s], sessionKey = %d\n",__FILE__,__FUNCTION__,__LINE__,networkMessageIntro.getGameState(),versionString.c_str(),sessionKey); + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got NetworkMessageIntro, networkMessageIntro.getGameState() = %d, versionString [%s], sessionKey = %d, playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,networkMessageIntro.getGameState(),versionString.c_str(),sessionKey,playerIndex); //check consistency if(networkMessageIntro.getVersionString() != getNetworkVersionString()) { @@ -471,7 +471,7 @@ void ClientInterface::updateLobby() { //set the faction index if(gameSettings.getStartLocationIndex(i) == playerIndex) { gameSettings.setThisFactionIndex(i); - SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] gameSettings.getThisFactionIndex(i) = %d, playerIndex = %d, i = %d\n",__FILE__,__FUNCTION__,__LINE__,gameSettings.getThisFactionIndex(),playerIndex,i); + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] gameSettings.getThisFactionIndex(i) = %d, playerIndex = %d, i = %d\n",__FILE__,__FUNCTION__,__LINE__,gameSettings.getThisFactionIndex(),playerIndex,i); } } @@ -487,9 +487,10 @@ void ClientInterface::updateLobby() { case nmtPlayerIndexMessage: { PlayerIndexMessage playerIndexMessage(-1); - if(receiveMessage(&playerIndexMessage)) - { + if(receiveMessage(&playerIndexMessage)) { playerIndex= playerIndexMessage.getPlayerIndex(); + + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got nmtPlayerIndexMessage, playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex); } } break; @@ -791,7 +792,11 @@ void ClientInterface::waitUntilReady(Checksum* checksum) { } void ClientInterface::sendTextMessage(const string &text, int teamIndex, bool echoLocal){ - NetworkMessageText networkMessageText(text, getHumanPlayerName(), teamIndex); + + string humanPlayerName = getHumanPlayerName(); + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] humanPlayerName = [%s] playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,humanPlayerName.c_str(),playerIndex); + + NetworkMessageText networkMessageText(text, humanPlayerName, teamIndex); sendMessage(&networkMessageText); if(echoLocal == true) { @@ -1015,9 +1020,9 @@ bool ClientInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess string ClientInterface::getHumanPlayerName(int index) { string result = Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()); - if(index >= 0 || playerIndex >= 0) { + if(index >= 0 || playerIndex > 0) { if(index < 0) { - index = playerIndex; + index = playerIndex-1; } if(gameSettings.getNetworkPlayerName(index) != "") { result = gameSettings.getNetworkPlayerName(index);