From c63283ffac6aad10b2172ad8b7b265c03697b79c Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 4 Aug 2010 16:56:24 +0000 Subject: [PATCH] - another attempt to fix game end crash for ultifd --- source/glest_game/game/game.cpp | 3 ++- source/glest_game/main/program.cpp | 5 +++++ source/glest_game/type_instances/faction.cpp | 20 ++++++++++++++++++++ source/glest_game/type_instances/faction.h | 3 +++ source/glest_game/world/world.cpp | 6 ++++++ 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index c982e6f8..904e187d 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -110,7 +110,7 @@ Game::~Game(){ world.end(); //must die before selection because of referencers - //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__); } // ==================== init and load ==================== @@ -555,6 +555,7 @@ void Game::update(){ errorMessageBox.getEnabled() == false) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); quitGame(); + return; } //update auto test diff --git a/source/glest_game/main/program.cpp b/source/glest_game/main/program.cpp index c1c16ae7..3279b702 100644 --- a/source/glest_game/main/program.cpp +++ b/source/glest_game/main/program.cpp @@ -344,7 +344,12 @@ void Program::setState(ProgramState *programState, bool cleanupOldState) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); delete this->programState; + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + this->programState = NULL; + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } } diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index 2ba68496..f3d25b9a 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -31,6 +31,26 @@ namespace Glest{ namespace Game{ // class Faction // ===================================================== +Faction::Faction() { + texture = NULL; +} + +Faction::~Faction() { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + Renderer &renderer= Renderer::getInstance(); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + //renderer.endTexture(rsGame,texture); + //texture->end(); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + //delete texture; + texture = NULL; + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); +} + void Faction::init( const FactionType *factionType, ControlType control, TechTree *techTree, Game *game, int factionIndex, int teamIndex, int startLocationIndex, bool thisFaction, bool giveResources) diff --git a/source/glest_game/type_instances/faction.h b/source/glest_game/type_instances/faction.h index bbcf17b9..32ecc3ef 100644 --- a/source/glest_game/type_instances/faction.h +++ b/source/glest_game/type_instances/faction.h @@ -76,6 +76,9 @@ private: bool thisFaction; public: + Faction(); + ~Faction(); + void init( const FactionType *factionType, ControlType control, TechTree *techTree, Game *game, int factionIndex, int teamIndex, int startLocationIndex, bool thisFaction, bool giveResources); diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index 42c2f2c7..5ad94ab4 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -80,8 +80,14 @@ World::~World() { delete techTree; techTree = NULL; + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + delete routePlanner; routePlanner = 0; + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + delete cartographer; cartographer = 0; SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);