XEEN: Reset combat data when loading a new savegame

This commit is contained in:
Paul Gilbert 2018-04-07 15:41:16 -04:00
parent 25eeee8e50
commit 569833b4ca
3 changed files with 20 additions and 0 deletions

View File

@ -2095,4 +2095,11 @@ bool Combat::areMonstersPresent() const {
return false;
}
void Combat::reset() {
clearShooting();
setupCombatParty();
_combatMode = COMBATMODE_STARTUP;
}
} // End of namespace Xeen

View File

@ -204,6 +204,11 @@ public:
*/
void clearShooting();
/**
* Resets all combat related data
*/
void reset();
/**
* Gives damage to character or characters in the party
*/

View File

@ -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);