Merge pull request #10399 from duncanspumpkin/refactor_map_animation

Refactor MapAnimation to use CoordsXYZ
This commit is contained in:
Michael Steenbeek 2019-12-21 13:12:11 +01:00 committed by GitHub
commit 6b5be4765d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 106 additions and 104 deletions

View File

@ -158,7 +158,7 @@ public:
bannerElement->SetGhost(true); bannerElement->SetGhost(true);
} }
map_invalidate_tile_full(_loc.x, _loc.y); map_invalidate_tile_full(_loc.x, _loc.y);
map_animation_create(MAP_ANIMATION_TYPE_BANNER, _loc.x, _loc.y, bannerElement->base_height); map_animation_create(MAP_ANIMATION_TYPE_BANNER, CoordsXYZ{ _loc, bannerElement->base_height * 8 });
rct_scenery_entry* bannerEntry = get_banner_entry(_bannerType); rct_scenery_entry* bannerEntry = get_banner_entry(_bannerType);
if (bannerEntry == nullptr) if (bannerEntry == nullptr)

View File

@ -313,7 +313,7 @@ public:
TileElement* newTileElement = tile_element_insert( TileElement* newTileElement = tile_element_insert(
{ curTile.x / 32, curTile.y / 32, zLow }, quarterTile.GetBaseQuarterOccupied()); { curTile.x / 32, curTile.y / 32, zLow }, quarterTile.GetBaseQuarterOccupied());
Guard::Assert(newTileElement != nullptr); Guard::Assert(newTileElement != nullptr);
map_animation_create(MAP_ANIMATION_TYPE_LARGE_SCENERY, curTile.x, curTile.y, zLow); map_animation_create(MAP_ANIMATION_TYPE_LARGE_SCENERY, { curTile, zLow * 8 });
newTileElement->SetType(TILE_ELEMENT_TYPE_LARGE_SCENERY); newTileElement->SetType(TILE_ELEMENT_TYPE_LARGE_SCENERY);
newTileElement->clearance_height = zHigh; newTileElement->clearance_height = zHigh;
auto newSceneryElement = newTileElement->AsLargeScenery(); auto newSceneryElement = newTileElement->AsLargeScenery();

View File

@ -184,7 +184,7 @@ public:
if (index == 0) if (index == 0)
{ {
map_animation_create(MAP_ANIMATION_TYPE_PARK_ENTRANCE, entranceLoc.x, entranceLoc.y, zLow); map_animation_create(MAP_ANIMATION_TYPE_PARK_ENTRANCE, { entranceLoc, zLow * 8 });
} }
} }

View File

@ -214,7 +214,7 @@ public:
ride->stations[_stationNum].LastPeepInQueue = SPRITE_INDEX_NULL; ride->stations[_stationNum].LastPeepInQueue = SPRITE_INDEX_NULL;
ride->stations[_stationNum].QueueLength = 0; ride->stations[_stationNum].QueueLength = 0;
map_animation_create(MAP_ANIMATION_TYPE_RIDE_ENTRANCE, _loc.x, _loc.y, z / 8); map_animation_create(MAP_ANIMATION_TYPE_RIDE_ENTRANCE, { _loc, z });
} }
footpath_queue_chain_reset(); footpath_queue_chain_reset();

View File

@ -456,7 +456,7 @@ public:
map_invalidate_tile_full(_loc.x, _loc.y); map_invalidate_tile_full(_loc.x, _loc.y);
if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_ANIMATED)) if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_ANIMATED))
{ {
map_animation_create(MAP_ANIMATION_TYPE_SMALL_SCENERY, _loc.x, _loc.y, sceneryElement->base_height); map_animation_create(MAP_ANIMATION_TYPE_SMALL_SCENERY, CoordsXYZ{ _loc, sceneryElement->base_height * 8 });
} }
return res; return res;

View File

@ -597,16 +597,17 @@ public:
switch (_trackType) switch (_trackType)
{ {
case TRACK_ELEM_WATERFALL: case TRACK_ELEM_WATERFALL:
map_animation_create(MAP_ANIMATION_TYPE_TRACK_WATERFALL, mapLoc.x, mapLoc.y, tileElement->base_height); map_animation_create(MAP_ANIMATION_TYPE_TRACK_WATERFALL, CoordsXYZ{ mapLoc, tileElement->base_height * 8 });
break; break;
case TRACK_ELEM_RAPIDS: case TRACK_ELEM_RAPIDS:
map_animation_create(MAP_ANIMATION_TYPE_TRACK_RAPIDS, mapLoc.x, mapLoc.y, tileElement->base_height); map_animation_create(MAP_ANIMATION_TYPE_TRACK_RAPIDS, CoordsXYZ{ mapLoc, tileElement->base_height * 8 });
break; break;
case TRACK_ELEM_WHIRLPOOL: case TRACK_ELEM_WHIRLPOOL:
map_animation_create(MAP_ANIMATION_TYPE_TRACK_WHIRLPOOL, mapLoc.x, mapLoc.y, tileElement->base_height); map_animation_create(MAP_ANIMATION_TYPE_TRACK_WHIRLPOOL, CoordsXYZ{ mapLoc, tileElement->base_height * 8 });
break; break;
case TRACK_ELEM_SPINNING_TUNNEL: case TRACK_ELEM_SPINNING_TUNNEL:
map_animation_create(MAP_ANIMATION_TYPE_TRACK_SPINNINGTUNNEL, mapLoc.x, mapLoc.y, tileElement->base_height); map_animation_create(
MAP_ANIMATION_TYPE_TRACK_SPINNINGTUNNEL, CoordsXYZ{ mapLoc, tileElement->base_height * 8 });
break; break;
} }
if (track_element_has_speed_setting(_trackType)) if (track_element_has_speed_setting(_trackType))

View File

@ -397,7 +397,7 @@ public:
TileElement* tileElement = tile_element_insert({ _loc.x / 32, _loc.y / 32, targetHeight / 8 }, 0b0000); TileElement* tileElement = tile_element_insert({ _loc.x / 32, _loc.y / 32, targetHeight / 8 }, 0b0000);
assert(tileElement != nullptr); assert(tileElement != nullptr);
map_animation_create(MAP_ANIMATION_TYPE_WALL, _loc.x, _loc.y, targetHeight / 8); map_animation_create(MAP_ANIMATION_TYPE_WALL, CoordsXYZ{ _loc, targetHeight });
tileElement->SetType(TILE_ELEMENT_TYPE_WALL); tileElement->SetType(TILE_ELEMENT_TYPE_WALL);
WallElement* wallElement = tileElement->AsWall(); WallElement* wallElement = tileElement->AsWall();

View File

@ -7443,7 +7443,7 @@ static void vehicle_update_scenery_door(rct_vehicle* vehicle)
{ {
tileElement->SetAnimationIsBackwards(false); tileElement->SetAnimationIsBackwards(false);
tileElement->SetAnimationFrame(1); tileElement->SetAnimationFrame(1);
map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, wallCoords.x, wallCoords.y, wallCoords.z >> 3); map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, wallCoords);
vehicle_play_scenery_door_open_sound(vehicle, tileElement); vehicle_play_scenery_door_open_sound(vehicle, tileElement);
} }
@ -7496,7 +7496,8 @@ static void vehicle_trigger_on_ride_photo(rct_vehicle* vehicle, TileElement* til
{ {
tileElement->AsTrack()->SetPhotoTimeout(); tileElement->AsTrack()->SetPhotoTimeout();
map_animation_create(MAP_ANIMATION_TYPE_TRACK_ONRIDEPHOTO, vehicle->track_x, vehicle->track_y, tileElement->base_height); map_animation_create(
MAP_ANIMATION_TYPE_TRACK_ONRIDEPHOTO, { vehicle->track_x, vehicle->track_y, tileElement->base_height * 8 });
} }
/** /**
@ -7523,7 +7524,7 @@ static void vehicle_update_handle_scenery_door(rct_vehicle* vehicle)
{ {
tileElement->SetAnimationIsBackwards(true); tileElement->SetAnimationIsBackwards(true);
tileElement->SetAnimationFrame(1); tileElement->SetAnimationFrame(1);
map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, wallCoords.x, wallCoords.y, wallCoords.z >> 3); map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, wallCoords);
vehicle_play_scenery_door_open_sound(vehicle, tileElement); vehicle_play_scenery_door_open_sound(vehicle, tileElement);
} }

View File

@ -1160,7 +1160,7 @@ void footpath_chain_ride_queue(
lastPathElement->AsPath()->SetHasQueueBanner(true); lastPathElement->AsPath()->SetHasQueueBanner(true);
lastPathElement->AsPath()->SetQueueBannerDirection(lastPathDirection); // set the ride sign direction lastPathElement->AsPath()->SetQueueBannerDirection(lastPathDirection); // set the ride sign direction
map_animation_create(MAP_ANIMATION_TYPE_QUEUE_BANNER, lastPathX, lastPathY, lastPathElement->base_height); map_animation_create(MAP_ANIMATION_TYPE_QUEUE_BANNER, { lastPathX, lastPathY, lastPathElement->base_height * 8 });
} }
} }
} }

View File

@ -25,7 +25,7 @@
#include "SmallScenery.h" #include "SmallScenery.h"
#include "Sprite.h" #include "Sprite.h"
using map_animation_invalidate_event_handler = bool (*)(int32_t x, int32_t y, int32_t baseZ); using map_animation_invalidate_event_handler = bool (*)(CoordsXYZ loc);
static std::vector<MapAnimation> _mapAnimations; static std::vector<MapAnimation> _mapAnimations;
@ -37,7 +37,7 @@ static bool DoesAnimationExist(int32_t type, const CoordsXYZ& location)
{ {
for (const auto& a : _mapAnimations) for (const auto& a : _mapAnimations)
{ {
if (a.type == type && a.location.x == location.x && a.location.y == location.y && a.location.z == location.z) if (a.type == type && a.location == location)
{ {
// Animation already exists // Animation already exists
return true; return true;
@ -46,15 +46,14 @@ static bool DoesAnimationExist(int32_t type, const CoordsXYZ& location)
return false; return false;
} }
void map_animation_create(int32_t type, int32_t x, int32_t y, int32_t z) void map_animation_create(int32_t type, const CoordsXYZ loc)
{ {
auto location = CoordsXYZ{ x, y, z }; if (!DoesAnimationExist(type, loc))
if (!DoesAnimationExist(type, location))
{ {
if (_mapAnimations.size() < MAX_ANIMATED_OBJECTS) if (_mapAnimations.size() < MAX_ANIMATED_OBJECTS)
{ {
// Create new animation // Create new animation
_mapAnimations.push_back({ (uint8_t)type, location }); _mapAnimations.push_back({ (uint8_t)type, loc });
} }
else else
{ {
@ -88,14 +87,15 @@ void map_animation_invalidate_all()
* *
* rct2: 0x00666670 * rct2: 0x00666670
*/ */
static bool map_animation_invalidate_ride_entrance(int32_t x, int32_t y, int32_t baseZ) static bool map_animation_invalidate_ride_entrance(CoordsXYZ loc)
{ {
auto tileElement = map_get_first_element_at(x >> 5, y >> 5); TileCoordsXYZ tileLoc{ loc };
auto tileElement = map_get_first_element_at(tileLoc.x, tileLoc.y);
if (tileElement == nullptr) if (tileElement == nullptr)
return true; return true;
do do
{ {
if (tileElement->base_height != baseZ) if (tileElement->base_height != tileLoc.z)
continue; continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE) if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE)
continue; continue;
@ -108,8 +108,8 @@ static bool map_animation_invalidate_ride_entrance(int32_t x, int32_t y, int32_t
auto stationObj = ride_get_station_object(ride); auto stationObj = ride_get_station_object(ride);
if (stationObj != nullptr) if (stationObj != nullptr)
{ {
int32_t height = (tileElement->base_height * 8) + stationObj->Height + 8; int32_t height = loc.z + stationObj->Height + 8;
map_invalidate_tile_zoom1(x, y, height, height + 16); map_invalidate_tile_zoom1(loc.x, loc.y, height, height + 16);
} }
} }
return false; return false;
@ -122,16 +122,17 @@ static bool map_animation_invalidate_ride_entrance(int32_t x, int32_t y, int32_t
* *
* rct2: 0x006A7BD4 * rct2: 0x006A7BD4
*/ */
static bool map_animation_invalidate_queue_banner(int32_t x, int32_t y, int32_t baseZ) static bool map_animation_invalidate_queue_banner(CoordsXYZ loc)
{ {
TileCoordsXYZ tileLoc{ loc };
TileElement* tileElement; TileElement* tileElement;
tileElement = map_get_first_element_at(x >> 5, y >> 5); tileElement = map_get_first_element_at(tileLoc.x, tileLoc.y);
if (tileElement == nullptr) if (tileElement == nullptr)
return true; return true;
do do
{ {
if (tileElement->base_height != baseZ) if (tileElement->base_height != tileLoc.z)
continue; continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH) if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
continue; continue;
@ -143,8 +144,7 @@ static bool map_animation_invalidate_queue_banner(int32_t x, int32_t y, int32_t
int32_t direction = (tileElement->AsPath()->GetQueueBannerDirection() + get_current_rotation()) & 3; int32_t direction = (tileElement->AsPath()->GetQueueBannerDirection() + get_current_rotation()) & 3;
if (direction == TILE_ELEMENT_DIRECTION_NORTH || direction == TILE_ELEMENT_DIRECTION_EAST) if (direction == TILE_ELEMENT_DIRECTION_NORTH || direction == TILE_ELEMENT_DIRECTION_EAST)
{ {
baseZ = tileElement->base_height * 8; map_invalidate_tile_zoom1(loc.x, loc.y, loc.z + 16, loc.z + 30);
map_invalidate_tile_zoom1(x, y, baseZ + 16, baseZ + 30);
} }
return false; return false;
} while (!(tileElement++)->IsLastForTile()); } while (!(tileElement++)->IsLastForTile());
@ -156,19 +156,20 @@ static bool map_animation_invalidate_queue_banner(int32_t x, int32_t y, int32_t
* *
* rct2: 0x006E32C9 * rct2: 0x006E32C9
*/ */
static bool map_animation_invalidate_small_scenery(int32_t x, int32_t y, int32_t baseZ) static bool map_animation_invalidate_small_scenery(CoordsXYZ loc)
{ {
TileCoordsXYZ tileLoc{ loc };
TileElement* tileElement; TileElement* tileElement;
rct_scenery_entry* sceneryEntry; rct_scenery_entry* sceneryEntry;
rct_sprite* sprite; rct_sprite* sprite;
Peep* peep; Peep* peep;
tileElement = map_get_first_element_at(x >> 5, y >> 5); tileElement = map_get_first_element_at(tileLoc.x, tileLoc.y);
if (tileElement == nullptr) if (tileElement == nullptr)
return true; return true;
do do
{ {
if (tileElement->base_height != baseZ) if (tileElement->base_height != tileLoc.z)
continue; continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY) if (tileElement->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY)
continue; continue;
@ -184,7 +185,7 @@ static bool map_animation_invalidate_small_scenery(int32_t x, int32_t y, int32_t
SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_1 | SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_4 | SMALL_SCENERY_FLAG_SWAMP_GOO SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_1 | SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_4 | SMALL_SCENERY_FLAG_SWAMP_GOO
| SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS)) | SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS))
{ {
map_invalidate_tile_zoom1(x, y, tileElement->base_height * 8, tileElement->clearance_height * 8); map_invalidate_tile_zoom1(loc.x, loc.y, loc.z, tileElement->clearance_height * 8);
return false; return false;
} }
@ -194,8 +195,8 @@ static bool map_animation_invalidate_small_scenery(int32_t x, int32_t y, int32_t
if (!(gCurrentTicks & 0x3FF) && game_is_not_paused()) if (!(gCurrentTicks & 0x3FF) && game_is_not_paused())
{ {
int32_t direction = tileElement->GetDirection(); int32_t direction = tileElement->GetDirection();
int32_t x2 = x - CoordsDirectionDelta[direction].x; int32_t x2 = loc.x - CoordsDirectionDelta[direction].x;
int32_t y2 = y - CoordsDirectionDelta[direction].y; int32_t y2 = loc.y - CoordsDirectionDelta[direction].y;
uint16_t spriteIdx = sprite_get_first_in_quadrant(x2, y2); uint16_t spriteIdx = sprite_get_first_in_quadrant(x2, y2);
for (; spriteIdx != SPRITE_INDEX_NULL; spriteIdx = sprite->generic.next_in_quadrant) for (; spriteIdx != SPRITE_INDEX_NULL; spriteIdx = sprite->generic.next_in_quadrant)
@ -207,7 +208,7 @@ static bool map_animation_invalidate_small_scenery(int32_t x, int32_t y, int32_t
peep = &sprite->peep; peep = &sprite->peep;
if (peep->state != PEEP_STATE_WALKING) if (peep->state != PEEP_STATE_WALKING)
continue; continue;
if (peep->z != tileElement->base_height * 8) if (peep->z != loc.z)
continue; continue;
if (peep->action < PEEP_ACTION_NONE_1) if (peep->action < PEEP_ACTION_NONE_1)
continue; continue;
@ -220,7 +221,7 @@ static bool map_animation_invalidate_small_scenery(int32_t x, int32_t y, int32_t
break; break;
} }
} }
map_invalidate_tile_zoom1(x, y, tileElement->base_height * 8, tileElement->clearance_height * 8); map_invalidate_tile_zoom1(loc.x, loc.y, loc.z, tileElement->clearance_height * 8);
return false; return false;
} }
@ -232,16 +233,17 @@ static bool map_animation_invalidate_small_scenery(int32_t x, int32_t y, int32_t
* *
* rct2: 0x00666C63 * rct2: 0x00666C63
*/ */
static bool map_animation_invalidate_park_entrance(int32_t x, int32_t y, int32_t baseZ) static bool map_animation_invalidate_park_entrance(CoordsXYZ loc)
{ {
TileCoordsXYZ tileLoc{ loc };
TileElement* tileElement; TileElement* tileElement;
tileElement = map_get_first_element_at(x >> 5, y >> 5); tileElement = map_get_first_element_at(tileLoc.x, tileLoc.y);
if (tileElement == nullptr) if (tileElement == nullptr)
return true; return true;
do do
{ {
if (tileElement->base_height != baseZ) if (tileElement->base_height != tileLoc.z)
continue; continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE) if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE)
continue; continue;
@ -250,8 +252,7 @@ static bool map_animation_invalidate_park_entrance(int32_t x, int32_t y, int32_t
if (tileElement->AsEntrance()->GetSequenceIndex()) if (tileElement->AsEntrance()->GetSequenceIndex())
continue; continue;
baseZ = tileElement->base_height * 8; map_invalidate_tile_zoom1(loc.x, loc.y, loc.z + 32, loc.z + 64);
map_invalidate_tile_zoom1(x, y, baseZ + 32, baseZ + 64);
return false; return false;
} while (!(tileElement++)->IsLastForTile()); } while (!(tileElement++)->IsLastForTile());
@ -262,24 +263,24 @@ static bool map_animation_invalidate_park_entrance(int32_t x, int32_t y, int32_t
* *
* rct2: 0x006CE29E * rct2: 0x006CE29E
*/ */
static bool map_animation_invalidate_track_waterfall(int32_t x, int32_t y, int32_t baseZ) static bool map_animation_invalidate_track_waterfall(CoordsXYZ loc)
{ {
TileCoordsXYZ tileLoc{ loc };
TileElement* tileElement; TileElement* tileElement;
tileElement = map_get_first_element_at(x >> 5, y >> 5); tileElement = map_get_first_element_at(tileLoc.x, tileLoc.y);
if (tileElement == nullptr) if (tileElement == nullptr)
return true; return true;
do do
{ {
if (tileElement->base_height != baseZ) if (tileElement->base_height != tileLoc.z)
continue; continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK) if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
continue; continue;
if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_WATERFALL) if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_WATERFALL)
{ {
int32_t z = tileElement->base_height * 8; map_invalidate_tile_zoom1(loc.x, loc.y, loc.z + 14, loc.z + 46);
map_invalidate_tile_zoom1(x, y, z + 14, z + 46);
return false; return false;
} }
} while (!(tileElement++)->IsLastForTile()); } while (!(tileElement++)->IsLastForTile());
@ -291,24 +292,24 @@ static bool map_animation_invalidate_track_waterfall(int32_t x, int32_t y, int32
* *
* rct2: 0x006CE2F3 * rct2: 0x006CE2F3
*/ */
static bool map_animation_invalidate_track_rapids(int32_t x, int32_t y, int32_t baseZ) static bool map_animation_invalidate_track_rapids(CoordsXYZ loc)
{ {
TileCoordsXYZ tileLoc{ loc };
TileElement* tileElement; TileElement* tileElement;
tileElement = map_get_first_element_at(x >> 5, y >> 5); tileElement = map_get_first_element_at(tileLoc.x, tileLoc.y);
if (tileElement == nullptr) if (tileElement == nullptr)
return true; return true;
do do
{ {
if (tileElement->base_height != baseZ) if (tileElement->base_height != tileLoc.z)
continue; continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK) if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
continue; continue;
if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_RAPIDS) if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_RAPIDS)
{ {
int32_t z = tileElement->base_height * 8; map_invalidate_tile_zoom1(loc.x, loc.y, loc.z + 14, loc.z + 18);
map_invalidate_tile_zoom1(x, y, z + 14, z + 18);
return false; return false;
} }
} while (!(tileElement++)->IsLastForTile()); } while (!(tileElement++)->IsLastForTile());
@ -320,23 +321,24 @@ static bool map_animation_invalidate_track_rapids(int32_t x, int32_t y, int32_t
* *
* rct2: 0x006CE39D * rct2: 0x006CE39D
*/ */
static bool map_animation_invalidate_track_onridephoto(int32_t x, int32_t y, int32_t baseZ) static bool map_animation_invalidate_track_onridephoto(CoordsXYZ loc)
{ {
TileCoordsXYZ tileLoc{ loc };
TileElement* tileElement; TileElement* tileElement;
tileElement = map_get_first_element_at(x >> 5, y >> 5); tileElement = map_get_first_element_at(tileLoc.x, tileLoc.y);
if (tileElement == nullptr) if (tileElement == nullptr)
return true; return true;
do do
{ {
if (tileElement->base_height != baseZ) if (tileElement->base_height != tileLoc.z)
continue; continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK) if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
continue; continue;
if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_ON_RIDE_PHOTO) if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_ON_RIDE_PHOTO)
{ {
map_invalidate_tile_zoom1(x, y, tileElement->base_height * 8, tileElement->clearance_height * 8); map_invalidate_tile_zoom1(loc.x, loc.y, loc.z, tileElement->clearance_height * 8);
if (game_is_paused()) if (game_is_paused())
{ {
return false; return false;
@ -360,24 +362,24 @@ static bool map_animation_invalidate_track_onridephoto(int32_t x, int32_t y, int
* *
* rct2: 0x006CE348 * rct2: 0x006CE348
*/ */
static bool map_animation_invalidate_track_whirlpool(int32_t x, int32_t y, int32_t baseZ) static bool map_animation_invalidate_track_whirlpool(CoordsXYZ loc)
{ {
TileCoordsXYZ tileLoc{ loc };
TileElement* tileElement; TileElement* tileElement;
tileElement = map_get_first_element_at(x >> 5, y >> 5); tileElement = map_get_first_element_at(tileLoc.x, tileLoc.y);
if (tileElement == nullptr) if (tileElement == nullptr)
return true; return true;
do do
{ {
if (tileElement->base_height != baseZ) if (tileElement->base_height != tileLoc.z)
continue; continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK) if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
continue; continue;
if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_WHIRLPOOL) if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_WHIRLPOOL)
{ {
int32_t z = tileElement->base_height * 8; map_invalidate_tile_zoom1(loc.x, loc.y, loc.z + 14, loc.z + 18);
map_invalidate_tile_zoom1(x, y, z + 14, z + 18);
return false; return false;
} }
} while (!(tileElement++)->IsLastForTile()); } while (!(tileElement++)->IsLastForTile());
@ -389,24 +391,24 @@ static bool map_animation_invalidate_track_whirlpool(int32_t x, int32_t y, int32
* *
* rct2: 0x006CE3FA * rct2: 0x006CE3FA
*/ */
static bool map_animation_invalidate_track_spinningtunnel(int32_t x, int32_t y, int32_t baseZ) static bool map_animation_invalidate_track_spinningtunnel(CoordsXYZ loc)
{ {
TileCoordsXYZ tileLoc{ loc };
TileElement* tileElement; TileElement* tileElement;
tileElement = map_get_first_element_at(x >> 5, y >> 5); tileElement = map_get_first_element_at(tileLoc.x, tileLoc.y);
if (tileElement == nullptr) if (tileElement == nullptr)
return true; return true;
do do
{ {
if (tileElement->base_height != baseZ) if (tileElement->base_height != tileLoc.z)
continue; continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK) if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
continue; continue;
if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_SPINNING_TUNNEL) if (tileElement->AsTrack()->GetTrackType() == TRACK_ELEM_SPINNING_TUNNEL)
{ {
int32_t z = tileElement->base_height * 8; map_invalidate_tile_zoom1(loc.x, loc.y, loc.z + 14, loc.z + 32);
map_invalidate_tile_zoom1(x, y, z + 14, z + 32);
return false; return false;
} }
} while (!(tileElement++)->IsLastForTile()); } while (!(tileElement++)->IsLastForTile());
@ -418,8 +420,7 @@ static bool map_animation_invalidate_track_spinningtunnel(int32_t x, int32_t y,
* *
* rct2: 0x0068DF8F * rct2: 0x0068DF8F
*/ */
static bool map_animation_invalidate_remove( static bool map_animation_invalidate_remove([[maybe_unused]] CoordsXYZ loc)
[[maybe_unused]] int32_t x, [[maybe_unused]] int32_t y, [[maybe_unused]] int32_t baseZ)
{ {
return true; return true;
} }
@ -428,22 +429,21 @@ static bool map_animation_invalidate_remove(
* *
* rct2: 0x006BA2BB * rct2: 0x006BA2BB
*/ */
static bool map_animation_invalidate_banner(int32_t x, int32_t y, int32_t baseZ) static bool map_animation_invalidate_banner(CoordsXYZ loc)
{ {
TileCoordsXYZ tileLoc{ loc };
TileElement* tileElement; TileElement* tileElement;
tileElement = map_get_first_element_at(x >> 5, y >> 5); tileElement = map_get_first_element_at(tileLoc.x, tileLoc.y);
if (tileElement == nullptr) if (tileElement == nullptr)
return true; return true;
do do
{ {
if (tileElement->base_height != baseZ) if (tileElement->base_height != tileLoc.z)
continue; continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_BANNER) if (tileElement->GetType() != TILE_ELEMENT_TYPE_BANNER)
continue; continue;
map_invalidate_tile_zoom1(loc.x, loc.y, loc.z, loc.z + 16);
baseZ = tileElement->base_height * 8;
map_invalidate_tile_zoom1(x, y, baseZ, baseZ + 16);
return false; return false;
} while (!(tileElement++)->IsLastForTile()); } while (!(tileElement++)->IsLastForTile());
@ -454,18 +454,19 @@ static bool map_animation_invalidate_banner(int32_t x, int32_t y, int32_t baseZ)
* *
* rct2: 0x006B94EB * rct2: 0x006B94EB
*/ */
static bool map_animation_invalidate_large_scenery(int32_t x, int32_t y, int32_t baseZ) static bool map_animation_invalidate_large_scenery(CoordsXYZ loc)
{ {
TileCoordsXYZ tileLoc{ loc };
TileElement* tileElement; TileElement* tileElement;
rct_scenery_entry* sceneryEntry; rct_scenery_entry* sceneryEntry;
bool wasInvalidated = false; bool wasInvalidated = false;
tileElement = map_get_first_element_at(x >> 5, y >> 5); tileElement = map_get_first_element_at(tileLoc.x, tileLoc.y);
if (tileElement == nullptr) if (tileElement == nullptr)
return true; return true;
do do
{ {
if (tileElement->base_height != baseZ) if (tileElement->base_height != tileLoc.z)
continue; continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_LARGE_SCENERY) if (tileElement->GetType() != TILE_ELEMENT_TYPE_LARGE_SCENERY)
continue; continue;
@ -473,8 +474,7 @@ static bool map_animation_invalidate_large_scenery(int32_t x, int32_t y, int32_t
sceneryEntry = tileElement->AsLargeScenery()->GetEntry(); sceneryEntry = tileElement->AsLargeScenery()->GetEntry();
if (sceneryEntry->large_scenery.flags & LARGE_SCENERY_FLAG_ANIMATED) if (sceneryEntry->large_scenery.flags & LARGE_SCENERY_FLAG_ANIMATED)
{ {
int32_t z = tileElement->base_height * 8; map_invalidate_tile_zoom1(loc.x, loc.y, loc.z, loc.z + 16);
map_invalidate_tile_zoom1(x, y, z, z + 16);
wasInvalidated = true; wasInvalidated = true;
} }
} while (!(tileElement++)->IsLastForTile()); } while (!(tileElement++)->IsLastForTile());
@ -486,8 +486,9 @@ static bool map_animation_invalidate_large_scenery(int32_t x, int32_t y, int32_t
* *
* rct2: 0x006E5B50 * rct2: 0x006E5B50
*/ */
static bool map_animation_invalidate_wall_door(int32_t x, int32_t y, int32_t baseZ) static bool map_animation_invalidate_wall_door(CoordsXYZ loc)
{ {
TileCoordsXYZ tileLoc{ loc };
TileElement* tileElement; TileElement* tileElement;
rct_scenery_entry* sceneryEntry; rct_scenery_entry* sceneryEntry;
@ -495,12 +496,12 @@ static bool map_animation_invalidate_wall_door(int32_t x, int32_t y, int32_t bas
return false; return false;
bool removeAnimation = true; bool removeAnimation = true;
tileElement = map_get_first_element_at(x >> 5, y >> 5); tileElement = map_get_first_element_at(tileLoc.x, tileLoc.y);
if (tileElement == nullptr) if (tileElement == nullptr)
return removeAnimation; return removeAnimation;
do do
{ {
if (tileElement->base_height != baseZ) if (tileElement->base_height != tileLoc.z)
continue; continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL) if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL)
continue; continue;
@ -539,8 +540,7 @@ static bool map_animation_invalidate_wall_door(int32_t x, int32_t y, int32_t bas
tileElement->AsWall()->SetAnimationFrame(currentFrame); tileElement->AsWall()->SetAnimationFrame(currentFrame);
if (invalidate) if (invalidate)
{ {
int32_t z = tileElement->base_height * 8; map_invalidate_tile_zoom1(loc.x, loc.y, loc.z, loc.z + 32);
map_invalidate_tile_zoom1(x, y, z, z + 32);
} }
} while (!(tileElement++)->IsLastForTile()); } while (!(tileElement++)->IsLastForTile());
@ -551,18 +551,19 @@ static bool map_animation_invalidate_wall_door(int32_t x, int32_t y, int32_t bas
* *
* rct2: 0x006E5EE4 * rct2: 0x006E5EE4
*/ */
static bool map_animation_invalidate_wall(int32_t x, int32_t y, int32_t baseZ) static bool map_animation_invalidate_wall(CoordsXYZ loc)
{ {
TileCoordsXYZ tileLoc{ loc };
TileElement* tileElement; TileElement* tileElement;
rct_scenery_entry* sceneryEntry; rct_scenery_entry* sceneryEntry;
bool wasInvalidated = false; bool wasInvalidated = false;
tileElement = map_get_first_element_at(x >> 5, y >> 5); tileElement = map_get_first_element_at(tileLoc.x, tileLoc.y);
if (tileElement == nullptr) if (tileElement == nullptr)
return true; return true;
do do
{ {
if (tileElement->base_height != baseZ) if (tileElement->base_height != tileLoc.z)
continue; continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL) if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL)
continue; continue;
@ -574,8 +575,7 @@ static bool map_animation_invalidate_wall(int32_t x, int32_t y, int32_t baseZ)
&& sceneryEntry->wall.scrolling_mode == SCROLLING_MODE_NONE)) && sceneryEntry->wall.scrolling_mode == SCROLLING_MODE_NONE))
continue; continue;
int32_t z = tileElement->base_height * 8; map_invalidate_tile_zoom1(loc.x, loc.y, loc.z, loc.z + 16);
map_invalidate_tile_zoom1(x, y, z, z + 16);
wasInvalidated = true; wasInvalidated = true;
} while (!(tileElement++)->IsLastForTile()); } while (!(tileElement++)->IsLastForTile());
@ -610,7 +610,7 @@ static bool InvalidateMapAnimation(const MapAnimation& a)
{ {
if (a.type < std::size(_animatedObjectEventHandlers)) if (a.type < std::size(_animatedObjectEventHandlers))
{ {
return _animatedObjectEventHandlers[a.type](a.location.x, a.location.y, a.location.z); return _animatedObjectEventHandlers[a.type](a.location);
} }
return true; return true;
} }
@ -634,11 +634,11 @@ void AutoCreateMapAnimations()
while (tile_element_iterator_next(&it)) while (tile_element_iterator_next(&it))
{ {
auto el = it.element; auto el = it.element;
auto loc = CoordsXYZ{ it.x * 32, it.y * 32, el->base_height }; auto loc = CoordsXYZ{ it.x * 32, it.y * 32, el->base_height * 8 };
switch (el->GetType()) switch (el->GetType())
{ {
case TILE_ELEMENT_TYPE_BANNER: case TILE_ELEMENT_TYPE_BANNER:
map_animation_create(MAP_ANIMATION_TYPE_BANNER, loc.x, loc.y, loc.z); map_animation_create(MAP_ANIMATION_TYPE_BANNER, loc);
break; break;
case TILE_ELEMENT_TYPE_WALL: case TILE_ELEMENT_TYPE_WALL:
{ {
@ -647,7 +647,7 @@ void AutoCreateMapAnimations()
if (entry != nullptr if (entry != nullptr
&& ((entry->wall.flags2 & WALL_SCENERY_2_ANIMATED) || entry->wall.scrolling_mode != SCROLLING_MODE_NONE)) && ((entry->wall.flags2 & WALL_SCENERY_2_ANIMATED) || entry->wall.scrolling_mode != SCROLLING_MODE_NONE))
{ {
map_animation_create(MAP_ANIMATION_TYPE_WALL, loc.x, loc.y, loc.z); map_animation_create(MAP_ANIMATION_TYPE_WALL, loc);
} }
break; break;
} }
@ -657,7 +657,7 @@ void AutoCreateMapAnimations()
auto entry = sceneryEl->GetEntry(); auto entry = sceneryEl->GetEntry();
if (entry != nullptr && scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_ANIMATED)) if (entry != nullptr && scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_ANIMATED))
{ {
map_animation_create(MAP_ANIMATION_TYPE_SMALL_SCENERY, loc.x, loc.y, loc.z); map_animation_create(MAP_ANIMATION_TYPE_SMALL_SCENERY, loc);
} }
break; break;
} }
@ -667,7 +667,7 @@ void AutoCreateMapAnimations()
auto entry = sceneryEl->GetEntry(); auto entry = sceneryEl->GetEntry();
if (entry != nullptr && (entry->large_scenery.flags & LARGE_SCENERY_FLAG_ANIMATED)) if (entry != nullptr && (entry->large_scenery.flags & LARGE_SCENERY_FLAG_ANIMATED))
{ {
map_animation_create(MAP_ANIMATION_TYPE_LARGE_SCENERY, loc.x, loc.y, loc.z); map_animation_create(MAP_ANIMATION_TYPE_LARGE_SCENERY, loc);
} }
break; break;
} }
@ -676,7 +676,7 @@ void AutoCreateMapAnimations()
auto path = el->AsPath(); auto path = el->AsPath();
if (path->HasQueueBanner()) if (path->HasQueueBanner())
{ {
map_animation_create(MAP_ANIMATION_TYPE_QUEUE_BANNER, loc.x, loc.y, loc.z); map_animation_create(MAP_ANIMATION_TYPE_QUEUE_BANNER, loc);
} }
break; break;
} }
@ -688,11 +688,11 @@ void AutoCreateMapAnimations()
case ENTRANCE_TYPE_PARK_ENTRANCE: case ENTRANCE_TYPE_PARK_ENTRANCE:
if (entrance->GetSequenceIndex() == 0) if (entrance->GetSequenceIndex() == 0)
{ {
map_animation_create(MAP_ANIMATION_TYPE_PARK_ENTRANCE, loc.x, loc.y, loc.z); map_animation_create(MAP_ANIMATION_TYPE_PARK_ENTRANCE, loc);
} }
break; break;
case ENTRANCE_TYPE_RIDE_ENTRANCE: case ENTRANCE_TYPE_RIDE_ENTRANCE:
map_animation_create(MAP_ANIMATION_TYPE_RIDE_ENTRANCE, loc.x, loc.y, loc.z); map_animation_create(MAP_ANIMATION_TYPE_RIDE_ENTRANCE, loc);
break; break;
} }
break; break;
@ -703,16 +703,16 @@ void AutoCreateMapAnimations()
switch (track->GetTrackType()) switch (track->GetTrackType())
{ {
case TRACK_ELEM_WATERFALL: case TRACK_ELEM_WATERFALL:
map_animation_create(MAP_ANIMATION_TYPE_TRACK_WATERFALL, loc.x, loc.y, loc.z); map_animation_create(MAP_ANIMATION_TYPE_TRACK_WATERFALL, loc);
break; break;
case TRACK_ELEM_RAPIDS: case TRACK_ELEM_RAPIDS:
map_animation_create(MAP_ANIMATION_TYPE_TRACK_RAPIDS, loc.x, loc.y, loc.z); map_animation_create(MAP_ANIMATION_TYPE_TRACK_RAPIDS, loc);
break; break;
case TRACK_ELEM_WHIRLPOOL: case TRACK_ELEM_WHIRLPOOL:
map_animation_create(MAP_ANIMATION_TYPE_TRACK_WHIRLPOOL, loc.x, loc.y, loc.z); map_animation_create(MAP_ANIMATION_TYPE_TRACK_WHIRLPOOL, loc);
break; break;
case TRACK_ELEM_SPINNING_TUNNEL: case TRACK_ELEM_SPINNING_TUNNEL:
map_animation_create(MAP_ANIMATION_TYPE_TRACK_SPINNINGTUNNEL, loc.x, loc.y, loc.z); map_animation_create(MAP_ANIMATION_TYPE_TRACK_SPINNINGTUNNEL, loc);
break; break;
} }
break; break;

View File

@ -39,7 +39,7 @@ enum
MAP_ANIMATION_TYPE_COUNT MAP_ANIMATION_TYPE_COUNT
}; };
void map_animation_create(int32_t type, int32_t x, int32_t y, int32_t z); void map_animation_create(int32_t type, const CoordsXYZ loc);
void map_animation_invalidate_all(); void map_animation_invalidate_all();
const std::vector<MapAnimation>& GetMapAnimations(); const std::vector<MapAnimation>& GetMapAnimations();
void AutoCreateMapAnimations(); void AutoCreateMapAnimations();