mirror of https://github.com/OpenRCT2/OpenRCT2.git
Remove button works in MP
This moves the logic from the window file to the file in world/. It updates the window on all clients correctly.
This commit is contained in:
parent
88a0bb4270
commit
8a8e2c1cd6
|
@ -457,7 +457,7 @@ static rct_map_element tileInspectorCopiedElement;
|
|||
|
||||
static rct_map_element* window_tile_inspector_get_selected_element(rct_window *w);
|
||||
static void window_tile_inspector_load_tile(rct_window* w);
|
||||
static void window_tile_inspector_insert_corrupt_element(rct_window *w);
|
||||
static void window_tile_inspector_insert_corrupt_element(sint32 element_index);
|
||||
static void window_tile_inspector_swap_elements(sint16 first, sint16 second);
|
||||
static void window_tile_inspector_remove_element(sint32 index);
|
||||
static void window_tile_inspector_rotate_element(sint32 index);
|
||||
|
@ -607,13 +607,14 @@ static void window_tile_inspector_load_tile(rct_window* w)
|
|||
window_invalidate(w);
|
||||
}
|
||||
|
||||
static void window_tile_inspector_insert_corrupt_element(rct_window *w)
|
||||
static void window_tile_inspector_insert_corrupt_element(sint32 element_index)
|
||||
{
|
||||
assert(element_index < windowTileInspectorElementCount);
|
||||
game_do_command(
|
||||
TILE_INSPECTOR_ELEMENT_CORRUPT,
|
||||
GAME_COMMAND_FLAG_APPLY,
|
||||
windowTileInspectorTileX | (windowTileInspectorTileY << 8),
|
||||
w->selected_list_item,
|
||||
element_index,
|
||||
GAME_COMMAND_MODIFY_TILE,
|
||||
0,
|
||||
0
|
||||
|
@ -622,11 +623,15 @@ static void window_tile_inspector_insert_corrupt_element(rct_window *w)
|
|||
|
||||
static void window_tile_inspector_remove_element(sint32 index)
|
||||
{
|
||||
assert(index < windowTileInspectorElementCount);
|
||||
rct_map_element *const mapElement = map_get_first_element_at(windowTileInspectorTileX, windowTileInspectorTileY) + index;
|
||||
map_element_remove(mapElement);
|
||||
windowTileInspectorElementCount--;
|
||||
map_invalidate_tile_full(windowTileInspectorTileX << 5, windowTileInspectorTileY << 5);
|
||||
game_do_command(
|
||||
TILE_INSPECTOR_ELEMENT_ANY,
|
||||
GAME_COMMAND_FLAG_APPLY,
|
||||
windowTileInspectorTileX | (windowTileInspectorTileY << 8),
|
||||
index,
|
||||
GAME_COMMAND_MODIFY_TILE,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
static void window_tile_inspector_rotate_element(sint32 index)
|
||||
|
@ -1028,14 +1033,10 @@ static void window_tile_inspector_mouseup(rct_window *w, sint32 widgetIndex)
|
|||
window_tile_inspector_auto_set_buttons(w);
|
||||
break;
|
||||
case WIDX_BUTTON_CORRUPT:
|
||||
window_tile_inspector_insert_corrupt_element(w);
|
||||
window_tile_inspector_insert_corrupt_element(w->selected_list_item);
|
||||
break;
|
||||
case WIDX_BUTTON_REMOVE:
|
||||
window_tile_inspector_remove_element(w->selected_list_item);
|
||||
w->selected_list_item = -1;
|
||||
window_tile_inspector_set_page(w, PAGE_DEFAULT);
|
||||
window_tile_inspector_auto_set_buttons(w);
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_BUTTON_ROTATE:
|
||||
window_tile_inspector_rotate_element(w->selected_list_item);
|
||||
|
|
|
@ -5607,11 +5607,19 @@ void game_command_set_sign_style(sint32* eax, sint32* ebx, sint32* ecx, sint32*
|
|||
|
||||
void game_command_modify_tile(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp)
|
||||
{
|
||||
sint32 flags = *ebx;
|
||||
const sint32 flags = *ebx;
|
||||
const sint32 x = *ecx & 0xFF;
|
||||
const sint32 y = (*ecx >> 8) & 0xFF;
|
||||
const tile_inspector_element_type action_type = *eax;
|
||||
|
||||
switch (action_type)
|
||||
{
|
||||
case TILE_INSPECTOR_ELEMENT_ANY:
|
||||
{
|
||||
const sint16 index = *edx;
|
||||
*ebx = tile_inspector_remove_element_at(x, y, index, flags);
|
||||
return;
|
||||
}
|
||||
case TILE_INSPECTOR_ELEMENT_SURFACE:
|
||||
case TILE_INSPECTOR_ELEMENT_PATH:
|
||||
case TILE_INSPECTOR_ELEMENT_TRACK:
|
||||
|
@ -5623,8 +5631,6 @@ void game_command_modify_tile(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx
|
|||
return;
|
||||
case TILE_INSPECTOR_ELEMENT_CORRUPT:
|
||||
{
|
||||
const sint32 x = *ecx & 0xFF;
|
||||
const sint32 y = (*ecx >> 8) & 0xFF;
|
||||
const sint16 index = *edx;
|
||||
*ebx = tile_inspector_insert_corrupt_at(x, y, index, flags);
|
||||
return;
|
||||
|
|
|
@ -89,7 +89,7 @@ sint32 tile_inspector_insert_corrupt_at(sint32 x, sint32 y, sint16 element_index
|
|||
map_invalidate_tile_full(x << 5, y << 5);
|
||||
|
||||
// Update the tile inspector's list for everyone who has the tile selected
|
||||
rct_window *tile_inspector_window = window_find_by_class(WC_TILE_INSPECTOR);
|
||||
rct_window *const tile_inspector_window = window_find_by_class(WC_TILE_INSPECTOR);
|
||||
if (tile_inspector_window != NULL)
|
||||
{
|
||||
windowTileInspectorElementCount++;
|
||||
|
@ -113,3 +113,35 @@ sint32 tile_inspector_insert_corrupt_at(sint32 x, sint32 y, sint16 element_index
|
|||
// Nothing went wrong
|
||||
return 0;
|
||||
}
|
||||
|
||||
sint32 tile_inspector_remove_element_at(sint32 x, sint32 y, sint16 element_index, sint32 flags)
|
||||
{
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY)
|
||||
{
|
||||
// Forcefully the element
|
||||
rct_map_element *const mapElement = map_get_first_element_at(x, y) + element_index;
|
||||
map_element_remove(mapElement);
|
||||
windowTileInspectorElementCount--;
|
||||
map_invalidate_tile_full(x << 5, y << 5);
|
||||
|
||||
// Update the window
|
||||
rct_window *const tile_inspector_window = window_find_by_class(WC_TILE_INSPECTOR);
|
||||
if (tile_inspector_window != NULL)
|
||||
{
|
||||
if (tile_inspector_window->selected_list_item > element_index)
|
||||
{
|
||||
tile_inspector_window->selected_list_item--;
|
||||
}
|
||||
else if (tile_inspector_window->selected_list_item == element_index)
|
||||
{
|
||||
tile_inspector_window->selected_list_item = -1;
|
||||
window_tile_inspector_set_page(tile_inspector_window, PAGE_DEFAULT);
|
||||
}
|
||||
|
||||
window_tile_inspector_auto_set_buttons(tile_inspector_window);
|
||||
window_invalidate(tile_inspector_window);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -32,3 +32,4 @@ typedef enum {
|
|||
} tile_inspector_element_type;
|
||||
|
||||
sint32 tile_inspector_insert_corrupt_at(sint32 x, sint32 y, sint16 element_index, sint32 flags);
|
||||
sint32 tile_inspector_remove_element_at(sint32 x, sint32 y, sint16 element_index, sint32 flags);
|
||||
|
|
Loading…
Reference in New Issue