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/world.cpp | |
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/world.cpp')
-rw-r--r-- | engines/macventure/world.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
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; |