mirror of https://github.com/OpenRCT2/OpenRCT2.git
Refactor fence door animation
This commit is contained in:
parent
9abff205c3
commit
50e1c831a6
|
@ -182,7 +182,9 @@ void fence_paint(uint8 direction, sint32 height, rct_map_element * map_element)
|
|||
if (sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR) {
|
||||
rct_xyz16 offset;
|
||||
rct_xyz16 boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_;
|
||||
uint8 animationFrame = (map_element->properties.fence.item[2] >> 3) & 0x1F;
|
||||
uint8 animationFrame = fence_get_animation_frame(map_element);
|
||||
// Add the direction as well
|
||||
animationFrame |= (map_element->properties.fence.item[2] & 0x80) >> 3;
|
||||
uint32 imageId;
|
||||
switch (direction) {
|
||||
case 0:
|
||||
|
@ -382,3 +384,7 @@ void fence_paint(uint8 direction, sint32 height, rct_map_element * map_element)
|
|||
|
||||
sub_98199C(scrolling_text_setup(stringId, scroll, scrollingMode), 0, 0, 1, 1, 13, height + 8, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation());
|
||||
}
|
||||
|
||||
uint8 fence_get_animation_frame(rct_map_element *fenceElement) {
|
||||
return (fenceElement->properties.fence.item[2] >> 3) & 0xF;
|
||||
}
|
||||
|
|
|
@ -1134,7 +1134,7 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32
|
|||
}
|
||||
}
|
||||
|
||||
bh = gMapGroundFlags & (ELEMENT_IS_1 | ELEMENT_IS_UNDERGROUND);
|
||||
bh = gMapGroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND);
|
||||
if (gTrackGroundFlags != 0 && (gTrackGroundFlags & bh) == 0) {
|
||||
gGameCommandErrorText = STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND;
|
||||
return MONEY32_UNDEFINED;
|
||||
|
|
|
@ -3237,7 +3237,7 @@ void game_command_place_scenery(sint32* eax, sint32* ebx, sint32* ecx, sint32* e
|
|||
return;
|
||||
}
|
||||
|
||||
gSceneryGroundFlags = gMapGroundFlags & (ELEMENT_IS_1 | ELEMENT_IS_UNDERGROUND);
|
||||
gSceneryGroundFlags = gMapGroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND);
|
||||
|
||||
*ebx = (scenery_entry->small_scenery.price * 10) + clearCost;
|
||||
if(gParkFlags & PARK_FLAGS_NO_MONEY){
|
||||
|
@ -3394,7 +3394,7 @@ static bool map_place_fence_check_obstruction(rct_scenery_entry *wall, sint32 x,
|
|||
rct_large_scenery_tile *tile;
|
||||
|
||||
_unk141F725 = 0;
|
||||
gMapGroundFlags = ELEMENT_IS_1;
|
||||
gMapGroundFlags = ELEMENT_IS_ABOVE_GROUND;
|
||||
if (map_is_location_at_edge(x, y)) {
|
||||
gGameCommandErrorText = STR_OFF_EDGE_OF_MAP;
|
||||
return false;
|
||||
|
@ -3915,7 +3915,7 @@ void game_command_place_large_scenery(sint32* eax, sint32* ebx, sint32* ecx, sin
|
|||
return;
|
||||
}
|
||||
|
||||
sint32 b = gMapGroundFlags & (ELEMENT_IS_1 | ELEMENT_IS_UNDERGROUND);
|
||||
sint32 b = gMapGroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND);
|
||||
if (!gCheatsDisableClearanceChecks) {
|
||||
if (gSceneryGroundFlags && !(gSceneryGroundFlags & b)) {
|
||||
gGameCommandErrorText = STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND;
|
||||
|
@ -4342,7 +4342,7 @@ static void map_obstruction_set_error_text(rct_map_element *mapElement)
|
|||
*/
|
||||
sint32 map_can_construct_with_clear_at(sint32 x, sint32 y, sint32 zLow, sint32 zHigh, CLEAR_FUNC *clearFunc, uint8 bl, uint8 flags, money32 *price)
|
||||
{
|
||||
gMapGroundFlags = ELEMENT_IS_1;
|
||||
gMapGroundFlags = ELEMENT_IS_ABOVE_GROUND;
|
||||
if (x >= gMapSizeUnits || y >= gMapSizeUnits || x < 32 || y < 32) {
|
||||
gGameCommandErrorText = STR_OFF_EDGE_OF_MAP;
|
||||
return false;
|
||||
|
@ -4378,7 +4378,7 @@ sint32 map_can_construct_with_clear_at(sint32 x, sint32 y, sint32 zLow, sint32 z
|
|||
if (map_element->base_height >= zHigh) {
|
||||
// loc_68BA81
|
||||
gMapGroundFlags |= ELEMENT_IS_UNDERGROUND;
|
||||
gMapGroundFlags &= ~ELEMENT_IS_1;
|
||||
gMapGroundFlags &= ~ELEMENT_IS_ABOVE_GROUND;
|
||||
} else {
|
||||
sint32 al = map_element->base_height;
|
||||
sint32 ah = al;
|
||||
|
|
|
@ -217,7 +217,7 @@ enum {
|
|||
};
|
||||
|
||||
enum {
|
||||
ELEMENT_IS_1 = 1 << 0,
|
||||
ELEMENT_IS_ABOVE_GROUND = 1 << 0,
|
||||
ELEMENT_IS_UNDERGROUND = 1 << 1,
|
||||
ELEMENT_IS_UNDERWATER = 1 << 2,
|
||||
};
|
||||
|
@ -533,4 +533,6 @@ rct_map_element *map_get_track_element_at_of_type_from_ride(sint32 x, sint32 y,
|
|||
rct_map_element *map_get_track_element_at_from_ride(sint32 x, sint32 y, sint32 z, sint32 rideIndex);
|
||||
rct_map_element *map_get_track_element_at_with_direction_from_ride(sint32 x, sint32 y, sint32 z, sint32 direction, sint32 rideIndex);
|
||||
|
||||
uint8 fence_get_animation_frame(rct_map_element *fenceElement);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -456,7 +456,7 @@ static bool map_animation_invalidate_wall_door(sint32 x, sint32 y, sint32 baseZ)
|
|||
if (gCurrentTicks & 1)
|
||||
return false;
|
||||
|
||||
bool wasInvalidated = false;
|
||||
bool removeAnimation = true;
|
||||
mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
||||
do {
|
||||
if (mapElement->base_height != baseZ)
|
||||
|
@ -468,38 +468,37 @@ static bool map_animation_invalidate_wall_door(sint32 x, sint32 y, sint32 baseZ)
|
|||
if (!(sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR))
|
||||
continue;
|
||||
|
||||
uint8 di = 0;
|
||||
uint8 bl = mapElement->properties.fence.item[2];
|
||||
uint8 bh = bl & 0x78;
|
||||
if (bh != 0) {
|
||||
if (bh == 0x78) {
|
||||
bl &= 0x87;
|
||||
} else {
|
||||
di |= 2;
|
||||
if (bh != 40) {
|
||||
bh += 8;
|
||||
if (bh == 104 && !(sceneryEntry->wall.flags & WALL_SCENERY_FLAG6))
|
||||
bh = 120;
|
||||
|
||||
di |= 1;
|
||||
bl &= 135;
|
||||
bl |= bh;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (game_is_paused()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool invalidate = false;
|
||||
uint8 bl = mapElement->properties.fence.item[2] & 0x87;
|
||||
uint8 currentFrame = fence_get_animation_frame(mapElement);
|
||||
if (currentFrame != 0) {
|
||||
if (currentFrame == 15) {
|
||||
currentFrame = 0;
|
||||
} else {
|
||||
removeAnimation = false;
|
||||
if (currentFrame != 5) {
|
||||
currentFrame++;
|
||||
if (currentFrame == 13 && !(sceneryEntry->wall.flags & WALL_SCENERY_FLAG6))
|
||||
currentFrame = 15;
|
||||
|
||||
invalidate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
bl |= currentFrame << 3;
|
||||
|
||||
mapElement->properties.fence.item[2] = bl;
|
||||
if (di & 1) {
|
||||
if (invalidate) {
|
||||
sint32 z = mapElement->base_height * 8;
|
||||
map_invalidate_tile_zoom1(x, y, z, z + 32);
|
||||
}
|
||||
if (di & 2)
|
||||
wasInvalidated = true;
|
||||
} while (!map_element_is_last_for_tile(mapElement++));
|
||||
|
||||
return !wasInvalidated;
|
||||
return removeAnimation;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue