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

559 lines
17 KiB
C++
Raw Normal View History

2017-06-01 21:55:10 +02:00
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
/*****************************************************************************
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* A full copy of the GNU General Public License can be found in licence.txt
*****************************************************************************/
#pragma endregion
2018-03-14 12:44:16 +01:00
#include <cstring>
2017-11-30 18:17:06 +01:00
#include "../Game.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-01-05 23:45:53 +00:00
#include "../interface/Viewport.h"
2018-05-01 17:47:00 +02:00
#include "../world/Wall.h"
2018-01-11 10:59:26 +01:00
#include "MapAnimation.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"
#include "Footpath.h"
2018-02-14 09:42:26 +01:00
using map_animation_invalidate_event_handler = bool (*)(sint32 x, sint32 y, sint32 baseZ);
static bool map_animation_invalidate(rct_map_animation *obj);
2016-08-20 22:38:50 +01:00
uint16 gNumMapAnimations;
rct_map_animation gAnimatedObjects[MAX_ANIMATED_OBJECTS];
/**
2015-10-20 20:16:30 +02:00
*
* rct2: 0x0068AF67
*
* @param type (dh)
* @param x (ax)
* @param y (cx)
* @param z (dl)
*/
2017-01-04 22:17:08 +01:00
void map_animation_create(sint32 type, sint32 x, sint32 y, sint32 z)
{
2017-06-06 23:24:18 +02:00
rct_map_animation *aobj = &gAnimatedObjects[0];
sint32 numAnimatedObjects = gNumMapAnimations;
if (numAnimatedObjects >= MAX_ANIMATED_OBJECTS) {
log_error("Exceeded the maximum number of animations");
return;
}
for (sint32 i = 0; i < numAnimatedObjects; i++, aobj++) {
if (aobj->x != x)
continue;
if (aobj->y != y)
continue;
if (aobj->baseZ != z)
continue;
if (aobj->type != type)
continue;
// Animation already exists
return;
}
2017-06-06 23:24:18 +02:00
// Create new animation
gNumMapAnimations++;
aobj->type = type;
aobj->x = x;
aobj->y = y;
aobj->baseZ = z;
}
/**
*
* rct2: 0x0068AFAD
*/
void map_animation_invalidate_all()
{
2017-06-06 23:24:18 +02:00
rct_map_animation *aobj = &gAnimatedObjects[0];
sint32 numAnimatedObjects = gNumMapAnimations;
while (numAnimatedObjects > 0) {
if (map_animation_invalidate(aobj)) {
// Remove animated object
gNumMapAnimations--;
numAnimatedObjects--;
if (numAnimatedObjects > 0)
memmove(aobj, aobj + 1, numAnimatedObjects * sizeof(rct_map_animation));
} else {
numAnimatedObjects--;
aobj++;
}
}
}
/**
*
* rct2: 0x00666670
*/
2017-01-04 22:17:08 +01:00
static bool map_animation_invalidate_ride_entrance(sint32 x, sint32 y, sint32 baseZ)
{
2017-10-31 14:03:45 +01:00
rct_tile_element *tileElement;
2017-09-12 11:16:57 +02:00
Ride *ride;
2017-06-06 23:24:18 +02:00
const rct_ride_entrance_definition *entranceDefinition;
2017-10-31 14:03:45 +01:00
tileElement = map_get_first_element_at(x >> 5, y >> 5);
2017-06-06 23:24:18 +02:00
do {
2017-10-31 14:03:45 +01:00
if (tileElement->base_height != baseZ)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_ENTRANCE)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (tileElement->properties.entrance.type != ENTRANCE_TYPE_RIDE_ENTRANCE)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
ride = get_ride(tileElement->properties.entrance.ride_index);
2017-06-06 23:24:18 +02:00
entranceDefinition = &RideEntranceDefinitions[ride->entrance_style];
2017-10-31 14:03:45 +01:00
sint32 height = (tileElement->base_height * 8) + entranceDefinition->height + 8;
2017-06-06 23:24:18 +02:00
map_invalidate_tile_zoom1(x, y, height, height + 16);
return false;
2017-10-31 14:03:45 +01:00
} while (!tile_element_is_last_for_tile(tileElement++));
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006A7BD4
*/
2017-01-04 22:17:08 +01:00
static bool map_animation_invalidate_queue_banner(sint32 x, sint32 y, sint32 baseZ)
{
2017-10-31 14:03:45 +01:00
rct_tile_element *tileElement;
2017-10-31 14:03:45 +01:00
tileElement = map_get_first_element_at(x >> 5, y >> 5);
2017-06-06 23:24:18 +02:00
do {
2017-10-31 14:03:45 +01:00
if (tileElement->base_height != baseZ)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_PATH)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (!(tileElement->flags & 1))
2017-06-06 23:24:18 +02:00
continue;
2018-01-03 10:57:37 +01:00
if (!footpath_element_has_queue_banner(tileElement))
2017-06-06 23:24:18 +02:00
continue;
2017-12-08 16:47:54 +01:00
sint32 direction = (footpath_element_get_direction(tileElement) + get_current_rotation()) & 3;
2017-10-31 12:57:40 +01:00
if (direction == TILE_ELEMENT_DIRECTION_NORTH || direction == TILE_ELEMENT_DIRECTION_EAST) {
2017-10-31 14:03:45 +01:00
baseZ = tileElement->base_height * 8;
2017-06-06 23:24:18 +02:00
map_invalidate_tile_zoom1(x, y, baseZ + 16, baseZ + 30);
}
return false;
2017-10-31 14:03:45 +01:00
} while (!tile_element_is_last_for_tile(tileElement++));
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006E32C9
*/
2017-01-04 22:17:08 +01:00
static bool map_animation_invalidate_small_scenery(sint32 x, sint32 y, sint32 baseZ)
{
2017-10-31 14:03:45 +01:00
rct_tile_element *tileElement;
2017-06-06 23:24:18 +02:00
rct_scenery_entry *sceneryEntry;
rct_sprite *sprite;
rct_peep *peep;
2017-10-31 14:03:45 +01:00
tileElement = map_get_first_element_at(x >> 5, y >> 5);
2017-06-06 23:24:18 +02:00
do {
2017-10-31 14:03:45 +01:00
if (tileElement->base_height != baseZ)
2017-06-06 23:24:18 +02:00
continue;
2017-11-20 10:15:52 +01:00
if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_SMALL_SCENERY)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (tileElement->flags & (1 << 4))
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
sceneryEntry = get_small_scenery_entry(tileElement->properties.scenery.type);
2017-12-04 20:09:38 +01: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-10-31 14:03:45 +01:00
map_invalidate_tile_zoom1(x, y, tileElement->base_height * 8, tileElement->clearance_height * 8);
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
if (!(gCurrentTicks & 0x3FF) && game_is_not_paused()) {
2017-10-31 14:03:45 +01:00
sint32 direction = tile_element_get_direction(tileElement);
2017-06-06 23:24:18 +02:00
sint32 x2 = x - TileDirectionDelta[direction].x;
sint32 y2 = y - TileDirectionDelta[direction].y;
2017-06-06 23:24:18 +02:00
uint16 spriteIdx = sprite_get_first_in_quadrant(x2, y2);
for (; spriteIdx != SPRITE_INDEX_NULL; spriteIdx = sprite->unknown.next_in_quadrant) {
sprite = get_sprite(spriteIdx);
if (sprite->unknown.linked_list_type_offset != SPRITE_LIST_PEEP * 2)
continue;
2017-06-06 23:24:18 +02:00
peep = &sprite->peep;
if (peep->state != PEEP_STATE_WALKING)
continue;
2017-10-31 14:03:45 +01:00
if (peep->z != tileElement->base_height * 8)
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;
peep_update_current_action_sprite_type(peep);
invalidate_sprite_1((rct_sprite*)peep);
break;
}
}
2017-10-31 14:03:45 +01:00
map_invalidate_tile_zoom1(x, y, tileElement->base_height * 8, tileElement->clearance_height * 8);
2017-06-06 23:24:18 +02:00
return false;
}
2017-10-15 15:53:16 +02:00
2017-10-31 14:03:45 +01:00
} while (!tile_element_is_last_for_tile(tileElement++));
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x00666C63
*/
2017-01-04 22:17:08 +01:00
static bool map_animation_invalidate_park_entrance(sint32 x, sint32 y, sint32 baseZ)
{
2017-10-31 14:03:45 +01:00
rct_tile_element *tileElement;
2017-10-31 14:03:45 +01:00
tileElement = map_get_first_element_at(x >> 5, y >> 5);
2017-06-06 23:24:18 +02:00
do {
2017-10-31 14:03:45 +01:00
if (tileElement->base_height != baseZ)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_ENTRANCE)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (tileElement->properties.entrance.type != ENTRANCE_TYPE_PARK_ENTRANCE)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (tileElement->properties.entrance.index & 0x0F)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
baseZ = tileElement->base_height * 8;
2017-06-06 23:24:18 +02:00
map_invalidate_tile_zoom1(x, y, baseZ + 32, baseZ + 64);
return false;
2017-10-31 14:03:45 +01:00
} while (!tile_element_is_last_for_tile(tileElement++));
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006CE29E
*/
2017-01-04 22:17:08 +01:00
static bool map_animation_invalidate_track_waterfall(sint32 x, sint32 y, sint32 baseZ)
{
2017-10-31 14:03:45 +01:00
rct_tile_element *tileElement;
2017-10-31 14:03:45 +01:00
tileElement = map_get_first_element_at(x >> 5, y >> 5);
2017-06-06 23:24:18 +02:00
do {
2017-10-31 14:03:45 +01:00
if (tileElement->base_height != baseZ)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_TRACK)
2017-06-06 23:24:18 +02:00
continue;
if (track_element_get_type(tileElement) == TRACK_ELEM_WATERFALL) {
2017-10-31 14:03:45 +01:00
sint32 z = tileElement->base_height * 8;
2017-06-06 23:24:18 +02:00
map_invalidate_tile_zoom1(x, y, z + 14, z + 46);
return false;
}
2017-10-31 14:03:45 +01:00
} while (!tile_element_is_last_for_tile(tileElement++));
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006CE2F3
*/
2017-01-04 22:17:08 +01:00
static bool map_animation_invalidate_track_rapids(sint32 x, sint32 y, sint32 baseZ)
{
2017-10-31 14:03:45 +01:00
rct_tile_element *tileElement;
2017-10-31 14:03:45 +01:00
tileElement = map_get_first_element_at(x >> 5, y >> 5);
2017-06-06 23:24:18 +02:00
do {
2017-10-31 14:03:45 +01:00
if (tileElement->base_height != baseZ)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_TRACK)
2017-06-06 23:24:18 +02:00
continue;
if (track_element_get_type(tileElement) == TRACK_ELEM_RAPIDS) {
2017-10-31 14:03:45 +01:00
sint32 z = tileElement->base_height * 8;
2017-06-06 23:24:18 +02:00
map_invalidate_tile_zoom1(x, y, z + 14, z + 18);
return false;
}
2017-10-31 14:03:45 +01:00
} while (!tile_element_is_last_for_tile(tileElement++));
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006CE39D
*/
2017-01-04 22:17:08 +01:00
static bool map_animation_invalidate_track_onridephoto(sint32 x, sint32 y, sint32 baseZ)
{
2017-10-31 14:03:45 +01:00
rct_tile_element *tileElement;
2017-10-31 14:03:45 +01:00
tileElement = map_get_first_element_at(x >> 5, y >> 5);
2017-06-06 23:24:18 +02:00
do {
2018-01-29 17:06:01 +01:00
if (tileElement == nullptr)
break;
2017-10-31 14:03:45 +01:00
if (tileElement->base_height != baseZ)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_TRACK)
2017-06-06 23:24:18 +02:00
continue;
if (track_element_get_type(tileElement) == TRACK_ELEM_ON_RIDE_PHOTO) {
2017-10-31 14:03:45 +01:00
map_invalidate_tile_zoom1(x, y, tileElement->base_height * 8, tileElement->clearance_height * 8);
2017-06-06 23:24:18 +02:00
if (game_is_paused()) {
return false;
}
2017-10-31 14:03:45 +01:00
if (tile_element_is_taking_photo(tileElement)) {
tile_element_decrement_onride_photo_timout(tileElement);
2017-06-06 23:24:18 +02:00
return false;
} else {
return true;
}
}
2017-10-31 14:03:45 +01:00
} while (!tile_element_is_last_for_tile(tileElement++));
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006CE348
*/
2017-01-04 22:17:08 +01:00
static bool map_animation_invalidate_track_whirlpool(sint32 x, sint32 y, sint32 baseZ)
{
2017-10-31 14:03:45 +01:00
rct_tile_element *tileElement;
2017-10-31 14:03:45 +01:00
tileElement = map_get_first_element_at(x >> 5, y >> 5);
2017-06-06 23:24:18 +02:00
do {
2017-10-31 14:03:45 +01:00
if (tileElement->base_height != baseZ)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_TRACK)
2017-06-06 23:24:18 +02:00
continue;
if (track_element_get_type(tileElement) == TRACK_ELEM_WHIRLPOOL) {
2017-10-31 14:03:45 +01:00
sint32 z = tileElement->base_height * 8;
2017-06-06 23:24:18 +02:00
map_invalidate_tile_zoom1(x, y, z + 14, z + 18);
return false;
}
2017-10-31 14:03:45 +01:00
} while (!tile_element_is_last_for_tile(tileElement++));
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006CE3FA
*/
2017-01-04 22:17:08 +01:00
static bool map_animation_invalidate_track_spinningtunnel(sint32 x, sint32 y, sint32 baseZ)
{
2017-10-31 14:03:45 +01:00
rct_tile_element *tileElement;
2017-10-31 14:03:45 +01:00
tileElement = map_get_first_element_at(x >> 5, y >> 5);
2017-06-06 23:24:18 +02:00
do {
2017-10-31 14:03:45 +01:00
if (tileElement->base_height != baseZ)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_TRACK)
2017-06-06 23:24:18 +02:00
continue;
if (track_element_get_type(tileElement) == TRACK_ELEM_SPINNING_TUNNEL) {
2017-10-31 14:03:45 +01:00
sint32 z = tileElement->base_height * 8;
2017-06-06 23:24:18 +02:00
map_invalidate_tile_zoom1(x, y, z + 14, z + 32);
return false;
}
2017-10-31 14:03:45 +01:00
} while (!tile_element_is_last_for_tile(tileElement++));
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x0068DF8F
*/
static bool map_animation_invalidate_remove([[maybe_unused]] sint32 x, [[maybe_unused]] sint32 y, [[maybe_unused]] sint32 baseZ)
{
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006BA2BB
*/
2017-01-04 22:17:08 +01:00
static bool map_animation_invalidate_banner(sint32 x, sint32 y, sint32 baseZ)
{
2017-10-31 14:03:45 +01:00
rct_tile_element *tileElement;
2017-10-31 14:03:45 +01:00
tileElement = map_get_first_element_at(x >> 5, y >> 5);
2017-06-06 23:24:18 +02:00
do {
2017-10-31 14:03:45 +01:00
if (tileElement->base_height != baseZ)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_BANNER)
2017-06-06 23:24:18 +02:00
continue;
2015-10-20 20:16:30 +02:00
2017-10-31 14:03:45 +01:00
baseZ = tileElement->base_height * 8;
2017-06-06 23:24:18 +02:00
map_invalidate_tile_zoom1(x, y, baseZ, baseZ + 16);
return false;
2017-10-31 14:03:45 +01:00
} while (!tile_element_is_last_for_tile(tileElement++));
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006B94EB
*/
2017-01-04 22:17:08 +01:00
static bool map_animation_invalidate_large_scenery(sint32 x, sint32 y, sint32 baseZ)
{
2017-10-31 14:03:45 +01:00
rct_tile_element *tileElement;
2017-06-06 23:24:18 +02:00
rct_scenery_entry *sceneryEntry;
2017-06-06 23:24:18 +02:00
bool wasInvalidated = false;
2017-10-31 14:03:45 +01:00
tileElement = map_get_first_element_at(x >> 5, y >> 5);
2017-06-06 23:24:18 +02:00
do {
2017-10-31 14:03:45 +01:00
if (tileElement->base_height != baseZ)
2017-06-06 23:24:18 +02:00
continue;
2017-11-20 10:15:52 +01:00
if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_LARGE_SCENERY)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
sceneryEntry = get_large_scenery_entry(tileElement->properties.scenery.type & 0x3FF);
2017-06-06 23:24:18 +02:00
if (sceneryEntry->large_scenery.flags & LARGE_SCENERY_FLAG_ANIMATED) {
2017-10-31 14:03:45 +01:00
sint32 z = tileElement->base_height * 8;
2017-06-06 23:24:18 +02:00
map_invalidate_tile_zoom1(x, y, z, z + 16);
wasInvalidated = true;
}
2017-10-31 14:03:45 +01:00
} while (!tile_element_is_last_for_tile(tileElement++));
2017-06-06 23:24:18 +02:00
return !wasInvalidated;
}
/**
*
* rct2: 0x006E5B50
*/
2017-01-04 22:17:08 +01:00
static bool map_animation_invalidate_wall_door(sint32 x, sint32 y, sint32 baseZ)
{
2017-10-31 14:03:45 +01:00
rct_tile_element *tileElement;
2017-06-06 23:24:18 +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;
2017-10-31 14:03:45 +01:00
tileElement = map_get_first_element_at(x >> 5, y >> 5);
2017-06-06 23:24:18 +02:00
do {
2017-10-31 14:03:45 +01:00
if (tileElement->base_height != baseZ)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_WALL)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
sceneryEntry = get_wall_entry(tileElement->properties.scenery.type);
2017-06-06 23:24:18 +02:00
if (!(sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR))
continue;
2017-06-06 23:24:18 +02:00
if (game_is_paused()) {
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
2018-05-01 17:47:00 +02:00
uint8 currentFrame = wall_get_animation_frame(tileElement);
2017-06-06 23:24:18 +02:00
if (currentFrame != 0) {
if (currentFrame == 15) {
currentFrame = 0;
} else {
removeAnimation = false;
if (currentFrame != 5) {
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;
}
}
}
2018-05-01 17:47:00 +02:00
wall_set_animation_frame(tileElement, currentFrame);
2017-06-06 23:24:18 +02:00
if (invalidate) {
2017-10-31 14:03:45 +01:00
sint32 z = tileElement->base_height * 8;
2017-06-06 23:24:18 +02:00
map_invalidate_tile_zoom1(x, y, z, z + 32);
}
2017-10-31 14:03:45 +01:00
} while (!tile_element_is_last_for_tile(tileElement++));
2017-06-06 23:24:18 +02:00
return removeAnimation;
}
/**
*
* rct2: 0x006E5EE4
*/
2017-01-04 22:17:08 +01:00
static bool map_animation_invalidate_wall(sint32 x, sint32 y, sint32 baseZ)
{
2017-10-31 14:03:45 +01:00
rct_tile_element *tileElement;
2017-06-06 23:24:18 +02:00
rct_scenery_entry *sceneryEntry;
2017-06-06 23:24:18 +02:00
bool wasInvalidated = false;
2017-10-31 14:03:45 +01:00
tileElement = map_get_first_element_at(x >> 5, y >> 5);
2017-06-06 23:24:18 +02:00
do {
2017-10-31 14:03:45 +01:00
if (tileElement->base_height != baseZ)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_WALL)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
sceneryEntry = get_wall_entry(tileElement->properties.scenery.type);
2017-10-15 15:53:16 +02:00
2017-11-22 22:53:13 +00:00
if (!(sceneryEntry->wall.flags2 & WALL_SCENERY_2_ANIMATED) && sceneryEntry->wall.scrolling_mode == 255)
2017-06-06 23:24:18 +02:00
continue;
2017-10-31 14:03:45 +01:00
sint32 z = tileElement->base_height * 8;
2017-06-06 23:24:18 +02:00
map_invalidate_tile_zoom1(x, y, z, z + 16);
wasInvalidated = true;
2017-10-31 14:03:45 +01:00
} while (!tile_element_is_last_for_tile(tileElement++));
2017-06-06 23:24:18 +02:00
return !wasInvalidated;
}
2015-12-11 09:38:37 -06:00
/**
*
* rct2: 0x009819DC
*/
2018-01-11 23:14:31 +01:00
static constexpr const map_animation_invalidate_event_handler _animatedObjectEventHandlers[MAP_ANIMATION_TYPE_COUNT] = {
2017-06-06 23:24:18 +02:00
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 map_animation_invalidate(rct_map_animation *obj)
{
assert(obj->type < MAP_ANIMATION_TYPE_COUNT);
return _animatedObjectEventHandlers[obj->type](obj->x, obj->y, obj->baseZ);
}