- another attempt to fix ultifd's game end issue

This commit is contained in:
Mark Vejvoda 2010-08-06 03:55:17 +00:00
parent 0f231f28e6
commit dfeea6fc0a
4 changed files with 37 additions and 15 deletions

View File

@ -1126,10 +1126,13 @@ void Game::keyPress(char c){
void Game::quitGame(){ void Game::quitGame(){
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
Stats stats = *(world.getStats()); //Stats stats = *(world.getStats());
Stats *endStats = new Stats();
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
*endStats = *(world.getStats());
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
NetworkManager::getInstance().end(); NetworkManager::getInstance().end();
@ -1137,7 +1140,16 @@ void Game::quitGame(){
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
program->setState(new BattleEnd(program, &stats)); ProgramState *newState = new BattleEnd(program, endStats);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
delete endStats;
endStats = NULL;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
program->setState(newState);
} }
// ==================== PRIVATE ==================== // ==================== PRIVATE ====================

View File

@ -15,16 +15,6 @@
namespace Glest{ namespace Game{ namespace Glest{ namespace Game{
PlayerStats::PlayerStats(){
victory= false;
kills= 0;
deaths= 0;
unitsProduced= 0;
resourcesHarvested= 0;
playerName = "";
}
// ===================================================== // =====================================================
// class Stats // class Stats
// ===================================================== // =====================================================

View File

@ -23,8 +23,20 @@ using namespace Shared::Graphics;
namespace Glest{ namespace Game{ namespace Glest{ namespace Game{
struct PlayerStats{ class PlayerStats {
PlayerStats(); public:
PlayerStats() {
control = ctClosed;
factionTypeName = "";
teamIndex = 0;
victory = false;
kills = 0;
deaths = 0;
unitsProduced = 0;
resourcesHarvested = 0;
playerName = "";
playerColor = Vec3f(0,0,0);
}
ControlType control; ControlType control;
string factionTypeName; string factionTypeName;
@ -44,7 +56,7 @@ struct PlayerStats{
/// Player statistics that are shown after the game ends /// Player statistics that are shown after the game ends
// ===================================================== // =====================================================
class Stats{ class Stats {
private: private:
PlayerStats playerStats[GameConstants::maxPlayers]; PlayerStats playerStats[GameConstants::maxPlayers];
@ -53,6 +65,12 @@ private:
int thisFactionIndex; int thisFactionIndex;
public: public:
Stats() {
description = "";
factionCount = 0;
thisFactionIndex = 0;
}
void init(int factionCount, int thisFactionIndex, const string &description); void init(int factionCount, int thisFactionIndex, const string &description);
string getDescription() const {return description;} string getDescription() const {return description;}

View File

@ -232,7 +232,9 @@ void Program::loopWorker() {
assert(programState != NULL); assert(programState != NULL);
if(this->programState->quitTriggered() == true) { if(this->programState->quitTriggered() == true) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
this->programState->quitAndToggleState(); this->programState->quitAndToggleState();
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
return; return;
} }
ProgramState *prevState = this->programState; ProgramState *prevState = this->programState;