From 36ebfcf95e1abdb2a637adeda1d6239c82faf5e1 Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Sat, 9 Apr 2011 23:25:18 +0000 Subject: [PATCH] end game stats with better PlayingTime, tomreyns endgame color problem (maybe) fixed ,updated german lang file --- source/glest_game/game/game.cpp | 5 ++++ source/glest_game/game/stats.h | 10 ++++++++ source/glest_game/main/battle_end.cpp | 35 +++++++++++++-------------- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 34303684..b18088b3 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -833,6 +833,10 @@ void Game::update() { if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld [after ReplaceDisconnectedNetworkPlayersWithAI]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + if(updateLoops>0){ + // update the frame based timer in the stats with at least one step + world.getStats()->addFramesToCalculatePlaytime(); + } //update for(int i = 0; i < updateLoops; ++i) { chrono.start(); @@ -1782,6 +1786,7 @@ void Game::render2d(){ world.getStats()->setMaxConcurrentUnitCount(totalUnitcount); } world.getStats()->setTotalEndGameConcurrentUnitCount(totalUnitcount); + world.getStats()->setFramesPlayed(world.getFrameCount()); } if( renderer.getShowDebugUI() == true || diff --git a/source/glest_game/game/stats.h b/source/glest_game/game/stats.h index 99fda885..21b18996 100644 --- a/source/glest_game/game/stats.h +++ b/source/glest_game/game/stats.h @@ -73,6 +73,9 @@ private: int thisFactionIndex; float worldTimeElapsed; + int framesPlayed; + int framesToCalculatePlaytime; + time_t timePlayed; int maxConcurrentUnitCount; int totalEndGameConcurrentUnitCount; @@ -84,6 +87,8 @@ public: thisFactionIndex = 0; worldTimeElapsed = 0.0; + framesPlayed = 0; + framesToCalculatePlaytime = 0; maxConcurrentUnitCount = 0; totalEndGameConcurrentUnitCount = 0; } @@ -95,6 +100,8 @@ public: int getFactionCount() const {return factionCount;} float getWorldTimeElapsed() const {return worldTimeElapsed;} + int getFramesPlayed() const {return framesPlayed; } + int getFramesToCalculatePlaytime() const {return framesToCalculatePlaytime; } int getMaxConcurrentUnitCount() const {return maxConcurrentUnitCount; } int getTotalEndGameConcurrentUnitCount() const {return totalEndGameConcurrentUnitCount; } @@ -114,6 +121,7 @@ public: void setDescription(const string& description) {this->description = description;} void setWorldTimeElapsed(float value) {this->worldTimeElapsed = value;} + void setFramesPlayed(int value) {this->framesPlayed = value; } void setMaxConcurrentUnitCount(int value) {this->maxConcurrentUnitCount = value; } void setTotalEndGameConcurrentUnitCount(int value) {this->totalEndGameConcurrentUnitCount = value; } @@ -130,6 +138,8 @@ public: void setPlayerName(int playerIndex, string value) {playerStats[playerIndex].playerName = value; } void setPlayerColor(int playerIndex, Vec3f value) {playerStats[playerIndex].playerColor = value; } + void addFramesToCalculatePlaytime() {this->framesToCalculatePlaytime++; } + }; }}//end namespace diff --git a/source/glest_game/main/battle_end.cpp b/source/glest_game/main/battle_end.cpp index 086ba706..2fff4d6b 100644 --- a/source/glest_game/main/battle_end.cpp +++ b/source/glest_game/main/battle_end.cpp @@ -210,15 +210,11 @@ void BattleEnd::render(){ textRenderer->render((lang.get("Player") + " " + intToStr(i+1)).c_str(), textX, bm+400,false, &color); } + Vec3f highliteColor = Vec3f(WHITE.x,WHITE.y,WHITE.z); if(disableStatsColorCoding == false) { - color.x = 0.85; - color.y = 0.8; - color.z = 0.07; - } - else { - color.x = WHITE.x; - color.y = WHITE.y; - color.z = WHITE.z; + highliteColor.x = 0.85; + highliteColor.y = 0.8; + highliteColor.z = 0.07; } if(stats.getPersonalityType(i) == fpt_Observer) { @@ -226,7 +222,7 @@ void BattleEnd::render(){ } else { if(stats.getVictory(i)) { - textRenderer->render(stats.getVictory(i)? lang.get("Victory").c_str(): lang.get("Defeat").c_str(), textX, bm+360, false, &color); + textRenderer->render(stats.getVictory(i)? lang.get("Victory").c_str(): lang.get("Defeat").c_str(), textX, bm+360, false, &highliteColor); } else { textRenderer->render(stats.getVictory(i)? lang.get("Victory").c_str(): lang.get("Defeat").c_str(), textX, bm+360); @@ -238,37 +234,37 @@ void BattleEnd::render(){ textRenderer->render(intToStr(team).c_str(), textX, bm+240); if(kills == bestKills) { - textRenderer->render(intToStr(kills).c_str(), textX, bm+200, false,&color); + textRenderer->render(intToStr(kills).c_str(), textX, bm+200, false,&highliteColor); } else { textRenderer->render(intToStr(kills).c_str(), textX, bm+200); } if(enemykills == bestEnemyKills) { - textRenderer->render(intToStr(enemykills).c_str(), textX, bm+180, false , &color); + textRenderer->render(intToStr(enemykills).c_str(), textX, bm+180, false , &highliteColor); } else { textRenderer->render(intToStr(enemykills).c_str(), textX, bm+180); } if(deaths == leastDeaths) { - textRenderer->render(intToStr(deaths).c_str(), textX, bm+160,false,&color); + textRenderer->render(intToStr(deaths).c_str(), textX, bm+160,false,&highliteColor); } else { textRenderer->render(intToStr(deaths).c_str(), textX, bm+160); } if(unitsProduced == bestUnitsProduced) { - textRenderer->render(intToStr(unitsProduced).c_str(), textX, bm+120,false,&color); + textRenderer->render(intToStr(unitsProduced).c_str(), textX, bm+120,false,&highliteColor); } else { textRenderer->render(intToStr(unitsProduced).c_str(), textX, bm+120); } if(resourcesHarvested == bestResourcesHarvested) { - textRenderer->render(intToStr(resourcesHarvested).c_str(), textX, bm+80,false,&color); + textRenderer->render(intToStr(resourcesHarvested).c_str(), textX, bm+80,false,&highliteColor); } else { textRenderer->render(intToStr(resourcesHarvested).c_str(), textX, bm+80); } if(score == bestScore) { - textRenderer->render(intToStr(score).c_str(), textX, bm+20,false,&color); + textRenderer->render(intToStr(score).c_str(), textX, bm+20,false,&highliteColor); } else { textRenderer->render(intToStr(score).c_str(), textX, bm+20); @@ -301,13 +297,16 @@ void BattleEnd::render(){ textRenderer->render(header, lm+250, bm+550); - string header2 = lang.get("GameDuration") + " " + floatToStr(stats.getWorldTimeElapsed() / 24.0,2); + //GameConstants::updateFps + //string header2 = lang.get("GameDuration") + " " + floatToStr(stats.getWorldTimeElapsed() / 24.0,2); + + string header2 = lang.get("GameDuration") + ": " + intToStr(stats.getFramesToCalculatePlaytime()/GameConstants::updateFps/60); textRenderer->render(header2, lm+250, bm+530); - header2 = lang.get("GameMaxConcurrentUnitCount") + " " + intToStr(stats.getMaxConcurrentUnitCount()); + header2 = lang.get("GameMaxConcurrentUnitCount") + ": " + intToStr(stats.getMaxConcurrentUnitCount()); textRenderer->render(header2, lm+250, bm+510); - header2 = lang.get("GameTotalEndGameConcurrentUnitCount") + " " + intToStr(stats.getTotalEndGameConcurrentUnitCount()); + header2 = lang.get("GameTotalEndGameConcurrentUnitCount") + ": " + intToStr(stats.getTotalEndGameConcurrentUnitCount()); textRenderer->render(header2, lm+250, bm+490); textRenderer->end();