1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

Resolves #4559: Changes land rights buttons to be disabled if no tiles for sale remain

This commit changes the land rights button in the park window to be
disabled if there are no more land rights and construction rights for
sale. It also disables the individual land rights and construction
rights buttons in the land rights window itself if that specific type of
tile is no longer for sale.

This is implemented by introducing two new global variables called
gLandRemainingOwnershipSales and gLandRemainingConstructionSales. These
are updated by map_count_remaining_land_rights() to contain the number
of land rights and construction rights that remain for sale. This
function is called when a scenario is loaded and whenever the game
command to buy land rights or construction rights is invoked.

It also introduces three new tooltip strings that explain why the
buttons are disabled.
This commit is contained in:
Alexander Overvoorde
2016-10-31 20:21:10 +01:00
parent 5699b9e4ed
commit bb059a2741
8 changed files with 75 additions and 1 deletions

View File

@@ -4296,6 +4296,9 @@ STR_5984 :Blocked paths:
STR_5985 :New folder STR_5985 :New folder
STR_5986 :Type the name of the new folder. STR_5986 :Type the name of the new folder.
STR_5987 :Unable to create folder STR_5987 :Unable to create folder
STR_5988 :{SMALLFONT}{BLACK}No remaining land rights for sale
STR_5989 :{SMALLFONT}{BLACK}No remaining construction rights for sale
STR_5990 :{SMALLFONT}{BLACK}No remaining land rights or construction rights for sale
############# #############
# Scenarios # # Scenarios #

View File

@@ -3636,6 +3636,9 @@ enum {
STR_FILEBROWSER_ACTION_NEW_FOLDER = 5985, STR_FILEBROWSER_ACTION_NEW_FOLDER = 5985,
STR_FILEBROWSER_FOLDER_NAME_PROMPT = 5986, STR_FILEBROWSER_FOLDER_NAME_PROMPT = 5986,
STR_UNABLE_TO_CREATE_FOLDER = 5987, STR_UNABLE_TO_CREATE_FOLDER = 5987,
STR_NO_LAND_RIGHTS_FOR_SALE_TIP = 5988,
STR_NO_CONSTRUCTION_RIGHTS_FOR_SALE_TIP = 5989,
STR_NO_LAND_OR_CONSTRUCTION_RIGHTS_FOR_SALE_TIP = 5990,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
STR_COUNT = 32768 STR_COUNT = 32768

View File

@@ -279,6 +279,7 @@ void scenario_begin()
date_reset(); date_reset();
duck_remove_all(); duck_remove_all();
park_calculate_size(); park_calculate_size();
map_count_remaining_land_rights();
staff_reset_stats(); staff_reset_stats();
gLastEntranceStyle = RIDE_ENTRANCE_STYLE_PLAIN; gLastEntranceStyle = RIDE_ENTRANCE_STYLE_PLAIN;
memset(gMarketingCampaignDaysLeft, 0, 20); memset(gMarketingCampaignDaysLeft, 0, 20);

View File

@@ -208,6 +208,23 @@ static void window_land_rights_invalidate(rct_window *w)
window_land_rights_widgets[WIDX_PREVIEW].image = gLandToolSize <= 7 ? window_land_rights_widgets[WIDX_PREVIEW].image = gLandToolSize <= 7 ?
SPR_LAND_TOOL_SIZE_0 + gLandToolSize : SPR_LAND_TOOL_SIZE_0 + gLandToolSize :
0xFFFFFFFF; 0xFFFFFFFF;
// Disable ownership and/or construction buying functions if there're no tiles left for sale
if (gLandRemainingOwnershipSales == 0) {
w->disabled_widgets |= (1 << WIDX_BUY_LAND_RIGHTS);
window_land_rights_widgets[WIDX_BUY_LAND_RIGHTS].tooltip = STR_NO_LAND_RIGHTS_FOR_SALE_TIP;
} else {
w->disabled_widgets &= ~(1 << WIDX_BUY_LAND_RIGHTS);
window_land_rights_widgets[WIDX_BUY_LAND_RIGHTS].tooltip = STR_BUY_LAND_RIGHTS_TIP;
}
if (gLandRemainingConstructionSales == 0) {
w->disabled_widgets |= (1 << WIDX_BUY_CONSTRUCTION_RIGHTS);
window_land_rights_widgets[WIDX_BUY_CONSTRUCTION_RIGHTS].tooltip = STR_NO_CONSTRUCTION_RIGHTS_FOR_SALE_TIP;
} else {
w->disabled_widgets &= ~(1 << WIDX_BUY_CONSTRUCTION_RIGHTS);
window_land_rights_widgets[WIDX_BUY_CONSTRUCTION_RIGHTS].tooltip = STR_BUY_CONSTRUCTION_RIGHTS_TIP;
}
} }
static void window_land_rights_paint(rct_window *w, rct_drawpixelinfo *dpi) static void window_land_rights_paint(rct_window *w, rct_drawpixelinfo *dpi)

