mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-17 03:53:07 +01:00
Fix #16576: Cannot select vehicle types with entry index >= 256
This commit is contained in:
@@ -926,7 +926,7 @@ static std::vector<RideTypeLabel> RideDropdownData;
|
||||
// Used for sorting the vehicle type dropdown.
|
||||
struct VehicleTypeLabel
|
||||
{
|
||||
int32_t subtype_id;
|
||||
ObjectEntryIndex subtype_id;
|
||||
rct_string_id label_id;
|
||||
const char* label_string;
|
||||
};
|
||||
|
||||
@@ -31,7 +31,7 @@ constexpr static rct_string_id SetVehicleTypeErrorTitle[] = {
|
||||
STR_RIDE_SET_VEHICLE_TYPE_FAIL,
|
||||
};
|
||||
|
||||
RideSetVehicleAction::RideSetVehicleAction(RideId rideIndex, RideSetVehicleType type, uint8_t value, uint8_t colour)
|
||||
RideSetVehicleAction::RideSetVehicleAction(RideId rideIndex, RideSetVehicleType type, uint16_t value, uint8_t colour)
|
||||
: _rideIndex(rideIndex)
|
||||
, _type(type)
|
||||
, _value(value)
|
||||
@@ -152,7 +152,8 @@ GameActions::Result RideSetVehicleAction::Execute() const
|
||||
log_warning("Invalid ride entry, ride->subtype = %d", ride->subtype);
|
||||
return GameActions::Result(GameActions::Status::InvalidParameters, errTitle, STR_NONE);
|
||||
}
|
||||
auto clampValue = _value;
|
||||
uint8_t clampValue = _value;
|
||||
static_assert(sizeof(clampValue) == sizeof(ride->proposed_num_cars_per_train));
|
||||
if (!gCheatsDisableTrainLengthLimit)
|
||||
{
|
||||
clampValue = std::clamp(clampValue, rideEntry->min_cars_in_train, rideEntry->max_cars_in_train);
|
||||
|
||||
@@ -24,12 +24,12 @@ class RideSetVehicleAction final : public GameActionBase<GameCommand::SetRideVeh
|
||||
private:
|
||||
RideId _rideIndex{ RideId::GetNull() };
|
||||
RideSetVehicleType _type{};
|
||||
uint8_t _value{};
|
||||
uint16_t _value{};
|
||||
uint8_t _colour{};
|
||||
|
||||
public:
|
||||
RideSetVehicleAction() = default;
|
||||
RideSetVehicleAction(RideId rideIndex, RideSetVehicleType type, uint8_t value, uint8_t colour = 0);
|
||||
RideSetVehicleAction(RideId rideIndex, RideSetVehicleType type, uint16_t value, uint8_t colour = 0);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||
|
||||
@@ -41,4 +41,6 @@ public:
|
||||
|
||||
private:
|
||||
bool ride_is_vehicle_type_valid(Ride* ride) const;
|
||||
|
||||
static_assert(sizeof(_value) >= sizeof(ObjectEntryIndex));
|
||||
};
|
||||
|
||||
@@ -5146,10 +5146,10 @@ void Ride::UpdateNumberOfCircuits()
|
||||
}
|
||||
}
|
||||
|
||||
void Ride::SetRideEntry(int32_t rideEntry)
|
||||
void Ride::SetRideEntry(ObjectEntryIndex entryIndex)
|
||||
{
|
||||
auto colour = ride_get_unused_preset_vehicle_colour(rideEntry);
|
||||
auto rideSetVehicleAction = RideSetVehicleAction(id, RideSetVehicleType::RideEntry, rideEntry, colour);
|
||||
auto colour = ride_get_unused_preset_vehicle_colour(entryIndex);
|
||||
auto rideSetVehicleAction = RideSetVehicleAction(id, RideSetVehicleType::RideEntry, entryIndex, colour);
|
||||
GameActions::Execute(&rideSetVehicleAction);
|
||||
}
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ public:
|
||||
void Delete();
|
||||
void Crash(uint8_t vehicleIndex);
|
||||
void SetToDefaultInspectionInterval();
|
||||
void SetRideEntry(int32_t rideEntry);
|
||||
void SetRideEntry(ObjectEntryIndex entryIndex);
|
||||
|
||||
void SetNumVehicles(int32_t numVehicles);
|
||||
void SetNumCarsPerVehicle(int32_t numCarsPerVehicle);
|
||||
|
||||
Reference in New Issue
Block a user