From ffc4af820f9dbdb6af75ce15c56e3677db3af567 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sat, 29 Jan 2011 22:48:44 +0000 Subject: [PATCH] GOB: _environments doesn't need to be a pointer svn-id: r55636 --- engines/gob/game.cpp | 30 ++++++++++++++---------------- engines/gob/game.h | 6 +++--- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index b913b2dd8cd..6bf0f3c1f5a 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -247,7 +247,7 @@ bool Environments::getMedia(uint8 env) { } -Game::Game(GobEngine *vm) : _vm(vm) { +Game::Game(GobEngine *vm) : _vm(vm), _environments(_vm) { _captureCount = 0; _startTimeKey = 0; @@ -267,14 +267,12 @@ Game::Game(GobEngine *vm) : _vm(vm) { _numEnvironments = 0; _curEnvironment = 0; - _environments = new Environments(_vm); - _script = new Script(_vm); - _resources = new Resources(_vm); - _hotspots = new Hotspots(_vm); + _script = new Script(_vm); + _resources = new Resources(_vm); + _hotspots = new Hotspots(_vm); } Game::~Game() { - delete _environments; delete _script; delete _resources; delete _hotspots; @@ -644,11 +642,11 @@ void Game::totSub(int8 flags, const Common::String &totFile) { if (_numEnvironments >= Environments::kEnvironmentCount) error("Game::totSub(): Environments overflow"); - _environments->set(_numEnvironments); + _environments.set(_numEnvironments); if (flags == 18) { warning("Backuping media to %d", _numEnvironments); - _environments->setMedia(_numEnvironments); + _environments.setMedia(_numEnvironments); } curBackupPos = _curEnvironment; @@ -694,11 +692,11 @@ void Game::totSub(int8 flags, const Common::String &totFile) { _numEnvironments--; _curEnvironment = curBackupPos; - _environments->get(_numEnvironments); + _environments.get(_numEnvironments); if (flags == 18) { warning("Restoring media from %d", _numEnvironments); - _environments->getMedia(_numEnvironments); + _environments.getMedia(_numEnvironments); } _vm->_global->_inter_animDataSize = _script->getAnimDataSize(); @@ -718,13 +716,13 @@ void Game::switchTotSub(int16 index, int16 function) { // WORKAROUND: Some versions don't make the MOVEMENT menu item unselectable // in the dreamland screen, resulting in a crash when it's clicked. if ((_vm->getGameType() == kGameTypeGob2) && (index == -1) && (function == 7) && - _environments->getTotFile(newPos).equalsIgnoreCase("gob06.tot")) + _environments.getTotFile(newPos).equalsIgnoreCase("gob06.tot")) return; curBackupPos = _curEnvironment; backupedCount = _numEnvironments; if (_curEnvironment == _numEnvironments) - _environments->set(_numEnvironments++); + _environments.set(_numEnvironments++); _curEnvironment -= index; if (index >= 0) @@ -732,7 +730,7 @@ void Game::switchTotSub(int16 index, int16 function) { clearUnusedEnvironment(); - _environments->get(_curEnvironment); + _environments.get(_curEnvironment); if (_vm->_inter->_terminate != 0) { clearUnusedEnvironment(); @@ -751,15 +749,15 @@ void Game::switchTotSub(int16 index, int16 function) { _curEnvironment = curBackupPos; _numEnvironments = backupedCount; - _environments->get(_curEnvironment); + _environments.get(_curEnvironment); } void Game::clearUnusedEnvironment() { - if (!_environments->has(_script)) { + if (!_environments.has(_script)) { delete _script; _script = 0; } - if (!_environments->has(_resources)) { + if (!_environments.has(_resources)) { delete _resources; _resources = 0; } diff --git a/engines/gob/game.h b/engines/gob/game.h index 8a67eb29fc6..82e73678d59 100644 --- a/engines/gob/game.h +++ b/engines/gob/game.h @@ -128,6 +128,8 @@ public: void switchTotSub(int16 index, int16 function); protected: + GobEngine *_vm; + char _tempStr[256]; // Capture @@ -137,9 +139,7 @@ protected: // For totSub() int8 _curEnvironment; int8 _numEnvironments; - Environments *_environments; - - GobEngine *_vm; + Environments _environments; void clearUnusedEnvironment(); };