From 569833b4ca80116efaab15e47d0097b5c62ecb6c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 7 Apr 2018 15:41:16 -0400 Subject: [PATCH] XEEN: Reset combat data when loading a new savegame --- engines/xeen/combat.cpp | 7 +++++++ engines/xeen/combat.h | 5 +++++ engines/xeen/saves.cpp | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp index 2293dcd6126..71ad6303a8d 100644 --- a/engines/xeen/combat.cpp +++ b/engines/xeen/combat.cpp @@ -2095,4 +2095,11 @@ bool Combat::areMonstersPresent() const { return false; } +void Combat::reset() { + clearShooting(); + setupCombatParty(); + + _combatMode = COMBATMODE_STARTUP; +} + } // End of namespace Xeen diff --git a/engines/xeen/combat.h b/engines/xeen/combat.h index c3fa987fb13..e55c8b7553b 100644 --- a/engines/xeen/combat.h +++ b/engines/xeen/combat.h @@ -204,6 +204,11 @@ public: */ void clearShooting(); + /** + * Resets all combat related data + */ + void reset(); + /** * Gives damage to character or characters in the party */ diff --git a/engines/xeen/saves.cpp b/engines/xeen/saves.cpp index 2f290960d3a..4aee1a6a347 100644 --- a/engines/xeen/saves.cpp +++ b/engines/xeen/saves.cpp @@ -152,6 +152,7 @@ Common::Error SavesManager::saveGameState(int slot, const Common::String &desc) } Common::Error SavesManager::loadGameState(int slot) { + Combat &combat = *g_vm->_combat; EventsManager &events = *g_vm->_events; FileManager &files = *g_vm->_files; Map &map = *g_vm->_map; @@ -187,6 +188,9 @@ Common::Error SavesManager::loadGameState(int slot) { // Read in miscellaneous files.load(*saveFile); + // Reset any combat information from the previous game + combat.reset(); + // Load the new map map.clearMaze(); map._loadCcNum = files._ccNum; @@ -206,6 +210,10 @@ void SavesManager::newGame() { File::_xeenSave = nullptr; File::_darkSave = nullptr; + // Reset any combat information from the previous game + g_vm->_combat->reset(); + + // Reset the game states if (g_vm->getGameID() != GType_Clouds) { File::_darkSave = new SaveArchive(g_vm->_party); File::_darkSave->reset(File::_darkCc);