From 577d1d1128aa804813253cf250c0ac072e8d9de7 Mon Sep 17 00:00:00 2001 From: Broxzier Date: Fri, 27 Jan 2017 14:19:23 +0100 Subject: [PATCH] Add diagonal toggle to MP --- src/openrct2/windows/tile_inspector.c | 27 ++++++------- src/openrct2/world/map.c | 5 +++ src/openrct2/world/tile_inspector.c | 56 ++++++++++++++++++++++++++- src/openrct2/world/tile_inspector.h | 2 + 4 files changed, 75 insertions(+), 15 deletions(-) diff --git a/src/openrct2/windows/tile_inspector.c b/src/openrct2/windows/tile_inspector.c index 9a5d677e0e..09af59c895 100644 --- a/src/openrct2/windows/tile_inspector.c +++ b/src/openrct2/windows/tile_inspector.c @@ -742,6 +742,19 @@ static void window_tile_inspector_surface_toggle_corner(sint32 cornerIndex) ); } +static void window_tile_inspector_surface_toggle_diagonal() +{ + game_do_command( + TILE_INSPECTOR_SURFACE_TOGGLE_DIAGONAL, + GAME_COMMAND_FLAG_APPLY, + windowTileInspectorTileX | (windowTileInspectorTileY << 8), + 0, + GAME_COMMAND_MODIFY_TILE, + 0, + 0 + ); +} + // Copied from track.c (track_remove), and modified for raising/lowering // Not sure if this should be in this file, track.c, or maybe another one static void window_tile_inspector_track_block_height_offset(rct_map_element *mapElement, uint8 offset) @@ -1050,19 +1063,7 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex) window_tile_inspector_surface_toggle_corner(((widgetIndex - WIDX_SURFACE_CHECK_CORNER_N) + 2 - get_current_rotation()) & 3); break; case WIDX_SURFACE_CHECK_DIAGONAL: - mapElement->properties.surface.slope ^= 0x10; - if (mapElement->properties.surface.slope & 0x10) { - mapElement->clearance_height = mapElement->base_height + 4; - } - else if (mapElement->properties.surface.slope & 0x0F) { - mapElement->clearance_height = mapElement->base_height + 2; - } - else { - mapElement->clearance_height = mapElement->base_height; - } - - map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5); - widget_invalidate(w, widgetIndex); + window_tile_inspector_surface_toggle_diagonal(); break; } // switch widgetindex break; diff --git a/src/openrct2/world/map.c b/src/openrct2/world/map.c index 0eb8e6bfc6..710a38f2c9 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -5672,6 +5672,11 @@ void game_command_modify_tile(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx *ebx = tile_inspector_surface_toggle_corner(x, y, corner_index, flags); return; } + case TILE_INSPECTOR_SURFACE_TOGGLE_DIAGONAL: + { + *ebx = tile_inspector_surface_toggle_diagonal(x, y, flags); + return; + } default: log_error("invalid instruction"); *ebx = MONEY32_UNDEFINED; diff --git a/src/openrct2/world/tile_inspector.c b/src/openrct2/world/tile_inspector.c index 11f8ec52b6..69746c86a7 100644 --- a/src/openrct2/world/tile_inspector.c +++ b/src/openrct2/world/tile_inspector.c @@ -335,7 +335,12 @@ sint32 tile_inspector_change_base_height_at(sint32 x, sint32 y, sint16 element_i map_element->clearance_height += height_offset; map_invalidate_tile_full(x << 5, y << 5); - window_invalidate_by_class(WC_TILE_INSPECTOR); + + rct_window *const tile_inspector_window = window_find_by_class(WC_TILE_INSPECTOR); + if (tile_inspector_window != NULL && (uint32)x == windowTileInspectorTileX && (uint32)y == windowTileInspectorTileY) + { + window_invalidate(tile_inspector_window); + } } return 0; @@ -357,6 +362,12 @@ sint32 tile_inspector_surface_show_park_fences(sint32 x, sint32 y, bool show_fen update_park_fences(x << 5, y << 5); map_invalidate_tile_full(x << 5, y << 5); + + rct_window *const tile_inspector_window = window_find_by_class(WC_TILE_INSPECTOR); + if (tile_inspector_window != NULL && (uint32)x == windowTileInspectorTileX && (uint32)y == windowTileInspectorTileY) + { + window_invalidate(tile_inspector_window); + } } return 0; @@ -407,7 +418,48 @@ sint32 tile_inspector_surface_toggle_corner(sint32 x, sint32 y, sint32 corner_in } map_invalidate_tile_full(x << 5, y << 5); - window_invalidate_by_class(WC_TILE_INSPECTOR); + + rct_window *const tile_inspector_window = window_find_by_class(WC_TILE_INSPECTOR); + if (tile_inspector_window != NULL && (uint32)x == windowTileInspectorTileX && (uint32)y == windowTileInspectorTileY) + { + window_invalidate(tile_inspector_window); + } + } + + return 0; +} + +sint32 tile_inspector_surface_toggle_diagonal(sint32 x, sint32 y, 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) + { + surface->properties.surface.slope ^= 0x10; + if (surface->properties.surface.slope & 0x10) + { + surface->clearance_height = surface->base_height + 4; + } + else if (surface->properties.surface.slope & 0x0F) + { + surface->clearance_height = surface->base_height + 2; + } + else + { + surface->clearance_height = surface->base_height; + } + + map_invalidate_tile_full(x << 5, y << 5); + + rct_window *const tile_inspector_window = window_find_by_class(WC_TILE_INSPECTOR); + if (tile_inspector_window != NULL && (uint32)x == windowTileInspectorTileX && (uint32)y == windowTileInspectorTileY) + { + window_invalidate(tile_inspector_window); + } } return 0; diff --git a/src/openrct2/world/tile_inspector.h b/src/openrct2/world/tile_inspector.h index 124acd6927..a181be6d7b 100644 --- a/src/openrct2/world/tile_inspector.h +++ b/src/openrct2/world/tile_inspector.h @@ -42,6 +42,7 @@ typedef enum { TILE_INSPECTOR_ANY_BASE_HEIGHT_OFFSET, TILE_INSPECTOR_SURFACE_SHOW_PARK_FENCES, TILE_INSPECTOR_SURFACE_TOGGLE_CORNER, + TILE_INSPECTOR_SURFACE_TOGGLE_DIAGONAL, } tile_inspector_instruction; sint32 tile_inspector_insert_corrupt_at(sint32 x, sint32 y, sint16 element_index, sint32 flags); @@ -53,3 +54,4 @@ 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_surface_show_park_fences(sint32 x, sint32 y, bool enabled, sint32 flags); sint32 tile_inspector_surface_toggle_corner(sint32 x, sint32 y, sint32 corner_index, sint32 flags); +sint32 tile_inspector_surface_toggle_diagonal(sint32 x, sint32 y, sint32 flags);