From bc93ecaf30a882c8bffc0170c3a854b887f13d05 Mon Sep 17 00:00:00 2001 From: Broxzier Date: Tue, 7 Feb 2017 21:42:39 +0100 Subject: [PATCH] Add banner toggle for blocking paths to MP --- src/openrct2/windows/tile_inspector.c | 22 +++++++++++++++++++--- src/openrct2/world/map.c | 7 +++++++ src/openrct2/world/tile_inspector.c | 22 ++++++++++++++++++++++ src/openrct2/world/tile_inspector.h | 2 ++ 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/openrct2/windows/tile_inspector.c b/src/openrct2/windows/tile_inspector.c index 4d787dbb52..89fde9d838 100644 --- a/src/openrct2/windows/tile_inspector.c +++ b/src/openrct2/windows/tile_inspector.c @@ -852,6 +852,24 @@ static void window_tile_inspector_toggle_quadrant_collosion(sint32 element_index ); } +static void window_tile_inspector_banner_toggle_block(sint32 element_index, sint32 edge_index) +{ + openrct2_assert(edge_index >= 0 && edge_index < 4, "edge_index out of range"); + + // Make edge_index abstract + edge_index = (edge_index - get_current_rotation()) & 3; + + game_do_command( + TILE_INSPECTOR_BANNER_TOGGLE_BLOCKING_EDGE, + GAME_COMMAND_FLAG_APPLY, + windowTileInspectorTileX | (windowTileInspectorTileY << 8), + element_index, + GAME_COMMAND_MODIFY_TILE, + edge_index, + 0 + ); +} + static void window_tile_inspector_clamp_corrupt(sint32 element_index) { game_do_command( @@ -1094,9 +1112,7 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex) case WIDX_BANNER_CHECK_BLOCK_SE: case WIDX_BANNER_CHECK_BLOCK_SW: case WIDX_BANNER_CHECK_BLOCK_NW: - mapElement->properties.banner.flags ^= 1 << ((widgetIndex - WIDX_BANNER_CHECK_BLOCK_NE - get_current_rotation()) & 3); - map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5); - widget_invalidate(w, widgetIndex); + window_tile_inspector_banner_toggle_block(w->selected_list_item, widgetIndex - WIDX_BANNER_CHECK_BLOCK_NE); break; } // switch widget index break; diff --git a/src/openrct2/world/map.c b/src/openrct2/world/map.c index e7880f59d7..131060099c 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -5727,6 +5727,13 @@ void game_command_modify_tile(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx *ebx = tile_inspector_scenery_set_quarter_collision(x, y, element_index, quarter_index, flags); break; } + case TILE_INSPECTOR_BANNER_TOGGLE_BLOCKING_EDGE: + { + const sint32 element_index = *edx; + const sint32 edge_index = *edi; + *ebx = tile_inspector_banner_toggle_blocking_edge(x, y, element_index, edge_index, flags); + break; + } case TILE_INSPECTOR_CORRUPT_CLAMP: { const sint32 element_index = *edx; diff --git a/src/openrct2/world/tile_inspector.c b/src/openrct2/world/tile_inspector.c index 6b03a19fdf..f125dce7b8 100644 --- a/src/openrct2/world/tile_inspector.c +++ b/src/openrct2/world/tile_inspector.c @@ -855,6 +855,28 @@ sint32 tile_inspector_scenery_set_quarter_collision(sint32 x, sint32 y, sint32 e return 0; } +sint32 tile_inspector_banner_toggle_blocking_edge(sint32 x, sint32 y, sint32 element_index, sint32 edge_index, sint32 flags) +{ + rct_map_element *const bannerElement = map_get_first_element_at(x, y) + element_index; + + if (!bannerElement || map_element_get_type(bannerElement) != MAP_ELEMENT_TYPE_BANNER) + { + return MONEY32_UNDEFINED; + } + + if (flags & GAME_COMMAND_FLAG_APPLY) + { + bannerElement->properties.banner.flags ^= 1 << edge_index; + + if ((uint32)x == windowTileInspectorTileX && (uint32)y == windowTileInspectorTileY) + { + window_invalidate_by_class(WC_TILE_INSPECTOR); + } + } + + return 0; +} + sint32 tile_inspector_corrupt_clamp(sint32 x, sint32 y, sint32 element_index, sint32 flags) { rct_map_element *const corruptElement = map_get_first_element_at(x, y) + element_index; diff --git a/src/openrct2/world/tile_inspector.h b/src/openrct2/world/tile_inspector.h index c767e73a51..58b89e0f52 100644 --- a/src/openrct2/world/tile_inspector.h +++ b/src/openrct2/world/tile_inspector.h @@ -50,6 +50,7 @@ typedef enum { TILE_INSPECTOR_TRACK_SET_CHAIN, TILE_INSPECTOR_SCENERY_SET_QUARTER_LOCATION, TILE_INSPECTOR_SCENERY_SET_QUARTER_COLLISION, + TILE_INSPECTOR_BANNER_TOGGLE_BLOCKING_EDGE, TILE_INSPECTOR_CORRUPT_CLAMP, } tile_inspector_instruction; @@ -70,4 +71,5 @@ sint32 tile_inspector_track_base_height_offset(sint32 x, sint32 y, sint32 elemen sint32 tile_inspector_track_set_chain(sint32 x, sint32 y, sint32 element_index, bool entire_track_block, bool set_chain, sint32 flags); sint32 tile_inspector_scenery_set_quarter_location(sint32 x, sint32 y, sint32 element_index, sint32 quarter_index, sint32 flags); sint32 tile_inspector_scenery_set_quarter_collision(sint32 x, sint32 y, sint32 element_index, sint32 quarter_index, sint32 flags); +sint32 tile_inspector_banner_toggle_blocking_edge(sint32 x, sint32 y, sint32 element_index, sint32 edge_index, sint32 flags); sint32 tile_inspector_corrupt_clamp(sint32 x, sint32 y, sint32 element_index, sint32 flags);