diff options
author | Filippos Karapetis | 2015-01-19 23:52:08 +0200 |
---|---|---|
committer | Filippos Karapetis | 2015-01-19 23:54:41 +0200 |
commit | dcac5be493a98764239619d5da60d6bc0f608383 (patch) | |
tree | 883ee1972ea6a9044c0b90bfa36dfe10c18d2a9c /engines/zvision/scripting | |
parent | ecc45b961f732c013053632db80976c878fad410 (diff) | |
download | scummvm-rg350-dcac5be493a98764239619d5da60d6bc0f608383.tar.gz scummvm-rg350-dcac5be493a98764239619d5da60d6bc0f608383.tar.bz2 scummvm-rg350-dcac5be493a98764239619d5da60d6bc0f608383.zip |
ZVISION: Simplify the checks in the location changing code
Diffstat (limited to 'engines/zvision/scripting')
-rw-r--r-- | engines/zvision/scripting/script_manager.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index df74fd69dc..bcc1f0a5ff 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -564,12 +564,16 @@ void ScriptManager::ChangeLocationReal() { assert(_nextLocation.world != 0); debug(1, "Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset); - if (_nextLocation.world == 'g' && _nextLocation.room == 'j' && !ConfMan.getBool("originalsaveload")) { - if ((_nextLocation.node == 's' || _nextLocation.node == 'r') && _nextLocation.view == 'e') { + const bool enteringMenu = (_nextLocation.world == 'g' && _nextLocation.room == 'j'); + const bool leavingMenu = (_currentLocation.world == 'g' && _currentLocation.room == 'j'); + const bool isSaveScreen = (enteringMenu && _nextLocation.node == 's' && _nextLocation.view == 'e'); + const bool isRestoreScreen = (enteringMenu && _nextLocation.node == 'r' && _nextLocation.view == 'e'); + + if (enteringMenu && !ConfMan.getBool("originalsaveload")) { + if (isSaveScreen || isRestoreScreen) { // Hook up the ScummVM save/restore dialog - bool isSave = (_nextLocation.node == 's'); - bool gameSavedOrLoaded = _engine->getSaveManager()->scummVMSaveLoadDialog(isSave); - if (!gameSavedOrLoaded || isSave) { + bool gameSavedOrLoaded = _engine->getSaveManager()->scummVMSaveLoadDialog(isSaveScreen); + if (!gameSavedOrLoaded || isSaveScreen) { // Reload the current room _nextLocation.world = _currentLocation.world; _nextLocation.room = _currentLocation.room; @@ -590,30 +594,26 @@ void ScriptManager::ChangeLocationReal() { _engine->setRenderDelay(2); - if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') { - if (_nextLocation.world != 'g' || _nextLocation.room != 'j') { + if (!enteringMenu) { + if (!leavingMenu) { setStateValue(StateKey_LastWorld, getStateValue(StateKey_World)); setStateValue(StateKey_LastRoom, getStateValue(StateKey_Room)); setStateValue(StateKey_LastNode, getStateValue(StateKey_Node)); setStateValue(StateKey_LastView, getStateValue(StateKey_View)); setStateValue(StateKey_LastViewPos, getStateValue(StateKey_ViewPos)); - } else { - setStateValue(StateKey_Menu_LastWorld, getStateValue(StateKey_World)); - setStateValue(StateKey_Menu_LastRoom, getStateValue(StateKey_Room)); - setStateValue(StateKey_Menu_LastNode, getStateValue(StateKey_Node)); - setStateValue(StateKey_Menu_LastView, getStateValue(StateKey_View)); - setStateValue(StateKey_Menu_LastViewPos, getStateValue(StateKey_ViewPos)); } + } else { + setStateValue(StateKey_Menu_LastWorld, getStateValue(StateKey_World)); + setStateValue(StateKey_Menu_LastRoom, getStateValue(StateKey_Room)); + setStateValue(StateKey_Menu_LastNode, getStateValue(StateKey_Node)); + setStateValue(StateKey_Menu_LastView, getStateValue(StateKey_View)); + setStateValue(StateKey_Menu_LastViewPos, getStateValue(StateKey_ViewPos)); } - if (_nextLocation.world == 'g' && _nextLocation.room == 'j') { - if (_nextLocation.node == 's' && _nextLocation.view == 'e' && _currentLocation.world != 'g') { - _engine->getSaveManager()->prepareSaveBuffer(); - } - } else { - if (_currentLocation.world == 'g' && _currentLocation.room == 'j') { - _engine->getSaveManager()->flushSaveBuffer(); - } + if (isSaveScreen && !leavingMenu) { + _engine->getSaveManager()->prepareSaveBuffer(); + } else if (leavingMenu) { + _engine->getSaveManager()->flushSaveBuffer(); } setStateValue(StateKey_World, _nextLocation.world); |