Reduce use of MAX_RIDES and RIDE_TYPE_NULL

This commit is contained in:
Ted John 2019-08-04 14:45:17 +01:00
parent 414b53b56d
commit e23638548a
19 changed files with 69 additions and 112 deletions

View File

@ -607,7 +607,7 @@ static void window_ride_construction_close(rct_window* w)
// If we demolish a ride all windows will be closed including the construction window, // If we demolish a ride all windows will be closed including the construction window,
// the ride at this point is already gone. // the ride at this point is already gone.
auto ride = get_ride(_currentRideIndex); auto ride = get_ride(_currentRideIndex);
if (ride == nullptr || ride->type == RIDE_TYPE_NULL) if (ride == nullptr)
{ {
return; return;
} }

View File

@ -187,8 +187,8 @@ void setup_in_use_selection_flags()
for (uint8_t ride_index = 0; ride_index < 0xFF; ride_index++) for (uint8_t ride_index = 0; ride_index < 0xFF; ride_index++)
{ {
Ride* ride = get_ride(ride_index); auto ride = get_ride(ride_index);
if (ride->type != RIDE_TYPE_NULL) if (ride != nullptr)
{ {
uint8_t type = ride->subtype; uint8_t type = ride->subtype;
Editor::SetSelectedObject(OBJECT_TYPE_RIDE, type, OBJECT_SELECTION_FLAG_SELECTED); Editor::SetSelectedObject(OBJECT_TYPE_RIDE, type, OBJECT_SELECTION_FLAG_SELECTED);

View File

@ -59,8 +59,8 @@ public:
GameActionResult::Ptr Query() const override GameActionResult::Ptr Query() const override
{ {
Ride* ride = get_ride(_rideIndex); auto ride = get_ride(_rideIndex);
if (ride->type == RIDE_TYPE_NULL) if (ride == nullptr)
{ {
log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); log_warning("Invalid game command for ride %u", uint32_t(_rideIndex));
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_DEMOLISH_RIDE, STR_NONE); return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_DEMOLISH_RIDE, STR_NONE);
@ -105,8 +105,8 @@ public:
GameActionResult::Ptr Execute() const override GameActionResult::Ptr Execute() const override
{ {
Ride* ride = get_ride(_rideIndex); auto ride = get_ride(_rideIndex);
if (ride->type == RIDE_TYPE_NULL) if (ride == nullptr)
{ {
log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); log_warning("Invalid game command for ride %u", uint32_t(_rideIndex));
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_DEMOLISH_RIDE, STR_NONE); return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_DEMOLISH_RIDE, STR_NONE);

View File

@ -60,14 +60,8 @@ public:
return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, errorTitle); return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, errorTitle);
} }
if (_rideIndex >= MAX_RIDES || _rideIndex == RIDE_ID_NULL)
{
log_warning("Invalid game command for ride %d", (int32_t)_rideIndex);
return MakeResult(GA_ERROR::INVALID_PARAMETERS, errorTitle);
}
Ride* ride = get_ride(_rideIndex); Ride* ride = get_ride(_rideIndex);
if (ride == nullptr || ride->type == RIDE_TYPE_NULL) if (ride == nullptr)
{ {
log_warning("Invalid game command for ride %d", (int32_t)_rideIndex); log_warning("Invalid game command for ride %d", (int32_t)_rideIndex);
return MakeResult(GA_ERROR::INVALID_PARAMETERS, errorTitle); return MakeResult(GA_ERROR::INVALID_PARAMETERS, errorTitle);
@ -147,7 +141,7 @@ public:
auto errorTitle = _isExit ? STR_CANT_BUILD_MOVE_EXIT_FOR_THIS_RIDE_ATTRACTION auto errorTitle = _isExit ? STR_CANT_BUILD_MOVE_EXIT_FOR_THIS_RIDE_ATTRACTION
: STR_CANT_BUILD_MOVE_ENTRANCE_FOR_THIS_RIDE_ATTRACTION; : STR_CANT_BUILD_MOVE_ENTRANCE_FOR_THIS_RIDE_ATTRACTION;
Ride* ride = get_ride(_rideIndex); Ride* ride = get_ride(_rideIndex);
if (ride == nullptr || ride->type == RIDE_TYPE_NULL) if (ride == nullptr)
{ {
log_warning("Invalid game command for ride %d", (int32_t)_rideIndex); log_warning("Invalid game command for ride %d", (int32_t)_rideIndex);
return MakeResult(GA_ERROR::INVALID_PARAMETERS, errorTitle); return MakeResult(GA_ERROR::INVALID_PARAMETERS, errorTitle);

View File

@ -47,14 +47,8 @@ public:
GameActionResult::Ptr Query() const override GameActionResult::Ptr Query() const override
{ {
if (_rideIndex >= MAX_RIDES || _rideIndex == RIDE_ID_NULL) auto ride = get_ride(_rideIndex);
{ if (ride == nullptr)
log_warning("Invalid game command for ride %d", int32_t(_rideIndex));
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
}
Ride* ride = get_ride(_rideIndex);
if (ride == nullptr || ride->type == RIDE_TYPE_NULL)
{ {
log_warning("Invalid ride id %d for entrance/exit removal", (int32_t)_rideIndex); log_warning("Invalid ride id %d for entrance/exit removal", (int32_t)_rideIndex);
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE); return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
@ -117,7 +111,7 @@ public:
GameActionResult::Ptr Execute() const override GameActionResult::Ptr Execute() const override
{ {
Ride* ride = get_ride(_rideIndex); Ride* ride = get_ride(_rideIndex);
if (ride == nullptr || ride->type == RIDE_TYPE_NULL) if (ride == nullptr)
{ {
log_warning("Invalid ride id %d for entrance/exit removal", (int32_t)_rideIndex); log_warning("Invalid ride id %d for entrance/exit removal", (int32_t)_rideIndex);
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE); return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE);

View File

@ -68,14 +68,8 @@ public:
GameActionResult::Ptr Query() const override GameActionResult::Ptr Query() const override
{ {
if (_rideIndex >= MAX_RIDES || _rideIndex == RIDE_ID_NULL) auto ride = get_ride(_rideIndex);
{ if (ride == nullptr)
log_warning("Invalid game command for ride %u", uint32_t(_rideIndex));
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
}
Ride* ride = get_ride(_rideIndex);
if (ride == nullptr || ride->type == RIDE_TYPE_NULL)
{ {
log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex));
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE); return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE);

View File

@ -52,8 +52,8 @@ public:
GameActionResult::Ptr Query() const override GameActionResult::Ptr Query() const override
{ {
Ride* ride = get_ride(_rideIndex); auto ride = get_ride(_rideIndex);
if (ride->type == RIDE_TYPE_NULL) if (ride == nullptr)
{ {
log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); log_warning("Invalid game command for ride %u", uint32_t(_rideIndex));
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_RENAME_RIDE_ATTRACTION, STR_NONE); return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_RENAME_RIDE_ATTRACTION, STR_NONE);
@ -70,8 +70,8 @@ public:
GameActionResult::Ptr Execute() const override GameActionResult::Ptr Execute() const override
{ {
Ride* ride = get_ride(_rideIndex); auto ride = get_ride(_rideIndex);
if (ride->type == RIDE_TYPE_NULL) if (ride == nullptr)
{ {
log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); log_warning("Invalid game command for ride %u", uint32_t(_rideIndex));
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_RENAME_RIDE_ATTRACTION, STR_NONE); return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_RENAME_RIDE_ATTRACTION, STR_NONE);

View File

@ -57,14 +57,8 @@ public:
{ {
GameActionResult::Ptr res = std::make_unique<GameActionResult>(); GameActionResult::Ptr res = std::make_unique<GameActionResult>();
if (_rideIndex >= MAX_RIDES || _rideIndex == RIDE_ID_NULL) auto ride = get_ride(_rideIndex);
{ if (ride == nullptr)
log_warning("Invalid game command for ride %u", uint32_t(_rideIndex));
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
}
Ride* ride = get_ride(_rideIndex);
if (ride == nullptr || ride->type == RIDE_TYPE_NULL)
{ {
log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex));
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
@ -86,7 +80,7 @@ public:
res->ExpenditureType = RCT_EXPENDITURE_TYPE_PARK_RIDE_TICKETS; res->ExpenditureType = RCT_EXPENDITURE_TYPE_PARK_RIDE_TICKETS;
Ride* ride = get_ride(_rideIndex); Ride* ride = get_ride(_rideIndex);
if (ride == nullptr || ride->type == RIDE_TYPE_NULL) if (ride == nullptr)
{ {
log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex));
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE);

View File

@ -60,14 +60,8 @@ public:
GameActionResult::Ptr Query() const override GameActionResult::Ptr Query() const override
{ {
if (_rideIndex >= MAX_RIDES || _rideIndex < 0) auto ride = get_ride(_rideIndex);
{ if (ride == nullptr)
log_warning("Invalid game command for ride %d", int32_t(_rideIndex));
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE);
}
Ride* ride = get_ride(_rideIndex);
if (ride == nullptr || ride->type == RIDE_TYPE_NULL)
{ {
log_warning("Invalid ride: #%d.", (int32_t)_rideIndex); log_warning("Invalid ride: #%d.", (int32_t)_rideIndex);
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE);
@ -172,7 +166,7 @@ public:
GameActionResult::Ptr Execute() const override GameActionResult::Ptr Execute() const override
{ {
Ride* ride = get_ride(_rideIndex); Ride* ride = get_ride(_rideIndex);
if (ride == nullptr || ride->type == RIDE_TYPE_NULL) if (ride == nullptr)
{ {
log_warning("Invalid ride: #%d.", (int32_t)_rideIndex); log_warning("Invalid ride: #%d.", (int32_t)_rideIndex);
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE);

View File

@ -59,18 +59,19 @@ public:
GameActionResult::Ptr Query() const override GameActionResult::Ptr Query() const override
{ {
GameActionResult::Ptr res = std::make_unique<GameActionResult>(); GameActionResult::Ptr res = std::make_unique<GameActionResult>();
Ride* ride = get_ride(_rideIndex);
res->ErrorTitle = _StatusErrorTitles[_status];
ride->FormatNameTo(res->ErrorMessageArgs.data() + 6);
if (_rideIndex >= MAX_RIDES || _rideIndex < 0) auto ride = get_ride(_rideIndex);
if (ride == nullptr)
{ {
log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); log_warning("Invalid game command for ride %u", uint32_t(_rideIndex));
res->Error = GA_ERROR::INVALID_PARAMETERS; res->Error = GA_ERROR::INVALID_PARAMETERS;
res->ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS; res->ErrorTitle = STR_RIDE_DESCRIPTION_UNKNOWN;
res->ErrorMessage = STR_NONE;
return res; return res;
} }
res->ErrorTitle = _StatusErrorTitles[_status];
ride->FormatNameTo(res->ErrorMessageArgs.data() + 6);
if (_status != ride->status) if (_status != ride->status)
{ {
if (_status == RIDE_STATUS_SIMULATING && (ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN)) if (_status == RIDE_STATUS_SIMULATING && (ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN))
@ -107,18 +108,18 @@ public:
GameActionResult::Ptr res = std::make_unique<GameActionResult>(); GameActionResult::Ptr res = std::make_unique<GameActionResult>();
res->ExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_RUNNING_COSTS; res->ExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_RUNNING_COSTS;
Ride* ride = get_ride(_rideIndex); auto ride = get_ride(_rideIndex);
res->ErrorTitle = _StatusErrorTitles[_status]; if (ride == nullptr)
ride->FormatNameTo(res->ErrorMessageArgs.data() + 6);
if (ride->type == RIDE_TYPE_NULL)
{ {
log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); log_warning("Invalid game command for ride %u", uint32_t(_rideIndex));
res->Error = GA_ERROR::INVALID_PARAMETERS; res->Error = GA_ERROR::INVALID_PARAMETERS;
res->ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS; res->ErrorTitle = STR_RIDE_DESCRIPTION_UNKNOWN;
res->ErrorMessage = STR_NONE;
return res; return res;
} }
res->ErrorTitle = _StatusErrorTitles[_status];
ride->FormatNameTo(res->ErrorMessageArgs.data() + 6);
if (ride->overall_view.xy != RCT_XY8_UNDEFINED) if (ride->overall_view.xy != RCT_XY8_UNDEFINED)
{ {
res->Position.x = ride->overall_view.x * 32 + 16; res->Position.x = ride->overall_view.x * 32 + 16;

View File

@ -74,14 +74,8 @@ public:
} }
auto errTitle = SetVehicleTypeErrorTitle[_type]; auto errTitle = SetVehicleTypeErrorTitle[_type];
if (_rideIndex >= MAX_RIDES || _rideIndex == RIDE_ID_NULL) auto ride = get_ride(_rideIndex);
{ if (ride == nullptr)
log_warning("Invalid game command for ride %u", uint32_t(_rideIndex));
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, errTitle);
}
Ride* ride = get_ride(_rideIndex);
if (ride == nullptr || ride->type == RIDE_TYPE_NULL)
{ {
log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex));
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, errTitle); return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, errTitle);
@ -138,7 +132,7 @@ public:
{ {
auto errTitle = SetVehicleTypeErrorTitle[_type]; auto errTitle = SetVehicleTypeErrorTitle[_type];
Ride* ride = get_ride(_rideIndex); Ride* ride = get_ride(_rideIndex);
if (ride == nullptr || ride->type == RIDE_TYPE_NULL) if (ride == nullptr)
{ {
log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex));
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, errTitle); return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, errTitle);

View File

@ -93,11 +93,6 @@ public:
log_warning("Invalid ride for track placement, rideIndex = %d", (int32_t)_rideIndex); log_warning("Invalid ride for track placement, rideIndex = %d", (int32_t)_rideIndex);
return std::make_unique<TrackPlaceActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE); return std::make_unique<TrackPlaceActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
} }
if (ride->type == RIDE_TYPE_NULL)
{
log_warning("Invalid ride type, rideIndex = %d", (int32_t)_rideIndex);
return std::make_unique<TrackPlaceActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
}
rct_ride_entry* rideEntry = get_ride_entry(ride->subtype); rct_ride_entry* rideEntry = get_ride_entry(ride->subtype);
if (rideEntry == nullptr) if (rideEntry == nullptr)
{ {

View File

@ -136,14 +136,12 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
{ {
if (argv[0] == "list") if (argv[0] == "list")
{ {
Ride* ride; for (const auto& ride : GetRideManager())
int32_t i;
FOR_ALL_RIDES (i, ride)
{ {
auto name = ride->GetName(); auto name = ride.GetName();
console.WriteFormatLine( console.WriteFormatLine(
"ride: %03d type: %02u subtype %03u operating mode: %02u name: %s", i, ride->type, ride->subtype, "ride: %03d type: %02u subtype %03u operating mode: %02u name: %s", ride.id, ride.type, ride.subtype,
ride->mode, name.c_str()); ride.mode, name.c_str());
} }
} }
else if (argv[0] == "set") else if (argv[0] == "set")
@ -215,7 +213,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
{ {
console.WriteFormatLine("Invalid ride mode."); console.WriteFormatLine("Invalid ride mode.");
} }
else if (ride == nullptr || ride->type == RIDE_TYPE_NULL) else if (ride == nullptr)
{ {
console.WriteFormatLine("No ride found with index %d", ride_index); console.WriteFormatLine("No ride found with index %d", ride_index);
} }
@ -242,12 +240,12 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
} }
else else
{ {
Ride* ride = get_ride(ride_index); auto ride = get_ride(ride_index);
if (mass <= 0) if (mass <= 0)
{ {
console.WriteFormatLine("Friction value must be strictly positive"); console.WriteFormatLine("Friction value must be strictly positive");
} }
else if (ride->type == RIDE_TYPE_NULL) else if (ride == nullptr)
{ {
console.WriteFormatLine("No ride found with index %d", ride_index); console.WriteFormatLine("No ride found with index %d", ride_index);
} }
@ -282,12 +280,12 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
} }
else else
{ {
Ride* ride = get_ride(ride_index); auto ride = get_ride(ride_index);
if (excitement <= 0) if (excitement <= 0)
{ {
console.WriteFormatLine("Excitement value must be strictly positive"); console.WriteFormatLine("Excitement value must be strictly positive");
} }
else if (ride->type == RIDE_TYPE_NULL) else if (ride == nullptr)
{ {
console.WriteFormatLine("No ride found with index %d", ride_index); console.WriteFormatLine("No ride found with index %d", ride_index);
} }
@ -313,12 +311,12 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
} }
else else
{ {
Ride* ride = get_ride(ride_index); auto ride = get_ride(ride_index);
if (intensity <= 0) if (intensity <= 0)
{ {
console.WriteFormatLine("Intensity value must be strictly positive"); console.WriteFormatLine("Intensity value must be strictly positive");
} }
else if (ride->type == RIDE_TYPE_NULL) else if (ride == nullptr)
{ {
console.WriteFormatLine("No ride found with index %d", ride_index); console.WriteFormatLine("No ride found with index %d", ride_index);
} }
@ -344,12 +342,12 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
} }
else else
{ {
Ride* ride = get_ride(ride_index); auto ride = get_ride(ride_index);
if (nausea <= 0) if (nausea <= 0)
{ {
console.WriteFormatLine("Nausea value must be strictly positive"); console.WriteFormatLine("Nausea value must be strictly positive");
} }
else if (ride->type == RIDE_TYPE_NULL) else if (ride == nullptr)
{ {
console.WriteFormatLine("No ride found with index %d", ride_index); console.WriteFormatLine("No ride found with index %d", ride_index);
} }
@ -390,13 +388,11 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
if (int_valid[0] && int_valid[1]) if (int_valid[0] && int_valid[1])
{ {
uint16_t rideId{}; for (const auto& ride : GetRideManager())
Ride* ride;
FOR_ALL_RIDES (rideId, ride)
{ {
if (ride->type == rideType) if (ride.type == rideType)
{ {
auto rideSetPrice = RideSetPriceAction(rideId, price, true); auto rideSetPrice = RideSetPriceAction(ride.id, price, true);
GameActions::Execute(&rideSetPrice); GameActions::Execute(&rideSetPrice);
} }
} }

View File

@ -18,6 +18,7 @@
#include "RideTypes.h" #include "RideTypes.h"
#include "Vehicle.h" #include "Vehicle.h"
#include <limits>
#include <string_view> #include <string_view>
interface IObjectManager; interface IObjectManager;
@ -39,10 +40,10 @@ struct Staff;
#define MAX_CARS_PER_TRAIN 255 #define MAX_CARS_PER_TRAIN 255
#define MAX_STATIONS 4 #define MAX_STATIONS 4
#define MAX_RIDES 255 #define MAX_RIDES 255
#define RIDE_ID_NULL 255
#define RIDE_TYPE_NULL 255 #define RIDE_TYPE_NULL 255
#define RIDE_ADJACENCY_CHECK_DISTANCE 5 #define RIDE_ADJACENCY_CHECK_DISTANCE 5
constexpr ride_id_t RIDE_ID_NULL = std::numeric_limits<ride_id_t>::max();
constexpr uint16_t const MAX_INVERSIONS = RCT12_MAX_INVERSIONS; constexpr uint16_t const MAX_INVERSIONS = RCT12_MAX_INVERSIONS;
constexpr uint16_t const MAX_GOLF_HOLES = RCT12_MAX_GOLF_HOLES; constexpr uint16_t const MAX_GOLF_HOLES = RCT12_MAX_GOLF_HOLES;
constexpr uint16_t const MAX_HELICES = RCT12_MAX_HELICES; constexpr uint16_t const MAX_HELICES = RCT12_MAX_HELICES;

View File

@ -194,8 +194,8 @@ static void ride_ratings_update_state_1()
static void ride_ratings_update_state_2() static void ride_ratings_update_state_2()
{ {
const ride_id_t rideIndex = gRideRatingsCalcData.current_ride; const ride_id_t rideIndex = gRideRatingsCalcData.current_ride;
Ride* ride = get_ride(rideIndex); auto ride = get_ride(rideIndex);
if (ride->type == RIDE_TYPE_NULL || ride->status == RIDE_STATUS_CLOSED) if (ride == nullptr || ride->status == RIDE_STATUS_CLOSED)
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE; gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
return; return;
@ -268,8 +268,8 @@ static void ride_ratings_update_state_2()
*/ */
static void ride_ratings_update_state_3() static void ride_ratings_update_state_3()
{ {
Ride* ride = get_ride(gRideRatingsCalcData.current_ride); auto ride = get_ride(gRideRatingsCalcData.current_ride);
if (ride->type == RIDE_TYPE_NULL || ride->status == RIDE_STATUS_CLOSED) if (ride == nullptr || ride->status == RIDE_STATUS_CLOSED)
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE; gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
return; return;
@ -298,8 +298,8 @@ static void ride_ratings_update_state_4()
*/ */
static void ride_ratings_update_state_5() static void ride_ratings_update_state_5()
{ {
Ride* ride = get_ride(gRideRatingsCalcData.current_ride); auto ride = get_ride(gRideRatingsCalcData.current_ride);
if (ride->type == RIDE_TYPE_NULL || ride->status == RIDE_STATUS_CLOSED) if (ride == nullptr || ride->status == RIDE_STATUS_CLOSED)
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE; gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
return; return;

View File

@ -1870,7 +1870,7 @@ static money32 place_track_design(int16_t x, int16_t y, int16_t z, uint8_t flags
} }
auto ride = get_ride(rideIndex); auto ride = get_ride(rideIndex);
if (ride->type == RIDE_TYPE_NULL) if (ride == nullptr)
{ {
log_warning("Invalid game command for track placement, ride id = %d", ride->id); log_warning("Invalid game command for track placement, ride id = %d", ride->id);
return MONEY32_UNDEFINED; return MONEY32_UNDEFINED;

View File

@ -2157,8 +2157,8 @@ void track_paint_util_left_corkscrew_up_supports(paint_session* session, uint8_t
void track_paint(paint_session* session, uint8_t direction, int32_t height, const TileElement* tileElement) void track_paint(paint_session* session, uint8_t direction, int32_t height, const TileElement* tileElement)
{ {
ride_id_t rideIndex = tileElement->AsTrack()->GetRideIndex(); ride_id_t rideIndex = tileElement->AsTrack()->GetRideIndex();
Ride* ride = get_ride(rideIndex); auto ride = get_ride(rideIndex);
if (ride->type == RIDE_TYPE_NULL) if (ride == nullptr)
{ {
log_error("Attempted to paint invalid ride: %d", rideIndex); log_error("Attempted to paint invalid ride: %d", rideIndex);
return; return;

View File

@ -1176,8 +1176,8 @@ void footpath_update_queue_chains()
for (uint8_t* queueChainPtr = _footpathQueueChain; queueChainPtr < _footpathQueueChainNext; queueChainPtr++) for (uint8_t* queueChainPtr = _footpathQueueChain; queueChainPtr < _footpathQueueChainNext; queueChainPtr++)
{ {
ride_id_t rideIndex = *queueChainPtr; ride_id_t rideIndex = *queueChainPtr;
Ride* ride = get_ride(rideIndex); auto ride = get_ride(rideIndex);
if (ride->type == RIDE_TYPE_NULL) if (ride == nullptr)
continue; continue;
for (int32_t i = 0; i < MAX_STATIONS; i++) for (int32_t i = 0; i < MAX_STATIONS; i++)

View File

@ -509,7 +509,7 @@ money32 Park::CalculateParkValue() const
money32 Park::CalculateRideValue(const Ride* ride) const money32 Park::CalculateRideValue(const Ride* ride) const
{ {
money32 result = 0; money32 result = 0;
if (ride->type != RIDE_TYPE_NULL && ride->value != RIDE_VALUE_UNDEFINED) if (ride != nullptr && ride->value != RIDE_VALUE_UNDEFINED)
{ {
result = (ride->value * 10) * (ride_customers_in_last_5_minutes(ride) + rideBonusValue[ride->type] * 4); result = (ride->value * 10) * (ride_customers_in_last_5_minutes(ride) + rideBonusValue[ride->type] * 4);
} }