Disconnect time of early leavers is shown in end game stats.

This commit is contained in:
Titus Tscharntke
2012-07-20 22:24:27 +00:00
parent c42d44a53a
commit ed6961195f
4 changed files with 16 additions and 2 deletions

View File

@@ -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());
}
}

View File

@@ -29,6 +29,7 @@ PlayerStats::PlayerStats() {
resourcesHarvested = 0;
playerName = "";
playerLeftBeforeEnd = false;
timePlayerLeft = -1;
playerColor = Vec3f(0,0,0);
}

View File

@@ -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++; }

View File

@@ -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);