Refactor map_is_location_owned to use CoordsXYZ

This commit is contained in:
duncanspumpkin 2019-08-11 07:56:00 +01:00
parent 7d2a7deb28
commit 9619fd384d
23 changed files with 30 additions and 34 deletions

View File

@ -296,7 +296,7 @@ int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_inter
}
else
{
if (!gCheatsSandboxMode && !map_is_location_owned(info->x, info->y, tileElement->base_height << 4))
if (!gCheatsSandboxMode && !map_is_location_owned({ info->x, info->y, tileElement->base_height << 4 }))
{
return info->type = VIEWPORT_INTERACTION_ITEM_NONE;
}

View File

@ -69,7 +69,7 @@ public:
}
if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode)
&& !map_is_location_owned(_loc.x, _loc.y, _loc.z))
&& !map_is_location_owned(_loc))
{
return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_BUILD_FOOTPATH_HERE, STR_LAND_NOT_OWNED_BY_PARK);
}

View File

@ -70,7 +70,7 @@ public:
}
if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode)
&& !map_is_location_owned(_loc.x, _loc.y, _loc.z))
&& !map_is_location_owned(_loc))
{
return MakeResult(GA_ERROR::DISALLOWED, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
}

View File

@ -53,8 +53,7 @@ public:
res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
res->Position = { _loc.x + 16, _loc.y + 16, _loc.z };
if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode)
&& !map_is_location_owned(_loc.x, _loc.y, _loc.z))
if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode) && !map_is_location_owned(_loc))
{
return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_LAND_NOT_OWNED_BY_PARK);
}

View File

@ -58,8 +58,7 @@ public:
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE, STR_OFF_EDGE_OF_MAP);
}
if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode)
&& !map_is_location_owned(_loc.x, _loc.y, _loc.z / 8))
if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode) && !map_is_location_owned(_loc))
{
return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
}

View File

@ -52,8 +52,7 @@ public:
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_OFF_EDGE_OF_MAP);
}
if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode)
&& !map_is_location_owned(_loc.x, _loc.y, _loc.z / 8))
if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode) && !map_is_location_owned(_loc))
{
return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
}

View File

@ -195,7 +195,7 @@ public:
return std::make_unique<LargeSceneryPlaceActionResult>(GA_ERROR::DISALLOWED, STR_OFF_EDGE_OF_MAP);
}
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !map_is_location_owned(curTile.x, curTile.y, zLow * 8)
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !map_is_location_owned({ curTile, zLow * 8 })
&& !gCheatsSandboxMode)
{
return std::make_unique<LargeSceneryPlaceActionResult>(GA_ERROR::DISALLOWED, STR_LAND_NOT_OWNED_BY_PARK);

View File

@ -96,7 +96,7 @@ public:
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode)
{
if (!map_is_location_owned(currentTile.x, currentTile.y, currentTile.z))
if (!map_is_location_owned({ currentTile.x, currentTile.y, currentTile.z }))
{
return MakeResult(GA_ERROR::NO_CLEARANCE, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
}
@ -167,7 +167,7 @@ public:
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode)
{
if (!map_is_location_owned(currentTile.x, currentTile.y, currentTile.z))
if (!map_is_location_owned({ currentTile.x, currentTile.y, currentTile.z }))
{
return MakeResult(GA_ERROR::NO_CLEARANCE, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
}

View File

@ -124,7 +124,7 @@ private:
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode)
{
if (!map_is_location_owned(currentTile.x, currentTile.y, currentTile.z))
if (!map_is_location_owned(currentTile))
{
return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK);
}

View File

@ -94,7 +94,7 @@ public:
return res;
}
if (!map_is_location_owned(floor2(_loc.x, 32), floor2(_loc.y, 32), _loc.z) && !gCheatsSandboxMode)
if (!map_is_location_owned(_loc) && !gCheatsSandboxMode)
{
res->Error = GA_ERROR::NOT_OWNED;
res->ErrorMessage = STR_LAND_NOT_OWNED_BY_PARK;

View File

@ -102,7 +102,7 @@ public:
auto z = ride->stations[_stationNum].Height * 8;
gCommandPosition.z = z;
if (!gCheatsSandboxMode && !map_is_location_owned(_loc.x, _loc.y, z))
if (!gCheatsSandboxMode && !map_is_location_owned({ _loc, z }))
{
return MakeResult(GA_ERROR::NOT_OWNED, errorTitle);
}
@ -245,7 +245,7 @@ public:
return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, errorTitle);
}
if (!gCheatsSandboxMode && !map_is_location_owned(loc.x, loc.y, loc.z))
if (!gCheatsSandboxMode && !map_is_location_owned(loc))
{
return MakeResult(GA_ERROR::NOT_OWNED, errorTitle);
}

View File

@ -180,7 +180,7 @@ public:
}
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode
&& !map_is_location_owned(_loc.x, _loc.y, targetHeight))
&& !map_is_location_owned({ _loc, targetHeight }))
{
return std::make_unique<SmallSceneryPlaceActionResult>(GA_ERROR::NOT_OWNED, STR_LAND_NOT_OWNED_BY_PARK);
}

View File

