diff options
author | johndoe123 | 2013-01-08 01:19:52 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:47:39 +0200 |
commit | 30178e46e522c6d741e82e282f3f3edc1fab4825 (patch) | |
tree | a40f689a6f72334bcb9e8776291c8f8b63bd1a0e /engines/neverhood | |
parent | a35cd088e52eced55d5c0f8253773e9d940b8373 (diff) | |
download | scummvm-rg350-30178e46e522c6d741e82e282f3f3edc1fab4825.tar.gz scummvm-rg350-30178e46e522c6d741e82e282f3f3edc1fab4825.tar.bz2 scummvm-rg350-30178e46e522c6d741e82e282f3f3edc1fab4825.zip |
NEVERHOOD: Implement savegame loading via GMM (in-game saving/loading still TODO)
Diffstat (limited to 'engines/neverhood')
-rw-r--r-- | engines/neverhood/gamemodule.cpp | 13 | ||||
-rw-r--r-- | engines/neverhood/gamemodule.h | 1 | ||||
-rw-r--r-- | engines/neverhood/gamevars.cpp | 1 | ||||
-rw-r--r-- | engines/neverhood/gamevars.h | 2 | ||||
-rw-r--r-- | engines/neverhood/module1200.cpp | 3 | ||||
-rw-r--r-- | engines/neverhood/saveload.cpp | 10 |
6 files changed, 26 insertions, 4 deletions
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp index 548b3585cd..823f89a05a 100644 --- a/engines/neverhood/gamemodule.cpp +++ b/engines/neverhood/gamemodule.cpp @@ -437,6 +437,15 @@ void GameModule::startup() { #endif } +void GameModule::restoreGame() { + delete _childObject; + delete _prevChildObject; + _childObject = NULL; + _prevChildObject = NULL; + _prevModuleNum = 0; + createModuleByHash(getGlobalVar(V_MODULE_NAME)); +} + void GameModule::checkMainMenu() { if (_mainMenuRequested) openMainMenu(); @@ -544,6 +553,7 @@ void GameModule::createModule(int moduleNum, int which) { } void GameModule::createModuleByHash(uint32 nameHash) { + debug("GameModule::createModuleByHash(%08X)", nameHash); switch (nameHash) { case 0x03294419: createModule(1000, -1); @@ -833,7 +843,7 @@ void GameModule::updateMenuModule() { _moduleNum = _prevModuleNum; SetUpdateHandler(&GameModule::updateModule); } else if (_gameWasLoaded) { - debug("_gameWasLoaded!"); +#if 0 // TODO Handle this in some other way... _gameWasLoaded = false; delete _childObject; delete _prevChildObject; @@ -842,6 +852,7 @@ void GameModule::updateMenuModule() { _prevModuleNum = 0; // TODO Create module from savegame values... // TODO createModuleByHash(...); +#endif } } diff --git a/engines/neverhood/gamemodule.h b/engines/neverhood/gamemodule.h index 53adb859f8..93373a1a3f 100644 --- a/engines/neverhood/gamemodule.h +++ b/engines/neverhood/gamemodule.h @@ -33,6 +33,7 @@ public: GameModule(NeverhoodEngine *vm); virtual ~GameModule(); void startup(); + void restoreGame(); void checkMainMenu(); void handleMouseMove(int16 x, int16 y); void handleMouseDown(int16 x, int16 y); diff --git a/engines/neverhood/gamevars.cpp b/engines/neverhood/gamevars.cpp index 558543fa31..7bf9f30e25 100644 --- a/engines/neverhood/gamevars.cpp +++ b/engines/neverhood/gamevars.cpp @@ -41,6 +41,7 @@ void GameVars::loadState(Common::InSaveFile *in) { var.value = in->readUint32LE(); var.firstIndex = in->readUint16LE(); var.nextIndex = in->readUint16LE(); + _vars.push_back(var); } } diff --git a/engines/neverhood/gamevars.h b/engines/neverhood/gamevars.h index 36fcebcbb8..a62b33c297 100644 --- a/engines/neverhood/gamevars.h +++ b/engines/neverhood/gamevars.h @@ -32,6 +32,8 @@ namespace Neverhood { enum { // Misc V_MODULE_NAME = 0x91080831, // Currently active module name hash + V_CURRENT_SCENE = 0x108A4870, // Current scene in the current module + V_CURRENT_SCENE_WHICH = 0x82C80875, V_DEBUG = 0xA4014072, // Original debug-flag, can probably be removed V_SMACKER_CAN_ABORT = 0x06C02850, // Not set anywhere (yet), seems like a debug flag V_KEY3_LOCATION = 0x13382860, // Location of the third key diff --git a/engines/neverhood/module1200.cpp b/engines/neverhood/module1200.cpp index 98ec012fb5..e86aa003ee 100644 --- a/engines/neverhood/module1200.cpp +++ b/engines/neverhood/module1200.cpp @@ -1025,7 +1025,7 @@ Scene1202::Scene1202(NeverhoodEngine *vm, Module *parentModule) playSound(0, 0x40106542); loadSound(1, 0x40005446); - loadSound(2, 0x40005446); + loadSound(2, 0x40005446); // Same sound as slot 1 loadSound(3, 0x68E25540); } @@ -1049,6 +1049,7 @@ void Scene1202::update() { playSound(3); _isPuzzleSolved = true; } else if (_clickedIndex >= 0 && _counter == 0) { + // Swap TNT positions int destIndex = kScene1202Table[_clickedIndex]; sendMessage(_asTntItems[_clickedIndex], 0x2001, getSubVar(VA_TNT_POSITIONS, destIndex)); sendMessage(_asTntItems[destIndex], 0x2001, getSubVar(VA_TNT_POSITIONS, _clickedIndex)); diff --git a/engines/neverhood/saveload.cpp b/engines/neverhood/saveload.cpp index 851943d61f..e1ef95477b 100644 --- a/engines/neverhood/saveload.cpp +++ b/engines/neverhood/saveload.cpp @@ -26,6 +26,7 @@ #include "graphics/thumbnail.h" #include "neverhood/neverhood.h" +#include "neverhood/gamemodule.h" #include "neverhood/gamevars.h" namespace Neverhood { @@ -91,8 +92,8 @@ void NeverhoodEngine::savegame(const char *filename, const char *description) { out->writeUint32LE(playTime); // Header end - _gameVars->setGlobalVar(0x108A4870, _gameState.sceneNum); - _gameVars->setGlobalVar(0x82C80875, _gameState.which); + _gameVars->setGlobalVar(V_CURRENT_SCENE, _gameState.sceneNum); + _gameVars->setGlobalVar(V_CURRENT_SCENE_WHICH, _gameState.which); _gameVars->saveState(out); @@ -121,6 +122,11 @@ void NeverhoodEngine::loadgame(const char *filename) { _gameVars->loadState(in); + _gameState.sceneNum = _gameVars->getGlobalVar(V_CURRENT_SCENE); + _gameState.which = _gameVars->getGlobalVar(V_CURRENT_SCENE_WHICH); + + _gameModule->restoreGame(); + delete in; } |