From 50e1c831a6d1b2727e60b7eaba5fbc6e9fb30fe8 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sat, 18 Feb 2017 08:26:33 +0000 Subject: [PATCH 01/16] Refactor fence door animation --- src/openrct2/paint/map_element/fence.c | 8 ++++- src/openrct2/ride/track.c | 2 +- src/openrct2/world/map.c | 10 +++--- src/openrct2/world/map.h | 4 ++- src/openrct2/world/map_animation.c | 47 +++++++++++++------------- 5 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/openrct2/paint/map_element/fence.c b/src/openrct2/paint/map_element/fence.c index e7f8a1dc1d..3bb6d5acd4 100644 --- a/src/openrct2/paint/map_element/fence.c +++ b/src/openrct2/paint/map_element/fence.c @@ -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; +} diff --git a/src/openrct2/ride/track.c b/src/openrct2/ride/track.c index 855a2a4bff..e67fdc6842 100644 --- a/src/openrct2/ride/track.c +++ b/src/openrct2/ride/track.c @@ -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; diff --git a/src/openrct2/world/map.c b/src/openrct2/world/map.c index 24be817085..f312db9463 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -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; diff --git a/src/openrct2/world/map.h b/src/openrct2/world/map.h index eedcd17084..a9a7effd13 100644 --- a/src/openrct2/world/map.h +++ b/src/openrct2/world/map.h @@ -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 diff --git a/src/openrct2/world/map_animation.c b/src/openrct2/world/map_animation.c index 5cba31baf9..3012dd0642 100644 --- a/src/openrct2/world/map_animation.c +++ b/src/openrct2/world/map_animation.c @@ -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; } /** From 133266deb09b874e1d2bb1984f150263b8e92a32 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sun, 19 Feb 2017 11:03:05 +0000 Subject: [PATCH 02/16] Label fence offsets --- src/openrct2/interface/viewport_interaction.c | 2 +- src/openrct2/paint/map_element/fence.c | 20 +++++------ src/openrct2/rct1/S4Importer.cpp | 12 +++---- src/openrct2/ride/track_design_save.c | 12 +++---- src/openrct2/ride/vehicle.c | 16 ++++----- src/openrct2/windows/sign.c | 8 ++--- src/openrct2/windows/tile_inspector.c | 2 +- src/openrct2/world/map.c | 34 +++++++++---------- src/openrct2/world/map.h | 7 +++- src/openrct2/world/map_animation.c | 4 +-- 10 files changed, 61 insertions(+), 56 deletions(-) diff --git a/src/openrct2/interface/viewport_interaction.c b/src/openrct2/interface/viewport_interaction.c index 27db414ba5..992f203149 100644 --- a/src/openrct2/interface/viewport_interaction.c +++ b/src/openrct2/interface/viewport_interaction.c @@ -492,7 +492,7 @@ static void viewport_interaction_remove_park_wall(rct_map_element *mapElement, s { rct_scenery_entry *sceneryEntry = get_wall_entry(mapElement->properties.fence.type); if (sceneryEntry->wall.scrolling_mode != 0xFF){ - window_sign_small_open(mapElement->properties.fence.item[0]); + window_sign_small_open(mapElement->properties.fence.banner_index); } else { gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; game_do_command( diff --git a/src/openrct2/paint/map_element/fence.c b/src/openrct2/paint/map_element/fence.c index 3bb6d5acd4..733a3701ea 100644 --- a/src/openrct2/paint/map_element/fence.c +++ b/src/openrct2/paint/map_element/fence.c @@ -145,18 +145,18 @@ void fence_paint(uint8 direction, sint32 height, rct_map_element * map_element) } - sint32 primaryColour = map_element->properties.fence.item[1] & 0x1F; + sint32 primaryColour = map_element->properties.fence.colour_1 & 0x1F; uint32 imageColourFlags = primaryColour << 19 | 0x20000000; uint32 dword_141F718 = imageColourFlags + 0x23800006; if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { - uint8 secondaryColour = (map_element->properties.fence.item[1] >> 5) | ((map_element->flags & 0x60) >> 2); + uint8 secondaryColour = (map_element->properties.fence.colour_1 >> 5) | ((map_element->flags & 0x60) >> 2); imageColourFlags |= secondaryColour << 24 | 0x80000000; } uint32 tertiaryColour = 0; if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) { - tertiaryColour = map_element->properties.fence.item[0]; + tertiaryColour = map_element->properties.fence.colour_3; imageColourFlags &= 0x0DFFFFFFF; } @@ -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 = fence_get_animation_frame(map_element); // Add the direction as well - animationFrame |= (map_element->properties.fence.item[2] & 0x80) >> 3; + animationFrame |= (map_element->properties.fence.animation & 0x80) >> 3; uint32 imageId; switch (direction) { case 0: @@ -345,21 +345,21 @@ void fence_paint(uint8 direction, sint32 height, rct_map_element * map_element) set_format_arg(0, uint32, 0); set_format_arg(4, uint32, 0); - uint8 al_2 = map_element->properties.fence.item[1] >> 5 | (map_element->flags & 0x60) >> 2; + uint8 secondaryColour = map_element->properties.fence.colour_1 >> 5 | (map_element->flags & 0x60) >> 2; if (dword_141F710 != 0) { - al_2 = COLOUR_GREY; + secondaryColour = COLOUR_GREY; } if (direction == 0) { - al_2 |= 0x80; + secondaryColour |= 0x80; } - set_format_arg(7, uint8, al_2); + set_format_arg(7, uint8, secondaryColour); uint16 scrollingMode = sceneryEntry->wall.scrolling_mode + ((direction + 1) & 0x3); - uint8 bannerIndex = map_element->properties.fence.item[0]; + uint8 bannerIndex = map_element->properties.fence.banner_index; rct_banner * banner = &gBanners[bannerIndex]; set_format_arg(0, rct_string_id, banner->string_idx); @@ -386,5 +386,5 @@ void fence_paint(uint8 direction, sint32 height, rct_map_element * map_element) } uint8 fence_get_animation_frame(rct_map_element *fenceElement) { - return (fenceElement->properties.fence.item[2] >> 3) & 0xF; + return (fenceElement->properties.fence.animation >> 3) & 0xF; } diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index a0bc2eeb73..7b40ad16cb 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -411,9 +411,9 @@ private: break; case MAP_ELEMENT_TYPE_FENCE: { - uint8 var_05 = mapElement->properties.fence.item[0]; - uint16 var_06 = mapElement->properties.fence.item[1] | - (mapElement->properties.fence.item[2] << 8); + uint8 var_05 = mapElement->properties.fence.colour_3; + uint16 var_06 = mapElement->properties.fence.colour_1 | + (mapElement->properties.fence.animation << 8); for (sint32 edge = 0; edge < 4; edge++) { @@ -2209,9 +2209,9 @@ private: rct_map_element originalMapElement = *mapElement; map_element_remove(mapElement); - uint8 var_05 = originalMapElement.properties.fence.item[0]; - uint16 var_06 = originalMapElement.properties.fence.item[1] | - (originalMapElement.properties.fence.item[2] << 8); + uint8 var_05 = originalMapElement.properties.fence.colour_3; + uint16 var_06 = originalMapElement.properties.fence.colour_1 | + (originalMapElement.properties.fence.animation << 8); for (sint32 edge = 0; edge < 4; edge++) { diff --git a/src/openrct2/ride/track_design_save.c b/src/openrct2/ride/track_design_save.c index 0066e2b4a0..8c6c37da2e 100644 --- a/src/openrct2/ride/track_design_save.c +++ b/src/openrct2/ride/track_design_save.c @@ -337,10 +337,10 @@ static void track_design_save_add_wall(sint32 x, sint32 y, rct_map_element *mapE uint8 flags = 0; flags |= mapElement->type & 3; - flags |= mapElement->properties.fence.item[0] << 2; + flags |= mapElement->properties.fence.colour_3 << 2; - uint8 secondaryColour = ((mapElement->flags & 0x60) >> 2) | (mapElement->properties.fence.item[1] >> 5); - uint8 primaryColour = mapElement->properties.fence.item[1] & 0x1F; + uint8 secondaryColour = ((mapElement->flags & 0x60) >> 2) | (mapElement->properties.fence.colour_1 >> 5); + uint8 primaryColour = mapElement->properties.fence.colour_1 & 0x1F; track_design_save_push_map_element(x, y, mapElement); track_design_save_push_map_element_desc(entry, x, y, mapElement->base_height, flags, primaryColour, secondaryColour); @@ -520,10 +520,10 @@ static void track_design_save_remove_wall(sint32 x, sint32 y, rct_map_element *m uint8 flags = 0; flags |= mapElement->type & 3; - flags |= mapElement->properties.fence.item[0] << 2; + flags |= mapElement->properties.fence.colour_3 << 2; - uint8 secondaryColour = ((mapElement->flags & 0x60) >> 2) | (mapElement->properties.fence.item[1] >> 5); - uint8 primaryColour = mapElement->properties.fence.item[1] & 0x1F; + uint8 secondaryColour = ((mapElement->flags & 0x60) >> 2) | (mapElement->properties.fence.colour_1 >> 5); + uint8 primaryColour = mapElement->properties.fence.colour_1 & 0x1F; track_design_save_pop_map_element(x, y, mapElement); track_design_save_pop_map_element_desc(entry, x, y, mapElement->base_height, flags, primaryColour, secondaryColour); diff --git a/src/openrct2/ride/vehicle.c b/src/openrct2/ride/vehicle.c index 41cc13061b..5366a94913 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.fence.item[2] &= 7; - mapElement->properties.fence.item[2] |= 8; + mapElement->properties.fence.animation &= 7; + mapElement->properties.fence.animation |= 8; map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, x, y, z); vehicle_play_scenery_door_open_sound(vehicle, mapElement); } else { - mapElement->properties.fence.item[2] &= 7; - mapElement->properties.fence.item[2] |= 0x30; + mapElement->properties.fence.animation &= 7; + mapElement->properties.fence.animation |= 0x30; 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.fence.item[2] &= 7; - mapElement->properties.fence.item[2] |= 0x88; + mapElement->properties.fence.animation &= 7; + mapElement->properties.fence.animation |= 0x88; map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, x, y, z); vehicle_play_scenery_door_open_sound(vehicle, mapElement); } else { - mapElement->properties.fence.item[2] &= 7; - mapElement->properties.fence.item[2] |= 0xB0; + mapElement->properties.fence.animation &= 7; + mapElement->properties.fence.animation |= 0xB0; vehicle_play_scenery_door_close_sound(vehicle, mapElement); } } diff --git a/src/openrct2/windows/sign.c b/src/openrct2/windows/sign.c index ca34ee7794..cc8277053b 100644 --- a/src/openrct2/windows/sign.c +++ b/src/openrct2/windows/sign.c @@ -437,7 +437,7 @@ void window_sign_small_open(rct_windownumber number){ if (map_element_get_type(map_element) == MAP_ELEMENT_TYPE_FENCE) { rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); if (scenery_entry->wall.scrolling_mode != 0xFF){ - if (map_element->properties.fence.item[0] == w->number) + if (map_element->properties.fence.banner_index == w->number) break; } } @@ -447,9 +447,9 @@ void window_sign_small_open(rct_windownumber number){ sint32 view_z = map_element->base_height << 3; w->frame_no = view_z; - w->list_information_type = map_element->properties.fence.item[1] & 0x1F; + w->list_information_type = map_element->properties.fence.colour_1 & 0x1F; w->var_492 = - ((map_element->properties.fence.item[1] >> 5) | ((map_element->flags & 0x60) >> 2)); + ((map_element->properties.fence.colour_1 >> 5) | ((map_element->flags & 0x60) >> 2)); w->var_48C = map_element->properties.fence.type; view_x += 16; @@ -499,7 +499,7 @@ static void window_sign_small_mouseup(rct_window *w, sint32 widgetIndex) if (map_element_get_type(map_element) == MAP_ELEMENT_TYPE_FENCE) { rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); if (scenery_entry->wall.scrolling_mode != 0xFF){ - if (map_element->properties.fence.item[0] == w->number) + if (map_element->properties.fence.banner_index == w->number) break; } } diff --git a/src/openrct2/windows/tile_inspector.c b/src/openrct2/windows/tile_inspector.c index 3cecb4c48f..9a61f0b183 100644 --- a/src/openrct2/windows/tile_inspector.c +++ b/src/openrct2/windows/tile_inspector.c @@ -1840,7 +1840,7 @@ static void window_tile_inspector_paint(rct_window *w, rct_drawpixelinfo *dpi) // Banner info rct_wall_scenery_entry fenceEntry = get_wall_entry(fenceType)->wall; if (fenceEntry.flags & WALL_SCENERY_IS_BANNER) { - gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_ENTRY_BANNER_TEXT, &gBanners[mapElement->properties.fence.item[0]].string_idx, COLOUR_DARK_GREEN, x, y + 11); + gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_ENTRY_BANNER_TEXT, &gBanners[mapElement->properties.fence.banner_index].string_idx, COLOUR_DARK_GREEN, x, y + 11); } else { gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_ENTRY_BANNER_NONE, NULL, COLOUR_DARK_GREEN, x, y + 11); diff --git a/src/openrct2/world/map.c b/src/openrct2/world/map.c index f312db9463..6dbbcdaf57 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -128,7 +128,7 @@ rct_xyz16 gCommandPosition; uint8 gUnk9E2E28; -static uint8 _unk141F725; +static bool gWallAcrossTrack; static void map_update_grass_length(sint32 x, sint32 y, rct_map_element *mapElement); static void map_set_grass_length(sint32 x, sint32 y, rct_map_element *mapElement, sint32 length); @@ -1244,15 +1244,15 @@ void game_command_set_fence_colour(sint32* eax, sint32* ebx, sint32* ecx, sint32 if(flags & GAME_COMMAND_FLAG_APPLY){ rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); - map_element->properties.fence.item[1] &= 0xE0; - map_element->properties.fence.item[1] |= colour1; - map_element->properties.fence.item[1] &= 0x1F; + map_element->properties.fence.colour_1 &= 0xE0; + map_element->properties.fence.colour_1 |= colour1; + map_element->properties.fence.colour_1 &= 0x1F; map_element->flags &= 0x9F; - map_element->properties.fence.item[1] |= (colour2 & 0x7) * 32; + map_element->properties.fence.colour_1 |= (colour2 & 0x7) * 32; map_element->flags |= (colour2 & 0x18) * 4; if(scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ - map_element->properties.fence.item[0] = colour3; + map_element->properties.fence.colour_3 = colour3; } map_invalidate_tile_zoom1(x, y, z, z + 72); } @@ -3329,7 +3329,7 @@ static bool map_place_fence_check_obstruction_with_track(rct_scenery_entry *wall return false; } - _unk141F725 |= 1; + gWallAcrossTrack = true; if (z0 & 1) { return false; } @@ -3393,7 +3393,7 @@ static bool map_place_fence_check_obstruction(rct_scenery_entry *wall, sint32 x, rct_scenery_entry *entry; rct_large_scenery_tile *tile; - _unk141F725 = 0; + gWallAcrossTrack = false; gMapGroundFlags = ELEMENT_IS_ABOVE_GROUND; if (map_is_location_at_edge(x, y)) { gGameCommandErrorText = STR_OFF_EDGE_OF_MAP; @@ -3717,21 +3717,21 @@ void game_command_place_fence(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx map_element->type = bp | edge | MAP_ELEMENT_TYPE_FENCE; - map_element->properties.fence.item[1] = primary_colour; - map_element->properties.fence.item[1] |= (secondary_colour & 7) << 5; + map_element->properties.fence.colour_1 = primary_colour; + map_element->properties.fence.colour_1 |= (secondary_colour & 7) << 5; map_element->flags |= (secondary_colour & 0x18) << 2; - if (_unk141F725 & 1) { - map_element->properties.fence.item[2] |= (1 << 2); + if (gWallAcrossTrack) { + map_element->properties.fence.animation |= (1 << 2); } map_element->properties.fence.type = fence_type; if (banner_index != 0xFF){ - map_element->properties.fence.item[0] = banner_index; + map_element->properties.fence.banner_index = banner_index; } if (fence->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ - map_element->properties.fence.item[0] = tertiary_colour; + map_element->properties.fence.colour_3 = tertiary_colour; } if (flags & (1 << 6)){ @@ -4637,7 +4637,7 @@ sint32 map_element_get_banner_index(rct_map_element *mapElement) if (sceneryEntry->wall.scrolling_mode == 0xFF) return -1; - return mapElement->properties.fence.item[0]; + return mapElement->properties.fence.banner_index; case MAP_ELEMENT_TYPE_BANNER: return mapElement->properties.banner.index; default: @@ -5594,7 +5594,7 @@ void game_command_set_sign_style(sint32* eax, sint32* ebx, sint32* ecx, sint32* rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); if (scenery_entry->wall.scrolling_mode == 0xFF) continue; - if (map_element->properties.fence.item[0] != bannerId) + if (map_element->properties.fence.banner_index != bannerId) continue; fence_found = true; break; @@ -5611,7 +5611,7 @@ void game_command_set_sign_style(sint32* eax, sint32* ebx, sint32* ecx, sint32* } map_element->flags &= 0x9F; - map_element->properties.fence.item[1] = + map_element->properties.fence.colour_1 = mainColour | ((textColour & 0x7) << 5); map_element->flags |= ((textColour & 0x18) << 2); diff --git a/src/openrct2/world/map.h b/src/openrct2/world/map.h index a9a7effd13..71399fc4c0 100644 --- a/src/openrct2/world/map.h +++ b/src/openrct2/world/map.h @@ -70,7 +70,12 @@ assert_struct_size(rct_map_element_entrance_properties, 4); typedef struct rct_map_element_fence_properties { uint8 type; //4 - uint8 item[3]; //5 + union { + uint8 colour_3; //5 + uint8 banner_index; //5 + }; + uint8 colour_1; //6 0b_2221_1111 2 = colour_2 (uses flags for rest of colour2), 1 = colour_1 + uint8 animation; //7 0b_dfff_ft00 d = direction, f = frame num, t = across track flag (not used) } rct_map_element_fence_properties; assert_struct_size(rct_map_element_fence_properties, 4); diff --git a/src/openrct2/world/map_animation.c b/src/openrct2/world/map_animation.c index 3012dd0642..917c4bd0cb 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.fence.item[2] & 0x87; + uint8 bl = mapElement->properties.fence.animation & 0x87; uint8 currentFrame = fence_get_animation_frame(mapElement); if (currentFrame != 0) { if (currentFrame == 15) { @@ -491,7 +491,7 @@ static bool map_animation_invalidate_wall_door(sint32 x, sint32 y, sint32 baseZ) } bl |= currentFrame << 3; - mapElement->properties.fence.item[2] = bl; + mapElement->properties.fence.animation = bl; if (invalidate) { sint32 z = mapElement->base_height * 8; map_invalidate_tile_zoom1(x, y, z, z + 32); From 735f1d42b9b109ebe4da0f84e0a9a1da9eb50fd0 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Mon, 20 Feb 2017 20:09:40 +0000 Subject: [PATCH 03/16] Move fence functions into fence.cpp --- src/openrct2/libopenrct2.vcxproj | 1 + src/openrct2/paint/map_element/fence.c | 4 - src/openrct2/world/fence.cpp | 717 +++++++++++++++++++++++++ src/openrct2/world/map.c | 683 +---------------------- src/openrct2/world/map.h | 2 + 5 files changed, 722 insertions(+), 685 deletions(-) create mode 100644 src/openrct2/world/fence.cpp diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 601b403f64..667f7b4eda 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -333,6 +333,7 @@ + diff --git a/src/openrct2/paint/map_element/fence.c b/src/openrct2/paint/map_element/fence.c index 733a3701ea..0e6bc7e5f9 100644 --- a/src/openrct2/paint/map_element/fence.c +++ b/src/openrct2/paint/map_element/fence.c @@ -384,7 +384,3 @@ 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.animation >> 3) & 0xF; -} diff --git a/src/openrct2/world/fence.cpp b/src/openrct2/world/fence.cpp new file mode 100644 index 0000000000..400239c775 --- /dev/null +++ b/src/openrct2/world/fence.cpp @@ -0,0 +1,717 @@ +#pragma region Copyright (c) 2014-2016 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 + +#include "../common.h" +#include "../network/network.h" + +extern "C" +{ + #include "map.h" + #include "park.h" + #include "scenery.h" + #include "../cheats.h" + #include "../game.h" + #include "../ride/track.h" + #include "../ride/track_data.h" + #include "../localisation/string_ids.h" +} + +static bool gWallAcrossTrack; + +extern "C" +{ + uint8 fence_get_animation_frame(rct_map_element *fenceElement) { + return (fenceElement->properties.fence.animation >> 3) & 0xF; + } + + rct_map_element *map_get_fence_element_at(sint32 x, sint32 y, sint32 z, sint32 direction) + { + rct_map_element *mapElement = map_get_first_element_at(x >> 5, y >> 5); + do { + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) + continue; + if (mapElement->base_height != z) + continue; + if (map_element_get_direction(mapElement) != direction) + continue; + + return mapElement; + } while (!map_element_is_last_for_tile(mapElement++)); + return NULL; + } + + /** + * + * rct2: 0x006E588E + */ + void map_remove_walls_at(sint32 x, sint32 y, sint32 z0, sint32 z1) + { + rct_map_element *mapElement; + + z0 /= 8; + z1 /= 8; + repeat: + mapElement = map_get_first_element_at(x >> 5, y >> 5); + do { + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) + continue; + if (z0 >= mapElement->clearance_height) + continue; + if (z1 <= mapElement->base_height) + continue; + + map_element_remove_banner_entry(mapElement); + map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->base_height * 8 + 72); + map_element_remove(mapElement); + goto repeat; + } while (!map_element_is_last_for_tile(mapElement++)); + } + + /** + * + * rct2: 0x006E57E6 + */ + void map_remove_walls_at_z(sint32 x, sint32 y, sint32 z) + { + map_remove_walls_at(x, y, z, z + 48); + } + + /** + * + * rct2: 0x006E5935 + */ + void map_remove_intersecting_walls(sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 direction) + { + rct_map_element *mapElement; + + mapElement = map_get_first_element_at(x >> 5, y >> 5); + do { + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) + continue; + + if (mapElement->clearance_height <= z0 || mapElement->base_height >= z1) + continue; + + if (direction != (mapElement->type & 3)) + continue; + + map_element_remove_banner_entry(mapElement); + map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->base_height * 8 + 72); + map_element_remove(mapElement); + mapElement--; + } while (!map_element_is_last_for_tile(mapElement++)); + } + + /** + * + * rct2: 0x006E5CBA + */ + static bool map_place_fence_check_obstruction_with_track(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge, rct_map_element *trackElement) + { + const rct_preview_track *trackBlock; + sint32 z, direction; + + sint32 trackType = trackElement->properties.track.type; + sint32 sequence = trackElement->properties.track.sequence & 0x0F; + direction = (edge - trackElement->type) & 3; + rct_ride *ride = get_ride(trackElement->properties.track.ride_index); + + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) { + if (FlatRideTrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) { + if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) { + return true; + } + } + } else { + if (TrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) { + if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) { + return true; + } + } + } + + if (!(wall->wall.flags & WALL_SCENERY_IS_DOOR)) { + return false; + } + + if (!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_0)) { + return false; + } + + rct_ride_entry *rideEntry = get_ride_entry(ride->subtype); + if (rideEntry->flags & RIDE_ENTRY_FLAG_16) { + return false; + } + + gWallAcrossTrack = true; + if (z0 & 1) { + return false; + } + + if (sequence == 0) { + if (TrackSequenceProperties[trackType][0] & TRACK_SEQUENCE_FLAG_DISALLOW_DOORS) { + return false; + } + + if (TrackDefinitions[trackType].bank_start == 0) { + if (!(TrackCoordinates[trackType].rotation_begin & 4)) { + direction = (trackElement->type & 3) ^ 2; + if (direction == edge) { + trackBlock = &TrackBlocks[trackType][sequence]; + z = TrackCoordinates[trackType].z_begin; + z = trackElement->base_height + ((z - trackBlock->z) * 8); + if (z == z0) { + return true; + } + } + } + } + } + + trackBlock = &TrackBlocks[trackType][sequence + 1]; + if (trackBlock->index != 0xFF) { + return false; + } + + if (TrackDefinitions[trackType].bank_end != 0) { + return false; + } + + direction = TrackCoordinates[trackType].rotation_end; + if (direction & 4) { + return false; + } + + direction = (trackElement->type + direction) & 3; + if (direction != edge) { + return false; + } + + trackBlock = &TrackBlocks[trackType][sequence]; + z = TrackCoordinates[trackType].z_end; + z = trackElement->base_height + ((z - trackBlock->z) * 8); + if (z != z0) { + return false; + } + + return true; + } + + /** + * + * rct2: 0x006E5C1A + */ + static bool map_place_fence_check_obstruction(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge) + { + sint32 entryType, sequence; + rct_scenery_entry *entry; + rct_large_scenery_tile *tile; + + gWallAcrossTrack = false; + gMapGroundFlags = ELEMENT_IS_ABOVE_GROUND; + if (map_is_location_at_edge(x, y)) { + gGameCommandErrorText = STR_OFF_EDGE_OF_MAP; + return false; + } + + rct_map_element *mapElement = map_get_first_element_at(x / 32, y / 32); + do { + sint32 elementType = map_element_get_type(mapElement); + if (elementType == MAP_ELEMENT_TYPE_SURFACE) continue; + if (z0 >= mapElement->clearance_height) continue; + if (z1 <= mapElement->base_height) continue; + if (elementType == MAP_ELEMENT_TYPE_FENCE) { + sint32 direction = mapElement->type & 3; + if (edge == direction) { + map_obstruction_set_error_text(mapElement); + return false; + } + continue; + } + if ((mapElement->flags & 0x0F) == 0) continue; + + switch (elementType) { + case MAP_ELEMENT_TYPE_ENTRANCE: + map_obstruction_set_error_text(mapElement); + return false; + case MAP_ELEMENT_TYPE_PATH: + if (mapElement->properties.path.edges & (1 << edge)) { + map_obstruction_set_error_text(mapElement); + return false; + } + break; + case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE: + entryType = mapElement->properties.scenerymultiple.type & 0x3FF; + sequence = mapElement->properties.scenerymultiple.type >> 10; + entry = get_large_scenery_entry(entryType); + tile = &entry->large_scenery.tiles[sequence]; + { + sint32 direction = ((edge - mapElement->type) & 3) + 8; + if (!(tile->var_7 & (1 << direction))) { + map_obstruction_set_error_text(mapElement); + return false; + } + } + break; + case MAP_ELEMENT_TYPE_SCENERY: + entryType = mapElement->properties.scenery.type; + entry = get_small_scenery_entry(entryType); + if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_ALLOW_WALLS) { + map_obstruction_set_error_text(mapElement); + return false; + } + break; + case MAP_ELEMENT_TYPE_TRACK: + if (!map_place_fence_check_obstruction_with_track(wall, x, y, z0, z1, edge, mapElement)) { + return false; + } + break; + } + } while (!map_element_is_last_for_tile(mapElement++)); + return true; + } + + enum + { + EDGE_SLOPE_ELEVATED = (1 << 0), // 0x01 + EDGE_SLOPE_UPWARDS = (1 << 6), // 0x40 + EDGE_SLOPE_DOWNWARDS = (1 << 7), // 0x80 + + EDGE_SLOPE_UPWARDS_ELEVATED = EDGE_SLOPE_UPWARDS | EDGE_SLOPE_ELEVATED, + EDGE_SLOPE_DOWNWARDS_ELEVATED = EDGE_SLOPE_DOWNWARDS | EDGE_SLOPE_ELEVATED, + }; + + /** rct2: 0x009A3FEC */ + static const uint8 EdgeSlopes[][4] = { + // Top right Bottom right Bottom left Top left + { 0, 0, 0, 0 }, + { 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, 0 }, + { 0, 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS }, + { 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS }, + { EDGE_SLOPE_DOWNWARDS, 0, 0, EDGE_SLOPE_UPWARDS }, + { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, + { EDGE_SLOPE_DOWNWARDS, 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED }, + { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED }, + { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, 0, 0 }, + { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, 0 }, + { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS }, + { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS }, + { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, 0, EDGE_SLOPE_UPWARDS }, + { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, + { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED }, + { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS }, + { 0, 0, 0, 0 }, + { EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, + { EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED }, + { 0, 0, 0, 0 }, + }; + + /** + * + * rct2: 0x006E519A + */ + void game_command_place_fence(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp){ + rct_xyz16 position = { + *eax & 0xFFFF, + *ecx & 0xFFFF, + *edi & 0xFFFF + }; + + uint8 flags = *ebx & 0xFF; + uint8 fence_type = (*ebx >> 8) & 0xFF; + uint8 primary_colour = (*edx >> 8) & 0xFF; + uint8 secondary_colour = *ebp & 0xFF; + uint8 tertiary_colour = (*ebp >> 8) & 0xFF; + uint8 edge = *edx & 0xFF; + + gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + gCommandPosition.x = position.x + 16; + gCommandPosition.y = position.y + 16; + gCommandPosition.z = position.z; + + if (position.z == 0){ + gCommandPosition.z = map_element_height(position.x, position.y) & 0xFFFF; + } + + if (game_is_paused() && !gCheatsBuildInPauseMode){ + gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; + *ebx = MONEY32_UNDEFINED; + return; + } + + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && + !(flags & GAME_COMMAND_FLAG_7) && !gCheatsSandboxMode){ + + if (position.z == 0){ + if (!map_is_location_in_park(position.x, position.y)){ + *ebx = MONEY32_UNDEFINED; + return; + } + } + else if (!map_is_location_owned(position.x, position.y, position.z)){ + *ebx = MONEY32_UNDEFINED; + return; + } + } + + uint8 bp = 0; + if (position.z == 0){ + rct_map_element* map_element = map_get_surface_element_at(position.x / 32, position.y / 32); + if (map_element == NULL){ + *ebx = MONEY32_UNDEFINED; + return; + } + position.z = map_element->base_height * 8; + + uint8 slope = map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK; + bp = EdgeSlopes[slope][edge & 3]; + if (bp & EDGE_SLOPE_ELEVATED) { + position.z += 16; + bp &= ~(1 << 0); + } + } + + rct_map_element* map_element = map_get_surface_element_at(position.x / 32, position.y / 32); + if (map_element == NULL){ + *ebx = MONEY32_UNDEFINED; + return; + } + + if (map_element->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK){ + uint16 water_height = map_element->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK; + water_height *= 16; + + if (position.z < water_height){ + gGameCommandErrorText = STR_CANT_BUILD_THIS_UNDERWATER; + *ebx = MONEY32_UNDEFINED; + return; + } + } + + if (position.z / 8 < map_element->base_height){ + gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; + *ebx = MONEY32_UNDEFINED; + return; + } + + if (!(bp & 0xC0)){ + uint8 new_edge = (edge + 2) & 3; + uint8 new_base_height = map_element->base_height; + new_base_height += 2; + if (map_element->properties.surface.slope & (1 << new_edge)){ + if (position.z / 8 < new_base_height){ + gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; + *ebx = MONEY32_UNDEFINED; + return; + } + + if (map_element->properties.surface.slope & (1 << 4)){ + new_edge = (new_edge - 1) & 3; + + if (map_element->properties.surface.slope & (1 << new_edge)){ + new_edge = (new_edge + 2) & 3; + if (map_element->properties.surface.slope & (1 << new_edge)){ + new_base_height += 2; + if (position.z / 8 < new_base_height){ + gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; + *ebx = MONEY32_UNDEFINED; + return; + } + new_base_height -= 2; + } + } + } + } + + new_edge = (edge + 3) & 3; + if (map_element->properties.surface.slope & (1 << new_edge)){ + if (position.z / 8 < new_base_height){ + gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; + *ebx = MONEY32_UNDEFINED; + return; + } + + if (map_element->properties.surface.slope & (1 << 4)){ + new_edge = (new_edge - 1) & 3; + + if (map_element->properties.surface.slope & (1 << new_edge)){ + new_edge = (new_edge + 2) & 3; + if (map_element->properties.surface.slope & (1 << new_edge)){ + new_base_height += 2; + if (position.z / 8 < new_base_height){ + gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; + *ebx = MONEY32_UNDEFINED; + return; + } + } + } + } + } + } + sint32 banner_index = 0xFF; + rct_scenery_entry* fence = get_wall_entry(fence_type); + // Have to check both -1 and NULL, as one can be a invalid object, + // while the other can be invalid index + if ((uintptr_t)fence == (uintptr_t)-1 || fence == NULL) { + *ebx = MONEY32_UNDEFINED; + return; + } + if (fence->wall.scrolling_mode != 0xFF){ + banner_index = create_new_banner(flags); + + if (banner_index == 0xFF){ + *ebx = MONEY32_UNDEFINED; + return; + } + + rct_banner* banner = &gBanners[banner_index]; + if (flags & GAME_COMMAND_FLAG_APPLY){ + banner->flags |= (1 << 3); + banner->type = 0; + banner->x = position.x / 32; + banner->y = position.y / 32; + + sint32 rideIndex = banner_get_closest_ride_index(position.x, position.y, position.z); + if (rideIndex != -1) { + banner->colour = rideIndex & 0xFF; + banner->flags |= BANNER_FLAG_LINKED_TO_RIDE; + } + } + } + + uint8 clearanceHeight = position.z / 8; + if (bp & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS)) { + if (fence->wall.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE){ + gGameCommandErrorText = STR_ERR_UNABLE_TO_BUILD_THIS_ON_SLOPE; + *ebx = MONEY32_UNDEFINED; + return; + } + clearanceHeight += 2; + } + clearanceHeight += fence->wall.height; + + if (!(flags & GAME_COMMAND_FLAG_7) && !gCheatsDisableClearanceChecks){ + if (!map_place_fence_check_obstruction(fence, position.x, position.y, position.z / 8, clearanceHeight, edge)) { + *ebx = MONEY32_UNDEFINED; + return; + } + } + + if (!map_check_free_elements_and_reorganise(1)){ + *ebx = MONEY32_UNDEFINED; + return; + } + + if (flags & GAME_COMMAND_FLAG_APPLY){ + if (gGameCommandNestLevel == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) { + rct_xyz16 coord; + coord.x = position.x + 16; + coord.y = position.y + 16; + coord.z = map_element_height(coord.x, coord.y); + network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); + } + + map_element = map_element_insert(position.x / 32, position.y / 32, position.z / 8, 0); + assert(map_element != NULL); + + map_animation_create(MAP_ANIMATION_TYPE_WALL, position.x, position.y, position.z / 8); + + map_element->clearance_height = clearanceHeight; + + map_element->type = bp | edge | MAP_ELEMENT_TYPE_FENCE; + + map_element->properties.fence.colour_1 = primary_colour; + map_element->properties.fence.colour_1 |= (secondary_colour & 7) << 5; + map_element->flags |= (secondary_colour & 0x18) << 2; + + if (gWallAcrossTrack) { + map_element->properties.fence.animation |= (1 << 2); + } + + map_element->properties.fence.type = fence_type; + if (banner_index != 0xFF){ + map_element->properties.fence.banner_index = banner_index; + } + + if (fence->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ + map_element->properties.fence.colour_3 = tertiary_colour; + } + + if (flags & (1 << 6)){ + map_element->flags |= MAP_ELEMENT_FLAG_GHOST; + } + + gSceneryMapElement = map_element; + map_invalidate_tile_zoom1(position.x, position.y, map_element->base_height * 8, map_element->base_height * 8 + 72); + } + + if (gParkFlags & PARK_FLAGS_NO_MONEY){ + *ebx = 0; + } + else{ + *ebx = fence->wall.price; + } + } + + money32 map_place_fence( + sint32 type, sint32 x, sint32 y, sint32 z, sint32 edge, sint32 primaryColour, sint32 secondaryColour, sint32 tertiaryColour, sint32 flags + ) { + sint32 eax, ebx, ecx, edx, esi, edi, ebp; + + eax = x; + ebx = flags | (type << 8); + ecx = y; + edx = edge | (primaryColour << 8); + edi = z; + ebp = secondaryColour | (tertiaryColour << 8); + game_command_place_fence(&eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + return ebx; + } + + + /** + * + * rct2: 0x006E5597 + */ + void game_command_remove_fence(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) + { + sint32 x = *eax; + sint32 y = *ecx; + if (!map_is_location_valid(x, y)) { + *ebx = MONEY32_UNDEFINED; + return; + } + uint8 base_height = (*edx >> 8); + uint8 direction = *edx; + uint8 flags = *ebx & 0xFF; + + gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + if(!(flags & GAME_COMMAND_FLAG_GHOST) && game_is_paused() && !gCheatsBuildInPauseMode){ + gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; + *ebx = MONEY32_UNDEFINED; + return; + } + if(!(flags & GAME_COMMAND_FLAG_GHOST) && !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && !map_is_location_owned(x, y, base_height * 8)){ + *ebx = MONEY32_UNDEFINED; + return; + } + + bool sceneryFound = false; + rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32); + do { + if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_FENCE) + continue; + if (map_element->base_height != base_height) + continue; + if ((map_element->type & MAP_ELEMENT_DIRECTION_MASK) != direction) + continue; + if ((flags & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST)) + continue; + + sceneryFound = true; + break; + } while (!map_element_is_last_for_tile(map_element++)); + + if (!(*ebx & GAME_COMMAND_FLAG_APPLY) || (sceneryFound == false)) { + *ebx = 0; + return; + } + + if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) { + rct_xyz16 coord; + coord.x = x + 16; + coord.y = y + 16; + coord.z = map_element_height(coord.x, coord.y); + network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); + } + + map_element_remove_banner_entry(map_element); + map_invalidate_tile_zoom1(x, y, map_element->base_height * 8, (map_element->base_height * 8) + 72); + map_element_remove(map_element); + *ebx = 0; + } + + /** + * + * rct2: 0x006E56B5 + */ + void game_command_set_fence_colour(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) + { + gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + sint32 x = *eax; + sint32 y = *ecx; + uint8 map_element_direction = *edx; + uint8 base_height = *edx >> 8; + uint8 colour1 = *ebx >> 8; + uint8 colour2 = *ebp; + uint8 colour3 = *ebp >> 8; + uint8 flags = *ebx & 0xFF; + sint32 z = base_height * 8; + + gCommandPosition.x = x + 16; + gCommandPosition.y = y + 16; + gCommandPosition.z = z; + + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && + !map_is_location_in_park(x, y) && + !gCheatsSandboxMode) { + + *ebx = MONEY32_UNDEFINED; + return; + } + + rct_map_element* map_element = map_get_fence_element_at(x, y, base_height, map_element_direction); + + if (map_element == NULL) { + *ebx = 0; + return; + } + + if ((flags & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST)) { + *ebx = 0; + return; + } + + if(flags & GAME_COMMAND_FLAG_APPLY){ + rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); + map_element->properties.fence.colour_1 &= 0xE0; + map_element->properties.fence.colour_1 |= colour1; + map_element->properties.fence.colour_1 &= 0x1F; + map_element->flags &= 0x9F; + map_element->properties.fence.colour_1 |= (colour2 & 0x7) * 32; + map_element->flags |= (colour2 & 0x18) * 4; + + if(scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ + map_element->properties.fence.colour_3 = colour3; + } + map_invalidate_tile_zoom1(x, y, z, z + 72); + } + + *ebx = 0; + } +} diff --git a/src/openrct2/world/map.c b/src/openrct2/world/map.c index 6dbbcdaf57..def3c3a25b 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -128,13 +128,10 @@ rct_xyz16 gCommandPosition; uint8 gUnk9E2E28; -static bool gWallAcrossTrack; - static void map_update_grass_length(sint32 x, sint32 y, rct_map_element *mapElement); static void map_set_grass_length(sint32 x, sint32 y, rct_map_element *mapElement, sint32 length); static void clear_elements_at(sint32 x, sint32 y); static void translate_3d_to_2d(sint32 rotation, sint32 *x, sint32 *y); -static void map_obstruction_set_error_text(rct_map_element *mapElement); void rotate_map_coordinates(sint16 *x, sint16 *y, sint32 rotation) { @@ -1201,65 +1198,6 @@ void game_command_set_scenery_colour(sint32* eax, sint32* ebx, sint32* ecx, sint *ebx = 0; } -/** - * - * rct2: 0x006E56B5 - */ -void game_command_set_fence_colour(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) -{ - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - sint32 x = *eax; - sint32 y = *ecx; - uint8 map_element_direction = *edx; - uint8 base_height = *edx >> 8; - uint8 colour1 = *ebx >> 8; - uint8 colour2 = *ebp; - uint8 colour3 = *ebp >> 8; - uint8 flags = *ebx & 0xFF; - sint32 z = base_height * 8; - - gCommandPosition.x = x + 16; - gCommandPosition.y = y + 16; - gCommandPosition.z = z; - - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && - !map_is_location_in_park(x, y) && - !gCheatsSandboxMode) { - - *ebx = MONEY32_UNDEFINED; - return; - } - - rct_map_element* map_element = map_get_fence_element_at(x, y, base_height, map_element_direction); - - if (map_element == NULL) { - *ebx = 0; - return; - } - - if ((flags & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST)) { - *ebx = 0; - return; - } - - if(flags & GAME_COMMAND_FLAG_APPLY){ - rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); - map_element->properties.fence.colour_1 &= 0xE0; - map_element->properties.fence.colour_1 |= colour1; - map_element->properties.fence.colour_1 &= 0x1F; - map_element->flags &= 0x9F; - map_element->properties.fence.colour_1 |= (colour2 & 0x7) * 32; - map_element->flags |= (colour2 & 0x18) * 4; - - if(scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ - map_element->properties.fence.colour_3 = colour3; - } - map_invalidate_tile_zoom1(x, y, z, z + 72); - } - - *ebx = 0; -} - /** * * rct2: 0x006B909A @@ -2803,68 +2741,6 @@ void game_command_set_water_height(sint32* eax, sint32* ebx, sint32* ecx, sint32 } } -/** - * - * rct2: 0x006E5597 - */ -void game_command_remove_fence(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) -{ - sint32 x = *eax; - sint32 y = *ecx; - if (!map_is_location_valid(x, y)) { - *ebx = MONEY32_UNDEFINED; - return; - } - uint8 base_height = (*edx >> 8); - uint8 direction = *edx; - uint8 flags = *ebx & 0xFF; - - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - if(!(flags & GAME_COMMAND_FLAG_GHOST) && game_is_paused() && !gCheatsBuildInPauseMode){ - gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; - *ebx = MONEY32_UNDEFINED; - return; - } - if(!(flags & GAME_COMMAND_FLAG_GHOST) && !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && !map_is_location_owned(x, y, base_height * 8)){ - *ebx = MONEY32_UNDEFINED; - return; - } - - bool sceneryFound = false; - rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32); - do { - if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_FENCE) - continue; - if (map_element->base_height != base_height) - continue; - if ((map_element->type & MAP_ELEMENT_DIRECTION_MASK) != direction) - continue; - if ((flags & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST)) - continue; - - sceneryFound = true; - break; - } while (!map_element_is_last_for_tile(map_element++)); - - if (!(*ebx & GAME_COMMAND_FLAG_APPLY) || (sceneryFound == false)) { - *ebx = 0; - return; - } - - if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) { - rct_xyz16 coord; - coord.x = x + 16; - coord.y = y + 16; - coord.z = map_element_height(coord.x, coord.y); - network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); - } - - map_element_remove_banner_entry(map_element); - map_invalidate_tile_zoom1(x, y, map_element->base_height * 8, (map_element->base_height * 8) + 72); - map_element_remove(map_element); - *ebx = 0; -} - /** * * rct2: 0x006B9E6D @@ -3283,488 +3159,11 @@ void game_command_place_scenery(sint32* eax, sint32* ebx, sint32* ecx, sint32* e } } -static bool map_is_location_at_edge(sint32 x, sint32 y) +bool map_is_location_at_edge(sint32 x, sint32 y) { return x < 32 || y < 32 || x >= ((256 - 1) * 32) || y >= ((256 - 1) * 32); } -/** - * - * rct2: 0x006E5CBA - */ -static bool map_place_fence_check_obstruction_with_track(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge, rct_map_element *trackElement) -{ - const rct_preview_track *trackBlock; - sint32 z, direction; - - sint32 trackType = trackElement->properties.track.type; - sint32 sequence = trackElement->properties.track.sequence & 0x0F; - direction = (edge - trackElement->type) & 3; - rct_ride *ride = get_ride(trackElement->properties.track.ride_index); - - if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) { - if (FlatRideTrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) { - if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) { - return true; - } - } - } else { - if (TrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) { - if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) { - return true; - } - } - } - - if (!(wall->wall.flags & WALL_SCENERY_IS_DOOR)) { - return false; - } - - if (!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_0)) { - return false; - } - - rct_ride_entry *rideEntry = get_ride_entry(ride->subtype); - if (rideEntry->flags & RIDE_ENTRY_FLAG_16) { - return false; - } - - gWallAcrossTrack = true; - if (z0 & 1) { - return false; - } - - if (sequence == 0) { - if (TrackSequenceProperties[trackType][0] & TRACK_SEQUENCE_FLAG_DISALLOW_DOORS) { - return false; - } - - if (TrackDefinitions[trackType].bank_start == 0) { - if (!(TrackCoordinates[trackType].rotation_begin & 4)) { - direction = (trackElement->type & 3) ^ 2; - if (direction == edge) { - trackBlock = &TrackBlocks[trackType][sequence]; - z = TrackCoordinates[trackType].z_begin; - z = trackElement->base_height + ((z - trackBlock->z) * 8); - if (z == z0) { - return true; - } - } - } - } - } - - trackBlock = &TrackBlocks[trackType][sequence + 1]; - if (trackBlock->index != 0xFF) { - return false; - } - - if (TrackDefinitions[trackType].bank_end != 0) { - return false; - } - - direction = TrackCoordinates[trackType].rotation_end; - if (direction & 4) { - return false; - } - - direction = (trackElement->type + direction) & 3; - if (direction != edge) { - return false; - } - - trackBlock = &TrackBlocks[trackType][sequence]; - z = TrackCoordinates[trackType].z_end; - z = trackElement->base_height + ((z - trackBlock->z) * 8); - if (z != z0) { - return false; - } - - return true; -} - -/** - * - * rct2: 0x006E5C1A - */ -static bool map_place_fence_check_obstruction(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge) -{ - sint32 entryType, sequence; - rct_scenery_entry *entry; - rct_large_scenery_tile *tile; - - gWallAcrossTrack = false; - gMapGroundFlags = ELEMENT_IS_ABOVE_GROUND; - if (map_is_location_at_edge(x, y)) { - gGameCommandErrorText = STR_OFF_EDGE_OF_MAP; - return false; - } - - rct_map_element *mapElement = map_get_first_element_at(x / 32, y / 32); - do { - sint32 elementType = map_element_get_type(mapElement); - if (elementType == MAP_ELEMENT_TYPE_SURFACE) continue; - if (z0 >= mapElement->clearance_height) continue; - if (z1 <= mapElement->base_height) continue; - if (elementType == MAP_ELEMENT_TYPE_FENCE) { - sint32 direction = mapElement->type & 3; - if (edge == direction) { - map_obstruction_set_error_text(mapElement); - return false; - } - continue; - } - if ((mapElement->flags & 0x0F) == 0) continue; - - switch (elementType) { - case MAP_ELEMENT_TYPE_ENTRANCE: - map_obstruction_set_error_text(mapElement); - return false; - case MAP_ELEMENT_TYPE_PATH: - if (mapElement->properties.path.edges & (1 << edge)) { - map_obstruction_set_error_text(mapElement); - return false; - } - break; - case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE: - entryType = mapElement->properties.scenerymultiple.type & 0x3FF; - sequence = mapElement->properties.scenerymultiple.type >> 10; - entry = get_large_scenery_entry(entryType); - tile = &entry->large_scenery.tiles[sequence]; - - sint32 direction = ((edge - mapElement->type) & 3) + 8; - if (!(tile->var_7 & (1 << direction))) { - map_obstruction_set_error_text(mapElement); - return false; - } - break; - case MAP_ELEMENT_TYPE_SCENERY: - entryType = mapElement->properties.scenery.type; - entry = get_small_scenery_entry(entryType); - if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_ALLOW_WALLS) { - map_obstruction_set_error_text(mapElement); - return false; - } - break; - case MAP_ELEMENT_TYPE_TRACK: - if (!map_place_fence_check_obstruction_with_track(wall, x, y, z0, z1, edge, mapElement)) { - return false; - } - break; - } - } while (!map_element_is_last_for_tile(mapElement++)); - return true; -} - -enum -{ - EDGE_SLOPE_ELEVATED = (1 << 0), // 0x01 - EDGE_SLOPE_UPWARDS = (1 << 6), // 0x40 - EDGE_SLOPE_DOWNWARDS = (1 << 7), // 0x80 - - EDGE_SLOPE_UPWARDS_ELEVATED = EDGE_SLOPE_UPWARDS | EDGE_SLOPE_ELEVATED, - EDGE_SLOPE_DOWNWARDS_ELEVATED = EDGE_SLOPE_DOWNWARDS | EDGE_SLOPE_ELEVATED, -}; - -/** rct2: 0x009A3FEC */ -static const uint8 EdgeSlopes[][4] = { -// Top right Bottom right Bottom left Top left - { 0, 0, 0, 0 }, - { 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, 0 }, - { 0, 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS }, - { 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS }, - { EDGE_SLOPE_DOWNWARDS, 0, 0, EDGE_SLOPE_UPWARDS }, - { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, - { EDGE_SLOPE_DOWNWARDS, 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED }, - { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED }, - { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, 0, 0 }, - { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, 0 }, - { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS }, - { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS }, - { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, 0, EDGE_SLOPE_UPWARDS }, - { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, - { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED }, - { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS }, - { 0, 0, 0, 0 }, - { EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, - { EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED }, - { 0, 0, 0, 0 }, -}; - -/** - * - * rct2: 0x006E519A - */ -void game_command_place_fence(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp){ - rct_xyz16 position = { - .x = *eax & 0xFFFF, - .y = *ecx & 0xFFFF, - .z = *edi & 0xFFFF - }; - - uint8 flags = *ebx & 0xFF; - uint8 fence_type = (*ebx >> 8) & 0xFF; - uint8 primary_colour = (*edx >> 8) & 0xFF; - uint8 secondary_colour = *ebp & 0xFF; - uint8 tertiary_colour = (*ebp >> 8) & 0xFF; - uint8 edge = *edx & 0xFF; - - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - gCommandPosition.x = position.x + 16; - gCommandPosition.y = position.y + 16; - gCommandPosition.z = position.z; - - if (position.z == 0){ - gCommandPosition.z = map_element_height(position.x, position.y) & 0xFFFF; - } - - if (game_is_paused() && !gCheatsBuildInPauseMode){ - gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; - *ebx = MONEY32_UNDEFINED; - return; - } - - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && - !(flags & GAME_COMMAND_FLAG_7) && !gCheatsSandboxMode){ - - if (position.z == 0){ - if (!map_is_location_in_park(position.x, position.y)){ - *ebx = MONEY32_UNDEFINED; - return; - } - } - else if (!map_is_location_owned(position.x, position.y, position.z)){ - *ebx = MONEY32_UNDEFINED; - return; - } - } - - uint8 bp = 0; - if (position.z == 0){ - rct_map_element* map_element = map_get_surface_element_at(position.x / 32, position.y / 32); - if (map_element == NULL){ - *ebx = MONEY32_UNDEFINED; - return; - } - position.z = map_element->base_height * 8; - - uint8 slope = map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK; - bp = EdgeSlopes[slope][edge & 3]; - if (bp & EDGE_SLOPE_ELEVATED) { - position.z += 16; - bp &= ~(1 << 0); - } - } - - rct_map_element* map_element = map_get_surface_element_at(position.x / 32, position.y / 32); - if (map_element == NULL){ - *ebx = MONEY32_UNDEFINED; - return; - } - - if (map_element->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK){ - uint16 water_height = map_element->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK; - water_height *= 16; - - if (position.z < water_height){ - gGameCommandErrorText = STR_CANT_BUILD_THIS_UNDERWATER; - *ebx = MONEY32_UNDEFINED; - return; - } - } - - if (position.z / 8 < map_element->base_height){ - gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; - *ebx = MONEY32_UNDEFINED; - return; - } - - if (!(bp & 0xC0)){ - uint8 new_edge = (edge + 2) & 3; - uint8 new_base_height = map_element->base_height; - new_base_height += 2; - if (map_element->properties.surface.slope & (1 << new_edge)){ - if (position.z / 8 < new_base_height){ - gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; - *ebx = MONEY32_UNDEFINED; - return; - } - - if (map_element->properties.surface.slope & (1 << 4)){ - new_edge = (new_edge - 1) & 3; - - if (map_element->properties.surface.slope & (1 << new_edge)){ - new_edge = (new_edge + 2) & 3; - if (map_element->properties.surface.slope & (1 << new_edge)){ - new_base_height += 2; - if (position.z / 8 < new_base_height){ - gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; - *ebx = MONEY32_UNDEFINED; - return; - } - new_base_height -= 2; - } - } - } - } - - new_edge = (edge + 3) & 3; - if (map_element->properties.surface.slope & (1 << new_edge)){ - if (position.z / 8 < new_base_height){ - gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; - *ebx = MONEY32_UNDEFINED; - return; - } - - if (map_element->properties.surface.slope & (1 << 4)){ - new_edge = (new_edge - 1) & 3; - - if (map_element->properties.surface.slope & (1 << new_edge)){ - new_edge = (new_edge + 2) & 3; - if (map_element->properties.surface.slope & (1 << new_edge)){ - new_base_height += 2; - if (position.z / 8 < new_base_height){ - gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; - *ebx = MONEY32_UNDEFINED; - return; - } - } - } - } - } - } - sint32 banner_index = 0xFF; - rct_scenery_entry* fence = get_wall_entry(fence_type); - // Have to check both -1 and NULL, as one can be a invalid object, - // while the other can be invalid index - if ((uintptr_t)fence == (uintptr_t)-1 || fence == NULL) { - *ebx = MONEY32_UNDEFINED; - return; - } - if (fence->wall.scrolling_mode != 0xFF){ - banner_index = create_new_banner(flags); - - if (banner_index == 0xFF){ - *ebx = MONEY32_UNDEFINED; - return; - } - - rct_banner* banner = &gBanners[banner_index]; - if (flags & GAME_COMMAND_FLAG_APPLY){ - banner->flags |= (1 << 3); - banner->type = 0; - banner->x = position.x / 32; - banner->y = position.y / 32; - - sint32 rideIndex = banner_get_closest_ride_index(position.x, position.y, position.z); - if (rideIndex != -1) { - banner->colour = rideIndex & 0xFF; - banner->flags |= BANNER_FLAG_LINKED_TO_RIDE; - } - } - } - - uint8 clearanceHeight = position.z / 8; - if (bp & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS)) { - if (fence->wall.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE){ - gGameCommandErrorText = STR_ERR_UNABLE_TO_BUILD_THIS_ON_SLOPE; - *ebx = MONEY32_UNDEFINED; - return; - } - clearanceHeight += 2; - } - clearanceHeight += fence->wall.height; - - if (!(flags & GAME_COMMAND_FLAG_7) && !gCheatsDisableClearanceChecks){ - if (!map_place_fence_check_obstruction(fence, position.x, position.y, position.z / 8, clearanceHeight, edge)) { - *ebx = MONEY32_UNDEFINED; - return; - } - } - - if (!map_check_free_elements_and_reorganise(1)){ - *ebx = MONEY32_UNDEFINED; - return; - } - - if (flags & GAME_COMMAND_FLAG_APPLY){ - if (gGameCommandNestLevel == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) { - rct_xyz16 coord; - coord.x = position.x + 16; - coord.y = position.y + 16; - coord.z = map_element_height(coord.x, coord.y); - network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); - } - - map_element = map_element_insert(position.x / 32, position.y / 32, position.z / 8, 0); - assert(map_element != NULL); - - map_animation_create(MAP_ANIMATION_TYPE_WALL, position.x, position.y, position.z / 8); - - map_element->clearance_height = clearanceHeight; - - map_element->type = bp | edge | MAP_ELEMENT_TYPE_FENCE; - - map_element->properties.fence.colour_1 = primary_colour; - map_element->properties.fence.colour_1 |= (secondary_colour & 7) << 5; - map_element->flags |= (secondary_colour & 0x18) << 2; - - if (gWallAcrossTrack) { - map_element->properties.fence.animation |= (1 << 2); - } - - map_element->properties.fence.type = fence_type; - if (banner_index != 0xFF){ - map_element->properties.fence.banner_index = banner_index; - } - - if (fence->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ - map_element->properties.fence.colour_3 = tertiary_colour; - } - - if (flags & (1 << 6)){ - map_element->flags |= MAP_ELEMENT_FLAG_GHOST; - } - - gSceneryMapElement = map_element; - map_invalidate_tile_zoom1(position.x, position.y, map_element->base_height * 8, map_element->base_height * 8 + 72); - } - - if (gParkFlags & PARK_FLAGS_NO_MONEY){ - *ebx = 0; - } - else{ - *ebx = fence->wall.price; - } -} - -money32 map_place_fence( - sint32 type, sint32 x, sint32 y, sint32 z, sint32 edge, sint32 primaryColour, sint32 secondaryColour, sint32 tertiaryColour, sint32 flags -) { - sint32 eax, ebx, ecx, edx, esi, edi, ebp; - - eax = x; - ebx = flags | (type << 8); - ecx = y; - edx = edge | (primaryColour << 8); - edi = z; - ebp = secondaryColour | (tertiaryColour << 8); - game_command_place_fence(&eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - return ebx; -} - /** * * rct2: 0x006B893C @@ -4277,7 +3676,7 @@ bool map_element_check_address(const rct_map_element * const element) * * rct2: 0x0068BB18 */ -static void map_obstruction_set_error_text(rct_map_element *mapElement) +void map_obstruction_set_error_text(rct_map_element *mapElement) { rct_string_id errorStringId; rct_ride *ride; @@ -4447,32 +3846,6 @@ sint32 map_can_construct_at(sint32 x, sint32 y, sint32 zLow, sint32 zHigh, uint8 return map_can_construct_with_clear_at(x, y, zLow, zHigh, NULL, bl, 0, NULL); } -/** - * - * rct2: 0x006E5935 - */ -void map_remove_intersecting_walls(sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 direction) -{ - rct_map_element *mapElement; - - mapElement = map_get_first_element_at(x >> 5, y >> 5); - do { - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) - continue; - - if (mapElement->clearance_height <= z0 || mapElement->base_height >= z1) - continue; - - if (direction != (mapElement->type & 3)) - continue; - - map_element_remove_banner_entry(mapElement); - map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->base_height * 8 + 72); - map_element_remove(mapElement); - mapElement--; - } while (!map_element_is_last_for_tile(mapElement++)); -} - /** * Updates grass length, scenery age and jumping fountains. * @@ -4900,22 +4273,6 @@ rct_map_element *map_get_large_scenery_segment(sint32 x, sint32 y, sint32 z, sin return NULL; } -rct_map_element *map_get_fence_element_at(sint32 x, sint32 y, sint32 z, sint32 direction) -{ - rct_map_element *mapElement = map_get_first_element_at(x >> 5, y >> 5); - do { - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) - continue; - if (mapElement->base_height != z) - continue; - if (map_element_get_direction(mapElement) != direction) - continue; - - return mapElement; - } while (!map_element_is_last_for_tile(mapElement++)); - return NULL; -} - rct_map_element *map_get_park_entrance_element_at(sint32 x, sint32 y, sint32 z, bool ghost) { rct_map_element* mapElement = map_get_first_element_at(x >> 5, y >> 5); @@ -5026,42 +4383,6 @@ bool sign_set_colour(sint32 x, sint32 y, sint32 z, sint32 direction, sint32 sequ return true; } -/** - * - * rct2: 0x006E588E - */ -void map_remove_walls_at(sint32 x, sint32 y, sint32 z0, sint32 z1) -{ - rct_map_element *mapElement; - - z0 /= 8; - z1 /= 8; -repeat: - mapElement = map_get_first_element_at(x >> 5, y >> 5); - do { - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) - continue; - if (z0 >= mapElement->clearance_height) - continue; - if (z1 <= mapElement->base_height) - continue; - - map_element_remove_banner_entry(mapElement); - map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->base_height * 8 + 72); - map_element_remove(mapElement); - goto repeat; - } while (!map_element_is_last_for_tile(mapElement++)); -} - -/** - * - * rct2: 0x006E57E6 - */ -void map_remove_walls_at_z(sint32 x, sint32 y, sint32 z) -{ - map_remove_walls_at(x, y, z, z + 48); -} - static void translate_3d_to_2d(sint32 rotation, sint32 *x, sint32 *y) { sint32 rx, ry; diff --git a/src/openrct2/world/map.h b/src/openrct2/world/map.h index 71399fc4c0..158125b6b8 100644 --- a/src/openrct2/world/map.h +++ b/src/openrct2/world/map.h @@ -538,6 +538,8 @@ 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); +bool map_is_location_at_edge(sint32 x, sint32 y); +void map_obstruction_set_error_text(rct_map_element *mapElement); uint8 fence_get_animation_frame(rct_map_element *fenceElement); #endif From 72d97371b18aab3212173b301fbe77408ab2f7dd Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Mon, 20 Feb 2017 20:15:43 +0000 Subject: [PATCH 04/16] Rename to wall.cpp --- src/openrct2/libopenrct2.vcxproj | 2 +- src/openrct2/world/{fence.cpp => wall.cpp} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/openrct2/world/{fence.cpp => wall.cpp} (100%) diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 667f7b4eda..2ffebe8f65 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -333,7 +333,6 @@ - @@ -413,6 +412,7 @@ + diff --git a/src/openrct2/world/fence.cpp b/src/openrct2/world/wall.cpp similarity index 100% rename from src/openrct2/world/fence.cpp rename to src/openrct2/world/wall.cpp From f54c71b61c45a468df783013c3df3b0e9fc2382f Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Mon, 20 Feb 2017 21:02:19 +0000 Subject: [PATCH 05/16] Rename functions to wall. Refactor game commands --- src/openrct2/game.c | 8 +- src/openrct2/game.h | 6 +- src/openrct2/interface/viewport_interaction.c | 2 +- src/openrct2/network/NetworkAction.cpp | 6 +- src/openrct2/paint/map_element/fence.c | 2 +- src/openrct2/paint/map_element/map_element.c | 2 +- src/openrct2/peep/peep.c | 12 +- src/openrct2/rct1/S4Importer.cpp | 8 +- src/openrct2/ride/ride.c | 2 +- src/openrct2/ride/track.c | 8 +- src/openrct2/ride/track_design.c | 6 +- src/openrct2/ride/track_design_save.c | 4 +- src/openrct2/ride/vehicle.c | 4 +- .../windows/editor_object_selection.c | 2 +- src/openrct2/windows/footpath.c | 4 +- src/openrct2/windows/map.c | 4 +- src/openrct2/windows/sign.c | 6 +- src/openrct2/windows/tile_inspector.c | 4 +- src/openrct2/windows/top_toolbar.c | 6 +- src/openrct2/world/footpath.c | 6 +- src/openrct2/world/map.c | 44 +- src/openrct2/world/map.h | 20 +- src/openrct2/world/map_animation.c | 6 +- src/openrct2/world/scenery.c | 2 +- src/openrct2/world/tile_inspector.c | 4 +- src/openrct2/world/wall.cpp | 1159 ++++++++--------- 26 files changed, 667 insertions(+), 670 deletions(-) diff --git a/src/openrct2/game.c b/src/openrct2/game.c index 43fa7e97a1..7da626a20d 100644 --- a/src/openrct2/game.c +++ b/src/openrct2/game.c @@ -494,7 +494,7 @@ sint32 game_do_command_p(sint32 command, sint32 *eax, sint32 *ebx, sint32 *ecx, // Remove ghost scenery so it doesn't interfere with incoming network command if ((flags & GAME_COMMAND_FLAG_NETWORKED) && !(flags & GAME_COMMAND_FLAG_GHOST) && - (command == GAME_COMMAND_PLACE_FENCE || + (command == GAME_COMMAND_PLACE_WALL || command == GAME_COMMAND_PLACE_SCENERY || command == GAME_COMMAND_PLACE_LARGE_SCENERY || command == GAME_COMMAND_PLACE_BANNER || @@ -1217,8 +1217,8 @@ GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT] = { game_command_set_maze_track, game_command_set_park_entrance_fee, game_command_update_staff_colour, - game_command_place_fence, - game_command_remove_fence, + game_command_place_wall, + game_command_remove_wall, game_command_place_large_scenery, game_command_remove_large_scenery, game_command_set_current_loan, @@ -1229,7 +1229,7 @@ GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT] = { game_command_place_banner, game_command_remove_banner, game_command_set_scenery_colour, - game_command_set_fence_colour, + game_command_set_wall_colour, game_command_set_large_scenery_colour, game_command_set_banner_colour, game_command_set_land_ownership, diff --git a/src/openrct2/game.h b/src/openrct2/game.h index ff6c30c67b..85af48415f 100644 --- a/src/openrct2/game.h +++ b/src/openrct2/game.h @@ -65,8 +65,8 @@ enum GAME_COMMAND { GAME_COMMAND_SET_MAZE_TRACK, GAME_COMMAND_SET_PARK_ENTRANCE_FEE, GAME_COMMAND_SET_STAFF_COLOUR, - GAME_COMMAND_PLACE_FENCE, - GAME_COMMAND_REMOVE_FENCE, + GAME_COMMAND_PLACE_WALL, + GAME_COMMAND_REMOVE_WALL, GAME_COMMAND_PLACE_LARGE_SCENERY, GAME_COMMAND_REMOVE_LARGE_SCENERY, GAME_COMMAND_SET_CURRENT_LOAN, @@ -77,7 +77,7 @@ enum GAME_COMMAND { GAME_COMMAND_PLACE_BANNER, GAME_COMMAND_REMOVE_BANNER, GAME_COMMAND_SET_SCENERY_COLOUR, - GAME_COMMAND_SET_FENCE_COLOUR, + GAME_COMMAND_SET_WALL_COLOUR, GAME_COMMAND_SET_LARGE_SCENERY_COLOUR, GAME_COMMAND_SET_BANNER_COLOUR, GAME_COMMAND_SET_LAND_OWNERSHIP, diff --git a/src/openrct2/interface/viewport_interaction.c b/src/openrct2/interface/viewport_interaction.c index 992f203149..b0bfc91a58 100644 --- a/src/openrct2/interface/viewport_interaction.c +++ b/src/openrct2/interface/viewport_interaction.c @@ -500,7 +500,7 @@ static void viewport_interaction_remove_park_wall(rct_map_element *mapElement, s GAME_COMMAND_FLAG_APPLY, y, (mapElement->type & 0x3) | (mapElement->base_height << 8), - GAME_COMMAND_REMOVE_FENCE, + GAME_COMMAND_REMOVE_WALL, 0, 0 ); diff --git a/src/openrct2/network/NetworkAction.cpp b/src/openrct2/network/NetworkAction.cpp index a59d24d1e3..812b4766fe 100644 --- a/src/openrct2/network/NetworkAction.cpp +++ b/src/openrct2/network/NetworkAction.cpp @@ -128,14 +128,14 @@ const std::vector NetworkActions::Actions = GAME_COMMAND_REMOVE_SCENERY, GAME_COMMAND_PLACE_SCENERY, GAME_COMMAND_SET_BRAKES_SPEED, - GAME_COMMAND_REMOVE_FENCE, - GAME_COMMAND_PLACE_FENCE, + GAME_COMMAND_REMOVE_WALL, + GAME_COMMAND_PLACE_WALL, GAME_COMMAND_REMOVE_LARGE_SCENERY, GAME_COMMAND_PLACE_LARGE_SCENERY, GAME_COMMAND_PLACE_BANNER, GAME_COMMAND_REMOVE_BANNER, GAME_COMMAND_SET_SCENERY_COLOUR, - GAME_COMMAND_SET_FENCE_COLOUR, + GAME_COMMAND_SET_WALL_COLOUR, GAME_COMMAND_SET_LARGE_SCENERY_COLOUR, GAME_COMMAND_SET_BANNER_COLOUR, GAME_COMMAND_SET_BANNER_NAME, diff --git a/src/openrct2/paint/map_element/fence.c b/src/openrct2/paint/map_element/fence.c index 0e6bc7e5f9..96b158f2af 100644 --- a/src/openrct2/paint/map_element/fence.c +++ b/src/openrct2/paint/map_element/fence.c @@ -182,7 +182,7 @@ 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 = fence_get_animation_frame(map_element); + uint8 animationFrame = wall_get_animation_frame(map_element); // Add the direction as well animationFrame |= (map_element->properties.fence.animation & 0x80) >> 3; uint32 imageId; diff --git a/src/openrct2/paint/map_element/map_element.c b/src/openrct2/paint/map_element/map_element.c index 1b0e748d1e..16cfd800e4 100644 --- a/src/openrct2/paint/map_element/map_element.c +++ b/src/openrct2/paint/map_element/map_element.c @@ -273,7 +273,7 @@ static void sub_68B3FB(sint32 x, sint32 y) case MAP_ELEMENT_TYPE_ENTRANCE: entrance_paint(direction, height, map_element); break; - case MAP_ELEMENT_TYPE_FENCE: + case MAP_ELEMENT_TYPE_WALL: fence_paint(direction, height, map_element); break; case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE: diff --git a/src/openrct2/peep/peep.c b/src/openrct2/peep/peep.c index aeef199b52..c8c0b140aa 100644 --- a/src/openrct2/peep/peep.c +++ b/src/openrct2/peep/peep.c @@ -11278,7 +11278,7 @@ static bool peep_find_ride_to_look_at(rct_peep *peep, uint8 edge, uint8 *rideToV mapElement = surfaceElement; do { - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) continue; + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue; if (map_element_get_direction(mapElement) != edge) continue; if (get_wall_entry(mapElement->properties.fence.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) continue; if (peep->next_z + 4 <= mapElement->base_height) continue; @@ -11299,7 +11299,7 @@ static bool peep_find_ride_to_look_at(rct_peep *peep, uint8 edge, uint8 *rideToV mapElement = surfaceElement; do { - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) continue; + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue; if ((map_element_get_direction(mapElement) ^ 0x2) != edge) continue; if (get_wall_entry(mapElement->properties.fence.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) continue; // TODO: Check whether this shouldn't be <=, as the other loops use. If so, also extract as loop A. @@ -11347,7 +11347,7 @@ static bool peep_find_ride_to_look_at(rct_peep *peep, uint8 edge, uint8 *rideToV if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_SURFACE) continue; if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_PATH) continue; - if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_FENCE) { + if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_WALL) { if (get_wall_entry(mapElement->properties.fence.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) { continue; } @@ -11369,7 +11369,7 @@ static bool peep_find_ride_to_look_at(rct_peep *peep, uint8 edge, uint8 *rideToV // TODO: extract loop A mapElement = surfaceElement; do { - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) continue; + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue; if ((map_element_get_direction(mapElement) ^ 0x2) != edge) continue; if (get_wall_entry(mapElement->properties.fence.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) continue; if (peep->next_z + 6 <= mapElement->base_height) continue; @@ -11416,7 +11416,7 @@ static bool peep_find_ride_to_look_at(rct_peep *peep, uint8 edge, uint8 *rideToV if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_SURFACE) continue; if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_PATH) continue; - if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_FENCE) { + if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_WALL) { if (get_wall_entry(mapElement->properties.fence.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) { continue; } @@ -11437,7 +11437,7 @@ static bool peep_find_ride_to_look_at(rct_peep *peep, uint8 edge, uint8 *rideToV // TODO: extract loop A mapElement = surfaceElement; do { - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) continue; + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue; if ((map_element_get_direction(mapElement) ^ 0x2) != edge) continue; if (get_wall_entry(mapElement->properties.fence.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) continue; if (peep->next_z + 8 <= mapElement->base_height) continue; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 7b40ad16cb..cfd958af66 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -409,7 +409,7 @@ private: case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE: AddEntryForLargeScenery(mapElement->properties.scenerymultiple.type & MAP_ELEMENT_LARGE_TYPE_MASK); break; - case MAP_ELEMENT_TYPE_FENCE: + case MAP_ELEMENT_TYPE_WALL: { uint8 var_05 = mapElement->properties.fence.colour_3; uint16 var_06 = mapElement->properties.fence.colour_1 | @@ -2098,7 +2098,7 @@ private: break; } break; - case MAP_ELEMENT_TYPE_FENCE: + case MAP_ELEMENT_TYPE_WALL: colour = ((mapElement->type & 0xC0) >> 3) | ((mapElement->properties.fence.type & 0xE0) >> 5); colour = RCT1::GetColour(colour); @@ -2204,7 +2204,7 @@ private: rct_map_element * mapElement = map_get_first_element_at(x, y); do { - if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_FENCE) + if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_WALL) { rct_map_element originalMapElement = *mapElement; map_element_remove(mapElement); @@ -2227,7 +2227,7 @@ private: ConvertWall(&type, &colourA, &colourB, &colourC); type = _wallTypeToEntryMap[type]; - map_place_fence(type, x * 32, y * 32, 0, edge, colourA, colourB, colourC, 169); + wall_place(type, x * 32, y * 32, 0, edge, colourA, colourB, colourC, 169); } } break; diff --git a/src/openrct2/ride/ride.c b/src/openrct2/ride/ride.c index 4bf2218982..7c63f8ca2c 100644 --- a/src/openrct2/ride/ride.c +++ b/src/openrct2/ride/ride.c @@ -8268,7 +8268,7 @@ static money32 place_ride_entrance_or_exit(sint16 x, sint16 y, sint16 z, uint8 d !(flags & GAME_COMMAND_FLAG_GHOST) ) { footpath_remove_litter(x, y, z); - map_remove_walls_at_z(x, y, z); + wall_remove_at_z(x, y, z); } if (!gCheatsSandboxMode && !map_is_location_owned(x, y, z)) { diff --git a/src/openrct2/ride/track.c b/src/openrct2/ride/track.c index e67fdc6842..0a19357afa 100644 --- a/src/openrct2/ride/track.c +++ b/src/openrct2/ride/track.c @@ -1121,14 +1121,14 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 if ((flags & GAME_COMMAND_FLAG_APPLY) && !(flags & GAME_COMMAND_FLAG_GHOST) && !gCheatsDisableClearanceChecks) { footpath_remove_litter(x, y, z); if (rideTypeFlags & RIDE_TYPE_FLAG_TRACK_NO_WALLS) { - map_remove_walls_at(x, y, baseZ * 8, clearanceZ * 8); + wall_remove_at(x, y, baseZ * 8, clearanceZ * 8); } else { // Remove walls in the directions this track intersects uint8 intersectingDirections = (*wallEdges)[blockIndex]; intersectingDirections ^= 0x0F; for (sint32 i = 0; i < 4; i++) { if (intersectingDirections & (1 << i)) { - map_remove_intersecting_walls(x, y, baseZ, clearanceZ, i); + wall_remove_intersecting_walls(x, y, baseZ, clearanceZ, i); } } } @@ -1228,7 +1228,7 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 temp_x += TileDirectionDelta[temp_direction].x; temp_y += TileDirectionDelta[temp_direction].y; temp_direction ^= (1 << 1); - map_remove_intersecting_walls(temp_x, temp_y, baseZ, clearanceZ, temp_direction & 3); + wall_remove_intersecting_walls(temp_x, temp_y, baseZ, clearanceZ, temp_direction & 3); } } } @@ -1779,7 +1779,7 @@ static money32 set_maze_track(uint16 x, uint8 flags, uint8 direction, uint16 y, if ((flags & GAME_COMMAND_FLAG_APPLY) != 0) { if (!(flags & GAME_COMMAND_FLAG_GHOST) && !(flags & GAME_COMMAND_FLAG_2)) { footpath_remove_litter(x, y, z); - map_remove_walls_at(floor2(x, 32), floor2(y, 32), z, z + 32); + wall_remove_at(floor2(x, 32), floor2(y, 32), z, z + 32); } } diff --git a/src/openrct2/ride/track_design.c b/src/openrct2/ride/track_design.c index de368e5b78..cd6cb24e61 100644 --- a/src/openrct2/ride/track_design.c +++ b/src/openrct2/ride/track_design.c @@ -682,7 +682,7 @@ static sint32 track_design_place_scenery(rct_td6_scenery_element *scenery_start, 0x69, mapCoord.y, (z << 8) | ((rotation + scenery->flags) & 0x3), - GAME_COMMAND_REMOVE_FENCE, + GAME_COMMAND_REMOVE_WALL, 0, 0); break; @@ -819,7 +819,7 @@ static sint32 track_design_place_scenery(rct_td6_scenery_element *scenery_start, bl | (entry_index << 8), mapCoord.y, rotation | (scenery->primary_colour << 8), - GAME_COMMAND_PLACE_FENCE, + GAME_COMMAND_PLACE_WALL, z, scenery->secondary_colour | ((scenery->flags & 0xFC) << 6) ); @@ -1536,7 +1536,7 @@ static money32 place_maze_design(uint8 flags, uint8 rideIndex, uint16 mazeEntry, if (flags & GAME_COMMAND_FLAG_APPLY) { if (!(flags & GAME_COMMAND_FLAG_GHOST)) { footpath_remove_litter(x, y, z); - map_remove_walls_at(floor2(x, 32), floor2(y, 32), z, z + 32); + wall_remove_at(floor2(x, 32), floor2(y, 32), z, z + 32); } } diff --git a/src/openrct2/ride/track_design_save.c b/src/openrct2/ride/track_design_save.c index 8c6c37da2e..bf89c1c260 100644 --- a/src/openrct2/ride/track_design_save.c +++ b/src/openrct2/ride/track_design_save.c @@ -200,7 +200,7 @@ static sint32 map_element_get_total_element_count(rct_map_element *mapElement) switch (map_element_get_type(mapElement)) { case MAP_ELEMENT_TYPE_PATH: case MAP_ELEMENT_TYPE_SCENERY: - case MAP_ELEMENT_TYPE_FENCE: + case MAP_ELEMENT_TYPE_WALL: return 1; case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE: @@ -608,7 +608,7 @@ static void track_design_save_select_nearby_scenery_for_tile(sint32 rideIndex, s case MAP_ELEMENT_TYPE_SCENERY: interactionType = VIEWPORT_INTERACTION_ITEM_SCENERY; break; - case MAP_ELEMENT_TYPE_FENCE: + case MAP_ELEMENT_TYPE_WALL: interactionType = VIEWPORT_INTERACTION_ITEM_WALL; break; case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE: diff --git a/src/openrct2/ride/vehicle.c b/src/openrct2/ride/vehicle.c index 5366a94913..f9b46745c6 100644 --- a/src/openrct2/ride/vehicle.c +++ b/src/openrct2/ride/vehicle.c @@ -6847,7 +6847,7 @@ static void vehicle_update_scenery_door(rct_vehicle *vehicle) sint32 z = (vehicle->track_z - trackBlock->z + trackCoordinates->z_end) >> 3; sint32 direction = (vehicle->track_direction + trackCoordinates->rotation_end) & 3; - rct_map_element *mapElement = map_get_fence_element_at(x, y, z, direction); + rct_map_element *mapElement = map_get_wall_element_at(x, y, z, direction); if (mapElement == NULL) { return; } @@ -6930,7 +6930,7 @@ static void sub_6DEDE8(rct_vehicle *vehicle) sint32 direction = (vehicle->track_direction + trackCoordinates->rotation_begin) & 3; direction ^= 2; - rct_map_element *mapElement = map_get_fence_element_at(x, y, z, direction); + rct_map_element *mapElement = map_get_wall_element_at(x, y, z, direction); if (mapElement == NULL) { return; } diff --git a/src/openrct2/windows/editor_object_selection.c b/src/openrct2/windows/editor_object_selection.c index 932fdd8dd1..ae69898c33 100644 --- a/src/openrct2/windows/editor_object_selection.c +++ b/src/openrct2/windows/editor_object_selection.c @@ -596,7 +596,7 @@ static void setup_in_use_selection_flags() assert(type < object_entry_group_counts[OBJECT_TYPE_PATHS]); gEditorSelectedObjects[OBJECT_TYPE_PATHS][type] |= (1 << 0); break; - case MAP_ELEMENT_TYPE_FENCE: + case MAP_ELEMENT_TYPE_WALL: type = iter.element->properties.fence.type; assert(type < object_entry_group_counts[OBJECT_TYPE_WALLS]); gEditorSelectedObjects[OBJECT_TYPE_WALLS][type] |= (1 << 0); diff --git a/src/openrct2/windows/footpath.c b/src/openrct2/windows/footpath.c index 7a1aa047ad..06e7e02a0f 100644 --- a/src/openrct2/windows/footpath.c +++ b/src/openrct2/windows/footpath.c @@ -894,8 +894,8 @@ static void window_footpath_construct() if (cost != MONEY32_UNDEFINED && !gCheatsDisableClearanceChecks) { // It is possible, let's remove walls between the old and new piece of path uint8 direction = gFootpathConstructDirection; - map_remove_intersecting_walls(x, y, z, z + 4 + ((slope & 0xf) ? 2 : 0), direction ^ 2); - map_remove_intersecting_walls( + wall_remove_intersecting_walls(x, y, z, z + 4 + ((slope & 0xf) ? 2 : 0), direction ^ 2); + wall_remove_intersecting_walls( x - TileDirectionDelta[direction].x, y - TileDirectionDelta[direction].y, z, z + 4, direction diff --git a/src/openrct2/windows/map.c b/src/openrct2/windows/map.c index 68b6853559..eaedcd5a1f 100644 --- a/src/openrct2/windows/map.c +++ b/src/openrct2/windows/map.c @@ -1448,7 +1448,7 @@ static const uint16 ElementTypeMaskColour[] = { 0x00FF, // MAP_ELEMENT_TYPE_TRACK 0xFF00, // MAP_ELEMENT_TYPE_SCENERY 0x0000, // MAP_ELEMENT_TYPE_ENTRANCE - 0xFFFF, // MAP_ELEMENT_TYPE_FENCE + 0xFFFF, // MAP_ELEMENT_TYPE_WALL 0x0000, // MAP_ELEMENT_TYPE_SCENERY_MULTIPLE 0xFFFF, // MAP_ELEMENT_TYPE_BANNER 0x0000, // MAP_ELEMENT_TYPE_CORRUPT @@ -1460,7 +1460,7 @@ static const uint16 ElementTypeAddColour[] = { 0xB700, // MAP_ELEMENT_TYPE_TRACK 0x0063, // MAP_ELEMENT_TYPE_SCENERY 0xBABA, // MAP_ELEMENT_TYPE_ENTRANCE - 0x0000, // MAP_ELEMENT_TYPE_FENCE + 0x0000, // MAP_ELEMENT_TYPE_WALL 0x6363, // MAP_ELEMENT_TYPE_SCENERY_MULTIPLE 0x0000, // MAP_ELEMENT_TYPE_BANNER 0x4444, // MAP_ELEMENT_TYPE_CORRUPT diff --git a/src/openrct2/windows/sign.c b/src/openrct2/windows/sign.c index cc8277053b..41285eea88 100644 --- a/src/openrct2/windows/sign.c +++ b/src/openrct2/windows/sign.c @@ -434,7 +434,7 @@ void window_sign_small_open(rct_windownumber number){ rct_map_element* map_element = map_get_first_element_at(view_x / 32, view_y / 32); while (1){ - if (map_element_get_type(map_element) == MAP_ELEMENT_TYPE_FENCE) { + if (map_element_get_type(map_element) == MAP_ELEMENT_TYPE_WALL) { rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); if (scenery_entry->wall.scrolling_mode != 0xFF){ if (map_element->properties.fence.banner_index == w->number) @@ -496,7 +496,7 @@ static void window_sign_small_mouseup(rct_window *w, sint32 widgetIndex) break; case WIDX_SIGN_DEMOLISH: while (1){ - if (map_element_get_type(map_element) == MAP_ELEMENT_TYPE_FENCE) { + if (map_element_get_type(map_element) == MAP_ELEMENT_TYPE_WALL) { rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); if (scenery_entry->wall.scrolling_mode != 0xFF){ if (map_element->properties.fence.banner_index == w->number) @@ -511,7 +511,7 @@ static void window_sign_small_mouseup(rct_window *w, sint32 widgetIndex) 1 | ((map_element->type & 0x3) << 8), y, (map_element->base_height << 8) | (map_element->type & 0x3), - GAME_COMMAND_REMOVE_FENCE, + GAME_COMMAND_REMOVE_WALL, 0, 0); break; diff --git a/src/openrct2/windows/tile_inspector.c b/src/openrct2/windows/tile_inspector.c index 9a61f0b183..9593dcac33 100644 --- a/src/openrct2/windows/tile_inspector.c +++ b/src/openrct2/windows/tile_inspector.c @@ -1203,7 +1203,7 @@ static void window_tile_inspector_dropdown(rct_window *w, sint32 widgetIndex, si switch (w->page) { case TILE_INSPECTOR_PAGE_FENCE: - openrct2_assert(map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_FENCE, "Element is not a fence"); + openrct2_assert(map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_WALL, "Element is not a fence"); switch (widgetIndex) { case WIDX_FENCE_DROPDOWN_SLOPE_BUTTON: @@ -1994,7 +1994,7 @@ static void window_tile_inspector_scrollpaint(rct_window *w, rct_drawpixelinfo * case MAP_ELEMENT_TYPE_ENTRANCE: typeName = "Entrance"; break; - case MAP_ELEMENT_TYPE_FENCE: + case MAP_ELEMENT_TYPE_WALL: snprintf( buffer, sizeof(buffer), "Fence (%s)", diff --git a/src/openrct2/windows/top_toolbar.c b/src/openrct2/windows/top_toolbar.c index e5c9eaa87e..236aaf5e66 100644 --- a/src/openrct2/windows/top_toolbar.c +++ b/src/openrct2/windows/top_toolbar.c @@ -949,7 +949,7 @@ static void repaint_scenery_tool_down(sint16 x, sint16 y, sint16 widgetIndex){ 1 | (gWindowSceneryPrimaryColour << 8), grid_y, (map_element->type & MAP_ELEMENT_DIRECTION_MASK) | (map_element->base_height << 8), - GAME_COMMAND_SET_FENCE_COLOUR, + GAME_COMMAND_SET_WALL_COLOUR, 0, gWindowScenerySecondaryColour | (gWindowSceneryTertiaryColour << 8)); break; @@ -1573,7 +1573,7 @@ static void window_top_toolbar_scenery_tool_down(sint16 x, sint16 y, rct_window gDisableErrorWindowSound = true; gGameCommandErrorTitle = STR_CANT_BUILD_PARK_ENTRANCE_HERE; - sint32 cost = game_do_command(gridX, flags, gridY, parameter_2, GAME_COMMAND_PLACE_FENCE, gSceneryPlaceZ, _unkF64F15); + sint32 cost = game_do_command(gridX, flags, gridY, parameter_2, GAME_COMMAND_PLACE_WALL, gSceneryPlaceZ, _unkF64F15); gDisableErrorWindowSound = false; if (cost != MONEY32_UNDEFINED){ @@ -2182,7 +2182,7 @@ static money32 try_place_ghost_scenery(rct_xy16 map_tile, uint32 parameter_1, ui parameter_1 | 0x69, map_tile.y, parameter_2, - GAME_COMMAND_PLACE_FENCE, + GAME_COMMAND_PLACE_WALL, gSceneryPlaceZ, _unkF64F15); diff --git a/src/openrct2/world/footpath.c b/src/openrct2/world/footpath.c index 25395b1085..52c916b5ab 100644 --- a/src/openrct2/world/footpath.c +++ b/src/openrct2/world/footpath.c @@ -153,8 +153,8 @@ static void loc_6A6620(sint32 flags, sint32 x, sint32 y, rct_map_element *mapEle if ((mapElement->properties.path.type & 4) && !(flags & GAME_COMMAND_FLAG_GHOST)) { sint32 direction = mapElement->properties.path.type & 3; sint32 z = mapElement->base_height; - map_remove_intersecting_walls(x, y, z, z + 6, direction ^ 2); - map_remove_intersecting_walls(x, y, z, z + 6, direction); + wall_remove_intersecting_walls(x, y, z, z + 6, direction ^ 2); + wall_remove_intersecting_walls(x, y, z, z + 6, direction); mapElement = map_get_footpath_element(x / 32, y / 32, z); } @@ -852,7 +852,7 @@ bool fence_in_the_way(sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 direction if (mapElement == NULL) return false; do { - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue; if (mapElement->flags & MAP_ELEMENT_FLAG_GHOST) continue; diff --git a/src/openrct2/world/map.c b/src/openrct2/world/map.c index def3c3a25b..88cf186564 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -1391,14 +1391,14 @@ restart_from_beginning: goto restart_from_beginning; } break; - case MAP_ELEMENT_TYPE_FENCE: + case MAP_ELEMENT_TYPE_WALL: if (clear & (1 << 0)) { sint32 eax = x * 32; sint32 ebx = flags; sint32 ecx = y * 32; sint32 edx = (mapElement->base_height << 8) | (mapElement->type & MAP_ELEMENT_DIRECTION_MASK); sint32 edi = 0, ebp = 0; - cost = game_do_command(eax, ebx, ecx, edx, GAME_COMMAND_REMOVE_FENCE, edi, ebp); + cost = game_do_command(eax, ebx, ecx, edx, GAME_COMMAND_REMOVE_WALL, edi, ebp); if (cost == MONEY32_UNDEFINED) return MONEY32_UNDEFINED; @@ -1742,7 +1742,7 @@ static money32 map_set_land_height(sint32 flags, sint32 x, sint32 y, sint32 heig { footpath_remove_litter(x, y, map_element_height(x, y)); if(!gCheatsDisableClearanceChecks) - map_remove_walls_at(x, y, height * 8 - 16, height * 8 + 32); + wall_remove_at(x, y, height * 8 - 16, height * 8 + 32); } cost += MONEY(20, 0); @@ -1833,7 +1833,7 @@ static money32 map_set_land_height(sint32 flags, sint32 x, sint32 y, sint32 heig do { sint32 elementType = map_element_get_type(mapElement); - if (elementType == MAP_ELEMENT_TYPE_FENCE) + if (elementType == MAP_ELEMENT_TYPE_WALL) continue; if (elementType == MAP_ELEMENT_TYPE_SCENERY) continue; @@ -2703,7 +2703,7 @@ void game_command_set_water_height(sint32* eax, sint32* ebx, sint32* ecx, sint32 sint32 element_height = map_element_height(x, y); footpath_remove_litter(x, y, element_height); if(!gCheatsDisableClearanceChecks) - map_remove_walls_at_z(x, y, element_height); + wall_remove_at_z(x, y, element_height); } rct_map_element* map_element = map_get_surface_element_at(x / 32, y / 32); @@ -3023,7 +3023,7 @@ void game_command_place_scenery(sint32* eax, sint32* ebx, sint32* ecx, sint32* e if(flags & GAME_COMMAND_FLAG_APPLY && !(flags & GAME_COMMAND_FLAG_GHOST)){ footpath_remove_litter(x, y, targetHeight); if(!gCheatsDisableClearanceChecks && (scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG_ALLOW_WALLS)) { - map_remove_walls_at(x, y, targetHeight, targetHeight + scenery_entry->small_scenery.height); + wall_remove_at(x, y, targetHeight, targetHeight + scenery_entry->small_scenery.height); } } @@ -3341,7 +3341,7 @@ void game_command_place_large_scenery(sint32* eax, sint32* ebx, sint32* ecx, sin if (!(flags & GAME_COMMAND_FLAG_GHOST)) { footpath_remove_litter(curTile.x, curTile.y, zLow * 8); if (!gCheatsDisableClearanceChecks) { - map_remove_walls_at(curTile.x, curTile.y, zLow * 8, zHigh * 8); + wall_remove_at(curTile.x, curTile.y, zLow * 8, zHigh * 8); } } if (gGameCommandNestLevel == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) { @@ -3714,7 +3714,7 @@ void map_obstruction_set_error_text(rct_map_element *mapElement) break; } break; - case MAP_ELEMENT_TYPE_FENCE: + case MAP_ELEMENT_TYPE_WALL: sceneryEntry = get_wall_entry(mapElement->properties.scenery.type); errorStringId = STR_X_IN_THE_WAY; set_format_arg(0, rct_string_id, sceneryEntry->name); @@ -3935,7 +3935,7 @@ static void map_update_grass_length(sint32 x, sint32 y, rct_map_element *mapElem } } else { mapElementAbove++; - if (map_element_get_type(mapElementAbove) == MAP_ELEMENT_TYPE_FENCE) + if (map_element_get_type(mapElementAbove) == MAP_ELEMENT_TYPE_WALL) continue; if (z0 >= mapElementAbove->clearance_height) continue; @@ -4005,7 +4005,7 @@ sint32 map_element_get_banner_index(rct_map_element *mapElement) (mapElement->type & MAP_ELEMENT_QUADRANT_MASK) | ((mapElement->properties.scenerymultiple.colour[0] & 0xE0) >> 2) | ((mapElement->properties.scenerymultiple.colour[1] & 0xE0) >> 5); - case MAP_ELEMENT_TYPE_FENCE: + case MAP_ELEMENT_TYPE_WALL: sceneryEntry = get_wall_entry(mapElement->properties.fence.type); if (sceneryEntry->wall.scrolling_mode == 0xFF) return -1; @@ -4154,14 +4154,14 @@ static void clear_element_at(sint32 x, sint32 y, rct_map_element **elementPtr) case MAP_ELEMENT_TYPE_ENTRANCE: viewport_interaction_remove_park_entrance(element, x, y); break; - case MAP_ELEMENT_TYPE_FENCE: + case MAP_ELEMENT_TYPE_WALL: gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; game_do_command( x, GAME_COMMAND_FLAG_APPLY, y, (element->type & MAP_ELEMENT_DIRECTION_MASK) | (element->base_height << 8), - GAME_COMMAND_REMOVE_FENCE, + GAME_COMMAND_REMOVE_WALL, 0, 0 ); @@ -4552,7 +4552,7 @@ bool map_surface_is_blocked(sint16 x, sint16 y){ continue; if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_PATH || - map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_FENCE) + map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_WALL) continue; if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_SCENERY) @@ -4909,7 +4909,7 @@ void game_command_set_sign_style(sint32* eax, sint32* ebx, sint32* ecx, sint32* rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32); bool fence_found = false; do{ - if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_FENCE) + if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_WALL) continue; rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); @@ -5277,3 +5277,19 @@ void map_offset_with_rotation(sint16 *x, sint16 *y, sint16 offsetX, sint16 offse break; } } + +rct_map_element *map_get_wall_element_at(sint32 x, sint32 y, sint32 z, sint32 direction) +{ + rct_map_element *mapElement = map_get_first_element_at(x >> 5, y >> 5); + do { + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) + continue; + if (mapElement->base_height != z) + continue; + if (map_element_get_direction(mapElement) != direction) + continue; + + return mapElement; + } while (!map_element_is_last_for_tile(mapElement++)); + return NULL; +} diff --git a/src/openrct2/world/map.h b/src/openrct2/world/map.h index 158125b6b8..0c08764411 100644 --- a/src/openrct2/world/map.h +++ b/src/openrct2/world/map.h @@ -132,7 +132,7 @@ enum { MAP_ELEMENT_TYPE_TRACK = (2 << 2), MAP_ELEMENT_TYPE_SCENERY = (3 << 2), MAP_ELEMENT_TYPE_ENTRANCE = (4 << 2), - MAP_ELEMENT_TYPE_FENCE = (5 << 2), + MAP_ELEMENT_TYPE_WALL = (5 << 2), MAP_ELEMENT_TYPE_SCENERY_MULTIPLE = (6 << 2), MAP_ELEMENT_TYPE_BANNER = (7 << 2), // The corrupt element type is used for skipping drawing other following @@ -418,7 +418,7 @@ sint32 map_height_from_slope(sint32 x, sint32 y, sint32 slope); rct_map_element* map_get_banner_element_at(sint32 x, sint32 y, sint32 z, uint8 direction); rct_map_element *map_get_surface_element_at(sint32 x, sint32 y); rct_map_element* map_get_path_element_at(sint32 x, sint32 y, sint32 z); -rct_map_element *map_get_fence_element_at(sint32 x, sint32 y, sint32 z, sint32 direction); +rct_map_element *map_get_wall_element_at(sint32 x, sint32 y, sint32 z, sint32 direction); rct_map_element *map_get_small_scenery_element_at(sint32 x, sint32 y, sint32 z, sint32 type, uint8 quadrant); rct_map_element *map_get_park_entrance_element_at(sint32 x, sint32 y, sint32 z, bool ghost); sint32 map_element_height(sint32 x, sint32 y); @@ -451,7 +451,7 @@ rct_xy16 coordinate_3d_to_2d(const rct_xyz16* coordinate_3d, sint32 rotation); money32 map_clear_scenery(sint32 x0, sint32 y0, sint32 x1, sint32 y1, sint32 clear, sint32 flags); money32 lower_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags); money32 raise_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags); -money32 map_place_fence(sint32 type, sint32 x, sint32 y, sint32 z, sint32 edge, sint32 primaryColour, sint32 secondaryColour, sint32 tertiaryColour, sint32 flags); +money32 wall_place(sint32 type, sint32 x, sint32 y, sint32 z, sint32 edge, sint32 primaryColour, sint32 secondaryColour, sint32 tertiaryColour, sint32 flags); void game_command_set_land_height(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp); void game_command_set_land_ownership(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp); @@ -459,7 +459,7 @@ void game_command_remove_scenery(sint32* eax, sint32* ebx, sint32* ecx, sint32* void game_command_remove_large_scenery(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_remove_banner(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_set_scenery_colour(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); -void game_command_set_fence_colour(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); +void game_command_set_wall_colour(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_set_large_scenery_colour(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_set_banner_colour(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_clear_scenery(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); @@ -470,10 +470,10 @@ void game_command_smooth_land(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx void game_command_raise_water(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_lower_water(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_set_water_height(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); -void game_command_remove_fence(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); +void game_command_remove_wall(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_place_banner(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_place_scenery(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); -void game_command_place_fence(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); +void game_command_place_wall(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_place_large_scenery(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_place_park_entrance(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_set_banner_name(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); @@ -495,7 +495,7 @@ void map_element_iterator_begin(map_element_iterator *it); sint32 map_element_iterator_next(map_element_iterator *it); void map_element_iterator_restart_for_tile(map_element_iterator *it); -void map_remove_intersecting_walls(sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 direction); +void wall_remove_intersecting_walls(sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 direction); void map_update_tiles(); sint32 map_get_highest_z(sint32 tileX, sint32 tileY); @@ -508,8 +508,8 @@ void map_remove_out_of_range_elements(); void map_extend_boundary_surface(); bool sign_set_colour(sint32 x, sint32 y, sint32 z, sint32 direction, sint32 sequence, uint8 mainColour, uint8 textColour); -void map_remove_walls_at(sint32 x, sint32 y, sint32 z0, sint32 z1); -void map_remove_walls_at_z(sint32 x, sint32 y, sint32 z); +void wall_remove_at(sint32 x, sint32 y, sint32 z0, sint32 z1); +void wall_remove_at_z(sint32 x, sint32 y, sint32 z); void map_invalidate_tile(sint32 x, sint32 y, sint32 z0, sint32 z1); void map_invalidate_tile_zoom1(sint32 x, sint32 y, sint32 z0, sint32 z1); @@ -540,6 +540,6 @@ 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 fence_get_animation_frame(rct_map_element *fenceElement); +uint8 wall_get_animation_frame(rct_map_element *fenceElement); #endif diff --git a/src/openrct2/world/map_animation.c b/src/openrct2/world/map_animation.c index 917c4bd0cb..ff3e66e110 100644 --- a/src/openrct2/world/map_animation.c +++ b/src/openrct2/world/map_animation.c @@ -461,7 +461,7 @@ static bool map_animation_invalidate_wall_door(sint32 x, sint32 y, sint32 baseZ) do { if (mapElement->base_height != baseZ) continue; - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue; sceneryEntry = get_wall_entry(mapElement->properties.scenery.type); @@ -474,7 +474,7 @@ static bool map_animation_invalidate_wall_door(sint32 x, sint32 y, sint32 baseZ) bool invalidate = false; uint8 bl = mapElement->properties.fence.animation & 0x87; - uint8 currentFrame = fence_get_animation_frame(mapElement); + uint8 currentFrame = wall_get_animation_frame(mapElement); if (currentFrame != 0) { if (currentFrame == 15) { currentFrame = 0; @@ -515,7 +515,7 @@ static bool map_animation_invalidate_wall(sint32 x, sint32 y, sint32 baseZ) do { if (mapElement->base_height != baseZ) continue; - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue; sceneryEntry = get_wall_entry(mapElement->properties.scenery.type); diff --git a/src/openrct2/world/scenery.c b/src/openrct2/world/scenery.c index 86d7055b22..cdb926481b 100644 --- a/src/openrct2/world/scenery.c +++ b/src/openrct2/world/scenery.c @@ -210,7 +210,7 @@ void scenery_remove_ghost_tool_placement(){ 105 | (gSceneryMapElementType << 8), y, gSceneryGhostWallRotation |(z << 8), - GAME_COMMAND_REMOVE_FENCE, + GAME_COMMAND_REMOVE_WALL, 0, 0); } diff --git a/src/openrct2/world/tile_inspector.c b/src/openrct2/world/tile_inspector.c index f87e8f24fd..3201bd3e74 100644 --- a/src/openrct2/world/tile_inspector.c +++ b/src/openrct2/world/tile_inspector.c @@ -225,7 +225,7 @@ sint32 tile_inspector_rotate_element_at(sint32 x, sint32 y, sint32 elementIndex, case MAP_ELEMENT_TYPE_TRACK: case MAP_ELEMENT_TYPE_SCENERY: case MAP_ELEMENT_TYPE_ENTRANCE: - case MAP_ELEMENT_TYPE_FENCE: + case MAP_ELEMENT_TYPE_WALL: newRotation = (mapElement->type + 1) & MAP_ELEMENT_DIRECTION_MASK; mapElement->type &= ~MAP_ELEMENT_DIRECTION_MASK; mapElement->type |= newRotation; @@ -553,7 +553,7 @@ sint32 tile_inspector_fence_set_slope(sint32 x, sint32 y, sint32 elementIndex, s { rct_map_element *const fenceElement = map_get_nth_element_at(x, y, elementIndex); - if (!fenceElement || map_element_get_type(fenceElement) != MAP_ELEMENT_TYPE_FENCE) + if (!fenceElement || map_element_get_type(fenceElement) != MAP_ELEMENT_TYPE_WALL) { return MONEY32_UNDEFINED; } diff --git a/src/openrct2/world/wall.cpp b/src/openrct2/world/wall.cpp index 400239c775..6e463cb7f8 100644 --- a/src/openrct2/world/wall.cpp +++ b/src/openrct2/world/wall.cpp @@ -31,33 +31,548 @@ extern "C" static bool gWallAcrossTrack; +/** + * + * rct2: 0x006E5CBA + */ +static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge, rct_map_element *trackElement) +{ + const rct_preview_track *trackBlock; + sint32 z, direction; + + sint32 trackType = trackElement->properties.track.type; + sint32 sequence = trackElement->properties.track.sequence & 0x0F; + direction = (edge - trackElement->type) & 3; + rct_ride *ride = get_ride(trackElement->properties.track.ride_index); + + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) { + if (FlatRideTrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) { + if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) { + return true; + } + } + } else { + if (TrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) { + if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) { + return true; + } + } + } + + if (!(wall->wall.flags & WALL_SCENERY_IS_DOOR)) { + return false; + } + + if (!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_0)) { + return false; + } + + rct_ride_entry *rideEntry = get_ride_entry(ride->subtype); + if (rideEntry->flags & RIDE_ENTRY_FLAG_16) { + return false; + } + + gWallAcrossTrack = true; + if (z0 & 1) { + return false; + } + + if (sequence == 0) { + if (TrackSequenceProperties[trackType][0] & TRACK_SEQUENCE_FLAG_DISALLOW_DOORS) { + return false; + } + + if (TrackDefinitions[trackType].bank_start == 0) { + if (!(TrackCoordinates[trackType].rotation_begin & 4)) { + direction = (trackElement->type & 3) ^ 2; + if (direction == edge) { + trackBlock = &TrackBlocks[trackType][sequence]; + z = TrackCoordinates[trackType].z_begin; + z = trackElement->base_height + ((z - trackBlock->z) * 8); + if (z == z0) { + return true; + } + } + } + } + } + + trackBlock = &TrackBlocks[trackType][sequence + 1]; + if (trackBlock->index != 0xFF) { + return false; + } + + if (TrackDefinitions[trackType].bank_end != 0) { + return false; + } + + direction = TrackCoordinates[trackType].rotation_end; + if (direction & 4) { + return false; + } + + direction = (trackElement->type + direction) & 3; + if (direction != edge) { + return false; + } + + trackBlock = &TrackBlocks[trackType][sequence]; + z = TrackCoordinates[trackType].z_end; + z = trackElement->base_height + ((z - trackBlock->z) * 8); + if (z != z0) { + return false; + } + + return true; +} + +/** + * + * rct2: 0x006E5C1A + */ +static bool WallCheckObstruction(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge) +{ + sint32 entryType, sequence; + rct_scenery_entry *entry; + rct_large_scenery_tile *tile; + + gWallAcrossTrack = false; + gMapGroundFlags = ELEMENT_IS_ABOVE_GROUND; + if (map_is_location_at_edge(x, y)) { + gGameCommandErrorText = STR_OFF_EDGE_OF_MAP; + return false; + } + + rct_map_element *mapElement = map_get_first_element_at(x / 32, y / 32); + do { + sint32 elementType = map_element_get_type(mapElement); + if (elementType == MAP_ELEMENT_TYPE_SURFACE) continue; + if (z0 >= mapElement->clearance_height) continue; + if (z1 <= mapElement->base_height) continue; + if (elementType == MAP_ELEMENT_TYPE_WALL) { + sint32 direction = mapElement->type & 3; + if (edge == direction) { + map_obstruction_set_error_text(mapElement); + return false; + } + continue; + } + if ((mapElement->flags & 0x0F) == 0) continue; + + switch (elementType) { + case MAP_ELEMENT_TYPE_ENTRANCE: + map_obstruction_set_error_text(mapElement); + return false; + case MAP_ELEMENT_TYPE_PATH: + if (mapElement->properties.path.edges & (1 << edge)) { + map_obstruction_set_error_text(mapElement); + return false; + } + break; + case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE: + entryType = mapElement->properties.scenerymultiple.type & 0x3FF; + sequence = mapElement->properties.scenerymultiple.type >> 10; + entry = get_large_scenery_entry(entryType); + tile = &entry->large_scenery.tiles[sequence]; + { + sint32 direction = ((edge - mapElement->type) & 3) + 8; + if (!(tile->var_7 & (1 << direction))) { + map_obstruction_set_error_text(mapElement); + return false; + } + } + break; + case MAP_ELEMENT_TYPE_SCENERY: + entryType = mapElement->properties.scenery.type; + entry = get_small_scenery_entry(entryType); + if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_ALLOW_WALLS) { + map_obstruction_set_error_text(mapElement); + return false; + } + break; + case MAP_ELEMENT_TYPE_TRACK: + if (!WallCheckObstructionWithTrack(wall, x, y, z0, z1, edge, mapElement)) { + return false; + } + break; + } + } while (!map_element_is_last_for_tile(mapElement++)); + return true; +} + +enum +{ + EDGE_SLOPE_ELEVATED = (1 << 0), // 0x01 + EDGE_SLOPE_UPWARDS = (1 << 6), // 0x40 + EDGE_SLOPE_DOWNWARDS = (1 << 7), // 0x80 + + EDGE_SLOPE_UPWARDS_ELEVATED = EDGE_SLOPE_UPWARDS | EDGE_SLOPE_ELEVATED, + EDGE_SLOPE_DOWNWARDS_ELEVATED = EDGE_SLOPE_DOWNWARDS | EDGE_SLOPE_ELEVATED, +}; + +/** rct2: 0x009A3FEC */ +static const uint8 EdgeSlopes[][4] = { +// Top right Bottom right Bottom left Top left + { 0, 0, 0, 0 }, + { 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, 0 }, + { 0, 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS }, + { 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS }, + { EDGE_SLOPE_DOWNWARDS, 0, 0, EDGE_SLOPE_UPWARDS }, + { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, + { EDGE_SLOPE_DOWNWARDS, 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED }, + { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED }, + { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, 0, 0 }, + { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, 0 }, + { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS }, + { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS }, + { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, 0, EDGE_SLOPE_UPWARDS }, + { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, + { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED }, + { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS }, + { 0, 0, 0, 0 }, + { EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, + { EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED }, + { 0, 0, 0, 0 }, +}; + + + +money32 WallPlace(uint8 wall_type, sint16 x, sint16 y, sint16 z, uint8 edge, uint8 primary_colour, uint8 secondary_colour, uint8 tertiary_colour, uint8 flags) { + rct_xyz16 position = { + x, + y, + z + }; + + gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + gCommandPosition.x = position.x + 16; + gCommandPosition.y = position.y + 16; + gCommandPosition.z = position.z; + + if (position.z == 0){ + gCommandPosition.z = map_element_height(position.x, position.y) & 0xFFFF; + } + + if (game_is_paused() && !gCheatsBuildInPauseMode){ + gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; + return MONEY32_UNDEFINED; + } + + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && + !(flags & GAME_COMMAND_FLAG_7) && !gCheatsSandboxMode){ + + if (position.z == 0){ + if (!map_is_location_in_park(position.x, position.y)){ + return MONEY32_UNDEFINED; + } + } + else if (!map_is_location_owned(position.x, position.y, position.z)){ + return MONEY32_UNDEFINED; + } + } + + uint8 bp = 0; + if (position.z == 0){ + rct_map_element* map_element = map_get_surface_element_at(position.x / 32, position.y / 32); + if (map_element == NULL){ + return MONEY32_UNDEFINED; + } + position.z = map_element->base_height * 8; + + uint8 slope = map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK; + bp = EdgeSlopes[slope][edge & 3]; + if (bp & EDGE_SLOPE_ELEVATED) { + position.z += 16; + bp &= ~(1 << 0); + } + } + + rct_map_element* map_element = map_get_surface_element_at(position.x / 32, position.y / 32); + if (map_element == NULL){ + return MONEY32_UNDEFINED; + } + + if (map_element->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK){ + uint16 water_height = map_element->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK; + water_height *= 16; + + if (position.z < water_height){ + gGameCommandErrorText = STR_CANT_BUILD_THIS_UNDERWATER; + return MONEY32_UNDEFINED; + } + } + + if (position.z / 8 < map_element->base_height){ + gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; + return MONEY32_UNDEFINED; + } + + if (!(bp & 0xC0)){ + uint8 new_edge = (edge + 2) & 3; + uint8 new_base_height = map_element->base_height; + new_base_height += 2; + if (map_element->properties.surface.slope & (1 << new_edge)){ + if (position.z / 8 < new_base_height){ + gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; + return MONEY32_UNDEFINED; + } + + if (map_element->properties.surface.slope & (1 << 4)){ + new_edge = (new_edge - 1) & 3; + + if (map_element->properties.surface.slope & (1 << new_edge)){ + new_edge = (new_edge + 2) & 3; + if (map_element->properties.surface.slope & (1 << new_edge)){ + new_base_height += 2; + if (position.z / 8 < new_base_height){ + gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; + return MONEY32_UNDEFINED; + } + new_base_height -= 2; + } + } + } + } + + new_edge = (edge + 3) & 3; + if (map_element->properties.surface.slope & (1 << new_edge)){ + if (position.z / 8 < new_base_height){ + gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; + return MONEY32_UNDEFINED; + } + + if (map_element->properties.surface.slope & (1 << 4)){ + new_edge = (new_edge - 1) & 3; + + if (map_element->properties.surface.slope & (1 << new_edge)){ + new_edge = (new_edge + 2) & 3; + if (map_element->properties.surface.slope & (1 << new_edge)){ + new_base_height += 2; + if (position.z / 8 < new_base_height){ + gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; + return MONEY32_UNDEFINED; + } + } + } + } + } + } + sint32 banner_index = 0xFF; + rct_scenery_entry* wall_entry = get_wall_entry(wall_type); + // Have to check both -1 and NULL, as one can be a invalid object, + // while the other can be invalid index + if ((uintptr_t)wall_entry == (uintptr_t)-1 || wall_entry == NULL) { + return MONEY32_UNDEFINED; + } + if (wall_entry->wall.scrolling_mode != 0xFF){ + banner_index = create_new_banner(flags); + + if (banner_index == 0xFF){ + return MONEY32_UNDEFINED; + } + + rct_banner* banner = &gBanners[banner_index]; + if (flags & GAME_COMMAND_FLAG_APPLY){ + banner->flags |= (1 << 3); + banner->type = 0; + banner->x = position.x / 32; + banner->y = position.y / 32; + + sint32 rideIndex = banner_get_closest_ride_index(position.x, position.y, position.z); + if (rideIndex != -1) { + banner->colour = rideIndex & 0xFF; + banner->flags |= BANNER_FLAG_LINKED_TO_RIDE; + } + } + } + + uint8 clearanceHeight = position.z / 8; + if (bp & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS)) { + if (wall_entry->wall.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE){ + gGameCommandErrorText = STR_ERR_UNABLE_TO_BUILD_THIS_ON_SLOPE; + return MONEY32_UNDEFINED; + } + clearanceHeight += 2; + } + clearanceHeight += wall_entry->wall.height; + + if (!(flags & GAME_COMMAND_FLAG_7) && !gCheatsDisableClearanceChecks){ + if (!WallCheckObstruction(wall_entry, position.x, position.y, position.z / 8, clearanceHeight, edge)) { + return MONEY32_UNDEFINED; + } + } + + if (!map_check_free_elements_and_reorganise(1)){ + return MONEY32_UNDEFINED; + } + + if (flags & GAME_COMMAND_FLAG_APPLY){ + if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) { + rct_xyz16 coord; + coord.x = position.x + 16; + coord.y = position.y + 16; + coord.z = map_element_height(coord.x, coord.y); + network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); + } + + map_element = map_element_insert(position.x / 32, position.y / 32, position.z / 8, 0); + assert(map_element != NULL); + + map_animation_create(MAP_ANIMATION_TYPE_WALL, position.x, position.y, position.z / 8); + + map_element->clearance_height = clearanceHeight; + + map_element->type = bp | edge | MAP_ELEMENT_TYPE_WALL; + + map_element->properties.fence.colour_1 = primary_colour; + map_element->properties.fence.colour_1 |= (secondary_colour & 7) << 5; + map_element->flags |= (secondary_colour & 0x18) << 2; + + if (gWallAcrossTrack) { + map_element->properties.fence.animation |= (1 << 2); + } + + map_element->properties.fence.type = wall_type; + if (banner_index != 0xFF){ + map_element->properties.fence.banner_index = banner_index; + } + + if (wall_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ + map_element->properties.fence.colour_3 = tertiary_colour; + } + + if (flags & (1 << 6)){ + map_element->flags |= MAP_ELEMENT_FLAG_GHOST; + } + + gSceneryMapElement = map_element; + map_invalidate_tile_zoom1(position.x, position.y, map_element->base_height * 8, map_element->base_height * 8 + 72); + } + + if (gParkFlags & PARK_FLAGS_NO_MONEY){ + return 0; + } + else{ + return wall_entry->wall.price; + } +} + +money32 WallRemove(sint16 x, sint16 y, uint8 base_height, uint8 direction, uint8 flags) +{ + if (!map_is_location_valid(x, y)) { + return MONEY32_UNDEFINED; + } + + gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + if(!(flags & GAME_COMMAND_FLAG_GHOST) && game_is_paused() && !gCheatsBuildInPauseMode){ + gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; + return MONEY32_UNDEFINED; + } + if(!(flags & GAME_COMMAND_FLAG_GHOST) && !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && !map_is_location_owned(x, y, base_height * 8)){ + return MONEY32_UNDEFINED; + } + + bool sceneryFound = false; + rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32); + do { + if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_WALL) + continue; + if (map_element->base_height != base_height) + continue; + if ((map_element->type & MAP_ELEMENT_DIRECTION_MASK) != direction) + continue; + if ((flags & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST)) + continue; + + sceneryFound = true; + break; + } while (!map_element_is_last_for_tile(map_element++)); + + if (!(flags & GAME_COMMAND_FLAG_APPLY) || (sceneryFound == false)) { + return 0; + } + + if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) { + rct_xyz16 coord; + coord.x = x + 16; + coord.y = y + 16; + coord.z = map_element_height(coord.x, coord.y); + network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); + } + + map_element_remove_banner_entry(map_element); + map_invalidate_tile_zoom1(x, y, map_element->base_height * 8, (map_element->base_height * 8) + 72); + map_element_remove(map_element); + return 0; +} + +money32 WallSetColour(sint16 x, sint16 y, uint8 base_height, uint8 direction, uint8 primaryColour, uint8 secondaryColour, uint8 tertiaryColour, uint8 flags) +{ + gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + sint32 z = base_height * 8; + + gCommandPosition.x = x + 16; + gCommandPosition.y = y + 16; + gCommandPosition.z = z; + + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && + !map_is_location_in_park(x, y) && + !gCheatsSandboxMode) { + + return MONEY32_UNDEFINED; + } + + rct_map_element* map_element = map_get_wall_element_at(x, y, base_height, direction); + + if (map_element == NULL) { + return 0; + } + + if ((flags & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST)) { + return 0; + } + + if(flags & GAME_COMMAND_FLAG_APPLY){ + rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); + map_element->properties.fence.colour_1 &= 0xE0; + map_element->properties.fence.colour_1 |= primaryColour; + map_element->properties.fence.colour_1 &= 0x1F; + map_element->flags &= 0x9F; + map_element->properties.fence.colour_1 |= (secondaryColour & 0x7) * 32; + map_element->flags |= (secondaryColour & 0x18) * 4; + + if(scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ + map_element->properties.fence.colour_3 = tertiaryColour; + } + map_invalidate_tile_zoom1(x, y, z, z + 72); + } + + return 0; +} + extern "C" { - uint8 fence_get_animation_frame(rct_map_element *fenceElement) { - return (fenceElement->properties.fence.animation >> 3) & 0xF; - } - - rct_map_element *map_get_fence_element_at(sint32 x, sint32 y, sint32 z, sint32 direction) - { - rct_map_element *mapElement = map_get_first_element_at(x >> 5, y >> 5); - do { - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) - continue; - if (mapElement->base_height != z) - continue; - if (map_element_get_direction(mapElement) != direction) - continue; - - return mapElement; - } while (!map_element_is_last_for_tile(mapElement++)); - return NULL; + uint8 wall_get_animation_frame(rct_map_element *wallElement) { + return (wallElement->properties.fence.animation >> 3) & 0xF; } /** * * rct2: 0x006E588E */ - void map_remove_walls_at(sint32 x, sint32 y, sint32 z0, sint32 z1) + void wall_remove_at(sint32 x, sint32 y, sint32 z0, sint32 z1) { rct_map_element *mapElement; @@ -66,7 +581,7 @@ extern "C" repeat: mapElement = map_get_first_element_at(x >> 5, y >> 5); do { - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue; if (z0 >= mapElement->clearance_height) continue; @@ -84,22 +599,22 @@ extern "C" * * rct2: 0x006E57E6 */ - void map_remove_walls_at_z(sint32 x, sint32 y, sint32 z) + void wall_remove_at_z(sint32 x, sint32 y, sint32 z) { - map_remove_walls_at(x, y, z, z + 48); + wall_remove_at(x, y, z, z + 48); } /** * * rct2: 0x006E5935 */ - void map_remove_intersecting_walls(sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 direction) + void wall_remove_intersecting_walls(sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 direction) { rct_map_element *mapElement; mapElement = map_get_first_element_at(x >> 5, y >> 5); do { - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_FENCE) + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue; if (mapElement->clearance_height <= z0 || mapElement->base_height >= z1) @@ -114,471 +629,26 @@ extern "C" mapElement--; } while (!map_element_is_last_for_tile(mapElement++)); } - - /** - * - * rct2: 0x006E5CBA - */ - static bool map_place_fence_check_obstruction_with_track(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge, rct_map_element *trackElement) - { - const rct_preview_track *trackBlock; - sint32 z, direction; - - sint32 trackType = trackElement->properties.track.type; - sint32 sequence = trackElement->properties.track.sequence & 0x0F; - direction = (edge - trackElement->type) & 3; - rct_ride *ride = get_ride(trackElement->properties.track.ride_index); - - if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) { - if (FlatRideTrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) { - if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) { - return true; - } - } - } else { - if (TrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) { - if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) { - return true; - } - } - } - - if (!(wall->wall.flags & WALL_SCENERY_IS_DOOR)) { - return false; - } - - if (!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_0)) { - return false; - } - - rct_ride_entry *rideEntry = get_ride_entry(ride->subtype); - if (rideEntry->flags & RIDE_ENTRY_FLAG_16) { - return false; - } - - gWallAcrossTrack = true; - if (z0 & 1) { - return false; - } - - if (sequence == 0) { - if (TrackSequenceProperties[trackType][0] & TRACK_SEQUENCE_FLAG_DISALLOW_DOORS) { - return false; - } - - if (TrackDefinitions[trackType].bank_start == 0) { - if (!(TrackCoordinates[trackType].rotation_begin & 4)) { - direction = (trackElement->type & 3) ^ 2; - if (direction == edge) { - trackBlock = &TrackBlocks[trackType][sequence]; - z = TrackCoordinates[trackType].z_begin; - z = trackElement->base_height + ((z - trackBlock->z) * 8); - if (z == z0) { - return true; - } - } - } - } - } - - trackBlock = &TrackBlocks[trackType][sequence + 1]; - if (trackBlock->index != 0xFF) { - return false; - } - - if (TrackDefinitions[trackType].bank_end != 0) { - return false; - } - - direction = TrackCoordinates[trackType].rotation_end; - if (direction & 4) { - return false; - } - - direction = (trackElement->type + direction) & 3; - if (direction != edge) { - return false; - } - - trackBlock = &TrackBlocks[trackType][sequence]; - z = TrackCoordinates[trackType].z_end; - z = trackElement->base_height + ((z - trackBlock->z) * 8); - if (z != z0) { - return false; - } - - return true; - } - - /** - * - * rct2: 0x006E5C1A - */ - static bool map_place_fence_check_obstruction(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge) - { - sint32 entryType, sequence; - rct_scenery_entry *entry; - rct_large_scenery_tile *tile; - - gWallAcrossTrack = false; - gMapGroundFlags = ELEMENT_IS_ABOVE_GROUND; - if (map_is_location_at_edge(x, y)) { - gGameCommandErrorText = STR_OFF_EDGE_OF_MAP; - return false; - } - - rct_map_element *mapElement = map_get_first_element_at(x / 32, y / 32); - do { - sint32 elementType = map_element_get_type(mapElement); - if (elementType == MAP_ELEMENT_TYPE_SURFACE) continue; - if (z0 >= mapElement->clearance_height) continue; - if (z1 <= mapElement->base_height) continue; - if (elementType == MAP_ELEMENT_TYPE_FENCE) { - sint32 direction = mapElement->type & 3; - if (edge == direction) { - map_obstruction_set_error_text(mapElement); - return false; - } - continue; - } - if ((mapElement->flags & 0x0F) == 0) continue; - - switch (elementType) { - case MAP_ELEMENT_TYPE_ENTRANCE: - map_obstruction_set_error_text(mapElement); - return false; - case MAP_ELEMENT_TYPE_PATH: - if (mapElement->properties.path.edges & (1 << edge)) { - map_obstruction_set_error_text(mapElement); - return false; - } - break; - case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE: - entryType = mapElement->properties.scenerymultiple.type & 0x3FF; - sequence = mapElement->properties.scenerymultiple.type >> 10; - entry = get_large_scenery_entry(entryType); - tile = &entry->large_scenery.tiles[sequence]; - { - sint32 direction = ((edge - mapElement->type) & 3) + 8; - if (!(tile->var_7 & (1 << direction))) { - map_obstruction_set_error_text(mapElement); - return false; - } - } - break; - case MAP_ELEMENT_TYPE_SCENERY: - entryType = mapElement->properties.scenery.type; - entry = get_small_scenery_entry(entryType); - if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_ALLOW_WALLS) { - map_obstruction_set_error_text(mapElement); - return false; - } - break; - case MAP_ELEMENT_TYPE_TRACK: - if (!map_place_fence_check_obstruction_with_track(wall, x, y, z0, z1, edge, mapElement)) { - return false; - } - break; - } - } while (!map_element_is_last_for_tile(mapElement++)); - return true; - } - - enum - { - EDGE_SLOPE_ELEVATED = (1 << 0), // 0x01 - EDGE_SLOPE_UPWARDS = (1 << 6), // 0x40 - EDGE_SLOPE_DOWNWARDS = (1 << 7), // 0x80 - - EDGE_SLOPE_UPWARDS_ELEVATED = EDGE_SLOPE_UPWARDS | EDGE_SLOPE_ELEVATED, - EDGE_SLOPE_DOWNWARDS_ELEVATED = EDGE_SLOPE_DOWNWARDS | EDGE_SLOPE_ELEVATED, - }; - - /** rct2: 0x009A3FEC */ - static const uint8 EdgeSlopes[][4] = { - // Top right Bottom right Bottom left Top left - { 0, 0, 0, 0 }, - { 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, 0 }, - { 0, 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS }, - { 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS }, - { EDGE_SLOPE_DOWNWARDS, 0, 0, EDGE_SLOPE_UPWARDS }, - { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, - { EDGE_SLOPE_DOWNWARDS, 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED }, - { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED }, - { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, 0, 0 }, - { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, 0 }, - { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS }, - { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS }, - { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, 0, EDGE_SLOPE_UPWARDS }, - { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, - { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED }, - { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS }, - { 0, 0, 0, 0 }, - { EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, - { EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED }, - { 0, 0, 0, 0 }, - }; /** * * rct2: 0x006E519A */ - void game_command_place_fence(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp){ - rct_xyz16 position = { + void game_command_place_wall(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) { + *ebx = WallPlace( + (*ebx >> 8) & 0xFF, *eax & 0xFFFF, *ecx & 0xFFFF, - *edi & 0xFFFF - }; - - uint8 flags = *ebx & 0xFF; - uint8 fence_type = (*ebx >> 8) & 0xFF; - uint8 primary_colour = (*edx >> 8) & 0xFF; - uint8 secondary_colour = *ebp & 0xFF; - uint8 tertiary_colour = (*ebp >> 8) & 0xFF; - uint8 edge = *edx & 0xFF; - - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - gCommandPosition.x = position.x + 16; - gCommandPosition.y = position.y + 16; - gCommandPosition.z = position.z; - - if (position.z == 0){ - gCommandPosition.z = map_element_height(position.x, position.y) & 0xFFFF; - } - - if (game_is_paused() && !gCheatsBuildInPauseMode){ - gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; - *ebx = MONEY32_UNDEFINED; - return; - } - - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && - !(flags & GAME_COMMAND_FLAG_7) && !gCheatsSandboxMode){ - - if (position.z == 0){ - if (!map_is_location_in_park(position.x, position.y)){ - *ebx = MONEY32_UNDEFINED; - return; - } - } - else if (!map_is_location_owned(position.x, position.y, position.z)){ - *ebx = MONEY32_UNDEFINED; - return; - } - } - - uint8 bp = 0; - if (position.z == 0){ - rct_map_element* map_element = map_get_surface_element_at(position.x / 32, position.y / 32); - if (map_element == NULL){ - *ebx = MONEY32_UNDEFINED; - return; - } - position.z = map_element->base_height * 8; - - uint8 slope = map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK; - bp = EdgeSlopes[slope][edge & 3]; - if (bp & EDGE_SLOPE_ELEVATED) { - position.z += 16; - bp &= ~(1 << 0); - } - } - - rct_map_element* map_element = map_get_surface_element_at(position.x / 32, position.y / 32); - if (map_element == NULL){ - *ebx = MONEY32_UNDEFINED; - return; - } - - if (map_element->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK){ - uint16 water_height = map_element->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK; - water_height *= 16; - - if (position.z < water_height){ - gGameCommandErrorText = STR_CANT_BUILD_THIS_UNDERWATER; - *ebx = MONEY32_UNDEFINED; - return; - } - } - - if (position.z / 8 < map_element->base_height){ - gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; - *ebx = MONEY32_UNDEFINED; - return; - } - - if (!(bp & 0xC0)){ - uint8 new_edge = (edge + 2) & 3; - uint8 new_base_height = map_element->base_height; - new_base_height += 2; - if (map_element->properties.surface.slope & (1 << new_edge)){ - if (position.z / 8 < new_base_height){ - gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; - *ebx = MONEY32_UNDEFINED; - return; - } - - if (map_element->properties.surface.slope & (1 << 4)){ - new_edge = (new_edge - 1) & 3; - - if (map_element->properties.surface.slope & (1 << new_edge)){ - new_edge = (new_edge + 2) & 3; - if (map_element->properties.surface.slope & (1 << new_edge)){ - new_base_height += 2; - if (position.z / 8 < new_base_height){ - gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; - *ebx = MONEY32_UNDEFINED; - return; - } - new_base_height -= 2; - } - } - } - } - - new_edge = (edge + 3) & 3; - if (map_element->properties.surface.slope & (1 << new_edge)){ - if (position.z / 8 < new_base_height){ - gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; - *ebx = MONEY32_UNDEFINED; - return; - } - - if (map_element->properties.surface.slope & (1 << 4)){ - new_edge = (new_edge - 1) & 3; - - if (map_element->properties.surface.slope & (1 << new_edge)){ - new_edge = (new_edge + 2) & 3; - if (map_element->properties.surface.slope & (1 << new_edge)){ - new_base_height += 2; - if (position.z / 8 < new_base_height){ - gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; - *ebx = MONEY32_UNDEFINED; - return; - } - } - } - } - } - } - sint32 banner_index = 0xFF; - rct_scenery_entry* fence = get_wall_entry(fence_type); - // Have to check both -1 and NULL, as one can be a invalid object, - // while the other can be invalid index - if ((uintptr_t)fence == (uintptr_t)-1 || fence == NULL) { - *ebx = MONEY32_UNDEFINED; - return; - } - if (fence->wall.scrolling_mode != 0xFF){ - banner_index = create_new_banner(flags); - - if (banner_index == 0xFF){ - *ebx = MONEY32_UNDEFINED; - return; - } - - rct_banner* banner = &gBanners[banner_index]; - if (flags & GAME_COMMAND_FLAG_APPLY){ - banner->flags |= (1 << 3); - banner->type = 0; - banner->x = position.x / 32; - banner->y = position.y / 32; - - sint32 rideIndex = banner_get_closest_ride_index(position.x, position.y, position.z); - if (rideIndex != -1) { - banner->colour = rideIndex & 0xFF; - banner->flags |= BANNER_FLAG_LINKED_TO_RIDE; - } - } - } - - uint8 clearanceHeight = position.z / 8; - if (bp & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS)) { - if (fence->wall.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE){ - gGameCommandErrorText = STR_ERR_UNABLE_TO_BUILD_THIS_ON_SLOPE; - *ebx = MONEY32_UNDEFINED; - return; - } - clearanceHeight += 2; - } - clearanceHeight += fence->wall.height; - - if (!(flags & GAME_COMMAND_FLAG_7) && !gCheatsDisableClearanceChecks){ - if (!map_place_fence_check_obstruction(fence, position.x, position.y, position.z / 8, clearanceHeight, edge)) { - *ebx = MONEY32_UNDEFINED; - return; - } - } - - if (!map_check_free_elements_and_reorganise(1)){ - *ebx = MONEY32_UNDEFINED; - return; - } - - if (flags & GAME_COMMAND_FLAG_APPLY){ - if (gGameCommandNestLevel == 1 && !(*ebx & GAME_COMMAND_FLAG_GHOST)) { - rct_xyz16 coord; - coord.x = position.x + 16; - coord.y = position.y + 16; - coord.z = map_element_height(coord.x, coord.y); - network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); - } - - map_element = map_element_insert(position.x / 32, position.y / 32, position.z / 8, 0); - assert(map_element != NULL); - - map_animation_create(MAP_ANIMATION_TYPE_WALL, position.x, position.y, position.z / 8); - - map_element->clearance_height = clearanceHeight; - - map_element->type = bp | edge | MAP_ELEMENT_TYPE_FENCE; - - map_element->properties.fence.colour_1 = primary_colour; - map_element->properties.fence.colour_1 |= (secondary_colour & 7) << 5; - map_element->flags |= (secondary_colour & 0x18) << 2; - - if (gWallAcrossTrack) { - map_element->properties.fence.animation |= (1 << 2); - } - - map_element->properties.fence.type = fence_type; - if (banner_index != 0xFF){ - map_element->properties.fence.banner_index = banner_index; - } - - if (fence->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ - map_element->properties.fence.colour_3 = tertiary_colour; - } - - if (flags & (1 << 6)){ - map_element->flags |= MAP_ELEMENT_FLAG_GHOST; - } - - gSceneryMapElement = map_element; - map_invalidate_tile_zoom1(position.x, position.y, map_element->base_height * 8, map_element->base_height * 8 + 72); - } - - if (gParkFlags & PARK_FLAGS_NO_MONEY){ - *ebx = 0; - } - else{ - *ebx = fence->wall.price; - } + *edi & 0xFFFF, + *edx & 0xFF, + (*edx >> 8) & 0xFF, + *ebp & 0xFF, + (*ebp >> 8) & 0xFF, + *ebx & 0xFF + ); } - money32 map_place_fence( + money32 wall_place( sint32 type, sint32 x, sint32 y, sint32 z, sint32 edge, sint32 primaryColour, sint32 secondaryColour, sint32 tertiaryColour, sint32 flags ) { sint32 eax, ebx, ecx, edx, esi, edi, ebp; @@ -589,129 +659,40 @@ extern "C" edx = edge | (primaryColour << 8); edi = z; ebp = secondaryColour | (tertiaryColour << 8); - game_command_place_fence(&eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + game_command_place_wall(&eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); return ebx; } - /** * * rct2: 0x006E5597 */ - void game_command_remove_fence(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) + void game_command_remove_wall(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) { - sint32 x = *eax; - sint32 y = *ecx; - if (!map_is_location_valid(x, y)) { - *ebx = MONEY32_UNDEFINED; - return; - } - uint8 base_height = (*edx >> 8); - uint8 direction = *edx; - uint8 flags = *ebx & 0xFF; - - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - if(!(flags & GAME_COMMAND_FLAG_GHOST) && game_is_paused() && !gCheatsBuildInPauseMode){ - gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; - *ebx = MONEY32_UNDEFINED; - return; - } - if(!(flags & GAME_COMMAND_FLAG_GHOST) && !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && !map_is_location_owned(x, y, base_height * 8)){ - *ebx = MONEY32_UNDEFINED; - return; - } - - bool sceneryFound = false; - rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32); - do { - if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_FENCE) - continue; - if (map_element->base_height != base_height) - continue; - if ((map_element->type & MAP_ELEMENT_DIRECTION_MASK) != direction) - continue; - if ((flags & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST)) - continue; - - sceneryFound = true; - break; - } while (!map_element_is_last_for_tile(map_element++)); - - if (!(*ebx & GAME_COMMAND_FLAG_APPLY) || (sceneryFound == false)) { - *ebx = 0; - return; - } - - if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) { - rct_xyz16 coord; - coord.x = x + 16; - coord.y = y + 16; - coord.z = map_element_height(coord.x, coord.y); - network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); - } - - map_element_remove_banner_entry(map_element); - map_invalidate_tile_zoom1(x, y, map_element->base_height * 8, (map_element->base_height * 8) + 72); - map_element_remove(map_element); - *ebx = 0; + *ebx = WallRemove( + *eax & 0xFFFF, + *ecx & 0xFFFF, + (*edx >> 8) & 0xFF, + *edx & 0xFF, + *ebx & 0xFF + ); } /** * * rct2: 0x006E56B5 */ - void game_command_set_fence_colour(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) + void game_command_set_wall_colour(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) { - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - sint32 x = *eax; - sint32 y = *ecx; - uint8 map_element_direction = *edx; - uint8 base_height = *edx >> 8; - uint8 colour1 = *ebx >> 8; - uint8 colour2 = *ebp; - uint8 colour3 = *ebp >> 8; - uint8 flags = *ebx & 0xFF; - sint32 z = base_height * 8; - - gCommandPosition.x = x + 16; - gCommandPosition.y = y + 16; - gCommandPosition.z = z; - - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && - !map_is_location_in_park(x, y) && - !gCheatsSandboxMode) { - - *ebx = MONEY32_UNDEFINED; - return; - } - - rct_map_element* map_element = map_get_fence_element_at(x, y, base_height, map_element_direction); - - if (map_element == NULL) { - *ebx = 0; - return; - } - - if ((flags & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST)) { - *ebx = 0; - return; - } - - if(flags & GAME_COMMAND_FLAG_APPLY){ - rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); - map_element->properties.fence.colour_1 &= 0xE0; - map_element->properties.fence.colour_1 |= colour1; - map_element->properties.fence.colour_1 &= 0x1F; - map_element->flags &= 0x9F; - map_element->properties.fence.colour_1 |= (colour2 & 0x7) * 32; - map_element->flags |= (colour2 & 0x18) * 4; - - if(scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ - map_element->properties.fence.colour_3 = colour3; - } - map_invalidate_tile_zoom1(x, y, z, z + 72); - } - - *ebx = 0; + *ebx = WallSetColour( + *eax & 0xFFFF, + *ecx & 0xFFFF, + (*edx >> 8) & 0xFF, + *edx & 0xFF, + (*ebx >> 8) & 0xFF, + *ebp & 0xFF, + (*ebp >> 8) & 0xFF, + *ebx & 0xFF + ); } } From 810bf301f31afc8a3bd000db9e09829d3bd24172 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Mon, 20 Feb 2017 21:10:49 +0000 Subject: [PATCH 06/16] Rename map element fence to wall --- src/openrct2/interface/viewport_interaction.c | 4 +-- src/openrct2/paint/map_element/fence.c | 14 +++++----- src/openrct2/peep/peep.c | 12 ++++----- src/openrct2/rct1/S4Importer.cpp | 20 +++++++------- src/openrct2/ride/track_design_save.c | 16 ++++++------ src/openrct2/ride/vehicle.c | 20 +++++++------- .../windows/editor_object_selection.c | 2 +- src/openrct2/windows/sign.c | 14 +++++----- src/openrct2/windows/tile_inspector.c | 6 ++--- src/openrct2/windows/top_toolbar.c | 2 +- src/openrct2/world/map.c | 10 +++---- src/openrct2/world/map.h | 8 +++--- src/openrct2/world/map_animation.c | 4 +-- src/openrct2/world/wall.cpp | 26 +++++++++---------- 14 files changed, 79 insertions(+), 79 deletions(-) diff --git a/src/openrct2/interface/viewport_interaction.c b/src/openrct2/interface/viewport_interaction.c index b0bfc91a58..412fe50371 100644 --- a/src/openrct2/interface/viewport_interaction.c +++ b/src/openrct2/interface/viewport_interaction.c @@ -490,9 +490,9 @@ void viewport_interaction_remove_park_entrance(rct_map_element *mapElement, sint */ static void viewport_interaction_remove_park_wall(rct_map_element *mapElement, sint32 x, sint32 y) { - rct_scenery_entry *sceneryEntry = get_wall_entry(mapElement->properties.fence.type); + rct_scenery_entry *sceneryEntry = get_wall_entry(mapElement->properties.wall.type); if (sceneryEntry->wall.scrolling_mode != 0xFF){ - window_sign_small_open(mapElement->properties.fence.banner_index); + window_sign_small_open(mapElement->properties.wall.banner_index); } else { gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; game_do_command( diff --git a/src/openrct2/paint/map_element/fence.c b/src/openrct2/paint/map_element/fence.c index 96b158f2af..2514bbeb78 100644 --- a/src/openrct2/paint/map_element/fence.c +++ b/src/openrct2/paint/map_element/fence.c @@ -134,7 +134,7 @@ void fence_paint(uint8 direction, sint32 height, rct_map_element * map_element) { gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_WALL; - rct_scenery_entry * sceneryEntry = get_wall_entry(map_element->properties.fence.type); + rct_scenery_entry * sceneryEntry = get_wall_entry(map_element->properties.wall.type); if (sceneryEntry == NULL || sceneryEntry == (rct_scenery_entry *)-1) { return; } @@ -145,18 +145,18 @@ void fence_paint(uint8 direction, sint32 height, rct_map_element * map_element) } - sint32 primaryColour = map_element->properties.fence.colour_1 & 0x1F; + sint32 primaryColour = map_element->properties.wall.colour_1 & 0x1F; uint32 imageColourFlags = primaryColour << 19 | 0x20000000; uint32 dword_141F718 = imageColourFlags + 0x23800006; if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { - uint8 secondaryColour = (map_element->properties.fence.colour_1 >> 5) | ((map_element->flags & 0x60) >> 2); + uint8 secondaryColour = (map_element->properties.wall.colour_1 >> 5) | ((map_element->flags & 0x60) >> 2); imageColourFlags |= secondaryColour << 24 | 0x80000000; } uint32 tertiaryColour = 0; if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) { - tertiaryColour = map_element->properties.fence.colour_3; + tertiaryColour = map_element->properties.wall.colour_3; imageColourFlags &= 0x0DFFFFFFF; } @@ -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_get_animation_frame(map_element); // Add the direction as well - animationFrame |= (map_element->properties.fence.animation & 0x80) >> 3; + animationFrame |= (map_element->properties.wall.animation & 0x80) >> 3; uint32 imageId; switch (direction) { case 0: @@ -345,7 +345,7 @@ void fence_paint(uint8 direction, sint32 height, rct_map_element * map_element) set_format_arg(0, uint32, 0); set_format_arg(4, uint32, 0); - uint8 secondaryColour = map_element->properties.fence.colour_1 >> 5 | (map_element->flags & 0x60) >> 2; + uint8 secondaryColour = map_element->properties.wall.colour_1 >> 5 | (map_element->flags & 0x60) >> 2; if (dword_141F710 != 0) { secondaryColour = COLOUR_GREY; @@ -359,7 +359,7 @@ void fence_paint(uint8 direction, sint32 height, rct_map_element * map_element) uint16 scrollingMode = sceneryEntry->wall.scrolling_mode + ((direction + 1) & 0x3); - uint8 bannerIndex = map_element->properties.fence.banner_index; + uint8 bannerIndex = map_element->properties.wall.banner_index; rct_banner * banner = &gBanners[bannerIndex]; set_format_arg(0, rct_string_id, banner->string_idx); diff --git a/src/openrct2/peep/peep.c b/src/openrct2/peep/peep.c index c8c0b140aa..e40ae5ade4 100644 --- a/src/openrct2/peep/peep.c +++ b/src/openrct2/peep/peep.c @@ -11280,7 +11280,7 @@ static bool peep_find_ride_to_look_at(rct_peep *peep, uint8 edge, uint8 *rideToV do { if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue; if (map_element_get_direction(mapElement) != edge) continue; - if (get_wall_entry(mapElement->properties.fence.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) continue; + if (get_wall_entry(mapElement->properties.wall.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) continue; if (peep->next_z + 4 <= mapElement->base_height) continue; if (peep->next_z + 1 >= mapElement->clearance_height) continue; @@ -11301,7 +11301,7 @@ static bool peep_find_ride_to_look_at(rct_peep *peep, uint8 edge, uint8 *rideToV do { if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue; if ((map_element_get_direction(mapElement) ^ 0x2) != edge) continue; - if (get_wall_entry(mapElement->properties.fence.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) continue; + if (get_wall_entry(mapElement->properties.wall.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) continue; // TODO: Check whether this shouldn't be <=, as the other loops use. If so, also extract as loop A. if (peep->next_z + 4 >= mapElement->base_height) continue; if (peep->next_z + 1 >= mapElement->clearance_height) continue; @@ -11348,7 +11348,7 @@ static bool peep_find_ride_to_look_at(rct_peep *peep, uint8 edge, uint8 *rideToV if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_PATH) continue; if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_WALL) { - if (get_wall_entry(mapElement->properties.fence.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) { + if (get_wall_entry(mapElement->properties.wall.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) { continue; } } @@ -11371,7 +11371,7 @@ static bool peep_find_ride_to_look_at(rct_peep *peep, uint8 edge, uint8 *rideToV do { if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue; if ((map_element_get_direction(mapElement) ^ 0x2) != edge) continue; - if (get_wall_entry(mapElement->properties.fence.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) continue; + if (get_wall_entry(mapElement->properties.wall.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) continue; if (peep->next_z + 6 <= mapElement->base_height) continue; if (peep->next_z >= mapElement->clearance_height) continue; @@ -11417,7 +11417,7 @@ static bool peep_find_ride_to_look_at(rct_peep *peep, uint8 edge, uint8 *rideToV if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_PATH) continue; if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_WALL) { - if (get_wall_entry(mapElement->properties.fence.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) { + if (get_wall_entry(mapElement->properties.wall.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) { continue; } } @@ -11439,7 +11439,7 @@ static bool peep_find_ride_to_look_at(rct_peep *peep, uint8 edge, uint8 *rideToV do { if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue; if ((map_element_get_direction(mapElement) ^ 0x2) != edge) continue; - if (get_wall_entry(mapElement->properties.fence.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) continue; + if (get_wall_entry(mapElement->properties.wall.type)->wall.flags2 & WALL_SCENERY_2_FLAG4) continue; if (peep->next_z + 8 <= mapElement->base_height) continue; if (peep->next_z >= mapElement->clearance_height) continue; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index cfd958af66..46ef79ace8 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -411,9 +411,9 @@ private: break; case MAP_ELEMENT_TYPE_WALL: { - uint8 var_05 = mapElement->properties.fence.colour_3; - uint16 var_06 = mapElement->properties.fence.colour_1 | - (mapElement->properties.fence.animation << 8); + uint8 var_05 = mapElement->properties.wall.colour_3; + uint16 var_06 = mapElement->properties.wall.colour_1 | + (mapElement->properties.wall.animation << 8); for (sint32 edge = 0; edge < 4; edge++) { @@ -2100,13 +2100,13 @@ private: break; case MAP_ELEMENT_TYPE_WALL: colour = ((mapElement->type & 0xC0) >> 3) | - ((mapElement->properties.fence.type & 0xE0) >> 5); + ((mapElement->properties.wall.type & 0xE0) >> 5); colour = RCT1::GetColour(colour); mapElement->type &= 0x3F; - mapElement->properties.fence.type &= 0x1F; + mapElement->properties.wall.type &= 0x1F; mapElement->type |= (colour & 0x18) << 3; - mapElement->properties.fence.type |= (colour & 7) << 5; + mapElement->properties.wall.type |= (colour & 7) << 5; break; case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE: colour = RCT1::GetColour(mapElement->properties.scenerymultiple.colour[0] & 0x1F); @@ -2209,9 +2209,9 @@ private: rct_map_element originalMapElement = *mapElement; map_element_remove(mapElement); - uint8 var_05 = originalMapElement.properties.fence.colour_3; - uint16 var_06 = originalMapElement.properties.fence.colour_1 | - (originalMapElement.properties.fence.animation << 8); + uint8 var_05 = originalMapElement.properties.wall.colour_3; + uint16 var_06 = originalMapElement.properties.wall.colour_1 | + (originalMapElement.properties.wall.animation << 8); for (sint32 edge = 0; edge < 4; edge++) { @@ -2221,7 +2221,7 @@ private: { sint32 type = typeA | (typeB << 2); sint32 colourA = ((originalMapElement.type & 0xC0) >> 3) | - (originalMapElement.properties.fence.type >> 5); + (originalMapElement.properties.wall.type >> 5); sint32 colourB = 0; sint32 colourC = 0; ConvertWall(&type, &colourA, &colourB, &colourC); diff --git a/src/openrct2/ride/track_design_save.c b/src/openrct2/ride/track_design_save.c index bf89c1c260..2b14a4ac2d 100644 --- a/src/openrct2/ride/track_design_save.c +++ b/src/openrct2/ride/track_design_save.c @@ -332,15 +332,15 @@ static void track_design_save_add_large_scenery(sint32 x, sint32 y, rct_map_elem static void track_design_save_add_wall(sint32 x, sint32 y, rct_map_element *mapElement) { - sint32 entryType = mapElement->properties.fence.type; + sint32 entryType = mapElement->properties.wall.type; rct_object_entry *entry = (rct_object_entry*)&object_entry_groups[OBJECT_TYPE_WALLS].entries[entryType]; uint8 flags = 0; flags |= mapElement->type & 3; - flags |= mapElement->properties.fence.colour_3 << 2; + flags |= mapElement->properties.wall.colour_3 << 2; - uint8 secondaryColour = ((mapElement->flags & 0x60) >> 2) | (mapElement->properties.fence.colour_1 >> 5); - uint8 primaryColour = mapElement->properties.fence.colour_1 & 0x1F; + uint8 secondaryColour = ((mapElement->flags & 0x60) >> 2) | (mapElement->properties.wall.colour_1 >> 5); + uint8 primaryColour = mapElement->properties.wall.colour_1 & 0x1F; track_design_save_push_map_element(x, y, mapElement); track_design_save_push_map_element_desc(entry, x, y, mapElement->base_height, flags, primaryColour, secondaryColour); @@ -515,15 +515,15 @@ static void track_design_save_remove_large_scenery(sint32 x, sint32 y, rct_map_e static void track_design_save_remove_wall(sint32 x, sint32 y, rct_map_element *mapElement) { - sint32 entryType = mapElement->properties.fence.type; + sint32 entryType = mapElement->properties.wall.type; rct_object_entry *entry = (rct_object_entry*)&object_entry_groups[OBJECT_TYPE_WALLS].entries[entryType]; uint8 flags = 0; flags |= mapElement->type & 3; - flags |= mapElement->properties.fence.colour_3 << 2; + flags |= mapElement->properties.wall.colour_3 << 2; - uint8 secondaryColour = ((mapElement->flags & 0x60) >> 2) | (mapElement->properties.fence.colour_1 >> 5); - uint8 primaryColour = mapElement->properties.fence.colour_1 & 0x1F; + uint8 secondaryColour = ((mapElement->flags & 0x60) >> 2) | (mapElement->properties.wall.colour_1 >> 5); + uint8 primaryColour = mapElement->properties.wall.colour_1 & 0x1F; track_design_save_pop_map_element(x, y, mapElement); track_design_save_pop_map_element_desc(entry, x, y, mapElement->base_height, flags, primaryColour, secondaryColour); diff --git a/src/openrct2/ride/vehicle.c b/src/openrct2/ride/vehicle.c index f9b46745c6..7cd1a50c40 100644 --- a/src/openrct2/ride/vehicle.c +++ b/src/openrct2/ride/vehicle.c @@ -6804,7 +6804,7 @@ static void sub_6D63D4(rct_vehicle *vehicle) */ static void vehicle_play_scenery_door_open_sound(rct_vehicle *vehicle, rct_map_element *mapElement) { - rct_scenery_entry *wallEntry = get_wall_entry(mapElement->properties.fence.type); + rct_scenery_entry *wallEntry = get_wall_entry(mapElement->properties.wall.type); sint32 doorSoundType = (wallEntry->wall.flags2 >> 1) & 3; if (doorSoundType != 0) { sint32 soundId = DoorOpenSoundIds[doorSoundType - 1]; @@ -6820,7 +6820,7 @@ static void vehicle_play_scenery_door_open_sound(rct_vehicle *vehicle, rct_map_e */ static void vehicle_play_scenery_door_close_sound(rct_vehicle *vehicle, rct_map_element *mapElement) { - rct_scenery_entry *wallEntry = get_wall_entry(mapElement->properties.fence.type); + rct_scenery_entry *wallEntry = get_wall_entry(mapElement->properties.wall.type); sint32 doorSoundType = (wallEntry->wall.flags2 >> 1) & 3; if (doorSoundType != 0) { sint32 soundId = DoorCloseSoundIds[doorSoundType - 1]; @@ -6853,13 +6853,13 @@ static void vehicle_update_scenery_door(rct_vehicle *vehicle) } if (vehicle->next_vehicle_on_train != SPRITE_INDEX_NULL) { - mapElement->properties.fence.animation &= 7; - mapElement->properties.fence.animation |= 8; + mapElement->properties.wall.animation &= 7; + mapElement->properties.wall.animation |= 8; map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, x, y, z); vehicle_play_scenery_door_open_sound(vehicle, mapElement); } else { - mapElement->properties.fence.animation &= 7; - mapElement->properties.fence.animation |= 0x30; + mapElement->properties.wall.animation &= 7; + mapElement->properties.wall.animation |= 0x30; 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.fence.animation &= 7; - mapElement->properties.fence.animation |= 0x88; + mapElement->properties.wall.animation &= 7; + mapElement->properties.wall.animation |= 0x88; map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, x, y, z); vehicle_play_scenery_door_open_sound(vehicle, mapElement); } else { - mapElement->properties.fence.animation &= 7; - mapElement->properties.fence.animation |= 0xB0; + mapElement->properties.wall.animation &= 7; + mapElement->properties.wall.animation |= 0xB0; vehicle_play_scenery_door_close_sound(vehicle, mapElement); } } diff --git a/src/openrct2/windows/editor_object_selection.c b/src/openrct2/windows/editor_object_selection.c index ae69898c33..3a14fd76ff 100644 --- a/src/openrct2/windows/editor_object_selection.c +++ b/src/openrct2/windows/editor_object_selection.c @@ -597,7 +597,7 @@ static void setup_in_use_selection_flags() gEditorSelectedObjects[OBJECT_TYPE_PATHS][type] |= (1 << 0); break; case MAP_ELEMENT_TYPE_WALL: - type = iter.element->properties.fence.type; + type = iter.element->properties.wall.type; assert(type < object_entry_group_counts[OBJECT_TYPE_WALLS]); gEditorSelectedObjects[OBJECT_TYPE_WALLS][type] |= (1 << 0); break; diff --git a/src/openrct2/windows/sign.c b/src/openrct2/windows/sign.c index 41285eea88..dd5616fb6c 100644 --- a/src/openrct2/windows/sign.c +++ b/src/openrct2/windows/sign.c @@ -435,9 +435,9 @@ void window_sign_small_open(rct_windownumber number){ while (1){ if (map_element_get_type(map_element) == MAP_ELEMENT_TYPE_WALL) { - rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); + rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.wall.type); if (scenery_entry->wall.scrolling_mode != 0xFF){ - if (map_element->properties.fence.banner_index == w->number) + if (map_element->properties.wall.banner_index == w->number) break; } } @@ -447,10 +447,10 @@ void window_sign_small_open(rct_windownumber number){ sint32 view_z = map_element->base_height << 3; w->frame_no = view_z; - w->list_information_type = map_element->properties.fence.colour_1 & 0x1F; + w->list_information_type = map_element->properties.wall.colour_1 & 0x1F; w->var_492 = - ((map_element->properties.fence.colour_1 >> 5) | ((map_element->flags & 0x60) >> 2)); - w->var_48C = map_element->properties.fence.type; + ((map_element->properties.wall.colour_1 >> 5) | ((map_element->flags & 0x60) >> 2)); + w->var_48C = map_element->properties.wall.type; view_x += 16; view_y += 16; @@ -497,9 +497,9 @@ static void window_sign_small_mouseup(rct_window *w, sint32 widgetIndex) case WIDX_SIGN_DEMOLISH: while (1){ if (map_element_get_type(map_element) == MAP_ELEMENT_TYPE_WALL) { - rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); + rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.wall.type); if (scenery_entry->wall.scrolling_mode != 0xFF){ - if (map_element->properties.fence.banner_index == w->number) + if (map_element->properties.wall.banner_index == w->number) break; } } diff --git a/src/openrct2/windows/tile_inspector.c b/src/openrct2/windows/tile_inspector.c index 9593dcac33..8613b73403 100644 --- a/src/openrct2/windows/tile_inspector.c +++ b/src/openrct2/windows/tile_inspector.c @@ -1327,7 +1327,7 @@ void window_tile_inspector_auto_set_buttons(rct_window *w) switch (w->page) { case TILE_INSPECTOR_PAGE_FENCE: { const rct_map_element *const mapElement = window_tile_inspector_get_selected_element(w); - const uint8 fenceType = mapElement->properties.fence.type; + const uint8 fenceType = mapElement->properties.wall.type; const rct_wall_scenery_entry wallEntry = get_wall_entry(fenceType)->wall; const bool canBeSloped = !(wallEntry.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE); // Fence slope dropdown @@ -1834,13 +1834,13 @@ static void window_tile_inspector_paint(rct_window *w, rct_drawpixelinfo *dpi) case TILE_INSPECTOR_PAGE_FENCE: { // Details // Type - sint16 fenceType = mapElement->properties.fence.type; + sint16 fenceType = mapElement->properties.wall.type; gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_FENCE_TYPE, &fenceType, COLOUR_DARK_GREEN, x, y); // Banner info rct_wall_scenery_entry fenceEntry = get_wall_entry(fenceType)->wall; if (fenceEntry.flags & WALL_SCENERY_IS_BANNER) { - gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_ENTRY_BANNER_TEXT, &gBanners[mapElement->properties.fence.banner_index].string_idx, COLOUR_DARK_GREEN, x, y + 11); + gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_ENTRY_BANNER_TEXT, &gBanners[mapElement->properties.wall.banner_index].string_idx, COLOUR_DARK_GREEN, x, y + 11); } else { gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_ENTRY_BANNER_NONE, NULL, COLOUR_DARK_GREEN, x, y + 11); diff --git a/src/openrct2/windows/top_toolbar.c b/src/openrct2/windows/top_toolbar.c index 236aaf5e66..bc8810bcbe 100644 --- a/src/openrct2/windows/top_toolbar.c +++ b/src/openrct2/windows/top_toolbar.c @@ -935,7 +935,7 @@ static void repaint_scenery_tool_down(sint16 x, sint16 y, sint16 widgetIndex){ } case VIEWPORT_INTERACTION_ITEM_WALL: { - rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); + rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.wall.type); // If can't repaint if (!(scenery_entry->wall.flags & diff --git a/src/openrct2/world/map.c b/src/openrct2/world/map.c index 88cf186564..f9d837e555 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -4006,11 +4006,11 @@ sint32 map_element_get_banner_index(rct_map_element *mapElement) ((mapElement->properties.scenerymultiple.colour[0] & 0xE0) >> 2) | ((mapElement->properties.scenerymultiple.colour[1] & 0xE0) >> 5); case MAP_ELEMENT_TYPE_WALL: - sceneryEntry = get_wall_entry(mapElement->properties.fence.type); + sceneryEntry = get_wall_entry(mapElement->properties.wall.type); if (sceneryEntry->wall.scrolling_mode == 0xFF) return -1; - return mapElement->properties.fence.banner_index; + return mapElement->properties.wall.banner_index; case MAP_ELEMENT_TYPE_BANNER: return mapElement->properties.banner.index; default: @@ -4912,10 +4912,10 @@ void game_command_set_sign_style(sint32* eax, sint32* ebx, sint32* ecx, sint32* if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_WALL) continue; - rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); + rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.wall.type); if (scenery_entry->wall.scrolling_mode == 0xFF) continue; - if (map_element->properties.fence.banner_index != bannerId) + if (map_element->properties.wall.banner_index != bannerId) continue; fence_found = true; break; @@ -4932,7 +4932,7 @@ void game_command_set_sign_style(sint32* eax, sint32* ebx, sint32* ecx, sint32* } map_element->flags &= 0x9F; - map_element->properties.fence.colour_1 = + map_element->properties.wall.colour_1 = mainColour | ((textColour & 0x7) << 5); map_element->flags |= ((textColour & 0x18) << 2); diff --git a/src/openrct2/world/map.h b/src/openrct2/world/map.h index 0c08764411..549b319347 100644 --- a/src/openrct2/world/map.h +++ b/src/openrct2/world/map.h @@ -68,7 +68,7 @@ typedef struct rct_map_element_entrance_properties { } rct_map_element_entrance_properties; assert_struct_size(rct_map_element_entrance_properties, 4); -typedef struct rct_map_element_fence_properties { +typedef struct rct_map_element_wall_properties { uint8 type; //4 union { uint8 colour_3; //5 @@ -76,8 +76,8 @@ typedef struct rct_map_element_fence_properties { }; uint8 colour_1; //6 0b_2221_1111 2 = colour_2 (uses flags for rest of colour2), 1 = colour_1 uint8 animation; //7 0b_dfff_ft00 d = direction, f = frame num, t = across track flag (not used) -} rct_map_element_fence_properties; -assert_struct_size(rct_map_element_fence_properties, 4); +} rct_map_element_wall_properties; +assert_struct_size(rct_map_element_wall_properties, 4); typedef struct rct_map_element_scenerymultiple_properties { uint16 type; //4 @@ -99,7 +99,7 @@ typedef union { rct_map_element_track_properties track; rct_map_element_scenery_properties scenery; rct_map_element_entrance_properties entrance; - rct_map_element_fence_properties fence; + rct_map_element_wall_properties wall; rct_map_element_scenerymultiple_properties scenerymultiple; rct_map_element_banner_properties banner; } rct_map_element_properties; diff --git a/src/openrct2/world/map_animation.c b/src/openrct2/world/map_animation.c index ff3e66e110..a0017f03e8 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.fence.animation & 0x87; + uint8 bl = mapElement->properties.wall.animation & 0x87; uint8 currentFrame = wall_get_animation_frame(mapElement); if (currentFrame != 0) { if (currentFrame == 15) { @@ -491,7 +491,7 @@ static bool map_animation_invalidate_wall_door(sint32 x, sint32 y, sint32 baseZ) } bl |= currentFrame << 3; - mapElement->properties.fence.animation = bl; + mapElement->properties.wall.animation = bl; 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 6e463cb7f8..8150e9bc36 100644 --- a/src/openrct2/world/wall.cpp +++ b/src/openrct2/world/wall.cpp @@ -436,21 +436,21 @@ money32 WallPlace(uint8 wall_type, sint16 x, sint16 y, sint16 z, uint8 edge, uin map_element->type = bp | edge | MAP_ELEMENT_TYPE_WALL; - map_element->properties.fence.colour_1 = primary_colour; - map_element->properties.fence.colour_1 |= (secondary_colour & 7) << 5; + map_element->properties.wall.colour_1 = primary_colour; + map_element->properties.wall.colour_1 |= (secondary_colour & 7) << 5; map_element->flags |= (secondary_colour & 0x18) << 2; if (gWallAcrossTrack) { - map_element->properties.fence.animation |= (1 << 2); + map_element->properties.wall.animation |= (1 << 2); } - map_element->properties.fence.type = wall_type; + map_element->properties.wall.type = wall_type; if (banner_index != 0xFF){ - map_element->properties.fence.banner_index = banner_index; + map_element->properties.wall.banner_index = banner_index; } if (wall_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ - map_element->properties.fence.colour_3 = tertiary_colour; + map_element->properties.wall.colour_3 = tertiary_colour; } if (flags & (1 << 6)){ @@ -545,16 +545,16 @@ money32 WallSetColour(sint16 x, sint16 y, uint8 base_height, uint8 direction, ui } if(flags & GAME_COMMAND_FLAG_APPLY){ - rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.fence.type); - map_element->properties.fence.colour_1 &= 0xE0; - map_element->properties.fence.colour_1 |= primaryColour; - map_element->properties.fence.colour_1 &= 0x1F; + rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.wall.type); + map_element->properties.wall.colour_1 &= 0xE0; + map_element->properties.wall.colour_1 |= primaryColour; + map_element->properties.wall.colour_1 &= 0x1F; map_element->flags &= 0x9F; - map_element->properties.fence.colour_1 |= (secondaryColour & 0x7) * 32; + map_element->properties.wall.colour_1 |= (secondaryColour & 0x7) * 32; map_element->flags |= (secondaryColour & 0x18) * 4; if(scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ - map_element->properties.fence.colour_3 = tertiaryColour; + map_element->properties.wall.colour_3 = tertiaryColour; } map_invalidate_tile_zoom1(x, y, z, z + 72); } @@ -565,7 +565,7 @@ money32 WallSetColour(sint16 x, sint16 y, uint8 base_height, uint8 direction, ui extern "C" { uint8 wall_get_animation_frame(rct_map_element *wallElement) { - return (wallElement->properties.fence.animation >> 3) & 0xF; + return (wallElement->properties.wall.animation >> 3) & 0xF; } /** From 69af7239727c7be4a2271e91674aa881c4e27b88 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Tue, 21 Feb 2017 20:22:03 +0000 Subject: [PATCH 07/16] Remove more fences --- data/language/en-GB.txt | 4 +- src/openrct2/localisation/string_ids.h | 12 +-- src/openrct2/windows/tile_inspector.c | 134 ++++++++++++------------- src/openrct2/windows/tile_inspector.h | 2 +- src/openrct2/world/tile_inspector.c | 10 +- src/openrct2/world/tile_inspector.h | 6 +- 6 files changed, 84 insertions(+), 84 deletions(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index ff9e06b484..727f24441a 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -4237,7 +4237,7 @@ STR_5925 :Path details STR_5926 :Track details STR_5927 :Scenery details STR_5928 :Entrance details -STR_5929 :Fence details +STR_5929 :Wall details STR_5930 :Large scenery details STR_5931 :Banner details STR_5932 :Corrupt element details @@ -4287,7 +4287,7 @@ STR_5975 :Slope: STR_5976 :Flat STR_5977 :Right side up STR_5978 :Left side up -STR_5979 :{WINDOW_COLOUR_2}Fence type: {BLACK}{COMMA16} +STR_5979 :{WINDOW_COLOUR_2}Wall type: {BLACK}{COMMA16} STR_5980 :{WINDOW_COLOUR_2}Banner text: {BLACK}{STRINGID} STR_5981 :{WINDOW_COLOUR_2}Not a banner STR_5982 :{WINDOW_COLOUR_2}Large scenery type: {BLACK}{COMMA16} diff --git a/src/openrct2/localisation/string_ids.h b/src/openrct2/localisation/string_ids.h index 4452a11cff..29442b27f3 100644 --- a/src/openrct2/localisation/string_ids.h +++ b/src/openrct2/localisation/string_ids.h @@ -3577,7 +3577,7 @@ enum { STR_TILE_INSPECTOR_GROUPBOX_TRACK_INFO = 5926, STR_TILE_INSPECTOR_GROUPBOX_SCENERY_INFO = 5927, STR_TILE_INSPECTOR_GROUPBOX_ENTRANCE_INFO = 5928, - STR_TILE_INSPECTOR_GROUPBOX_FENCE_INFO = 5929, + STR_TILE_INSPECTOR_GROUPBOX_WALL_INFO = 5929, STR_TILE_INSPECTOR_GROUPBOX_LARGE_SCENERY_INFO = 5930, STR_TILE_INSPECTOR_GROUPBOX_BANNER_INFO = 5931, STR_TILE_INSPECTOR_GROUPBOX_CORRUPT_INFO = 5932, @@ -3623,11 +3623,11 @@ enum { STR_TILE_INSPECTOR_ENTRANCE_RIDE_ID = 5972, STR_TILE_INSPECTOR_CLAMP_TO_NEXT = 5973, STR_TILE_INSPECTOR_CLAMP_TO_NEXT_TIP = 5974, - STR_TILE_INSPECTOR_FENCE_SLOPE = 5975, - STR_TILE_INSPECTOR_FENCE_FLAT = 5976, - STR_TILE_INSPECTOR_FENCE_SLOPED_LEFT = 5977, - STR_TILE_INSPECTOR_FENCE_SLOPED_RIGHT = 5978, - STR_TILE_INSPECTOR_FENCE_TYPE = 5979, + STR_TILE_INSPECTOR_WALL_SLOPE = 5975, + STR_TILE_INSPECTOR_WALL_FLAT = 5976, + STR_TILE_INSPECTOR_WALL_SLOPED_LEFT = 5977, + STR_TILE_INSPECTOR_WALL_SLOPED_RIGHT = 5978, + STR_TILE_INSPECTOR_WALL_TYPE = 5979, STR_TILE_INSPECTOR_ENTRY_BANNER_TEXT = 5980, STR_TILE_INSPECTOR_ENTRY_BANNER_NONE = 5981, STR_TILE_INSPECTOR_LARGE_SCENERY_TYPE = 5982, diff --git a/src/openrct2/windows/tile_inspector.c b/src/openrct2/windows/tile_inspector.c index 8613b73403..fcbf1c34d0 100644 --- a/src/openrct2/windows/tile_inspector.c +++ b/src/openrct2/windows/tile_inspector.c @@ -70,10 +70,10 @@ static const rct_string_id ParkEntrancePartStringIds[] = { STR_TILE_INSPECTOR_ENTRANCE_RIGHT }; -static const rct_string_id FenceSlopeStringIds[] = { - STR_TILE_INSPECTOR_FENCE_FLAT, - STR_TILE_INSPECTOR_FENCE_SLOPED_LEFT, - STR_TILE_INSPECTOR_FENCE_SLOPED_RIGHT +static const rct_string_id WallSlopeStringIds[] = { + STR_TILE_INSPECTOR_WALL_FLAT, + STR_TILE_INSPECTOR_WALL_SLOPED_LEFT, + STR_TILE_INSPECTOR_WALL_SLOPED_RIGHT }; enum WINDOW_TILE_INSPECTOR_WIDGET_IDX { @@ -157,12 +157,12 @@ enum WINDOW_TILE_INSPECTOR_WIDGET_IDX { WIDX_ENTRANCE_SPINNER_HEIGHT_INCREASE, WIDX_ENTRANCE_SPINNER_HEIGHT_DECREASE, - // Fence - WIDX_FENCE_SPINNER_HEIGHT = PAGE_WIDGETS, - WIDX_FENCE_SPINNER_HEIGHT_INCREASE, - WIDX_FENCE_SPINNER_HEIGHT_DECREASE, - WIDX_FENCE_DROPDOWN_SLOPE, - WIDX_FENCE_DROPDOWN_SLOPE_BUTTON, + // Wall + WIDX_WALL_SPINNER_HEIGHT = PAGE_WIDGETS, + WIDX_WALL_SPINNER_HEIGHT_INCREASE, + WIDX_WALL_SPINNER_HEIGHT_DECREASE, + WIDX_WALL_DROPDOWN_SLOPE, + WIDX_WALL_DROPDOWN_SLOPE_BUTTON, // Large WIDX_LARGE_SCENERY_SPINNER_HEIGHT = PAGE_WIDGETS, @@ -356,17 +356,17 @@ static rct_widget EntranceWidgets[] = { { WIDGETS_END }, }; -#define FEN_GBPB PADDING_BOTTOM // Fence group box properties bottom -#define FEN_GBPT (FEN_GBPB + 16 + 2 * 21) // Fence group box properties top -#define FEN_GBDB (FEN_GBPT + GROUPBOX_PADDING) // Fence group box info bottom -#define FEN_GBDT (FEN_GBDB + 20 + 2 * 11) // Fence group box info top -static rct_widget FenceWidgets[] = { +#define WALL_GBPB PADDING_BOTTOM // Wall group box properties bottom +#define WALL_GBPT (WALL_GBPB + 16 + 2 * 21) // Wall group box properties top +#define WALL_GBDB (WALL_GBPT + GROUPBOX_PADDING) // Wall group box info bottom +#define WALL_GBDT (WALL_GBDB + 20 + 2 * 11) // Wall group box info top +static rct_widget WallWidgets[] = { MAIN_TILE_INSPECTOR_WIDGETS, - { WWT_SPINNER, 1, GBS(WH - FEN_GBPT, 1, 0), STR_NONE, STR_NONE }, // WIDX_FENCE_SPINNER_HEIGHT - { WWT_DROPDOWN_BUTTON, 1, GBSI(WH - FEN_GBPT, 1, 0), STR_NUMERIC_UP, STR_NONE }, // WIDX_FENCE_SPINNER_HEIGHT_INCREASE - { WWT_DROPDOWN_BUTTON, 1, GBSD(WH - FEN_GBPT, 1, 0), STR_NUMERIC_DOWN, STR_NONE }, // WIDX_FENCE_SPINNER_HEIGHT_DECREASE - { WWT_DROPDOWN, 1, GBS(WH - FEN_GBPT, 1, 1), STR_NONE, STR_NONE }, // WIDX_FENCE_DROPDOWN_SLOPE - { WWT_DROPDOWN_BUTTON, 1, GBDB(WH - FEN_GBPT, 1, 1), STR_DROPDOWN_GLYPH, STR_NONE }, // WIDX_FENCE_DROPDOWN_SLOPE_BUTTON + { WWT_SPINNER, 1, GBS(WH - WALL_GBPT, 1, 0), STR_NONE, STR_NONE }, // WIDX_WALL_SPINNER_HEIGHT + { WWT_DROPDOWN_BUTTON, 1, GBSI(WH - WALL_GBPT, 1, 0), STR_NUMERIC_UP, STR_NONE }, // WIDX_WALL_SPINNER_HEIGHT_INCREASE + { WWT_DROPDOWN_BUTTON, 1, GBSD(WH - WALL_GBPT, 1, 0), STR_NUMERIC_DOWN, STR_NONE }, // WIDX_WALL_SPINNER_HEIGHT_DECREASE + { WWT_DROPDOWN, 1, GBS(WH - WALL_GBPT, 1, 1), STR_NONE, STR_NONE }, // WIDX_WALL_DROPDOWN_SLOPE + { WWT_DROPDOWN_BUTTON, 1, GBDB(WH - WALL_GBPT, 1, 1), STR_DROPDOWN_GLYPH, STR_NONE }, // WIDX_WALL_DROPDOWN_SLOPE_BUTTON { WIDGETS_END }, }; @@ -419,7 +419,7 @@ static rct_widget *PageWidgets[] = { TrackWidgets, SceneryWidgets, EntranceWidgets, - FenceWidgets, + WallWidgets, LargeSceneryWidgets, BannerWidgets, CorruptWidgets, @@ -437,7 +437,7 @@ static struct { { TRA_GBDT, TRA_GBDB, TRA_GBPT, TRA_GBPB, STR_TILE_INSPECTOR_GROUPBOX_TRACK_INFO }, { SCE_GBDT, SCE_GBDB, SCE_GBPT, SCE_GBPB, STR_TILE_INSPECTOR_GROUPBOX_SCENERY_INFO }, { ENT_GBDT, ENT_GBDB, ENT_GBPT, ENT_GBPB, STR_TILE_INSPECTOR_GROUPBOX_ENTRANCE_INFO }, - { FEN_GBDT, FEN_GBDB, FEN_GBPT, FEN_GBPB, STR_TILE_INSPECTOR_GROUPBOX_FENCE_INFO }, + { WALL_GBDT, WALL_GBDB, WALL_GBPT, WALL_GBPB, STR_TILE_INSPECTOR_GROUPBOX_WALL_INFO }, { LAR_GBDT, LAR_GBDB, LAR_GBPT, LAR_GBPB, STR_TILE_INSPECTOR_GROUPBOX_LARGE_SCENERY_INFO }, { BAN_GBDT, BAN_GBDB, BAN_GBPT, BAN_GBPB, STR_TILE_INSPECTOR_GROUPBOX_BANNER_INFO }, { COR_GBDT, COR_GBDB, COR_GBPT, COR_GBPB, STR_TILE_INSPECTOR_GROUPBOX_CORRUPT_INFO } @@ -510,7 +510,7 @@ static uint64 PageEnabledWidgets[] = { (1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_ROTATE) | (1ULL << WIDX_BUTTON_COPY) | (1ULL << WIDX_TRACK_CHECK_APPLY_TO_ALL) | (1ULL << WIDX_TRACK_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_TRACK_SPINNER_HEIGHT_DECREASE) | (1ULL << WIDX_TRACK_CHECK_CHAIN_LIFT), (1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_ROTATE) | (1ULL << WIDX_BUTTON_COPY) | (1ULL << WIDX_SCENERY_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_SCENERY_SPINNER_HEIGHT_DECREASE) | (1ULL << WIDX_SCENERY_CHECK_QUARTER_N) | (1ULL << WIDX_SCENERY_CHECK_QUARTER_E) | (1ULL << WIDX_SCENERY_CHECK_QUARTER_S) | (1ULL << WIDX_SCENERY_CHECK_QUARTER_W) | (1ULL << WIDX_SCENERY_CHECK_COLLISION_N) | (1ULL << WIDX_SCENERY_CHECK_COLLISION_E) | (1ULL << WIDX_SCENERY_CHECK_COLLISION_S) | (1ULL << WIDX_SCENERY_CHECK_COLLISION_W), (1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_ROTATE) | (1ULL << WIDX_BUTTON_COPY) | (1ULL << WIDX_ENTRANCE_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_ENTRANCE_SPINNER_HEIGHT_DECREASE), - (1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_ROTATE) | (1ULL << WIDX_BUTTON_COPY) | (1ULL << WIDX_FENCE_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_FENCE_SPINNER_HEIGHT_DECREASE) | (1ULL << WIDX_FENCE_DROPDOWN_SLOPE) | (1ULL << WIDX_FENCE_DROPDOWN_SLOPE_BUTTON), + (1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_ROTATE) | (1ULL << WIDX_BUTTON_COPY) | (1ULL << WIDX_WALL_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_WALL_SPINNER_HEIGHT_DECREASE) | (1ULL << WIDX_WALL_DROPDOWN_SLOPE) | (1ULL << WIDX_WALL_DROPDOWN_SLOPE_BUTTON), (1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_COPY) | (1ULL << WIDX_LARGE_SCENERY_SPINNER_HEIGHT) | (1ULL << WIDX_LARGE_SCENERY_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_LARGE_SCENERY_SPINNER_HEIGHT_DECREASE), (1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_ROTATE) | (1ULL << WIDX_BUTTON_COPY) | (1ULL << WIDX_BANNER_SPINNER_HEIGHT) | (1ULL << WIDX_BANNER_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_BANNER_SPINNER_HEIGHT_DECREASE) | (1ULL << WIDX_BANNER_CHECK_BLOCK_NE) | (1ULL << WIDX_BANNER_CHECK_BLOCK_SE) | (1ULL << WIDX_BANNER_CHECK_BLOCK_SW) | (1ULL << WIDX_BANNER_CHECK_BLOCK_NW), (1ULL << WIDX_CLOSE) | (1ULL << WIDX_BUTTON_CORRUPT) | (1ULL << WIDX_BUTTON_REMOVE) | (1ULL << WIDX_BUTTON_COPY) | (1ULL << WIDX_CORRUPT_SPINNER_HEIGHT) | (1ULL << WIDX_CORRUPT_SPINNER_HEIGHT_INCREASE) | (1ULL << WIDX_CORRUPT_SPINNER_HEIGHT_DECREASE) | (1ULL << WIDX_CORRUPT_BUTTON_CLAMP), @@ -778,13 +778,13 @@ static void window_tile_inspector_path_toggle_edge(sint32 elementIndex, sint32 c ); } -static void window_tile_inspector_fence_set_slope(sint32 elementIndex, sint32 slopeValue) +static void window_tile_inspector_wall_set_slope(sint32 elementIndex, sint32 slopeValue) { // Make sure only the correct bits are set openrct2_assert((slopeValue & 0xC0) == slopeValue, "slopeValue doesn't match its mask"); game_do_command( - TILE_INSPECTOR_FENCE_SET_SLOPE, + TILE_INSPECTOR_WALL_SET_SLOPE, GAME_COMMAND_FLAG_APPLY, windowTileInspectorTileX | (windowTileInspectorTileY << 8), elementIndex, @@ -1075,12 +1075,12 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex) } // switch widget index break; - case TILE_INSPECTOR_PAGE_FENCE: + case TILE_INSPECTOR_PAGE_WALL: switch (widgetIndex) { - case WIDX_FENCE_SPINNER_HEIGHT_INCREASE: + case WIDX_WALL_SPINNER_HEIGHT_INCREASE: window_tile_inspector_base_height_offset(w->selected_list_item, 1); break; - case WIDX_FENCE_SPINNER_HEIGHT_DECREASE: + case WIDX_WALL_SPINNER_HEIGHT_DECREASE: window_tile_inspector_base_height_offset(w->selected_list_item, -1); break; } // switch widget index @@ -1147,9 +1147,9 @@ static void window_tile_inspector_resize(rct_window *w) static void window_tile_inspector_mousedown(sint32 widgetIndex, rct_window *w, rct_widget* widget) { switch (w->page) { - case TILE_INSPECTOR_PAGE_FENCE: + case TILE_INSPECTOR_PAGE_WALL: switch (widgetIndex) { - case WIDX_FENCE_DROPDOWN_SLOPE_BUTTON: + case WIDX_WALL_DROPDOWN_SLOPE_BUTTON: // Use dropdown instead of dropdown button widget--; @@ -1157,9 +1157,9 @@ static void window_tile_inspector_mousedown(sint32 widgetIndex, rct_window *w, r gDropdownItemsFormat[0] = STR_DROPDOWN_MENU_LABEL; gDropdownItemsFormat[1] = STR_DROPDOWN_MENU_LABEL; gDropdownItemsFormat[2] = STR_DROPDOWN_MENU_LABEL; - gDropdownItemsArgs[0] = STR_TILE_INSPECTOR_FENCE_FLAT; - gDropdownItemsArgs[1] = STR_TILE_INSPECTOR_FENCE_SLOPED_LEFT; - gDropdownItemsArgs[2] = STR_TILE_INSPECTOR_FENCE_SLOPED_RIGHT; + gDropdownItemsArgs[0] = STR_TILE_INSPECTOR_WALL_FLAT; + gDropdownItemsArgs[1] = STR_TILE_INSPECTOR_WALL_SLOPED_LEFT; + gDropdownItemsArgs[2] = STR_TILE_INSPECTOR_WALL_SLOPED_RIGHT; window_dropdown_show_text_custom_width( w->x + widget->left, w->y + widget->top, @@ -1202,12 +1202,12 @@ static void window_tile_inspector_dropdown(rct_window *w, sint32 widgetIndex, si rct_map_element *const mapElement = window_tile_inspector_get_selected_element(w); switch (w->page) { - case TILE_INSPECTOR_PAGE_FENCE: - openrct2_assert(map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_WALL, "Element is not a fence"); + case TILE_INSPECTOR_PAGE_WALL: + openrct2_assert(map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_WALL, "Element is not a wall"); switch (widgetIndex) { - case WIDX_FENCE_DROPDOWN_SLOPE_BUTTON: - window_tile_inspector_fence_set_slope(w->selected_list_item, dropdownIndex << 6); + case WIDX_WALL_DROPDOWN_SLOPE_BUTTON: + window_tile_inspector_wall_set_slope(w->selected_list_item, dropdownIndex << 6); break; } break; @@ -1325,16 +1325,16 @@ void window_tile_inspector_auto_set_buttons(rct_window *w) // Page widgets switch (w->page) { - case TILE_INSPECTOR_PAGE_FENCE: { + case TILE_INSPECTOR_PAGE_WALL: { const rct_map_element *const mapElement = window_tile_inspector_get_selected_element(w); - const uint8 fenceType = mapElement->properties.wall.type; - const rct_wall_scenery_entry wallEntry = get_wall_entry(fenceType)->wall; + const uint8 wallType = mapElement->properties.wall.type; + const rct_wall_scenery_entry wallEntry = get_wall_entry(wallType)->wall; const bool canBeSloped = !(wallEntry.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE); - // Fence slope dropdown - widget_set_enabled(w, WIDX_FENCE_DROPDOWN_SLOPE, canBeSloped); - widget_invalidate(w, WIDX_FENCE_DROPDOWN_SLOPE); - widget_set_enabled(w, WIDX_FENCE_DROPDOWN_SLOPE_BUTTON, canBeSloped); - widget_invalidate(w, WIDX_FENCE_DROPDOWN_SLOPE_BUTTON); + // Wall slope dropdown + widget_set_enabled(w, WIDX_WALL_DROPDOWN_SLOPE, canBeSloped); + widget_invalidate(w, WIDX_WALL_DROPDOWN_SLOPE); + widget_set_enabled(w, WIDX_WALL_DROPDOWN_SLOPE_BUTTON, canBeSloped); + widget_invalidate(w, WIDX_WALL_DROPDOWN_SLOPE_BUTTON); break; } } // switch page @@ -1539,18 +1539,18 @@ static void window_tile_inspector_invalidate(rct_window *w) w->widgets[WIDX_ENTRANCE_SPINNER_HEIGHT_DECREASE].top = GBBB(propertiesAnchor, 0) - 8; w->widgets[WIDX_ENTRANCE_SPINNER_HEIGHT_DECREASE].bottom = GBBB(propertiesAnchor, 0) - 4; break; - case TILE_INSPECTOR_PAGE_FENCE: - w->widgets[WIDX_FENCE_SPINNER_HEIGHT].top = GBBT(propertiesAnchor, 0) + 3; - w->widgets[WIDX_FENCE_SPINNER_HEIGHT].bottom = GBBB(propertiesAnchor, 0) - 3; - w->widgets[WIDX_FENCE_SPINNER_HEIGHT_INCREASE].top = GBBT(propertiesAnchor, 0) + 4; - w->widgets[WIDX_FENCE_SPINNER_HEIGHT_INCREASE].bottom = GBBT(propertiesAnchor, 0) + 8; - w->widgets[WIDX_FENCE_SPINNER_HEIGHT_DECREASE].top = GBBB(propertiesAnchor, 0) - 8; - w->widgets[WIDX_FENCE_SPINNER_HEIGHT_DECREASE].bottom = GBBB(propertiesAnchor, 0) - 4; - w->widgets[WIDX_FENCE_DROPDOWN_SLOPE].top = GBBT(propertiesAnchor, 1) + 3; - w->widgets[WIDX_FENCE_DROPDOWN_SLOPE].bottom = GBBB(propertiesAnchor, 1) - 3; - w->widgets[WIDX_FENCE_DROPDOWN_SLOPE].text = FenceSlopeStringIds[(mapElement->type & 0xC0) >> 6]; - w->widgets[WIDX_FENCE_DROPDOWN_SLOPE_BUTTON].top = GBBT(propertiesAnchor, 1) + 4; - w->widgets[WIDX_FENCE_DROPDOWN_SLOPE_BUTTON].bottom = GBBB(propertiesAnchor, 1) - 4; + case TILE_INSPECTOR_PAGE_WALL: + w->widgets[WIDX_WALL_SPINNER_HEIGHT].top = GBBT(propertiesAnchor, 0) + 3; + w->widgets[WIDX_WALL_SPINNER_HEIGHT].bottom = GBBB(propertiesAnchor, 0) - 3; + w->widgets[WIDX_WALL_SPINNER_HEIGHT_INCREASE].top = GBBT(propertiesAnchor, 0) + 4; + w->widgets[WIDX_WALL_SPINNER_HEIGHT_INCREASE].bottom = GBBT(propertiesAnchor, 0) + 8; + w->widgets[WIDX_WALL_SPINNER_HEIGHT_DECREASE].top = GBBB(propertiesAnchor, 0) - 8; + w->widgets[WIDX_WALL_SPINNER_HEIGHT_DECREASE].bottom = GBBB(propertiesAnchor, 0) - 4; + w->widgets[WIDX_WALL_DROPDOWN_SLOPE].top = GBBT(propertiesAnchor, 1) + 3; + w->widgets[WIDX_WALL_DROPDOWN_SLOPE].bottom = GBBB(propertiesAnchor, 1) - 3; + w->widgets[WIDX_WALL_DROPDOWN_SLOPE].text = WallSlopeStringIds[(mapElement->type & 0xC0) >> 6]; + w->widgets[WIDX_WALL_DROPDOWN_SLOPE_BUTTON].top = GBBT(propertiesAnchor, 1) + 4; + w->widgets[WIDX_WALL_DROPDOWN_SLOPE_BUTTON].bottom = GBBB(propertiesAnchor, 1) - 4; break; case TILE_INSPECTOR_PAGE_LARGE_SCENERY: w->widgets[WIDX_LARGE_SCENERY_SPINNER_HEIGHT].top = GBBT(propertiesAnchor, 0) + 3; @@ -1831,15 +1831,15 @@ static void window_tile_inspector_paint(rct_window *w, rct_drawpixelinfo *dpi) break; } - case TILE_INSPECTOR_PAGE_FENCE: { + case TILE_INSPECTOR_PAGE_WALL: { // Details // Type - sint16 fenceType = mapElement->properties.wall.type; - gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_FENCE_TYPE, &fenceType, COLOUR_DARK_GREEN, x, y); + sint16 wallType = mapElement->properties.wall.type; + gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_WALL_TYPE, &wallType, COLOUR_DARK_GREEN, x, y); // Banner info - rct_wall_scenery_entry fenceEntry = get_wall_entry(fenceType)->wall; - if (fenceEntry.flags & WALL_SCENERY_IS_BANNER) { + rct_wall_scenery_entry wallEntry = get_wall_entry(wallType)->wall; + if (wallEntry.flags & WALL_SCENERY_IS_BANNER) { gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_ENTRY_BANNER_TEXT, &gBanners[mapElement->properties.wall.banner_index].string_idx, COLOUR_DARK_GREEN, x, y + 11); } else { @@ -1848,18 +1848,18 @@ static void window_tile_inspector_paint(rct_window *w, rct_drawpixelinfo *dpi) // Properties // Raise / lower label - y = w->y + w->widgets[WIDX_FENCE_SPINNER_HEIGHT].top; + y = w->y + w->widgets[WIDX_WALL_SPINNER_HEIGHT].top; gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_BASE_HEIGHT_FULL, NULL, COLOUR_DARK_GREEN, x, y); // Current base height - x = w->x + w->widgets[WIDX_FENCE_SPINNER_HEIGHT].left + 3; + x = w->x + w->widgets[WIDX_WALL_SPINNER_HEIGHT].left + 3; sint32 baseHeight = mapElement->base_height; gfx_draw_string_left(dpi, STR_FORMAT_INTEGER, &baseHeight, COLOUR_DARK_GREEN, x, y); // Slope label x = w->x + w->widgets[WIDX_GROUPBOX_DETAILS].left + 7; - y = w->y + w->widgets[WIDX_FENCE_DROPDOWN_SLOPE].top; - gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_FENCE_SLOPE, NULL, COLOUR_DARK_GREEN, x, y); + y = w->y + w->widgets[WIDX_WALL_DROPDOWN_SLOPE].top; + gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_WALL_SLOPE, NULL, COLOUR_DARK_GREEN, x, y); break; } @@ -1997,7 +1997,7 @@ static void window_tile_inspector_scrollpaint(rct_window *w, rct_drawpixelinfo * case MAP_ELEMENT_TYPE_WALL: snprintf( buffer, sizeof(buffer), - "Fence (%s)", + "Wall (%s)", language_get_string(get_wall_entry(mapElement->properties.scenery.type)->name) ); typeName = buffer; diff --git a/src/openrct2/windows/tile_inspector.h b/src/openrct2/windows/tile_inspector.h index fe96e219f8..a375e65add 100644 --- a/src/openrct2/windows/tile_inspector.h +++ b/src/openrct2/windows/tile_inspector.h @@ -27,7 +27,7 @@ typedef enum tile_inspector_page TILE_INSPECTOR_PAGE_TRACK, TILE_INSPECTOR_PAGE_SCENERY, TILE_INSPECTOR_PAGE_ENTRANCE, - TILE_INSPECTOR_PAGE_FENCE, + TILE_INSPECTOR_PAGE_WALL, TILE_INSPECTOR_PAGE_LARGE_SCENERY, TILE_INSPECTOR_PAGE_BANNER, TILE_INSPECTOR_PAGE_CORRUPT diff --git a/src/openrct2/world/tile_inspector.c b/src/openrct2/world/tile_inspector.c index 3201bd3e74..939929ff8a 100644 --- a/src/openrct2/world/tile_inspector.c +++ b/src/openrct2/world/tile_inspector.c @@ -549,11 +549,11 @@ sint32 tile_inspector_path_toggle_edge(sint32 x, sint32 y, sint32 elementIndex, return 0; } -sint32 tile_inspector_fence_set_slope(sint32 x, sint32 y, sint32 elementIndex, sint32 slopeValue, sint32 flags) +sint32 tile_inspector_wall_set_slope(sint32 x, sint32 y, sint32 elementIndex, sint32 slopeValue, sint32 flags) { - rct_map_element *const fenceElement = map_get_nth_element_at(x, y, elementIndex); + rct_map_element *const wallElement = map_get_nth_element_at(x, y, elementIndex); - if (!fenceElement || map_element_get_type(fenceElement) != MAP_ELEMENT_TYPE_WALL) + if (!wallElement || map_element_get_type(wallElement) != MAP_ELEMENT_TYPE_WALL) { return MONEY32_UNDEFINED; } @@ -561,8 +561,8 @@ sint32 tile_inspector_fence_set_slope(sint32 x, sint32 y, sint32 elementIndex, s if (flags & GAME_COMMAND_FLAG_APPLY) { // Set new slope value - fenceElement->type &= ~0xC0; - fenceElement->type |= slopeValue; + wallElement->type &= ~0xC0; + wallElement->type |= slopeValue; map_invalidate_tile_full(x << 5, y << 5); diff --git a/src/openrct2/world/tile_inspector.h b/src/openrct2/world/tile_inspector.h index f430949872..ec6ebca074 100644 --- a/src/openrct2/world/tile_inspector.h +++ b/src/openrct2/world/tile_inspector.h @@ -26,7 +26,7 @@ typedef enum { TILE_INSPECTOR_ELEMENT_TRACK, TILE_INSPECTOR_ELEMENT_SCENERY, TILE_INSPECTOR_ELEMENT_ENTRANCE, - TILE_INSPECTOR_ELEMENT_FENCE, + TILE_INSPECTOR_ELEMENT_WALL, TILE_INSPECTOR_ELEMENT_SCENERYMULTIPLE, TILE_INSPECTOR_ELEMENT_BANNER, TILE_INSPECTOR_ELEMENT_CORRUPT, @@ -45,7 +45,7 @@ typedef enum { TILE_INSPECTOR_SURFACE_TOGGLE_DIAGONAL, TILE_INSPECTOR_PATH_SET_SLOPE, TILE_INSPECTOR_PATH_TOGGLE_EDGE, - TILE_INSPECTOR_FENCE_SET_SLOPE, + TILE_INSPECTOR_WALL_SET_SLOPE, TILE_INSPECTOR_TRACK_BASE_HEIGHT_OFFSET, TILE_INSPECTOR_TRACK_SET_CHAIN, TILE_INSPECTOR_SCENERY_SET_QUARTER_LOCATION, @@ -66,7 +66,7 @@ sint32 tile_inspector_surface_toggle_corner(sint32 x, sint32 y, sint32 cornerInd sint32 tile_inspector_surface_toggle_diagonal(sint32 x, sint32 y, sint32 flags); sint32 tile_inspector_path_set_sloped(sint32 x, sint32 y, sint32 elementIndex, bool sloped, sint32 flags); sint32 tile_inspector_path_toggle_edge(sint32 x, sint32 y, sint32 elementIndex, sint32 cornerIndex, sint32 flags); -sint32 tile_inspector_fence_set_slope(sint32 x, sint32 y, sint32 elementIndex, sint32 slopeValue, sint32 flags); +sint32 tile_inspector_wall_set_slope(sint32 x, sint32 y, sint32 elementIndex, sint32 slopeValue, sint32 flags); sint32 tile_inspector_track_base_height_offset(sint32 x, sint32 y, sint32 elementIndex, sint8 offset, sint32 flags); sint32 tile_inspector_track_set_chain(sint32 x, sint32 y, sint32 elementIndex, bool entireTrackBlock, bool setChain, sint32 flags); sint32 tile_inspector_scenery_set_quarter_location(sint32 x, sint32 y, sint32 elementIndex, sint32 quarterIndex, sint32 flags); From 4db8f0551597c0a8c0ca71c175bb0509208d749a Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Tue, 21 Feb 2017 20:45:59 +0000 Subject: [PATCH 08/16] Replace tabs with spaces. Use coding style for var names --- src/openrct2/world/wall.cpp | 1121 +++++++++++++++++------------------ 1 file changed, 560 insertions(+), 561 deletions(-) diff --git a/src/openrct2/world/wall.cpp b/src/openrct2/world/wall.cpp index 8150e9bc36..4324bf0782 100644 --- a/src/openrct2/world/wall.cpp +++ b/src/openrct2/world/wall.cpp @@ -20,679 +20,678 @@ extern "C" { #include "map.h" - #include "park.h" - #include "scenery.h" - #include "../cheats.h" - #include "../game.h" - #include "../ride/track.h" - #include "../ride/track_data.h" - #include "../localisation/string_ids.h" + #include "park.h" + #include "scenery.h" + #include "../cheats.h" + #include "../game.h" + #include "../ride/track.h" + #include "../ride/track_data.h" + #include "../localisation/string_ids.h" } -static bool gWallAcrossTrack; - /** * * rct2: 0x006E5CBA */ -static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge, rct_map_element *trackElement) +static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge, rct_map_element *trackElement, bool *wallAcrossTrack) { - const rct_preview_track *trackBlock; - sint32 z, direction; + const rct_preview_track *trackBlock; + sint32 z, direction; - sint32 trackType = trackElement->properties.track.type; - sint32 sequence = trackElement->properties.track.sequence & 0x0F; - direction = (edge - trackElement->type) & 3; - rct_ride *ride = get_ride(trackElement->properties.track.ride_index); + sint32 trackType = trackElement->properties.track.type; + sint32 sequence = trackElement->properties.track.sequence & 0x0F; + direction = (edge - trackElement->type) & 3; + rct_ride *ride = get_ride(trackElement->properties.track.ride_index); - if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) { - if (FlatRideTrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) { - if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) { - return true; - } - } - } else { - if (TrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) { - if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) { - return true; - } - } - } + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) { + if (FlatRideTrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) { + if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) { + return true; + } + } + } else { + if (TrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) { + if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) { + return true; + } + } + } - if (!(wall->wall.flags & WALL_SCENERY_IS_DOOR)) { - return false; - } + if (!(wall->wall.flags & WALL_SCENERY_IS_DOOR)) { + return false; + } - if (!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_0)) { - return false; - } + if (!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_0)) { + return false; + } - rct_ride_entry *rideEntry = get_ride_entry(ride->subtype); - if (rideEntry->flags & RIDE_ENTRY_FLAG_16) { - return false; - } + rct_ride_entry *rideEntry = get_ride_entry(ride->subtype); + if (rideEntry->flags & RIDE_ENTRY_FLAG_16) { + return false; + } - gWallAcrossTrack = true; - if (z0 & 1) { - return false; - } + *wallAcrossTrack = true; + if (z0 & 1) { + return false; + } - if (sequence == 0) { - if (TrackSequenceProperties[trackType][0] & TRACK_SEQUENCE_FLAG_DISALLOW_DOORS) { - return false; - } + if (sequence == 0) { + if (TrackSequenceProperties[trackType][0] & TRACK_SEQUENCE_FLAG_DISALLOW_DOORS) { + return false; + } - if (TrackDefinitions[trackType].bank_start == 0) { - if (!(TrackCoordinates[trackType].rotation_begin & 4)) { - direction = (trackElement->type & 3) ^ 2; - if (direction == edge) { - trackBlock = &TrackBlocks[trackType][sequence]; - z = TrackCoordinates[trackType].z_begin; - z = trackElement->base_height + ((z - trackBlock->z) * 8); - if (z == z0) { - return true; - } - } - } - } - } + if (TrackDefinitions[trackType].bank_start == 0) { + if (!(TrackCoordinates[trackType].rotation_begin & 4)) { + direction = (trackElement->type & 3) ^ 2; + if (direction == edge) { + trackBlock = &TrackBlocks[trackType][sequence]; + z = TrackCoordinates[trackType].z_begin; + z = trackElement->base_height + ((z - trackBlock->z) * 8); + if (z == z0) { + return true; + } + } + } + } + } - trackBlock = &TrackBlocks[trackType][sequence + 1]; - if (trackBlock->index != 0xFF) { - return false; - } + trackBlock = &TrackBlocks[trackType][sequence + 1]; + if (trackBlock->index != 0xFF) { + return false; + } - if (TrackDefinitions[trackType].bank_end != 0) { - return false; - } + if (TrackDefinitions[trackType].bank_end != 0) { + return false; + } - direction = TrackCoordinates[trackType].rotation_end; - if (direction & 4) { - return false; - } + direction = TrackCoordinates[trackType].rotation_end; + if (direction & 4) { + return false; + } - direction = (trackElement->type + direction) & 3; - if (direction != edge) { - return false; - } + direction = (trackElement->type + direction) & 3; + if (direction != edge) { + return false; + } - trackBlock = &TrackBlocks[trackType][sequence]; - z = TrackCoordinates[trackType].z_end; - z = trackElement->base_height + ((z - trackBlock->z) * 8); - if (z != z0) { - return false; - } + trackBlock = &TrackBlocks[trackType][sequence]; + z = TrackCoordinates[trackType].z_end; + z = trackElement->base_height + ((z - trackBlock->z) * 8); + if (z != z0) { + return false; + } - return true; + return true; } /** * * rct2: 0x006E5C1A */ -static bool WallCheckObstruction(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge) +static bool WallCheckObstruction(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge, bool *wallAcrossTrack) { - sint32 entryType, sequence; - rct_scenery_entry *entry; - rct_large_scenery_tile *tile; + sint32 entryType, sequence; + rct_scenery_entry *entry; + rct_large_scenery_tile *tile; - gWallAcrossTrack = false; - gMapGroundFlags = ELEMENT_IS_ABOVE_GROUND; - if (map_is_location_at_edge(x, y)) { - gGameCommandErrorText = STR_OFF_EDGE_OF_MAP; - return false; - } + *wallAcrossTrack = false; + gMapGroundFlags = ELEMENT_IS_ABOVE_GROUND; + if (map_is_location_at_edge(x, y)) { + gGameCommandErrorText = STR_OFF_EDGE_OF_MAP; + return false; + } - rct_map_element *mapElement = map_get_first_element_at(x / 32, y / 32); - do { - sint32 elementType = map_element_get_type(mapElement); - if (elementType == MAP_ELEMENT_TYPE_SURFACE) continue; - if (z0 >= mapElement->clearance_height) continue; - if (z1 <= mapElement->base_height) continue; - if (elementType == MAP_ELEMENT_TYPE_WALL) { - sint32 direction = mapElement->type & 3; - if (edge == direction) { - map_obstruction_set_error_text(mapElement); - return false; - } - continue; - } - if ((mapElement->flags & 0x0F) == 0) continue; + rct_map_element *mapElement = map_get_first_element_at(x / 32, y / 32); + do { + sint32 elementType = map_element_get_type(mapElement); + if (elementType == MAP_ELEMENT_TYPE_SURFACE) continue; + if (z0 >= mapElement->clearance_height) continue; + if (z1 <= mapElement->base_height) continue; + if (elementType == MAP_ELEMENT_TYPE_WALL) { + sint32 direction = mapElement->type & 3; + if (edge == direction) { + map_obstruction_set_error_text(mapElement); + return false; + } + continue; + } + if ((mapElement->flags & 0x0F) == 0) continue; - switch (elementType) { - case MAP_ELEMENT_TYPE_ENTRANCE: - map_obstruction_set_error_text(mapElement); - return false; - case MAP_ELEMENT_TYPE_PATH: - if (mapElement->properties.path.edges & (1 << edge)) { - map_obstruction_set_error_text(mapElement); - return false; - } - break; - case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE: - entryType = mapElement->properties.scenerymultiple.type & 0x3FF; - sequence = mapElement->properties.scenerymultiple.type >> 10; - entry = get_large_scenery_entry(entryType); - tile = &entry->large_scenery.tiles[sequence]; - { - sint32 direction = ((edge - mapElement->type) & 3) + 8; - if (!(tile->var_7 & (1 << direction))) { - map_obstruction_set_error_text(mapElement); - return false; - } - } - break; - case MAP_ELEMENT_TYPE_SCENERY: - entryType = mapElement->properties.scenery.type; - entry = get_small_scenery_entry(entryType); - if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_ALLOW_WALLS) { - map_obstruction_set_error_text(mapElement); - return false; - } - break; - case MAP_ELEMENT_TYPE_TRACK: - if (!WallCheckObstructionWithTrack(wall, x, y, z0, z1, edge, mapElement)) { - return false; - } - break; - } - } while (!map_element_is_last_for_tile(mapElement++)); - return true; + switch (elementType) { + case MAP_ELEMENT_TYPE_ENTRANCE: + map_obstruction_set_error_text(mapElement); + return false; + case MAP_ELEMENT_TYPE_PATH: + if (mapElement->properties.path.edges & (1 << edge)) { + map_obstruction_set_error_text(mapElement); + return false; + } + break; + case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE: + entryType = mapElement->properties.scenerymultiple.type & 0x3FF; + sequence = mapElement->properties.scenerymultiple.type >> 10; + entry = get_large_scenery_entry(entryType); + tile = &entry->large_scenery.tiles[sequence]; + { + sint32 direction = ((edge - mapElement->type) & 3) + 8; + if (!(tile->var_7 & (1 << direction))) { + map_obstruction_set_error_text(mapElement); + return false; + } + } + break; + case MAP_ELEMENT_TYPE_SCENERY: + entryType = mapElement->properties.scenery.type; + entry = get_small_scenery_entry(entryType); + if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_ALLOW_WALLS) { + map_obstruction_set_error_text(mapElement); + return false; + } + break; + case MAP_ELEMENT_TYPE_TRACK: + if (!WallCheckObstructionWithTrack(wall, x, y, z0, z1, edge, mapElement, wallAcrossTrack)) { + return false; + } + break; + } + } while (!map_element_is_last_for_tile(mapElement++)); + return true; } - + enum { - EDGE_SLOPE_ELEVATED = (1 << 0), // 0x01 - EDGE_SLOPE_UPWARDS = (1 << 6), // 0x40 - EDGE_SLOPE_DOWNWARDS = (1 << 7), // 0x80 + EDGE_SLOPE_ELEVATED = (1 << 0), // 0x01 + EDGE_SLOPE_UPWARDS = (1 << 6), // 0x40 + EDGE_SLOPE_DOWNWARDS = (1 << 7), // 0x80 - EDGE_SLOPE_UPWARDS_ELEVATED = EDGE_SLOPE_UPWARDS | EDGE_SLOPE_ELEVATED, - EDGE_SLOPE_DOWNWARDS_ELEVATED = EDGE_SLOPE_DOWNWARDS | EDGE_SLOPE_ELEVATED, + EDGE_SLOPE_UPWARDS_ELEVATED = EDGE_SLOPE_UPWARDS | EDGE_SLOPE_ELEVATED, + EDGE_SLOPE_DOWNWARDS_ELEVATED = EDGE_SLOPE_DOWNWARDS | EDGE_SLOPE_ELEVATED, }; /** rct2: 0x009A3FEC */ static const uint8 EdgeSlopes[][4] = { -// Top right Bottom right Bottom left Top left - { 0, 0, 0, 0 }, - { 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, 0 }, - { 0, 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS }, - { 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS }, - { EDGE_SLOPE_DOWNWARDS, 0, 0, EDGE_SLOPE_UPWARDS }, - { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, - { EDGE_SLOPE_DOWNWARDS, 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED }, - { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED }, - { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, 0, 0 }, - { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, 0 }, - { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS }, - { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS }, - { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, 0, EDGE_SLOPE_UPWARDS }, - { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, - { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED }, - { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 }, - { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS }, - { 0, 0, 0, 0 }, - { EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, - { EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED }, - { 0, 0, 0, 0 }, +// Top right Bottom right Bottom left Top left + { 0, 0, 0, 0 }, + { 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, 0 }, + { 0, 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS }, + { 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS }, + { EDGE_SLOPE_DOWNWARDS, 0, 0, EDGE_SLOPE_UPWARDS }, + { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, + { EDGE_SLOPE_DOWNWARDS, 0, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED }, + { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED }, + { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, 0, 0 }, + { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, 0 }, + { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_DOWNWARDS }, + { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS }, + { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, 0, EDGE_SLOPE_UPWARDS }, + { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, + { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_ELEVATED }, + { EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED, EDGE_SLOPE_ELEVATED }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS }, + { 0, 0, 0, 0 }, + { EDGE_SLOPE_UPWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS }, + { EDGE_SLOPE_DOWNWARDS_ELEVATED, EDGE_SLOPE_DOWNWARDS, EDGE_SLOPE_UPWARDS, EDGE_SLOPE_UPWARDS_ELEVATED }, + { 0, 0, 0, 0 }, }; -money32 WallPlace(uint8 wall_type, sint16 x, sint16 y, sint16 z, uint8 edge, uint8 primary_colour, uint8 secondary_colour, uint8 tertiary_colour, uint8 flags) { - rct_xyz16 position = { - x, - y, - z - }; +money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint8 primaryColour, uint8 secondaryColour, uint8 tertiaryColour, uint8 flags) { + rct_xyz16 position = { + x, + y, + z + }; - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - gCommandPosition.x = position.x + 16; - gCommandPosition.y = position.y + 16; - gCommandPosition.z = position.z; + gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + gCommandPosition.x = position.x + 16; + gCommandPosition.y = position.y + 16; + gCommandPosition.z = position.z; - if (position.z == 0){ - gCommandPosition.z = map_element_height(position.x, position.y) & 0xFFFF; - } + if (position.z == 0){ + gCommandPosition.z = map_element_height(position.x, position.y) & 0xFFFF; + } - if (game_is_paused() && !gCheatsBuildInPauseMode){ - gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; - return MONEY32_UNDEFINED; - } + if (game_is_paused() && !gCheatsBuildInPauseMode){ + gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; + return MONEY32_UNDEFINED; + } - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && - !(flags & GAME_COMMAND_FLAG_7) && !gCheatsSandboxMode){ + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && + !(flags & GAME_COMMAND_FLAG_7) && !gCheatsSandboxMode){ - if (position.z == 0){ - if (!map_is_location_in_park(position.x, position.y)){ - return MONEY32_UNDEFINED; - } - } - else if (!map_is_location_owned(position.x, position.y, position.z)){ - return MONEY32_UNDEFINED; - } - } + if (position.z == 0){ + if (!map_is_location_in_park(position.x, position.y)){ + return MONEY32_UNDEFINED; + } + } + else if (!map_is_location_owned(position.x, position.y, position.z)){ + return MONEY32_UNDEFINED; + } + } - uint8 bp = 0; - if (position.z == 0){ - rct_map_element* map_element = map_get_surface_element_at(position.x / 32, position.y / 32); - if (map_element == NULL){ - return MONEY32_UNDEFINED; - } - position.z = map_element->base_height * 8; + uint8 bp = 0; + if (position.z == 0){ + rct_map_element* surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32); + if (surfaceElement == NULL){ + return MONEY32_UNDEFINED; + } + position.z = surfaceElement->base_height * 8; - uint8 slope = map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK; - bp = EdgeSlopes[slope][edge & 3]; - if (bp & EDGE_SLOPE_ELEVATED) { - position.z += 16; - bp &= ~(1 << 0); - } - } + uint8 slope = surfaceElement->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK; + bp = EdgeSlopes[slope][edge & 3]; + if (bp & EDGE_SLOPE_ELEVATED) { + position.z += 16; + bp &= ~(1 << 0); + } + } - rct_map_element* map_element = map_get_surface_element_at(position.x / 32, position.y / 32); - if (map_element == NULL){ - return MONEY32_UNDEFINED; - } + rct_map_element* surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32); + if (surfaceElement == NULL){ + return MONEY32_UNDEFINED; + } - if (map_element->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK){ - uint16 water_height = map_element->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK; - water_height *= 16; + if (surfaceElement->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK){ + uint16 waterHeight = surfaceElement->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK; + waterHeight *= 16; - if (position.z < water_height){ - gGameCommandErrorText = STR_CANT_BUILD_THIS_UNDERWATER; - return MONEY32_UNDEFINED; - } - } + if (position.z < waterHeight){ + gGameCommandErrorText = STR_CANT_BUILD_THIS_UNDERWATER; + return MONEY32_UNDEFINED; + } + } - if (position.z / 8 < map_element->base_height){ - gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; - return MONEY32_UNDEFINED; - } + if (position.z / 8 < surfaceElement->base_height){ + gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; + return MONEY32_UNDEFINED; + } - if (!(bp & 0xC0)){ - uint8 new_edge = (edge + 2) & 3; - uint8 new_base_height = map_element->base_height; - new_base_height += 2; - if (map_element->properties.surface.slope & (1 << new_edge)){ - if (position.z / 8 < new_base_height){ - gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; - return MONEY32_UNDEFINED; - } + if (!(bp & 0xC0)){ + uint8 newEdge = (edge + 2) & 3; + uint8 newBaseHeight = surfaceElement->base_height; + newBaseHeight += 2; + if (surfaceElement->properties.surface.slope & (1 << newEdge)){ + if (position.z / 8 < newBaseHeight){ + gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; + return MONEY32_UNDEFINED; + } - if (map_element->properties.surface.slope & (1 << 4)){ - new_edge = (new_edge - 1) & 3; + if (surfaceElement->properties.surface.slope & (1 << 4)){ + newEdge = (newEdge - 1) & 3; - if (map_element->properties.surface.slope & (1 << new_edge)){ - new_edge = (new_edge + 2) & 3; - if (map_element->properties.surface.slope & (1 << new_edge)){ - new_base_height += 2; - if (position.z / 8 < new_base_height){ - gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; - return MONEY32_UNDEFINED; - } - new_base_height -= 2; - } - } - } - } + if (surfaceElement->properties.surface.slope & (1 << newEdge)){ + newEdge = (newEdge + 2) & 3; + if (surfaceElement->properties.surface.slope & (1 << newEdge)){ + newBaseHeight += 2; + if (position.z / 8 < newBaseHeight){ + gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; + return MONEY32_UNDEFINED; + } + newBaseHeight -= 2; + } + } + } + } - new_edge = (edge + 3) & 3; - if (map_element->properties.surface.slope & (1 << new_edge)){ - if (position.z / 8 < new_base_height){ - gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; - return MONEY32_UNDEFINED; - } + newEdge = (edge + 3) & 3; + if (surfaceElement->properties.surface.slope & (1 << newEdge)){ + if (position.z / 8 < newBaseHeight){ + gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; + return MONEY32_UNDEFINED; + } - if (map_element->properties.surface.slope & (1 << 4)){ - new_edge = (new_edge - 1) & 3; + if (surfaceElement->properties.surface.slope & (1 << 4)){ + newEdge = (newEdge - 1) & 3; - if (map_element->properties.surface.slope & (1 << new_edge)){ - new_edge = (new_edge + 2) & 3; - if (map_element->properties.surface.slope & (1 << new_edge)){ - new_base_height += 2; - if (position.z / 8 < new_base_height){ - gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; - return MONEY32_UNDEFINED; - } - } - } - } - } - } - sint32 banner_index = 0xFF; - rct_scenery_entry* wall_entry = get_wall_entry(wall_type); - // Have to check both -1 and NULL, as one can be a invalid object, - // while the other can be invalid index - if ((uintptr_t)wall_entry == (uintptr_t)-1 || wall_entry == NULL) { - return MONEY32_UNDEFINED; - } - if (wall_entry->wall.scrolling_mode != 0xFF){ - banner_index = create_new_banner(flags); + if (surfaceElement->properties.surface.slope & (1 << newEdge)){ + newEdge = (newEdge + 2) & 3; + if (surfaceElement->properties.surface.slope & (1 << newEdge)){ + newBaseHeight += 2; + if (position.z / 8 < newBaseHeight){ + gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; + return MONEY32_UNDEFINED; + } + } + } + } + } + } + sint32 bannerIndex = 0xFF; + rct_scenery_entry* wallEntry = get_wall_entry(wallType); + // Have to check both -1 and NULL, as one can be a invalid object, + // while the other can be invalid index + if ((uintptr_t)wallEntry == (uintptr_t)-1 || wallEntry == NULL) { + return MONEY32_UNDEFINED; + } + if (wallEntry->wall.scrolling_mode != 0xFF){ + bannerIndex = create_new_banner(flags); - if (banner_index == 0xFF){ - return MONEY32_UNDEFINED; - } + if (bannerIndex == 0xFF){ + return MONEY32_UNDEFINED; + } - rct_banner* banner = &gBanners[banner_index]; - if (flags & GAME_COMMAND_FLAG_APPLY){ - banner->flags |= (1 << 3); - banner->type = 0; - banner->x = position.x / 32; - banner->y = position.y / 32; + rct_banner* banner = &gBanners[bannerIndex]; + if (flags & GAME_COMMAND_FLAG_APPLY){ + banner->flags |= (1 << 3); + banner->type = 0; + banner->x = position.x / 32; + banner->y = position.y / 32; - sint32 rideIndex = banner_get_closest_ride_index(position.x, position.y, position.z); - if (rideIndex != -1) { - banner->colour = rideIndex & 0xFF; - banner->flags |= BANNER_FLAG_LINKED_TO_RIDE; - } - } - } + sint32 rideIndex = banner_get_closest_ride_index(position.x, position.y, position.z); + if (rideIndex != -1) { + banner->colour = rideIndex & 0xFF; + banner->flags |= BANNER_FLAG_LINKED_TO_RIDE; + } + } + } - uint8 clearanceHeight = position.z / 8; - if (bp & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS)) { - if (wall_entry->wall.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE){ - gGameCommandErrorText = STR_ERR_UNABLE_TO_BUILD_THIS_ON_SLOPE; - return MONEY32_UNDEFINED; - } - clearanceHeight += 2; - } - clearanceHeight += wall_entry->wall.height; + uint8 clearanceHeight = position.z / 8; + if (bp & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS)) { + if (wallEntry->wall.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE){ + gGameCommandErrorText = STR_ERR_UNABLE_TO_BUILD_THIS_ON_SLOPE; + return MONEY32_UNDEFINED; + } + clearanceHeight += 2; + } + clearanceHeight += wallEntry->wall.height; - if (!(flags & GAME_COMMAND_FLAG_7) && !gCheatsDisableClearanceChecks){ - if (!WallCheckObstruction(wall_entry, position.x, position.y, position.z / 8, clearanceHeight, edge)) { - return MONEY32_UNDEFINED; - } - } + bool wallAcrossTrack = false; + if (!(flags & GAME_COMMAND_FLAG_7) && !gCheatsDisableClearanceChecks){ + if (!WallCheckObstruction(wallEntry, position.x, position.y, position.z / 8, clearanceHeight, edge, &wallAcrossTrack)) { + return MONEY32_UNDEFINED; + } + } - if (!map_check_free_elements_and_reorganise(1)){ - return MONEY32_UNDEFINED; - } + if (!map_check_free_elements_and_reorganise(1)){ + return MONEY32_UNDEFINED; + } - if (flags & GAME_COMMAND_FLAG_APPLY){ - if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) { - rct_xyz16 coord; - coord.x = position.x + 16; - coord.y = position.y + 16; - coord.z = map_element_height(coord.x, coord.y); - network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); - } + if (flags & GAME_COMMAND_FLAG_APPLY){ + if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) { + rct_xyz16 coord; + coord.x = position.x + 16; + coord.y = position.y + 16; + coord.z = map_element_height(coord.x, coord.y); + network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); + } - map_element = map_element_insert(position.x / 32, position.y / 32, position.z / 8, 0); - assert(map_element != NULL); + rct_map_element* mapElement = map_element_insert(position.x / 32, position.y / 32, position.z / 8, 0); + assert(mapElement != NULL); - map_animation_create(MAP_ANIMATION_TYPE_WALL, position.x, position.y, position.z / 8); + map_animation_create(MAP_ANIMATION_TYPE_WALL, position.x, position.y, position.z / 8); - map_element->clearance_height = clearanceHeight; + mapElement->clearance_height = clearanceHeight; - map_element->type = bp | edge | MAP_ELEMENT_TYPE_WALL; + mapElement->type = bp | edge | MAP_ELEMENT_TYPE_WALL; - map_element->properties.wall.colour_1 = primary_colour; - map_element->properties.wall.colour_1 |= (secondary_colour & 7) << 5; - map_element->flags |= (secondary_colour & 0x18) << 2; + mapElement->properties.wall.colour_1 = primaryColour; + mapElement->properties.wall.colour_1 |= (secondaryColour & 7) << 5; + mapElement->flags |= (secondaryColour & 0x18) << 2; - if (gWallAcrossTrack) { - map_element->properties.wall.animation |= (1 << 2); - } + if (wallAcrossTrack) { + mapElement->properties.wall.animation |= (1 << 2); + } - map_element->properties.wall.type = wall_type; - if (banner_index != 0xFF){ - map_element->properties.wall.banner_index = banner_index; - } + mapElement->properties.wall.type = wallType; + if (bannerIndex != 0xFF){ + mapElement->properties.wall.banner_index = bannerIndex; + } - if (wall_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ - map_element->properties.wall.colour_3 = tertiary_colour; - } + if (wallEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ + mapElement->properties.wall.colour_3 = tertiaryColour; + } - if (flags & (1 << 6)){ - map_element->flags |= MAP_ELEMENT_FLAG_GHOST; - } + if (flags & (1 << 6)){ + mapElement->flags |= MAP_ELEMENT_FLAG_GHOST; + } - gSceneryMapElement = map_element; - map_invalidate_tile_zoom1(position.x, position.y, map_element->base_height * 8, map_element->base_height * 8 + 72); - } + gSceneryMapElement = mapElement; + map_invalidate_tile_zoom1(position.x, position.y, mapElement->base_height * 8, mapElement->base_height * 8 + 72); + } - if (gParkFlags & PARK_FLAGS_NO_MONEY){ - return 0; - } - else{ - return wall_entry->wall.price; - } + if (gParkFlags & PARK_FLAGS_NO_MONEY){ + return 0; + } + else{ + return wallEntry->wall.price; + } } -money32 WallRemove(sint16 x, sint16 y, uint8 base_height, uint8 direction, uint8 flags) +money32 WallRemove(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8 flags) { - if (!map_is_location_valid(x, y)) { - return MONEY32_UNDEFINED; - } + if (!map_is_location_valid(x, y)) { + return MONEY32_UNDEFINED; + } - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - if(!(flags & GAME_COMMAND_FLAG_GHOST) && game_is_paused() && !gCheatsBuildInPauseMode){ - gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; - return MONEY32_UNDEFINED; - } - if(!(flags & GAME_COMMAND_FLAG_GHOST) && !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && !map_is_location_owned(x, y, base_height * 8)){ - return MONEY32_UNDEFINED; - } + gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + if(!(flags & GAME_COMMAND_FLAG_GHOST) && game_is_paused() && !gCheatsBuildInPauseMode){ + gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; + return MONEY32_UNDEFINED; + } + if(!(flags & GAME_COMMAND_FLAG_GHOST) && !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && !map_is_location_owned(x, y, baseHeight * 8)){ + return MONEY32_UNDEFINED; + } - bool sceneryFound = false; - rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32); - do { - if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_WALL) - continue; - if (map_element->base_height != base_height) - continue; - if ((map_element->type & MAP_ELEMENT_DIRECTION_MASK) != direction) - continue; - if ((flags & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST)) - continue; + bool wallFound = false; + rct_map_element* wallElement = map_get_first_element_at(x / 32, y / 32); + do { + if (map_element_get_type(wallElement) != MAP_ELEMENT_TYPE_WALL) + continue; + if (wallElement->base_height != baseHeight) + continue; + if ((wallElement->type & MAP_ELEMENT_DIRECTION_MASK) != direction) + continue; + if ((flags & GAME_COMMAND_FLAG_GHOST) && !(wallElement->flags & MAP_ELEMENT_FLAG_GHOST)) + continue; - sceneryFound = true; - break; - } while (!map_element_is_last_for_tile(map_element++)); + wallFound = true; + break; + } while (!map_element_is_last_for_tile(wallElement++)); - if (!(flags & GAME_COMMAND_FLAG_APPLY) || (sceneryFound == false)) { - return 0; - } + if (!(flags & GAME_COMMAND_FLAG_APPLY) || (wallFound == false)) { + return 0; + } - if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) { - rct_xyz16 coord; - coord.x = x + 16; - coord.y = y + 16; - coord.z = map_element_height(coord.x, coord.y); - network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); - } + if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) { + rct_xyz16 coord; + coord.x = x + 16; + coord.y = y + 16; + coord.z = map_element_height(coord.x, coord.y); + network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); + } - map_element_remove_banner_entry(map_element); - map_invalidate_tile_zoom1(x, y, map_element->base_height * 8, (map_element->base_height * 8) + 72); - map_element_remove(map_element); - return 0; + map_element_remove_banner_entry(wallElement); + map_invalidate_tile_zoom1(x, y, wallElement->base_height * 8, (wallElement->base_height * 8) + 72); + map_element_remove(wallElement); + return 0; } -money32 WallSetColour(sint16 x, sint16 y, uint8 base_height, uint8 direction, uint8 primaryColour, uint8 secondaryColour, uint8 tertiaryColour, uint8 flags) +money32 WallSetColour(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8 primaryColour, uint8 secondaryColour, uint8 tertiaryColour, uint8 flags) { - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - sint32 z = base_height * 8; + gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + sint32 z = baseHeight * 8; - gCommandPosition.x = x + 16; - gCommandPosition.y = y + 16; - gCommandPosition.z = z; + gCommandPosition.x = x + 16; + gCommandPosition.y = y + 16; + gCommandPosition.z = z; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && - !map_is_location_in_park(x, y) && - !gCheatsSandboxMode) { + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && + !map_is_location_in_park(x, y) && + !gCheatsSandboxMode) { - return MONEY32_UNDEFINED; - } + return MONEY32_UNDEFINED; + } - rct_map_element* map_element = map_get_wall_element_at(x, y, base_height, direction); + rct_map_element* wallElement = map_get_wall_element_at(x, y, baseHeight, direction); - if (map_element == NULL) { - return 0; - } + if (wallElement == NULL) { + return 0; + } - if ((flags & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST)) { - return 0; - } + if ((flags & GAME_COMMAND_FLAG_GHOST) && !(wallElement->flags & MAP_ELEMENT_FLAG_GHOST)) { + return 0; + } - if(flags & GAME_COMMAND_FLAG_APPLY){ - rct_scenery_entry* scenery_entry = get_wall_entry(map_element->properties.wall.type); - map_element->properties.wall.colour_1 &= 0xE0; - map_element->properties.wall.colour_1 |= primaryColour; - map_element->properties.wall.colour_1 &= 0x1F; - map_element->flags &= 0x9F; - map_element->properties.wall.colour_1 |= (secondaryColour & 0x7) * 32; - map_element->flags |= (secondaryColour & 0x18) * 4; + if(flags & GAME_COMMAND_FLAG_APPLY){ + rct_scenery_entry* scenery_entry = get_wall_entry(wallElement->properties.wall.type); + wallElement->properties.wall.colour_1 &= 0xE0; + wallElement->properties.wall.colour_1 |= primaryColour; + wallElement->properties.wall.colour_1 &= 0x1F; + wallElement->flags &= 0x9F; + wallElement->properties.wall.colour_1 |= (secondaryColour & 0x7) * 32; + wallElement->flags |= (secondaryColour & 0x18) * 4; - if(scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ - map_element->properties.wall.colour_3 = tertiaryColour; - } - map_invalidate_tile_zoom1(x, y, z, z + 72); - } + if(scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ + wallElement->properties.wall.colour_3 = tertiaryColour; + } + map_invalidate_tile_zoom1(x, y, z, z + 72); + } - return 0; + return 0; } extern "C" { - uint8 wall_get_animation_frame(rct_map_element *wallElement) { - return (wallElement->properties.wall.animation >> 3) & 0xF; - } - - /** - * - * rct2: 0x006E588E - */ - void wall_remove_at(sint32 x, sint32 y, sint32 z0, sint32 z1) - { - rct_map_element *mapElement; + uint8 wall_get_animation_frame(rct_map_element *wallElement) { + return (wallElement->properties.wall.animation >> 3) & 0xF; + } + + /** + * + * rct2: 0x006E588E + */ + void wall_remove_at(sint32 x, sint32 y, sint32 z0, sint32 z1) + { + rct_map_element *mapElement; - z0 /= 8; - z1 /= 8; - repeat: - mapElement = map_get_first_element_at(x >> 5, y >> 5); - do { - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) - continue; - if (z0 >= mapElement->clearance_height) - continue; - if (z1 <= mapElement->base_height) - continue; + z0 /= 8; + z1 /= 8; + repeat: + mapElement = map_get_first_element_at(x >> 5, y >> 5); + do { + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) + continue; + if (z0 >= mapElement->clearance_height) + continue; + if (z1 <= mapElement->base_height) + continue; - map_element_remove_banner_entry(mapElement); - map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->base_height * 8 + 72); - map_element_remove(mapElement); - goto repeat; - } while (!map_element_is_last_for_tile(mapElement++)); - } - - /** - * - * rct2: 0x006E57E6 - */ - void wall_remove_at_z(sint32 x, sint32 y, sint32 z) - { - wall_remove_at(x, y, z, z + 48); - } + map_element_remove_banner_entry(mapElement); + map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->base_height * 8 + 72); + map_element_remove(mapElement); + goto repeat; + } while (!map_element_is_last_for_tile(mapElement++)); + } + + /** + * + * rct2: 0x006E57E6 + */ + void wall_remove_at_z(sint32 x, sint32 y, sint32 z) + { + wall_remove_at(x, y, z, z + 48); + } - /** - * - * rct2: 0x006E5935 - */ - void wall_remove_intersecting_walls(sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 direction) - { - rct_map_element *mapElement; + /** + * + * rct2: 0x006E5935 + */ + void wall_remove_intersecting_walls(sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 direction) + { + rct_map_element *mapElement; - mapElement = map_get_first_element_at(x >> 5, y >> 5); - do { - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) - continue; + mapElement = map_get_first_element_at(x >> 5, y >> 5); + do { + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) + continue; - if (mapElement->clearance_height <= z0 || mapElement->base_height >= z1) - continue; + if (mapElement->clearance_height <= z0 || mapElement->base_height >= z1) + continue; - if (direction != (mapElement->type & 3)) - continue; + if (direction != (mapElement->type & 3)) + continue; - map_element_remove_banner_entry(mapElement); - map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->base_height * 8 + 72); - map_element_remove(mapElement); - mapElement--; - } while (!map_element_is_last_for_tile(mapElement++)); - } + map_element_remove_banner_entry(mapElement); + map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->base_height * 8 + 72); + map_element_remove(mapElement); + mapElement--; + } while (!map_element_is_last_for_tile(mapElement++)); + } - /** - * - * rct2: 0x006E519A - */ - void game_command_place_wall(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) { - *ebx = WallPlace( - (*ebx >> 8) & 0xFF, - *eax & 0xFFFF, - *ecx & 0xFFFF, - *edi & 0xFFFF, - *edx & 0xFF, - (*edx >> 8) & 0xFF, - *ebp & 0xFF, - (*ebp >> 8) & 0xFF, - *ebx & 0xFF - ); - } + /** + * + * rct2: 0x006E519A + */ + void game_command_place_wall(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) { + *ebx = WallPlace( + (*ebx >> 8) & 0xFF, + *eax & 0xFFFF, + *ecx & 0xFFFF, + *edi & 0xFFFF, + *edx & 0xFF, + (*edx >> 8) & 0xFF, + *ebp & 0xFF, + (*ebp >> 8) & 0xFF, + *ebx & 0xFF + ); + } - money32 wall_place( - sint32 type, sint32 x, sint32 y, sint32 z, sint32 edge, sint32 primaryColour, sint32 secondaryColour, sint32 tertiaryColour, sint32 flags - ) { - sint32 eax, ebx, ecx, edx, esi, edi, ebp; + money32 wall_place( + sint32 type, sint32 x, sint32 y, sint32 z, sint32 edge, sint32 primaryColour, sint32 secondaryColour, sint32 tertiaryColour, sint32 flags + ) { + sint32 eax, ebx, ecx, edx, esi, edi, ebp; - eax = x; - ebx = flags | (type << 8); - ecx = y; - edx = edge | (primaryColour << 8); - edi = z; - ebp = secondaryColour | (tertiaryColour << 8); - game_command_place_wall(&eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - return ebx; - } + eax = x; + ebx = flags | (type << 8); + ecx = y; + edx = edge | (primaryColour << 8); + edi = z; + ebp = secondaryColour | (tertiaryColour << 8); + game_command_place_wall(&eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + return ebx; + } - /** - * - * rct2: 0x006E5597 - */ - void game_command_remove_wall(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) - { - *ebx = WallRemove( - *eax & 0xFFFF, - *ecx & 0xFFFF, - (*edx >> 8) & 0xFF, - *edx & 0xFF, - *ebx & 0xFF - ); - } - - /** - * - * rct2: 0x006E56B5 - */ - void game_command_set_wall_colour(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) - { - *ebx = WallSetColour( - *eax & 0xFFFF, - *ecx & 0xFFFF, - (*edx >> 8) & 0xFF, - *edx & 0xFF, - (*ebx >> 8) & 0xFF, - *ebp & 0xFF, - (*ebp >> 8) & 0xFF, - *ebx & 0xFF - ); - } + /** + * + * rct2: 0x006E5597 + */ + void game_command_remove_wall(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) + { + *ebx = WallRemove( + *eax & 0xFFFF, + *ecx & 0xFFFF, + (*edx >> 8) & 0xFF, + *edx & 0xFF, + *ebx & 0xFF + ); + } + + /** + * + * rct2: 0x006E56B5 + */ + void game_command_set_wall_colour(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) + { + *ebx = WallSetColour( + *eax & 0xFFFF, + *ecx & 0xFFFF, + (*edx >> 8) & 0xFF, + *edx & 0xFF, + (*ebx >> 8) & 0xFF, + *ebp & 0xFF, + (*ebp >> 8) & 0xFF, + *ebx & 0xFF + ); + } } From c5e9698f0ce952b29a356b7b2ca9f2b8d70836f2 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Tue, 21 Feb 2017 21:17:10 +0000 Subject: [PATCH 09/16] Fix remaining wall fence issue --- src/openrct2/world/map.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openrct2/world/map.c b/src/openrct2/world/map.c index f9d837e555..4c3abe91d7 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -5059,11 +5059,11 @@ void game_command_modify_tile(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx *ebx = tile_inspector_path_toggle_edge(x, y, elementIndex, edgeIndex, flags); break; } - case TILE_INSPECTOR_FENCE_SET_SLOPE: + case TILE_INSPECTOR_WALL_SET_SLOPE: { const sint32 elementIndex = *edx; const sint32 slopeValue = *edi; - *ebx = tile_inspector_fence_set_slope(x, y, elementIndex, slopeValue, flags); + *ebx = tile_inspector_wall_set_slope(x, y, elementIndex, slopeValue, flags); break; } case TILE_INSPECTOR_TRACK_BASE_HEIGHT_OFFSET: From 84a0060090f8468861a6df5dc1b8f6694e20eac6 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Wed, 22 Feb 2017 18:18:23 +0000 Subject: [PATCH 10/16] Enforce the bracket and line width rule --- src/openrct2/rct12/SawyerChunkReader.cpp | 1 + src/openrct2/world/wall.cpp | 405 ++++++++++++++++------- 2 files changed, 286 insertions(+), 120 deletions(-) diff --git a/src/openrct2/rct12/SawyerChunkReader.cpp b/src/openrct2/rct12/SawyerChunkReader.cpp index 65e3269f22..c0a37a5e08 100644 --- a/src/openrct2/rct12/SawyerChunkReader.cpp +++ b/src/openrct2/rct12/SawyerChunkReader.cpp @@ -57,6 +57,7 @@ void SawyerChunkReader::SkipChunk() std::shared_ptr SawyerChunkReader::ReadChunk() { + Guard::Assert(false, "Test"); uint64 originalPosition = _stream->GetPosition(); try { diff --git a/src/openrct2/world/wall.cpp b/src/openrct2/world/wall.cpp index 4324bf0782..839d924575 100644 --- a/src/openrct2/world/wall.cpp +++ b/src/openrct2/world/wall.cpp @@ -33,7 +33,14 @@ extern "C" * * rct2: 0x006E5CBA */ -static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge, rct_map_element *trackElement, bool *wallAcrossTrack) +static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall, + sint32 x, + sint32 y, + sint32 z0, + sint32 z1, + sint32 edge, + rct_map_element * trackElement, + bool * wallAcrossTrack) { const rct_preview_track *trackBlock; sint32 z, direction; @@ -41,53 +48,70 @@ static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall, sint32 x, sin sint32 trackType = trackElement->properties.track.type; sint32 sequence = trackElement->properties.track.sequence & 0x0F; direction = (edge - trackElement->type) & 3; - rct_ride *ride = get_ride(trackElement->properties.track.ride_index); + rct_ride * ride = get_ride(trackElement->properties.track.ride_index); - if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) { - if (FlatRideTrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) { - if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) { + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) + { + if (FlatRideTrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) + { + if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) + { return true; } } - } else { - if (TrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) { - if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) { + } + else + { + if (TrackSequenceElementAllowedWallEdges[trackType][sequence] & (1 << direction)) + { + if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_NO_WALLS)) + { return true; } } } - if (!(wall->wall.flags & WALL_SCENERY_IS_DOOR)) { + if (!(wall->wall.flags & WALL_SCENERY_IS_DOOR)) + { return false; } - if (!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_0)) { + if (!(RideData4[ride->type].flags & RIDE_TYPE_FLAG4_0)) + { return false; } - rct_ride_entry *rideEntry = get_ride_entry(ride->subtype); - if (rideEntry->flags & RIDE_ENTRY_FLAG_16) { + rct_ride_entry * rideEntry = get_ride_entry(ride->subtype); + if (rideEntry->flags & RIDE_ENTRY_FLAG_16) + { return false; } *wallAcrossTrack = true; - if (z0 & 1) { + if (z0 & 1) + { return false; } - if (sequence == 0) { - if (TrackSequenceProperties[trackType][0] & TRACK_SEQUENCE_FLAG_DISALLOW_DOORS) { + if (sequence == 0) + { + if (TrackSequenceProperties[trackType][0] & TRACK_SEQUENCE_FLAG_DISALLOW_DOORS) + { return false; } - if (TrackDefinitions[trackType].bank_start == 0) { - if (!(TrackCoordinates[trackType].rotation_begin & 4)) { + if (TrackDefinitions[trackType].bank_start == 0) + { + if (!(TrackCoordinates[trackType].rotation_begin & 4)) + { direction = (trackElement->type & 3) ^ 2; - if (direction == edge) { + if (direction == edge) + { trackBlock = &TrackBlocks[trackType][sequence]; z = TrackCoordinates[trackType].z_begin; z = trackElement->base_height + ((z - trackBlock->z) * 8); - if (z == z0) { + if (z == z0) + { return true; } } @@ -96,28 +120,33 @@ static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall, sint32 x, sin } trackBlock = &TrackBlocks[trackType][sequence + 1]; - if (trackBlock->index != 0xFF) { + if (trackBlock->index != 0xFF) + { return false; } - if (TrackDefinitions[trackType].bank_end != 0) { + if (TrackDefinitions[trackType].bank_end != 0) + { return false; } direction = TrackCoordinates[trackType].rotation_end; - if (direction & 4) { + if (direction & 4) + { return false; } direction = (trackElement->type + direction) & 3; - if (direction != edge) { + if (direction != edge) + { return false; } trackBlock = &TrackBlocks[trackType][sequence]; z = TrackCoordinates[trackType].z_end; z = trackElement->base_height + ((z - trackBlock->z) * 8); - if (z != z0) { + if (z != z0) + { return false; } @@ -128,28 +157,38 @@ static bool WallCheckObstructionWithTrack(rct_scenery_entry *wall, sint32 x, sin * * rct2: 0x006E5C1A */ -static bool WallCheckObstruction(rct_scenery_entry *wall, sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 edge, bool *wallAcrossTrack) +static bool WallCheckObstruction(rct_scenery_entry * wall, + sint32 x, + sint32 y, + sint32 z0, + sint32 z1, + sint32 edge, + bool * wallAcrossTrack) { sint32 entryType, sequence; - rct_scenery_entry *entry; - rct_large_scenery_tile *tile; + rct_scenery_entry * entry; + rct_large_scenery_tile * tile; *wallAcrossTrack = false; gMapGroundFlags = ELEMENT_IS_ABOVE_GROUND; - if (map_is_location_at_edge(x, y)) { + if (map_is_location_at_edge(x, y)) + { gGameCommandErrorText = STR_OFF_EDGE_OF_MAP; return false; } - rct_map_element *mapElement = map_get_first_element_at(x / 32, y / 32); - do { + rct_map_element * mapElement = map_get_first_element_at(x / 32, y / 32); + do + { sint32 elementType = map_element_get_type(mapElement); if (elementType == MAP_ELEMENT_TYPE_SURFACE) continue; if (z0 >= mapElement->clearance_height) continue; if (z1 <= mapElement->base_height) continue; - if (elementType == MAP_ELEMENT_TYPE_WALL) { + if (elementType == MAP_ELEMENT_TYPE_WALL) + { sint32 direction = mapElement->type & 3; - if (edge == direction) { + if (edge == direction) + { map_obstruction_set_error_text(mapElement); return false; } @@ -157,12 +196,14 @@ static bool WallCheckObstruction(rct_scenery_entry *wall, sint32 x, sint32 y, si } if ((mapElement->flags & 0x0F) == 0) continue; - switch (elementType) { + switch (elementType) + { case MAP_ELEMENT_TYPE_ENTRANCE: map_obstruction_set_error_text(mapElement); return false; case MAP_ELEMENT_TYPE_PATH: - if (mapElement->properties.path.edges & (1 << edge)) { + if (mapElement->properties.path.edges & (1 << edge)) + { map_obstruction_set_error_text(mapElement); return false; } @@ -174,7 +215,8 @@ static bool WallCheckObstruction(rct_scenery_entry *wall, sint32 x, sint32 y, si tile = &entry->large_scenery.tiles[sequence]; { sint32 direction = ((edge - mapElement->type) & 3) + 8; - if (!(tile->var_7 & (1 << direction))) { + if (!(tile->var_7 & (1 << direction))) + { map_obstruction_set_error_text(mapElement); return false; } @@ -183,21 +225,27 @@ static bool WallCheckObstruction(rct_scenery_entry *wall, sint32 x, sint32 y, si case MAP_ELEMENT_TYPE_SCENERY: entryType = mapElement->properties.scenery.type; entry = get_small_scenery_entry(entryType); - if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_ALLOW_WALLS) { + if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_ALLOW_WALLS) + { map_obstruction_set_error_text(mapElement); return false; } break; case MAP_ELEMENT_TYPE_TRACK: - if (!WallCheckObstructionWithTrack(wall, x, y, z0, z1, edge, mapElement, wallAcrossTrack)) { + if (!WallCheckObstructionWithTrack(wall, x, y, z0, z1, edge, mapElement, wallAcrossTrack)) + { return false; } break; } - } while (!map_element_is_last_for_tile(mapElement++)); + } + while (!map_element_is_last_for_tile(mapElement++)); + return true; } - + +#pragma region Edge Slopes Table + enum { EDGE_SLOPE_ELEVATED = (1 << 0), // 0x01 @@ -245,10 +293,20 @@ static const uint8 EdgeSlopes[][4] = { { 0, 0, 0, 0 }, }; +#pragma endregion - -money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint8 primaryColour, uint8 secondaryColour, uint8 tertiaryColour, uint8 flags) { - rct_xyz16 position = { +money32 WallPlace(uint8 wallType, + sint16 x, + sint16 y, + sint16 z, + uint8 edge, + uint8 primaryColour, + uint8 secondaryColour, + uint8 tertiaryColour, + uint8 flags) +{ + rct_xyz16 position = + { x, y, z @@ -259,82 +317,103 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint gCommandPosition.y = position.y + 16; gCommandPosition.z = position.z; - if (position.z == 0){ + if (position.z == 0) + { gCommandPosition.z = map_element_height(position.x, position.y) & 0xFFFF; } - if (game_is_paused() && !gCheatsBuildInPauseMode){ + if (game_is_paused() && !gCheatsBuildInPauseMode) + { gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; return MONEY32_UNDEFINED; } if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && - !(flags & GAME_COMMAND_FLAG_7) && !gCheatsSandboxMode){ + !(flags & GAME_COMMAND_FLAG_7) && + !gCheatsSandboxMode) + { - if (position.z == 0){ - if (!map_is_location_in_park(position.x, position.y)){ + if (position.z == 0) + { + if (!map_is_location_in_park(position.x, position.y)) + { return MONEY32_UNDEFINED; } } - else if (!map_is_location_owned(position.x, position.y, position.z)){ + else if (!map_is_location_owned(position.x, position.y, position.z)) + { return MONEY32_UNDEFINED; } } uint8 bp = 0; - if (position.z == 0){ - rct_map_element* surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32); - if (surfaceElement == NULL){ + if (position.z == 0) + { + rct_map_element * surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32); + if (surfaceElement == NULL) + { return MONEY32_UNDEFINED; } position.z = surfaceElement->base_height * 8; uint8 slope = surfaceElement->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK; bp = EdgeSlopes[slope][edge & 3]; - if (bp & EDGE_SLOPE_ELEVATED) { + if (bp & EDGE_SLOPE_ELEVATED) + { position.z += 16; bp &= ~(1 << 0); } } - rct_map_element* surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32); - if (surfaceElement == NULL){ + rct_map_element * surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32); + if (surfaceElement == NULL) + { return MONEY32_UNDEFINED; } - if (surfaceElement->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK){ + if (surfaceElement->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK) + { uint16 waterHeight = surfaceElement->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK; waterHeight *= 16; - if (position.z < waterHeight){ + if (position.z < waterHeight) + { gGameCommandErrorText = STR_CANT_BUILD_THIS_UNDERWATER; return MONEY32_UNDEFINED; } } - if (position.z / 8 < surfaceElement->base_height){ + if (position.z / 8 < surfaceElement->base_height) + { gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; return MONEY32_UNDEFINED; } - if (!(bp & 0xC0)){ + if (!(bp & 0xC0)) + { uint8 newEdge = (edge + 2) & 3; uint8 newBaseHeight = surfaceElement->base_height; newBaseHeight += 2; - if (surfaceElement->properties.surface.slope & (1 << newEdge)){ - if (position.z / 8 < newBaseHeight){ + if (surfaceElement->properties.surface.slope & (1 << newEdge)) + { + if (position.z / 8 < newBaseHeight) + { gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; return MONEY32_UNDEFINED; } - if (surfaceElement->properties.surface.slope & (1 << 4)){ + if (surfaceElement->properties.surface.slope & (1 << 4)) + { newEdge = (newEdge - 1) & 3; - if (surfaceElement->properties.surface.slope & (1 << newEdge)){ + if (surfaceElement->properties.surface.slope & (1 << newEdge)) + { newEdge = (newEdge + 2) & 3; - if (surfaceElement->properties.surface.slope & (1 << newEdge)){ + if (surfaceElement->properties.surface.slope & (1 << newEdge)) + { newBaseHeight += 2; - if (position.z / 8 < newBaseHeight){ + if (position.z / 8 < newBaseHeight) + { gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; return MONEY32_UNDEFINED; } @@ -345,20 +424,26 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint } newEdge = (edge + 3) & 3; - if (surfaceElement->properties.surface.slope & (1 << newEdge)){ - if (position.z / 8 < newBaseHeight){ + if (surfaceElement->properties.surface.slope & (1 << newEdge)) + { + if (position.z / 8 < newBaseHeight) + { gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; return MONEY32_UNDEFINED; } - if (surfaceElement->properties.surface.slope & (1 << 4)){ + if (surfaceElement->properties.surface.slope & (1 << 4)) + { newEdge = (newEdge - 1) & 3; - if (surfaceElement->properties.surface.slope & (1 << newEdge)){ + if (surfaceElement->properties.surface.slope & (1 << newEdge)) + { newEdge = (newEdge + 2) & 3; - if (surfaceElement->properties.surface.slope & (1 << newEdge)){ + if (surfaceElement->properties.surface.slope & (1 << newEdge)) + { newBaseHeight += 2; - if (position.z / 8 < newBaseHeight){ + if (position.z / 8 < newBaseHeight) + { gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; return MONEY32_UNDEFINED; } @@ -368,28 +453,34 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint } } sint32 bannerIndex = 0xFF; - rct_scenery_entry* wallEntry = get_wall_entry(wallType); + rct_scenery_entry * wallEntry = get_wall_entry(wallType); // Have to check both -1 and NULL, as one can be a invalid object, // while the other can be invalid index - if ((uintptr_t)wallEntry == (uintptr_t)-1 || wallEntry == NULL) { + if ((uintptr_t)wallEntry == (uintptr_t)-1 || wallEntry == NULL) + { return MONEY32_UNDEFINED; } - if (wallEntry->wall.scrolling_mode != 0xFF){ + + if (wallEntry->wall.scrolling_mode != 0xFF) + { bannerIndex = create_new_banner(flags); - if (bannerIndex == 0xFF){ + if (bannerIndex == 0xFF) + { return MONEY32_UNDEFINED; } - rct_banner* banner = &gBanners[bannerIndex]; - if (flags & GAME_COMMAND_FLAG_APPLY){ + rct_banner * banner = &gBanners[bannerIndex]; + if (flags & GAME_COMMAND_FLAG_APPLY) + { banner->flags |= (1 << 3); banner->type = 0; banner->x = position.x / 32; banner->y = position.y / 32; sint32 rideIndex = banner_get_closest_ride_index(position.x, position.y, position.z); - if (rideIndex != -1) { + if (rideIndex != -1) + { banner->colour = rideIndex & 0xFF; banner->flags |= BANNER_FLAG_LINKED_TO_RIDE; } @@ -397,8 +488,10 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint } uint8 clearanceHeight = position.z / 8; - if (bp & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS)) { - if (wallEntry->wall.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE){ + if (bp & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS)) + { + if (wallEntry->wall.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE) + { gGameCommandErrorText = STR_ERR_UNABLE_TO_BUILD_THIS_ON_SLOPE; return MONEY32_UNDEFINED; } @@ -407,18 +500,29 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint clearanceHeight += wallEntry->wall.height; bool wallAcrossTrack = false; - if (!(flags & GAME_COMMAND_FLAG_7) && !gCheatsDisableClearanceChecks){ - if (!WallCheckObstruction(wallEntry, position.x, position.y, position.z / 8, clearanceHeight, edge, &wallAcrossTrack)) { + if (!(flags & GAME_COMMAND_FLAG_7) && !gCheatsDisableClearanceChecks) + { + if (!WallCheckObstruction(wallEntry, + position.x, + position.y, + position.z / 8, + clearanceHeight, + edge, + &wallAcrossTrack)) + { return MONEY32_UNDEFINED; } } - if (!map_check_free_elements_and_reorganise(1)){ + if (!map_check_free_elements_and_reorganise(1)) + { return MONEY32_UNDEFINED; } - if (flags & GAME_COMMAND_FLAG_APPLY){ - if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) { + if (flags & GAME_COMMAND_FLAG_APPLY) + { + if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) + { rct_xyz16 coord; coord.x = position.x + 16; coord.y = position.y + 16; @@ -426,7 +530,7 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); } - rct_map_element* mapElement = map_element_insert(position.x / 32, position.y / 32, position.z / 8, 0); + rct_map_element * mapElement = map_element_insert(position.x / 32, position.y / 32, position.z / 8, 0); assert(mapElement != NULL); map_animation_create(MAP_ANIMATION_TYPE_WALL, position.x, position.y, position.z / 8); @@ -439,20 +543,24 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint mapElement->properties.wall.colour_1 |= (secondaryColour & 7) << 5; mapElement->flags |= (secondaryColour & 0x18) << 2; - if (wallAcrossTrack) { + if (wallAcrossTrack) + { mapElement->properties.wall.animation |= (1 << 2); } mapElement->properties.wall.type = wallType; - if (bannerIndex != 0xFF){ + if (bannerIndex != 0xFF) + { mapElement->properties.wall.banner_index = bannerIndex; } - if (wallEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ + if (wallEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) + { mapElement->properties.wall.colour_3 = tertiaryColour; } - if (flags & (1 << 6)){ + if (flags & (1 << 6)) + { mapElement->flags |= MAP_ELEMENT_FLAG_GHOST; } @@ -460,32 +568,44 @@ money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, uint8 edge, uint map_invalidate_tile_zoom1(position.x, position.y, mapElement->base_height * 8, mapElement->base_height * 8 + 72); } - if (gParkFlags & PARK_FLAGS_NO_MONEY){ + if (gParkFlags & PARK_FLAGS_NO_MONEY) + { return 0; } - else{ + else + { return wallEntry->wall.price; } } money32 WallRemove(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8 flags) { - if (!map_is_location_valid(x, y)) { + if (!map_is_location_valid(x, y)) + { return MONEY32_UNDEFINED; } gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - if(!(flags & GAME_COMMAND_FLAG_GHOST) && game_is_paused() && !gCheatsBuildInPauseMode){ + if(!(flags & GAME_COMMAND_FLAG_GHOST) && + game_is_paused() && + !gCheatsBuildInPauseMode) + { gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; return MONEY32_UNDEFINED; } - if(!(flags & GAME_COMMAND_FLAG_GHOST) && !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && !map_is_location_owned(x, y, baseHeight * 8)){ + + if(!(flags & GAME_COMMAND_FLAG_GHOST) && + !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && + !gCheatsSandboxMode && + !map_is_location_owned(x, y, baseHeight * 8)) + { return MONEY32_UNDEFINED; } bool wallFound = false; - rct_map_element* wallElement = map_get_first_element_at(x / 32, y / 32); - do { + rct_map_element * wallElement = map_get_first_element_at(x / 32, y / 32); + do + { if (map_element_get_type(wallElement) != MAP_ELEMENT_TYPE_WALL) continue; if (wallElement->base_height != baseHeight) @@ -497,13 +617,16 @@ money32 WallRemove(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8 wallFound = true; break; - } while (!map_element_is_last_for_tile(wallElement++)); + } + while (!map_element_is_last_for_tile(wallElement++)); - if (!(flags & GAME_COMMAND_FLAG_APPLY) || (wallFound == false)) { + if (!(flags & GAME_COMMAND_FLAG_APPLY) || (wallFound == false)) + { return 0; } - if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) { + if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) + { rct_xyz16 coord; coord.x = x + 16; coord.y = y + 16; @@ -517,7 +640,14 @@ money32 WallRemove(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8 return 0; } -money32 WallSetColour(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8 primaryColour, uint8 secondaryColour, uint8 tertiaryColour, uint8 flags) +money32 WallSetColour(sint16 x, + sint16 y, + uint8 baseHeight, + uint8 direction, + uint8 primaryColour, + uint8 secondaryColour, + uint8 tertiaryColour, + uint8 flags) { gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; sint32 z = baseHeight * 8; @@ -528,23 +658,27 @@ money32 WallSetColour(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uin if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !map_is_location_in_park(x, y) && - !gCheatsSandboxMode) { + !gCheatsSandboxMode) + { return MONEY32_UNDEFINED; } - rct_map_element* wallElement = map_get_wall_element_at(x, y, baseHeight, direction); + rct_map_element * wallElement = map_get_wall_element_at(x, y, baseHeight, direction); - if (wallElement == NULL) { + if (wallElement == NULL) + { return 0; } - if ((flags & GAME_COMMAND_FLAG_GHOST) && !(wallElement->flags & MAP_ELEMENT_FLAG_GHOST)) { + if ((flags & GAME_COMMAND_FLAG_GHOST) && !(wallElement->flags & MAP_ELEMENT_FLAG_GHOST)) + { return 0; } - if(flags & GAME_COMMAND_FLAG_APPLY){ - rct_scenery_entry* scenery_entry = get_wall_entry(wallElement->properties.wall.type); + if(flags & GAME_COMMAND_FLAG_APPLY) + { + rct_scenery_entry * scenery_entry = get_wall_entry(wallElement->properties.wall.type); wallElement->properties.wall.colour_1 &= 0xE0; wallElement->properties.wall.colour_1 |= primaryColour; wallElement->properties.wall.colour_1 &= 0x1F; @@ -552,7 +686,8 @@ money32 WallSetColour(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uin wallElement->properties.wall.colour_1 |= (secondaryColour & 0x7) * 32; wallElement->flags |= (secondaryColour & 0x18) * 4; - if(scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR){ + if(scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) + { wallElement->properties.wall.colour_3 = tertiaryColour; } map_invalidate_tile_zoom1(x, y, z, z + 72); @@ -563,7 +698,7 @@ money32 WallSetColour(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uin extern "C" { - uint8 wall_get_animation_frame(rct_map_element *wallElement) { + uint8 wall_get_animation_frame(rct_map_element * wallElement) { return (wallElement->properties.wall.animation >> 3) & 0xF; } @@ -573,13 +708,14 @@ extern "C" */ void wall_remove_at(sint32 x, sint32 y, sint32 z0, sint32 z1) { - rct_map_element *mapElement; + rct_map_element * mapElement; z0 /= 8; z1 /= 8; repeat: mapElement = map_get_first_element_at(x >> 5, y >> 5); - do { + do + { if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue; if (z0 >= mapElement->clearance_height) @@ -591,7 +727,8 @@ extern "C" map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->base_height * 8 + 72); map_element_remove(mapElement); goto repeat; - } while (!map_element_is_last_for_tile(mapElement++)); + } + while (!map_element_is_last_for_tile(mapElement++)); } /** @@ -609,10 +746,11 @@ extern "C" */ void wall_remove_intersecting_walls(sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 direction) { - rct_map_element *mapElement; + rct_map_element * mapElement; mapElement = map_get_first_element_at(x >> 5, y >> 5); - do { + do + { if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_WALL) continue; @@ -626,14 +764,22 @@ extern "C" map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->base_height * 8 + 72); map_element_remove(mapElement); mapElement--; - } while (!map_element_is_last_for_tile(mapElement++)); + } + while (!map_element_is_last_for_tile(mapElement++)); } /** * * rct2: 0x006E519A */ - void game_command_place_wall(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) { + void game_command_place_wall(sint32 * eax, + sint32 * ebx, + sint32 * ecx, + sint32 * edx, + sint32 * esi, + sint32 * edi, + sint32 * ebp) + { *ebx = WallPlace( (*ebx >> 8) & 0xFF, *eax & 0xFFFF, @@ -647,9 +793,16 @@ extern "C" ); } - money32 wall_place( - sint32 type, sint32 x, sint32 y, sint32 z, sint32 edge, sint32 primaryColour, sint32 secondaryColour, sint32 tertiaryColour, sint32 flags - ) { + money32 wall_place(sint32 type, + sint32 x, + sint32 y, + sint32 z, + sint32 edge, + sint32 primaryColour, + sint32 secondaryColour, + sint32 tertiaryColour, + sint32 flags) + { sint32 eax, ebx, ecx, edx, esi, edi, ebp; eax = x; @@ -666,7 +819,13 @@ extern "C" * * rct2: 0x006E5597 */ - void game_command_remove_wall(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) + void game_command_remove_wall(sint32 * eax, + sint32 * ebx, + sint32 * ecx, + sint32 * edx, + sint32 * esi, + sint32 * edi, + sint32 * ebp) { *ebx = WallRemove( *eax & 0xFFFF, @@ -681,7 +840,13 @@ extern "C" * * rct2: 0x006E56B5 */ - void game_command_set_wall_colour(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) + void game_command_set_wall_colour(sint32 * eax, + sint32 * ebx, + sint32 * ecx, + sint32 * edx, + sint32 * esi, + sint32 * edi, + sint32 * ebp) { *ebx = WallSetColour( *eax & 0xFFFF, From e4b0ef428fb4ee3feed59df00f9a1c47f2bd1d12 Mon Sep 17 00:00:00 2001 From: LRFLEW Date: Thu, 23 Feb 2017 06:07:42 -0600 Subject: [PATCH 11/16] Update Xcode Project (#13) --- OpenRCT2.xcodeproj/project.pbxproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index b7715d83b8..82dca0f73d 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -243,6 +243,7 @@ D41B73EF1C2101890080A7B9 /* libcurl.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D41B73EE1C2101890080A7B9 /* libcurl.tbd */; }; D41B741D1C210A7A0080A7B9 /* libiconv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D41B741C1C210A7A0080A7B9 /* libiconv.tbd */; }; D41B74731C2125E50080A7B9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D41B74721C2125E50080A7B9 /* Assets.xcassets */; }; + D41FA8641E5EA1E200215624 /* wall.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D41FA8631E5EA1E200215624 /* wall.cpp */; }; D429FF421E36ABCD009342A6 /* tile_inspector.c in Sources */ = {isa = PBXBuildFile; fileRef = D429FF401E36ABCD009342A6 /* tile_inspector.c */; }; D433A5001E4A861F00D9A6DF /* SawyerChunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D433A4FA1E4A861F00D9A6DF /* SawyerChunk.cpp */; }; D433A5011E4A861F00D9A6DF /* SawyerChunkReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D433A4FC1E4A861F00D9A6DF /* SawyerChunkReader.cpp */; }; @@ -716,6 +717,7 @@ D41B73EE1C2101890080A7B9 /* libcurl.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libcurl.tbd; path = usr/lib/libcurl.tbd; sourceTree = SDKROOT; }; D41B741C1C210A7A0080A7B9 /* libiconv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libiconv.tbd; path = usr/lib/libiconv.tbd; sourceTree = SDKROOT; }; D41B74721C2125E50080A7B9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = distribution/macos/Assets.xcassets; sourceTree = SOURCE_ROOT; }; + D41FA8631E5EA1E200215624 /* wall.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wall.cpp; sourceTree = ""; }; D429FF3F1E36ABB3009342A6 /* tile_inspector.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tile_inspector.h; sourceTree = ""; }; D429FF401E36ABCD009342A6 /* tile_inspector.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tile_inspector.c; sourceTree = ""; }; D429FF411E36ABCD009342A6 /* tile_inspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tile_inspector.h; sourceTree = ""; }; @@ -2037,6 +2039,7 @@ D44271F31CC81B3200D84D28 /* sprite.h */, D429FF401E36ABCD009342A6 /* tile_inspector.c */, D429FF411E36ABCD009342A6 /* tile_inspector.h */, + D41FA8631E5EA1E200215624 /* wall.cpp */, D44271F41CC81B3200D84D28 /* water.h */, ); path = world; @@ -2916,6 +2919,7 @@ C686F9491CDBC3B7009F9BFC /* chairlift.c in Sources */, C686F9501CDBC3B7009F9BFC /* log_flume.c in Sources */, D464FEE81D31A6AA00CBABAC /* FootpathObject.cpp in Sources */, + D41FA8641E5EA1E200215624 /* wall.cpp in Sources */, D43407D61D0E14BE00C2B3D4 /* CopyFramebufferShader.cpp in Sources */, C6E96E231E04070E0076A04F /* scenario.c in Sources */, D44272241CC81B3200D84D28 /* intro.c in Sources */, From 3bb73986496b62bcdcb92405b5c1cac2439a33fd Mon Sep 17 00:00:00 2001 From: Duncan Date: Thu, 23 Feb 2017 12:48:41 +0000 Subject: [PATCH 12/16] Add static keyword to static functions --- src/openrct2/world/wall.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openrct2/world/wall.cpp b/src/openrct2/world/wall.cpp index 839d924575..6282040846 100644 --- a/src/openrct2/world/wall.cpp +++ b/src/openrct2/world/wall.cpp @@ -295,7 +295,7 @@ static const uint8 EdgeSlopes[][4] = { #pragma endregion -money32 WallPlace(uint8 wallType, +static money32 WallPlace(uint8 wallType, sint16 x, sint16 y, sint16 z, @@ -578,7 +578,7 @@ money32 WallPlace(uint8 wallType, } } -money32 WallRemove(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8 flags) +static money32 WallRemove(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8 flags) { if (!map_is_location_valid(x, y)) { @@ -640,7 +640,7 @@ money32 WallRemove(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8 return 0; } -money32 WallSetColour(sint16 x, +static money32 WallSetColour(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, From 7c17cef89cbb35f5792d58f77b04be0d87e12968 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Thu, 23 Feb 2017 20:18:34 +0000 Subject: [PATCH 13/16] Remove test code --- src/openrct2/rct12/SawyerChunkReader.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/openrct2/rct12/SawyerChunkReader.cpp b/src/openrct2/rct12/SawyerChunkReader.cpp index c0a37a5e08..65e3269f22 100644 --- a/src/openrct2/rct12/SawyerChunkReader.cpp +++ b/src/openrct2/rct12/SawyerChunkReader.cpp @@ -57,7 +57,6 @@ void SawyerChunkReader::SkipChunk() std::shared_ptr SawyerChunkReader::ReadChunk() { - Guard::Assert(false, "Test"); uint64 originalPosition = _stream->GetPosition(); try { From 7691dc3c1085691f901f06438ba0be34e96af6d2 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sat, 25 Feb 2017 09:19:31 +0000 Subject: [PATCH 14/16] Use functions to set and get secondary colour --- src/openrct2/paint/map_element/fence.c | 6 ++-- src/openrct2/ride/track_design_save.c | 4 +-- src/openrct2/windows/sign.c | 3 +- src/openrct2/world/banner.h | 3 +- src/openrct2/world/map.c | 16 ++++----- src/openrct2/world/map.h | 4 ++- src/openrct2/world/map_animation.c | 2 +- src/openrct2/world/wall.cpp | 49 ++++++++++++++++---------- 8 files changed, 48 insertions(+), 39 deletions(-) diff --git a/src/openrct2/paint/map_element/fence.c b/src/openrct2/paint/map_element/fence.c index 2514bbeb78..e574b49bcd 100644 --- a/src/openrct2/paint/map_element/fence.c +++ b/src/openrct2/paint/map_element/fence.c @@ -150,7 +150,7 @@ void fence_paint(uint8 direction, sint32 height, rct_map_element * map_element) uint32 dword_141F718 = imageColourFlags + 0x23800006; if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { - uint8 secondaryColour = (map_element->properties.wall.colour_1 >> 5) | ((map_element->flags & 0x60) >> 2); + uint8 secondaryColour = wall_element_get_secondary_colour(map_element); imageColourFlags |= secondaryColour << 24 | 0x80000000; } @@ -182,7 +182,7 @@ 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 = wall_get_animation_frame(map_element); + uint8 animationFrame = wall_element_get_animation_frame(map_element); // Add the direction as well animationFrame |= (map_element->properties.wall.animation & 0x80) >> 3; uint32 imageId; @@ -345,7 +345,7 @@ void fence_paint(uint8 direction, sint32 height, rct_map_element * map_element) set_format_arg(0, uint32, 0); set_format_arg(4, uint32, 0); - uint8 secondaryColour = map_element->properties.wall.colour_1 >> 5 | (map_element->flags & 0x60) >> 2; + uint8 secondaryColour = wall_element_get_secondary_colour(map_element); if (dword_141F710 != 0) { secondaryColour = COLOUR_GREY; diff --git a/src/openrct2/ride/track_design_save.c b/src/openrct2/ride/track_design_save.c index 2b14a4ac2d..511a710473 100644 --- a/src/openrct2/ride/track_design_save.c +++ b/src/openrct2/ride/track_design_save.c @@ -339,7 +339,7 @@ static void track_design_save_add_wall(sint32 x, sint32 y, rct_map_element *mapE flags |= mapElement->type & 3; flags |= mapElement->properties.wall.colour_3 << 2; - uint8 secondaryColour = ((mapElement->flags & 0x60) >> 2) | (mapElement->properties.wall.colour_1 >> 5); + uint8 secondaryColour = wall_element_get_secondary_colour(mapElement); uint8 primaryColour = mapElement->properties.wall.colour_1 & 0x1F; track_design_save_push_map_element(x, y, mapElement); @@ -522,7 +522,7 @@ static void track_design_save_remove_wall(sint32 x, sint32 y, rct_map_element *m flags |= mapElement->type & 3; flags |= mapElement->properties.wall.colour_3 << 2; - uint8 secondaryColour = ((mapElement->flags & 0x60) >> 2) | (mapElement->properties.wall.colour_1 >> 5); + uint8 secondaryColour = wall_element_get_secondary_colour(mapElement); uint8 primaryColour = mapElement->properties.wall.colour_1 & 0x1F; track_design_save_pop_map_element(x, y, mapElement); diff --git a/src/openrct2/windows/sign.c b/src/openrct2/windows/sign.c index dd5616fb6c..61fa5d7485 100644 --- a/src/openrct2/windows/sign.c +++ b/src/openrct2/windows/sign.c @@ -448,8 +448,7 @@ void window_sign_small_open(rct_windownumber number){ w->frame_no = view_z; w->list_information_type = map_element->properties.wall.colour_1 & 0x1F; - w->var_492 = - ((map_element->properties.wall.colour_1 >> 5) | ((map_element->flags & 0x60) >> 2)); + w->var_492 = wall_element_get_secondary_colour(map_element); w->var_48C = map_element->properties.wall.type; view_x += 16; diff --git a/src/openrct2/world/banner.h b/src/openrct2/world/banner.h index 7c142e2055..003d711e18 100644 --- a/src/openrct2/world/banner.h +++ b/src/openrct2/world/banner.h @@ -39,7 +39,8 @@ assert_struct_size(rct_banner, 8); enum{ BANNER_FLAG_NO_ENTRY = (1 << 0), BANNER_FLAG_IS_LARGE_SCENERY = (1 << 1), - BANNER_FLAG_LINKED_TO_RIDE = (1 << 2) + BANNER_FLAG_LINKED_TO_RIDE = (1 << 2), + BANNER_FLAG_4 = (1 << 3) }; extern rct_banner gBanners[MAX_BANNERS]; diff --git a/src/openrct2/world/map.c b/src/openrct2/world/map.c index 4c3abe91d7..ae2e214dce 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -4907,7 +4907,7 @@ void game_command_set_sign_style(sint32* eax, sint32* ebx, sint32* ecx, sint32* if (*ebp == 0) { // small sign rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32); - bool fence_found = false; + bool wall_found = false; do{ if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_WALL) continue; @@ -4917,11 +4917,11 @@ void game_command_set_sign_style(sint32* eax, sint32* ebx, sint32* ecx, sint32* continue; if (map_element->properties.wall.banner_index != bannerId) continue; - fence_found = true; + wall_found = true; break; } while (!map_element_is_last_for_tile(map_element++)); - if (fence_found == false) { + if (wall_found == false) { *ebx = MONEY32_UNDEFINED; return; } @@ -4930,13 +4930,9 @@ void game_command_set_sign_style(sint32* eax, sint32* ebx, sint32* ecx, sint32* *ebx = 0; return; } - - map_element->flags &= 0x9F; - map_element->properties.wall.colour_1 = - mainColour | - ((textColour & 0x7) << 5); - map_element->flags |= ((textColour & 0x18) << 2); - + map_element->properties.wall.colour_1 = mainColour; + wall_element_set_secondary_colour(map_element, textColour); + map_invalidate_tile(x, y, map_element->base_height * 8, map_element->clearance_height * 8); } else { // large sign rct_map_element *mapElement = banner_get_map_element(bannerId); diff --git a/src/openrct2/world/map.h b/src/openrct2/world/map.h index 549b319347..a8b98bc1de 100644 --- a/src/openrct2/world/map.h +++ b/src/openrct2/world/map.h @@ -540,6 +540,8 @@ 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_get_animation_frame(rct_map_element *fenceElement); +uint8 wall_element_get_animation_frame(rct_map_element *fenceElement); +uint8 wall_element_get_secondary_colour(rct_map_element * wallElement); +void wall_element_set_secondary_colour(rct_map_element * wallElement, uint8 secondaryColour); #endif diff --git a/src/openrct2/world/map_animation.c b/src/openrct2/world/map_animation.c index a0017f03e8..898457784e 100644 --- a/src/openrct2/world/map_animation.c +++ b/src/openrct2/world/map_animation.c @@ -474,7 +474,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_get_animation_frame(mapElement); + uint8 currentFrame = wall_element_get_animation_frame(mapElement); if (currentFrame != 0) { if (currentFrame == 15) { currentFrame = 0; diff --git a/src/openrct2/world/wall.cpp b/src/openrct2/world/wall.cpp index 6282040846..680d4ece96 100644 --- a/src/openrct2/world/wall.cpp +++ b/src/openrct2/world/wall.cpp @@ -346,7 +346,7 @@ static money32 WallPlace(uint8 wallType, } } - uint8 bp = 0; + uint8 edgeSlope = 0; if (position.z == 0) { rct_map_element * surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32); @@ -357,11 +357,11 @@ static money32 WallPlace(uint8 wallType, position.z = surfaceElement->base_height * 8; uint8 slope = surfaceElement->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK; - bp = EdgeSlopes[slope][edge & 3]; - if (bp & EDGE_SLOPE_ELEVATED) + edgeSlope = EdgeSlopes[slope][edge & 3]; + if (edgeSlope & EDGE_SLOPE_ELEVATED) { position.z += 16; - bp &= ~(1 << 0); + edgeSlope &= ~EDGE_SLOPE_ELEVATED; } } @@ -389,7 +389,7 @@ static money32 WallPlace(uint8 wallType, return MONEY32_UNDEFINED; } - if (!(bp & 0xC0)) + if (!(edgeSlope & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS))) { uint8 newEdge = (edge + 2) & 3; uint8 newBaseHeight = surfaceElement->base_height; @@ -473,7 +473,7 @@ static money32 WallPlace(uint8 wallType, rct_banner * banner = &gBanners[bannerIndex]; if (flags & GAME_COMMAND_FLAG_APPLY) { - banner->flags |= (1 << 3); + banner->flags |= BANNER_FLAG_4; banner->type = 0; banner->x = position.x / 32; banner->y = position.y / 32; @@ -488,7 +488,7 @@ static money32 WallPlace(uint8 wallType, } uint8 clearanceHeight = position.z / 8; - if (bp & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS)) + if (edgeSlope & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS)) { if (wallEntry->wall.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE) { @@ -537,11 +537,10 @@ static money32 WallPlace(uint8 wallType, mapElement->clearance_height = clearanceHeight; - mapElement->type = bp | edge | MAP_ELEMENT_TYPE_WALL; + mapElement->type = edgeSlope | edge | MAP_ELEMENT_TYPE_WALL; mapElement->properties.wall.colour_1 = primaryColour; - mapElement->properties.wall.colour_1 |= (secondaryColour & 7) << 5; - mapElement->flags |= (secondaryColour & 0x18) << 2; + wall_element_set_secondary_colour(mapElement, secondaryColour); if (wallAcrossTrack) { @@ -559,7 +558,7 @@ static money32 WallPlace(uint8 wallType, mapElement->properties.wall.colour_3 = tertiaryColour; } - if (flags & (1 << 6)) + if (flags & GAME_COMMAND_FLAG_GHOST) { mapElement->flags |= MAP_ELEMENT_FLAG_GHOST; } @@ -679,12 +678,8 @@ static money32 WallSetColour(sint16 x, if(flags & GAME_COMMAND_FLAG_APPLY) { rct_scenery_entry * scenery_entry = get_wall_entry(wallElement->properties.wall.type); - wallElement->properties.wall.colour_1 &= 0xE0; - wallElement->properties.wall.colour_1 |= primaryColour; - wallElement->properties.wall.colour_1 &= 0x1F; - wallElement->flags &= 0x9F; - wallElement->properties.wall.colour_1 |= (secondaryColour & 0x7) * 32; - wallElement->flags |= (secondaryColour & 0x18) * 4; + wallElement->properties.wall.colour_1 = primaryColour; + wall_element_set_secondary_colour(wallElement, secondaryColour); if(scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) { @@ -698,10 +693,26 @@ static money32 WallSetColour(sint16 x, extern "C" { - uint8 wall_get_animation_frame(rct_map_element * wallElement) { + uint8 wall_element_get_animation_frame(rct_map_element * wallElement) + { return (wallElement->properties.wall.animation >> 3) & 0xF; } - + + uint8 wall_element_get_secondary_colour(rct_map_element * wallElement) + { + uint8 secondaryColour = (wallElement->properties.wall.colour_1 & 0xE0) >> 5; + secondaryColour |= (wallElement->flags & 0x60) >> 2; + return secondaryColour; + } + + void wall_element_set_secondary_colour(rct_map_element * wallElement, uint8 secondaryColour) + { + wallElement->properties.wall.colour_1 &= 0x1F; + wallElement->properties.wall.colour_1 |= (secondaryColour & 0x7) << 5; + wallElement->flags &= 0x9F; + wallElement->flags |= (secondaryColour & 0x18) << 2; + } + /** * * rct2: 0x006E588E From adab7f7a6d5210c03796152b5c21fcd4d6ebf5d2 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sat, 25 Feb 2017 09:36:28 +0000 Subject: [PATCH 15/16] Add set animation frame function --- src/openrct2/paint/map_element/fence.c | 2 +- src/openrct2/ride/vehicle.c | 16 ++++++++-------- src/openrct2/world/map.h | 8 ++++++++ src/openrct2/world/map_animation.c | 6 ++---- src/openrct2/world/wall.cpp | 8 +++++++- 5 files changed, 26 insertions(+), 14 deletions(-) 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; From ece3be303cd7c469c8b6ee35866aeba18b607d25 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sun, 26 Feb 2017 09:04:32 +0000 Subject: [PATCH 16/16] Fix formating --- src/openrct2/paint/map_element/fence.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openrct2/paint/map_element/fence.c b/src/openrct2/paint/map_element/fence.c index 21d9fa781a..8aac062562 100644 --- a/src/openrct2/paint/map_element/fence.c +++ b/src/openrct2/paint/map_element/fence.c @@ -182,9 +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 = wall_element_get_animation_frame(map_element); - // Add the direction as well - animationFrame |= (map_element->properties.wall.animation & WALL_ANIMATION_FLAG_DIRECTION_BACKWARD) >> 3; + uint8 animationFrame = wall_element_get_animation_frame(map_element); + // Add the direction as well + animationFrame |= (map_element->properties.wall.animation & WALL_ANIMATION_FLAG_DIRECTION_BACKWARD) >> 3; uint32 imageId; switch (direction) { case 0: