1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-17 12:03:07 +01:00

Add setting slope for fences to MP

This commit is contained in:
Broxzier
2017-02-02 20:06:27 +01:00
committed by Michał Janiszewski
parent 31aa7f045a
commit 1a611bc5be
4 changed files with 53 additions and 2 deletions

View File

@@ -769,6 +769,22 @@ static void window_tile_inspector_path_toggle_edge(sint32 element_index, sint32
);
}
static void window_tile_inspector_fence_set_slope(sint32 element_index, sint32 slope_value)
{
// Make sure only the correct bits are set
assert((slope_value & 0xC0) == slope_value);
game_do_command(
TILE_INSPECTOR_FENCE_SET_SLOPE,
GAME_COMMAND_FLAG_APPLY,
windowTileInspectorTileX | (windowTileInspectorTileY << 8),
element_index,
GAME_COMMAND_MODIFY_TILE,
slope_value,
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)
@@ -1326,8 +1342,7 @@ static void window_tile_inspector_dropdown(rct_window *w, sint32 widgetIndex, si
switch (widgetIndex) {
case WIDX_FENCE_DROPDOWN_SLOPE_BUTTON:
mapElement->type &= ~0xC0;
mapElement->type |= dropdownIndex << 6;
window_tile_inspector_fence_set_slope(w->selected_list_item, dropdownIndex << 6);
break;
}
break;

View File

@@ -5684,6 +5684,13 @@ void game_command_modify_tile(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx
*ebx = tile_inspector_path_toggle_edge(x, y, element_index, edge_index, flags);
return;
}
case TILE_INSPECTOR_FENCE_SET_SLOPE:
{
const sint32 element_index = *edx;
const sint32 slope_value = *edi;
*ebx = tile_inspector_fence_set_slope(x, y, element_index, slope_value, flags);
return;
}
default:
log_error("invalid instruction");
*ebx = MONEY32_UNDEFINED;

View File

@@ -484,3 +484,30 @@ sint32 tile_inspector_path_toggle_edge(sint32 x, sint32 y, sint32 element_index,
return 0;
}
sint32 tile_inspector_fence_set_slope(sint32 x, sint32 y, sint32 element_index, sint32 slope_value, sint32 flags)
{
rct_map_element *const fence_element = map_get_first_element_at(x, y) + element_index;
if (!fence_element || map_element_get_type(fence_element) != MAP_ELEMENT_TYPE_FENCE)
{
return MONEY32_UNDEFINED;
}
if (flags & GAME_COMMAND_FLAG_APPLY)
{
// Set new slope value
fence_element->type &= ~0xC0;
fence_element->type |= slope_value;
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;
}

View File

@@ -44,6 +44,7 @@ typedef enum {
TILE_INSPECTOR_SURFACE_TOGGLE_CORNER,
TILE_INSPECTOR_SURFACE_TOGGLE_DIAGONAL,
TILE_INSPECTOR_PATH_TOGGLE_EDGE,
TILE_INSPECTOR_FENCE_SET_SLOPE,
} tile_inspector_instruction;
sint32 tile_inspector_insert_corrupt_at(sint32 x, sint32 y, sint16 element_index, sint32 flags);
@@ -57,3 +58,4 @@ sint32 tile_inspector_surface_show_park_fences(sint32 x, sint32 y, bool enabled,
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);
sint32 tile_inspector_path_toggle_edge(sint32 x, sint32 y, sint32 element_index, sint32 corner_index, sint32 flags);
sint32 tile_inspector_fence_set_slope(sint32 x, sint32 y, sint32 element_index, sint32 slope_value, sint32 flags);