TWINE: time freeze cleanup

This commit is contained in:
Martin Gerhardy 2021-08-01 14:54:00 +02:00
parent 8f94245ff9
commit 3d8e34b756
3 changed files with 9 additions and 22 deletions

View File

@ -722,12 +722,11 @@ void Scene::processActorZones(int32 actorIdx) {
break;
case ZoneType::kText:
if (IS_HERO(actorIdx) && _engine->_movements->shouldTriggerZoneAction()) {
_engine->freezeTime();
ScopedEngineFreeze scopedFreeze(_engine);
_engine->exitSceneryView();
_engine->_text->setFontCrossColor(zone->infoData.DisplayText.textColor);
_talkingActor = actorIdx;
_engine->_text->drawTextProgressive(zone->infoData.DisplayText.textIdx);
_engine->unfreezeTime();
_engine->_redraw->redrawEngineActions(true);
}
break;

View File

@ -649,7 +649,7 @@ static int32 lSET_TRACK_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 lMESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
const TextId textIdx = (TextId)ctx.stream.readSint16LE();
engine->freezeTime();
ScopedEngineFreeze scopedFreeze(engine);
if (engine->_text->_showDialogueBubble) {
engine->_redraw->drawBubble(ctx.actorIdx);
}
@ -659,7 +659,6 @@ static int32 lMESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
if (engine->_scene->_currentSceneIdx == LBA1SceneId::Principal_Island_Library && engine->_scene->_talkingActor == 8)/* && (*(short *)lifeScriptPosition == 0xe2 [226])*/ {
engine->unlockAchievement("LBA_ACH_008");
}
engine->unfreezeTime();
engine->_redraw->redrawEngineActions(true);
return 0;
@ -905,14 +904,13 @@ static int32 lMESSAGE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
const int32 otherActorIdx = ctx.stream.readByte();
const TextId textIdx = (TextId)ctx.stream.readSint16LE();
engine->freezeTime();
ScopedEngineFreeze scopedFreeze(engine);
if (engine->_text->_showDialogueBubble) {
engine->_redraw->drawBubble(otherActorIdx);
}
engine->_text->setFontCrossColor(engine->_scene->getActor(otherActorIdx)->_talkColor);
engine->_scene->_talkingActor = otherActorIdx;
engine->_text->drawTextProgressive(textIdx);
engine->unfreezeTime();
engine->_redraw->redrawEngineActions(true);
return 0;
@ -1256,14 +1254,13 @@ static int32 lADD_CHOICE(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 lASK_CHOICE(TwinEEngine *engine, LifeScriptContext &ctx) {
TextId choiceIdx = (TextId)ctx.stream.readSint16LE();
engine->freezeTime();
ScopedEngineFreeze scopedFreeze(engine);
if (engine->_text->_showDialogueBubble) {
engine->_redraw->drawBubble(ctx.actorIdx);
}
engine->_text->setFontCrossColor(ctx.actor->_talkColor);
engine->_gameState->processGameChoices(choiceIdx);
engine->_gameState->_numChoices = 0;
engine->unfreezeTime();
engine->_redraw->redrawEngineActions(true);
return 0;
@ -1276,7 +1273,7 @@ static int32 lASK_CHOICE(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 lBIG_MESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
TextId textIdx = (TextId)ctx.stream.readSint16LE();
engine->freezeTime();
ScopedEngineFreeze scopedFreeze(engine);
engine->_text->textClipFull();
if (engine->_text->_showDialogueBubble) {
engine->_redraw->drawBubble(ctx.actorIdx);
@ -1285,7 +1282,6 @@ static int32 lBIG_MESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
engine->_scene->_talkingActor = ctx.actorIdx;
engine->_text->drawTextProgressive(textIdx);
engine->_text->textClipSmall();
engine->unfreezeTime();
engine->_redraw->redrawEngineActions(true);
return 0;

View File

@ -547,7 +547,7 @@ int TwinEEngine::getRandomNumber(uint max) {
}
void TwinEEngine::freezeTime() {
if (!_isTimeFreezed) {
if (_isTimeFreezed == 0) {
_saveFreezedTime = _lbaTime;
_pauseToken = pauseEngine();
}
@ -667,9 +667,7 @@ void TwinEEngine::processInventoryAction() {
break;
}
case kiBonusList: {
unfreezeTime();
_redraw->redrawEngineActions(true);
freezeTime();
processBonusList();
break;
}
@ -731,19 +729,17 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
} else {
// Process give up menu - Press ESC
if (_input->toggleAbortAction() && _scene->_sceneHero->_life > 0 && _scene->_sceneHero->_entity != -1 && !_scene->_sceneHero->_staticFlags.bIsHidden) {
freezeTime();
ScopedEngineFreeze scopedFreeze(this);
exitSceneryView();
const int giveUp = _menu->giveupMenu();
if (giveUp == kQuitEngine) {
return 0;
}
if (giveUp == 1) {
unfreezeTime();
_redraw->redrawEngineActions(true);
_quitGame = 0;
return 0;
}
unfreezeTime();
_redraw->redrawEngineActions(true);
}
@ -783,9 +779,8 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
} else if (_input->isActionActive(TwinEActionType::QuickBehaviourDiscreet, false)) {
_actor->_heroBehaviour = HeroBehaviourType::kDiscrete;
}
freezeTime();
ScopedEngineFreeze scopedFreeze(this);
_menu->processBehaviourMenu();
unfreezeTime();
_redraw->redrawEngineActions(true);
}
@ -812,16 +807,14 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
// Draw holomap
if (_input->toggleActionIfActive(TwinEActionType::OpenHolomap) && _gameState->hasItem(InventoryItems::kiHolomap) && !_gameState->inventoryDisabled()) {
freezeTime();
_holomap->processHolomap();
_screens->_lockPalette = true;
unfreezeTime();
_redraw->redrawEngineActions(true);
}
// Process Pause
if (_input->toggleActionIfActive(TwinEActionType::Pause)) {
freezeTime();
ScopedEngineFreeze scopedFreeze(this);
const char *PauseString = "Pause";
_text->setFontColor(COLOR_WHITE);
if (_redraw->_inSceneryView) {
@ -840,7 +833,6 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
break;
}
} while (!_input->toggleActionIfActive(TwinEActionType::Pause));
unfreezeTime();
_redraw->redrawEngineActions(true);
}
}