diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index c573ea0c..1285c2e1 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -65,6 +65,7 @@ Game::Game(Program *program, const GameSettings *gameSettings): captureAvgTestStatus = false; lastRenderLog2d = 0; totalRenderFps = 0; + lastMaxUnitCalcTime = 0; mouseMoved= false; quitTriggeredIndicator = false; @@ -1749,6 +1750,23 @@ void Game::render2d(){ string str=""; std::map factionDebugInfo; + world.getStats()->setWorldTimeElapsed(world.getTimeFlow()->getTime()); + + if(difftime(time(NULL),lastMaxUnitCalcTime) >= 1) { + lastMaxUnitCalcTime = time(NULL); + + int totalUnitcount = 0; + for(int i = 0; i < world.getFactionCount(); ++i) { + Faction *faction= world.getFaction(i); + totalUnitcount += faction->getUnitCount(); + } + + if(world.getStats()->getMaxConcurrentUnitCount() < totalUnitcount) { + world.getStats()->setMaxConcurrentUnitCount(totalUnitcount); + } + world.getStats()->setTotalEndGameConcurrentUnitCount(totalUnitcount); + } + if( renderer.getShowDebugUI() == true || (perfLogging == true && difftime(time(NULL),lastRenderLog2d) >= 1)) { str+= "MouseXY: " + intToStr(mouseX) + "," + intToStr(mouseY)+"\n"; diff --git a/source/glest_game/game/game.h b/source/glest_game/game/game.h index 2a63e6fd..6efc5784 100644 --- a/source/glest_game/game/game.h +++ b/source/glest_game/game/game.h @@ -114,6 +114,8 @@ private: bool gameStarted; + time_t lastMaxUnitCalcTime; + public: Game(); Game(Program *program, const GameSettings *gameSettings); diff --git a/source/glest_game/game/stats.cpp b/source/glest_game/game/stats.cpp index ce1fb924..0ccdadde 100644 --- a/source/glest_game/game/stats.cpp +++ b/source/glest_game/game/stats.cpp @@ -29,9 +29,12 @@ void Stats::setVictorious(int playerIndex){ playerStats[playerIndex].victory= true; } -void Stats::kill(int killerFactionIndex, int killedFactionIndex){ +void Stats::kill(int killerFactionIndex, int killedFactionIndex, bool isEnemy) { playerStats[killerFactionIndex].kills++; playerStats[killedFactionIndex].deaths++; + if(isEnemy == true) { + playerStats[killerFactionIndex].enemykills++; + } } void Stats::die(int diedFactionIndex){ diff --git a/source/glest_game/game/stats.h b/source/glest_game/game/stats.h index b828a5ac..99fda885 100644 --- a/source/glest_game/game/stats.h +++ b/source/glest_game/game/stats.h @@ -35,6 +35,7 @@ public: teamIndex = 0; victory = false; kills = 0; + enemykills = 0; deaths = 0; unitsProduced = 0; resourcesHarvested = 0; @@ -49,6 +50,7 @@ public: int teamIndex; bool victory; int kills; + int enemykills; int deaths; int unitsProduced; int resourcesHarvested; @@ -70,25 +72,40 @@ private: int factionCount; int thisFactionIndex; + float worldTimeElapsed; + int maxConcurrentUnitCount; + int totalEndGameConcurrentUnitCount; + public: Stats() { - description = ""; - factionCount = 0; - thisFactionIndex = 0; + description = ""; + factionCount = 0; + thisFactionIndex = 0; + + worldTimeElapsed = 0.0; + maxConcurrentUnitCount = 0; + totalEndGameConcurrentUnitCount = 0; } + void init(int factionCount, int thisFactionIndex, const string &description); string getDescription() const {return description;} int getThisFactionIndex() const {return thisFactionIndex;} int getFactionCount() const {return factionCount;} + + float getWorldTimeElapsed() const {return worldTimeElapsed;} + int getMaxConcurrentUnitCount() const {return maxConcurrentUnitCount; } + int getTotalEndGameConcurrentUnitCount() const {return totalEndGameConcurrentUnitCount; } + const string &getFactionTypeName(int factionIndex) const {return playerStats[factionIndex].factionTypeName;} FactionPersonalityType getPersonalityType(int factionIndex) const { return playerStats[factionIndex].personalityType;} ControlType getControl(int factionIndex) const {return playerStats[factionIndex].control;} - float getResourceMultiplier(int factionIndex) const {return playerStats[factionIndex].resourceMultiplier;} + float getResourceMultiplier(int factionIndex) const {return playerStats[factionIndex].resourceMultiplier;} bool getVictory(int factionIndex) const {return playerStats[factionIndex].victory;} int getTeam(int factionIndex) const {return playerStats[factionIndex].teamIndex;} int getKills(int factionIndex) const {return playerStats[factionIndex].kills;} + int getEnemyKills(int factionIndex) const {return playerStats[factionIndex].enemykills;} int getDeaths(int factionIndex) const {return playerStats[factionIndex].deaths;} int getUnitsProduced(int factionIndex) const {return playerStats[factionIndex].unitsProduced;} int getResourcesHarvested(int factionIndex) const {return playerStats[factionIndex].resourcesHarvested;} @@ -96,13 +113,17 @@ public: Vec3f getPlayerColor(int factionIndex) const { return playerStats[factionIndex].playerColor;} void setDescription(const string& description) {this->description = description;} + void setWorldTimeElapsed(float value) {this->worldTimeElapsed = value;} + void setMaxConcurrentUnitCount(int value) {this->maxConcurrentUnitCount = value; } + void setTotalEndGameConcurrentUnitCount(int value) {this->totalEndGameConcurrentUnitCount = value; } + void setFactionTypeName(int playerIndex, const string& factionTypeName) {playerStats[playerIndex].factionTypeName= factionTypeName;} - void setPersonalityType(int playerIndex, FactionPersonalityType value) { playerStats[playerIndex].personalityType = value;} + void setPersonalityType(int playerIndex, FactionPersonalityType value) {playerStats[playerIndex].personalityType = value;} void setControl(int playerIndex, ControlType control) {playerStats[playerIndex].control= control;} void setResourceMultiplier(int playerIndex, float resourceMultiplier) {playerStats[playerIndex].resourceMultiplier= resourceMultiplier;} void setTeam(int playerIndex, int teamIndex) {playerStats[playerIndex].teamIndex= teamIndex;} void setVictorious(int playerIndex); - void kill(int killerFactionIndex, int killedFactionIndex); + void kill(int killerFactionIndex, int killedFactionIndex, bool isEnemy); void die(int diedFactionIndex); void produce(int producerFactionIndex); void harvest(int harvesterFactionIndex, int amount); diff --git a/source/glest_game/main/battle_end.cpp b/source/glest_game/main/battle_end.cpp index 7a816d60..6a3ed456 100644 --- a/source/glest_game/main/battle_end.cpp +++ b/source/glest_game/main/battle_end.cpp @@ -89,11 +89,12 @@ void BattleEnd::render(){ int textX= lm+160+i*100; int team= stats.getTeam(i) + 1; int kills= stats.getKills(i); + int enemykills= stats.getEnemyKills(i); int deaths= stats.getDeaths(i); int unitsProduced= stats.getUnitsProduced(i); int resourcesHarvested= stats.getResourcesHarvested(i); - int score= kills*100 + unitsProduced*50 + resourcesHarvested/10; + int score= enemykills*100 + unitsProduced*50 + resourcesHarvested/10; string controlString; if(stats.getPersonalityType(i) == fpt_Observer) { @@ -161,6 +162,7 @@ void BattleEnd::render(){ textRenderer->render(stats.getFactionTypeName(i), textX, bm+280); textRenderer->render(intToStr(team).c_str(), textX, bm+240); textRenderer->render(intToStr(kills).c_str(), textX, bm+200); + textRenderer->render(intToStr(enemykills).c_str(), textX, bm+180); textRenderer->render(intToStr(deaths).c_str(), textX, bm+160); textRenderer->render(intToStr(unitsProduced).c_str(), textX, bm+120); textRenderer->render(intToStr(resourcesHarvested).c_str(), textX, bm+80); @@ -172,6 +174,7 @@ void BattleEnd::render(){ textRenderer->render(lang.get("Faction"), lm, bm+280); textRenderer->render(lang.get("Team"), lm, bm+240); textRenderer->render(lang.get("Kills"), lm, bm+200); + textRenderer->render(lang.get("EnemyKills"), lm, bm+180); textRenderer->render(lang.get("Deaths"), lm, bm+160); textRenderer->render(lang.get("UnitsProduced"), lm, bm+120); textRenderer->render(lang.get("ResourcesHarvested"), lm, bm+80); @@ -192,6 +195,15 @@ void BattleEnd::render(){ textRenderer->render(header, lm+250, bm+550); + string header2 = lang.get("GameDuration") + " " + floatToStr(stats.getWorldTimeElapsed() / 24.0,2); + textRenderer->render(header2, lm+250, bm+530); + + header2 = lang.get("GameMaxConcurrentUnitCount") + " " + intToStr(stats.getMaxConcurrentUnitCount()); + textRenderer->render(header2, lm+250, bm+510); + + header2 = lang.get("GameTotalEndGameConcurrentUnitCount") + " " + intToStr(stats.getTotalEndGameConcurrentUnitCount()); + textRenderer->render(header2, lm+250, bm+490); + textRenderer->end(); renderer.renderButton(&buttonExit); diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index 0cae7b91..ec09dfe8 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -1819,7 +1819,7 @@ void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attac //damage the unit if(attacked->decHp(static_cast(damage))){ - world->getStats()->kill(attacker->getFactionIndex(), attacked->getFactionIndex()); + world->getStats()->kill(attacker->getFactionIndex(), attacked->getFactionIndex(), attacker->getTeam() != attacked->getTeam()); attacker->incKills(); switch(this->game->getGameSettings()->getPathFinderType()) {