From 500b0d09aa89b8c935dcc9954dbae2beee5963b6 Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Mon, 17 Jul 2017 16:55:04 +0200 Subject: [PATCH] Add follow sprite command to title sequence --- src/openrct2/title/TitleSequence.cpp | 5 +++++ src/openrct2/title/TitleSequence.h | 12 +++++++----- src/openrct2/title/TitleSequencePlayer.cpp | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/openrct2/title/TitleSequence.cpp b/src/openrct2/title/TitleSequence.cpp index 8ffa6b80d9..189dcda04d 100644 --- a/src/openrct2/title/TitleSequence.cpp +++ b/src/openrct2/title/TitleSequence.cpp @@ -456,6 +456,11 @@ static std::vector LegacyScriptRead(utf8 * script, size_t scriptLe command.Type = TITLE_SCRIPT_SPEED; command.Speed = Math::Max(1, Math::Min(4, atoi(part1) & 0xFF)); } + else if (_stricmp(token, "FOLLOW") == 0) + { + command.Type = TITLE_SCRIPT_FOLLOW; + command.SpriteIndex = atoi(part1) & 0xFFFF; + } else if (_stricmp(token, "WAIT") == 0) { command.Type = TITLE_SCRIPT_WAIT; diff --git a/src/openrct2/title/TitleSequence.h b/src/openrct2/title/TitleSequence.h index bf3015eb9b..34069a3665 100644 --- a/src/openrct2/title/TitleSequence.h +++ b/src/openrct2/title/TitleSequence.h @@ -30,11 +30,12 @@ typedef struct TitleCommand uint8 X; uint8 Y; }; - uint8 Rotations; // ROTATE (counter-clockwise) - uint8 Zoom; // ZOOM - uint8 Speed; // SPEED - uint16 Milliseconds; // WAIT - utf8 Scenario[TITLE_COMMAND_SCENARIO_LENGTH]; // LOADSC + uint8 Rotations; // ROTATE (counter-clockwise) + uint8 Zoom; // ZOOM + uint16 SpriteIndex; // FOLLOW + uint8 Speed; // SPEED + uint16 Milliseconds; // WAIT + utf8 Scenario[TITLE_COMMAND_SCENARIO_LENGTH]; // LOADSC }; } TitleCommand; @@ -66,6 +67,7 @@ enum TITLE_SCRIPT TITLE_SCRIPT_LOCATION, TITLE_SCRIPT_ROTATE, TITLE_SCRIPT_ZOOM, + TITLE_SCRIPT_FOLLOW, TITLE_SCRIPT_RESTART, TITLE_SCRIPT_LOAD, TITLE_SCRIPT_END, diff --git a/src/openrct2/title/TitleSequencePlayer.cpp b/src/openrct2/title/TitleSequencePlayer.cpp index 81dc930681..6ca2963aea 100644 --- a/src/openrct2/title/TitleSequencePlayer.cpp +++ b/src/openrct2/title/TitleSequencePlayer.cpp @@ -289,6 +289,9 @@ private: case TITLE_SCRIPT_SPEED: gGameSpeed = Math::Clamp(1, command->Speed, 4); break; + case TITLE_SCRIPT_FOLLOW: + FollowSprite(command->SpriteIndex); + break; case TITLE_SCRIPT_RESTART: Reset(); break; @@ -379,6 +382,14 @@ private: } } + void FollowSprite(uint16 SpriteIndex) { + rct_window *const MainWindow = window_get_main(); + if (MainWindow != nullptr) + { + MainWindow->viewport_target_sprite = SpriteIndex; + } + } + bool LoadParkFromFile(const utf8 * path) { log_verbose("TitleSequencePlayer::LoadParkFromFile(%s)", path); @@ -536,6 +547,9 @@ private: _lastScreenHeight = w->height; _viewCentreLocation.x = x; _viewCentreLocation.y = y; + + // Stop following sprites + w->viewport_target_sprite = SPRITE_INDEX_NULL; } }