Clean up many other coordinates

This commit is contained in:
Gymnasiast committed 2020-03-13 12:03:43 +01:00
1 parent 3412c47a9e
commit bdf681f440
32 files changed
+132 -172

No files matched your search

+10 -13
View File
@@ -106,7 +106,7 @@ public:
if (_sequence == nullptr)
{
SetViewLocation(75 * 32, 75 * 32);
SetViewLocation(TileCoordsXY(75, 75).ToCoordsXY());
return false;
}
@@ -254,9 +254,8 @@ private:
break;
case TITLE_SCRIPT_LOCATION:
{
int32_t x = command->X * 32 + 16;
int32_t y = command->Y * 32 + 16;
SetViewLocation(x, y);
auto loc = TileCoordsXY(command->X, command->Y).ToCoordsXY().ToTileCentre();
SetViewLocation(loc);
break;
}
case TITLE_SCRIPT_ROTATE:
@@ -465,22 +464,21 @@ private:
}
/**
* Sets the map location to the given tile coordinates. Z is automatic.
* @param x X position in map tiles.
* @param y Y position in map tiles.
* Sets the map location to the given (big) coordinates. Z is automatic.
* @param loc X and Y position in big coordinates.
*/
void SetViewLocation(int32_t x, int32_t y)
void SetViewLocation(const CoordsXY& loc)
{
// Update viewport
rct_window* w = window_get_main();
if (w != nullptr)
{
int32_t z = tile_element_height({ x, y });
int32_t z = tile_element_height(loc);
// Prevent scroll adjustment due to window placement when in-game
auto oldScreenFlags = gScreenFlags;
gScreenFlags = SCREEN_FLAGS_TITLE_DEMO;
w->SetLocation(x, y, z);
w->SetLocation(loc.x, loc.y, z);
gScreenFlags = oldScreenFlags;
viewport_update_position(w);
@@ -488,8 +486,7 @@ private:
// Save known tile position in case of window resize
_lastScreenWidth = w->width;
_lastScreenHeight = w->height;
_viewCentreLocation.x = x;
_viewCentreLocation.y = y;
_viewCentreLocation = loc;
}
}
@@ -503,7 +500,7 @@ private:
{
if (w->width != _lastScreenWidth || w->height != _lastScreenHeight)
{
SetViewLocation(_viewCentreLocation.x, _viewCentreLocation.y);
SetViewLocation(_viewCentreLocation);
}
}
}
+5 -6
View File
@@ -1498,17 +1498,16 @@ static void window_ride_update_overall_view(Ride* ride)
if (it.element->AsTrack()->GetRideIndex() != ride->id)
continue;
int32_t x = it.x * 32;
int32_t y = it.y * 32;
auto location = TileCoordsXY(it.x, it.y).ToCoordsXY();
int32_t baseZ = it.element->GetBaseZ();
int32_t clearZ = it.element->GetClearanceZ();
minx = std::min(minx, x);
miny = std::min(miny, y);
minx = std::min(minx, location.x);
miny = std::min(miny, location.y);
minz = std::min(minz, baseZ);
maxx = std::max(maxx, x);
maxy = std::max(maxy, y);
maxx = std::max(maxx, location.x);
maxy = std::max(maxy, location.y);
maxz = std::max(maxz, clearZ);
}
+3 -3
View File
@@ -542,8 +542,8 @@ static void window_track_place_draw_mini_preview(TrackDesign* td6)
CoordsXY origin = { 0, 0 };
if (pass == 1)
{
origin.x -= ((max.x + min.x) >> 6) * 32;
origin.y -= ((max.y + min.y) >> 6) * 32;
origin.x -= ((max.x + min.x) >> 6) * COORDS_XY_STEP;
origin.y -= ((max.y + min.y) >> 6) * COORDS_XY_STEP;
}
if (td6->type == RIDE_TYPE_MAZE)
@@ -670,7 +670,7 @@ static void window_track_place_draw_mini_preview_maze(
uint8_t rotation = (_currentTrackPieceDirection + get_current_rotation()) & 3;
for (const auto& mazeElement : td6->maze_elements)
{
auto rotatedMazeCoords = origin + CoordsXY{ mazeElement.x * 32, mazeElement.y * 32 }.Rotate(rotation);
auto rotatedMazeCoords = origin + TileCoordsXY{ mazeElement.x, mazeElement.y }.ToCoordsXY().Rotate(rotation);
if (pass == 0)
{
+1 -2
View File
@@ -143,8 +143,7 @@ public:
banner->text_colour = 2;
banner->type = _bannerType;
banner->colour = _primaryColour;
banner->position.x = _loc.x / 32;
banner->position.y = _loc.y / 32;
banner->position = TileCoordsXY(_loc);
newTileElement->SetType(TILE_ELEMENT_TYPE_BANNER);
BannerElement* bannerElement = newTileElement->AsBanner();
bannerElement->SetClearanceZ(_loc.z + PATH_CLEARANCE);
+2 -2
View File
@@ -76,12 +76,12 @@ public:
return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_BUILD_FOOTPATH_HERE, STR_LAND_SLOPE_UNSUITABLE);
}
if (_loc.z / 8 < FootpathMinHeight)
if (_loc.z < FootpathMinHeight)
{
return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_BUILD_FOOTPATH_HERE, STR_TOO_LOW);
}
if (_loc.z / 8 > FootpathMaxHeight)
if (_loc.z > FootpathMaxHeight)
{
return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_BUILD_FOOTPATH_HERE, STR_TOO_HIGH);
}
@@ -72,12 +72,12 @@ public:
return MakeResult(GA_ERROR::DISALLOWED, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
}
if (_loc.z / 8 < FootpathMinHeight)
if (_loc.z < FootpathMinHeight)
{
return MakeResult(GA_ERROR::DISALLOWED, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_LOW);
}
if (_loc.z / 8 > FootpathMaxHeight)
if (_loc.z > FootpathMaxHeight)
{
return MakeResult(GA_ERROR::DISALLOWED, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_HIGH);
}
@@ -63,12 +63,12 @@ public:
return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
}
if (_loc.z / 8 < 2)
if (_loc.z < FootpathMinHeight)
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE, STR_TOO_LOW);
}
if (_loc.z / 8 > 248)
if (_loc.z > FootpathMaxHeight)
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE, STR_TOO_HIGH);
}
@@ -57,12 +57,12 @@ public:
return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
}
if (_loc.z / 8 < 2)
if (_loc.z < FootpathMinHeight)
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_TOO_LOW);
}
if (_loc.z / 8 > 248)
if (_loc.z > FootpathMaxHeight)
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_TOO_HIGH);
}
@@ -159,13 +159,13 @@ public:
curTile.x += _loc.x;
curTile.y += _loc.y;
int32_t zLow = (tile->z_offset + maxHeight) / 8;
int32_t zHigh = (tile->z_clearance / 8) + zLow;
int32_t zLow = tile->z_offset + maxHeight;
int32_t zHigh = tile->z_clearance + zLow;
QuarterTile quarterTile = QuarterTile{ static_cast<uint8_t>(tile->flags >> 12), 0 }.Rotate(_loc.direction);
if (!map_can_construct_with_clear_at(
{ curTile, zLow * COORDS_Z_STEP, zHigh * COORDS_Z_STEP }, &map_place_scenery_clear_func, quarterTile,
GetFlags(), &supportsCost, CREATE_CROSSING_MODE_NONE))
{ curTile, zLow, zHigh }, &map_place_scenery_clear_func, quarterTile, GetFlags(), &supportsCost,
CREATE_CROSSING_MODE_NONE))
{
return std::make_unique<LargeSceneryPlaceActionResult>(
GA_ERROR::NO_CLEARANCE, gGameCommandErrorText, gCommonFormatArgs);
@@ -193,7 +193,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, zLow * COORDS_Z_STEP })
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !map_is_location_owned({ curTile, zLow })
&& !gCheatsSandboxMode)
{
return std::make_unique<LargeSceneryPlaceActionResult>(GA_ERROR::DISALLOWED, STR_LAND_NOT_OWNED_BY_PARK);
@@ -263,8 +263,7 @@ public:
banner->text_colour = 2;
banner->flags = BANNER_FLAG_IS_LARGE_SCENERY;
banner->type = 0;
banner->position.x = _loc.x / 32;
banner->position.y = _loc.y / 32;
banner->position = TileCoordsXY(_loc);
ride_id_t rideIndex = banner_get_closest_ride_index({ _loc, maxHeight });
if (rideIndex != RIDE_ID_NULL)
+4 -7
View File
@@ -300,16 +300,13 @@ private:
if (it.element->AsTrack()->GetRideIndex() != (ride_id_t)_rideIndex)
continue;
int32_t x = it.x * 32, y = it.y * 32;
int32_t z = it.element->GetBaseZ();
uint8_t rotation = it.element->GetDirection();
auto location = CoordsXYZD(
TileCoordsXY(it.x, it.y).ToCoordsXY(), it.element->GetBaseZ(), it.element->GetDirection());
auto type = it.element->AsTrack()->GetTrackType();
if (type != TRACK_ELEM_MAZE)
{
auto trackRemoveAction = TrackRemoveAction(
type, it.element->AsTrack()->GetSequenceIndex(), { x, y, z, rotation });
auto trackRemoveAction = TrackRemoveAction(type, it.element->AsTrack()->GetSequenceIndex(), location);
trackRemoveAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND);
auto removRes = GameActions::ExecuteNested(&trackRemoveAction);
@@ -337,7 +334,7 @@ private:
for (Direction dir : ALL_DIRECTIONS)
{
const CoordsXY& off = DirOffsets[dir];
money32 removePrice = MazeRemoveTrack(x + off.x, y + off.y, z, dir);
money32 removePrice = MazeRemoveTrack(location.x + off.x, location.y + off.y, location.z, dir);
if (removePrice != MONEY32_UNDEFINED)
refundPrice += removePrice;
else
+1 -5
View File
@@ -57,10 +57,6 @@ public:
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
}
auto banner = GetBanner(_bannerIndex);
CoordsXY coords{ banner->position.x * 32, banner->position.y * 32 };
if (_isLarge)
{
TileElement* tileElement = banner_get_tile_element(_bannerIndex);
@@ -93,7 +89,7 @@ public:
{
auto banner = GetBanner(_bannerIndex);
CoordsXY coords{ banner->position.x * 32, banner->position.y * 32 };
CoordsXY coords = banner->position.ToCoordsXY();
if (_isLarge)
{
@@ -89,9 +89,9 @@ public:
gStaffModes[peep->staff_id] |= (1 << 1);
}
for (int32_t y = 0; y < 4 * 32; y += COORDS_XY_STEP)
for (int32_t y = 0; y < 4 * COORDS_XY_STEP; y += COORDS_XY_STEP)
{
for (int32_t x = 0; x < 4 * 32; x += COORDS_XY_STEP)
for (int32_t x = 0; x < 4 * COORDS_XY_STEP; x += COORDS_XY_STEP)
{
map_invalidate_tile_full({ (_loc.x & 0x1F80) + x, (_loc.y & 0x1F80) + y });
}
+12 -12
View File
@@ -248,23 +248,23 @@ static void virtual_floor_get_tile_properties(
if (elementType == TILE_ELEMENT_TYPE_SURFACE)
{
if (height < tileElement->clearance_height)
if (height < tileElement->GetClearanceZ())
{
*outBelowGround = true;
}
else if (height < tileElement->base_height + 2 && tileElement->AsSurface()->GetSlope() != 0)
else if (height < (tileElement->GetBaseZ() + LAND_HEIGHT_STEP) && tileElement->AsSurface()->GetSlope() != 0)
{
*outBelowGround = true;
*outOccupied = true;
}
if (height > tileElement->base_height)
if (height > tileElement->GetBaseZ())
{
*aboveGround = true;
}
continue;
}
if (height >= tileElement->clearance_height || height < tileElement->base_height)
if (height >= tileElement->GetClearanceZ() || height < tileElement->GetBaseZ())
{
continue;
}
@@ -289,10 +289,10 @@ static void virtual_floor_get_tile_properties(
void virtual_floor_paint(paint_session* session)
{
static constexpr const CoordsXY scenery_half_tile_offsets[4] = {
{ -32, 0 },
{ 0, 32 },
{ 32, 0 },
{ 0, -32 },
{ -COORDS_XY_STEP, 0 },
{ 0, COORDS_XY_STEP },
{ COORDS_XY_STEP, 0 },
{ 0, -COORDS_XY_STEP },
};
if (_virtualFloorHeight < MINIMUM_LAND_HEIGHT)
@@ -303,7 +303,7 @@ void virtual_floor_paint(paint_session* session)
// This is a virtual floor, so no interactions
session->InteractionType = VIEWPORT_INTERACTION_ITEM_NONE;
int16_t virtualFloorClipHeight = _virtualFloorHeight / 8;
int16_t virtualFloorClipHeight = _virtualFloorHeight;
// Check for occupation and walls
bool weAreOccupied;
@@ -325,9 +325,9 @@ void virtual_floor_paint(paint_session* session)
// Try the four tiles next to us for the same parameters as above,
// if our parameters differ we set an edge towards that tile
for (uint8_t i = 0; i < 4; i++)
for (uint8_t i = 0; i < NumOrthogonalDirections; i++)
{
uint8_t effectiveRotation = (4 + i - direction) % 4;
uint8_t effectiveRotation = (NumOrthogonalDirections + i - direction) % NumOrthogonalDirections;
CoordsXY theirLocation = session->MapPosition + scenery_half_tile_offsets[effectiveRotation];
bool theyAreOccupied;
@@ -341,7 +341,7 @@ void virtual_floor_paint(paint_session* session)
theirLocation, virtualFloorClipHeight, &theyAreOccupied, &theyAreOwned, &theirOccupiedEdges, &theyAreBelowGround,
&theyAreAboveGround, &theyAreLit);
if (theirOccupiedEdges & (1 << ((effectiveRotation + 2) % 4)) && (weAreOwned && !theyAreOwned))
if (theirOccupiedEdges & (1 << ((effectiveRotation + 2) % NumOrthogonalDirections)) && (weAreOwned && !theyAreOwned))
{
occupiedEdges |= 1 << i;
}
@@ -518,7 +518,7 @@ static bool tile_is_inside_clip_view(const tile_descriptor& tile)
if (tile.tile_element == nullptr)
return false;
if (tile.tile_element->base_height > gClipHeight)
if (tile.tile_element->GetBaseZ() > gClipHeight / COORDS_Z_STEP)
return false;
auto coords = tile.tile_coords.ToCoordsXY();
@@ -245,7 +245,7 @@ static void sub_68B3FB(paint_session* session, int32_t x, int32_t y)
do
{
// Only paint tile_elements below the clip height.
if ((session->ViewFlags & VIEWPORT_FLAG_CLIP_VIEW) && (tile_element->base_height > gClipHeight))
if ((session->ViewFlags & VIEWPORT_FLAG_CLIP_VIEW) && (tile_element->GetBaseZ() > gClipHeight / COORDS_Z_STEP))
continue;
Direction direction = tile_element->GetDirectionWithOffset(rotation);
+8 -10
View File
@@ -4539,9 +4539,8 @@ void Guest::UpdateRideApproachExitWaypoints()
var_37 |= 3;
auto exit = ride_get_exit_location(ride, current_ride_station);
CoordsXY targetLoc = { exit.x * 32 + 16, exit.y * 32 + 16 };
uint8_t exit_direction = direction_reverse(exit.direction);
auto targetLoc = ride_get_exit_location(ride, current_ride_station).ToCoordsXYZD().ToTileCentre();
uint8_t exit_direction = direction_reverse(targetLoc.direction);
int16_t x_shift = DirectionOffsets[exit_direction].x;
int16_t y_shift = DirectionOffsets[exit_direction].y;
@@ -4772,11 +4771,10 @@ void Guest::UpdateRideLeaveSpiralSlide()
// Actually force the final waypoint
var_37 |= 3;
auto exit = ride_get_exit_location(ride, current_ride_station);
CoordsXY targetLoc{ exit.x * 32 + 16, exit.y * 32 + 16 };
auto targetLoc = ride_get_exit_location(ride, current_ride_station).ToCoordsXYZD().ToTileCentre();
int16_t xShift = DirectionOffsets[direction_reverse(exit.direction)].x;
int16_t yShift = DirectionOffsets[direction_reverse(exit.direction)].y;
int16_t xShift = DirectionOffsets[direction_reverse(targetLoc.direction)].x;
int16_t yShift = DirectionOffsets[direction_reverse(targetLoc.direction)].y;
int16_t shiftMultiplier = 20;
@@ -6428,7 +6426,7 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
uint16_t x = peep->NextLoc.x + CoordsDirectionDelta[edge].x;
uint16_t y = peep->NextLoc.y + CoordsDirectionDelta[edge].y;
if (x > 255 * 32 || y > 255 * 32)
if (!map_is_location_valid({ x, y }))
{
return false;
}
@@ -6544,7 +6542,7 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
x += CoordsDirectionDelta[edge].x;
y += CoordsDirectionDelta[edge].y;
if (x > 255 * 32 || y > 255 * 32)
if (!map_is_location_valid({ x, y }))
{
return false;
}
@@ -6661,7 +6659,7 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
x += CoordsDirectionDelta[edge].x;
y += CoordsDirectionDelta[edge].y;
if (x > 255 * 32 || y > 255 * 32)
if (!map_is_location_valid({ x, y }))
{
return false;
}
+6 -17
View File
@@ -1571,11 +1571,7 @@ static int32_t guest_path_find_entering_park(Peep* peep, uint8_t edges)
if (chosenEntrance == 0xFF)
return guest_path_find_aimless(peep, edges);
int16_t x = gParkEntrances[chosenEntrance].x;
int16_t y = gParkEntrances[chosenEntrance].y;
int16_t z = gParkEntrances[chosenEntrance].z;
gPeepPathFindGoalPosition = { x / 32, y / 32, z >> 3 };
gPeepPathFindGoalPosition = TileCoordsXYZ(gParkEntrances[chosenEntrance]);
gPeepPathFindIgnoreForeignQueues = true;
gPeepPathFindQueueRideIndex = RIDE_ID_NULL;
@@ -1624,15 +1620,11 @@ static int32_t guest_path_find_leaving_park(Peep* peep, uint8_t edges)
if (chosenSpawn == 0xFF)
return guest_path_find_aimless(peep, edges);
PeepSpawn* peepSpawn = &gPeepSpawns[chosenSpawn];
const auto peepSpawnLoc = gPeepSpawns[chosenSpawn].ToTileStart();
Direction direction = peepSpawnLoc.direction;
int16_t x = peepSpawn->x & 0xFFE0;
int16_t y = peepSpawn->y & 0xFFE0;
uint8_t z = peepSpawn->z / 8;
Direction direction = peepSpawn->direction;
gPeepPathFindGoalPosition = { x / 32, y / 32, z };
if (x == peep->NextLoc.x && y == peep->NextLoc.y)
gPeepPathFindGoalPosition = TileCoordsXYZ(peepSpawnLoc);
if (peepSpawnLoc.x == peep->NextLoc.x && peepSpawnLoc.y == peep->NextLoc.y)
{
return peep_move_one_tile(direction, peep);
}
@@ -1683,11 +1675,8 @@ static int32_t guest_path_find_park_entrance(Peep* peep, uint8_t edges)
}
const auto& entrance = gParkEntrances[peep->current_ride];
int16_t x = entrance.x;
int16_t y = entrance.y;
int16_t z = entrance.z;
gPeepPathFindGoalPosition = { x / 32, y / 32, z >> 3 };
gPeepPathFindGoalPosition = TileCoordsXYZ(entrance);
gPeepPathFindIgnoreForeignQueues = true;
gPeepPathFindQueueRideIndex = RIDE_ID_NULL;
+1 -1
View File
@@ -771,7 +771,7 @@ bool Peep::Place(const TileCoordsXYZ& location, bool apply)
// Set the coordinate of destination to be exactly
// in the middle of a tile.
CoordsXYZ destination = { location.x * 32 + 16, location.y * 32 + 16, tileElement->GetBaseZ() + 16 };
CoordsXYZ destination = { location.ToCoordsXY().ToTileCentre(), tileElement->GetBaseZ() + 16 };
if (!map_is_location_owned(destination))
{
+14 -22
View File
@@ -2574,10 +2574,10 @@ bool Staff::UpdateFixingMoveToStationExit(bool firstRun, Ride* ride)
{
if (!firstRun)
{
TileCoordsXYZD stationPosition = ride_get_exit_location(ride, current_ride_station);
auto stationPosition = ride_get_exit_location(ride, current_ride_station).ToCoordsXY();
if (stationPosition.isNull())
{
stationPosition = ride_get_entrance_location(ride, current_ride_station);
stationPosition = ride_get_entrance_location(ride, current_ride_station).ToCoordsXY();
if (stationPosition.isNull())
{
@@ -2585,18 +2585,14 @@ bool Staff::UpdateFixingMoveToStationExit(bool firstRun, Ride* ride)
}
}
uint16_t stationX = stationPosition.x * 32;
uint16_t stationY = stationPosition.y * 32;
stationX += 16;
stationY += 16;
stationPosition = stationPosition.ToTileCentre();
CoordsXY stationPlatformDirection = DirectionOffsets[direction];
stationX += stationPlatformDirection.x * 20;
stationY += stationPlatformDirection.y * 20;
stationPosition.x += stationPlatformDirection.x * 20;
stationPosition.y += stationPlatformDirection.y * 20;
destination_x = stationX;
destination_y = stationY;
destination_x = stationPosition.x;
destination_y = stationPosition.y;
destination_tolerance = 2;
}
@@ -2664,10 +2660,10 @@ bool Staff::UpdateFixingLeaveByEntranceExit(bool firstRun, Ride* ride)
{
if (!firstRun)
{
TileCoordsXYZD exitPosition = ride_get_exit_location(ride, current_ride_station);
auto exitPosition = ride_get_exit_location(ride, current_ride_station).ToCoordsXY();
if (exitPosition.isNull())
{
exitPosition = ride_get_entrance_location(ride, current_ride_station);
exitPosition = ride_get_entrance_location(ride, current_ride_station).ToCoordsXY();
if (exitPosition.isNull())
{
@@ -2676,18 +2672,14 @@ bool Staff::UpdateFixingLeaveByEntranceExit(bool firstRun, Ride* ride)
}
}
uint16_t exitX = exitPosition.x * 32;
uint16_t exitY = exitPosition.y * 32;
exitX += 16;
exitY += 16;
exitPosition = exitPosition.ToTileCentre();
CoordsXY ebx_direction = DirectionOffsets[direction];
exitX -= ebx_direction.x * 19;
exitY -= ebx_direction.y * 19;
exitPosition.x -= ebx_direction.x * 19;
exitPosition.y -= ebx_direction.y * 19;
destination_x = exitX;
destination_y = exitY;
destination_x = exitPosition.x;
destination_y = exitPosition.y;
destination_tolerance = 2;
}
+3 -7
View File
@@ -2788,8 +2788,8 @@ private:
type = _wallTypeToEntryMap[type];
auto wallPlaceAction = WallPlaceAction(
type, { x * 32, y * 32, 0 }, edge, colourA, colourB, colourC);
auto location = TileCoordsXYZ(x, y, 0).ToCoordsXYZ();
auto wallPlaceAction = WallPlaceAction(type, location, edge, colourA, colourB, colourC);
wallPlaceAction.SetFlags(
GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND
| GAME_COMMAND_FLAG_PATH_SCENERY);
@@ -2878,11 +2878,7 @@ private:
if ((element->AsEntrance()->GetSequenceIndex()) != 0)
continue;
CoordsXYZD entrance;
entrance.x = it.x * 32;
entrance.y = it.y * 32;
entrance.z = element->GetBaseZ();
entrance.direction = element->GetDirection();
CoordsXYZD entrance = { TileCoordsXY(it.x, it.y).ToCoordsXY(), element->GetBaseZ(), element->GetDirection() };
gParkEntrances.push_back(entrance);
}
}
+3 -3
View File
@@ -471,8 +471,8 @@ bool ride_try_get_origin_element(const Ride* ride, CoordsXYE* output)
if (output != nullptr)
{
output->element = resultTileElement;
output->x = it.x * 32;
output->y = it.y * 32;
output->x = it.x * COORDS_XY_STEP;
output->y = it.y * COORDS_XY_STEP;
}
}
@@ -6984,7 +6984,7 @@ void sub_6CB945(Ride* ride)
continue;
}
CoordsXY location = { locationCoords.x * 32, locationCoords.y * 32 };
CoordsXY location = locationCoords.ToCoordsXY();
TileElement* tileElement = map_get_first_element_at(location);
if (tileElement == nullptr)
+10 -10
View File
@@ -368,8 +368,8 @@ rct_string_id TrackDesign::CreateTrackDesignMaze(const Ride& ride)
TrackDesignMazeElement maze{};
maze.maze_entry = tileElement->AsTrack()->GetMazeEntry();
maze.x = (x - startLoc.x) / 32;
maze.y = (y - startLoc.y) / 32;
maze.x = (x - startLoc.x) / COORDS_XY_STEP;
maze.y = (y - startLoc.y) / COORDS_XY_STEP;
_saveDirection = tileElement->GetDirection();
maze_elements.push_back(maze);
@@ -542,8 +542,8 @@ rct_string_id TrackDesign::CreateTrackDesignScenery()
scenery.x = static_cast<int8_t>(sceneryTilePos.x);
scenery.y = static_cast<int8_t>(sceneryTilePos.y);
int32_t z = scenery.z * 8 - gTrackPreviewOrigin.z;
z /= 8;
int32_t z = scenery.z * COORDS_Z_STEP - gTrackPreviewOrigin.z;
z /= COORDS_Z_STEP;
if (z > 127 || z < -126)
{
return STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY;
@@ -953,7 +953,7 @@ static bool TrackDesignPlaceSceneryElementRemoveGhost(
static bool TrackDesignPlaceSceneryElementGetPlaceZ(const TrackDesignSceneryElement& scenery)
{
int32_t z = scenery.z * 8 + _trackDesignPlaceZ;
int32_t z = scenery.z * COORDS_Z_STEP + _trackDesignPlaceZ;
if (z < _trackDesignPlaceSceneryZ)
{
_trackDesignPlaceSceneryZ = z;
@@ -1014,7 +1014,7 @@ static bool TrackDesignPlaceSceneryElement(
rotation += scenery.flags;
rotation &= 3;
z = scenery.z * 8 + originZ;
z = scenery.z * COORDS_Z_STEP + originZ;
quadrant = ((scenery.flags >> 2) + _currentTrackPieceDirection) & 3;
flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_PATH_SCENERY;
@@ -1256,11 +1256,11 @@ static int32_t track_design_place_all_scenery(
for (const auto& scenery : sceneryList)
{
uint8_t rotation = _currentTrackPieceDirection;
TileCoordsXY tileCoords = { originX / 32, originY / 32 };
TileCoordsXY tileCoords = { originX / COORDS_XY_STEP, originY / COORDS_XY_STEP };
TileCoordsXY offsets = { scenery.x, scenery.y };
tileCoords += offsets.Rotate(rotation);
CoordsXY mapCoord = { tileCoords.x * 32, tileCoords.y * 32 };
CoordsXY mapCoord = tileCoords.ToCoordsXY();
track_design_update_max_min_coordinates(mapCoord.x, mapCoord.y, originZ);
if (!TrackDesignPlaceSceneryElement(mapCoord, mode, scenery, rotation, originZ))
@@ -1287,7 +1287,7 @@ static int32_t track_design_place_maze(TrackDesign* td6, int16_t x, int16_t y, i
for (const auto& maze_element : td6->maze_elements)
{
uint8_t rotation = _currentTrackPieceDirection & 3;
CoordsXY mazeMapPos{ maze_element.x * 32, maze_element.y * 32 };
CoordsXY mazeMapPos = TileCoordsXY(maze_element.x, maze_element.y).ToCoordsXY();
auto mapCoord = mazeMapPos.Rotate(rotation);
mapCoord.x += x;
mapCoord.y += y;
@@ -2102,7 +2102,7 @@ static void track_design_preview_clear_map()
{
// These values were previously allocated in backup map but
// it seems more fitting to place in this function
gMapSizeUnits = 255 * 32;
gMapSizeUnits = 255 * COORDS_XY_STEP;
gMapSizeMinus2 = (264 * 32) - 2;
gMapSize = 256;
+9 -7
View File
@@ -192,11 +192,12 @@ static void track_design_save_push_tile_element(const CoordsXY& loc, TileElement
static void track_design_save_push_tile_element_desc(
const rct_object_entry* entry, const CoordsXYZ& loc, uint8_t flags, uint8_t primaryColour, uint8_t secondaryColour)
{
auto tileLoc = TileCoordsXYZ(loc);
TrackDesignSceneryElement item{};
item.scenery_object = *entry;
item.x = loc.x / 32;
item.y = loc.y / 32;
item.z = loc.z / 8;
item.x = tileLoc.x;
item.y = tileLoc.y;
item.z = tileLoc.z;
item.flags = flags;
item.primary_colour = primaryColour;
item.secondary_colour = secondaryColour;
@@ -361,14 +362,15 @@ static void track_design_save_pop_tile_element(const CoordsXY& loc, TileElement*
static void track_design_save_pop_tile_element_desc(const rct_object_entry* entry, const CoordsXYZ& loc, uint8_t flags)
{
size_t removeIndex = SIZE_MAX;
auto tileLoc = TileCoordsXYZ(loc);
for (size_t i = 0; i < _trackSavedTileElementsDesc.size(); i++)
{
TrackDesignSceneryElement* item = &_trackSavedTileElementsDesc[i];
if (item->x != loc.x / 32)
if (item->x != tileLoc.x)
continue;
if (item->y != loc.y / 32)
if (item->y != tileLoc.y)
continue;
if (item->z != loc.z / 8)
if (item->z != tileLoc.z)
continue;
if (item->flags != flags)
continue;
@@ -554,7 +556,7 @@ static void track_design_save_select_nearby_scenery_for_tile(ride_id_t rideIndex
{
if (!track_design_save_contains_tile_element(tileElement))
{
track_design_save_add_tile_element(interactionType, { x * 32, y * 32 }, tileElement);
track_design_save_add_tile_element(interactionType, TileCoordsXY(x, y).ToCoordsXY(), tileElement);
}
}
} while (!(tileElement++)->IsLastForTile());
+2 -3
View File
@@ -221,14 +221,13 @@ bool track_paint_util_has_fence(
break;
}
int32_t entranceX = (position.x / 32) + offset.x;
int32_t entranceY = (position.y / 32) + offset.y;
auto entranceLoc = TileCoordsXY(position) + offset;
int32_t entranceId = tileElement->AsTrack()->GetStationIndex();
const TileCoordsXYZD entrance = ride_get_entrance_location(ride, entranceId);
const TileCoordsXYZD exit = ride_get_exit_location(ride, entranceId);
return ((entrance.x != entranceX || entrance.y != entranceY) && (exit.x != entranceX || exit.y != entranceY));
return (entranceLoc != entrance && entranceLoc != exit);
}
void track_paint_util_paint_floor(
+4 -4
View File
@@ -4447,8 +4447,8 @@ static void vehicle_update_motion_boat_hire(Vehicle* vehicle)
}
else
{
if (ride->boat_hire_return_position.x != (flooredLocation.x / 32)
|| ride->boat_hire_return_position.y != (flooredLocation.y / 32))
auto flooredTileLoc = TileCoordsXY(flooredLocation);
if (ride->boat_hire_return_position != flooredTileLoc)
{
do_loc_6DAA97 = true;
}
@@ -9867,7 +9867,7 @@ void vehicle_update_crossings(const Vehicle* vehicle)
while (true)
{
auto* pathElement = map_get_path_element_at({ xyElement.x / 32, xyElement.y / 32, xyElement.element->base_height });
auto* pathElement = map_get_path_element_at(TileCoordsXYZ(CoordsXYZ{ xyElement, xyElement.element->GetBaseZ() }));
auto ride = get_ride(vehicle->ride);
// Many New Element parks have invisible rides hacked into the path.
@@ -9940,7 +9940,7 @@ void vehicle_update_crossings(const Vehicle* vehicle)
}
}
auto* pathElement = map_get_path_element_at({ xyElement.x / 32, xyElement.y / 32, xyElement.element->base_height });
auto* pathElement = map_get_path_element_at(TileCoordsXYZ(CoordsXYZ{ xyElement, xyElement.element->GetBaseZ() }));
if (pathElement)
{
pathElement->SetIsBlockedByVehicle(false);
+5 -4
View File
@@ -1640,7 +1640,7 @@ static void footpath_clear_wide(const CoordsXY& footpathPos)
* returns footpath element if it can be made wide
* returns NULL if it can not be made wide
*/
static TileElement* footpath_can_be_wide(const CoordsXY& footpathPos, uint8_t height)
static TileElement* footpath_can_be_wide(const CoordsXYZ& footpathPos)
{
TileElement* tileElement = map_get_first_element_at(footpathPos);
if (tileElement == nullptr)
@@ -1649,7 +1649,7 @@ static TileElement* footpath_can_be_wide(const CoordsXY& footpathPos, uint8_t he
{
if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
continue;
if (height != tileElement->base_height)
if (footpathPos.z != tileElement->GetBaseZ())
continue;
if (tileElement->AsPath()->IsQueue())
continue;
@@ -1706,7 +1706,7 @@ void footpath_update_path_wide_flags(const CoordsXY& footpathPos)
if (tileElement->AsPath()->GetEdges() == 0)
continue;
uint8_t height = tileElement->base_height;
auto height = tileElement->GetBaseZ();
// pathList is a list of elements, set by sub_6A8ACF adjacent to x,y
// Spanned from 0x00F3EFA8 to 0x00F3EFC7 (8 elements) in the original
@@ -1714,7 +1714,8 @@ void footpath_update_path_wide_flags(const CoordsXY& footpathPos)
for (int32_t direction = 0; direction < 8; ++direction)
{
pathList[direction] = footpath_can_be_wide(footpathPos + CoordsDirectionDelta[direction], height);
auto footpathLoc = CoordsXYZ(footpathPos + CoordsDirectionDelta[direction], height);
pathList[direction] = footpath_can_be_wide(footpathLoc);
}
uint8_t pathConnections = 0;
+2 -2
View File
@@ -20,8 +20,8 @@ enum
PROVISIONAL_PATH_FLAG_2 = (1 << 2),
};
constexpr auto FootpathMaxHeight = 248;
constexpr auto FootpathMinHeight = 2;
constexpr auto FootpathMaxHeight = 248 * COORDS_Z_STEP;
constexpr auto FootpathMinHeight = 2 * COORDS_Z_STEP;
constexpr auto PATH_HEIGHT_STEP = 2 * COORDS_Z_STEP;
constexpr auto PATH_CLEARANCE = 4 * COORDS_Z_STEP;
+1 -1
View File
@@ -372,7 +372,7 @@ struct TileCoordsXYZ : public TileCoordsXY
explicit TileCoordsXYZ(const CoordsXYZ& c)
: TileCoordsXY(c)
, z(c.z / 8)
, z(c.z / COORDS_Z_STEP)
{
}
+1 -1
View File
@@ -634,7 +634,7 @@ void AutoCreateMapAnimations()
while (tile_element_iterator_next(&it))
{
auto el = it.element;
auto loc = CoordsXYZ{ it.x * 32, it.y * 32, el->GetBaseZ() };
auto loc = CoordsXYZ{ TileCoordsXY(it.x, it.y).ToCoordsXY(), el->GetBaseZ() };
switch (el->GetType())
{
case TILE_ELEMENT_TYPE_BANNER:
+2 -4
View File
@@ -230,7 +230,7 @@ void mapgen_generate(mapgen_settings* settings)
map_reorganise_elements();
}
static void mapgen_place_tree(int32_t type, int32_t x, int32_t y)
static void mapgen_place_tree(int32_t type, const CoordsXY& loc)
{
rct_scenery_entry* sceneryEntry = get_small_scenery_entry(type);
if (sceneryEntry == nullptr)
@@ -238,8 +238,6 @@ static void mapgen_place_tree(int32_t type, int32_t x, int32_t y)
return;
}
auto loc = CoordsXY(x, y);
int32_t surfaceZ = tile_element_height(loc.ToTileCentre());
TileElement* tileElement = tile_element_insert({ loc, surfaceZ }, 0b1111);
assert(tileElement != nullptr);
@@ -382,7 +380,7 @@ static void mapgen_place_trees()
}
if (type != -1)
mapgen_place_tree(type, pos.x, pos.y);
mapgen_place_tree(type, pos.ToCoordsXY());
}
}
+6 -6
View File
@@ -466,32 +466,32 @@ void TileElementBase::SetOccupiedQuadrants(uint8_t quadrants)
int32_t TileElementBase::GetBaseZ() const
{
return base_height * 8;
return base_height * COORDS_Z_STEP;
}
void TileElementBase::SetBaseZ(int32_t newZ)
{
base_height = (newZ / 8);
base_height = (newZ / COORDS_Z_STEP);
}
int32_t TileElementBase::GetClearanceZ() const
{
return clearance_height * 8;
return clearance_height * COORDS_Z_STEP;
}
void TileElementBase::SetClearanceZ(int32_t newZ)
{
clearance_height = (newZ / 8);
clearance_height = (newZ / COORDS_Z_STEP);
}
int32_t RideStation::GetBaseZ() const
{
return Height * 8;
return Height * COORDS_Z_STEP;
}
void RideStation::SetBaseZ(int32_t newZ)
{
Height = newZ / 8;
Height = newZ / COORDS_Z_STEP;
}
CoordsXYZ RideStation::GetStart() const
+1 -3
View File
@@ -109,9 +109,7 @@ protected:
peep->PerformNextAction(pathingResult);
++step;
pos->x = peep->x / 32;
pos->y = peep->y / 32;
pos->z = peep->z / 8;
pos = TileCoordsXYZ(CoordsXYZ(peep->x, peep->y, peep->z));
EXPECT_PRED_FORMAT1(AssertIsNotForbiddenPosition, *pos);