diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 7d89f62318..d61a935b82 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -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; } diff --git a/src/openrct2/actions/FootpathPlaceAction.hpp b/src/openrct2/actions/FootpathPlaceAction.hpp index be47524587..91e176353f 100644 --- a/src/openrct2/actions/FootpathPlaceAction.hpp +++ b/src/openrct2/actions/FootpathPlaceAction.hpp @@ -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); } diff --git a/src/openrct2/actions/FootpathPlaceFromTrackAction.hpp b/src/openrct2/actions/FootpathPlaceFromTrackAction.hpp index 0a1f675a3b..8226fb13ee 100644 --- a/src/openrct2/actions/FootpathPlaceFromTrackAction.hpp +++ b/src/openrct2/actions/FootpathPlaceFromTrackAction.hpp @@ -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); } diff --git a/src/openrct2/actions/FootpathRemoveAction.hpp b/src/openrct2/actions/FootpathRemoveAction.hpp index 878cf51375..b3ba4c3803 100644 --- a/src/openrct2/actions/FootpathRemoveAction.hpp +++ b/src/openrct2/actions/FootpathRemoveAction.hpp @@ -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); } diff --git a/src/openrct2/actions/FootpathSceneryPlaceAction.hpp b/src/openrct2/actions/FootpathSceneryPlaceAction.hpp index b8fc4e21e2..122c387b0d 100644 --- a/src/openrct2/actions/FootpathSceneryPlaceAction.hpp +++ b/src/openrct2/actions/FootpathSceneryPlaceAction.hpp @@ -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); } diff --git a/src/openrct2/actions/FootpathSceneryRemoveAction.hpp b/src/openrct2/actions/FootpathSceneryRemoveAction.hpp index 70b40ff6d9..02752e9014 100644 --- a/src/openrct2/actions/FootpathSceneryRemoveAction.hpp +++ b/src/openrct2/actions/FootpathSceneryRemoveAction.hpp @@ -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); } diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.hpp b/src/openrct2/actions/LargeSceneryPlaceAction.hpp index 12f54c2eca..914fde12fa 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.hpp +++ b/src/openrct2/actions/LargeSceneryPlaceAction.hpp @@ -195,7 +195,7 @@ public: return std::make_unique(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(GA_ERROR::DISALLOWED, STR_LAND_NOT_OWNED_BY_PARK); diff --git a/src/openrct2/actions/LargeSceneryRemoveAction.hpp b/src/openrct2/actions/LargeSceneryRemoveAction.hpp index 3915c03952..0695e6882f 100644 --- a/src/openrct2/actions/LargeSceneryRemoveAction.hpp +++ b/src/openrct2/actions/LargeSceneryRemoveAction.hpp @@ -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); } diff --git a/src/openrct2/actions/LargeScenerySetColourAction.hpp b/src/openrct2/actions/LargeScenerySetColourAction.hpp index 7cfff25de3..6fe1e58f2c 100644 --- a/src/openrct2/actions/LargeScenerySetColourAction.hpp +++ b/src/openrct2/actions/LargeScenerySetColourAction.hpp @@ -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); } diff --git a/src/openrct2/actions/MazeSetTrackAction.hpp b/src/openrct2/actions/MazeSetTrackAction.hpp index 7a12b7e38a..ec3fbb7b4d 100644 --- a/src/openrct2/actions/MazeSetTrackAction.hpp +++ b/src/openrct2/actions/MazeSetTrackAction.hpp @@ -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; diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.hpp b/src/openrct2/actions/RideEntranceExitPlaceAction.hpp index 7dbe2c6d05..4643840fb0 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.hpp +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.hpp @@ -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); } diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.hpp b/src/openrct2/actions/SmallSceneryPlaceAction.hpp index 99f6462456..360b22d955 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.hpp +++ b/src/openrct2/actions/SmallSceneryPlaceAction.hpp @@ -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(GA_ERROR::NOT_OWNED, STR_LAND_NOT_OWNED_BY_PARK); } diff --git a/src/openrct2/actions/SmallSceneryRemoveAction.hpp b/src/openrct2/actions/SmallSceneryRemoveAction.hpp index ee0f6a161d..086ebbb0d9 100644 --- a/src/openrct2/actions/SmallSceneryRemoveAction.hpp +++ b/src/openrct2/actions/SmallSceneryRemoveAction.hpp @@ -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; diff --git a/src/openrct2/actions/SmallScenerySetColourAction.hpp b/src/openrct2/actions/SmallScenerySetColourAction.hpp index 937ac551a9..07e2bc4e1e 100644 --- a/src/openrct2/actions/SmallScenerySetColourAction.hpp +++ b/src/openrct2/actions/SmallScenerySetColourAction.hpp @@ -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); } diff --git a/src/openrct2/actions/TrackPlaceAction.hpp b/src/openrct2/actions/TrackPlaceAction.hpp index 5f18761fdd..905513ffe0 100644 --- a/src/openrct2/actions/TrackPlaceAction.hpp +++ b/src/openrct2/actions/TrackPlaceAction.hpp @@ -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(GA_ERROR::DISALLOWED, STR_LAND_NOT_OWNED_BY_PARK); } diff --git a/src/openrct2/actions/WallPlaceAction.hpp b/src/openrct2/actions/WallPlaceAction.hpp index 9a610aea66..5fa0ec9fe0 100644 --- a/src/openrct2/actions/WallPlaceAction.hpp +++ b/src/openrct2/actions/WallPlaceAction.hpp @@ -122,7 +122,7 @@ public: return std::make_unique(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(GA_ERROR::NOT_OWNED); } diff --git a/src/openrct2/actions/WallRemoveAction.hpp b/src/openrct2/actions/WallRemoveAction.hpp index 7b6fe984bc..f25ace4b10 100644 --- a/src/openrct2/actions/WallRemoveAction.hpp +++ b/src/openrct2/actions/WallRemoveAction.hpp @@ -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(GA_ERROR::NOT_OWNED, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); } diff --git a/src/openrct2/paint/VirtualFloor.cpp b/src/openrct2/paint/VirtualFloor.cpp index 06fecbd57b..44c55cd4b5 100644 --- a/src/openrct2/paint/VirtualFloor.cpp +++ b/src/openrct2/paint/VirtualFloor.cpp @@ -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; diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 0dab53853d..49a3289873 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -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) { diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 94acdb97f7..0ad6105105 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -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; } diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 64cfb0029e..dc0d4fb608 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -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; } } diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index da0029b3a4..6be75e7f61 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -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); diff --git a/src/openrct2/world/Sprite.cpp b/src/openrct2/world/Sprite.cpp index 97092a8205..4c64f5e155 100644 --- a/src/openrct2/world/Sprite.cpp +++ b/src/openrct2/world/Sprite.cpp @@ -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);