Fix #20349: Tile inspector creates map animations

This commit is contained in:
Michael Bernardi 2023-06-05 20:37:16 +02:00
parent 4a471a3a3e
commit 9c5c1eb858
4 changed files with 96 additions and 88 deletions

View File

@ -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

View File

@ -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;
}
}

View File

@ -14,6 +14,8 @@
#include <cstdint>
#include <vector>
struct TileElement;
struct MapAnimation
{
uint8_t type{};
@ -43,3 +45,4 @@ void MapAnimationCreate(int32_t type, const CoordsXYZ& loc);
void MapAnimationInvalidateAll();
const std::vector<MapAnimation>& GetMapAnimations();
void MapAnimationAutoCreate();
void MapAnimationAutoCreateAtTileElement(TileCoordsXY coords, TileElement* el);

View File

@ -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)