Modify code using Location8 to use isNull()/setNull() (#10403)

This commit is contained in:
Michael Steenbeek 2019-12-21 11:34:46 +01:00 committed by GitHub
parent 19f9fef532
commit a2b9598341
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 65 additions and 53 deletions

View File

@ -315,7 +315,7 @@ int32_t viewport_interaction_get_item_right(ScreenCoordsXY screenCoords, viewpor
stationIndex = tileElement->AsTrack()->GetStationIndex(); stationIndex = tileElement->AsTrack()->GetStationIndex();
for (i = stationIndex; i >= 0; i--) for (i = stationIndex; i >= 0; i--)
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED) if (ride->stations[i].Start.isNull())
stationIndex--; stationIndex--;
stationIndex++; stationIndex++;
set_map_tooltip_format_arg(4 + nameArgLen + 2, uint16_t, stationIndex); set_map_tooltip_format_arg(4 + nameArgLen + 2, uint16_t, stationIndex);

View File

@ -173,7 +173,7 @@ static void window_maze_construction_close(rct_window* w)
auto ride = get_ride(_currentRideIndex); auto ride = get_ride(_currentRideIndex);
if (ride != nullptr) if (ride != nullptr)
{ {
if (ride->overall_view.xy == RCT_XY8_UNDEFINED) if (ride->overall_view.isNull())
{ {
int32_t savedPausedState = gGamePaused; int32_t savedPausedState = gGamePaused;
gGamePaused = 0; gGamePaused = 0;

View File

@ -1639,7 +1639,7 @@ static rct_window* window_ride_open_station(Ride* ride, int32_t stationIndex)
// View // View
for (int32_t i = stationIndex; i >= 0; i--) for (int32_t i = stationIndex; i >= 0; i--)
{ {
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED) if (ride->stations[i].Start.isNull())
{ {
stationIndex--; stationIndex--;
} }
@ -1905,7 +1905,7 @@ static void window_ride_init_viewport(rct_window* w)
do do
{ {
stationIndex++; stationIndex++;
if (ride->stations[stationIndex].Start.xy != RCT_XY8_UNDEFINED) if (!ride->stations[stationIndex].Start.isNull())
{ {
count--; count--;
} }
@ -1970,7 +1970,7 @@ static void window_ride_init_viewport(rct_window* w)
w->viewport_focus_coordinates.height = w->height; w->viewport_focus_coordinates.height = w->height;
// rct2: 0x006aec9c only used here so brought it into the function // rct2: 0x006aec9c only used here so brought it into the function
if (!w->viewport && ride->overall_view.xy != RCT_XY8_UNDEFINED) if (!w->viewport && !ride->overall_view.isNull())
{ {
rct_widget* view_widget = &w->widgets[WIDX_VIEWPORT]; rct_widget* view_widget = &w->widgets[WIDX_VIEWPORT];
@ -2823,7 +2823,7 @@ static rct_string_id window_ride_get_status_station(rct_window* w, void* argumen
do do
{ {
stationIndex++; stationIndex++;
if (ride->stations[stationIndex].Start.xy != RCT_XY8_UNDEFINED) if (!ride->stations[stationIndex].Start.isNull())
count--; count--;
} while (count >= 0); } while (count >= 0);

View File

@ -194,7 +194,8 @@ public:
ride->maze_tiles++; ride->maze_tiles++;
ride->stations[0].Height = tileElement->base_height; ride->stations[0].Height = tileElement->base_height;
ride->stations[0].Start.xy = 0; ride->stations[0].Start.x = 0;
ride->stations[0].Start.y = 0;
if (ride->maze_tiles == 1) if (ride->maze_tiles == 1)
{ {

View File

@ -235,7 +235,8 @@ public:
ride->maze_tiles++; ride->maze_tiles++;
ride->stations[0].Height = tileElement->base_height; ride->stations[0].Height = tileElement->base_height;
ride->stations[0].Start.xy = 0; ride->stations[0].Start.x = 0;
ride->stations[0].Start.y = 0;
if (_initialPlacement && !(flags & GAME_COMMAND_FLAG_GHOST)) if (_initialPlacement && !(flags & GAME_COMMAND_FLAG_GHOST))
{ {

View File

@ -137,12 +137,12 @@ public:
ride->type = _rideType; ride->type = _rideType;
ride->subtype = rideEntryIndex; ride->subtype = rideEntryIndex;
ride->SetColourPreset(_colour1); ride->SetColourPreset(_colour1);
ride->overall_view.xy = RCT_XY8_UNDEFINED; ride->overall_view.setNull();
ride->SetNameToDefault(); ride->SetNameToDefault();
for (int32_t i = 0; i < MAX_STATIONS; i++) for (int32_t i = 0; i < MAX_STATIONS; i++)
{ {
ride->stations[i].Start.xy = RCT_XY8_UNDEFINED; ride->stations[i].Start.setNull();
ride_clear_entrance_location(ride, i); ride_clear_entrance_location(ride, i);
ride_clear_exit_location(ride, i); ride_clear_exit_location(ride, i);
ride->stations[i].TrainAtStation = RideStation::NO_TRAIN; ride->stations[i].TrainAtStation = RideStation::NO_TRAIN;

View File

@ -239,7 +239,7 @@ private:
res->ExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION; res->ExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION;
res->Cost = refundPrice; res->Cost = refundPrice;
if (ride->overall_view.xy != RCT_XY8_UNDEFINED) if (!ride->overall_view.isNull())
{ {
int32_t x = (ride->overall_view.x * 32) + 16; int32_t x = (ride->overall_view.x * 32) + 16;
int32_t y = (ride->overall_view.y * 32) + 16; int32_t y = (ride->overall_view.y * 32) + 16;
@ -367,7 +367,7 @@ private:
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAINTENANCE | RIDE_INVALIDATE_RIDE_CUSTOMER; ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAINTENANCE | RIDE_INVALIDATE_RIDE_CUSTOMER;
if (ride->overall_view.xy != RCT_XY8_UNDEFINED) if (!ride->overall_view.isNull())
{ {
int32_t x = (ride->overall_view.x * 32) + 16; int32_t x = (ride->overall_view.x * 32) + 16;
int32_t y = (ride->overall_view.y * 32) + 16; int32_t y = (ride->overall_view.y * 32) + 16;

View File

@ -159,7 +159,7 @@ public:
window_invalidate_by_number(WC_RIDE, _rideIndex); window_invalidate_by_number(WC_RIDE, _rideIndex);
auto res = std::make_unique<GameActionResult>(); auto res = std::make_unique<GameActionResult>();
if (ride->overall_view.xy != RCT_XY8_UNDEFINED) if (!ride->overall_view.isNull())
{ {
res->Position.x = ride->overall_view.x * 32 + 16; res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16; res->Position.y = ride->overall_view.y * 32 + 16;

View File

@ -93,7 +93,7 @@ public:
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
} }
if (ride->overall_view.xy != RCT_XY8_UNDEFINED) if (!ride->overall_view.isNull())
{ {
res->Position.x = ride->overall_view.x * 32 + 16; res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16; res->Position.y = ride->overall_view.y * 32 + 16;

View File

@ -243,7 +243,7 @@ public:
} }
auto res = std::make_unique<GameActionResult>(); auto res = std::make_unique<GameActionResult>();
if (ride->overall_view.xy != RCT_XY8_UNDEFINED) if (!ride->overall_view.isNull())
{ {
res->Position.x = ride->overall_view.x * 32 + 16; res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16; res->Position.y = ride->overall_view.y * 32 + 16;

View File

@ -120,7 +120,7 @@ public:
res->ErrorTitle = _StatusErrorTitles[_status]; res->ErrorTitle = _StatusErrorTitles[_status];
ride->FormatNameTo(res->ErrorMessageArgs.data() + 6); ride->FormatNameTo(res->ErrorMessageArgs.data() + 6);
if (ride->overall_view.xy != RCT_XY8_UNDEFINED) if (!ride->overall_view.isNull())
{ {
res->Position.x = ride->overall_view.x * 32 + 16; res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16; res->Position.y = ride->overall_view.y * 32 + 16;

View File

@ -201,7 +201,7 @@ public:
ride->UpdateMaxVehicles(); ride->UpdateMaxVehicles();
auto res = std::make_unique<GameActionResult>(); auto res = std::make_unique<GameActionResult>();
if (ride->overall_view.xy != RCT_XY8_UNDEFINED) if (!ride->overall_view.isNull())
{ {
res->Position.x = ride->overall_view.x * 32 + 16; res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16; res->Position.y = ride->overall_view.y * 32 + 16;

View File

@ -554,7 +554,7 @@ public:
} }
int32_t entranceDirections = 0; int32_t entranceDirections = 0;
if (ride->overall_view.xy != RCT_XY8_UNDEFINED) if (!ride->overall_view.isNull())
{ {
if (!(GetFlags() & GAME_COMMAND_FLAG_NO_SPEND)) if (!(GetFlags() & GAME_COMMAND_FLAG_NO_SPEND))
{ {
@ -569,7 +569,7 @@ public:
} }
} }
if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN || ride->overall_view.xy == RCT_XY8_UNDEFINED) if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN || ride->overall_view.isNull())
{ {
ride->overall_view.x = mapLoc.x / 32; ride->overall_view.x = mapLoc.x / 32;
ride->overall_view.y = mapLoc.y / 32; ride->overall_view.y = mapLoc.y / 32;

View File

@ -217,7 +217,7 @@ void news_item_get_subject_location(int32_t type, int32_t subject, int32_t* x, i
{ {
case NEWS_ITEM_RIDE: case NEWS_ITEM_RIDE:
ride = get_ride(subject); ride = get_ride(subject);
if (ride == nullptr || ride->overall_view.xy == RCT_XY8_UNDEFINED) if (ride == nullptr || ride->overall_view.isNull())
{ {
*x = LOCATION_NULL; *x = LOCATION_NULL;
break; break;

View File

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

View File

@ -807,12 +807,12 @@ private:
dst->stations[i].TrainAtStation = src->station_depart[i]; dst->stations[i].TrainAtStation = src->station_depart[i];
// Direction is fixed later. // Direction is fixed later.
if (src->entrance[i].xy == RCT_XY8_UNDEFINED) if (src->entrance[i].isNull())
ride_clear_entrance_location(dst, i); ride_clear_entrance_location(dst, i);
else else
ride_set_entrance_location(dst, i, { src->entrance[i].x, src->entrance[i].y, src->station_height[i] / 2, 0 }); ride_set_entrance_location(dst, i, { src->entrance[i].x, src->entrance[i].y, src->station_height[i] / 2, 0 });
if (src->exit[i].xy == RCT_XY8_UNDEFINED) if (src->exit[i].isNull())
ride_clear_exit_location(dst, i); ride_clear_exit_location(dst, i);
else else
ride_set_exit_location(dst, i, { src->exit[i].x, src->exit[i].y, src->station_height[i] / 2, 0 }); ride_set_exit_location(dst, i, { src->exit[i].x, src->exit[i].y, src->station_height[i] / 2, 0 });
@ -827,7 +827,7 @@ private:
// All other values take 0 as their default. Since they're already memset to that, no need to do it again. // All other values take 0 as their default. Since they're already memset to that, no need to do it again.
for (int32_t i = RCT12_MAX_STATIONS_PER_RIDE; i < MAX_STATIONS; i++) for (int32_t i = RCT12_MAX_STATIONS_PER_RIDE; i < MAX_STATIONS; i++)
{ {
dst->stations[i].Start.xy = RCT_XY8_UNDEFINED; dst->stations[i].Start.setNull();
dst->stations[i].TrainAtStation = RideStation::NO_TRAIN; dst->stations[i].TrainAtStation = RideStation::NO_TRAIN;
ride_clear_entrance_location(dst, i); ride_clear_entrance_location(dst, i);
ride_clear_exit_location(dst, i); ride_clear_exit_location(dst, i);

View File

@ -534,13 +534,13 @@ void S6Exporter::ExportRide(rct2_ride* dst, const Ride* src)
TileCoordsXYZD entrance = ride_get_entrance_location(src, i); TileCoordsXYZD entrance = ride_get_entrance_location(src, i);
if (entrance.isNull()) if (entrance.isNull())
dst->entrances[i].xy = RCT_XY8_UNDEFINED; dst->entrances[i].setNull();
else else
dst->entrances[i] = { (uint8_t)entrance.x, (uint8_t)entrance.y }; dst->entrances[i] = { (uint8_t)entrance.x, (uint8_t)entrance.y };
TileCoordsXYZD exit = ride_get_exit_location(src, i); TileCoordsXYZD exit = ride_get_exit_location(src, i);
if (exit.isNull()) if (exit.isNull())
dst->exits[i].xy = RCT_XY8_UNDEFINED; dst->exits[i].setNull();
else else
dst->exits[i] = { (uint8_t)exit.x, (uint8_t)exit.y }; dst->exits[i] = { (uint8_t)exit.x, (uint8_t)exit.y };

View File

@ -528,12 +528,12 @@ public:
dst->stations[i].TrainAtStation = src->train_at_station[i]; dst->stations[i].TrainAtStation = src->train_at_station[i];
// Direction is fixed later. // Direction is fixed later.
if (src->entrances[i].xy == RCT_XY8_UNDEFINED) if (src->entrances[i].isNull())
ride_clear_entrance_location(dst, i); ride_clear_entrance_location(dst, i);
else else
ride_set_entrance_location(dst, i, { src->entrances[i].x, src->entrances[i].y, src->station_heights[i], 0 }); ride_set_entrance_location(dst, i, { src->entrances[i].x, src->entrances[i].y, src->station_heights[i], 0 });
if (src->exits[i].xy == RCT_XY8_UNDEFINED) if (src->exits[i].isNull())
ride_clear_exit_location(dst, i); ride_clear_exit_location(dst, i);
else else
ride_set_exit_location(dst, i, { src->exits[i].x, src->exits[i].y, src->station_heights[i], 0 }); ride_set_exit_location(dst, i, { src->exits[i].x, src->exits[i].y, src->station_heights[i], 0 });
@ -550,7 +550,7 @@ public:
// All other values take 0 as their default. Since they're already memset to that, no need to do it again. // All other values take 0 as their default. Since they're already memset to that, no need to do it again.
for (int32_t i = RCT12_MAX_STATIONS_PER_RIDE; i < MAX_STATIONS; i++) for (int32_t i = RCT12_MAX_STATIONS_PER_RIDE; i < MAX_STATIONS; i++)
{ {
dst->stations[i].Start.xy = RCT_XY8_UNDEFINED; dst->stations[i].Start.setNull();
dst->stations[i].TrainAtStation = RideStation::NO_TRAIN; dst->stations[i].TrainAtStation = RideStation::NO_TRAIN;
ride_clear_entrance_location(dst, i); ride_clear_entrance_location(dst, i);
ride_clear_exit_location(dst, i); ride_clear_exit_location(dst, i);

View File

@ -2229,7 +2229,7 @@ void Ride::UpdateSpiralSlide()
// Invalidate something related to station start // Invalidate something related to station start
for (int32_t i = 0; i < MAX_STATIONS; i++) for (int32_t i = 0; i < MAX_STATIONS; i++)
{ {
if (stations[i].Start.xy == RCT_XY8_UNDEFINED) if (stations[i].Start.isNull())
continue; continue;
int32_t x = stations[i].Start.x; int32_t x = stations[i].Start.x;
@ -3261,7 +3261,7 @@ static void ride_entrance_exit_connected(Ride* ride)
auto entrance = ride_get_entrance_location(ride, i); auto entrance = ride_get_entrance_location(ride, i);
auto exit = ride_get_exit_location(ride, i); auto exit = ride_get_exit_location(ride, i);
if (station_start.xy == RCT_XY8_UNDEFINED) if (station_start.isNull())
continue; continue;
if (!entrance.isNull() && !ride_entrance_exit_is_reachable(entrance)) if (!entrance.isNull() && !ride_entrance_exit_is_reachable(entrance))
{ {
@ -3290,7 +3290,7 @@ static void ride_entrance_exit_connected(Ride* ride)
static void ride_shop_connected(Ride* ride) static void ride_shop_connected(Ride* ride)
{ {
LocationXY8 coordinates = ride->stations[0].Start; LocationXY8 coordinates = ride->stations[0].Start;
if (coordinates.xy == RCT_XY8_UNDEFINED) if (coordinates.isNull())
return; return;
TileCoordsXY loc = { coordinates.x, coordinates.y }; TileCoordsXY loc = { coordinates.x, coordinates.y };
@ -3399,7 +3399,7 @@ static void ride_station_set_map_tooltip(TileElement* tileElement)
{ {
auto stationIndex = tileElement->AsTrack()->GetStationIndex(); auto stationIndex = tileElement->AsTrack()->GetStationIndex();
for (int32_t i = stationIndex; i >= 0; i--) for (int32_t i = stationIndex; i >= 0; i--)
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED) if (ride->stations[i].Start.isNull())
stationIndex--; stationIndex--;
size_t argPos = 0; size_t argPos = 0;
@ -3426,7 +3426,7 @@ static void ride_entrance_set_map_tooltip(TileElement* tileElement)
// Get the station // Get the station
auto stationIndex = tileElement->AsEntrance()->GetStationIndex(); auto stationIndex = tileElement->AsEntrance()->GetStationIndex();
for (int32_t i = stationIndex; i >= 0; i--) for (int32_t i = stationIndex; i >= 0; i--)
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED) if (ride->stations[i].Start.isNull())
stationIndex--; stationIndex--;
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE) if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE)
@ -3469,7 +3469,7 @@ static void ride_entrance_set_map_tooltip(TileElement* tileElement)
// Get the station // Get the station
stationIndex = tileElement->AsEntrance()->GetStationIndex(); stationIndex = tileElement->AsEntrance()->GetStationIndex();
for (int32_t i = stationIndex; i >= 0; i--) for (int32_t i = stationIndex; i >= 0; i--)
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED) if (ride->stations[i].Start.isNull())
stationIndex--; stationIndex--;
size_t argPos = 0; size_t argPos = 0;
@ -3824,7 +3824,7 @@ static int32_t ride_mode_check_valid_station_numbers(Ride* ride)
uint8_t no_stations = 0; uint8_t no_stations = 0;
for (uint8_t station_index = 0; station_index < MAX_STATIONS; ++station_index) for (uint8_t station_index = 0; station_index < MAX_STATIONS; ++station_index)
{ {
if (ride->stations[station_index].Start.xy != RCT_XY8_UNDEFINED) if (!ride->stations[station_index].Start.isNull())
{ {
no_stations++; no_stations++;
} }
@ -3900,7 +3900,7 @@ static int32_t ride_check_for_entrance_exit(ride_id_t rideIndex)
uint8_t exit = 0; uint8_t exit = 0;
for (i = 0; i < MAX_STATIONS; i++) for (i = 0; i < MAX_STATIONS; i++)
{ {
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED) if (ride->stations[i].Start.isNull())
continue; continue;
if (!ride_get_entrance_location(ride, i).isNull()) if (!ride_get_entrance_location(ride, i).isNull())
@ -4929,7 +4929,7 @@ static bool ride_initialise_cable_lift_track(Ride* ride, bool isApplying)
for (stationIndex = 0; stationIndex < MAX_STATIONS; stationIndex++) for (stationIndex = 0; stationIndex < MAX_STATIONS; stationIndex++)
{ {
location = ride->stations[stationIndex].Start; location = ride->stations[stationIndex].Start;
if (location.xy != RCT_XY8_UNDEFINED) if (!location.isNull())
break; break;
if (stationIndex == 3) if (stationIndex == 3)
{ {
@ -5118,7 +5118,7 @@ static void loc_6B51C0(const Ride* ride)
int32_t i; int32_t i;
for (i = 0; i < MAX_STATIONS; i++) for (i = 0; i < MAX_STATIONS; i++)
{ {
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED) if (ride->stations[i].Start.isNull())
continue; continue;
if (ride_get_entrance_location(ride, i).isNull()) if (ride_get_entrance_location(ride, i).isNull())
@ -6235,7 +6235,7 @@ CoordsXYZD ride_get_entrance_or_exit_position_from_screen_position(ScreenCoordsX
} }
LocationXY8 stationStart = ride->stations[gRideEntranceExitPlaceStationIndex].Start; LocationXY8 stationStart = ride->stations[gRideEntranceExitPlaceStationIndex].Start;
if (stationStart.xy == RCT_XY8_UNDEFINED) if (stationStart.isNull())
{ {
entranceExitCoords.x = LOCATION_NULL; entranceExitCoords.x = LOCATION_NULL;
return entranceExitCoords; return entranceExitCoords;
@ -6436,7 +6436,7 @@ bool ride_are_all_possible_entrances_and_exits_built(Ride* ride)
for (int32_t i = 0; i < MAX_STATIONS; i++) for (int32_t i = 0; i < MAX_STATIONS; i++)
{ {
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED) if (ride->stations[i].Start.isNull())
{ {
continue; continue;
} }
@ -6631,7 +6631,7 @@ static opt::optional<int32_t> ride_get_smallest_station_length(Ride* ride)
opt::optional<int32_t> result; opt::optional<int32_t> result;
for (const auto& station : ride->stations) for (const auto& station : ride->stations)
{ {
if (station.Start.xy != RCT_XY8_UNDEFINED) if (!station.Start.isNull())
{ {
if (!result.has_value() || station.Length < *result) if (!result.has_value() || station.Length < *result)
{ {
@ -6658,7 +6658,7 @@ static int32_t ride_get_track_length(Ride* ride)
for (int32_t i = 0; i < MAX_STATIONS && !foundTrack; i++) for (int32_t i = 0; i < MAX_STATIONS && !foundTrack; i++)
{ {
LocationXY8 location = ride->stations[i].Start; LocationXY8 location = ride->stations[i].Start;
if (location.xy == RCT_XY8_UNDEFINED) if (location.isNull())
continue; continue;
x = location.x * 32; x = location.x * 32;
@ -6911,7 +6911,7 @@ void sub_6CB945(Ride* ride)
{ {
for (uint8_t stationId = 0; stationId < MAX_STATIONS; ++stationId) for (uint8_t stationId = 0; stationId < MAX_STATIONS; ++stationId)
{ {
if (ride->stations[stationId].Start.xy == RCT_XY8_UNDEFINED) if (ride->stations[stationId].Start.isNull())
continue; continue;
CoordsXYZ location = { ride->stations[stationId].Start.x * 32, ride->stations[stationId].Start.y * 32, CoordsXYZ location = { ride->stations[stationId].Start.x * 32, ride->stations[stationId].Start.y * 32,
@ -7377,7 +7377,7 @@ bool ride_has_adjacent_station(Ride* ride)
* adjacent station on either side. */ * adjacent station on either side. */
for (int32_t stationNum = 0; stationNum < MAX_STATIONS; stationNum++) for (int32_t stationNum = 0; stationNum < MAX_STATIONS; stationNum++)
{ {
if (ride->stations[stationNum].Start.xy != RCT_XY8_UNDEFINED) if (!ride->stations[stationNum].Start.isNull())
{ {
/* Get the map element for the station start. */ /* Get the map element for the station start. */
uint16_t stationX = ride->stations[stationNum].Start.x * 32; uint16_t stationX = ride->stations[stationNum].Start.x * 32;

View File

@ -386,7 +386,7 @@ static void ride_ratings_begin_proximity_loop()
for (int32_t i = 0; i < MAX_STATIONS; i++) for (int32_t i = 0; i < MAX_STATIONS; i++)
{ {
if (ride->stations[i].Start.xy != RCT_XY8_UNDEFINED) if (!ride->stations[i].Start.isNull())
{ {
gRideRatingsCalcData.station_flags &= ~RIDE_RATING_STATION_FLAG_NO_ENTRANCE; gRideRatingsCalcData.station_flags &= ~RIDE_RATING_STATION_FLAG_NO_ENTRANCE;
if (ride_get_entrance_location(ride, i).isNull()) if (ride_get_entrance_location(ride, i).isNull())

View File

@ -27,7 +27,7 @@ static void ride_invalidate_station_start(Ride* ride, int32_t stationIndex, bool
*/ */
void ride_update_station(Ride* ride, int32_t stationIndex) void ride_update_station(Ride* ride, int32_t stationIndex)
{ {
if (ride->stations[stationIndex].Start.xy == RCT_XY8_UNDEFINED) if (ride->stations[stationIndex].Start.isNull())
return; return;
switch (ride->mode) switch (ride->mode)
@ -385,7 +385,7 @@ int8_t ride_get_first_valid_station_start(const Ride* ride)
{ {
for (int8_t i = 0; i < MAX_STATIONS; i++) for (int8_t i = 0; i < MAX_STATIONS; i++)
{ {
if (ride->stations[i].Start.xy != RCT_XY8_UNDEFINED) if (!ride->stations[i].Start.isNull())
{ {
return i; return i;
} }
@ -397,7 +397,7 @@ int8_t ride_get_first_empty_station_start(const Ride* ride)
{ {
for (int8_t i = 0; i < MAX_STATIONS; i++) for (int8_t i = 0; i < MAX_STATIONS; i++)
{ {
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED) if (ride->stations[i].Start.isNull())
{ {
return i; return i;
} }

View File

@ -625,7 +625,7 @@ static void ride_remove_station(Ride* ride, int32_t x, int32_t y, int32_t z)
{ {
if (ride->stations[i].Start.x == (x >> 5) && ride->stations[i].Start.y == (y >> 5) && ride->stations[i].Height == z) if (ride->stations[i].Start.x == (x >> 5) && ride->stations[i].Start.y == (y >> 5) && ride->stations[i].Height == z)
{ {
ride->stations[i].Start.xy = RCT_XY8_UNDEFINED; ride->stations[i].Start.setNull();
ride->num_stations--; ride->num_stations--;
break; break;
} }

View File

@ -3074,7 +3074,7 @@ void vehicle_test_reset(rct_vehicle* vehicle)
ride->previous_vertical_g = 0; ride->previous_vertical_g = 0;
ride->previous_lateral_g = 0; ride->previous_lateral_g = 0;
ride->testing_flags = 0; ride->testing_flags = 0;
ride->cur_test_track_location.xy = 0xFFFF; ride->cur_test_track_location.setNull();
ride->cur_test_track_z = 0xFF; ride->cur_test_track_z = 0xFF;
ride->turn_count_default = 0; ride->turn_count_default = 0;
ride->turn_count_banked = 0; ride->turn_count_banked = 0;

View File

@ -232,7 +232,7 @@ uint8_t banner_get_closest_ride_index(int32_t x, int32_t y, int32_t z)
continue; continue;
LocationXY8 location = ride.overall_view; LocationXY8 location = ride.overall_view;
if (location.xy == RCT_XY8_UNDEFINED) if (location.isNull())
continue; continue;
int32_t rideX = location.x * 32; int32_t rideX = location.x * 32;

View File

@ -31,6 +31,16 @@ struct LocationXY8
}; };
uint16_t xy; uint16_t xy;
}; };
bool isNull() const
{
return xy == RCT_XY8_UNDEFINED;
}
void setNull()
{
xy = RCT_XY8_UNDEFINED;
}
}; };
assert_struct_size(LocationXY8, 2); assert_struct_size(LocationXY8, 2);