diff options
author | Borja Lorente | 2016-08-10 16:45:14 +0200 |
---|---|---|
committer | Borja Lorente | 2016-08-19 16:29:16 +0200 |
commit | 1d5b7a6e19377c0b279c337ef4ca60749b31f6c9 (patch) | |
tree | eb41a9dc48f22c5e042d75d53bdaf14a7271892a /engines/macventure | |
parent | c8a2b0afe29da6daab4f448f1eb0acc108cdf8ae (diff) | |
download | scummvm-rg350-1d5b7a6e19377c0b279c337ef4ca60749b31f6c9.tar.gz scummvm-rg350-1d5b7a6e19377c0b279c337ef4ca60749b31f6c9.tar.bz2 scummvm-rg350-1d5b7a6e19377c0b279c337ef4ca60749b31f6c9.zip |
MACVENTURE: Refactor world to extract new game method
Diffstat (limited to 'engines/macventure')
-rw-r--r-- | engines/macventure/macventure.cpp | 2 | ||||
-rw-r--r-- | engines/macventure/world.cpp | 33 | ||||
-rw-r--r-- | engines/macventure/world.h | 2 |
3 files changed, 25 insertions, 12 deletions
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp index b3b3463cf5..37e1472338 100644 --- a/engines/macventure/macventure.cpp +++ b/engines/macventure/macventure.cpp @@ -304,7 +304,7 @@ void MacVentureEngine::winGame() { void MacVentureEngine::loseGame() { _gui->showPrebuiltDialog(kWinGameDialog); _paused = true; - _gameState = kGameStateLosing; + //_gameState = kGameStateLosing; } void MacVentureEngine::clickToContinue() { diff --git a/engines/macventure/world.cpp b/engines/macventure/world.cpp index 012e872272..2c9b55c6ab 100644 --- a/engines/macventure/world.cpp +++ b/engines/macventure/world.cpp @@ -8,25 +8,17 @@ namespace MacVenture { World::World(MacVentureEngine *engine, Common::MacResManager *resMan) { _resourceManager = resMan; _engine = engine; + _saveGame = NULL; - if ((_startGameFileName = _engine->getStartGameFileName()) == "") - error("Could not load initial game configuration"); - Common::File saveGameFile; - if (!saveGameFile.open(_startGameFileName)) - error("Could not load initial game configuration"); + startNewGame(); - debug("Loading save game state from %s", _startGameFileName.c_str()); - Common::SeekableReadStream *saveGameRes = saveGameFile.readStream(saveGameFile.size()); + //_-------------------- - _saveGame = new SaveGame(_engine, saveGameRes); _objectConstants = new Container(_engine->getFilePath(kObjectPathID)); calculateObjectRelations(); _gameText = new Container(_engine->getFilePath(kTextPathID)); - - delete saveGameRes; - saveGameFile.close(); } @@ -39,6 +31,25 @@ World::~World() { delete _objectConstants; } +void World::startNewGame() { + if (_saveGame) + delete _saveGame; + + if ((_startGameFileName = _engine->getStartGameFileName()) == "") + error("Could not load initial game configuration"); + + Common::File saveGameFile; + if (!saveGameFile.open(_startGameFileName)) + error("Could not load initial game configuration"); + + debug("Loading save game state from %s", _startGameFileName.c_str()); + Common::SeekableReadStream *saveGameRes = saveGameFile.readStream(saveGameFile.size()); + + _saveGame = new SaveGame(_engine, saveGameRes); + + delete saveGameRes; + saveGameFile.close(); +} uint32 World::getObjAttr(ObjID objID, uint32 attrID) { uint res; diff --git a/engines/macventure/world.h b/engines/macventure/world.h index f3933c5f7e..e78ab7f0db 100644 --- a/engines/macventure/world.h +++ b/engines/macventure/world.h @@ -92,6 +92,8 @@ public: World(MacVentureEngine *engine, Common::MacResManager *resMan); ~World(); + void startNewGame(); + void setObjAttr(ObjID objID, uint32 attrID, Attribute value); void setGlobal(uint32 attrID, Attribute value); void updateObj(ObjID objID); |