Move station_starts to TileCoordsXY

This commit is contained in:
duncanspumpkin 2019-12-21 11:48:13 +00:00
parent 7297125cae
commit 45403ac2d3
10 changed files with 25 additions and 23 deletions

View File

@ -1911,7 +1911,7 @@ static void window_ride_init_viewport(rct_window* w)
}
} while (count >= 0);
LocationXY8 location = ride->stations[stationIndex].Start;
auto location = ride->stations[stationIndex].Start;
focus.coordinate.x = location.x * 32;
focus.coordinate.y = location.y * 32;

View File

@ -2121,7 +2121,7 @@ int32_t guest_path_finding(Guest* peep)
if (numEntranceStations == 0)
{
// closestStationNum is always 0 here.
LocationXY8 entranceXY = ride->stations[closestStationNum].Start;
auto entranceXY = ride->stations[closestStationNum].Start;
loc.x = entranceXY.x;
loc.y = entranceXY.y;
loc.z = ride->stations[closestStationNum].Height;

View File

@ -2333,7 +2333,7 @@ bool Staff::UpdateFixingMoveToStationEnd(bool firstRun, Ride* ride)
return true;
}
LocationXY8 stationPosition = ride->stations[current_ride_station].Start;
auto stationPosition = ride->stations[current_ride_station].Start;
if (stationPosition.isNull())
{
return true;
@ -2425,7 +2425,7 @@ bool Staff::UpdateFixingMoveToStationStart(bool firstRun, Ride* ride)
return true;
}
LocationXY8 stationPosition = ride->stations[current_ride_station].Start;
auto stationPosition = ride->stations[current_ride_station].Start;
if (stationPosition.isNull())
{
return true;

View File

@ -532,7 +532,7 @@ void S6Exporter::ExportRide(rct2_ride* dst, const Ride* src)
}
else
{
dst->station_starts[i] = { src->stations[i].Start.x, src->stations[i].Start.y };
dst->station_starts[i] = { static_cast<uint8_t>(src->stations[i].Start.x), static_cast<uint8_t>(src->stations[i].Start.y) };
}
dst->station_heights[i] = src->stations[i].Height;
dst->station_length[i] = src->stations[i].Length;

View File

@ -3289,14 +3289,12 @@ static void ride_entrance_exit_connected(Ride* ride)
static void ride_shop_connected(Ride* ride)
{
LocationXY8 coordinates = ride->stations[0].Start;
if (coordinates.isNull())
TileCoordsXY shopLoc = ride->stations[0].Start;
if (shopLoc.isNull())
return;
TileCoordsXY loc = { coordinates.x, coordinates.y };
TrackElement* trackElement = nullptr;
TileElement* tileElement = map_get_first_element_at(loc.x, loc.y);
TileElement* tileElement = map_get_first_element_at(shopLoc.x, shopLoc.y);
do
{
if (tileElement == nullptr)
@ -3346,8 +3344,8 @@ static void ride_shop_connected(Ride* ride)
// Flip direction north<->south, east<->west
uint8_t face_direction = direction_reverse(count);
int32_t y2 = loc.y - TileDirectionDelta[face_direction].y;
int32_t x2 = loc.x - TileDirectionDelta[face_direction].x;
int32_t y2 = shopLoc.y - TileDirectionDelta[face_direction].y;
int32_t x2 = shopLoc.x - TileDirectionDelta[face_direction].x;
if (map_coord_is_connected({ x2, y2, tileElement->base_height }, face_direction))
return;
@ -4924,7 +4922,7 @@ void loc_6DDF9C(Ride* ride, TileElement* tileElement)
*/
static bool ride_initialise_cable_lift_track(Ride* ride, bool isApplying)
{
LocationXY8 location;
TileCoordsXY location;
int32_t stationIndex;
for (stationIndex = 0; stationIndex < MAX_STATIONS; stationIndex++)
{
@ -6234,7 +6232,7 @@ CoordsXYZD ride_get_entrance_or_exit_position_from_screen_position(ScreenCoordsX
return entranceExitCoords;
}
LocationXY8 stationStart = ride->stations[gRideEntranceExitPlaceStationIndex].Start;
auto stationStart = ride->stations[gRideEntranceExitPlaceStationIndex].Start;
if (stationStart.isNull())
{
entranceExitCoords.x = LOCATION_NULL;
@ -6657,12 +6655,11 @@ static int32_t ride_get_track_length(Ride* ride)
for (int32_t i = 0; i < MAX_STATIONS && !foundTrack; i++)
{
LocationXY8 location = ride->stations[i].Start;
if (location.isNull())
if (ride->stations[i].Start.isNull())
continue;
x = location.x * 32;
y = location.y * 32;
x = ride->stations[i].Start.x * 32;
y = ride->stations[i].Start.y * 32;
z = ride->stations[i].Height;
tileElement = map_get_first_element_at(x >> 5, y >> 5);

View File

@ -162,7 +162,7 @@ struct rct_ride_entry
struct RideStation
{
LocationXY8 Start;
TileCoordsXY Start;
uint8_t Height;
uint8_t Length;
uint8_t Depart;

View File

@ -1433,7 +1433,7 @@ static int32_t ride_ratings_get_scenery_score(Ride* ride)
}
else
{
LocationXY8 location = ride->stations[i].Start;
auto location = ride->stations[i].Start;
x = location.x;
y = location.y;
}

View File

@ -417,12 +417,12 @@ TileCoordsXYZD ride_get_exit_location(const Ride* ride, const int32_t stationInd
void ride_clear_entrance_location(Ride* ride, const int32_t stationIndex)
{
ride->stations[stationIndex].Entrance.x = COORDS_NULL;
ride->stations[stationIndex].Entrance.setNull();
}
void ride_clear_exit_location(Ride* ride, const int32_t stationIndex)
{
ride->stations[stationIndex].Exit.x = COORDS_NULL;
ride->stations[stationIndex].Exit.setNull();
}
void ride_set_entrance_location(Ride* ride, const int32_t stationIndex, const TileCoordsXYZD location)

View File

@ -2797,7 +2797,7 @@ static bool vehicle_can_depart_synchronised(rct_vehicle* vehicle)
return false;
int32_t station = vehicle->current_station;
LocationXY8 location = ride->stations[station].Start;
auto location = ride->stations[station].Start;
int32_t x = location.x * 32;
int32_t y = location.y * 32;
int32_t z = ride->stations[station].Height;

View File

@ -234,6 +234,11 @@ struct TileCoordsXY
{
return x == COORDS_NULL;
};
void setNull()
{
x = COORDS_NULL;
}
};
struct CoordsXYZ : public CoordsXY