From ed6961195f1f9ce0893729d16b7012e538ffaa6a Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Fri, 20 Jul 2012 22:24:27 +0000 Subject: [PATCH] Disconnect time of early leavers is shown in end game stats. --- source/glest_game/game/commander.cpp | 1 + source/glest_game/game/stats.cpp | 1 + source/glest_game/game/stats.h | 7 ++++++- source/glest_game/main/battle_end.cpp | 9 ++++++++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/source/glest_game/game/commander.cpp b/source/glest_game/game/commander.cpp index 163cbf430..97df9eb6f 100644 --- a/source/glest_game/game/commander.cpp +++ b/source/glest_game/game/commander.cpp @@ -839,6 +839,7 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const { settings->setNetworkPlayerGameStatus(factionIndex,1); if(!world->getGame()->getGameOver()&& !this->world->getGame()->factionLostGame(factionIndex)){ this->world->getStats()->setPlayerLeftBeforeEnd(factionIndex,true); + this->world->getStats()->setTimePlayerLeft(factionIndex,this->world->getStats()->getFramesToCalculatePlaytime()); } } diff --git a/source/glest_game/game/stats.cpp b/source/glest_game/game/stats.cpp index d8fac52e5..8dd559506 100644 --- a/source/glest_game/game/stats.cpp +++ b/source/glest_game/game/stats.cpp @@ -29,6 +29,7 @@ PlayerStats::PlayerStats() { resourcesHarvested = 0; playerName = ""; playerLeftBeforeEnd = false; + timePlayerLeft = -1; playerColor = Vec3f(0,0,0); } diff --git a/source/glest_game/game/stats.h b/source/glest_game/game/stats.h index b444e3f08..5b9694dbb 100644 --- a/source/glest_game/game/stats.h +++ b/source/glest_game/game/stats.h @@ -46,6 +46,7 @@ public: int resourcesHarvested; string playerName; bool playerLeftBeforeEnd; + int timePlayerLeft; Vec3f playerColor; string getStats() const; @@ -113,8 +114,13 @@ public: int getResourcesHarvested(int factionIndex) const {return playerStats[factionIndex].resourcesHarvested;} string getPlayerName(int factionIndex) const {return playerStats[factionIndex].playerName;} bool getPlayerLeftBeforeEnd(int factionIndex) const {return playerStats[factionIndex].playerLeftBeforeEnd;} + void setPlayerLeftBeforeEnd(int factionIndex, bool value) {playerStats[factionIndex].playerLeftBeforeEnd = value; } Vec3f getPlayerColor(int factionIndex) const { return playerStats[factionIndex].playerColor;} + int getTimePlayerLeft(int factionIndex) const {return playerStats[factionIndex].timePlayerLeft;} + void setTimePlayerLeft(int factionIndex, int value) {playerStats[factionIndex].timePlayerLeft = value; } + + bool getIsMasterserverMode() const { return isMasterserverMode; } void setIsMasterserverMode(bool value) { isMasterserverMode = value; } @@ -135,7 +141,6 @@ public: void produce(int producerFactionIndex, bool isProductionCounted); void harvest(int harvesterFactionIndex, int amount); void setPlayerName(int playerIndex, string value) {playerStats[playerIndex].playerName = value; } - void setPlayerLeftBeforeEnd(int playerIndex, bool value) {playerStats[playerIndex].playerLeftBeforeEnd = value; } void setPlayerColor(int playerIndex, Vec3f value) {playerStats[playerIndex].playerColor = value; } void addFramesToCalculatePlaytime() {this->framesToCalculatePlaytime++; } diff --git a/source/glest_game/main/battle_end.cpp b/source/glest_game/main/battle_end.cpp index c2ea36ed5..46f086cbd 100644 --- a/source/glest_game/main/battle_end.cpp +++ b/source/glest_game/main/battle_end.cpp @@ -311,7 +311,13 @@ void BattleEnd::render() { Vec3f color = stats.getPlayerColor(i); if(stats.getPlayerName(i) != "") { - textRenderer->render(stats.getPlayerName(i).c_str(), textX, bm+400, false, &color); + string textToRender=stats.getPlayerName(i); + if(stats.getPlayerLeftBeforeEnd(i)==true){ + textToRender+="\n("+ + floatToStr((float)stats.getTimePlayerLeft(i) / (float)GameConstants::updateFps / 60.0,2)+")"; + } + + textRenderer->render(textToRender.c_str(), textX, bm+400, false, &color); } else { textRenderer->render((lang.get("Player") + " " + intToStr(i+1)).c_str(), textX, bm+400,false, &color); @@ -378,6 +384,7 @@ void BattleEnd::render() { } } + textRenderer->render("\n"+(lang.get("left at (min)")), lm, bm+400); textRenderer->render(lang.get("Result"), lm, bm+360); textRenderer->render(lang.get("Control"), lm, bm+320); textRenderer->render(lang.get("Faction"), lm, bm+280);