mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 13:42:55 +01:00
improve clear scenery tool
This commit is contained in:
@@ -661,6 +661,8 @@ enum {
|
||||
STR_CANT_OPEN_PARK = 1723,
|
||||
STR_CANT_CLOSE_PARK = 1724,
|
||||
|
||||
STR_LAND_NOT_OWNED_BY_PARK = 1729,
|
||||
|
||||
STR_BANNER_TEXT = 1731,
|
||||
|
||||
STR_RIDE_CONSTRUCTION_BUILD = 1732,
|
||||
|
||||
@@ -822,7 +822,7 @@ int map_is_location_owned(int x, int y, int z)
|
||||
}
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 1729;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_LAND_NOT_OWNED_BY_PARK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -840,10 +840,22 @@ int map_is_location_in_park(int x, int y)
|
||||
return 1;
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 1729;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_LAND_NOT_OWNED_BY_PARK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool map_is_location_owned_or_has_rights(int x, int y)
|
||||
{
|
||||
rct_map_element *mapElement;
|
||||
|
||||
if (x < (256 * 32) && y < (256 * 32)) {
|
||||
mapElement = map_get_surface_element_at(x / 32, y / 32);
|
||||
if (mapElement->properties.surface.ownership & OWNERSHIP_OWNED) return true;
|
||||
if (mapElement->properties.surface.ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E0E01
|
||||
@@ -1446,6 +1458,7 @@ money32 map_clear_scenery(int x0, int y0, int x1, int y1, int flags)
|
||||
{
|
||||
int x, y, z;
|
||||
money32 totalCost, cost;
|
||||
bool noValidTiles;
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_LANDSCAPING * 4;
|
||||
|
||||
@@ -1461,18 +1474,23 @@ money32 map_clear_scenery(int x0, int y0, int x1, int y1, int flags)
|
||||
x1 = min(x1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16));
|
||||
y1 = min(y1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16));
|
||||
|
||||
noValidTiles = true;
|
||||
totalCost = 0;
|
||||
for (y = y0; y <= y1; y += 32) {
|
||||
for (x = x0; x <= x1; x += 32) {
|
||||
cost = map_clear_scenery_from_tile(x / 32, y / 32, flags);
|
||||
if (cost == MONEY32_UNDEFINED)
|
||||
return MONEY32_UNDEFINED;
|
||||
|
||||
totalCost += cost;
|
||||
if (gCheatsSandboxMode || map_is_location_owned_or_has_rights(x, y)) {
|
||||
cost = map_clear_scenery_from_tile(x / 32, y / 32, flags);
|
||||
if (cost != MONEY32_UNDEFINED) {
|
||||
noValidTiles = false;
|
||||
totalCost += cost;
|
||||
}
|
||||
} else {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_LAND_NOT_OWNED_BY_PARK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return totalCost;
|
||||
return noValidTiles ? MONEY32_UNDEFINED : totalCost;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -287,6 +287,7 @@ int map_coord_is_connected(int x, int y, int z, uint8 faceDirection);
|
||||
void sub_6A876D();
|
||||
int map_is_location_owned(int x, int y, int z);
|
||||
int map_is_location_in_park(int x, int y);
|
||||
bool map_is_location_owned_or_has_rights(int x, int y);
|
||||
bool map_surface_is_blocked(sint16 x, sint16 y);
|
||||
int map_get_station(rct_map_element *mapElement);
|
||||
void map_element_remove(rct_map_element *mapElement);
|
||||
|
||||
Reference in New Issue
Block a user