diff options
author | Sven Hesse | 2012-06-16 17:20:45 +0200 |
---|---|---|
committer | Sven Hesse | 2012-06-16 17:20:45 +0200 |
commit | b7ae6a93a983c7feaa7cf029967354bd176b8efc (patch) | |
tree | de2f5ab9b31a4d506e81a6400e274a496a623881 /engines | |
parent | 026ef70b87f4b85476cb6a3d74ffb9170a170718 (diff) | |
download | scummvm-rg350-b7ae6a93a983c7feaa7cf029967354bd176b8efc.tar.gz scummvm-rg350-b7ae6a93a983c7feaa7cf029967354bd176b8efc.tar.bz2 scummvm-rg350-b7ae6a93a983c7feaa7cf029967354bd176b8efc.zip |
GOB: Fix a segfault when quitting AJ's World
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gob/game.cpp | 11 | ||||
-rw-r--r-- | engines/gob/game.h | 4 | ||||
-rw-r--r-- | engines/gob/inter.cpp | 3 |
3 files changed, 18 insertions, 0 deletions
diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index 502a440005..0d1953322f 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -167,6 +167,13 @@ bool Environments::has(Resources *resources, uint8 startEnv, int16 except) const return false; } +void Environments::deleted(Variables *variables) { + for (uint i = 0; i < kEnvironmentCount; i++) { + if (_environments[i].variables == variables) + _environments[i].variables = 0; + } +} + bool Environments::clearMedia(uint8 env) { if (env >= kEnvironmentCount) return false; @@ -947,6 +954,10 @@ void Game::switchTotSub(int16 index, int16 function) { _environments.get(_curEnvironment); } +void Game::deletedVars(Variables *variables) { + _environments.deleted(variables); +} + void Game::clearUnusedEnvironment() { if (!_environments.has(_script)) { delete _script; diff --git a/engines/gob/game.h b/engines/gob/game.h index b3057ac262..995baa5629 100644 --- a/engines/gob/game.h +++ b/engines/gob/game.h @@ -52,6 +52,8 @@ public: bool has(Script *script , uint8 startEnv = 0, int16 except = -1) const; bool has(Resources *resources, uint8 startEnv = 0, int16 except = -1) const; + void deleted(Variables *variables); + void clear(); bool setMedia(uint8 env); @@ -169,6 +171,8 @@ public: void totSub(int8 flags, const Common::String &totFile); void switchTotSub(int16 index, int16 function); + void deletedVars(Variables *variables); + bool loadFunctions(const Common::String &tot, uint16 flags); bool callFunction(const Common::String &tot, const Common::String &function, int16 param); diff --git a/engines/gob/inter.cpp b/engines/gob/inter.cpp index 843c0bff48..4460274561 100644 --- a/engines/gob/inter.cpp +++ b/engines/gob/inter.cpp @@ -359,6 +359,9 @@ void Inter::allocateVars(uint32 count) { } void Inter::delocateVars() { + if (_vm->_game) + _vm->_game->deletedVars(_variables); + delete _variables; _variables = 0; } |