diff options
author | Thanasis Antoniou | 2019-07-17 19:08:43 +0300 |
---|---|---|
committer | Thanasis Antoniou | 2019-07-17 19:09:15 +0300 |
commit | caa4578add35021bfbb00b5f81359592402096a3 (patch) | |
tree | 2133b0dd3f4e71324bafc1ca65699ba79483e512 /engines/bladerunner/script | |
parent | d1ff73cbb381db1876e2dbdf0457c9efc76fcd1a (diff) | |
download | scummvm-rg350-caa4578add35021bfbb00b5f81359592402096a3.tar.gz scummvm-rg350-caa4578add35021bfbb00b5f81359592402096a3.tar.bz2 scummvm-rg350-caa4578add35021bfbb00b5f81359592402096a3.zip |
BLADERUNNER: Use unsigned 32bit diff for time durations
Diffstat (limited to 'engines/bladerunner/script')
-rw-r--r-- | engines/bladerunner/script/police_maze.cpp | 13 | ||||
-rw-r--r-- | engines/bladerunner/script/script.cpp | 81 | ||||
-rw-r--r-- | engines/bladerunner/script/script.h | 32 | ||||
-rw-r--r-- | engines/bladerunner/script/vk_script.cpp | 4 |
4 files changed, 66 insertions, 64 deletions
diff --git a/engines/bladerunner/script/police_maze.cpp b/engines/bladerunner/script/police_maze.cpp index 68e2b672ed..028eca00b5 100644 --- a/engines/bladerunner/script/police_maze.cpp +++ b/engines/bladerunner/script/police_maze.cpp @@ -120,10 +120,10 @@ void PoliceMaze::setPauseState(bool state) { warning("PAUSE: %d", state); _isPaused = state; - uint32 t = _vm->_time->current(); + uint32 timeNow = _vm->_time->current(); for (int i = 0; i < kNumMazeTracks; i++) { - _tracks[i]->setTime(t); + _tracks[i]->setTime(timeNow); } } @@ -256,8 +256,8 @@ bool PoliceMazeTargetTrack::tick() { uint32 oldTime = _time; _time = _vm->_time->current(); - int32 timeDiff = _time - oldTime; - _timeLeftUpdate -= timeDiff; + uint32 timeDiff = _time - oldTime; // unsigned difference is intentional + _timeLeftUpdate = _timeLeftUpdate - (int32)timeDiff; // should be ok if (_timeLeftUpdate > 0) { return false; @@ -265,8 +265,9 @@ bool PoliceMazeTargetTrack::tick() { #if BLADERUNNER_ORIGINAL_BUGS #else + // here _timeLeftUpdate is <= 0 if (_vm->_settings->getDifficulty() > kGameDifficultyEasy) { - timeDiff = 0 - _timeLeftUpdate; + timeDiff = abs(_timeLeftUpdate); } #endif // BLADERUNNER_ORIGINAL_BUGS _timeLeftUpdate = 66; // update the target track 15 times per second @@ -282,7 +283,7 @@ bool PoliceMazeTargetTrack::tick() { if (_vm->_settings->getDifficulty() == kGameDifficultyEasy) { _timeLeftWait -= timeDiff; // original behavior } else { - _timeLeftWait -= (timeDiff + _timeLeftUpdate); // this deducts an amount >= 66 + _timeLeftWait = _timeLeftWait - (int32)(timeDiff + _timeLeftUpdate); // this deducts an amount >= 66 // should be ok } #endif // BLADERUNNER_ORIGINAL_BUGS if (_timeLeftWait > 0) { diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp index a0c27ae431..d0355d3289 100644 --- a/engines/bladerunner/script/script.cpp +++ b/engines/bladerunner/script/script.cpp @@ -343,7 +343,7 @@ void ScriptBase::Actor_Says_With_Pause(int actorId, int sentenceId, float pause, } if (pause > 0.0f && !_vm->_actorSpeakStopIsRequested) { - Delay(pause * 1000); + Delay(pause * 1000u); } Player_Gains_Control(); @@ -929,11 +929,12 @@ int ScriptBase::Animation_Skip_To_Frame() { return 0; } -void ScriptBase::Delay(int miliseconds) { - debugC(kDebugScript, "Delay(%d)", miliseconds); +void ScriptBase::Delay(uint32 miliseconds) { + debugC(kDebugScript, "Delay(%u)", miliseconds); Player_Loses_Control(); - int endTime = _vm->_time->current() + miliseconds; - while (_vm->_gameIsRunning && (_vm->_time->current() < endTime)) { + uint32 startTime = _vm->_time->current(); + // unsigned difference is intentional + while (_vm->_gameIsRunning && (_vm->_time->current() - startTime < miliseconds)) { _vm->gameTick(); } Player_Gains_Control(); @@ -1138,18 +1139,18 @@ void ScriptBase::Footstep_Sound_Override_Off() { _vm->_scene->_set->resetFoodstepSoundOverride(); } -bool ScriptBase::Music_Play(int musicId, int volume, int pan, int timeFadeIn, int timePlay, int loop, int timeFadeOut) { - debugC(kDebugScript, "Music_Play(%d, %d, %d, %d, %d, %d, %d)", musicId, volume, pan, timeFadeIn, timePlay, loop, timeFadeOut); +bool ScriptBase::Music_Play(int musicId, int volume, int pan, uint32 timeFadeIn, uint32 timePlay, int loop, uint32 timeFadeOut) { + debugC(kDebugScript, "Music_Play(%d, %d, %d, %u, %u, %d, %u)", musicId, volume, pan, timeFadeIn, timePlay, loop, timeFadeOut); return _vm->_music->play(_vm->_gameInfo->getMusicTrack(musicId), volume, pan, timeFadeIn, timePlay, loop, timeFadeOut); } -void ScriptBase::Music_Adjust(int volume, int pan, int delay) { - debugC(kDebugScript, "Music_Adjust(%d, %d, %d)", volume, pan, delay); +void ScriptBase::Music_Adjust(int volume, int pan, uint32 delay) { + debugC(kDebugScript, "Music_Adjust(%d, %d, %u)", volume, pan, delay); _vm->_music->adjust(volume, pan, delay); } -void ScriptBase::Music_Stop(int delay) { - debugC(kDebugScript, "Music_Stop(%d)", delay); +void ScriptBase::Music_Stop(uint32 delay) { + debugC(kDebugScript, "Music_Stop(%u)", delay); _vm->_music->stop(delay); } @@ -1189,8 +1190,8 @@ void ScriptBase::Outtake_Play(int id, int noLocalization, int container) { _vm->outtakePlay(id, noLocalization, container); } -void ScriptBase::Ambient_Sounds_Add_Sound(int sfxId, int timeMin, int timeMax, int volumeMin, int volumeMax, int panStartMin, int panStartMax, int panEndMin, int panEndMax, int priority, int unk) { - debugC(kDebugScript, "Ambient_Sounds_Add_Sound(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)", sfxId, timeMin, timeMax, volumeMin, volumeMax, panStartMin, panStartMax, panEndMin, panEndMax, priority, unk); +void ScriptBase::Ambient_Sounds_Add_Sound(int sfxId, uint32 timeMin, uint32 timeMax, int volumeMin, int volumeMax, int panStartMin, int panStartMax, int panEndMin, int panEndMax, int priority, int unk) { + debugC(kDebugScript, "Ambient_Sounds_Add_Sound(%d, %u, %u, %d, %d, %d, %d, %d, %d, %d, %d)", sfxId, timeMin, timeMax, volumeMin, volumeMax, panStartMin, panStartMax, panEndMin, panEndMax, priority, unk); _vm->_ambientSounds->addSound(sfxId, timeMin, timeMax, volumeMin, volumeMax, panStartMin, panStartMax, panEndMin, panEndMax, priority, unk); } @@ -1199,8 +1200,8 @@ void ScriptBase::Ambient_Sounds_Remove_Sound(int sfxId, bool stopPlaying) { _vm->_ambientSounds->removeNonLoopingSound(sfxId, stopPlaying); } -void ScriptBase::Ambient_Sounds_Add_Speech_Sound(int actorId, int sentenceId, int timeMin, int timeMax, int volumeMin, int volumeMax, int panStartMin, int panStartMax, int panEndMin, int panEndMax, int priority, int unk) { - debugC(kDebugScript, "Ambient_Sounds_Add_Speech_Sound(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)", actorId, sentenceId, timeMin, timeMax, volumeMin, volumeMax, panStartMin, panStartMax, panEndMin, panEndMax, priority, unk); +void ScriptBase::Ambient_Sounds_Add_Speech_Sound(int actorId, int sentenceId, uint32 timeMin, uint32 timeMax, int volumeMin, int volumeMax, int panStartMin, int panStartMax, int panEndMin, int panEndMax, int priority, int unk) { + debugC(kDebugScript, "Ambient_Sounds_Add_Speech_Sound(%d, %d, %u, %u, %d, %d, %d, %d, %d, %d, %d, %d)", actorId, sentenceId, timeMin, timeMax, volumeMin, volumeMax, panStartMin, panStartMax, panEndMin, panEndMax, priority, unk); _vm->_ambientSounds->addSpeech(actorId, sentenceId, timeMin, timeMax, volumeMin, volumeMax, panStartMin, panStartMax, panEndMin, panEndMax, priority, unk); } @@ -1221,23 +1222,23 @@ void ScriptBase::Ambient_Sounds_Remove_All_Non_Looping_Sounds(bool stopPlaying) _vm->_ambientSounds->removeAllNonLoopingSounds(stopPlaying); } -void ScriptBase::Ambient_Sounds_Add_Looping_Sound(int sfxId, int volume, int pan, int delay) { - debugC(kDebugScript, "Ambient_Sounds_Add_Looping_Sound(%d, %d, %d, %d)", sfxId, volume, pan, delay); +void ScriptBase::Ambient_Sounds_Add_Looping_Sound(int sfxId, int volume, int pan, uint32 delay) { + debugC(kDebugScript, "Ambient_Sounds_Add_Looping_Sound(%d, %d, %d, %u)", sfxId, volume, pan, delay); _vm->_ambientSounds->addLoopingSound(sfxId, volume, pan, delay); } -void ScriptBase::Ambient_Sounds_Adjust_Looping_Sound(int sfxId, int volume, int pan, int delay) { - debugC(kDebugScript, "Ambient_Sounds_Adjust_Looping_Sound(%d, %d, %d, %d)", sfxId, volume, pan, delay); +void ScriptBase::Ambient_Sounds_Adjust_Looping_Sound(int sfxId, int volume, int pan, uint32 delay) { + debugC(kDebugScript, "Ambient_Sounds_Adjust_Looping_Sound(%d, %d, %d, %u)", sfxId, volume, pan, delay); _vm->_ambientSounds->adjustLoopingSound(sfxId, volume, pan, delay); } -void ScriptBase::Ambient_Sounds_Remove_Looping_Sound(int sfxId, int delay) { - debugC(kDebugScript, "Ambient_Sounds_Remove_Looping_Sound(%d, %d)", sfxId, delay); +void ScriptBase::Ambient_Sounds_Remove_Looping_Sound(int sfxId, uint32 delay) { + debugC(kDebugScript, "Ambient_Sounds_Remove_Looping_Sound(%d, %u)", sfxId, delay); _vm->_ambientSounds->removeLoopingSound(sfxId, delay); } -void ScriptBase::Ambient_Sounds_Remove_All_Looping_Sounds(int delay) { - debugC(kDebugScript, "Ambient_Sounds_Remove_All_Looping_Sounds(%d)", delay); +void ScriptBase::Ambient_Sounds_Remove_All_Looping_Sounds(uint32 delay) { + debugC(kDebugScript, "Ambient_Sounds_Remove_All_Looping_Sounds(%u)", delay); _vm->_ambientSounds->removeAllLoopingSounds(delay); } @@ -1656,8 +1657,8 @@ void ScriptBase::ADQ_Add(int actorId, int sentenceId, int animationMode) { _vm->_actorDialogueQueue->add(actorId, sentenceId, animationMode); } -void ScriptBase::ADQ_Add_Pause(int delay) { - debugC(kDebugScript, "ADQ_Add_Pause(%d)", delay); +void ScriptBase::ADQ_Add_Pause(uint32 delay) { + debugC(kDebugScript, "ADQ_Add_Pause(%u)", delay); _vm->_actorDialogueQueue->addPause(delay); } @@ -1683,10 +1684,10 @@ void ScriptBase::I_Sez(const char *str) { _vm->ISez(str); } -void ScriptBase::AI_Countdown_Timer_Start(int actorId, signed int timer, int seconds) { - debugC(kDebugScript, "AI_Countdown_Timer_Start(%d, %d, %d)", actorId, timer, seconds); +void ScriptBase::AI_Countdown_Timer_Start(int actorId, signed int timer, uint32 seconds) { + debugC(kDebugScript, "AI_Countdown_Timer_Start(%d, %d, %u)", actorId, timer, seconds); if (timer >= 0 && timer <= 2) { - _vm->_actors[actorId]->timerStart(timer, 1000 * seconds); + _vm->_actors[actorId]->timerStart(timer, 1000u * seconds); } } @@ -1713,24 +1714,24 @@ void ScriptBase::AI_Movement_Track_Repeat(int actorId) { _vm->_actors[actorId]->movementTrackNext(true); } -void ScriptBase::AI_Movement_Track_Append_Run_With_Facing(int actorId, int waypointId, int delay, int angle) { - debugC(kDebugScript, "AI_Movement_Track_Append_Run_With_Facing(%d, %d, %d, %d)", actorId, waypointId, delay, angle); - _vm->_actors[actorId]->_movementTrack->append(waypointId, delay * 1000, angle, true); +void ScriptBase::AI_Movement_Track_Append_Run_With_Facing(int actorId, int waypointId, uint32 delay, int angle) { + debugC(kDebugScript, "AI_Movement_Track_Append_Run_With_Facing(%d, %d, %u, %d)", actorId, waypointId, delay, angle); + _vm->_actors[actorId]->_movementTrack->append(waypointId, delay * 1000u, angle, true); } -void ScriptBase::AI_Movement_Track_Append_With_Facing(int actorId, int waypointId, int delay, int angle) { - debugC(kDebugScript, "AI_Movement_Track_Append_With_Facing(%d, %d, %d, %d)", actorId, waypointId, delay, angle); - _vm->_actors[actorId]->_movementTrack->append(waypointId, delay * 1000, angle, false); +void ScriptBase::AI_Movement_Track_Append_With_Facing(int actorId, int waypointId, uint32 delay, int angle) { + debugC(kDebugScript, "AI_Movement_Track_Append_With_Facing(%d, %d, %u, %d)", actorId, waypointId, delay, angle); + _vm->_actors[actorId]->_movementTrack->append(waypointId, delay * 1000u, angle, false); } -void ScriptBase::AI_Movement_Track_Append_Run(int actorId, int waypointId, int delay) { - debugC(kDebugScript, "AI_Movement_Track_Append_Run(%d, %d, %d)", actorId, waypointId, delay); - _vm->_actors[actorId]->_movementTrack->append(waypointId, delay * 1000, true); +void ScriptBase::AI_Movement_Track_Append_Run(int actorId, int waypointId, uint32 delay) { + debugC(kDebugScript, "AI_Movement_Track_Append_Run(%d, %d, %u)", actorId, waypointId, delay); + _vm->_actors[actorId]->_movementTrack->append(waypointId, delay * 1000u, true); } -void ScriptBase::AI_Movement_Track_Append(int actorId, int waypointId, int delay) { - debugC(kDebugScript, "AI_Movement_Track_Append(%d, %d, %d)", actorId, waypointId, delay); - _vm->_actors[actorId]->_movementTrack->append(waypointId, delay * 1000, false); +void ScriptBase::AI_Movement_Track_Append(int actorId, int waypointId, uint32 delay) { + debugC(kDebugScript, "AI_Movement_Track_Append(%d, %d, %u)", actorId, waypointId, delay); + _vm->_actors[actorId]->_movementTrack->append(waypointId, delay * 1000u, false); } void ScriptBase::AI_Movement_Track_Flush(int actorId) { diff --git a/engines/bladerunner/script/script.h b/engines/bladerunner/script/script.h index 3a31e49481..ac88458f42 100644 --- a/engines/bladerunner/script/script.h +++ b/engines/bladerunner/script/script.h @@ -140,7 +140,7 @@ protected: int Animation_Start(); int Animation_Stop(); int Animation_Skip_To_Frame(); - void Delay(int miliseconds); + void Delay(uint32 miliseconds); void Player_Loses_Control(); void Player_Gains_Control(); void Player_Set_Combat_Mode(bool activate); @@ -172,26 +172,26 @@ protected: void Footstep_Sounds_Set(int index, int value); void Footstep_Sound_Override_On(int footstepSoundOverride); void Footstep_Sound_Override_Off(); - bool Music_Play(int musicId, int volume, int pan, int timeFadeIn, int timePlay, int loop, int timeFadeOut); - void Music_Adjust(int volume, int pan, int delay); - void Music_Stop(int delay); + bool Music_Play(int musicId, int volume, int pan, uint32 timeFadeIn, uint32 timePlay, int loop, uint32 timeFadeOut); + void Music_Adjust(int volume, int pan, uint32 delay); + void Music_Stop(uint32 delay); bool Music_Is_Playing(); void Overlay_Play(const char *overlay, int loopId, bool loopForever, bool startNow, int a5); void Overlay_Remove(const char *overlay); void Scene_Loop_Set_Default(int loopId); void Scene_Loop_Start_Special(int sceneLoopMode, int loopId, bool immediately); void Outtake_Play(int id, int noLocalization = false, int container = -1); - void Ambient_Sounds_Add_Sound(int sfxId, int timeMin, int timeMax, int volumeMin, int volumeMax, int panStartMin, int panStartMax, int panEndMin, int panEndMax, int priority, int unk); + void Ambient_Sounds_Add_Sound(int sfxId, uint32 timeMin, uint32 timeMax, int volumeMin, int volumeMax, int panStartMin, int panStartMax, int panEndMin, int panEndMax, int priority, int unk); void Ambient_Sounds_Remove_Sound(int sfxId, bool stopPlaying); - void Ambient_Sounds_Add_Speech_Sound(int actorId, int sentenceId, int timeMin, int timeMax, int volumeMin, int volumeMax, int panStartMin, int panStartMax, int panEndMin, int panEndMax, int priority, int unk); + void Ambient_Sounds_Add_Speech_Sound(int actorId, int sentenceId, uint32 timeMin, uint32 timeMax, int volumeMin, int volumeMax, int panStartMin, int panStartMax, int panEndMin, int panEndMax, int priority, int unk); // Ambient_Sounds_Remove_Speech_Sound void Ambient_Sounds_Play_Sound(int sfxId, int volume, int panStart, int panEnd, int priority); void Ambient_Sounds_Play_Speech_Sound(int actorId, int sfxId, int volume, int panStart, int panEnd, int priority); void Ambient_Sounds_Remove_All_Non_Looping_Sounds(bool stopPlaying); - void Ambient_Sounds_Add_Looping_Sound(int sfxId, int volume, int pan, int delay); - void Ambient_Sounds_Adjust_Looping_Sound(int sfxId, int volume, int pan, int delay); - void Ambient_Sounds_Remove_Looping_Sound(int sfxId, int delay); - void Ambient_Sounds_Remove_All_Looping_Sounds(int delay); + void Ambient_Sounds_Add_Looping_Sound(int sfxId, int volume, int pan, uint32 delay); + void Ambient_Sounds_Adjust_Looping_Sound(int sfxId, int volume, int pan, uint32 delay); + void Ambient_Sounds_Remove_Looping_Sound(int sfxId, uint32 delay); + void Ambient_Sounds_Remove_All_Looping_Sounds(uint32 delay); void Setup_Scene_Information(float actorX, float actorY, float actorZ, int actorFacing); bool Dialogue_Menu_Appear(int x, int y); bool Dialogue_Menu_Disappear(); @@ -265,21 +265,21 @@ protected: void Set_Fog_Density(const char *fogName, float density); void ADQ_Flush(); void ADQ_Add(int actorId, int sentenceId, int animationMode); - void ADQ_Add_Pause(int delay); + void ADQ_Add_Pause(uint32 delay); void ADQ_Wait_For_All_Queued_Dialogue(); bool Game_Over(); void Autosave_Game(int textId); void I_Sez(const char *str); - void AI_Countdown_Timer_Start(int actorId, signed int timer, int seconds); + void AI_Countdown_Timer_Start(int actorId, signed int timer, uint32 seconds); void AI_Countdown_Timer_Reset(int actorId, int timer); void AI_Movement_Track_Unpause(int actorId); void AI_Movement_Track_Pause(int actorId); void AI_Movement_Track_Repeat(int actorId); - void AI_Movement_Track_Append_Run_With_Facing(int actorId, int waypointId, int delay, int angle); - void AI_Movement_Track_Append_With_Facing(int actorId, int waypointId, int delay, int angle); - void AI_Movement_Track_Append_Run(int actorId, int waypointId, int delay); - void AI_Movement_Track_Append(int actorId, int waypointId, int delay); + void AI_Movement_Track_Append_Run_With_Facing(int actorId, int waypointId, uint32 delay, int angle); + void AI_Movement_Track_Append_With_Facing(int actorId, int waypointId, uint32 delay, int angle); + void AI_Movement_Track_Append_Run(int actorId, int waypointId, uint32 delay); + void AI_Movement_Track_Append(int actorId, int waypointId, uint32 delay); void AI_Movement_Track_Flush(int actorId); void ESPER_Add_Photo(const char *name, int photoId, int shapeId); diff --git a/engines/bladerunner/script/vk_script.cpp b/engines/bladerunner/script/vk_script.cpp index 30dede7721..6c4de428a5 100644 --- a/engines/bladerunner/script/vk_script.cpp +++ b/engines/bladerunner/script/vk_script.cpp @@ -1948,7 +1948,7 @@ void VKScript::askRunciter(int questionId) { VK_Play_Speech_Line(kActorMcCoy, 7660, 0.5f); VK_Play_Speech_Line(kActorMcCoy, 7665, 0.5f); VK_Eye_Animates(1); - Delay(1500); + Delay(1500u); VK_Play_Speech_Line(kActorMcCoy, 8395, 0.5f); // M: You don't have anything to say? VK_Subject_Reacts(12, 8, 1, 0); VK_Play_Speech_Line(kActorRunciter, 1400, 0.5f); // R: What's the point @@ -2312,7 +2312,7 @@ void VKScript::askBulletBob(int questionId) { case 7470: // Low 15 VK_Subject_Reacts(50, -4, 0, -5); if (_vm->_cutContent) { - Delay(2000); + Delay(2000u); VK_Play_Speech_Line(kActorMcCoy, 8270, 0.5f); } VK_Play_Speech_Line(kActorBulletBob, 1240, 0.5f); |