@ -86,7 +86,7 @@ public:
}
// Check if the land is owned
if (!map_is_location_owned(_loc.x, _loc.y, _loc.z))
if (!map_is_location_owned(_loc))
{
res->Error = GA_ERROR::NO_CLEARANCE;
res->ErrorTitle = STR_CANT_REMOVE_THIS;

View File

@ -84,7 +84,7 @@ private:
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode)
{
if (!map_is_location_owned(_loc.x, _loc.y, _loc.z))
if (!map_is_location_owned(_loc))
{
return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK);
}

View File

@ -172,7 +172,7 @@ public:
tileCoords.x += track.x;
tileCoords.y += track.y;
if (!map_is_location_owned(tileCoords.x, tileCoords.y, tileCoords.z) && !gCheatsSandboxMode)
if (!map_is_location_owned(tileCoords) && !gCheatsSandboxMode)
{
return std::make_unique<TrackPlaceActionResult>(GA_ERROR::DISALLOWED, STR_LAND_NOT_OWNED_BY_PARK);
}

View File

@ -122,7 +122,7 @@ public:
return std::make_unique<WallPlaceActionResult>(GA_ERROR::NOT_OWNED);
}
}
else if (!map_is_location_owned(_loc.x, _loc.y, _loc.z))
else if (!map_is_location_owned(_loc))
{
return std::make_unique<WallPlaceActionResult>(GA_ERROR::NOT_OWNED);
}

View File

@ -52,7 +52,7 @@ public:
const bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST;
if (!isGhost && !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode
&& !map_is_location_owned(_loc.x, _loc.y, _loc.z))
&& !map_is_location_owned({ _loc.x, _loc.y, _loc.z }))
{
return std::make_unique<GameActionResult>(GA_ERROR::NOT_OWNED, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
}

View File

@ -233,7 +233,7 @@ static void virtual_floor_get_tile_properties(
}
}
*tileOwned = map_is_location_owned(x, y, height);
*tileOwned = map_is_location_owned({ x, y, height });
if (gCheatsSandboxMode)
*tileOwned = true;

View File

@ -781,7 +781,7 @@ bool Peep::Place(TileCoordsXYZ location, bool apply)
destination.y += 16;
destination.z = tileElement->base_height * 8 + 16;
if (!map_is_location_owned(location.x * 32, location.y * 32, destination.z))
if (!map_is_location_owned({ location.x * 32, location.y * 32, destination.z }))
{
gGameCommandErrorTitle = STR_ERR_CANT_PLACE_PERSON_HERE;
return false;
@ -2821,7 +2821,7 @@ static void peep_interact_with_path(Peep* peep, int16_t x, int16_t y, TileElemen
}
int16_t z = tile_element->base_height * 8;
if (map_is_location_owned(x, y, z))
if (map_is_location_owned({ x, y, z }))
{
if (peep->outside_of_park == 1)
{

View File

@ -2117,7 +2117,7 @@ static money32 place_maze_design(uint8_t flags, Ride* ride, uint16_t mazeEntry,
if (!gCheatsSandboxMode)
{
if (!map_is_location_owned(floor2(x, 32), floor2(y, 32), z))
if (!map_is_location_owned({ x, y, z }))
{
return MONEY32_UNDEFINED;
}

View File

@ -752,7 +752,7 @@ bool map_can_build_at(int32_t x, int32_t y, int32_t z)
return true;
if (gCheatsSandboxMode)
return true;
if (map_is_location_owned(x, y, z))
if (map_is_location_owned({ x, y, z }))
return true;
return false;
}
@ -761,12 +761,12 @@ bool map_can_build_at(int32_t x, int32_t y, int32_t z)
*
* rct2: 0x00664F72
*/
bool map_is_location_owned(int32_t x, int32_t y, int32_t z)
bool map_is_location_owned(CoordsXYZ loc)
{
// This check is to avoid throwing lots of messages in logs.
if (map_is_location_valid({ x, y }))
if (map_is_location_valid({ loc.x, loc.y }))
{
TileElement* tileElement = map_get_surface_element_at({ x, y });
TileElement* tileElement = map_get_surface_element_at({ loc.x, loc.y });
if (tileElement != nullptr)
{
if (tileElement->AsSurface()->GetOwnership() & OWNERSHIP_OWNED)
@ -774,8 +774,7 @@ bool map_is_location_owned(int32_t x, int32_t y, int32_t z)
if (tileElement->AsSurface()->GetOwnership() & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED)
{
z /= 8;
if (z < tileElement->base_height || z - 2 > tileElement->base_height)
if (loc.z / 8 < tileElement->base_height || loc.z / 8 - 2 > tileElement->base_height)
return true;
}
}

View File

@ -162,7 +162,7 @@ void map_update_path_wide_flags();
bool map_is_location_valid(CoordsXY coords);
bool map_is_edge(CoordsXY coords);
bool map_can_build_at(int32_t x, int32_t y, int32_t z);
bool map_is_location_owned(int32_t x, int32_t y, int32_t z);
bool map_is_location_owned(CoordsXYZ loc);
bool map_is_location_in_park(CoordsXY coords);
bool map_is_location_owned_or_has_rights(int32_t x, int32_t y);
bool map_surface_is_blocked(int16_t x, int16_t y);

View File

@ -707,7 +707,7 @@ static bool litter_can_be_at(int32_t x, int32_t y, int32_t z)
{
TileElement* tileElement;
if (!map_is_location_owned(x & 0xFFE0, y & 0xFFE0, z))
if (!map_is_location_owned({ x, y, z }))
return false;
tileElement = map_get_first_element_at(x >> 5, y >> 5);