Add show/restore park fences to MP

This commit is contained in:
Broxzier 2017-01-27 13:30:09 +01:00 committed by Michał Janiszewski
parent 044f9c60a9
commit c38f4b7171
6 changed files with 46 additions and 17 deletions

View File

@ -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,
};

View File

@ -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
};

View File

@ -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:

View File

@ -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.

View File

@ -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;
}

View File

@ -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);