From c38f4b71711aaf8858f56fc40096ece929062c33 Mon Sep 17 00:00:00 2001 From: Broxzier Date: Fri, 27 Jan 2017 13:30:09 +0100 Subject: [PATCH] Add show/restore park fences to MP --- src/openrct2/game.c | 1 - src/openrct2/game.h | 1 - src/openrct2/windows/tile_inspector.c | 19 +++++++++++++++---- src/openrct2/world/map.c | 18 +++++++----------- src/openrct2/world/tile_inspector.c | 22 ++++++++++++++++++++++ src/openrct2/world/tile_inspector.h | 2 ++ 6 files changed, 46 insertions(+), 17 deletions(-) diff --git a/src/openrct2/game.c b/src/openrct2/game.c index 6aafeca295..43fa7e97a1 100644 --- a/src/openrct2/game.c +++ b/src/openrct2/game.c @@ -1246,5 +1246,4 @@ GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT] = { game_command_pickup_staff, game_command_balloon_press, game_command_modify_tile, - game_command_modify_element, }; diff --git a/src/openrct2/game.h b/src/openrct2/game.h index e75d9d7463..ff6c30c67b 100644 --- a/src/openrct2/game.h +++ b/src/openrct2/game.h @@ -94,7 +94,6 @@ enum GAME_COMMAND { GAME_COMMAND_PICKUP_STAFF, GAME_COMMAND_BALLOON_PRESS, GAME_COMMAND_MODIFY_TILE, - GAME_COMMAND_MODIFY_ELEMENT, GAME_COMMAND_COUNT }; diff --git a/src/openrct2/windows/tile_inspector.c b/src/openrct2/windows/tile_inspector.c index 6ef44bd352..78da4f448c 100644 --- a/src/openrct2/windows/tile_inspector.c +++ b/src/openrct2/windows/tile_inspector.c @@ -716,6 +716,19 @@ static void window_tile_inspector_base_height_offset(sint16 element_index, sint8 ); } +static void window_tile_inspector_surface_show_park_fences(bool show_fences) +{ + game_do_command( + TILE_INSPECTOR_SURFACE_SHOW_PARK_FENCES, + GAME_COMMAND_FLAG_APPLY, + windowTileInspectorTileX | (windowTileInspectorTileY << 8), + show_fences, + GAME_COMMAND_MODIFY_TILE, + 0, + 0 + ); +} + static void window_tile_inspector_surface_toggle_corner(rct_map_element *mapElement, sint32 cornerIndex) { const uint8 originalSlope = mapElement->properties.surface.slope; @@ -1044,12 +1057,10 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex) window_tile_inspector_base_height_offset(w->selected_list_item, -1); break; case WIDX_SURFACE_BUTTON_REMOVE_FENCES: - mapElement->properties.surface.ownership &= ~0x0F; - map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5); + window_tile_inspector_surface_show_park_fences(false); break; case WIDX_SURFACE_BUTTON_RESTORE_FENCES: - update_park_fences(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5); - map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5); + window_tile_inspector_surface_show_park_fences(true); break; case WIDX_SURFACE_CHECK_CORNER_N: case WIDX_SURFACE_CHECK_CORNER_E: diff --git a/src/openrct2/world/map.c b/src/openrct2/world/map.c index 80b5421b2d..852eeddea4 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -5642,7 +5642,7 @@ void game_command_modify_tile(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx case TILE_INSPECTOR_ANY_PASTE: { rct_map_element element_to_paste; - sint32 data[] = { *edx, *edi }; + const sint32 data[] = { *edx, *edi }; assert_struct_size(data, sizeof(element_to_paste)); memcpy(&element_to_paste, data, 8); *ebx = tile_inspector_paste_element_at(x, y, element_to_paste, flags); @@ -5660,6 +5660,12 @@ void game_command_modify_tile(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx *ebx = tile_inspector_change_base_height_at(x, y, element_index, height_offset, flags); return; } + case TILE_INSPECTOR_SURFACE_SHOW_PARK_FENCES: + { + const bool show_fences = *edx; + *ebx = tile_inspector_show_park_fences(x, y, show_fences, flags); + return; + } default: log_error("invalid instruction"); *ebx = MONEY32_UNDEFINED; @@ -5667,16 +5673,6 @@ void game_command_modify_tile(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx } } -void game_command_modify_element(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) -{ - log_info("Modifying element"); - if (*ebx & GAME_COMMAND_FLAG_APPLY) { - puts("Yeah baby"); - } - - *ebx = 0; -} - /** * Gets the track element at x, y, z. * @param x x units, not tiles. diff --git a/src/openrct2/world/tile_inspector.c b/src/openrct2/world/tile_inspector.c index 5f6dcc1099..b394d9c534 100644 --- a/src/openrct2/world/tile_inspector.c +++ b/src/openrct2/world/tile_inspector.c @@ -18,6 +18,7 @@ #include "../interface/window.h" #include "../windows/tile_inspector.h" #include "footpath.h" +#include "map.h" #include "tile_inspector.h" static void map_swap_elements_at(sint32 x, sint32 y, sint16 first, sint16 second) @@ -338,3 +339,24 @@ sint32 tile_inspector_change_base_height_at(sint32 x, sint32 y, sint16 element_i return 0; } + +sint32 tile_inspector_show_park_fences(sint32 x, sint32 y, bool show_fences, sint32 flags) +{ + rct_map_element *const surface = map_get_surface_element_at(x, y); + + // No surface element on tile + if (surface == NULL) + return MONEY32_UNDEFINED; + + if (flags & GAME_COMMAND_FLAG_APPLY) + { + if (!show_fences) + surface->properties.surface.ownership &= ~0x0F; + else + update_park_fences(x << 5, y << 5); + + map_invalidate_tile_full(x << 5, y << 5); + } + + return 0; +} diff --git a/src/openrct2/world/tile_inspector.h b/src/openrct2/world/tile_inspector.h index 8d5301c6e9..4e91b47964 100644 --- a/src/openrct2/world/tile_inspector.h +++ b/src/openrct2/world/tile_inspector.h @@ -40,6 +40,7 @@ typedef enum { TILE_INSPECTOR_ANY_PASTE, TILE_INSPECTOR_ANY_SORT, TILE_INSPECTOR_ANY_BASE_HEIGHT_OFFSET, + TILE_INSPECTOR_SURFACE_SHOW_PARK_FENCES, } tile_inspector_instruction; sint32 tile_inspector_insert_corrupt_at(sint32 x, sint32 y, sint16 element_index, sint32 flags); @@ -49,3 +50,4 @@ sint32 tile_inspector_rotate_element_at(sint32 x, sint32 y, sint32 element_index sint32 tile_inspector_paste_element_at(sint32 x, sint32 y, rct_map_element element, sint32 flags); sint32 tile_inspector_sort_elements_at(sint32 x, sint32 y, sint32 flags); sint32 tile_inspector_change_base_height_at(sint32 x, sint32 y, sint16 element_index, sint8 height_offset, sint32 flags); +sint32 tile_inspector_show_park_fences(sint32 x, sint32 y, bool enabled, sint32 flags);