diff --git a/src/openrct2/paint/map_element/fence.c b/src/openrct2/paint/map_element/fence.c index e574b49bcd..21d9fa781a 100644 --- a/src/openrct2/paint/map_element/fence.c +++ b/src/openrct2/paint/map_element/fence.c @@ -184,7 +184,7 @@ void fence_paint(uint8 direction, sint32 height, rct_map_element * map_element) rct_xyz16 boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_; uint8 animationFrame = wall_element_get_animation_frame(map_element); // Add the direction as well - animationFrame |= (map_element->properties.wall.animation & 0x80) >> 3; + animationFrame |= (map_element->properties.wall.animation & WALL_ANIMATION_FLAG_DIRECTION_BACKWARD) >> 3; uint32 imageId; switch (direction) { case 0: diff --git a/src/openrct2/ride/vehicle.c b/src/openrct2/ride/vehicle.c index 7cd1a50c40..0960af8667 100644 --- a/src/openrct2/ride/vehicle.c +++ b/src/openrct2/ride/vehicle.c @@ -6853,13 +6853,13 @@ static void vehicle_update_scenery_door(rct_vehicle *vehicle) } if (vehicle->next_vehicle_on_train != SPRITE_INDEX_NULL) { - mapElement->properties.wall.animation &= 7; - mapElement->properties.wall.animation |= 8; + mapElement->properties.wall.animation &= ~(WALL_ANIMATION_FLAG_DIRECTION_BACKWARD); + wall_element_set_animation_frame(mapElement, 1); map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, x, y, z); vehicle_play_scenery_door_open_sound(vehicle, mapElement); } else { - mapElement->properties.wall.animation &= 7; - mapElement->properties.wall.animation |= 0x30; + mapElement->properties.wall.animation &= ~(WALL_ANIMATION_FLAG_DIRECTION_BACKWARD); + wall_element_set_animation_frame(mapElement, 12); vehicle_play_scenery_door_close_sound(vehicle, mapElement); } } @@ -6936,13 +6936,13 @@ static void sub_6DEDE8(rct_vehicle *vehicle) } if (vehicle->next_vehicle_on_train != SPRITE_INDEX_NULL) { - mapElement->properties.wall.animation &= 7; - mapElement->properties.wall.animation |= 0x88; + mapElement->properties.wall.animation |= WALL_ANIMATION_FLAG_DIRECTION_BACKWARD; + wall_element_set_animation_frame(mapElement, 1); map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, x, y, z); vehicle_play_scenery_door_open_sound(vehicle, mapElement); } else { - mapElement->properties.wall.animation &= 7; - mapElement->properties.wall.animation |= 0xB0; + mapElement->properties.wall.animation &= ~(WALL_ANIMATION_FLAG_DIRECTION_BACKWARD); + wall_element_set_animation_frame(mapElement, 12); vehicle_play_scenery_door_close_sound(vehicle, mapElement); } } diff --git a/src/openrct2/world/map.h b/src/openrct2/world/map.h index a8b98bc1de..a9ad06806b 100644 --- a/src/openrct2/world/map.h +++ b/src/openrct2/world/map.h @@ -215,6 +215,13 @@ enum { PATH_FLAG_QUEUE_BANNER = 1 << 3 }; +enum { + WALL_ANIMATION_FLAG_ACROSS_TRACK = (1 << 2), + // 3 - 6 animation frame number + WALL_ANIMATION_FLAG_DIRECTION_BACKWARD = (1 << 7), + WALL_ANIMATION_FLAG_ALL_FLAGS = WALL_ANIMATION_FLAG_ACROSS_TRACK | WALL_ANIMATION_FLAG_DIRECTION_BACKWARD +}; + enum { ENTRANCE_TYPE_RIDE_ENTRANCE, ENTRANCE_TYPE_RIDE_EXIT, @@ -541,6 +548,7 @@ rct_map_element *map_get_track_element_at_with_direction_from_ride(sint32 x, sin bool map_is_location_at_edge(sint32 x, sint32 y); void map_obstruction_set_error_text(rct_map_element *mapElement); uint8 wall_element_get_animation_frame(rct_map_element *fenceElement); +void wall_element_set_animation_frame(rct_map_element * wallElement, uint8 frameNum); uint8 wall_element_get_secondary_colour(rct_map_element * wallElement); void wall_element_set_secondary_colour(rct_map_element * wallElement, uint8 secondaryColour); diff --git a/src/openrct2/world/map_animation.c b/src/openrct2/world/map_animation.c index 898457784e..51d8b099a2 100644 --- a/src/openrct2/world/map_animation.c +++ b/src/openrct2/world/map_animation.c @@ -473,7 +473,7 @@ static bool map_animation_invalidate_wall_door(sint32 x, sint32 y, sint32 baseZ) } bool invalidate = false; - uint8 bl = mapElement->properties.wall.animation & 0x87; + uint8 currentFrame = wall_element_get_animation_frame(mapElement); if (currentFrame != 0) { if (currentFrame == 15) { @@ -489,9 +489,7 @@ static bool map_animation_invalidate_wall_door(sint32 x, sint32 y, sint32 baseZ) } } } - bl |= currentFrame << 3; - - mapElement->properties.wall.animation = bl; + wall_element_set_animation_frame(mapElement, currentFrame); if (invalidate) { sint32 z = mapElement->base_height * 8; map_invalidate_tile_zoom1(x, y, z, z + 32); diff --git a/src/openrct2/world/wall.cpp b/src/openrct2/world/wall.cpp index 680d4ece96..36ed8cecb9 100644 --- a/src/openrct2/world/wall.cpp +++ b/src/openrct2/world/wall.cpp @@ -544,7 +544,7 @@ static money32 WallPlace(uint8 wallType, if (wallAcrossTrack) { - mapElement->properties.wall.animation |= (1 << 2); + mapElement->properties.wall.animation |= WALL_ANIMATION_FLAG_ACROSS_TRACK; } mapElement->properties.wall.type = wallType; @@ -698,6 +698,12 @@ extern "C" return (wallElement->properties.wall.animation >> 3) & 0xF; } + void wall_element_set_animation_frame(rct_map_element * wallElement, uint8 frameNum) + { + wallElement->properties.wall.animation &= WALL_ANIMATION_FLAG_ALL_FLAGS; + wallElement->properties.wall.animation |= (frameNum >> 3) & 0xF; + } + uint8 wall_element_get_secondary_colour(rct_map_element * wallElement) { uint8 secondaryColour = (wallElement->properties.wall.colour_1 & 0xE0) >> 5;