Implemented clear scenery update

Not tested.
This commit is contained in:
Duncan Frost 2015-05-25 17:24:18 +01:00
parent 7c29d781dc
commit 54a37edb44
2 changed files with 86 additions and 1 deletions

View File

@ -1535,6 +1535,90 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window* w
}
}
/**
*
* rct2: 0x0068E213
*/
void sub_68E213(sint16 x, sint16 y){
map_invalidate_selection_rect();
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0);
rct_xy16 mapTile = { 0 };
sub_688972(x, y, &mapTile.x, &mapTile.y, NULL);
if (mapTile.x == (sint16)0x8000){
if (RCT2_GLOBAL(0x00F1AD62, money32) != MONEY32_UNDEFINED){
RCT2_GLOBAL(0x00F1AD62, money32) = MONEY32_UNDEFINED;
window_invalidate_by_class(WC_CLEAR_SCENERY);
return;
}
}
uint8 state_changed = 0;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 0))){
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0);
state_changed++;
}
if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) != 4){
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4;
state_changed++;
}
sint16 tool_size = RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16);
if (tool_size == 0)
tool_size = 1;
sint16 tool_length = (tool_size - 1) * 32;
// Move to tool bottom left
mapTile.x -= (tool_size - 1) * 16;
mapTile.y -= (tool_size - 1) * 16;
mapTile.x &= 0xFFE0;
mapTile.y &= 0xFFE0;
if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) != mapTile.x){
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) = mapTile.x;
state_changed++;
}
if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) != mapTile.y){
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = mapTile.y;
state_changed++;
}
mapTile.x += tool_length;
mapTile.y += tool_length;
if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) != mapTile.x){
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = mapTile.x;
state_changed++;
}
if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) != mapTile.y){
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = mapTile.y;
state_changed++;
}
map_invalidate_selection_rect();
if (!state_changed)
return;
money32 cost = map_clear_scenery(
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16),
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16),
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16),
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16),
0);
if (RCT2_GLOBAL(0x00F1AD62, money32) != cost){
RCT2_GLOBAL(0x00F1AD62, money32) = cost;
window_invalidate_by_class(WC_CLEAR_SCENERY);
return;
}
}
/**
*
* rct2: 0x0066CB25
@ -1549,7 +1633,7 @@ static void window_top_toolbar_tool_update()
switch (widgetIndex){
case WIDX_CLEAR_SCENERY:
RCT2_CALLPROC_X(0x0068E213, x, y, 0, widgetIndex, (int)w, 0, 0);
sub_68E213(x, y);
break;
case WIDX_LAND:
if (LandPaintMode)

View File

@ -279,6 +279,7 @@ rct_map_element *map_element_insert(int x, int y, int z, int flags);
int map_can_construct_with_clear_at(int x, int y, int zLow, int zHigh, void *clearFunc, uint8 bl);
int map_can_construct_at(int x, int y, int zLow, int zHigh, uint8 bl);
int sub_6BA278(int ebx);
money32 map_clear_scenery(int x0, int y0, int x1, int y1, int flags);
void game_command_remove_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp);
void game_command_remove_large_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp);