From 34fe6fd0f111301cc586de063eb3ca22d33e0d96 Mon Sep 17 00:00:00 2001 From: mathusummut Date: Mon, 10 Dec 2018 19:37:05 +0100 Subject: [PATCH] Resource multiplier goes up to 10 --- .../zetaglest/Start Headless Server.lnk | Bin 1349 -> 1349 bytes source/glest_game/game/game.cpp | 76 +++++++++--------- source/glest_game/game/game.h | 3 +- source/glest_game/graphics/renderer.cpp | 2 +- source/glest_game/main/battle_end.cpp | 6 +- .../menu/menu_state_connected_game.cpp | 8 +- .../menu/menu_state_custom_game.cpp | 4 +- source/shared_lib/include/util/conversion.h | 4 +- source/shared_lib/sources/util/conversion.cpp | 4 +- 9 files changed, 53 insertions(+), 54 deletions(-) diff --git a/mk/windows/vs2017-64/zetaglest/Start Headless Server.lnk b/mk/windows/vs2017-64/zetaglest/Start Headless Server.lnk index 9f6a54ea437ccf78a37da3b1194a51f3f8b7914d..77988f2130a6821df20f8e78ef7aad1b5b72641b 100644 GIT binary patch delta 12 TcmX@gb(Cv@D5JtgF@0758sr0D delta 12 TcmX@gb(Cv@C?ms0F@0758bkv? diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index befe4e458..749980f07 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -2864,7 +2864,7 @@ namespace Game { chronoGamePerformanceCounts.start(); - ReplaceDisconnectedNetworkPlayersWithAI(isNetworkGame, role); + ReplaceDisconnectedNetworkPlayersWithAI(isNetworkGame, role, getTimeDurationMinutes(this->world.getFrameCount(), GameConstants::updateFps) > 0.06); addPerformanceCount("ReplaceDisconnectedNetworkPlayersWithAI", chronoGamePerformanceCounts.getMillis()); @@ -4362,8 +4362,7 @@ namespace Game { } void - Game::ReplaceDisconnectedNetworkPlayersWithAI(bool isNetworkGame, - NetworkRole role) { + Game::ReplaceDisconnectedNetworkPlayersWithAI(bool isNetworkGame, NetworkRole role, bool showMessage) { if (role == nrServer && isNetworkGame == true && difftime((long int) time(NULL), lastNetworkPlayerConnectionCheck) >= @@ -4415,42 +4414,43 @@ namespace Game { isPlayerObserver = true; } - - const - vector < - string > - languageList = - this->gameSettings.getUniqueNetworkPlayerLanguages(); - for (unsigned int j = 0; - j < (unsigned int) languageList.size(); ++j) { - if (isPlayerObserver == false) { - string - msg = - "Player #%d %s has disconnected, switching player to AI mode"; - if (lang.hasString("GameSwitchPlayerToAI", - languageList[j], true)) { - msg = - lang.getString("GameSwitchPlayerToAI", languageList[j]); + if (showMessage) { + const + vector < + string > + languageList = + this->gameSettings.getUniqueNetworkPlayerLanguages(); + for (unsigned int j = 0; + j < (unsigned int) languageList.size(); ++j) { + if (isPlayerObserver == false) { + string + msg = + "Player #%d %s has disconnected, switching player to AI mode"; + if (lang.hasString("GameSwitchPlayerToAI", + languageList[j], true)) { + msg = + lang.getString("GameSwitchPlayerToAI", languageList[j]); + } + snprintf(szBuf, 8096, msg.c_str(), i + 1, + this->gameSettings.getNetworkPlayerName(i). + c_str()); + } else { + string + msg = + "Player #%d %s has disconnected, but player was only an observer"; + if (lang.hasString("GameSwitchPlayerObserverToAI", + languageList[j], true)) { + msg = + lang.getString("GameSwitchPlayerObserverToAI", languageList[j]); + } + snprintf(szBuf, 8096, msg.c_str(), i + 1, + this->gameSettings.getNetworkPlayerName(i). + c_str()); } - snprintf(szBuf, 8096, msg.c_str(), i + 1, - this->gameSettings.getNetworkPlayerName(i). - c_str()); - } else { - string - msg = - "Player #%d %s has disconnected, but player was only an observer"; - if (lang.hasString("GameSwitchPlayerObserverToAI", - languageList[j], true)) { - msg = - lang.getString("GameSwitchPlayerObserverToAI", languageList[j]); - } - snprintf(szBuf, 8096, msg.c_str(), i + 1, - this->gameSettings.getNetworkPlayerName(i). - c_str()); + bool localEcho = (languageList[j] == lang.getLanguage()); + server->sendTextMessage(szBuf, -1, localEcho, + languageList[j]); } - bool localEcho = (languageList[j] == lang.getLanguage()); - server->sendTextMessage(szBuf, -1, localEcho, - languageList[j]); } } } @@ -6985,7 +6985,7 @@ namespace Game { >::getString (stat_online_minutes_played).c_str ()) + - getTimeDuationMinutes + getTimeDurationMinutes (endStats.getFramesToCalculatePlaytime (), GameConstants::updateFps)); } diff --git a/source/glest_game/game/game.h b/source/glest_game/game/game.h index d9ffad4ef..c171ce957 100644 --- a/source/glest_game/game/game.h +++ b/source/glest_game/game/game.h @@ -502,8 +502,7 @@ namespace Game { static int ErrorDisplayMessage(const char *msg, bool exitApp); void - ReplaceDisconnectedNetworkPlayersWithAI(bool isNetworkGame, - NetworkRole role); + ReplaceDisconnectedNetworkPlayersWithAI(bool isNetworkGame, NetworkRole role, bool showMessage); void calcCameraMoveX(); void calcCameraMoveZ(); diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 3389823ce..7a45a1729 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -2246,7 +2246,7 @@ namespace Game { //int minutes = (world->getTimeFlow()->getTime() - hours) * 100 * 0.6; // scale 100 to 60 //snprintf(szBuf,200,"%s %.2d:%.2d",lang.getString("GameTime","",true).c_str(),hours,minutes); // string header2 = lang.getString("GameDurationTime","",true) + ": " + getTimeString(stats.getFramesToCalculatePlaytime()); - snprintf(szBuf, 500, "%s %s", lang.getString("GameDurationTime", "").c_str(), getTimeDuationString(world->getFrameCount(), GameConstants::updateFps).c_str()); + snprintf(szBuf, 500, "%s %s", lang.getString("GameDurationTime", "").c_str(), getTimeDurationString(world->getFrameCount(), GameConstants::updateFps).c_str()); if (str != "") { str += " "; } diff --git a/source/glest_game/main/battle_end.cpp b/source/glest_game/main/battle_end.cpp index d860d45aa..a0fa470c8 100644 --- a/source/glest_game/main/battle_end.cpp +++ b/source/glest_game/main/battle_end.cpp @@ -660,7 +660,7 @@ namespace Game { int score = - enemykills * 100 + unitsProduced * 50 + resourcesHarvested / 10; + enemykills * 100 + unitsProduced * 50 + resourcesHarvested / 10 - deaths / 100; string controlString; if (stats.getPersonalityType(i) == fpt_Observer) { @@ -729,7 +729,7 @@ namespace Game { string textToRender = stats.getPlayerName(i).substr(0, 11); if (stats.getPlayerLeftBeforeEnd(i) == true) { textToRender += - "\n(" + getTimeDuationString(stats.getTimePlayerLeft(i), + "\n(" + getTimeDurationString(stats.getTimePlayerLeft(i), GameConstants::updateFps) + ")"; } @@ -860,7 +860,7 @@ namespace Game { string header2 = lang.getString("GameDurationTime", "") + ": " + - getTimeDuationString(stats.getFramesToCalculatePlaytime(), + getTimeDurationString(stats.getFramesToCalculatePlaytime(), GameConstants::updateFps); textRenderer->render(header2, lm + 250, bm + 530); diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 5d193d65e..cb6a01d05 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -299,8 +299,8 @@ namespace Game { checkBoxAllowObservers.setEditable(false); - for (int i = 0; i <= 45; ++i) { - rMultiplier.push_back(floatToStr(0.5f + 0.1f * i, 1)); + for (int i = 1; i <= 20; ++i) { + rMultiplier.push_back(floatToStr(0.5f * i, 1)); } labelFallbackCpuMultiplier.registerGraphicComponent(containerName, @@ -914,8 +914,8 @@ namespace Game { listBoxAISwitchTeamAcceptPercent.setItems(aiswitchteamModeItems); vector < string > rMultiplier; - for (int i = 0; i <= 45; ++i) { - rMultiplier.push_back(floatToStr(0.5f + 0.1f * i, 1)); + for (int i = 1; i <= 20; ++i) { + rMultiplier.push_back(floatToStr(0.5f * i, 1)); } listBoxFallbackCpuMultiplier.setItems(rMultiplier); diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index ac48268d7..7ab0d8748 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -501,8 +501,8 @@ namespace Game { checkBoxAllowObservers.setValue(checkBoxAllowObservers.getValue()); vector < string > rMultiplier; - for (int i = 0; i <= 45; ++i) { - rMultiplier.push_back(floatToStr(0.5f + 0.1f * i, 1)); + for (int i = 1; i <= 20; ++i) { + rMultiplier.push_back(floatToStr(0.5f * i, 1)); } labelFallbackCpuMultiplier.registerGraphicComponent(containerName, diff --git a/source/shared_lib/include/util/conversion.h b/source/shared_lib/include/util/conversion.h index 9b6c328f2..b0e837dde 100644 --- a/source/shared_lib/include/util/conversion.h +++ b/source/shared_lib/include/util/conversion.h @@ -52,8 +52,8 @@ namespace Shared { string formatNumber(uint64 f); - double getTimeDuationMinutes(int frames, int updateFps); - string getTimeDuationString(int frames, int updateFps); + double getTimeDurationMinutes(int frames, int updateFps); + string getTimeDurationString(int frames, int updateFps); } } //end namespace diff --git a/source/shared_lib/sources/util/conversion.cpp b/source/shared_lib/sources/util/conversion.cpp index cc2abc487..0524bdb47 100644 --- a/source/shared_lib/sources/util/conversion.cpp +++ b/source/shared_lib/sources/util/conversion.cpp @@ -223,7 +223,7 @@ namespace Shared { return out.str(); } - double getTimeDuationMinutes(int frames, int updateFps) { + double getTimeDurationMinutes(int frames, int updateFps) { int framesleft = frames; double hours = (int) ((int) frames / (float) updateFps / 3600.0f); framesleft = (int) (framesleft - hours * 3600 * updateFps); @@ -238,7 +238,7 @@ namespace Shared { return result; } - string getTimeDuationString(int frames, int updateFps) { + string getTimeDurationString(int frames, int updateFps) { int framesleft = frames; int hours = (int) ((int) frames / (float) updateFps / 3600.0f); framesleft = framesleft - hours * 3600 * updateFps;