Skip to content

Commit

Permalink
XEEN: Allow loading savegames during combat using GMM
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dreammaster committed Apr 7, 2018
1 parent 569833b commit c1ae848
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
3 changes: 2 additions & 1 deletion engines/xeen/combat.cpp
Expand Up @@ -2099,7 +2099,8 @@ void Combat::reset() {
clearShooting();
setupCombatParty();

_combatMode = COMBATMODE_STARTUP;
_combatMode = COMBATMODE_1;
_monster2Attack = -1;
}

} // End of namespace Xeen
28 changes: 15 additions & 13 deletions engines/xeen/interface.cpp
Expand Up @@ -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:
Expand Down Expand Up @@ -1701,7 +1701,7 @@ void Interface::doCombat() {
}
}
}

exit:
w.close();
events.clearEvents();

Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions engines/xeen/xeen.cpp
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions engines/xeen/xeen.h
Expand Up @@ -219,9 +219,9 @@ class XeenEngine : public Engine {
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
Expand Down

0 comments on commit c1ae848

Please sign in to comment.