Add set animation frame function

This commit is contained in:
duncanspumpkin 2017-02-25 09:36:28 +00:00
parent 7691dc3c10
commit adab7f7a6d
5 changed files with 26 additions and 14 deletions

View File

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

View File

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

View File

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

View File

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

View File

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