Files
OpenRCT2-Web/src/openrct2/world/MapAnimation.cpp
T

722 lines
20 KiB
C++
Raw Normal View History

/*****************************************************************************
2019-03-17 08:16:15 +01:00
* Copyright (c) 2014-2019 OpenRCT2 developers
*
2018-06-15 14:07:34 +02:00
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
2018-06-15 14:07:34 +02:00
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
2018-06-22 23:17:03 +02:00
#include "MapAnimation.h"
2018-03-14 12:44:16 +01:00
#include "../Context.h"
2017-11-30 18:17:06 +01:00
#include "../Game.h"
2018-06-22 23:17:03 +02:00
#include "../interface/Viewport.h"
#include "../object/StationObject.h"
2017-12-31 13:21:34 +01:00
#include "../ride/Ride.h"
2018-01-10 00:00:09 +01:00
#include "../ride/RideData.h"
2017-10-17 13:51:47 +02:00
#include "../ride/Track.h"
2018-05-01 17:47:00 +02:00
#include "../world/Wall.h"
2019-02-14 22:41:48 +01:00
#include "Banner.h"
2018-06-22 23:17:03 +02:00
#include "Footpath.h"
2018-09-14 12:12:22 +02:00
#include "LargeScenery.h"
2018-01-03 14:56:08 +01:00
#include "Map.h"
2018-01-11 10:59:26 +01:00
#include "Scenery.h"
2017-12-04 20:09:38 +01:00
#include "SmallScenery.h"
2018-01-11 10:59:26 +01:00
#include "Sprite.h"
2018-06-22 23:17:03 +02:00
2019-12-19 18:38:46 +00:00
using map_animation_invalidate_event_handler = bool (*)(CoordsXYZ loc);
static std::vector<MapAnimation> _mapAnimations;
constexpr size_t MAX_ANIMATED_OBJECTS = 2000;
static bool InvalidateMapAnimation(const MapAnimation& obj);
static bool DoesAnimationExist(int32_t type, const CoordsXYZ& location)
{
for (const auto& a : _mapAnimations)
{
if (a.type == type && a.location == location)
{
// Animation already exists
return true;
}
}
return false;
}
2019-12-19 18:38:46 +00:00
void map_animation_create(int32_t type, const CoordsXYZ loc)
{
2019-12-19 18:38:46 +00:00
if (!DoesAnimationExist(type, loc))
2018-06-22 23:17:03 +02:00
{
if (_mapAnimations.size() < MAX_ANIMATED_OBJECTS)
{
// Create new animation
2019-12-19 18:38:46 +00:00
_mapAnimations.push_back({ (uint8_t)type, loc });
}
else
{
log_error("Exceeded the maximum number of animations");
}
2017-06-06 23:24:18 +02:00
}
}
/**
*
* rct2: 0x0068AFAD
*/
void map_animation_invalidate_all()
{
auto it = _mapAnimations.begin();
while (it != _mapAnimations.end())
2018-06-22 23:17:03 +02:00
{
if (InvalidateMapAnimation(*it))
2018-06-22 23:17:03 +02:00
{
// Map animation has finished, remove it
it = _mapAnimations.erase(it);
2018-06-22 23:17:03 +02:00
}
else
{
it++;
2017-06-06 23:24:18 +02:00
}
}
}
/**
*
* rct2: 0x00666670
*/
2019-12-19 18:38:46 +00:00
static bool map_animation_invalidate_ride_entrance(CoordsXYZ loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
auto tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE)
2017-06-06 23:24:18 +02:00
continue;
2018-09-26 12:13:44 +02:00
if (tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_RIDE_ENTRANCE)
2017-06-06 23:24:18 +02:00
continue;
auto ride = get_ride(tileElement->AsEntrance()->GetRideIndex());
if (ride != nullptr)
{
auto stationObj = ride_get_station_object(ride);
if (stationObj != nullptr)
{
2019-12-19 18:38:46 +00:00
int32_t height = loc.z + stationObj->Height + 8;
map_invalidate_tile_zoom1(loc.x, loc.y, height, height + 16);
}
}
2017-06-06 23:24:18 +02:00
return false;
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006A7BD4
*/
2019-12-19 18:38:46 +00:00
static bool map_animation_invalidate_queue_banner(CoordsXYZ loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
2017-06-06 23:24:18 +02:00
continue;
if (!(tileElement->AsPath()->IsQueue()))
2017-06-06 23:24:18 +02:00
continue;
if (!tileElement->AsPath()->HasQueueBanner())
2017-06-06 23:24:18 +02:00
continue;
int32_t direction = (tileElement->AsPath()->GetQueueBannerDirection() + get_current_rotation()) & 3;
2018-06-22 23:17:03 +02:00
if (direction == TILE_ELEMENT_DIRECTION_NORTH || direction == TILE_ELEMENT_DIRECTION_EAST)
{
2019-12-19 18:38:46 +00:00
map_invalidate_tile_zoom1(loc.x, loc.y, loc.z + 16, loc.z + 30);
2017-06-06 23:24:18 +02:00
}
return false;
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006E32C9
*/
2019-12-19 18:38:46 +00:00
static bool map_animation_invalidate_small_scenery(CoordsXYZ loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
2018-06-22 23:17:03 +02:00
rct_scenery_entry* sceneryEntry;
rct_sprite* sprite;
2019-02-28 19:28:58 +00:00
Peep* peep;
tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY)
2017-06-06 23:24:18 +02:00
continue;
2019-02-26 10:09:58 +00:00
if (tileElement->IsGhost())
2017-06-06 23:24:18 +02:00
continue;
2018-09-13 18:12:20 +02:00
sceneryEntry = tileElement->AsSmallScenery()->GetEntry();
2019-02-05 11:02:22 -08:00
if (sceneryEntry == nullptr)
continue;
2018-06-22 23:17:03 +02:00
if (scenery_small_entry_has_flag(
sceneryEntry,
SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_1 | SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_4 | SMALL_SCENERY_FLAG_SWAMP_GOO
| SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS))
2017-12-04 20:09:38 +01:00
{
2019-12-22 22:14:02 +01:00
map_invalidate_tile_zoom1(loc.x, loc.y, loc.z, tileElement->GetClearanceZ());
2017-06-06 23:24:18 +02:00
return false;
}
2017-12-04 20:09:38 +01:00
if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_IS_CLOCK))
{
2017-06-06 23:24:18 +02:00
// Peep, looking at scenery
2018-06-22 23:17:03 +02:00
if (!(gCurrentTicks & 0x3FF) && game_is_not_paused())
{
2018-09-14 11:14:19 +02:00
int32_t direction = tileElement->GetDirection();
2019-12-19 18:38:46 +00:00
int32_t x2 = loc.x - CoordsDirectionDelta[direction].x;
int32_t y2 = loc.y - CoordsDirectionDelta[direction].y;
uint16_t spriteIdx = sprite_get_first_in_quadrant(x2, y2);
for (; spriteIdx != SPRITE_INDEX_NULL; spriteIdx = sprite->generic.next_in_quadrant)
2018-06-22 23:17:03 +02:00
{
2017-06-06 23:24:18 +02:00
sprite = get_sprite(spriteIdx);
if (sprite->generic.linked_list_index != SPRITE_LIST_PEEP)
2017-06-06 23:24:18 +02:00
continue;
2017-06-06 23:24:18 +02:00
peep = &sprite->peep;
if (peep->state != PEEP_STATE_WALKING)
continue;
2019-12-19 18:38:46 +00:00
if (peep->z != loc.z)
2017-06-06 23:24:18 +02:00
continue;
if (peep->action < PEEP_ACTION_NONE_1)
continue;
2017-06-06 23:24:18 +02:00
peep->action = PEEP_ACTION_CHECK_TIME;
peep->action_frame = 0;
peep->action_sprite_image_offset = 0;
2018-04-01 20:35:41 +01:00
peep->UpdateCurrentActionSpriteType();
2017-06-06 23:24:18 +02:00
invalidate_sprite_1((rct_sprite*)peep);
break;
}
}
2019-12-22 22:14:02 +01:00
map_invalidate_tile_zoom1(loc.x, loc.y, loc.z, tileElement->GetClearanceZ());
2017-06-06 23:24:18 +02:00
return false;
}
2017-10-15 15:53:16 +02:00
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x00666C63
*/
2019-12-19 18:38:46 +00:00
static bool map_animation_invalidate_park_entrance(CoordsXYZ loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE)
2017-06-06 23:24:18 +02:00
continue;
2018-09-26 12:13:44 +02:00
if (tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->AsEntrance()->GetSequenceIndex())
2017-06-06 23:24:18 +02:00
continue;
2019-12-19 18:38:46 +00:00
map_invalidate_tile_zoom1(loc.x, loc.y, loc.z + 32, loc.z + 64);
2017-06-06 23:24:18 +02:00
return false;
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006CE29E
*/
2019-12-19 18:38:46 +00:00
static bool map_animation_invalidate_track_waterfall(CoordsXYZ loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
2017-06-06 23:24:18 +02:00
continue;
2018-09-17 21:54:36 +02:00
if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_WATERFALL)
2018-06-22 23:17:03 +02:00
{
2019-12-19 18:38:46 +00:00
map_invalidate_tile_zoom1(loc.x, loc.y, loc.z + 14, loc.z + 46);
2017-06-06 23:24:18 +02:00
return false;
}
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006CE2F3
*/
2019-12-19 18:38:46 +00:00
static bool map_animation_invalidate_track_rapids(CoordsXYZ loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
2017-06-06 23:24:18 +02:00
continue;
2018-09-17 21:54:36 +02:00
if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_RAPIDS)
2018-06-22 23:17:03 +02:00
{
2019-12-19 18:38:46 +00:00
map_invalidate_tile_zoom1(loc.x, loc.y, loc.z + 14, loc.z + 18);
2017-06-06 23:24:18 +02:00
return false;
}
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006CE39D
*/
2019-12-19 18:38:46 +00:00
static bool map_animation_invalidate_track_onridephoto(CoordsXYZ loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
2017-06-06 23:24:18 +02:00
continue;
2018-09-17 21:54:36 +02:00
if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_ON_RIDE_PHOTO)
2018-06-22 23:17:03 +02:00
{
2019-12-22 22:14:02 +01:00
map_invalidate_tile_zoom1(loc.x, loc.y, loc.z, tileElement->GetClearanceZ());
2018-06-22 23:17:03 +02:00
if (game_is_paused())
{
2017-06-06 23:24:18 +02:00
return false;
}
2018-09-18 13:49:58 +02:00
if (tileElement->AsTrack()->IsTakingPhoto())
2018-06-22 23:17:03 +02:00
{
2018-09-18 13:49:58 +02:00
tileElement->AsTrack()->DecrementPhotoTimeout();
2017-06-06 23:24:18 +02:00
return false;
2018-06-22 23:17:03 +02:00
}
else
{
2017-06-06 23:24:18 +02:00
return true;
}
}
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006CE348
*/
2019-12-19 18:38:46 +00:00
static bool map_animation_invalidate_track_whirlpool(CoordsXYZ loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
2017-06-06 23:24:18 +02:00
continue;
2018-09-17 21:54:36 +02:00
if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_WHIRLPOOL)
2018-06-22 23:17:03 +02:00
{
2019-12-19 18:38:46 +00:00
map_invalidate_tile_zoom1(loc.x, loc.y, loc.z + 14, loc.z + 18);
2017-06-06 23:24:18 +02:00
return false;
}
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006CE3FA
*/
2019-12-19 18:38:46 +00:00
static bool map_animation_invalidate_track_spinningtunnel(CoordsXYZ loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
2017-06-06 23:24:18 +02:00
continue;
2018-09-17 21:54:36 +02:00
if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_SPINNING_TUNNEL)
2018-06-22 23:17:03 +02:00
{
2019-12-19 18:38:46 +00:00
map_invalidate_tile_zoom1(loc.x, loc.y, loc.z + 14, loc.z + 32);
2017-06-06 23:24:18 +02:00
return false;
}
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x0068DF8F
*/
2019-12-19 18:38:46 +00:00
static bool map_animation_invalidate_remove([[maybe_unused]] CoordsXYZ loc)
{
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006BA2BB
*/
2019-12-19 18:38:46 +00:00
static bool map_animation_invalidate_banner(CoordsXYZ loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_BANNER)
2017-06-06 23:24:18 +02:00
continue;
2019-12-19 18:38:46 +00:00
map_invalidate_tile_zoom1(loc.x, loc.y, loc.z, loc.z + 16);
2017-06-06 23:24:18 +02:00
return false;
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006B94EB
*/
2019-12-19 18:38:46 +00:00
static bool map_animation_invalidate_large_scenery(CoordsXYZ loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
2018-06-22 23:17:03 +02:00
rct_scenery_entry* sceneryEntry;
2017-06-06 23:24:18 +02:00
bool wasInvalidated = false;
tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_LARGE_SCENERY)
2017-06-06 23:24:18 +02:00
continue;
2018-09-14 12:12:22 +02:00
sceneryEntry = tileElement->AsLargeScenery()->GetEntry();
2018-06-22 23:17:03 +02:00
if (sceneryEntry->large_scenery.flags & LARGE_SCENERY_FLAG_ANIMATED)
{
2019-12-19 18:38:46 +00:00
map_invalidate_tile_zoom1(loc.x, loc.y, loc.z, loc.z + 16);
2017-06-06 23:24:18 +02:00
wasInvalidated = true;
}
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return !wasInvalidated;
}
/**
*
* rct2: 0x006E5B50
*/
2019-12-19 18:38:46 +00:00
static bool map_animation_invalidate_wall_door(CoordsXYZ loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
2018-06-22 23:17:03 +02:00
rct_scenery_entry* sceneryEntry;
2017-06-06 23:24:18 +02:00
if (gCurrentTicks & 1)
return false;
2017-06-06 23:24:18 +02:00
bool removeAnimation = true;
tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr)
return removeAnimation;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL)
2017-06-06 23:24:18 +02:00
continue;
2018-09-17 15:42:34 +02:00
sceneryEntry = tileElement->AsWall()->GetEntry();
2017-06-06 23:24:18 +02:00
if (!(sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR))
continue;
2018-06-22 23:17:03 +02:00
if (game_is_paused())
{
2017-06-06 23:24:18 +02:00
return false;
}
2017-02-18 08:26:33 +00:00
2017-06-06 23:24:18 +02:00
bool invalidate = false;
2017-02-25 09:36:28 +00:00
uint8_t currentFrame = tileElement->AsWall()->GetAnimationFrame();
2018-06-22 23:17:03 +02:00
if (currentFrame != 0)
{
if (currentFrame == 15)
{
2017-06-06 23:24:18 +02:00
currentFrame = 0;
2018-06-22 23:17:03 +02:00
}
else
{
2017-06-06 23:24:18 +02:00
removeAnimation = false;
2018-06-22 23:17:03 +02:00
if (currentFrame != 5)
{
2017-06-06 23:24:18 +02:00
currentFrame++;
2017-11-22 22:53:13 +00:00
if (currentFrame == 13 && !(sceneryEntry->wall.flags & WALL_SCENERY_LONG_DOOR_ANIMATION))
2017-06-06 23:24:18 +02:00
currentFrame = 15;
2017-02-18 08:26:33 +00:00
2017-06-06 23:24:18 +02:00
invalidate = true;
}
}
}
tileElement->AsWall()->SetAnimationFrame(currentFrame);
2018-06-22 23:17:03 +02:00
if (invalidate)
{
2019-12-19 18:38:46 +00:00
map_invalidate_tile_zoom1(loc.x, loc.y, loc.z, loc.z + 32);
2017-06-06 23:24:18 +02:00
}
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return removeAnimation;
}
/**
*
* rct2: 0x006E5EE4
*/
2019-12-19 18:38:46 +00:00
static bool map_animation_invalidate_wall(CoordsXYZ loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
2018-06-22 23:17:03 +02:00
rct_scenery_entry* sceneryEntry;
2017-06-06 23:24:18 +02:00
bool wasInvalidated = false;
tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL)
2017-06-06 23:24:18 +02:00
continue;
2018-09-17 15:42:34 +02:00
sceneryEntry = tileElement->AsWall()->GetEntry();
2017-10-15 15:53:16 +02:00
2018-12-05 23:01:13 +01:00
if (!sceneryEntry
2019-02-14 22:41:48 +01:00
|| (!(sceneryEntry->wall.flags2 & WALL_SCENERY_2_ANIMATED)
&& sceneryEntry->wall.scrolling_mode == SCROLLING_MODE_NONE))
2017-06-06 23:24:18 +02:00
continue;
2019-12-19 18:38:46 +00:00
map_invalidate_tile_zoom1(loc.x, loc.y, loc.z, loc.z + 16);
2017-06-06 23:24:18 +02:00
wasInvalidated = true;
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return !wasInvalidated;
}
2015-12-11 09:38:37 -06:00
/**
*
* rct2: 0x009819DC
*/
static constexpr const map_animation_invalidate_event_handler _animatedObjectEventHandlers[MAP_ANIMATION_TYPE_COUNT] = {
map_animation_invalidate_ride_entrance,
map_animation_invalidate_queue_banner,
map_animation_invalidate_small_scenery,
map_animation_invalidate_park_entrance,
map_animation_invalidate_track_waterfall,
map_animation_invalidate_track_rapids,
map_animation_invalidate_track_onridephoto,
map_animation_invalidate_track_whirlpool,
map_animation_invalidate_track_spinningtunnel,
map_animation_invalidate_remove,
map_animation_invalidate_banner,
map_animation_invalidate_large_scenery,
map_animation_invalidate_wall_door,
map_animation_invalidate_wall
};
2018-01-11 10:59:26 +01:00
/**
* @returns true if the animation should be removed.
*/
static bool InvalidateMapAnimation(const MapAnimation& a)
2018-01-11 10:59:26 +01:00
{
if (a.type < std::size(_animatedObjectEventHandlers))
{
2019-12-19 18:38:46 +00:00
return _animatedObjectEventHandlers[a.type](a.location);
}
return true;
}
2018-06-22 23:17:03 +02:00
const std::vector<MapAnimation>& GetMapAnimations()
{
return _mapAnimations;
}
static void ClearMapAnimations()
{
_mapAnimations.clear();
}
void AutoCreateMapAnimations()
{
ClearMapAnimations();
tile_element_iterator it;
tile_element_iterator_begin(&it);
while (tile_element_iterator_next(&it))
{
auto el = it.element;
2019-12-22 22:14:02 +01:00
auto loc = CoordsXYZ{ it.x * 32, it.y * 32, el->GetBaseZ() };
switch (el->GetType())
{
case TILE_ELEMENT_TYPE_BANNER:
2019-12-19 18:38:46 +00:00
map_animation_create(MAP_ANIMATION_TYPE_BANNER, loc);
break;
case TILE_ELEMENT_TYPE_WALL:
{
auto wallEl = el->AsWall();
auto entry = wallEl->GetEntry();
if (entry != nullptr
&& ((entry->wall.flags2 & WALL_SCENERY_2_ANIMATED) || entry->wall.scrolling_mode != SCROLLING_MODE_NONE))
{
2019-12-19 18:38:46 +00:00
map_animation_create(MAP_ANIMATION_TYPE_WALL, loc);
}
break;
}
case TILE_ELEMENT_TYPE_SMALL_SCENERY:
{
auto sceneryEl = el->AsSmallScenery();
auto entry = sceneryEl->GetEntry();
if (entry != nullptr && scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_ANIMATED))
{
2019-12-19 18:38:46 +00:00
map_animation_create(MAP_ANIMATION_TYPE_SMALL_SCENERY, loc);
}
break;
}
case TILE_ELEMENT_TYPE_LARGE_SCENERY:
{
auto sceneryEl = el->AsLargeScenery();
auto entry = sceneryEl->GetEntry();
if (entry != nullptr && (entry->large_scenery.flags & LARGE_SCENERY_FLAG_ANIMATED))
{
2019-12-19 18:38:46 +00:00
map_animation_create(MAP_ANIMATION_TYPE_LARGE_SCENERY, loc);
}
break;
}
case TILE_ELEMENT_TYPE_PATH:
{
auto path = el->AsPath();
if (path->HasQueueBanner())
{
2019-12-19 18:38:46 +00:00
map_animation_create(MAP_ANIMATION_TYPE_QUEUE_BANNER, loc);
}
break;
}
case TILE_ELEMENT_TYPE_ENTRANCE:
{
auto entrance = el->AsEntrance();
switch (entrance->GetEntranceType())
{
case ENTRANCE_TYPE_PARK_ENTRANCE:
if (entrance->GetSequenceIndex() == 0)
{
2019-12-19 18:38:46 +00:00
map_animation_create(MAP_ANIMATION_TYPE_PARK_ENTRANCE, loc);
}
break;
case ENTRANCE_TYPE_RIDE_ENTRANCE:
2019-12-19 18:38:46 +00:00
map_animation_create(MAP_ANIMATION_TYPE_RIDE_ENTRANCE, loc);
break;
}
break;
}
case TILE_ELEMENT_TYPE_TRACK:
{
auto track = el->AsTrack();
switch (track->GetTrackType())
{
case TRACK_ELEM_WATERFALL:
2019-12-19 18:38:46 +00:00
map_animation_create(MAP_ANIMATION_TYPE_TRACK_WATERFALL, loc);
break;
case TRACK_ELEM_RAPIDS:
2019-12-19 18:38:46 +00:00
map_animation_create(MAP_ANIMATION_TYPE_TRACK_RAPIDS, loc);
break;
case TRACK_ELEM_WHIRLPOOL:
2019-12-19 18:38:46 +00:00
map_animation_create(MAP_ANIMATION_TYPE_TRACK_WHIRLPOOL, loc);
break;
case TRACK_ELEM_SPINNING_TUNNEL:
2019-12-19 18:38:46 +00:00
map_animation_create(MAP_ANIMATION_TYPE_TRACK_SPINNINGTUNNEL, loc);
break;
}
break;
}
}
}
2018-01-11 10:59:26 +01:00
}