aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorLe Philousophe2019-06-08 11:27:14 +0200
committerLe Philousophe2019-06-08 12:43:22 +0200
commitdeb92e13ebe309fba67fab47eca003dcb0b06e97 (patch)
tree4ff8fd91ae66510a11a51623f00e47505eb2f890 /engines
parent89922138e2f9f29b1265aabe6e250fa050411caa (diff)
downloadscummvm-rg350-deb92e13ebe309fba67fab47eca003dcb0b06e97.tar.gz
scummvm-rg350-deb92e13ebe309fba67fab47eca003dcb0b06e97.tar.bz2
scummvm-rg350-deb92e13ebe309fba67fab47eca003dcb0b06e97.zip
CRYOMNI3D: Use shouldAbort to prepare GMM in-game load
Diffstat (limited to 'engines')
-rw-r--r--engines/cryomni3d/cryomni3d.cpp10
-rw-r--r--engines/cryomni3d/dialogs_manager.cpp2
-rw-r--r--engines/cryomni3d/versailles/dialogs_manager.cpp8
-rw-r--r--engines/cryomni3d/versailles/documentation.cpp16
-rw-r--r--engines/cryomni3d/versailles/engine.cpp35
-rw-r--r--engines/cryomni3d/versailles/engine.h2
-rw-r--r--engines/cryomni3d/versailles/logic.cpp4
-rw-r--r--engines/cryomni3d/versailles/menus.cpp10
-rw-r--r--engines/cryomni3d/versailles/toolbar.cpp8
9 files changed, 52 insertions, 43 deletions
diff --git a/engines/cryomni3d/cryomni3d.cpp b/engines/cryomni3d/cryomni3d.cpp
index f27bffb437..ee788d6d8c 100644
--- a/engines/cryomni3d/cryomni3d.cpp
+++ b/engines/cryomni3d/cryomni3d.cpp
@@ -137,7 +137,7 @@ void CryOmni3DEngine::playHNM(const Common::String &filename, Audio::Mixer::Soun
bool skipVideo = false;
uint frameNum = 0;
- while (!g_engine->shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) {
+ while (!shouldAbort() && !videoDecoder->endOfVideo() && !skipVideo) {
if (videoDecoder->needsUpdate()) {
const Graphics::Surface *frame = videoDecoder->decodeNextFrame();
@@ -208,7 +208,7 @@ void CryOmni3DEngine::displayHLZ(const Common::String &filename) {
g_system->updateScreen();
bool exitImg = false;
- while (!g_engine->shouldQuit() && !exitImg) {
+ while (!shouldAbort() && !exitImg) {
if (pollEvents()) {
if (checkKeysPressed(1, Common::KEYCODE_ESCAPE) || getCurrentMouseButton() == 1) {
exitImg = true;
@@ -309,7 +309,7 @@ void CryOmni3DEngine::setAutoRepeatClick(uint millis) {
}
void CryOmni3DEngine::waitMouseRelease() {
- while (getCurrentMouseButton() != 0 && !g_engine->shouldQuit()) {
+ while (getCurrentMouseButton() != 0 && !shouldAbort()) {
pollEvents();
g_system->updateScreen();
g_system->delayMillis(10);
@@ -396,7 +396,7 @@ void CryOmni3DEngine::fadeOutPalette() {
delta[i] = palWork[i] / 25;
}
- for (uint step = 0; step < 25 && !g_engine->shouldQuit(); step++) {
+ for (uint step = 0; step < 25 && !shouldAbort(); step++) {
for (uint i = 0; i < 256 * 3; i++) {
palWork[i] -= delta[i];
palOut[i] = palWork[i] >> 8;
@@ -427,7 +427,7 @@ void CryOmni3DEngine::fadeInPalette(const byte *palette) {
}
setBlackPalette();
- for (uint step = 0; step < 25 && !g_engine->shouldQuit(); step++) {
+ for (uint step = 0; step < 25 && !shouldAbort(); step++) {
for (uint i = 0; i < 256 * 3; i++) {
palWork[i] += delta[i];
palOut[i] = palWork[i] >> 8;
diff --git a/engines/cryomni3d/dialogs_manager.cpp b/engines/cryomni3d/dialogs_manager.cpp
index fc40b149b9..5f78d2c431 100644
--- a/engines/cryomni3d/dialogs_manager.cpp
+++ b/engines/cryomni3d/dialogs_manager.cpp
@@ -323,7 +323,7 @@ bool DialogsManager::play(const Common::String &sequence, bool &slowStop) {
// We must give a subject
uint playerChoice = askPlayerQuestions(video, questions);
didSomething = true;
- // -1 when shouldQuit
+ // -1 when shouldAbort
if (playerChoice == -1u || playerChoice == eocInserted) {
break;
}
diff --git a/engines/cryomni3d/versailles/dialogs_manager.cpp b/engines/cryomni3d/versailles/dialogs_manager.cpp
index d49984a327..b69dfc1789 100644
--- a/engines/cryomni3d/versailles/dialogs_manager.cpp
+++ b/engines/cryomni3d/versailles/dialogs_manager.cpp
@@ -53,7 +53,7 @@ bool Versailles_DialogsManager::play(const Common::String &sequence) {
if (_engine->showSubtitles()) {
bool skip = false;
uint end = g_system->getMillis() + 2000;
- while (!g_engine->shouldQuit() && g_system->getMillis() < end && !skip) {
+ while (!_engine->shouldAbort() && g_system->getMillis() < end && !skip) {
g_system->updateScreen();
g_system->delayMillis(10);
if (_engine->pollEvents() &&
@@ -189,7 +189,7 @@ void Versailles_DialogsManager::playDialog(const Common::String &video, const Co
bool skipWait = false;
uint end = g_system->getMillis() + duration;
- while (!g_engine->shouldQuit() && g_system->getMillis() < end && !skipWait) {
+ while (!_engine->shouldAbort() && g_system->getMillis() < end && !skipWait) {
g_system->updateScreen();
g_system->delayMillis(10);
if (_engine->pollEvents() && _engine->checkKeysPressed(1, Common::KEYCODE_SPACE)) {
@@ -206,7 +206,7 @@ void Versailles_DialogsManager::playDialog(const Common::String &video, const Co
audioDecoder = nullptr;
bool skipVideo = false;
- while (!g_engine->shouldQuit() && _engine->_mixer->isSoundHandleActive(audioHandle) && !skipVideo) {
+ while (!_engine->shouldAbort() && _engine->_mixer->isSoundHandleActive(audioHandle) && !skipVideo) {
if (_engine->pollEvents() && _engine->checkKeysPressed(1, Common::KEYCODE_SPACE)) {
skipVideo = true;
}
@@ -311,7 +311,7 @@ uint Versailles_DialogsManager::askPlayerQuestions(const Common::String &video,
if (_engine->pollEvents()) {
_engine->clearKeys();
- if (g_engine->shouldQuit()) {
+ if (_engine->shouldAbort()) {
finished = true;
selectedQuestion = -1;
break;
diff --git a/engines/cryomni3d/versailles/documentation.cpp b/engines/cryomni3d/versailles/documentation.cpp
index 3846651dd2..c0acbc874f 100644
--- a/engines/cryomni3d/versailles/documentation.cpp
+++ b/engines/cryomni3d/versailles/documentation.cpp
@@ -404,7 +404,7 @@ Common::String Versailles_Documentation::docAreaHandleSummary() {
selectedBox = 7;
}
}
- if (g_engine->shouldQuit()) {
+ if (_engine->shouldAbort()) {
selectedBox = 7;
}
}
@@ -510,7 +510,7 @@ Common::String Versailles_Documentation::docAreaHandleTimeline() {
selectedBox = leaveBoxId;
}
}
- if (g_engine->shouldQuit()) {
+ if (_engine->shouldAbort()) {
selectedBox = leaveBoxId;
}
}
@@ -710,7 +710,7 @@ uint Versailles_Documentation::docAreaHandleRecord(Graphics::ManagedSurface &sur
if (_engine->pollEvents() || first) {
first = false;
- if (g_engine->shouldQuit()) {
+ if (_engine->shouldAbort()) {
// Fake the quit
action = 6;
}
@@ -1044,7 +1044,7 @@ Common::String Versailles_Documentation::docAreaHandleGeneralMap() {
if (_engine->checkKeysPressed(1, Common::KEYCODE_ESCAPE)) {
selectedBox = ARRAYSIZE(areas);
}
- if (g_engine->shouldQuit()) {
+ if (_engine->shouldAbort()) {
selectedBox = ARRAYSIZE(areas);
}
}
@@ -1288,7 +1288,7 @@ Common::String Versailles_Documentation::docAreaHandleCastleMap() {
if (_engine->checkKeysPressed(1, Common::KEYCODE_ESCAPE)) {
selectedBox = ARRAYSIZE(areas);
}
- if (g_engine->shouldQuit()) {
+ if (_engine->shouldAbort()) {
selectedBox = ARRAYSIZE(areas);
}
}
@@ -1351,9 +1351,9 @@ uint Versailles_Documentation::inGameHandleRecord(Graphics::ManagedSurface &surf
g_system->delayMillis(10);
if (_engine->pollEvents()) {
- if (g_engine->shouldQuit()) {
+ if (_engine->shouldAbort()) {
// Fake the quit
- action = 6;
+ action = 1;
}
Common::Point mouse = _engine->getMousePos();
if (_engine->getDragStatus() == kDragStatus_Pressed) {
@@ -1726,7 +1726,7 @@ uint Versailles_Documentation::handlePopupMenu(const Graphics::ManagedSurface
g_system->delayMillis(10);
if (_engine->pollEvents()) {
- if (g_engine->shouldQuit()) {
+ if (_engine->shouldAbort()) {
// Fake the quit
break;
}
diff --git a/engines/cryomni3d/versailles/engine.cpp b/engines/cryomni3d/versailles/engine.cpp
index 321b71c758..2e7373f9ad 100644
--- a/engines/cryomni3d/versailles/engine.cpp
+++ b/engines/cryomni3d/versailles/engine.cpp
@@ -169,11 +169,11 @@ Common::Error CryOmni3DEngine_Versailles::run() {
#if !defined(DEBUG_FAST_START) || DEBUG_FAST_START<1
playTransitionEndLevel(-2);
- if (g_engine->shouldQuit()) {
+ if (shouldAbort()) {
return Common::kNoError;
}
playTransitionEndLevel(-1);
- if (g_engine->shouldQuit()) {
+ if (shouldAbort()) {
return Common::kNoError;
}
#endif
@@ -203,7 +203,7 @@ Common::Error CryOmni3DEngine_Versailles::run() {
// New game
#if !defined(DEBUG_FAST_START) || DEBUG_FAST_START<1
playTransitionEndLevel(0);
- if (g_engine->shouldQuit()) {
+ if (shouldAbort()) {
stopGame = true;
exitLoop = true;
break;
@@ -256,6 +256,16 @@ Common::Error CryOmni3DEngine_Versailles::run() {
return Common::kNoError;
}
+bool CryOmni3DEngine_Versailles::shouldAbort() {
+ if (g_engine->shouldQuit()) {
+ _abortCommand = kAbortQuit;
+ return true;
+ }
+ // If we are not playing _abortCommand isn't used
+ // Even GMM can't load game when not playing
+ return _isPlaying && _abortCommand != kAbortNoAbort;
+}
+
Common::String CryOmni3DEngine_Versailles::prepareFileName(const Common::String &baseName,
const char *const *extensions) const {
Common::String baseName_(baseName);
@@ -592,8 +602,7 @@ void CryOmni3DEngine_Versailles::playTransitionEndLevel(int level) {
}
fadeOutPalette();
- if (g_engine->shouldQuit()) {
- _abortCommand = kAbortQuit;
+ if (shouldAbort()) {
return;
}
@@ -606,14 +615,12 @@ void CryOmni3DEngine_Versailles::playTransitionEndLevel(int level) {
playHNM(video, Audio::Mixer::kMusicSoundType);
clearKeys();
- if (g_engine->shouldQuit()) {
- _abortCommand = kAbortQuit;
+ if (shouldAbort()) {
return;
}
fadeOutPalette();
- if (g_engine->shouldQuit()) {
- _abortCommand = kAbortQuit;
+ if (shouldAbort()) {
return;
}
@@ -1155,8 +1162,8 @@ int CryOmni3DEngine_Versailles::handleWarp() {
actionId = _currentPlace->hitTest(mouseRev);
exit = handleWarpMouse(&actionId, movingCursor);
- if (g_engine->shouldQuit()) {
- _abortCommand = kAbortQuit;
+ if (shouldAbort()) {
+ // We abort if we quit or if we load from GMM
exit = true;
}
if (exit) {
@@ -1225,7 +1232,7 @@ bool CryOmni3DEngine_Versailles::handleWarpMouse(uint *actionId,
bool mustRedraw = displayToolbar(original);
// Don't redraw if we abort game
- if (_abortCommand != kAbortNoAbort) {
+ if (shouldAbort()) {
return true;
}
if (mustRedraw) {
@@ -1239,7 +1246,7 @@ bool CryOmni3DEngine_Versailles::handleWarpMouse(uint *actionId,
if (countDown()) {
// Time has changed: need redraw
// Don't redraw if we abort game
- if (_abortCommand != kAbortNoAbort) {
+ if (shouldAbort()) {
return true;
}
@@ -1471,7 +1478,7 @@ void CryOmni3DEngine_Versailles::displayObject(const Common::String &imgName,
bool cursorWasVisible = showMouse(true);
bool exitImg = false;
- while (!g_engine->shouldQuit() && !exitImg) {
+ while (!shouldAbort() && !exitImg) {
if (pollEvents()) {
if (getCurrentMouseButton() == 1) {
exitImg = true;
diff --git a/engines/cryomni3d/versailles/engine.h b/engines/cryomni3d/versailles/engine.h
index 66f4663a86..369f69ade9 100644
--- a/engines/cryomni3d/versailles/engine.h
+++ b/engines/cryomni3d/versailles/engine.h
@@ -231,7 +231,7 @@ public:
virtual bool hasPlaceDocumentation() override;
virtual bool displayPlaceDocumentation() override;
virtual uint displayOptions() override;
- virtual bool shouldAbort() override { return g_engine->shouldQuit() || _abortCommand != kAbortNoAbort; }
+ virtual bool shouldAbort() override;
private:
void setupFonts();
diff --git a/engines/cryomni3d/versailles/logic.cpp b/engines/cryomni3d/versailles/logic.cpp
index 02592ee871..48c919b2b3 100644
--- a/engines/cryomni3d/versailles/logic.cpp
+++ b/engines/cryomni3d/versailles/logic.cpp
@@ -3090,7 +3090,7 @@ IMG_CB(88004b) {
break;
}
}
- if (!shouldQuit()) {
+ if (!shouldAbort()) {
// Close the toilets
playInGameVideo("31j32b");
// Force reload of the place
@@ -3163,7 +3163,7 @@ INIT_PLACE(1, 3) {
FILTER_EVENT(1, 3) {
if (*event == 11301) {
- while (!g_engine->shouldQuit() && _mixer->isSoundIDActive(SoundIds::kLeb001)) {
+ while (!shouldAbort() && _mixer->isSoundIDActive(SoundIds::kLeb001)) {
g_system->updateScreen();
g_system->delayMillis(10);
pollEvents();
diff --git a/engines/cryomni3d/versailles/menus.cpp b/engines/cryomni3d/versailles/menus.cpp
index 98d433a3ba..305fe1c06b 100644
--- a/engines/cryomni3d/versailles/menus.cpp
+++ b/engines/cryomni3d/versailles/menus.cpp
@@ -105,7 +105,7 @@ uint CryOmni3DEngine_Versailles::displayOptions() {
bool resetScreen = true;
bool forceEvents = true;
- while (!g_engine->shouldQuit() && !end) {
+ while (!shouldAbort() && !end) {
if (resetScreen) {
setPalette(imageDecoder->getPalette(), imageDecoder->getPaletteStartIndex(),
imageDecoder->getPaletteColorCount());
@@ -465,10 +465,12 @@ uint CryOmni3DEngine_Versailles::displayOptions() {
} else if (selectedMsg == 27) {
_abortCommand = kAbortNewGame;
_isVisiting = false;
- } else if (g_engine->shouldQuit()) {
+ } else if (shouldAbort()) {
// Fake a quit
selectedMsg = 40;
- _abortCommand = kAbortQuit;
+ // shouldAbort called earlier has already set _abortCommand
+ // If GMM is called on main menu in game, return value is ignored so quit isn't important
+ // If GMM is called on main menu out of game, GMM can only quit game and don't load
}
ConfMan.flushToDisk();
@@ -1013,7 +1015,7 @@ void CryOmni3DEngine_Versailles::displayCredits() {
}
clearKeys();
}
- if (g_engine->shouldQuit()) {
+ if (shouldAbort()) {
skipScreen = true;
end = true;
}
diff --git a/engines/cryomni3d/versailles/toolbar.cpp b/engines/cryomni3d/versailles/toolbar.cpp
index a0d4d3091a..d302dce905 100644
--- a/engines/cryomni3d/versailles/toolbar.cpp
+++ b/engines/cryomni3d/versailles/toolbar.cpp
@@ -428,7 +428,7 @@ bool Toolbar::displayToolbar(const Graphics::Surface *original) {
g_system->delayMillis(10);
_engine->pollEvents();
- if (g_engine->shouldQuit()) {
+ if (_engine->shouldAbort()) {
return false;
}
}
@@ -438,7 +438,7 @@ bool Toolbar::displayToolbar(const Graphics::Surface *original) {
_engine->waitMouseRelease();
handleToolbarEvents(original);
- if (g_engine->shouldQuit()) {
+ if (_engine->shouldAbort()) {
return false;
}
@@ -457,7 +457,7 @@ bool Toolbar::displayToolbar(const Graphics::Surface *original) {
g_system->delayMillis(10);
_engine->pollEvents();
- if (g_engine->shouldQuit()) {
+ if (_engine->shouldAbort()) {
return false;
}
}
@@ -495,7 +495,7 @@ void Toolbar::handleToolbarEvents(const Graphics::Surface *original) {
_mouse_in_view_object = false;
_engine->pollEvents();
- if (g_engine->shouldQuit()) {
+ if (_engine->shouldAbort()) {
exitToolbar = true;
break;
}