GRIFFON: fix timer behavior during GMM pause

(possible fix for bug no. 13489 - "GRIFFON: Bringing up ScummVM menu (Alt+F5) corrupts engine")
This commit is contained in:
athrxx 2022-05-17 23:22:51 +02:00
parent 76b3b5bc84
commit cb3424be01
2 changed files with 14 additions and 1 deletions

View File

@ -75,6 +75,7 @@ GriffonEngine::GriffonEngine(OSystem *syst) : Engine(syst) {
_saveSlot = 0;
_ticks = g_system->getMillis();
_ticksAtPauseStart = 0;
for (int i = 0; i < 33; ++i) {
for (int j = 0; j < 6; ++j) {
@ -193,4 +194,14 @@ Common::Error GriffonEngine::run() {
return Common::kNoError;
}
void GriffonEngine::pauseEngineIntern(bool pause) {
if (pause) {
_ticksAtPauseStart = _ticks;
} else {
uint32 diff = _system->getMillis() - _ticksAtPauseStart;
_ticks += diff;
_nextTicks += diff;
}
}
}

View File

@ -442,6 +442,8 @@ private:
void setupAudio();
void updateMusic();
// Common engine overrides
void pauseEngineIntern(bool pause) override;
bool canLoadGameStateCurrently() override { return true; }
bool canSaveGameStateCurrently() override { return _gameMode == kGameModePlay; }
int getAutosaveSlot() const override { return 4; }
@ -476,7 +478,7 @@ private:
int _scriptFlag[100][10], _saveSlot; // script, flag
// timer related - move to local later
int _ticks, _ticksPassed, _nextTicks;
uint _ticks, _ticksPassed, _nextTicks, _ticksAtPauseStart;
float _fp, _fps, _fpsr; // CHECKME: _fp and _fps seems to be integers
int _secsInGame, _secStart;