From aed3a9cb3b2ffcefc08b0b067e5b13c31d67f2c0 Mon Sep 17 00:00:00 2001 From: mix Date: Mon, 26 May 2025 00:24:45 +0100 Subject: [PATCH] Prevent scrolling text map animations invalidating when not drawn --- src/openrct2/world/MapAnimation.cpp | 34 ++++++++++++++++------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/openrct2/world/MapAnimation.cpp b/src/openrct2/world/MapAnimation.cpp index d3b15f670e..0a3f5c2600 100644 --- a/src/openrct2/world/MapAnimation.cpp +++ b/src/openrct2/world/MapAnimation.cpp @@ -42,6 +42,7 @@ using namespace OpenRCT2; constexpr ZoomLevel kMaxZoom{ 2 }; +constexpr ZoomLevel kMaxScrollingTextZoom{ 0 }; struct TemporaryMapAnimation { @@ -76,15 +77,17 @@ static std::set _mapAnimationsUpdate; static std::set _temporaryMapAnimations; template -static void Invalidate(const Viewport* const viewport, const int32_t x, const int32_t y, const int32_t z0, const int32_t z1) +static void Invalidate( + const Viewport* const viewport, const int32_t x, const int32_t y, const int32_t z0, const int32_t z1, + const ZoomLevel maxZoom) { if constexpr (invalidateAllViewports) { - ViewportsInvalidate(x, y, z0, z1, kMaxZoom); + ViewportsInvalidate(x, y, z0, z1, maxZoom); } else { - viewport->Invalidate(x, y, z0, z1, kMaxZoom); + viewport->Invalidate(x, y, z0, z1, maxZoom); } } @@ -103,7 +106,8 @@ static bool UpdateEntranceAnimation( if constexpr (invalidate) { Invalidate( - viewport, loc.x, loc.y, baseZ + stationObj->Height + 8, baseZ + stationObj->Height + 24); + viewport, loc.x, loc.y, baseZ + stationObj->Height + 8, baseZ + stationObj->Height + 24, + kMaxScrollingTextZoom); } return true; } @@ -116,7 +120,7 @@ static bool UpdateEntranceAnimation( const int32_t direction = (entrance.GetDirection() + GetCurrentRotation()) & 3; if (direction == TILE_ELEMENT_DIRECTION_SOUTH || direction == TILE_ELEMENT_DIRECTION_WEST) { - Invalidate(viewport, loc.x, loc.y, baseZ + 32, baseZ + 64); + Invalidate(viewport, loc.x, loc.y, baseZ + 32, baseZ + 64, kMaxScrollingTextZoom); } } return true; @@ -136,7 +140,7 @@ static bool UpdatePathAnimation( const int32_t direction = (path.GetQueueBannerDirection() + GetCurrentRotation()) & 3; if (direction == TILE_ELEMENT_DIRECTION_NORTH || direction == TILE_ELEMENT_DIRECTION_EAST) { - Invalidate(viewport, loc.x, loc.y, baseZ + 16, baseZ + 30); + Invalidate(viewport, loc.x, loc.y, baseZ + 16, baseZ + 30, kMaxScrollingTextZoom); } } return true; @@ -184,13 +188,13 @@ static std::optional UpdateSmallSceneryAnimation( } if constexpr (invalidate) { - Invalidate(viewport, loc.x, loc.y, baseZ, scenery.GetClearanceZ()); + Invalidate(viewport, loc.x, loc.y, baseZ, scenery.GetClearanceZ(), kMaxZoom); } } } else if constexpr (invalidate) { - Invalidate(viewport, loc.x, loc.y, baseZ, scenery.GetClearanceZ()); + Invalidate(viewport, loc.x, loc.y, baseZ, scenery.GetClearanceZ(), kMaxZoom); } return std::optional(animationType); } @@ -206,20 +210,20 @@ static bool UpdateTrackAnimation(TrackElement& track, const CoordsXYZ& loc, cons case TrackElemType::Waterfall: if constexpr (invalidate) { - Invalidate(viewport, loc.x, loc.y, baseZ + 14, baseZ + 46); + Invalidate(viewport, loc.x, loc.y, baseZ + 14, baseZ + 46, kMaxZoom); } return true; case TrackElemType::Rapids: case TrackElemType::Whirlpool: if constexpr (invalidate) { - Invalidate(viewport, loc.x, loc.y, baseZ + 14, baseZ + 18); + Invalidate(viewport, loc.x, loc.y, baseZ + 14, baseZ + 18, kMaxZoom); } return true; case TrackElemType::SpinningTunnel: if constexpr (invalidate) { - Invalidate(viewport, loc.x, loc.y, baseZ + 14, baseZ + 32); + Invalidate(viewport, loc.x, loc.y, baseZ + 14, baseZ + 32, kMaxZoom); } return true; default: @@ -238,7 +242,7 @@ static bool UpdateLargeSceneryAnimation( { if constexpr (invalidate) { - Invalidate(viewport, loc.x, loc.y, baseZ, baseZ + 16); + Invalidate(viewport, loc.x, loc.y, baseZ, baseZ + 16, kMaxZoom); } return true; } @@ -291,7 +295,7 @@ static std::optional UpdateWallAnimation( wall.SetAnimationFrame(newFrame); if constexpr (invalidate) { - Invalidate(viewport, loc.x, loc.y, baseZ, baseZ + 32); + Invalidate(viewport, loc.x, loc.y, baseZ, baseZ + 32, kMaxZoom); } } } @@ -302,7 +306,7 @@ static std::optional UpdateWallAnimation( { if constexpr (invalidate) { - Invalidate(viewport, loc.x, loc.y, baseZ, baseZ + 16); + Invalidate(viewport, loc.x, loc.y, baseZ, baseZ + 16, kMaxZoom); } return std::optional(UpdateType::invalidate); } @@ -316,7 +320,7 @@ static bool UpdateBannerAnimation( { if constexpr (invalidate) { - Invalidate(viewport, loc.x, loc.y, baseZ, baseZ + 16); + Invalidate(viewport, loc.x, loc.y, baseZ, baseZ + 16, kMaxScrollingTextZoom); } return true; }