From 9c5c1eb858f56db1be548c18b0d9ae3a30e227cb Mon Sep 17 00:00:00 2001 From: Michael Bernardi Date: Mon, 5 Jun 2023 20:37:16 +0200 Subject: [PATCH] Fix #20349: Tile inspector creates map animations --- src/openrct2/network/NetworkBase.cpp | 2 +- src/openrct2/world/MapAnimation.cpp | 177 ++++++++++++++------------- src/openrct2/world/MapAnimation.h | 3 + src/openrct2/world/TileInspector.cpp | 2 + 4 files changed, 96 insertions(+), 88 deletions(-) diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 740b9a7239..0207abcb3f 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -43,7 +43,7 @@ // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -#define NETWORK_STREAM_VERSION "6" +#define NETWORK_STREAM_VERSION "7" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION diff --git a/src/openrct2/world/MapAnimation.cpp b/src/openrct2/world/MapAnimation.cpp index c467fb10e7..56d50ed7c3 100644 --- a/src/openrct2/world/MapAnimation.cpp +++ b/src/openrct2/world/MapAnimation.cpp @@ -610,92 +610,95 @@ void MapAnimationAutoCreate() TileElementIteratorBegin(&it); while (TileElementIteratorNext(&it)) { - auto el = it.element; - auto loc = CoordsXYZ{ TileCoordsXY(it.x, it.y).ToCoordsXY(), el->GetBaseZ() }; - switch (el->GetType()) - { - case TileElementType::Banner: - MapAnimationCreate(MAP_ANIMATION_TYPE_BANNER, loc); - break; - case TileElementType::Wall: - { - auto wallEl = el->AsWall(); - auto* entry = wallEl->GetEntry(); - if (entry != nullptr - && ((entry->flags2 & WALL_SCENERY_2_ANIMATED) || entry->scrolling_mode != SCROLLING_MODE_NONE)) - { - MapAnimationCreate(MAP_ANIMATION_TYPE_WALL, loc); - } - break; - } - case TileElementType::SmallScenery: - { - auto sceneryEl = el->AsSmallScenery(); - auto* sceneryEntry = sceneryEl->GetEntry(); - if (sceneryEntry != nullptr && sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_ANIMATED)) - { - MapAnimationCreate(MAP_ANIMATION_TYPE_SMALL_SCENERY, loc); - } - break; - } - case TileElementType::LargeScenery: - { - auto sceneryEl = el->AsLargeScenery(); - auto entry = sceneryEl->GetEntry(); - if (entry != nullptr && (entry->flags & LARGE_SCENERY_FLAG_ANIMATED)) - { - MapAnimationCreate(MAP_ANIMATION_TYPE_LARGE_SCENERY, loc); - } - break; - } - case TileElementType::Path: - { - auto path = el->AsPath(); - if (path->HasQueueBanner()) - { - MapAnimationCreate(MAP_ANIMATION_TYPE_QUEUE_BANNER, loc); - } - break; - } - case TileElementType::Entrance: - { - auto entrance = el->AsEntrance(); - switch (entrance->GetEntranceType()) - { - case ENTRANCE_TYPE_PARK_ENTRANCE: - if (entrance->GetSequenceIndex() == 0) - { - MapAnimationCreate(MAP_ANIMATION_TYPE_PARK_ENTRANCE, loc); - } - break; - case ENTRANCE_TYPE_RIDE_ENTRANCE: - MapAnimationCreate(MAP_ANIMATION_TYPE_RIDE_ENTRANCE, loc); - break; - } - break; - } - case TileElementType::Track: - { - auto track = el->AsTrack(); - switch (track->GetTrackType()) - { - case TrackElemType::Waterfall: - MapAnimationCreate(MAP_ANIMATION_TYPE_TRACK_WATERFALL, loc); - break; - case TrackElemType::Rapids: - MapAnimationCreate(MAP_ANIMATION_TYPE_TRACK_RAPIDS, loc); - break; - case TrackElemType::Whirlpool: - MapAnimationCreate(MAP_ANIMATION_TYPE_TRACK_WHIRLPOOL, loc); - break; - case TrackElemType::SpinningTunnel: - MapAnimationCreate(MAP_ANIMATION_TYPE_TRACK_SPINNINGTUNNEL, loc); - break; - } - break; - } - case TileElementType::Surface: - break; - } + MapAnimationAutoCreateAtTileElement(TileCoordsXY(it.x, it.y), it.element); + } +} + +void MapAnimationAutoCreateAtTileElement(TileCoordsXY coords, TileElement* el) +{ + auto loc = CoordsXYZ{ coords.ToCoordsXY(), el->GetBaseZ() }; + switch (el->GetType()) + { + case TileElementType::Banner: + MapAnimationCreate(MAP_ANIMATION_TYPE_BANNER, loc); + break; + case TileElementType::Wall: + { + auto wallEl = el->AsWall(); + auto* entry = wallEl->GetEntry(); + if (entry != nullptr && ((entry->flags2 & WALL_SCENERY_2_ANIMATED) || entry->scrolling_mode != SCROLLING_MODE_NONE)) + { + MapAnimationCreate(MAP_ANIMATION_TYPE_WALL, loc); + } + break; + } + case TileElementType::SmallScenery: + { + auto sceneryEl = el->AsSmallScenery(); + auto* sceneryEntry = sceneryEl->GetEntry(); + if (sceneryEntry != nullptr && sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_ANIMATED)) + { + MapAnimationCreate(MAP_ANIMATION_TYPE_SMALL_SCENERY, loc); + } + break; + } + case TileElementType::LargeScenery: + { + auto sceneryEl = el->AsLargeScenery(); + auto entry = sceneryEl->GetEntry(); + if (entry != nullptr && (entry->flags & LARGE_SCENERY_FLAG_ANIMATED)) + { + MapAnimationCreate(MAP_ANIMATION_TYPE_LARGE_SCENERY, loc); + } + break; + } + case TileElementType::Path: + { + auto path = el->AsPath(); + if (path->HasQueueBanner()) + { + MapAnimationCreate(MAP_ANIMATION_TYPE_QUEUE_BANNER, loc); + } + break; + } + case TileElementType::Entrance: + { + auto entrance = el->AsEntrance(); + switch (entrance->GetEntranceType()) + { + case ENTRANCE_TYPE_PARK_ENTRANCE: + if (entrance->GetSequenceIndex() == 0) + { + MapAnimationCreate(MAP_ANIMATION_TYPE_PARK_ENTRANCE, loc); + } + break; + case ENTRANCE_TYPE_RIDE_ENTRANCE: + MapAnimationCreate(MAP_ANIMATION_TYPE_RIDE_ENTRANCE, loc); + break; + } + break; + } + case TileElementType::Track: + { + auto track = el->AsTrack(); + switch (track->GetTrackType()) + { + case TrackElemType::Waterfall: + MapAnimationCreate(MAP_ANIMATION_TYPE_TRACK_WATERFALL, loc); + break; + case TrackElemType::Rapids: + MapAnimationCreate(MAP_ANIMATION_TYPE_TRACK_RAPIDS, loc); + break; + case TrackElemType::Whirlpool: + MapAnimationCreate(MAP_ANIMATION_TYPE_TRACK_WHIRLPOOL, loc); + break; + case TrackElemType::SpinningTunnel: + MapAnimationCreate(MAP_ANIMATION_TYPE_TRACK_SPINNINGTUNNEL, loc); + break; + } + break; + } + case TileElementType::Surface: + break; } } diff --git a/src/openrct2/world/MapAnimation.h b/src/openrct2/world/MapAnimation.h index ada1270d68..5aa77e9290 100644 --- a/src/openrct2/world/MapAnimation.h +++ b/src/openrct2/world/MapAnimation.h @@ -14,6 +14,8 @@ #include #include +struct TileElement; + struct MapAnimation { uint8_t type{}; @@ -43,3 +45,4 @@ void MapAnimationCreate(int32_t type, const CoordsXYZ& loc); void MapAnimationInvalidateAll(); const std::vector& GetMapAnimations(); void MapAnimationAutoCreate(); +void MapAnimationAutoCreateAtTileElement(TileCoordsXY coords, TileElement* el); diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index 440ffbd492..0275e5cf6e 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -23,6 +23,7 @@ #include "../ride/TrackData.h" #include "../windows/Intent.h" #include "../windows/TileInspectorGlobals.h" +#include "../world/MapAnimation.h" #include "Banner.h" #include "Footpath.h" #include "Location.hpp" @@ -364,6 +365,7 @@ namespace OpenRCT2::TileInspector *pastedElement = element; pastedElement->SetLastForTile(lastForTile); + MapAnimationAutoCreateAtTileElement(tileLoc, pastedElement); MapInvalidateTileFull(loc); if (auto* inspector = GetTileInspectorWithPos(loc); inspector != nullptr)