Correct max vehicles per ride value (#10504)

* Correct max vehicles per ride value

* Fix formatting

* Fix constant usage in TrackDesign.cpp
This commit is contained in:
Michael Steenbeek authored and GitHub committed 2020-01-04 18:10:33 +01:00
1 parent d861658669
commit 0c9b1cec96
11 files changed
+19 -23

No files matched your search

+1 -1
View File
@@ -1703,7 +1703,7 @@ rct_window* window_ride_open_vehicle(rct_vehicle* vehicle)
// Get view index
int32_t view = 1;
for (int32_t i = 0; i < MAX_VEHICLES_PER_RIDE; i++)
for (int32_t i = 0; i <= MAX_VEHICLES_PER_RIDE; i++)
{
if (ride->vehicles[i] == headVehicleSpriteIndex)
break;
+1 -1
View File
@@ -261,7 +261,7 @@ GameActionResult::Ptr TrackDesignAction::Execute() const
ride->track_colour[i].supports = _td.track_support_colour[i];
}
for (int32_t i = 0; i < MAX_VEHICLES_PER_RIDE; i++)
for (int32_t i = 0; i <= MAX_VEHICLES_PER_RIDE; i++)
{
ride->vehicle_colours[i].Body = _td.vehicle_colours[i].body_colour;
ride->vehicle_colours[i].Trim = _td.vehicle_colours[i].trim_colour;
+1 -1
View File
@@ -856,7 +856,7 @@ private:
{
dst->vehicles[i] = src->vehicles[i];
}
for (int32_t i = RCT1_MAX_TRAINS_PER_RIDE; i < MAX_VEHICLES_PER_RIDE; i++)
for (int32_t i = RCT1_MAX_TRAINS_PER_RIDE; i <= MAX_VEHICLES_PER_RIDE; i++)
{
dst->vehicles[i] = SPRITE_INDEX_NULL;
}
+1 -1
View File
@@ -211,7 +211,7 @@ private:
}
}
// Set remaining vehicles to same colour as first vehicle
for (int32_t i = RCT1_MAX_TRAINS_PER_RIDE; i < MAX_VEHICLES_PER_RIDE; i++)
for (int32_t i = RCT1_MAX_TRAINS_PER_RIDE; i <= MAX_VEHICLES_PER_RIDE; i++)
{
td->vehicle_colours[i] = td->vehicle_colours[0];
td->vehicle_additional_colour[i] = td->vehicle_additional_colour[0];
-1
View File
@@ -29,7 +29,6 @@
#define RCT12_PATROL_AREA_SIZE 128
#define RCT12_STAFF_TYPE_COUNT 4
#define RCT12_NUM_COLOUR_SCHEMES 4
#define RCT12_MAX_VEHICLES_PER_RIDE 32
#define RCT12_MAX_VEHICLE_COLOURS 32
#define RCT12_SOUND_ID_NULL 0xFF
+4 -4
View File
@@ -19,7 +19,7 @@
#define RCT2_MAX_STAFF 200
#define RCT2_MAX_BANNERS_IN_PARK 250
#define RCT2_MAX_VEHICLES_PER_RIDE 32
#define RCT2_MAX_VEHICLES_PER_RIDE 31
#define RCT2_MAX_CARS_PER_TRAIN 32
#define RCT2_MAX_CATEGORIES_PER_RIDE 2
#define RCT2_MAX_RIDE_TYPES_PER_RIDE_ENTRY 3
@@ -85,9 +85,9 @@ struct rct2_ride
LocationXY8 entrances[RCT12_MAX_STATIONS_PER_RIDE]; // 0x06A
LocationXY8 exits[RCT12_MAX_STATIONS_PER_RIDE]; // 0x072
uint16_t last_peep_in_queue[RCT12_MAX_STATIONS_PER_RIDE]; // 0x07A
uint8_t pad_082[RCT12_MAX_STATIONS_PER_RIDE]; // 0x082, Used to be number of peeps in queue in RCT1, but this has moved.
uint16_t vehicles[RCT2_MAX_VEHICLES_PER_RIDE]; // 0x086, Points to the first car in the train
uint8_t depart_flags; // 0x0C6
uint8_t pad_082[RCT12_MAX_STATIONS_PER_RIDE]; // 0x082, Used to be number of peeps in queue in RCT1, but this has moved.
uint16_t vehicles[RCT2_MAX_VEHICLES_PER_RIDE + 1]; // 0x086, Points to the first car in the train
uint8_t depart_flags; // 0x0C6
// Not sure if these should be uint or sint.
uint8_t num_stations; // 0x0C7
+1 -1
View File
@@ -569,7 +569,7 @@ void S6Exporter::ExportRide(rct2_ride* dst, const Ride* src)
dst->queue_length[i] = src->stations[i].QueueLength;
}
for (uint8_t i = 0; i < RCT2_MAX_VEHICLES_PER_RIDE; i++)
for (uint8_t i = 0; i <= RCT2_MAX_VEHICLES_PER_RIDE; i++)
{
dst->vehicles[i] = src->vehicles[i];
}
+2 -2
View File
@@ -571,11 +571,11 @@ public:
dst->stations[i].LastPeepInQueue = SPRITE_INDEX_NULL;
}
for (int32_t i = 0; i < RCT2_MAX_VEHICLES_PER_RIDE; i++)
for (int32_t i = 0; i <= RCT2_MAX_VEHICLES_PER_RIDE; i++)
{
dst->vehicles[i] = src->vehicles[i];
}
for (int32_t i = RCT2_MAX_VEHICLES_PER_RIDE; i < MAX_VEHICLES_PER_RIDE; i++)
for (int32_t i = RCT2_MAX_VEHICLES_PER_RIDE; i <= MAX_VEHICLES_PER_RIDE; i++)
{
dst->vehicles[i] = SPRITE_INDEX_NULL;
}
+5 -8
View File
@@ -1031,7 +1031,7 @@ static void ride_remove_vehicles(Ride* ride)
ride->lifecycle_flags &= ~RIDE_LIFECYCLE_ON_TRACK;
ride->lifecycle_flags &= ~(RIDE_LIFECYCLE_TEST_IN_PROGRESS | RIDE_LIFECYCLE_HAS_STALLED_VEHICLE);
for (size_t i = 0; i < MAX_VEHICLES_PER_RIDE; i++)
for (size_t i = 0; i <= MAX_VEHICLES_PER_RIDE; i++)
{
uint16_t spriteIndex = ride->vehicles[i];
while (spriteIndex != SPRITE_INDEX_NULL)
@@ -3109,10 +3109,7 @@ vehicle_colour ride_get_vehicle_colour(Ride* ride, int32_t vehicleIndex)
vehicle_colour result;
// Prevent indexing array out of bounds
if (vehicleIndex > 31)
{
vehicleIndex = 31;
}
vehicleIndex = std::min(vehicleIndex, MAX_CARS_PER_TRAIN);
result.main = ride->vehicle_colours[vehicleIndex].Body;
result.additional_1 = ride->vehicle_colours[vehicleIndex].Trim;
@@ -4643,7 +4640,7 @@ static void vehicle_create_trains(ride_id_t rideIndex, int32_t x, int32_t y, int
// Add train to ride vehicle list
move_sprite_to_list((rct_sprite*)train.head, SPRITE_LIST_VEHICLE_HEAD);
for (int32_t i = 0; i < MAX_VEHICLES_PER_RIDE; i++)
for (int32_t i = 0; i <= MAX_VEHICLES_PER_RIDE; i++)
{
if (ride->vehicles[i] == SPRITE_INDEX_NULL)
{
@@ -6499,7 +6496,7 @@ void ride_update_vehicle_colours(Ride* ride)
gfx_invalidate_screen();
}
for (int32_t i = 0; i < MAX_VEHICLES_PER_RIDE; i++)
for (int32_t i = 0; i <= MAX_VEHICLES_PER_RIDE; i++)
{
int32_t carIndex = 0;
uint16_t spriteIndex = ride->vehicles[i];
@@ -7531,7 +7528,7 @@ void fix_invalid_vehicle_sprite_sizes()
{
for (const auto& ride : GetRideManager())
{
for (uint16_t j = 0; j < MAX_VEHICLES_PER_RIDE; j++)
for (uint16_t j = 0; j <= MAX_VEHICLES_PER_RIDE; j++)
{
uint16_t rideSpriteIndex = ride.vehicles[j];
while (rideSpriteIndex != SPRITE_INDEX_NULL)
+2 -2
View File
@@ -31,7 +31,7 @@ struct Staff;
// The max number of different types of vehicle.
// Examples of vehicles here are the locomotive, tender and carriage of the Miniature Railway.
#define MAX_VEHICLES_PER_RIDE_ENTRY 4
#define MAX_VEHICLES_PER_RIDE 32
#define MAX_VEHICLES_PER_RIDE 31
#define RIDE_ENTRY_INDEX_NULL 255
#define NUM_COLOUR_SCHEMES 4
#define MAX_CATEGORIES_PER_RIDE 2
@@ -228,7 +228,7 @@ struct Ride
std::string custom_name;
uint16_t default_name_number;
TileCoordsXY overall_view;
uint16_t vehicles[MAX_VEHICLES_PER_RIDE]; // Points to the first car in the train
uint16_t vehicles[MAX_VEHICLES_PER_RIDE + 1]; // Points to the first car in the train
uint8_t depart_flags;
uint8_t num_stations;
uint8_t num_vehicles;
+1 -1
View File
@@ -110,7 +110,7 @@ rct_string_id TrackDesign::CreateTrackDesign(const Ride& ride)
ride_mode = ride.mode;
colour_scheme = ride.colour_scheme_type & 3;
for (int32_t i = 0; i < RCT12_MAX_VEHICLES_PER_RIDE; i++)
for (int32_t i = 0; i < RCT2_MAX_CARS_PER_TRAIN; i++)
{
vehicle_colours[i].body_colour = ride.vehicle_colours[i].Body;
vehicle_colours[i].trim_colour = ride.vehicle_colours[i].Trim;