Refactor map_can_build_at to use CoordsXYZ

This commit is contained in:
duncanspumpkin 2019-08-12 18:20:27 +01:00
parent 5333dc4295
commit 0a1cb68328
5 changed files with 6 additions and 6 deletions

View File

@ -72,7 +72,7 @@ public:
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE, STR_CAN_ONLY_BE_BUILT_ACROSS_PATHS);
}
if (!map_can_build_at(_loc.x, _loc.y, _loc.z))
if (!map_can_build_at({ _loc.x, _loc.y, _loc.z }))
{
return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
}

View File

@ -48,7 +48,7 @@ public:
res->Position.z = _loc.z;
res->ErrorTitle = STR_CANT_REMOVE_THIS;
if (!map_can_build_at(_loc.x, _loc.y, _loc.z - 16))
if (!map_can_build_at({ _loc.x, _loc.y, _loc.z - 16 }))
{
return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
}

View File

@ -74,7 +74,7 @@ private:
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS);
}
if (!map_can_build_at(_loc.x, _loc.y, _loc.z - 16))
if (!map_can_build_at({ _loc.x, _loc.y, _loc.z - 16 }))
{
return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK);
}

View File

@ -742,13 +742,13 @@ bool map_is_edge(const CoordsXY coords)
return (coords.x < 32 || coords.y < 32 || coords.x >= gMapSizeUnits || coords.y >= gMapSizeUnits);
}
bool map_can_build_at(int32_t x, int32_t y, int32_t z)
bool map_can_build_at(CoordsXYZ loc)
{
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
return true;
if (gCheatsSandboxMode)
return true;
if (map_is_location_owned({ x, y, z }))
if (map_is_location_owned(loc))
return true;
return false;
}

View File

@ -161,7 +161,7 @@ void map_restore_provisional_elements();
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_can_build_at(CoordsXYZ loc);
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);