[Scummvm-git-logs] scummvm master -> c1ae84881883363da05bfdb53ad274bd4814c057

dreammaster dreammaster at scummvm.org
Sat Apr 7 21:55:36 CEST 2018


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
569833b4ca XEEN: Reset combat data when loading a new savegame
c1ae848818 XEEN: Allow loading savegames during combat using GMM


Commit: 569833b4ca80116efaab15e47d0097b5c62ecb6c
    https://github.com/scummvm/scummvm/commit/569833b4ca80116efaab15e47d0097b5c62ecb6c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-04-07T15:41:16-04:00

Commit Message:
XEEN: Reset combat data when loading a new savegame

Changed paths:
    engines/xeen/combat.cpp
    engines/xeen/combat.h
    engines/xeen/saves.cpp


diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp
index 2293dcd..71ad630 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 c3fa987..e55c8b7 100644
--- a/engines/xeen/combat.h
+++ b/engines/xeen/combat.h
@@ -205,6 +205,11 @@ public:
 	void clearShooting();
 
 	/**
+	 * Resets all combat related data
+	 */
+	void reset();
+
+	/**
 	 * Gives damage to character or characters in the party
 	 */
 	void giveCharDamage(int damage, DamageType attackType, int charIndex);
diff --git a/engines/xeen/saves.cpp b/engines/xeen/saves.cpp
index 2f29096..4aee1a6 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);


Commit: c1ae84881883363da05bfdb53ad274bd4814c057
    https://github.com/scummvm/scummvm/commit/c1ae84881883363da05bfdb53ad274bd4814c057
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-04-07T15:53:27-04:00

Commit Message:
XEEN: Allow loading savegames during combat using GMM

The original didn't allow loading during combat from it's
options dialog, and I'll leave that untouched, but the ability
to load out of a unwinnable combat is too convenient to not
allow in some form.

Changed paths:
    engines/xeen/combat.cpp
    engines/xeen/interface.cpp
    engines/xeen/xeen.cpp
    engines/xeen/xeen.h


diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp
index 71ad630..397370f 100644
--- a/engines/xeen/combat.cpp
+++ b/engines/xeen/combat.cpp
@@ -2099,7 +2099,8 @@ void Combat::reset() {
 	clearShooting();
 	setupCombatParty();
 
-	_combatMode = COMBATMODE_STARTUP;
+	_combatMode = COMBATMODE_1;
+	_monster2Attack = -1;
 }
 
 } // End of namespace Xeen
diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index 88b33c4..1a79002 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -1519,7 +1519,7 @@ void Interface::doCombat() {
 				} while (!_vm->shouldExit() && events.timeElapsed() < 1 && !_buttonValue);
 			} while (!_vm->shouldExit() && !_buttonValue);
 			if (_vm->shouldExit())
-				return;
+				goto exit;
 
 			switch (_buttonValue) {
 			case Common::KEYCODE_TAB:
@@ -1701,7 +1701,7 @@ void Interface::doCombat() {
 				}
 			}
 		}
-
+exit:
 		w.close();
 		events.clearEvents();
 
@@ -1721,18 +1721,20 @@ void Interface::doCombat() {
 	mainIconsPrint();
 	combat._monster2Attack = -1;
 
-	if (upDoorText) {
-		map.cellFlagLookup(party._mazePosition);
-		if (map._currentIsEvent)
-			scripts.checkEvents();
-	}
+	if (!g_vm->isLoadPending()) {
+		if (upDoorText) {
+			map.cellFlagLookup(party._mazePosition);
+			if (map._currentIsEvent)
+				scripts.checkEvents();
+		}
 
-	if (reloadMap) {
-		sound.playFX(51);
-		map._loadCcNum = _vm->getGameID() != GType_WorldOfXeen ? 1 : 0;
-		map.load(_vm->getGameID() == GType_WorldOfXeen ? 28 : 29);
-		party._mazeDirection = _vm->getGameID() == GType_WorldOfXeen ?
-			DIR_EAST : DIR_SOUTH;
+		if (reloadMap) {
+			sound.playFX(51);
+			map._loadCcNum = _vm->getGameID() != GType_WorldOfXeen ? 1 : 0;
+			map.load(_vm->getGameID() == GType_WorldOfXeen ? 28 : 29);
+			party._mazeDirection = _vm->getGameID() == GType_WorldOfXeen ?
+				DIR_EAST : DIR_SOUTH;
+		}
 	}
 
 	combat._combatMode = COMBATMODE_1;
diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp
index 5f6243c..8300040 100644
--- a/engines/xeen/xeen.cpp
+++ b/engines/xeen/xeen.cpp
@@ -189,7 +189,7 @@ Common::Error XeenEngine::loadGameState(int slot) {
 }
 
 bool XeenEngine::canLoadGameStateCurrently() {
-	return _mode != MODE_COMBAT && _mode != MODE_STARTUP;
+	return _mode != MODE_STARTUP;
 }
 
 bool XeenEngine::canSaveGameStateCurrently() {
@@ -256,7 +256,7 @@ void XeenEngine::play() {
 
 void XeenEngine::gameLoop() {
 	// Main game loop
-	while (!shouldExit()) {
+	while (isLoadPending() || !shouldExit()) {
 		if (isLoadPending()) {
 			// Load any pending savegame
 			int saveSlot = _loadSaveSlot;
@@ -268,7 +268,7 @@ void XeenEngine::gameLoop() {
 		_map->cellFlagLookup(_party->_mazePosition);
 		if (_map->_currentIsEvent) {
 			_gameMode = (GameMode)_scripts->checkEvents();
-			if (shouldExit() || _gameMode)
+			if (shouldExit())
 				return;
 		}
 		_party->giveTreasure();
diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h
index 774e97b..2cd42fd 100644
--- a/engines/xeen/xeen.h
+++ b/engines/xeen/xeen.h
@@ -219,9 +219,9 @@ public:
 	void GUIError(const char *msg, ...) GCC_PRINTF(2, 3);
 
 	/**
-	 * Returns true if the game should be exited (and likely return to game menu)
+	 * Returns true if the game should be exited (either quitting, exiting to the main menu, or loading a savegame)
 	 */
-	bool shouldExit() const { return _gameMode != GMODE_NONE || shouldQuit(); }
+	bool shouldExit() const { return _gameMode != GMODE_NONE || isLoadPending() || shouldQuit(); }
 
 	/**
 	 * Returns true if a savegame load is pending





More information about the Scummvm-git-logs mailing list