mirror of https://github.com/OpenRCT2/OpenRCT2.git
Create CoordsXY::ToTileStart() and CoordsXY::ToTileCentre()
This commit is contained in:
parent
58948793e9
commit
1532ee2b23
|
@ -695,5 +695,5 @@ CoordsXY sub_68A15E(ScreenCoordsXY screenCoords)
|
|||
mapPos.y = std::clamp(mapPos.y, initialPos.y, initialPos.y + 31);
|
||||
}
|
||||
|
||||
return { mapPos.x & ~0x1F, mapPos.y & ~0x1F };
|
||||
return mapPos.ToTileStart();
|
||||
}
|
||||
|
|
|
@ -330,8 +330,7 @@ static void window_land_rights_tool_update_land_rights(ScreenCoordsXY screenCoor
|
|||
// Move to tool bottom left
|
||||
mapTile->x -= (tool_size - 1) * 16;
|
||||
mapTile->y -= (tool_size - 1) * 16;
|
||||
mapTile->x &= 0xFFE0;
|
||||
mapTile->y &= 0xFFE0;
|
||||
mapTile = mapTile->ToTileStart();
|
||||
|
||||
if (gMapSelectPositionA.x != mapTile->x)
|
||||
{
|
||||
|
|
|
@ -2212,7 +2212,7 @@ static std::optional<CoordsXY> ride_get_place_position_from_screen_position(Scre
|
|||
if (mapCoords.x == LOCATION_NULL)
|
||||
return std::nullopt;
|
||||
|
||||
return CoordsXY{ floor2(mapCoords.x, 32), floor2(mapCoords.y, 32) };
|
||||
return mapCoords.ToTileStart();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2048,8 +2048,7 @@ static uint8_t top_toolbar_tool_update_land_paint(int16_t x, int16_t y)
|
|||
// Move to tool bottom left
|
||||
mapTile->x -= (tool_size - 1) * 16;
|
||||
mapTile->y -= (tool_size - 1) * 16;
|
||||
mapTile->x &= 0xFFE0;
|
||||
mapTile->y &= 0xFFE0;
|
||||
mapTile = mapTile->ToTileStart();
|
||||
|
||||
if (gMapSelectPositionA.x != mapTile->x)
|
||||
{
|
||||
|
@ -2263,20 +2262,19 @@ static void top_toolbar_tool_update_land(int16_t x, int16_t y)
|
|||
case MAP_SELECT_TYPE_EDGE_2:
|
||||
// Line
|
||||
mapTile->y -= (tool_size - 1) * 16;
|
||||
mapTile->y &= 0xFFE0;
|
||||
mapTile->y = mapTile->ToTileStart().y;
|
||||
break;
|
||||
case MAP_SELECT_TYPE_EDGE_1:
|
||||
case MAP_SELECT_TYPE_EDGE_3:
|
||||
// Line
|
||||
mapTile->x -= (tool_size - 1) * 16;
|
||||
mapTile->x &= 0xFFE0;
|
||||
mapTile->x = mapTile->ToTileStart().x;
|
||||
break;
|
||||
default:
|
||||
// Move to tool bottom left
|
||||
mapTile->x -= (tool_size - 1) * 16;
|
||||
mapTile->y -= (tool_size - 1) * 16;
|
||||
mapTile->x &= 0xFFE0;
|
||||
mapTile->y &= 0xFFE0;
|
||||
mapTile = mapTile->ToTileStart();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1037,11 +1037,9 @@ CoordsXY screen_pos_to_map_pos(ScreenCoordsXY screenCoords, int32_t* direction)
|
|||
}
|
||||
}
|
||||
|
||||
mapCoords->x = mapCoords->x & ~0x1F;
|
||||
mapCoords->y = mapCoords->y & ~0x1F;
|
||||
if (direction != nullptr)
|
||||
*direction = my_direction;
|
||||
return *mapCoords;
|
||||
return mapCoords->ToTileStart();
|
||||
}
|
||||
|
||||
LocationXY16 screen_coord_to_viewport_coord(rct_viewport* viewport, ScreenCoordsXY screenCoords)
|
||||
|
@ -1815,7 +1813,7 @@ std::optional<CoordsXY> screen_get_map_xy_quadrant(ScreenCoordsXY screenCoords,
|
|||
return std::nullopt;
|
||||
|
||||
*quadrant = map_get_tile_quadrant(mapCoords->x, mapCoords->y);
|
||||
return CoordsXY(floor2(mapCoords->x, 32), floor2(mapCoords->y, 32));
|
||||
return mapCoords->ToTileStart();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1829,7 +1827,7 @@ std::optional<CoordsXY> screen_get_map_xy_quadrant_with_z(ScreenCoordsXY screenC
|
|||
return std::nullopt;
|
||||
|
||||
*quadrant = map_get_tile_quadrant(mapCoords->x, mapCoords->y);
|
||||
return CoordsXY(floor2(mapCoords->x, 32), floor2(mapCoords->y, 32));
|
||||
return mapCoords->ToTileStart();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1843,7 +1841,7 @@ std::optional<CoordsXY> screen_get_map_xy_side(ScreenCoordsXY screenCoords, uint
|
|||
return std::nullopt;
|
||||
|
||||
*side = map_get_tile_side(mapCoords->x, mapCoords->y);
|
||||
return CoordsXY(floor2(mapCoords->x, 32), floor2(mapCoords->y, 32));
|
||||
return mapCoords->ToTileStart();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1857,7 +1855,7 @@ std::optional<CoordsXY> screen_get_map_xy_side_with_z(ScreenCoordsXY screenCoord
|
|||
return std::nullopt;
|
||||
|
||||
*side = map_get_tile_side(mapCoords->x, mapCoords->y);
|
||||
return CoordsXY(floor2(mapCoords->x, 32), floor2(mapCoords->y, 32));
|
||||
return mapCoords->ToTileStart();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4981,13 +4981,11 @@ void Guest::UpdateRideMazePathfinding()
|
|||
targetLoc.y = destination_y;
|
||||
if (chosenEdge & 1)
|
||||
{
|
||||
targetLoc.x &= 0xFFE0;
|
||||
targetLoc.x += 16;
|
||||
targetLoc.x = targetLoc.ToTileCentre().x;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetLoc.y &= 0xFFE0;
|
||||
targetLoc.y += 16;
|
||||
targetLoc.y = targetLoc.ToTileCentre().y;
|
||||
}
|
||||
destination_x = targetLoc.x;
|
||||
destination_y = targetLoc.y;
|
||||
|
|
|
@ -3078,7 +3078,8 @@ void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result)
|
|||
}
|
||||
|
||||
auto newLoc = *loc;
|
||||
if ((newLoc.x & 0xFFE0) == next_x && (newLoc.y & 0xFFE0) == next_y)
|
||||
CoordsXY truncatedNewLoc = newLoc.ToTileStart();
|
||||
if (truncatedNewLoc.x == next_x && truncatedNewLoc.y == next_y)
|
||||
{
|
||||
int16_t height = GetZOnSlope(newLoc.x, newLoc.y);
|
||||
MoveTo(newLoc.x, newLoc.y, height);
|
||||
|
@ -3175,8 +3176,8 @@ void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result)
|
|||
}
|
||||
|
||||
// The peep is on a surface and not on a path
|
||||
next_x = newLoc.x & 0xFFE0;
|
||||
next_y = newLoc.y & 0xFFE0;
|
||||
next_x = truncatedNewLoc.x;
|
||||
next_y = truncatedNewLoc.y;
|
||||
next_z = surfaceElement->base_height;
|
||||
SetNextFlags(0, false, true);
|
||||
|
||||
|
|
|
@ -6227,7 +6227,7 @@ CoordsXYZD ride_get_entrance_or_exit_position_from_screen_position(ScreenCoordsX
|
|||
word_F4418C = coords->x;
|
||||
word_F4418E = coords->y;
|
||||
|
||||
entranceExitCoords = { floor2(coords->x, 32), floor2(coords->y, 32), stationHeight, INVALID_DIRECTION };
|
||||
entranceExitCoords = { coords->ToTileStart(), stationHeight, INVALID_DIRECTION };
|
||||
|
||||
if (ride->type == RIDE_TYPE_NULL)
|
||||
{
|
||||
|
|
|
@ -323,10 +323,12 @@ void footpath_get_coordinates_from_pos(
|
|||
}
|
||||
}
|
||||
|
||||
position = position.ToTileStart();
|
||||
|
||||
if (x != nullptr)
|
||||
*x = position.x & ~0x1F;
|
||||
*x = position.x;
|
||||
if (y != nullptr)
|
||||
*y = position.y & ~0x1F;
|
||||
*y = position.y;
|
||||
if (direction != nullptr)
|
||||
*direction = myDirection;
|
||||
if (tileElement != nullptr)
|
||||
|
|
|
@ -139,6 +139,16 @@ struct CoordsXY
|
|||
|
||||
return rotatedCoords;
|
||||
}
|
||||
|
||||
CoordsXY ToTileCentre() const
|
||||
{
|
||||
return ToTileStart() + CoordsXY{ 16, 16 };
|
||||
}
|
||||
|
||||
CoordsXY ToTileStart() const
|
||||
{
|
||||
return { floor2(x, 32), floor2(y, 32) };
|
||||
}
|
||||
};
|
||||
|
||||
struct TileCoordsXY
|
||||
|
@ -328,6 +338,12 @@ struct CoordsXYZD : public CoordsXYZ
|
|||
{
|
||||
}
|
||||
|
||||
constexpr CoordsXYZD(CoordsXY _c, int32_t _z, Direction _d)
|
||||
: CoordsXYZ(_c, _z)
|
||||
, direction(_d)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(const CoordsXYZD& other) const
|
||||
{
|
||||
return x == other.x && y == other.y && z == other.z && direction == other.direction;
|
||||
|
|
Loading…
Reference in New Issue