View File

@@ -1033,6 +1033,15 @@ static void window_park_entrance_invalidate(rct_window *w)
window_park_entrance_widgets[i].bottom = height + 23; window_park_entrance_widgets[i].bottom = height + 23;
height += 24; height += 24;
} }
// Disable land rights button if there's no more construction/ownership for sale
if (gLandRemainingOwnershipSales == 0 && gLandRemainingConstructionSales == 0) {
w->disabled_widgets |= (1 << WIDX_BUY_LAND_RIGHTS);
window_park_entrance_widgets[WIDX_BUY_LAND_RIGHTS].tooltip = STR_NO_LAND_OR_CONSTRUCTION_RIGHTS_FOR_SALE_TIP;
} else {
w->disabled_widgets &= ~(1 << WIDX_BUY_LAND_RIGHTS);
window_park_entrance_widgets[WIDX_BUY_LAND_RIGHTS].tooltip = STR_BUY_LAND_AND_CONSTRUCTION_RIGHTS_TIP;
}
} }
/** /**

View File

@@ -119,6 +119,9 @@ money32 gWaterToolRaiseCost;
money32 gWaterToolLowerCost; money32 gWaterToolLowerCost;
money32 gLandRightsCost; money32 gLandRightsCost;
uint16 gLandRemainingOwnershipSales;
uint16 gLandRemainingConstructionSales;
rct_xyz16 gCommandPosition; rct_xyz16 gCommandPosition;
uint8 gUnk9E2E28; uint8 gUnk9E2E28;
@@ -394,6 +397,31 @@ void map_init(int size)
climate_reset(CLIMATE_WARM); climate_reset(CLIMATE_WARM);
} }
/**
* Counts the number of surface tiles that offer land ownership rights for sale,
* but haven't been bought yet. It updates gLandRemainingOwnershipSales and
* gLandRemainingConstructionSales.
*/
void map_count_remaining_land_rights()
{
gLandRemainingOwnershipSales = 0;
gLandRemainingConstructionSales = 0;
for (int x = 0; x <= 255; x++) {
for (int y = 0; y <= 255; y++) {
rct_map_element *element = map_get_surface_element_at(x, y);
uint8 flags = element->properties.surface.ownership;
if ((flags & OWNERSHIP_AVAILABLE) && (flags & OWNERSHIP_OWNED) == 0) {
gLandRemainingOwnershipSales++;
} else if ((flags & OWNERSHIP_CONSTRUCTION_RIGHTS_AVAILABLE) && (flags & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED) == 0) {
gLandRemainingConstructionSales++;
}
}
}
}
/** /**
* *
* rct2: 0x0068AFFD * rct2: 0x0068AFFD

View File

@@ -384,11 +384,15 @@ extern money32 gWaterToolRaiseCost;
extern money32 gWaterToolLowerCost; extern money32 gWaterToolLowerCost;
extern money32 gLandRightsCost; extern money32 gLandRightsCost;
extern uint16 gLandRemainingOwnershipSales;
extern uint16 gLandRemainingConstructionSales;
extern rct_xyz16 gCommandPosition; extern rct_xyz16 gCommandPosition;
extern uint8 gUnk9E2E28; extern uint8 gUnk9E2E28;
void map_init(int size); void map_init(int size);
void map_count_remaining_land_rights();
void map_update_tile_pointers(); void map_update_tile_pointers();
rct_map_element *map_get_first_element_at(int x, int y); rct_map_element *map_get_first_element_at(int x, int y);
void map_set_tile_elements(int x, int y, rct_map_element *elements); void map_set_tile_elements(int x, int y, rct_map_element *elements);

View File

@@ -1114,14 +1114,23 @@ int map_buy_land_rights(int x0, int y0, int x1, int y1, int setting, int flags)
*/ */
void game_command_buy_land_rights(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp) void game_command_buy_land_rights(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp)
{ {
int flags = *ebx & 0xFFFF;
*ebx = map_buy_land_rights( *ebx = map_buy_land_rights(
(*eax & 0xFFFF), (*eax & 0xFFFF),
(*ecx & 0xFFFF), (*ecx & 0xFFFF),
(*edi & 0xFFFF), (*edi & 0xFFFF),
(*ebp & 0xFFFF), (*ebp & 0xFFFF),
(*edx & 0xFF00) >> 8, (*edx & 0xFF00) >> 8,
*ebx & 0xFFFF flags
); );
// Too expensive to always call in map_buy_land_rights.
// It's already counted when the park is loaded, after
// that it should only be called for user actions.
if (flags & GAME_COMMAND_FLAG_APPLY) {
map_count_remaining_land_rights();
}
} }