diff --git a/src/openrct2/Cheats.cpp b/src/openrct2/Cheats.cpp index 4f0ddf24d8..57024fa43a 100644 --- a/src/openrct2/Cheats.cpp +++ b/src/openrct2/Cheats.cpp @@ -436,25 +436,26 @@ static void cheat_set_staff_speed(uint8 value) static void cheat_own_all_land() { - sint32 min = 32; - sint32 max = gMapSizeUnits - 32; - for (sint32 y = min; y <= max; y += 32) { - for (sint32 x = min; x <= max; x += 32) { - rct_tile_element * surfaceElement = map_get_surface_element_at(x >> 5, y >> 5); + const sint32 min = 32; + const sint32 max = gMapSizeUnits - 32; + + for (BigCoordsXY coords = {min, min}; coords.y <= max; coords.y += 32) { + for (; coords.x <= max; coords.x += 32) { + rct_tile_element * surfaceElement = map_get_surface_element_at(coords); // Ignore already owned tiles. if (surfaceElement->properties.surface.ownership & OWNERSHIP_OWNED) continue; sint32 base_z = surfaceElement->base_height; - sint32 destOwnership = check_max_allowable_land_rights_for_tile(x >> 5, y >> 5, base_z); + sint32 destOwnership = check_max_allowable_land_rights_for_tile(coords.x >> 5, coords.y >> 5, base_z); // only own tiles that were not set to 0 if (destOwnership != OWNERSHIP_UNOWNED) { surfaceElement->properties.surface.ownership |= destOwnership; - update_park_fences_around_tile(x, y); + update_park_fences_around_tile(coords.x, coords.y); uint16 baseHeight = surfaceElement->base_height * 8; - map_invalidate_tile(x, y, baseHeight, baseHeight + 16); + map_invalidate_tile(coords.x, coords.y, baseHeight, baseHeight + 16); } } } @@ -464,7 +465,7 @@ static void cheat_own_all_land() sint32 x = spawn.x; sint32 y = spawn.y; if (x != PEEP_SPAWN_UNDEFINED) { - rct_tile_element * surfaceElement = map_get_surface_element_at(x >> 5, y >> 5); + rct_tile_element * surfaceElement = map_get_surface_element_at((BigCoordsXY){x, y}); surfaceElement->properties.surface.ownership = OWNERSHIP_UNOWNED; update_park_fences_around_tile(x, y); uint16 baseHeight = surfaceElement->base_height * 8; diff --git a/src/openrct2/actions/PlaceParkEntranceAction.hpp b/src/openrct2/actions/PlaceParkEntranceAction.hpp index cdf138eea0..e88f0f17fa 100644 --- a/src/openrct2/actions/PlaceParkEntranceAction.hpp +++ b/src/openrct2/actions/PlaceParkEntranceAction.hpp @@ -158,7 +158,7 @@ public: sint8 zLow = _z * 2; sint8 zHigh = zLow + 12; - LocationXY16 entranceLoc = { _x, _y }; + BigCoordsXY entranceLoc = { _x, _y }; for (uint8 index = 0; index < 3; index++) { if (index == 1) @@ -174,7 +174,7 @@ public: if (!(flags & GAME_COMMAND_FLAG_GHOST)) { - rct_tile_element* surfaceElement = map_get_surface_element_at(entranceLoc.x / 32, entranceLoc.y / 32); + rct_tile_element* surfaceElement = map_get_surface_element_at(entranceLoc); surfaceElement->properties.surface.ownership = 0; } diff --git a/src/openrct2/audio/Audio.cpp b/src/openrct2/audio/Audio.cpp index a3b42be7b5..f023a58ad8 100644 --- a/src/openrct2/audio/Audio.cpp +++ b/src/openrct2/audio/Audio.cpp @@ -217,7 +217,7 @@ AudioParams audio_get_params_from_location(sint32 soundId, const LocationXYZ16 * params.volume = 0; params.pan = 0; - rct_tile_element * element = map_get_surface_element_at(location->x >> 5, location->y >> 5); + rct_tile_element * element = map_get_surface_element_at((BigCoordsXY){location->x, location->y}); if (element && (element->base_height * 8) - 5 > location->z) { volumeDown = 10; diff --git a/src/openrct2/paint/tile_element/Path.cpp b/src/openrct2/paint/tile_element/Path.cpp index cf446e6aba..41153de357 100644 --- a/src/openrct2/paint/tile_element/Path.cpp +++ b/src/openrct2/paint/tile_element/Path.cpp @@ -787,7 +787,7 @@ void path_paint(paint_session * session, uint8 direction, uint16 height, const r sint16 x = session->MapPosition.x, y = session->MapPosition.y; - rct_tile_element * surface = map_get_surface_element_at(x / 32, y / 32); + rct_tile_element * surface = map_get_surface_element_at((BigCoordsXY){session->MapPosition.x, session->MapPosition.y}); uint16 bl = height / 8; if (surface == nullptr) { diff --git a/src/openrct2/paint/tile_element/Surface.cpp b/src/openrct2/paint/tile_element/Surface.cpp index f8e61f1675..cf446860fc 100644 --- a/src/openrct2/paint/tile_element/Surface.cpp +++ b/src/openrct2/paint/tile_element/Surface.cpp @@ -957,10 +957,10 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, cons for (sint32 i = 0; i < 4; i++) { const LocationXY16& offset = viewport_surface_paint_data[i][rotation]; - const LocationXY16 position = + const BigCoordsXY position = { - (sint16)(base.x + offset.x), - (sint16)(base.y + offset.y) + (sint32)(base.x + offset.x), + (sint32)(base.y + offset.y) }; tile_descriptor& descriptor = tileDescriptors[i + 1]; @@ -971,7 +971,7 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, cons continue; } - rct_tile_element * surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32); + rct_tile_element * surfaceElement = map_get_surface_element_at(position); if (surfaceElement == nullptr) { continue; diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index b3007cde50..48484e6c5b 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -2059,7 +2059,7 @@ bool peep_pickup_place(rct_peep * peep, sint32 x, sint32 y, sint32 z, bool apply if (!tileElement) { - tileElement = map_get_surface_element_at(x / 32, y / 32); + tileElement = map_get_surface_element_at({x, y}); } if (!tileElement) @@ -6919,7 +6919,7 @@ static sint32 peep_update_patrolling_find_grass(rct_peep * peep) if ((peep->next_var_29 & 0x18) != 8) return 0; - rct_tile_element * tile_element = map_get_surface_element_at(peep->next_x / 32, peep->next_y / 32); + rct_tile_element * tile_element = map_get_surface_element_at({peep->next_x, peep->next_y}); if ((tile_element->properties.surface.terrain & TILE_ELEMENT_SURFACE_TERRAIN_MASK) != TERRAIN_GRASS) return 0; @@ -6991,7 +6991,7 @@ static void peep_update_patrolling(rct_peep * peep) if ((peep->next_var_29 & 0x18) == 8) { - rct_tile_element * tile_element = map_get_surface_element_at(peep->next_x / 32, peep->next_y / 32); + rct_tile_element * tile_element = map_get_surface_element_at({peep->next_x, peep->next_y}); if (tile_element != nullptr) { @@ -7193,7 +7193,7 @@ static void peep_update_walking(rct_peep * peep) if ((peep->next_var_29 & 0x18) == 8) { - rct_tile_element * tile_element = map_get_surface_element_at(peep->next_x / 32, peep->next_y / 32); + rct_tile_element * tile_element = map_get_surface_element_at({peep->next_x, peep->next_y}); sint32 water_height = map_get_water_height(tile_element); if (water_height) @@ -11662,7 +11662,7 @@ static sint32 peep_perform_next_action(rct_peep * peep) return peep_return_to_centre_of_tile(peep); } - tileElement = map_get_surface_element_at(x / 32, y / 32); + tileElement = map_get_surface_element_at({x, y}); if (tileElement == nullptr) return peep_return_to_centre_of_tile(peep); @@ -12646,7 +12646,7 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8 edge, uint8 * rideT { rct_tile_element *tileElement, *surfaceElement; - surfaceElement = map_get_surface_element_at(peep->next_x / 32, peep->next_y / 32); + surfaceElement = map_get_surface_element_at({peep->next_x, peep->next_y}); tileElement = surfaceElement; do @@ -12680,7 +12680,7 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8 edge, uint8 * rideT return false; } - surfaceElement = map_get_surface_element_at(x / 32, y / 32); + surfaceElement = map_get_surface_element_at({x, y}); tileElement = surfaceElement; do @@ -12792,7 +12792,7 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8 edge, uint8 * rideT return false; } - surfaceElement = map_get_surface_element_at(x / 32, y / 32); + surfaceElement = map_get_surface_element_at({x, y}); // TODO: extract loop A tileElement = surfaceElement; @@ -12904,7 +12904,7 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8 edge, uint8 * rideT return false; } - surfaceElement = map_get_surface_element_at(x / 32, y / 32); + surfaceElement = map_get_surface_element_at({x, y}); // TODO: extract loop A tileElement = surfaceElement; diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 628f690e7d..10eb64c9f3 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -990,7 +990,7 @@ static uint8 staff_handyman_direction_to_uncut_grass(rct_peep * peep, uint8 vali if (!(peep->next_var_29 & 0x18)) { - rct_tile_element * tileElement = map_get_surface_element_at(peep->next_x / 32, peep->next_y / 32); + rct_tile_element * tileElement = map_get_surface_element_at({peep->next_x, peep->next_y}); if (peep->next_z != tileElement->base_height) return 0xFF; @@ -1014,13 +1014,13 @@ static uint8 staff_handyman_direction_to_uncut_grass(rct_peep * peep, uint8 vali continue; } - LocationXY16 chosenTile = { static_cast(peep->next_x + TileDirectionDelta[chosenDirection].x), - static_cast(peep->next_y + TileDirectionDelta[chosenDirection].y) }; + BigCoordsXY chosenTile = { static_cast(peep->next_x + TileDirectionDelta[chosenDirection].x), + static_cast(peep->next_y + TileDirectionDelta[chosenDirection].y) }; if (chosenTile.x > 0x1FFF || chosenTile.y > 0x1FFF) continue; - rct_tile_element * tileElement = map_get_surface_element_at(chosenTile.x / 32, chosenTile.y / 32); + rct_tile_element * tileElement = map_get_surface_element_at(chosenTile); if (tile_element_get_terrain(tileElement) != 0) continue; diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index b1f35b600e..0f91b3c708 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -1300,7 +1300,7 @@ static money32 track_place(sint32 rideIndex, if ((rideTypeFlags & RIDE_TYPE_FLAG_TRACK_MUST_BE_ON_WATER) && !byte_9D8150) { - tileElement = map_get_surface_element_at(x / 32, y / 32); + tileElement = map_get_surface_element_at({x, y}); uint8 water_height = map_get_water_height(tileElement) * 2; if (water_height == 0) @@ -1370,7 +1370,7 @@ static money32 track_place(sint32 rideIndex, } } //6c5648 12 push - tileElement = map_get_surface_element_at(x / 32, y / 32); + tileElement = map_get_surface_element_at({x, y}); if (!gCheatsDisableSupportLimits) { sint32 ride_height = clearanceZ - tileElement->base_height; @@ -1550,7 +1550,7 @@ static money32 track_place(sint32 rideIndex, if (rideTypeFlags & RIDE_TYPE_FLAG_TRACK_MUST_BE_ON_WATER) { - rct_tile_element * surfaceElement = map_get_surface_element_at(x / 32, y / 32); + rct_tile_element * surfaceElement = map_get_surface_element_at({x, y}); surfaceElement->type |= (1 << 6); tileElement = surfaceElement; } @@ -1810,7 +1810,7 @@ static money32 track_remove(uint8 type, } } - rct_tile_element * surfaceElement = map_get_surface_element_at(x / 32, y / 32); + rct_tile_element * surfaceElement = map_get_surface_element_at({x, y}); if (surfaceElement == nullptr) { return MONEY32_UNDEFINED; @@ -2029,7 +2029,7 @@ static money32 set_maze_track(uint16 x, uint8 flags, uint8 direction, uint16 y, return MONEY32_UNDEFINED; } - rct_tile_element * tileElement = map_get_surface_element_at(x / 32, y / 32); + rct_tile_element * tileElement = map_get_surface_element_at({x, y}); if (tileElement == nullptr) { return MONEY32_UNDEFINED; diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 107de15eb6..178f057edc 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -1194,8 +1194,10 @@ static sint32 track_design_place_maze(rct_track_td6 * td6, sint16 x, sint16 y, s for (; maze_element->all != 0; maze_element++) { uint8 rotation = _currentTrackPieceDirection & 3; - LocationXY16 mapCoord = {(sint16) (maze_element->x * 32), (sint16) (maze_element->y * 32)}; - rotate_map_coordinates(&mapCoord.x, &mapCoord.y, rotation); + BigCoordsXY mapCoord = {maze_element->x * 32, maze_element->y * 32}; + sint16 tmpX = mapCoord.x; + sint16 tmpY = mapCoord.y; + rotate_map_coordinates(&tmpX, &tmpY, rotation); mapCoord.x += x; mapCoord.y += y; @@ -1337,7 +1339,7 @@ static sint32 track_design_place_maze(rct_track_td6 * td6, sint16 x, sint16 y, s continue; } - rct_tile_element * tile_element = map_get_surface_element_at(mapCoord.x / 32, mapCoord.y / 32); + rct_tile_element * tile_element = map_get_surface_element_at(mapCoord); sint16 map_height = tile_element->base_height * 8; if (tile_element->properties.surface.slope & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP) { @@ -1492,14 +1494,16 @@ static bool track_design_place_ride(rct_track_td6 * td6, sint16 x, sint16 y, sin sint32 tempZ = z - TrackCoordinates[trackType].z_begin; for (const rct_preview_track * trackBlock = TrackBlocks[trackType]; trackBlock->index != 0xFF; trackBlock++) { - LocationXY16 tile = {x, y}; - map_offset_with_rotation(&tile.x, &tile.y, trackBlock->x, trackBlock->y, rotation); + BigCoordsXY tile = {x, y}; + sint16 tmpX = tile.x; + sint16 tmpY = tile.y; + map_offset_with_rotation(&tmpX, &tmpY, trackBlock->x, trackBlock->y, rotation); if (tile.x < 0 || tile.y < 0 || tile.x >= (256 * 32) || tile.y >= (256 * 32)) { continue; } - rct_tile_element * tileElement = map_get_surface_element_at(tile.x >> 5, tile.y >> 5); + rct_tile_element * tileElement = map_get_surface_element_at(tile); if (tileElement == nullptr) { return false; @@ -2061,7 +2065,7 @@ static money32 place_maze_design(uint8 flags, uint8 rideIndex, uint16 mazeEntry, // Check support height if (!gCheatsDisableSupportLimits) { - rct_tile_element * tileElement = map_get_surface_element_at(x >> 5, y >> 5); + rct_tile_element * tileElement = map_get_surface_element_at({x, y}); uint8 supportZ = (z + 32) >> 3; if (supportZ > tileElement->base_height) { diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index d544d5387f..18cd38de8f 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -978,7 +978,7 @@ static void vehicle_update_sound_params(rct_vehicle * vehicle) if (vehicle->x != LOCATION_NULL) { - rct_tile_element * tile_element = map_get_surface_element_at(vehicle->x >> 5, vehicle->y >> 5); + rct_tile_element * tile_element = map_get_surface_element_at({vehicle->x, vehicle->y}); // vehicle underground if (tile_element != nullptr && tile_element->base_height * 8 > vehicle->z) @@ -1826,7 +1826,7 @@ static void vehicle_update_measurements(rct_vehicle * vehicle) return; } - rct_tile_element * tile_element = map_get_surface_element_at(x / 32, y / 32); + rct_tile_element * tile_element = map_get_surface_element_at({x, y}); if (tile_element->base_height * 8 <= vehicle->z) { @@ -7251,7 +7251,7 @@ static void vehicle_update_spinning_car(rct_vehicle * vehicle) */ static void steam_particle_create(sint16 x, sint16 y, sint16 z) { - rct_tile_element * tileElement = map_get_surface_element_at(x >> 5, y >> 5); + rct_tile_element * tileElement = map_get_surface_element_at({x, y}); if (tileElement != nullptr && z > tileElement->base_height * 8) { rct_steam_particle * steam = (rct_steam_particle *)create_sprite(2); diff --git a/src/openrct2/world/Duck.cpp b/src/openrct2/world/Duck.cpp index bae1f36aa5..c30c51ee07 100644 --- a/src/openrct2/world/Duck.cpp +++ b/src/openrct2/world/Duck.cpp @@ -125,7 +125,7 @@ void rct_duck::UpdateFlyToWater() sint32 newY = y + DuckMoveOffset[direction].y; sint32 manhattanDistanceN = abs(target_x - newX) + abs(target_y - newY); - rct_tile_element * tileElement = map_get_surface_element_at(target_x >> 5, target_y >> 5); + rct_tile_element * tileElement = map_get_surface_element_at({target_x, target_y}); sint32 waterHeight = map_get_water_height(tileElement); if (waterHeight == 0) { diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index e7481a8a8c..4a837653b6 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -222,7 +222,7 @@ static money32 footpath_element_insert(sint32 type, sint32 x, sint32 y, sint32 z return MONEY32_UNDEFINED; } - tileElement = map_get_surface_element_at((x / 32), (y / 32)); + tileElement = map_get_surface_element_at({x, y}); sint32 supportHeight = z - tileElement->base_height; gFootpathPrice += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / 2) * MONEY(5, 00); @@ -631,7 +631,7 @@ static money32 footpath_place_from_track(sint32 type, sint32 x, sint32 y, sint32 return MONEY32_UNDEFINED; } - tileElement = map_get_surface_element_at((x / 32), (y / 32)); + tileElement = map_get_surface_element_at({x, y}); sint32 supportHeight = z - tileElement->base_height; gFootpathPrice += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / 2) * MONEY(5, 00); @@ -1636,7 +1636,7 @@ void footpath_update_queue_chains() */ static void footpath_fix_ownership(sint32 x, sint32 y, rct_tile_element *pathElement) { - const rct_tile_element * surfaceElement = map_get_surface_element_at(x >> 5, y >> 5); + const rct_tile_element * surfaceElement = map_get_surface_element_at({x, y}); uint16 ownership; // Unlikely to be NULL unless deliberate. diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 66b8845f12..84f1eaa8df 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -334,7 +334,7 @@ void tile_element_set_terrain_edge(rct_tile_element *element, sint32 terrain) element->properties.surface.slope |= (terrain & 7) << 5; } -rct_tile_element *map_get_surface_element_at(sint32 x, sint32 y) +rct_tile_element * map_get_surface_element_at(sint32 x, sint32 y) { rct_tile_element *tileElement = map_get_first_element_at(x, y); @@ -352,6 +352,11 @@ rct_tile_element *map_get_surface_element_at(sint32 x, sint32 y) return tileElement; } +rct_tile_element * map_get_surface_element_at(BigCoordsXY coords) +{ + return map_get_surface_element_at(coords.x / 32, coords.y / 32); +} + rct_tile_element* map_get_path_element_at(sint32 x, sint32 y, sint32 z){ rct_tile_element *tileElement = map_get_first_element_at(x, y); @@ -536,7 +541,7 @@ sint32 tile_element_height(sint32 x, sint32 y) sint32 y_tile = y & 0xFFFFFFE0; // Get the surface element for the tile - tileElement = map_get_surface_element_at(x_tile / 32, y_tile / 32); + tileElement = map_get_surface_element_at({x_tile, y_tile}); if (tileElement == nullptr) { return 16; @@ -832,7 +837,7 @@ bool map_is_location_owned(sint32 x, sint32 y, sint32 z) { // This check is to avoid throwing lots of messages in logs. if (map_is_location_valid(x, y)) { - rct_tile_element *tileElement = map_get_surface_element_at(x / 32, y / 32); + rct_tile_element *tileElement = map_get_surface_element_at({x, y}); if (tileElement != nullptr) { if (tileElement->properties.surface.ownership & OWNERSHIP_OWNED) return true; @@ -856,7 +861,7 @@ bool map_is_location_owned(sint32 x, sint32 y, sint32 z) bool map_is_location_in_park(sint32 x, sint32 y) { if (map_is_location_valid(x, y)) { - rct_tile_element *tileElement = map_get_surface_element_at(x / 32, y / 32); + rct_tile_element *tileElement = map_get_surface_element_at({x, y}); if (tileElement == nullptr) return false; if (tileElement->properties.surface.ownership & OWNERSHIP_OWNED) @@ -870,7 +875,7 @@ bool map_is_location_in_park(sint32 x, sint32 y) bool map_is_location_owned_or_has_rights(sint32 x, sint32 y) { if (map_is_location_valid(x, y)) { - rct_tile_element *tileElement = map_get_surface_element_at(x / 32, y / 32); + rct_tile_element *tileElement = map_get_surface_element_at({x, y}); if (tileElement == nullptr) { return false; } @@ -1342,7 +1347,7 @@ static money32 map_change_surface_style(sint32 x0, sint32 y0, sint32 x1, sint32 if (!map_is_location_in_park(x, y)) continue; } - rct_tile_element* tileElement = map_get_surface_element_at(x / 32, y / 32); + rct_tile_element* tileElement = map_get_surface_element_at({x, y}); if (surfaceStyle != 0xFF){ uint8 cur_terrain = ( @@ -1629,7 +1634,7 @@ static money32 map_set_land_height(sint32 flags, sint32 x, sint32 y, sint32 heig } uint8 zCorner = height; //z position of highest corner of tile - rct_tile_element *surfaceElement = map_get_surface_element_at(x / 32, y / 32); + rct_tile_element *surfaceElement = map_get_surface_element_at({x, y}); if(surfaceElement->type & TILE_ELEMENT_TYPE_FLAG_HIGHLIGHT) { sint32 waterHeight = map_get_water_height(surfaceElement); @@ -1714,7 +1719,7 @@ static money32 map_set_land_height(sint32 flags, sint32 x, sint32 y, sint32 heig network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); } - surfaceElement = map_get_surface_element_at(x / 32, y / 32); + surfaceElement = map_get_surface_element_at({x, y}); surfaceElement->base_height = height; surfaceElement->clearance_height = height; surfaceElement->properties.surface.slope &= TILE_ELEMENT_SURFACE_EDGE_STYLE_MASK; @@ -1801,7 +1806,7 @@ static uint8 map_get_lowest_land_height(sint32 xMin, sint32 xMax, sint32 yMin, s uint8 min_height = 0xFF; for (sint32 yi = yMin; yi <= yMax; yi += 32) { for (sint32 xi = xMin; xi <= xMax; xi += 32) { - rct_tile_element *tile_element = map_get_surface_element_at(xi / 32, yi / 32); + rct_tile_element *tile_element = map_get_surface_element_at({xi, yi}); if (tile_element != nullptr && min_height > tile_element->base_height) { min_height = tile_element->base_height; } @@ -1820,7 +1825,7 @@ static uint8 map_get_highest_land_height(sint32 xMin, sint32 xMax, sint32 yMin, uint8 max_height = 0; for (sint32 yi = yMin; yi <= yMax; yi += 32) { for (sint32 xi = xMin; xi <= xMax; xi += 32) { - rct_tile_element *tile_element = map_get_surface_element_at(xi / 32, yi / 32); + rct_tile_element *tile_element = map_get_surface_element_at({xi, yi}); if (tile_element != nullptr) { uint8 base_height = tile_element->base_height; if (tile_element->properties.surface.slope & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP) @@ -1853,7 +1858,7 @@ static money32 raise_land(sint32 flags, sint32 x, sint32 y, sint32 z, sint32 ax, for (sint32 yi = ay; yi <= by; yi += 32) { for (sint32 xi = ax; xi <= bx; xi += 32) { - rct_tile_element *tile_element = map_get_surface_element_at(xi / 32, yi / 32); + rct_tile_element *tile_element = map_get_surface_element_at({xi, yi}); if (tile_element != nullptr) { uint8 height = tile_element->base_height; if (height <= min_height){ @@ -1900,7 +1905,7 @@ static money32 lower_land(sint32 flags, sint32 x, sint32 y, sint32 z, sint32 ax, for (sint32 yi = ay; yi <= by; yi += 32) { for (sint32 xi = ax; xi <= bx; xi += 32) { - rct_tile_element *tile_element = map_get_surface_element_at(xi / 32, yi / 32); + rct_tile_element *tile_element = map_get_surface_element_at({xi, yi}); if (tile_element != nullptr) { uint8 height = tile_element->base_height; if (tile_element->properties.surface.slope & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP) @@ -1953,7 +1958,7 @@ money32 raise_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags) for (sint32 yi = y0; yi <= y1; yi += 32) { for (sint32 xi = x0; xi <= x1; xi += 32) { - rct_tile_element* tile_element = map_get_surface_element_at(xi / 32, yi / 32); + rct_tile_element* tile_element = map_get_surface_element_at({xi, yi}); if (tile_element != nullptr) { uint8 height = tile_element->base_height; if (map_get_water_height(tile_element) > 0) @@ -1966,7 +1971,7 @@ money32 raise_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags) for (sint32 yi = y0; yi <= y1; yi += 32) { for (sint32 xi = x0; xi <= x1; xi += 32) { - rct_tile_element* tile_element = map_get_surface_element_at(xi / 32, yi / 32); + rct_tile_element* tile_element = map_get_surface_element_at({xi, yi}); if (tile_element != nullptr) { if (tile_element->base_height <= max_height){ uint8 height = map_get_water_height(tile_element); @@ -2034,7 +2039,7 @@ money32 lower_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags) for (sint32 yi = y0; yi <= y1; yi += 32){ for (sint32 xi = x0; xi <= x1; xi += 32){ - rct_tile_element* tile_element = map_get_surface_element_at(xi / 32, yi / 32); + rct_tile_element* tile_element = map_get_surface_element_at({xi, yi}); if (tile_element != nullptr) { uint8 height = map_get_water_height(tile_element); if (height != 0) { @@ -2048,7 +2053,7 @@ money32 lower_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags) for (sint32 yi = y0; yi <= y1; yi += 32) { for (sint32 xi = x0; xi <= x1; xi += 32) { - rct_tile_element* tile_element = map_get_surface_element_at(xi / 32, yi / 32); + rct_tile_element* tile_element = map_get_surface_element_at({xi, yi}); if (tile_element != nullptr) { uint8 height = map_get_water_height(tile_element); if (height != 0) { @@ -2167,8 +2172,8 @@ static money32 smooth_land_row_by_edge(sint32 flags, sint32 x, sint32 y, sint32 if (!map_is_location_valid(x, y) || !map_is_location_valid(x + stepX, y + stepY)) { return 0; } - tileElement = map_get_surface_element_at(x >> 5, y >> 5); - nextTileElement = map_get_surface_element_at((x + stepX) >> 5, (y + stepY) >> 5); + tileElement = map_get_surface_element_at({x, y}); + nextTileElement = map_get_surface_element_at({x + stepX, y + stepY}); if (tileElement == nullptr || nextTileElement == nullptr) { return 0; } @@ -2197,7 +2202,7 @@ static money32 smooth_land_row_by_edge(sint32 flags, sint32 x, sint32 y, sint32 else { tileElement = nextTileElement; - nextTileElement = map_get_surface_element_at((x + stepX) >> 5, (y + stepY) >> 5); + nextTileElement = map_get_surface_element_at({x + stepX, y + stepY}); if (nextTileElement == nullptr) { shouldContinue &= ~0x3; } @@ -2287,7 +2292,7 @@ static money32 smooth_land_row_by_corner(sint32 flags, sint32 x, sint32 y, sint3 if (!map_is_location_valid(x, y) || !map_is_location_valid(x + stepX, y + stepY)) { return 0; } - tileElement = map_get_surface_element_at(x >> 5, y >> 5); + tileElement = map_get_surface_element_at({x, y}); nextTileElement = map_get_surface_element_at((x + stepX) >> 5, (y + stepY) >> 5); if (tileElement == nullptr || nextTileElement == nullptr) { return 0; @@ -2359,7 +2364,7 @@ static money32 smooth_land(sint32 flags, sint32 centreX, sint32 centreY, sint32 money32 totalCost = 0; money32 result; - rct_tile_element *tileElement = map_get_surface_element_at(mapLeft >> 5, mapTop >> 5); + rct_tile_element *tileElement = map_get_surface_element_at({mapLeft, mapTop}); if (tileElement == nullptr) { log_warning("Invalid coordinates for land smoothing, x = %d, y = %d", mapLeft, mapTop); @@ -2435,7 +2440,7 @@ static money32 smooth_land(sint32 flags, sint32 centreX, sint32 centreY, sint32 sint32 y, z2; for (y = mapTop; y <= mapBottom; y += 32) { - tileElement = map_get_surface_element_at(x >> 5, y >> 5); + tileElement = map_get_surface_element_at({x, y}); z = Math::Clamp(minHeight, (uint8)tile_element_get_corner_height(tileElement, 3), maxHeight); z2 = Math::Clamp(minHeight, (uint8)tile_element_get_corner_height(tileElement, 2), maxHeight); totalCost += smooth_land_row_by_edge(flags, x, y, z, z2, -32, 0, 0, 1, 3, 2, raiseLand); @@ -2443,7 +2448,7 @@ static money32 smooth_land(sint32 flags, sint32 centreX, sint32 centreY, sint32 x = mapRight; for (y = mapTop; y <= mapBottom; y += 32) { - tileElement = map_get_surface_element_at(x >> 5, y >> 5); + tileElement = map_get_surface_element_at({x, y}); z = Math::Clamp(minHeight, (uint8)tile_element_get_corner_height(tileElement, 1), maxHeight); z2 = Math::Clamp(minHeight, (uint8)tile_element_get_corner_height(tileElement, 0), maxHeight); totalCost += smooth_land_row_by_edge(flags, x, y, z, z2, 32, 0, 2, 3, 1, 0, raiseLand); @@ -2451,7 +2456,7 @@ static money32 smooth_land(sint32 flags, sint32 centreX, sint32 centreY, sint32 y = mapTop; for (x = mapLeft; x <= mapRight; x += 32) { - tileElement = map_get_surface_element_at(x >> 5, y >> 5); + tileElement = map_get_surface_element_at({x, y}); z = Math::Clamp(minHeight, (uint8)tile_element_get_corner_height(tileElement, 1), maxHeight); z2 = Math::Clamp(minHeight, (uint8)tile_element_get_corner_height(tileElement, 2), maxHeight); totalCost += smooth_land_row_by_edge(flags, x, y, z, z2, 0, -32, 0, 3, 1, 2, raiseLand); @@ -2459,7 +2464,7 @@ static money32 smooth_land(sint32 flags, sint32 centreX, sint32 centreY, sint32 y = mapBottom; for (x = mapLeft; x <= mapRight; x += 32) { - tileElement = map_get_surface_element_at(x >> 5, y >> 5); + tileElement = map_get_surface_element_at({x, y}); z = Math::Clamp(minHeight, (uint8)tile_element_get_corner_height(tileElement, 0), maxHeight); z2 = Math::Clamp(minHeight, (uint8)tile_element_get_corner_height(tileElement, 3), maxHeight); totalCost += smooth_land_row_by_edge(flags, x, y, z, z2, 0, 32, 1, 2, 0, 3, raiseLand); @@ -2635,7 +2640,7 @@ void game_command_set_water_height(sint32* eax, sint32* ebx, sint32* ecx, sint32 wall_remove_at_z(x, y, element_height); } - rct_tile_element* tile_element = map_get_surface_element_at(x / 32, y / 32); + rct_tile_element* tile_element = map_get_surface_element_at({x, y}); sint32 zHigh = tile_element->base_height; sint32 zLow = base_height; if (map_get_water_height(tile_element) > 0) @@ -2763,7 +2768,7 @@ void game_command_place_large_scenery(sint32* eax, sint32* ebx, sint32* ecx, sin continue; } - rct_tile_element * tile_element = map_get_surface_element_at(curTile.x / 32, curTile.y / 32); + rct_tile_element * tile_element = map_get_surface_element_at({curTile.x, curTile.y}); if(tile_element != nullptr) { sint32 height = tile_element->base_height * 8; @@ -4160,7 +4165,7 @@ bool map_surface_is_blocked(sint16 x, sint16 y){ if (x >= 8192 || y >= 8192) return true; - tileElement = map_get_surface_element_at(x / 32, y / 32); + tileElement = map_get_surface_element_at({x, y}); if (tileElement == nullptr) { return true; @@ -4899,15 +4904,15 @@ bool map_tile_is_part_of_virtual_floor(sint16 x, sint16 y) return false; } -void FixLandOwnershipTiles(std::initializer_list tiles) +void FixLandOwnershipTiles(std::initializer_list tiles) { FixLandOwnershipTilesWithOwnership(tiles, OWNERSHIP_AVAILABLE); } -void FixLandOwnershipTilesWithOwnership(std::initializer_list tiles, uint8 ownership) +void FixLandOwnershipTilesWithOwnership(std::initializer_list tiles, uint8 ownership) { rct_tile_element * currentElement; - for (const LocationXY8 * tile = tiles.begin(); tile != tiles.end(); ++tile) + for (const SmallCoordsXY * tile = tiles.begin(); tile != tiles.end(); ++tile) { currentElement = map_get_surface_element_at((*tile).x, (*tile).y); currentElement->properties.surface.ownership |= ownership; diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index 9cc95ee1b5..d639b74cfa 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -444,6 +444,7 @@ void tile_element_set_terrain_edge(rct_tile_element *element, sint32 terrain); sint32 map_height_from_slope(sint32 x, sint32 y, sint32 slope); rct_tile_element* map_get_banner_element_at(sint32 x, sint32 y, sint32 z, uint8 direction); rct_tile_element *map_get_surface_element_at(sint32 x, sint32 y); +rct_tile_element * map_get_surface_element_at(BigCoordsXY coords); rct_tile_element* map_get_path_element_at(sint32 x, sint32 y, sint32 z); rct_tile_element *map_get_wall_element_at(sint32 x, sint32 y, sint32 z, sint32 direction); rct_tile_element *map_get_small_scenery_element_at(sint32 x, sint32 y, sint32 z, sint32 type, uint8 quadrant); @@ -584,7 +585,7 @@ uint32 map_get_available_peep_spawn_index_list(uint32* peepSpawnIndexList); uint16 check_max_allowable_land_rights_for_tile(uint8 x, uint8 y, uint8 base_z); uint8 tile_element_get_ride_index(const rct_tile_element * tileElement); -void FixLandOwnershipTiles(std::initializer_list tiles); -void FixLandOwnershipTilesWithOwnership(std::initializer_list tiles, uint8 ownership); +void FixLandOwnershipTiles(std::initializer_list tiles); +void FixLandOwnershipTilesWithOwnership(std::initializer_list tiles, uint8 ownership); #endif diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index 92dcbe8a4d..5d604b51d2 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -704,7 +704,7 @@ void update_park_fences(sint32 x, sint32 y) if (y <= 0 || y >= gMapSizeUnits) return; - rct_tile_element* sufaceElement = map_get_surface_element_at(x / 32, y / 32); + rct_tile_element* sufaceElement = map_get_surface_element_at({x, y}); if (sufaceElement == nullptr)return; uint8 newOwnership = sufaceElement->properties.surface.ownership & 0xF0; @@ -859,7 +859,7 @@ void game_command_set_park_name(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *e } static money32 map_buy_land_rights_for_tile(sint32 x, sint32 y, sint32 setting, sint32 flags) { - rct_tile_element* surfaceElement = map_get_surface_element_at(x / 32, y / 32); + rct_tile_element* surfaceElement = map_get_surface_element_at({x, y}); if (surfaceElement == nullptr) return MONEY32_UNDEFINED; diff --git a/src/openrct2/world/SmallScenery.cpp b/src/openrct2/world/SmallScenery.cpp index ac4d96ff6c..ea023814ca 100644 --- a/src/openrct2/world/SmallScenery.cpp +++ b/src/openrct2/world/SmallScenery.cpp @@ -268,7 +268,7 @@ static money32 SmallSceneryPlace(sint16 x, } } - rct_tile_element* surfaceElement = map_get_surface_element_at(x / 32, y / 32); + rct_tile_element* surfaceElement = map_get_surface_element_at({x, y}); if (surfaceElement != nullptr && !gCheatsDisableClearanceChecks && map_get_water_height(surfaceElement) > 0) { diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index 91b6a2ba42..5a826c36f6 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -754,7 +754,7 @@ sint32 tile_inspector_track_base_height_offset(sint32 x, sint32 y, sint32 elemen // track_remove returns here on failure, not sure when this would ever be hit. Only thing I can think of is for when // you decrease the map size. - openrct2_assert(map_get_surface_element_at(elemX >> 5, elemY >> 5) != nullptr, "No surface at %d,%d", elemX >> 5, + openrct2_assert(map_get_surface_element_at({elemX, elemY}) != nullptr, "No surface at %d,%d", elemX >> 5, elemY >> 5); // Keep? @@ -887,7 +887,7 @@ sint32 tile_inspector_track_set_chain(sint32 x, sint32 y, sint32 elementIndex, b // track_remove returns here on failure, not sure when this would ever be hit. Only thing I can think of is for when // you decrease the map size. - openrct2_assert(map_get_surface_element_at(elemX >> 5, elemY >> 5) != nullptr, "No surface at %d,%d", elemX >> 5, + openrct2_assert(map_get_surface_element_at({elemX, elemY}) != nullptr, "No surface at %d,%d", elemX >> 5, elemY >> 5); // Keep? diff --git a/src/openrct2/world/Wall.cpp b/src/openrct2/world/Wall.cpp index d041987813..084193f4ec 100644 --- a/src/openrct2/world/Wall.cpp +++ b/src/openrct2/world/Wall.cpp @@ -350,7 +350,7 @@ static money32 WallPlace(uint8 wallType, uint8 edgeSlope = 0; if (position.z == 0) { - rct_tile_element * surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32); + rct_tile_element * surfaceElement = map_get_surface_element_at({position.x, position.y}); if (surfaceElement == nullptr) { return MONEY32_UNDEFINED; @@ -366,7 +366,7 @@ static money32 WallPlace(uint8 wallType, } } - rct_tile_element * surfaceElement = map_get_surface_element_at(position.x / 32, position.y / 32); + rct_tile_element * surfaceElement = map_get_surface_element_at({position.x, position.y}); if (surfaceElement == nullptr) { return MONEY32_UNDEFINED;