From 71bdb1cba71e40b0fd754adf09793fa1ed9de80b Mon Sep 17 00:00:00 2001 From: titiger Date: Fri, 14 Nov 2014 22:25:56 +0100 Subject: [PATCH] Player names of Scenarios were displayed in wrong slot. The player names were set with wrong index and CPU players had wrong names. --- source/glest_game/world/scenario.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/source/glest_game/world/scenario.cpp b/source/glest_game/world/scenario.cpp index 63f19e6ea..442ebeb53 100644 --- a/source/glest_game/world/scenario.cpp +++ b/source/glest_game/world/scenario.cpp @@ -480,6 +480,8 @@ void Scenario::loadGameSettings(const vector &dirList, const ScenarioInfo *scenarioInfo, GameSettings *gameSettings, string scenarioDescription) { int factionCount= 0; + int AIPlayerCount=0; + Lang &lang= Lang::getInstance(); if(gameSettings->getGameUUID() == "") { gameSettings->setGameUUID(getUUIDAsString()); @@ -501,15 +503,21 @@ void Scenario::loadGameSettings(const vector &dirList, if(ct == ctHuman) { gameSettings->setThisFactionIndex(factionCount); - if(gameSettings->getNetworkPlayerName(i) == "") { - gameSettings->setNetworkPlayerName(i,Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str())); + if(gameSettings->getNetworkPlayerName(factionCount) == "") { + gameSettings->setNetworkPlayerName(factionCount,Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str())); } - gameSettings->setNetworkPlayerUUID(i,Config::getInstance().getString("PlayerId","")); - gameSettings->setNetworkPlayerPlatform(i,getPlatformNameString()); + gameSettings->setNetworkPlayerUUID(factionCount,Config::getInstance().getString("PlayerId","")); + gameSettings->setNetworkPlayerPlatform(factionCount,getPlatformNameString()); } - else { - if(gameSettings->getNetworkPlayerName(i) == "") { - gameSettings->setNetworkPlayerName(i,controllerTypeToStr(ct)); + else if(ct == ctNetwork || ct == ctNetworkUnassigned){ + if(gameSettings->getNetworkPlayerName(factionCount) == "") { + gameSettings->setNetworkPlayerName(factionCount,controllerTypeToStr(ct)); + } + } + else {//this is a CPU player + AIPlayerCount++; + if(gameSettings->getNetworkPlayerName(factionCount) == "") { + gameSettings->setNetworkPlayerName(factionCount,lang.getString("AI") + intToStr(AIPlayerCount)); } } gameSettings->setFactionControl(factionCount, ct);