From bf03de4755dfa51d51d42073f4599bae814a5d6b Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 15 Dec 2018 11:51:05 +0100 Subject: [PATCH] Focus camera on last replay event. --- src/openrct2/ReplayManager.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/openrct2/ReplayManager.cpp b/src/openrct2/ReplayManager.cpp index 89d253ab9b..f26921ce3d 100644 --- a/src/openrct2/ReplayManager.cpp +++ b/src/openrct2/ReplayManager.cpp @@ -717,6 +717,8 @@ namespace OpenRCT2 _nextReplayTick = gCurrentTicks + 1; } + bool isPositionValid = false; + if (command.action != nullptr) { GameAction* action = command.action.get(); @@ -725,11 +727,28 @@ namespace OpenRCT2 Guard::Assert(action != nullptr); GameActionResult::Ptr result = GameActions::Execute(action); + if (result->Error == GA_ERROR::OK) + { + isPositionValid = true; + } } else { uint32_t flags = command.ebx | GAME_COMMAND_FLAG_REPLAY; - game_do_command(command.eax, flags, command.ecx, command.edx, command.esi, command.edi, command.ebp); + int32_t res = game_do_command( + command.eax, flags, command.ecx, command.edx, command.esi, command.edi, command.ebp); + if (res != MONEY32_UNDEFINED) + { + isPositionValid = true; + } + } + + // Focus camera on event. + if (isPositionValid && gCommandPosition.x != 0x8000) + { + auto* mainWindow = window_get_main(); + if (mainWindow != nullptr) + window_scroll_to_location(mainWindow, gCommandPosition.x, gCommandPosition.y, gCommandPosition.z); } replayQueue.erase(replayQueue.begin());