diff --git a/src/openrct2/editor.c b/src/openrct2/editor.c index 210541a289..f9b5ab9f33 100644 --- a/src/openrct2/editor.c +++ b/src/openrct2/editor.c @@ -625,7 +625,7 @@ void game_command_edit_scenario_options(sint32* eax, sint32* ebx, sint32* ecx, s gLandPrice = clamp(MONEY(5, 00), *edx, MONEY(200, 00)); break; case EDIT_SCENARIOOPTIONS_SETCOSTTOBUYCONSTRUCTIONRIGHTS: - gLandRightsCost = clamp(MONEY(5,00), *edx, MONEY(200,00)); + gConstructionRightsPrice = clamp(MONEY(5,00), *edx, MONEY(200,00)); break; case EDIT_SCENARIOOPTIONS_SETPARKCHARGEMETHOD: if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) { diff --git a/src/openrct2/interface/window.h b/src/openrct2/interface/window.h index 5c38425e14..f72def0a68 100644 --- a/src/openrct2/interface/window.h +++ b/src/openrct2/interface/window.h @@ -839,7 +839,6 @@ bool window_is_visible(rct_window* w); bool land_tool_is_active(); bool water_tool_is_active(); bool clear_scenery_tool_is_active(); -bool land_rights_tool_is_active(); bool scenery_tool_is_active(); //Cheat: in-game land ownership editor diff --git a/src/openrct2/windows/land_rights.c b/src/openrct2/windows/land_rights.c index f2d5a917b7..b8c8670560 100644 --- a/src/openrct2/windows/land_rights.c +++ b/src/openrct2/windows/land_rights.c @@ -58,6 +58,12 @@ static void window_land_rights_invalidate(rct_window *w); static void window_land_rights_paint(rct_window *w, rct_drawpixelinfo *dpi); static void window_land_rights_textinput(rct_window *w, rct_widgetindex widgetIndex, char *text); static void window_land_rights_inputsize(rct_window *w); +static void window_land_rights_toolupdate(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y); +static void window_land_rights_tooldown(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y); +static void window_land_rights_tooldrag(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y); +static void window_land_rights_toolabort(rct_window *w, rct_widgetindex widgetIndex); +static bool land_rights_tool_is_active(); + static rct_window_event_list window_land_rights_events = { window_land_rights_close, @@ -69,11 +75,11 @@ static rct_window_event_list window_land_rights_events = { window_land_rights_update, NULL, NULL, + window_land_rights_toolupdate, + window_land_rights_tooldown, + window_land_rights_tooldrag, NULL, - NULL, - NULL, - NULL, - NULL, + window_land_rights_toolabort, NULL, NULL, NULL, @@ -90,6 +96,12 @@ static rct_window_event_list window_land_rights_events = { NULL }; +#define LAND_RIGHTS_MODE_BUY_CONSTRUCTION_RIGHTS 0 +#define LAND_RIGHTS_MODE_BUY_LAND 1 + +static uint8 _landRightsMode; +static money32 _landRightsCost; + void window_land_rights_open() { rct_window* window; @@ -105,12 +117,14 @@ void window_land_rights_open() window_init_scroll_widgets(window); window_push_others_below(window); - LandRightsMode = true; + _landRightsMode = LAND_RIGHTS_MODE_BUY_LAND; window->pressed_widgets = (1 << WIDX_BUY_LAND_RIGHTS); gLandToolSize = 1; - gWaterToolRaiseCost = MONEY32_UNDEFINED; - gWaterToolLowerCost = MONEY32_UNDEFINED; + + show_gridlines(); + tool_set(window, WIDX_BUY_LAND_RIGHTS, TOOL_UP_ARROW); + input_set_flag(INPUT_FLAG_6, true); show_land_rights(); @@ -138,14 +152,14 @@ static void window_land_rights_mouseup(rct_window *w, rct_widgetindex widgetInde break; case WIDX_DECREMENT: // Decrement land rights tool size - gLandToolSize = max(MINIMUM_TOOL_SIZE, gLandToolSize-1); + gLandToolSize = max(MINIMUM_TOOL_SIZE, gLandToolSize - 1); // Invalidate the window window_invalidate(w); break; case WIDX_INCREMENT: // Decrement land rights tool size - gLandToolSize = min(MAXIMUM_TOOL_SIZE, gLandToolSize+1); + gLandToolSize = min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1); // Invalidate the window window_invalidate(w); @@ -154,18 +168,22 @@ static void window_land_rights_mouseup(rct_window *w, rct_widgetindex widgetInde window_land_rights_inputsize(w); break; case WIDX_BUY_LAND_RIGHTS: - if (!LandRightsMode) { - LandRightsMode = true; + if (_landRightsMode != LAND_RIGHTS_MODE_BUY_LAND) + { + _landRightsMode = LAND_RIGHTS_MODE_BUY_LAND; hide_construction_rights(); show_land_rights(); + tool_set(w, WIDX_BUY_LAND_RIGHTS, TOOL_UP_ARROW); window_invalidate(w); } break; case WIDX_BUY_CONSTRUCTION_RIGHTS: - if (LandRightsMode) { - LandRightsMode = false; + if (_landRightsMode != LAND_RIGHTS_MODE_BUY_CONSTRUCTION_RIGHTS) + { + _landRightsMode = LAND_RIGHTS_MODE_BUY_CONSTRUCTION_RIGHTS; hide_land_rights(); show_construction_rights(); + tool_set(w, WIDX_BUY_CONSTRUCTION_RIGHTS, TOOL_UP_ARROW); window_invalidate(w); } break; @@ -206,8 +224,8 @@ static void window_land_rights_update(rct_window *w) static void window_land_rights_invalidate(rct_window *w) { // Set the preview image button to be pressed down - w->pressed_widgets |= (1 << WIDX_PREVIEW) | (1 << (LandRightsMode ? WIDX_BUY_LAND_RIGHTS : WIDX_BUY_CONSTRUCTION_RIGHTS)); - w->pressed_widgets &= ~(1 << (!LandRightsMode ? WIDX_BUY_LAND_RIGHTS : WIDX_BUY_CONSTRUCTION_RIGHTS)); + w->pressed_widgets |= (1 << WIDX_PREVIEW) | (1 << ((_landRightsMode == LAND_RIGHTS_MODE_BUY_LAND) ? WIDX_BUY_LAND_RIGHTS : WIDX_BUY_CONSTRUCTION_RIGHTS)); + w->pressed_widgets &= ~(1 << ((_landRightsMode == LAND_RIGHTS_MODE_BUY_CONSTRUCTION_RIGHTS) ? WIDX_BUY_LAND_RIGHTS : WIDX_BUY_CONSTRUCTION_RIGHTS)); // Update the preview image window_land_rights_widgets[WIDX_PREVIEW].image = land_tool_size_to_sprite_index(gLandToolSize); @@ -246,9 +264,196 @@ static void window_land_rights_paint(rct_window *w, rct_drawpixelinfo *dpi) // Draw cost amount x = (window_land_rights_widgets[WIDX_PREVIEW].left + window_land_rights_widgets[WIDX_PREVIEW].right) / 2 + w->x; y = window_land_rights_widgets[WIDX_PREVIEW].bottom + w->y + 32; - if (gLandRightsCost != MONEY32_UNDEFINED && - gLandRightsCost != 0 + if (_landRightsCost != MONEY32_UNDEFINED && + _landRightsCost != 0 ) { - gfx_draw_string_centred(dpi, STR_COST_AMOUNT, x, y, COLOUR_BLACK, &gLandRightsCost); + gfx_draw_string_centred(dpi, STR_COST_AMOUNT, x, y, COLOUR_BLACK, &_landRightsCost); } } + +static void window_land_rights_tool_update_land_rights(sint16 x, sint16 y) +{ + map_invalidate_selection_rect(); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + + rct_xy16 mapTile = { 0 }; + screen_get_map_xy(x, y, &mapTile.x, &mapTile.y, NULL); + + if (mapTile.x == MAP_LOCATION_NULL) { + if (_landRightsCost != MONEY32_UNDEFINED) { + _landRightsCost = MONEY32_UNDEFINED; + window_invalidate_by_class(WC_CLEAR_SCENERY); + } + return; + } + + uint8 state_changed = 0; + + if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) { + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + state_changed++; + } + + if (gMapSelectType != MAP_SELECT_TYPE_FULL) { + gMapSelectType = MAP_SELECT_TYPE_FULL; + state_changed++; + } + + sint16 tool_size = gLandToolSize; + 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 (gMapSelectPositionA.x != mapTile.x){ + gMapSelectPositionA.x = mapTile.x; + state_changed++; + } + + if (gMapSelectPositionA.y != mapTile.y){ + gMapSelectPositionA.y = mapTile.y; + state_changed++; + } + + mapTile.x += tool_length; + mapTile.y += tool_length; + + if (gMapSelectPositionB.x != mapTile.x){ + gMapSelectPositionB.x = mapTile.x; + state_changed++; + } + + if (gMapSelectPositionB.y != mapTile.y){ + gMapSelectPositionB.y = mapTile.y; + state_changed++; + } + + map_invalidate_selection_rect(); + if (!state_changed) + return; + + _landRightsCost = game_do_command( + gMapSelectPositionA.x, + GAME_COMMAND_FLAG_2, + gMapSelectPositionA.y, + (_landRightsMode == LAND_RIGHTS_MODE_BUY_LAND) ? BUY_LAND_RIGHTS_FLAG_BUY_LAND : BUY_LAND_RIGHTS_FLAG_BUY_CONSTRUCTION_RIGHTS, + GAME_COMMAND_BUY_LAND_RIGHTS, + gMapSelectPositionB.x, + gMapSelectPositionB.y); +} + +/** + * + * rct2: 0x0066822A + */ +static void window_land_rights_toolabort(rct_window *w, rct_widgetindex widgetIndex) +{ + hide_gridlines(); + if (_landRightsMode == LAND_RIGHTS_MODE_BUY_LAND) + { + hide_land_rights(); + } + else + { + hide_construction_rights(); + } +} + +/** + * + * rct2: 0x006681D1 + */ +static void window_land_rights_toolupdate(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y) +{ + window_land_rights_tool_update_land_rights(x, y); +} + +/** + * + * rct2: 0x006681E6 + */ +static void window_land_rights_tooldown(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y) +{ + if (_landRightsMode == LAND_RIGHTS_MODE_BUY_LAND) + { + if (x != MAP_LOCATION_NULL) + { + gGameCommandErrorTitle = STR_CANT_BUY_LAND; + game_do_command( + gMapSelectPositionA.x, + GAME_COMMAND_FLAG_APPLY, + gMapSelectPositionA.y, + BUY_LAND_RIGHTS_FLAG_BUY_LAND, + GAME_COMMAND_BUY_LAND_RIGHTS, + gMapSelectPositionB.x, + gMapSelectPositionB.y); + } + } + else + { + if (x != MAP_LOCATION_NULL) + { + gGameCommandErrorTitle = STR_CANT_BUY_CONSTRUCTION_RIGHTS_HERE; + game_do_command( + gMapSelectPositionA.x, + GAME_COMMAND_FLAG_APPLY, + gMapSelectPositionA.y, + BUY_LAND_RIGHTS_FLAG_BUY_CONSTRUCTION_RIGHTS, + GAME_COMMAND_BUY_LAND_RIGHTS, + gMapSelectPositionB.x, + gMapSelectPositionB.y); + } + } +} + +/** + * + * rct2: 0x006681FB + */ +static void window_land_rights_tooldrag(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y) +{ + if (_landRightsMode == LAND_RIGHTS_MODE_BUY_LAND) { + if (x != MAP_LOCATION_NULL) + { + gGameCommandErrorTitle = STR_CANT_BUY_LAND; + game_do_command( + gMapSelectPositionA.x, + GAME_COMMAND_FLAG_APPLY, + gMapSelectPositionA.y, + BUY_LAND_RIGHTS_FLAG_BUY_LAND, + GAME_COMMAND_BUY_LAND_RIGHTS, + gMapSelectPositionB.x, + gMapSelectPositionB.y); + } + } + else + { + if (x != MAP_LOCATION_NULL) + { + gGameCommandErrorTitle = STR_CANT_BUY_CONSTRUCTION_RIGHTS_HERE; + game_do_command( + gMapSelectPositionA.x, + GAME_COMMAND_FLAG_APPLY, + gMapSelectPositionA.y, + BUY_LAND_RIGHTS_FLAG_BUY_CONSTRUCTION_RIGHTS, + GAME_COMMAND_BUY_LAND_RIGHTS, + gMapSelectPositionB.x, + gMapSelectPositionB.y); + } + } +} + +static bool land_rights_tool_is_active() +{ + if (!(input_test_flag(INPUT_FLAG_TOOL_ACTIVE))) + return false; + if (gCurrentToolWidget.window_classification != WC_LAND_RIGHTS) + return false; + return true; +} diff --git a/src/openrct2/windows/park.c b/src/openrct2/windows/park.c index 09309a22ba..6e05114bfa 100644 --- a/src/openrct2/windows/park.c +++ b/src/openrct2/windows/park.c @@ -67,7 +67,6 @@ enum WINDOW_PARK_WIDGET_IDX { WIDX_STATUS, WIDX_OPEN_OR_CLOSE, WIDX_BUY_LAND_RIGHTS, - //WIDX_BUY_CONSTRUCTION_RIGHTS, WIDX_LOCATE, WIDX_RENAME, WIDX_CLOSE_LIGHT, @@ -102,7 +101,6 @@ static rct_widget window_park_entrance_widgets[] = { { WWT_12, 1, 3, 204, 161, 171, 0xFFFFFFFF, STR_NONE }, // status { WWT_FLATBTN, 1, 205, 228, 49, 72, 0xFFFFFFFF, STR_OPEN_OR_CLOSE_PARK_TIP }, // open / close { WWT_FLATBTN, 1, 205, 228, 73, 96, SPR_BUY_LAND_RIGHTS, STR_BUY_LAND_AND_CONSTRUCTION_RIGHTS_TIP }, // buy land rights - //{ WWT_FLATBTN, 1, 205, 228, 97, 120, SPR_BUY_CONSTRUCTION_RIGHTS, STR_BUY_CONSTRUCTION_RIGHTS_TIP }, // buy construction rights { WWT_FLATBTN, 1, 205, 228, 97, 120, SPR_LOCATE, STR_LOCATE_SUBJECT_TIP }, // locate { WWT_FLATBTN, 1, 205, 228, 121, 144, SPR_RENAME, STR_NAME_PARK_TIP }, // rename { WWT_IMGBTN, 1, 210, 223, 51, 65, SPR_G2_RCT1_CLOSE_BUTTON_0, STR_CLOSE_PARK_TIP }, @@ -165,14 +163,9 @@ static void window_park_entrance_resize(rct_window *w); static void window_park_entrance_mousedown(rct_widgetindex widgetIndex, rct_window*w, rct_widget* widget); static void window_park_entrance_dropdown(rct_window *w, rct_widgetindex widgetIndex, sint32 dropdownIndex); static void window_park_entrance_update(rct_window *w); -static void window_park_entrance_toolupdate(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y); -static void window_park_entrance_tooldown(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y); -static void window_park_entrance_tooldrag(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y); -static void window_park_entrance_toolabort(rct_window *w, rct_widgetindex widgetIndex); static void window_park_entrance_textinput(rct_window *w, rct_widgetindex widgetIndex, char *text); static void window_park_entrance_invalidate(rct_window *w); static void window_park_entrance_paint(rct_window *w, rct_drawpixelinfo *dpi); -void toggle_land_rights_window(rct_window *parkWindow, rct_widgetindex widgetIndex); static void window_park_rating_mouseup(rct_window *w, rct_widgetindex widgetIndex); static void window_park_rating_resize(rct_window *w); @@ -222,11 +215,11 @@ static rct_window_event_list window_park_entrance_events = { window_park_entrance_update, NULL, NULL, - window_park_entrance_toolupdate, - window_park_entrance_tooldown, - window_park_entrance_tooldrag, NULL, - window_park_entrance_toolabort, + NULL, + NULL, + NULL, + NULL, NULL, NULL, NULL, @@ -454,7 +447,6 @@ static uint32 window_park_page_enabled_widgets[] = { (1 << WIDX_TAB_7) | (1 << WIDX_OPEN_OR_CLOSE) | (1 << WIDX_BUY_LAND_RIGHTS) | - //(1 << WIDX_BUY_CONSTRUCTION_RIGHTS) | (1 << WIDX_LOCATE) | (1 << WIDX_RENAME) | (1 << WIDX_CLOSE_LIGHT) | @@ -662,10 +654,8 @@ static void window_park_entrance_mouseup(rct_window *w, rct_widgetindex widgetIn window_park_set_page(w, widgetIndex - WIDX_TAB_1); break; case WIDX_BUY_LAND_RIGHTS: - toggle_land_rights_window(w, WIDX_BUY_LAND_RIGHTS); + window_land_rights_open(); break; - // case WIDX_BUY_CONSTRUCTION_RIGHTS: - // break; case WIDX_LOCATE: window_scroll_to_viewport(w); break; @@ -753,201 +743,6 @@ static void window_park_entrance_update(rct_window *w) widget_invalidate(w, WIDX_TAB_1); } - -static void window_park_entrance_tool_update_land_rights(sint16 x, sint16 y) -{ - map_invalidate_selection_rect(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - - rct_xy16 mapTile = { 0 }; - screen_get_map_xy(x, y, &mapTile.x, &mapTile.y, NULL); - - if (mapTile.x == MAP_LOCATION_NULL) { - if (gLandRightsCost != MONEY32_UNDEFINED) { - gLandRightsCost = MONEY32_UNDEFINED; - window_invalidate_by_class(WC_CLEAR_SCENERY); - } - return; - } - - uint8 state_changed = 0; - - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) { - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; - state_changed++; - } - - if (gMapSelectType != MAP_SELECT_TYPE_FULL) { - gMapSelectType = MAP_SELECT_TYPE_FULL; - state_changed++; - } - - sint16 tool_size = gLandToolSize; - 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 (gMapSelectPositionA.x != mapTile.x){ - gMapSelectPositionA.x = mapTile.x; - state_changed++; - } - - if (gMapSelectPositionA.y != mapTile.y){ - gMapSelectPositionA.y = mapTile.y; - state_changed++; - } - - mapTile.x += tool_length; - mapTile.y += tool_length; - - if (gMapSelectPositionB.x != mapTile.x){ - gMapSelectPositionB.x = mapTile.x; - state_changed++; - } - - if (gMapSelectPositionB.y != mapTile.y){ - gMapSelectPositionB.y = mapTile.y; - state_changed++; - } - - map_invalidate_selection_rect(); - if (!state_changed) - return; - - gLandRightsCost = game_do_command( - gMapSelectPositionA.x, - 0x4, - gMapSelectPositionA.y, - LandRightsMode ? 0x00E : 0x20F, - GAME_COMMAND_BUY_LAND_RIGHTS, - gMapSelectPositionB.x, - gMapSelectPositionB.y - ); -} - -/** - * - * rct2: 0x006681D1 - */ -static void window_park_entrance_toolupdate(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y) -{ - switch (widgetIndex){ - case WIDX_BUY_LAND_RIGHTS: - window_park_entrance_tool_update_land_rights(x, y); - break; - } -} - -/** - * - * rct2: 0x006681E6 - */ -static void window_park_entrance_tooldown(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y) -{ - switch (widgetIndex){ - case WIDX_BUY_LAND_RIGHTS: - if (LandRightsMode) { - if (x != MAP_LOCATION_NULL) { - gGameCommandErrorTitle = STR_CANT_BUY_LAND; - game_do_command( - gMapSelectPositionA.x, - 1, - gMapSelectPositionA.y, - 0x00E, - GAME_COMMAND_BUY_LAND_RIGHTS, - gMapSelectPositionB.x, - gMapSelectPositionB.y - ); - } - } - else { - if (x != MAP_LOCATION_NULL) { - gGameCommandErrorTitle = STR_CANT_BUY_CONSTRUCTION_RIGHTS_HERE; - game_do_command( - gMapSelectPositionA.x, - 1, - gMapSelectPositionA.y, - 0x20F, - GAME_COMMAND_BUY_LAND_RIGHTS, - gMapSelectPositionB.x, - gMapSelectPositionB.y - ); - } - } - break; - } -} - -/** - * - * rct2: 0x006681FB - */ -static void window_park_entrance_tooldrag(rct_window* w, rct_widgetindex widgetIndex, sint32 x, sint32 y) -{ - rct_window* w2 = window_find_by_number(0xB, 0); - - if (!w2) { - switch (widgetIndex){ - case WIDX_BUY_LAND_RIGHTS: - if (LandRightsMode) { - if (x != MAP_LOCATION_NULL) { - gGameCommandErrorTitle = STR_CANT_BUY_LAND; - game_do_command( - gMapSelectPositionA.x, - 1, - gMapSelectPositionA.y, - 0x00E, - GAME_COMMAND_BUY_LAND_RIGHTS, - gMapSelectPositionB.x, - gMapSelectPositionB.y - ); - } - } - else { - if (x != MAP_LOCATION_NULL) { - gGameCommandErrorTitle = STR_CANT_BUY_CONSTRUCTION_RIGHTS_HERE; - game_do_command( - gMapSelectPositionA.x, - 1, - gMapSelectPositionA.y, - 0x20F, - GAME_COMMAND_BUY_LAND_RIGHTS, - gMapSelectPositionB.x, - gMapSelectPositionB.y - ); - } - } - break; - } - } -} - -/** - * - * rct2: 0x0066822A - */ -static void window_park_entrance_toolabort(rct_window *w, rct_widgetindex widgetIndex) -{ - if (widgetIndex == WIDX_BUY_LAND_RIGHTS) { - hide_gridlines(); - if (LandRightsMode) - hide_land_rights(); - else - hide_construction_rights(); - } - //else if (widgetIndex == WIDX_BUY_CONSTRUCTION_RIGHTS) { - // hide_gridlines(); - // hide_construction_rights(); - //} -} - /** * * rct2: 0x0066848B @@ -1145,20 +940,6 @@ static void window_park_init_viewport(rct_window *w) window_invalidate(w); } -void toggle_land_rights_window(rct_window *parkWindow, rct_widgetindex widgetIndex) -{ - if ((input_test_flag(INPUT_FLAG_TOOL_ACTIVE)) && gCurrentToolWidget.window_classification == WC_PARK_INFORMATION && - gCurrentToolWidget.widget_index == WIDX_BUY_LAND_RIGHTS) { - tool_cancel(); - } - else { - show_gridlines(); - tool_set(parkWindow, widgetIndex, TOOL_UP_ARROW); - input_set_flag(INPUT_FLAG_6, true); - window_land_rights_open(); - } -} - #pragma endregion #pragma region Rating page diff --git a/src/openrct2/windows/top_toolbar.c b/src/openrct2/windows/top_toolbar.c index 7c81ac6dc9..bc4ee90583 100644 --- a/src/openrct2/windows/top_toolbar.c +++ b/src/openrct2/windows/top_toolbar.c @@ -3358,17 +3358,6 @@ bool clear_scenery_tool_is_active() return true; } -bool land_rights_tool_is_active() -{ - if (!(input_test_flag(INPUT_FLAG_TOOL_ACTIVE))) - return false; - if (gCurrentToolWidget.window_classification != WC_PARK_INFORMATION) - return false; - if (gCurrentToolWidget.widget_index != WIDX_PARK) - return false; - return true; -} - /** * * rct2: 0x0066DB3D diff --git a/src/openrct2/world/map.c b/src/openrct2/world/map.c index b3b1523b30..e68e547ceb 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -108,12 +108,10 @@ uint32 gNextFreeMapElementPointerIndex; bool gLandMountainMode; bool gLandPaintMode; -bool LandRightsMode; bool gClearSmallScenery; bool gClearLargeScenery; bool gClearFootpath; -money32 gLandRightsCost; uint16 gLandRemainingOwnershipSales; uint16 gLandRemainingConstructionSales; diff --git a/src/openrct2/world/map.h b/src/openrct2/world/map.h index d9e36d6aa1..5c2b7a4bb4 100644 --- a/src/openrct2/world/map.h +++ b/src/openrct2/world/map.h @@ -391,14 +391,11 @@ extern uint32 gNextFreeMapElementPointerIndex; extern bool gLandMountainMode; // Used in the land tool window to allow dragging and changing land styles extern bool gLandPaintMode; -// Used in the land rights tool window to either buy land rights or construction rights -extern bool LandRightsMode; // Used in the clear scenery tool extern bool gClearSmallScenery; extern bool gClearLargeScenery; extern bool gClearFootpath; -extern money32 gLandRightsCost; extern uint16 gLandRemainingOwnershipSales; extern uint16 gLandRemainingConstructionSales; diff --git a/src/openrct2/world/park.c b/src/openrct2/world/park.c index 3e1838cb51..bdf4a01fd0 100644 --- a/src/openrct2/world/park.c +++ b/src/openrct2/world/park.c @@ -875,7 +875,7 @@ static money32 map_buy_land_rights_for_tile(sint32 x, sint32 y, sint32 setting, return MONEY32_UNDEFINED; switch (setting) { - case 0: + case BUY_LAND_RIGHTS_FLAG_BUY_LAND: // 0 if ((surfaceElement->properties.surface.ownership & OWNERSHIP_OWNED) != 0) { // If the land is already owned return 0; } @@ -889,13 +889,13 @@ static money32 map_buy_land_rights_for_tile(sint32 x, sint32 y, sint32 setting, update_park_fences_around_tile(x, y); } return gLandPrice; - case 1: + case BUY_LAND_RIGHTS_FLAG_UNOWN_TILE: // 1 if (flags & GAME_COMMAND_FLAG_APPLY) { surfaceElement->properties.surface.ownership &= ~(OWNERSHIP_OWNED | OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED); update_park_fences_around_tile(x, y); } return 0; - case 2: + case BUY_LAND_RIGHTS_FLAG_BUY_CONSTRUCTION_RIGHTS: // 2 if ((surfaceElement->properties.surface.ownership & (OWNERSHIP_OWNED | OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED)) != 0) { // If the land or construction rights are already owned return 0; } @@ -911,21 +911,21 @@ static money32 map_buy_land_rights_for_tile(sint32 x, sint32 y, sint32 setting, map_invalidate_tile(x, y, baseHeight, baseHeight + 16); } return gConstructionRightsPrice; - case 3: + case BUY_LAND_RIGHTS_FLAG_UNOWN_CONSTRUCTION_RIGHTS: // 3 if (flags & GAME_COMMAND_FLAG_APPLY) { surfaceElement->properties.surface.ownership &= ~OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED; uint16 baseHeight = surfaceElement->base_height * 8; map_invalidate_tile(x, y, baseHeight, baseHeight + 16); } return 0; - case 4: + case BUY_LAND_RIGHTS_FLAG_SET_FOR_SALE: // 4 if (flags & GAME_COMMAND_FLAG_APPLY) { surfaceElement->properties.surface.ownership |= OWNERSHIP_AVAILABLE; uint16 baseHeight = surfaceElement->base_height * 8; map_invalidate_tile(x, y, baseHeight, baseHeight + 16); } return 0; - case 5: + case BUY_LAND_RIGHTS_FLAG_SET_CONSTRUCTION_RIGHTS_FOR_SALE: // 5 if (flags & GAME_COMMAND_FLAG_APPLY) { surfaceElement->properties.surface.ownership |= OWNERSHIP_CONSTRUCTION_RIGHTS_AVAILABLE; uint16 baseHeight = surfaceElement->base_height * 8; @@ -1040,7 +1040,7 @@ void game_command_buy_land_rights(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 (*ecx & 0xFFFF), (*edi & 0xFFFF), (*ebp & 0xFFFF), - (*edx & 0xFF00) >> 8, + (*edx & 0x00FF), flags ); diff --git a/src/openrct2/world/park.h b/src/openrct2/world/park.h index 9d9f530e67..5ca50ecf2e 100644 --- a/src/openrct2/world/park.h +++ b/src/openrct2/world/park.h @@ -45,6 +45,16 @@ enum { PARK_FLAGS_SIX_FLAGS_DEPRECATED = (1 << 19) // Not used anymore }; +enum +{ + BUY_LAND_RIGHTS_FLAG_BUY_LAND, + BUY_LAND_RIGHTS_FLAG_UNOWN_TILE, + BUY_LAND_RIGHTS_FLAG_BUY_CONSTRUCTION_RIGHTS, + BUY_LAND_RIGHTS_FLAG_UNOWN_CONSTRUCTION_RIGHTS, + BUY_LAND_RIGHTS_FLAG_SET_FOR_SALE, + BUY_LAND_RIGHTS_FLAG_SET_CONSTRUCTION_RIGHTS_FOR_SALE, +}; + extern rct_string_id gParkName; extern uint32 gParkNameArgs; extern uint32 gParkFlags;