Move station fields into new station struct

This commit is contained in:
Ted John 2019-01-01 01:14:19 +00:00
parent 8e6497fc1d
commit 37f76d1687
23 changed files with 304 additions and 296 deletions

View File

@ -303,7 +303,7 @@ int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_inter
stationIndex = tileElement->AsTrack()->GetStationIndex();
for (i = stationIndex; i >= 0; i--)
if (ride->station_starts[i].xy == RCT_XY8_UNDEFINED)
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED)
stationIndex--;
stationIndex++;
set_map_tooltip_format_arg(12, uint16_t, stationIndex);

View File

@ -1625,7 +1625,7 @@ static rct_window* window_ride_open_station(int32_t rideIndex, int32_t stationIn
// View
for (i = stationIndex; i >= 0; i--)
{
if (ride->station_starts[i].xy == RCT_XY8_UNDEFINED)
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED)
{
stationIndex--;
}
@ -1873,17 +1873,17 @@ static void window_ride_init_viewport(rct_window* w)
do
{
stationIndex++;
if (ride->station_starts[stationIndex].xy != RCT_XY8_UNDEFINED)
if (ride->stations[stationIndex].Start.xy != RCT_XY8_UNDEFINED)
{
count--;
}
} while (count >= 0);
LocationXY8 location = ride->station_starts[stationIndex];
LocationXY8 location = ride->stations[stationIndex].Start;
focus.coordinate.x = location.x * 32;
focus.coordinate.y = location.y * 32;
focus.coordinate.z = ride->station_heights[stationIndex] << 3;
focus.coordinate.z = ride->stations[stationIndex].Height << 3;
focus.sprite.type |= VIEWPORT_FOCUS_TYPE_COORDINATE;
}
else
@ -2697,7 +2697,7 @@ static rct_string_id window_ride_get_status_station(rct_window* w, void* argumen
do
{
stationIndex++;
if (ride->station_starts[stationIndex].xy != RCT_XY8_UNDEFINED)
if (ride->stations[stationIndex].Start.xy != RCT_XY8_UNDEFINED)
count--;
} while (count >= 0);
@ -2718,7 +2718,7 @@ static rct_string_id window_ride_get_status_station(rct_window* w, void* argumen
// Queue length
if (stringId == 0)
{
int32_t queueLength = ride->queue_length[stationIndex];
int32_t queueLength = ride->stations[stationIndex].QueueLength;
set_format_arg_body(static_cast<uint8_t*>(arguments), 2, (uintptr_t)queueLength, sizeof(uint16_t));
stringId = STR_QUEUE_EMPTY;
if (queueLength == 1)
@ -5581,7 +5581,7 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi
int32_t numTimes = 0;
for (int32_t i = 0; i < ride->num_stations; i++)
{
time = ride->time[numTimes];
time = ride->stations[numTimes].SegmentTime;
if (time != 0)
{
set_format_arg(0 + (numTimes * 4), uint16_t, STR_RIDE_TIME_ENTRY_WITH_SEPARATOR);
@ -5613,7 +5613,7 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi
int32_t numLengths = 0;
for (int32_t i = 0; i < ride->num_stations; i++)
{
length = ride->length[numLengths];
length = ride->stations[numLengths].SegmentLength;
if (length != 0)
{
length >>= 16;

View File

@ -370,8 +370,8 @@ static void cheat_remove_all_guests()
for (size_t stationIndex = 0; stationIndex < MAX_STATIONS; stationIndex++)
{
ride->queue_length[stationIndex] = 0;
ride->last_peep_in_queue[stationIndex] = SPRITE_INDEX_NULL;
ride->stations[stationIndex].QueueLength = 0;
ride->stations[stationIndex].LastPeepInQueue = SPRITE_INDEX_NULL;
}
for (auto trainIndex : ride->vehicles)

View File

@ -243,8 +243,8 @@ public:
map_invalidate_tile_full(flooredX, flooredY);
ride->maze_tiles++;
ride->station_heights[0] = tileElement->base_height;
ride->station_starts[0].xy = 0;
ride->stations[0].Height = tileElement->base_height;
ride->stations[0].Start.xy = 0;
if (_initialPlacement && !(flags & GAME_COMMAND_FLAG_GHOST))
{

View File

@ -148,11 +148,11 @@ public:
for (int32_t i = 0; i < MAX_STATIONS; i++)
{
ride->station_starts[i].xy = RCT_XY8_UNDEFINED;
ride->stations[i].Start.xy = RCT_XY8_UNDEFINED;
ride_clear_entrance_location(ride, i);
ride_clear_exit_location(ride, i);
ride->train_at_station[i] = 255;
ride->queue_time[i] = 0;
ride->stations[i].TrainAtStation = 255;
ride->stations[i].QueueTime = 0;
}
for (auto& vehicle : ride->vehicles)

View File

@ -1002,21 +1002,21 @@ void rct_peep::RemoveFromQueue()
{
Ride* ride = get_ride(current_ride);
uint8_t cur_station = current_ride_station;
auto& station = ride->stations[current_ride_station];
// Make sure we don't underflow, building while paused might reset it to 0 where peeps have
// not yet left the queue.
if (ride->queue_length[cur_station] > 0)
if (station.QueueLength > 0)
{
ride->queue_length[cur_station]--;
station.QueueLength--;
}
if (sprite_index == ride->last_peep_in_queue[cur_station])
if (sprite_index == station.LastPeepInQueue)
{
ride->last_peep_in_queue[cur_station] = next_in_queue;
station.LastPeepInQueue = next_in_queue;
return;
}
uint16_t spriteId = ride->last_peep_in_queue[cur_station];
auto spriteId = station.LastPeepInQueue;
while (spriteId != SPRITE_INDEX_NULL)
{
rct_peep* other_peep = GET_PEEP(spriteId);
@ -1739,7 +1739,7 @@ bool rct_peep::ShouldGoOnRide(int32_t rideIndex, int32_t entranceNum, bool atQue
if (peepAtRide)
{
// Peeps won't join a queue that has 1000 peeps already in it.
if (ride->queue_length[entranceNum] >= 1000)
if (ride->stations[entranceNum].QueueLength >= 1000)
{
peep_tried_to_enter_full_queue(this, rideIndex);
return false;
@ -1748,7 +1748,7 @@ bool rct_peep::ShouldGoOnRide(int32_t rideIndex, int32_t entranceNum, bool atQue
// Rides without queues can only have one peep waiting at a time.
if (!atQueue)
{
if (ride->last_peep_in_queue[entranceNum] != 0xFFFF)
if (ride->stations[entranceNum].LastPeepInQueue != 0xFFFF)
{
peep_tried_to_enter_full_queue(this, rideIndex);
return false;
@ -1757,9 +1757,9 @@ bool rct_peep::ShouldGoOnRide(int32_t rideIndex, int32_t entranceNum, bool atQue
else
{
// Check if there's room in the queue for the peep to enter.
if (ride->last_peep_in_queue[entranceNum] != 0xFFFF)
if (ride->stations[entranceNum].LastPeepInQueue != 0xFFFF)
{
rct_peep* lastPeepInQueue = GET_PEEP(ride->last_peep_in_queue[entranceNum]);
rct_peep* lastPeepInQueue = GET_PEEP(ride->stations[entranceNum].LastPeepInQueue);
if (abs(lastPeepInQueue->z - z) <= 6)
{
int32_t dx = abs(lastPeepInQueue->x - x);
@ -2340,7 +2340,7 @@ static bool peep_find_vehicle_to_enter(rct_peep* peep, Ride* ride, std::vector<u
}
else
{
chosen_train = ride->train_at_station[peep->current_ride_station];
chosen_train = ride->stations[peep->current_ride_station].TrainAtStation;
}
if (chosen_train == 0xFF)
{
@ -2995,8 +2995,8 @@ static void peep_head_for_nearest_ride_type(rct_peep* peep, int32_t rideType)
for (int32_t i = 0; i < numPotentialRides; i++)
{
ride = get_ride(potentialRides[i]);
int32_t rideX = ride->station_starts[0].x * 32;
int32_t rideY = ride->station_starts[0].y * 32;
int32_t rideX = ride->stations[0].Start.x * 32;
int32_t rideY = ride->stations[0].Start.y * 32;
int32_t distance = abs(rideX - peep->x) + abs(rideY - peep->y);
if (distance < closestRideDistance)
{
@ -3124,8 +3124,8 @@ static void peep_head_for_nearest_ride_with_flags(rct_peep* peep, int32_t rideTy
for (int32_t i = 0; i < numPotentialRides; i++)
{
ride = get_ride(potentialRides[i]);
int32_t rideX = ride->station_starts[0].x * 32;
int32_t rideY = ride->station_starts[0].y * 32;
int32_t rideX = ride->stations[0].Start.x * 32;
int32_t rideY = ride->stations[0].Start.y * 32;
int32_t distance = abs(rideX - peep->x) + abs(rideY - peep->y);
if (distance < closestRideDistance)
{
@ -3458,8 +3458,8 @@ static void peep_update_ride_leave_entrance_maze(rct_peep* peep, Ride* ride, Til
static void peep_update_ride_leave_entrance_spiral_slide(rct_peep* peep, Ride* ride, TileCoordsXYZD& entrance_loc)
{
entrance_loc.x = ride->station_starts[peep->current_ride_station].x * 32;
entrance_loc.y = ride->station_starts[peep->current_ride_station].y * 32;
entrance_loc.x = ride->stations[peep->current_ride_station].Start.x * 32;
entrance_loc.y = ride->stations[peep->current_ride_station].Start.y * 32;
TileElement* tile_element = ride_get_station_start_track_element(ride, peep->current_ride_station);
@ -3514,8 +3514,8 @@ static void peep_update_ride_leave_entrance_waypoints(rct_peep* peep, Ride* ride
uint8_t direction_entrance = entranceLocation.direction;
LocationXY16 waypoint;
waypoint.x = ride->station_starts[peep->current_ride_station].x * 32 + 16;
waypoint.y = ride->station_starts[peep->current_ride_station].y * 32 + 16;
waypoint.x = ride->stations[peep->current_ride_station].Start.x * 32 + 16;
waypoint.y = ride->stations[peep->current_ride_station].Start.y * 32 + 16;
TileElement* tile_element = ride_get_station_start_track_element(ride, peep->current_ride_station);
@ -3573,7 +3573,7 @@ void rct_peep::UpdateRideAdvanceThroughEntrance()
Invalidate();
actionZ = ride->station_heights[current_ride_station] * 8;
actionZ = ride->stations[current_ride_station].Height * 8;
distanceThreshold += 4;
if (xy_distance < distanceThreshold)
@ -3765,9 +3765,9 @@ void rct_peep::UpdateRideFreeVehicleEnterRide(Ride* ride)
queueTime += 3;
queueTime /= 2;
if (queueTime != ride->queue_time[current_ride_station])
if (queueTime != ride->stations[current_ride_station].QueueTime)
{
ride->queue_time[current_ride_station] = queueTime;
ride->stations[current_ride_station].QueueTime = queueTime;
window_invalidate_by_number(WC_RIDE, current_ride);
}
@ -4045,7 +4045,7 @@ void rct_peep::UpdateRideLeaveVehicle()
assert(current_ride_station < MAX_STATIONS);
TileCoordsXYZD exitLocation = ride_get_exit_location(current_ride, current_ride_station);
CoordsXYZD platformLocation;
platformLocation.z = ride->station_heights[current_ride_station];
platformLocation.z = ride->stations[current_ride_station].Height;
platformLocation.direction = exitLocation.direction ^ (1 << 1);
@ -4128,7 +4128,7 @@ void rct_peep::UpdateRideLeaveVehicle()
break;
}
platformLocation.z = ride->station_heights[current_ride_station] * 8;
platformLocation.z = ride->stations[current_ride_station].Height * 8;
peep_go_to_ride_exit(
this, ride, platformLocation.x, platformLocation.y, platformLocation.z, platformLocation.direction);
@ -4140,8 +4140,8 @@ void rct_peep::UpdateRideLeaveVehicle()
CoordsXYZ waypointLoc;
waypointLoc.z = (int16_t)exitLocation.z * 8 + RideData5[ride->type].z;
waypointLoc.x = ride->station_starts[current_ride_station].x * 32 + 16;
waypointLoc.y = ride->station_starts[current_ride_station].y * 32 + 16;
waypointLoc.x = ride->stations[current_ride_station].Start.x * 32 + 16;
waypointLoc.y = ride->stations[current_ride_station].Start.y * 32 + 16;
TileElement* trackElement = ride_get_station_start_track_element(ride, current_ride_station);
@ -4190,7 +4190,7 @@ static void peep_update_ride_prepare_for_exit(rct_peep* peep)
{
Ride* ride = get_ride(peep->current_ride);
Guard::Assert(peep->current_ride_station < std::size(ride->exits), GUARD_LINE);
Guard::Assert(peep->current_ride_station < std::size(ride->stations), GUARD_LINE);
auto exit = ride_get_exit_location(peep->current_ride, peep->current_ride_station);
int16_t x = exit.x;
int16_t y = exit.y;
@ -4261,7 +4261,7 @@ void rct_peep::UpdateRideInExit()
if (xy_distance >= 16)
{
int16_t actionZ = ride->station_heights[current_ride_station] * 8;
int16_t actionZ = ride->stations[current_ride_station].Height * 8;
actionZ += RideData5[ride->type].z;
MoveTo(actionX, actionY, actionZ);
@ -4301,7 +4301,7 @@ void rct_peep::UpdateRideApproachVehicleWaypoints()
// Motion simulators have steps this moves the peeps up the steps
if (ride->type == RIDE_TYPE_MOTION_SIMULATOR)
{
actionZ = ride->station_heights[current_ride_station] * 8 + 2;
actionZ = ride->stations[current_ride_station].Height * 8 + 2;
if (waypoint == 2)
{
@ -4337,8 +4337,8 @@ void rct_peep::UpdateRideApproachVehicleWaypoints()
rct_vehicle* vehicle = GET_VEHICLE(ride->vehicles[current_train]);
actionX = ride->station_starts[current_ride_station].x * 32 + 16;
actionY = ride->station_starts[current_ride_station].y * 32 + 16;
actionX = ride->stations[current_ride_station].Start.x * 32 + 16;
actionY = ride->stations[current_ride_station].Start.y * 32 + 16;
if (ride->type == RIDE_TYPE_ENTERPRISE)
{
@ -4375,7 +4375,7 @@ void rct_peep::UpdateRideApproachExitWaypoints()
int16_t actionZ;
if (ride->type == RIDE_TYPE_MOTION_SIMULATOR)
{
actionZ = ride->station_heights[current_ride_station] * 8 + 2;
actionZ = ride->stations[current_ride_station].Height * 8 + 2;
if ((var_37 & 3) == 1)
{
@ -4406,8 +4406,8 @@ void rct_peep::UpdateRideApproachExitWaypoints()
var_37--;
rct_vehicle* vehicle = GET_VEHICLE(ride->vehicles[current_train]);
actionX = ride->station_starts[current_ride_station].x * 32 + 16;
actionY = ride->station_starts[current_ride_station].y * 32 + 16;
actionX = ride->stations[current_ride_station].Start.x * 32 + 16;
actionY = ride->stations[current_ride_station].Start.y * 32 + 16;
if (ride->type == RIDE_TYPE_ENTERPRISE)
{
@ -4507,8 +4507,8 @@ void rct_peep::UpdateRideApproachSpiralSlide()
auto exit = ride_get_exit_location(current_ride, current_ride_station);
waypoint = 1;
var_37 = (exit.direction * 4) | (var_37 & 0x30) | waypoint;
actionX = ride->station_starts[current_ride_station].x * 32;
actionY = ride->station_starts[current_ride_station].y * 32;
actionX = ride->stations[current_ride_station].Start.x * 32;
actionY = ride->stations[current_ride_station].Start.y * 32;
assert(ride->type == RIDE_TYPE_SPIRAL_SLIDE);
const CoordsXY slidePlatformDestination = SpiralSlideWalkingPath[var_37];
@ -4526,8 +4526,8 @@ void rct_peep::UpdateRideApproachSpiralSlide()
// Actually increment the real peep waypoint
var_37++;
actionX = ride->station_starts[current_ride_station].x * 32;
actionY = ride->station_starts[current_ride_station].y * 32;
actionX = ride->stations[current_ride_station].Start.x * 32;
actionY = ride->stations[current_ride_station].Start.y * 32;
assert(ride->type == RIDE_TYPE_SPIRAL_SLIDE);
const CoordsXY slidePlatformDestination = SpiralSlideWalkingPath[var_37];
@ -4589,8 +4589,8 @@ void rct_peep::UpdateRideOnSpiralSlide()
return;
case 3:
{
int16_t newX = ride->station_starts[current_ride_station].x * 32;
int16_t newY = ride->station_starts[current_ride_station].y * 32;
int16_t newX = ride->stations[current_ride_station].Start.x * 32;
int16_t newY = ride->stations[current_ride_station].Start.y * 32;
uint8_t dir = (var_37 / 4) & 3;
// Set the location that the peep walks to go on slide again
@ -4626,8 +4626,8 @@ void rct_peep::UpdateRideOnSpiralSlide()
uint8_t waypoint = 2;
var_37 = (var_37 * 4 & 0x30) + waypoint;
actionX = ride->station_starts[current_ride_station].x * 32;
actionY = ride->station_starts[current_ride_station].y * 32;
actionX = ride->stations[current_ride_station].Start.x * 32;
actionY = ride->stations[current_ride_station].Start.y * 32;
assert(ride->type == RIDE_TYPE_SPIRAL_SLIDE);
const CoordsXY slidePlatformDestination = SpiralSlideWalkingPath[var_37];
@ -4673,8 +4673,8 @@ void rct_peep::UpdateRideLeaveSpiralSlide()
waypoint--;
// Actually decrement the peep waypoint
var_37--;
actionX = ride->station_starts[current_ride_station].x * 32;
actionY = ride->station_starts[current_ride_station].y * 32;
actionX = ride->stations[current_ride_station].Start.x * 32;
actionY = ride->stations[current_ride_station].Start.y * 32;
assert(ride->type == RIDE_TYPE_SPIRAL_SLIDE);
const CoordsXY slidePlatformDestination = SpiralSlideWalkingPath[var_37];
@ -4763,7 +4763,7 @@ void rct_peep::UpdateRideMazePathfinding()
actionX = destination_x & 0xFFE0;
actionY = destination_y & 0xFFE0;
int16_t stationHeight = ride->station_heights[0];
int16_t stationHeight = ride->stations[0].Height;
// Find the station track element
TileElement* tileElement = map_get_first_element_at(actionX / 32, actionY / 32);
@ -4901,7 +4901,7 @@ void rct_peep::UpdateRideLeaveExit()
if (UpdateAction(&actionX, &actionY, &xy_distance))
{
Invalidate();
MoveTo(actionX, actionY, ride->station_heights[current_ride_station] * 8);
MoveTo(actionX, actionY, ride->stations[current_ride_station].Height * 8);
Invalidate();
return;
}

View File

@ -2116,10 +2116,10 @@ int32_t guest_path_finding(rct_peep* peep)
if (numEntranceStations == 0)
{
// closestStationNum is always 0 here.
LocationXY8 entranceXY = ride->station_starts[closestStationNum];
LocationXY8 entranceXY = ride->stations[closestStationNum].Start;
loc.x = entranceXY.x;
loc.y = entranceXY.y;
loc.z = ride->station_heights[closestStationNum];
loc.z = ride->stations[closestStationNum].Height;
}
else
{

View File

@ -2501,10 +2501,10 @@ static void peep_interact_with_entrance(
peep->interaction_ride_index = rideIndex;
Ride* ride = get_ride(rideIndex);
uint16_t previous_last = ride->last_peep_in_queue[stationNum];
ride->last_peep_in_queue[stationNum] = peep->sprite_index;
uint16_t previous_last = ride->stations[stationNum].LastPeepInQueue;
ride->stations[stationNum].LastPeepInQueue = peep->sprite_index;
peep->next_in_queue = previous_last;
ride->queue_length[stationNum]++;
ride->stations[stationNum].QueueLength++;
peep->current_ride = rideIndex;
peep->current_ride_station = stationNum;
@ -2951,10 +2951,10 @@ static void peep_interact_with_path(rct_peep* peep, int16_t x, int16_t y, TileEl
Ride* ride = get_ride(rideIndex);
// Add the peep to the ride queue.
uint16_t old_last_peep = ride->last_peep_in_queue[stationNum];
ride->last_peep_in_queue[stationNum] = peep->sprite_index;
uint16_t old_last_peep = ride->stations[stationNum].LastPeepInQueue;
ride->stations[stationNum].LastPeepInQueue = peep->sprite_index;
peep->next_in_queue = old_last_peep;
ride->queue_length[stationNum]++;
ride->stations[stationNum].QueueLength++;
peep_decrement_num_riders(peep);
peep->current_ride = rideIndex;

View File

@ -1959,7 +1959,7 @@ void rct_peep::UpdateHeadingToInspect()
return;
}
int32_t newZ = ride->station_heights[current_ride_station] * 8;
int32_t newZ = ride->stations[current_ride_station].Height * 8;
if (delta_y < 20)
{
@ -2077,7 +2077,7 @@ void rct_peep::UpdateAnswering()
return;
}
int32_t newZ = ride->station_heights[current_ride_station] * 8;
int32_t newZ = ride->stations[current_ride_station].Height * 8;
if (delta_y < 20)
{
@ -2768,13 +2768,13 @@ bool rct_peep::UpdateFixingMoveToStationEnd(bool firstRun, Ride* ride)
return true;
}
LocationXY8 stationPosition = ride->station_starts[current_ride_station];
LocationXY8 stationPosition = ride->stations[current_ride_station].Start;
if (stationPosition.xy == RCT_XY8_UNDEFINED)
{
return true;
}
uint8_t stationZ = ride->station_heights[current_ride_station];
uint8_t stationZ = ride->stations[current_ride_station].Height;
uint16_t stationX = stationPosition.x * 32;
uint16_t stationY = stationPosition.y * 32;
@ -2864,13 +2864,13 @@ bool rct_peep::UpdateFixingMoveToStationStart(bool firstRun, Ride* ride)
return true;
}
LocationXY8 stationPosition = ride->station_starts[current_ride_station];
LocationXY8 stationPosition = ride->stations[current_ride_station].Start;
if (stationPosition.xy == RCT_XY8_UNDEFINED)
{
return true;
}
uint8_t stationZ = ride->station_heights[current_ride_station];
uint8_t stationZ = ride->stations[current_ride_station].Height;
CoordsXYE input;
input.x = stationPosition.x * 32;
@ -3147,7 +3147,7 @@ bool rct_peep::UpdateFixingLeaveByEntranceExit(bool firstRun, Ride* ride)
return false;
}
uint16_t stationHeight = ride->station_heights[current_ride_station] * 8;
uint16_t stationHeight = ride->stations[current_ride_station].Height * 8;
if (xy_distance >= 16)
{

View File

@ -809,12 +809,12 @@ private:
dst->overall_view = src->overall_view;
for (int32_t i = 0; i < RCT12_MAX_STATIONS_PER_RIDE; i++)
{
dst->station_starts[i] = src->station_starts[i];
dst->station_heights[i] = src->station_height[i] / 2;
dst->station_length[i] = src->station_length[i];
dst->station_depart[i] = src->station_light[i];
dst->stations[i].Start = src->station_starts[i];
dst->stations[i].Height = src->station_height[i] / 2;
dst->stations[i].Length = src->station_length[i];
dst->stations[i].Depart = src->station_light[i];
dst->train_at_station[i] = src->station_depart[i];
dst->stations[i].TrainAtStation = src->station_depart[i];
// Direction is fixed later.
if (src->entrance[i].xy == RCT_XY8_UNDEFINED)
@ -827,21 +827,21 @@ private:
else
ride_set_exit_location(dst, i, { src->exit[i].x, src->exit[i].y, src->station_height[i] / 2, 0 });
dst->queue_time[i] = src->queue_time[i];
dst->last_peep_in_queue[i] = src->last_peep_in_queue[i];
dst->queue_length[i] = src->num_peeps_in_queue[i];
dst->stations[i].QueueTime = src->queue_time[i];
dst->stations[i].LastPeepInQueue = src->last_peep_in_queue[i];
dst->stations[i].QueueLength = src->num_peeps_in_queue[i];
dst->time[i] = src->time[i];
dst->length[i] = src->length[i];
dst->stations[i].SegmentTime = src->time[i];
dst->stations[i].SegmentLength = src->length[i];
}
// 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++)
{
dst->station_starts[i].xy = RCT_XY8_UNDEFINED;
dst->train_at_station[i] = 255;
dst->stations[i].Start.xy = RCT_XY8_UNDEFINED;
dst->stations[i].TrainAtStation = 255;
ride_clear_entrance_location(dst, i);
ride_clear_exit_location(dst, i);
dst->last_peep_in_queue[i] = SPRITE_INDEX_NULL;
dst->stations[i].LastPeepInQueue = SPRITE_INDEX_NULL;
}
dst->num_stations = src->num_stations;
@ -1588,9 +1588,9 @@ private:
void FixRidePeepLinks(Ride* ride, const uint16_t* spriteIndexMap)
{
for (auto& peep : ride->last_peep_in_queue)
for (auto& station : ride->stations)
{
peep = MapSpriteIndex(peep, spriteIndexMap);
station.LastPeepInQueue = MapSpriteIndex(station.LastPeepInQueue, spriteIndexMap);
}
ride->mechanic = MapSpriteIndex(ride->mechanic, spriteIndexMap);
if (ride->type == RIDE_TYPE_SPIRAL_SLIDE)

View File

@ -498,11 +498,11 @@ void S6Exporter::ExportRide(rct2_ride* dst, const Ride* src)
for (int32_t i = 0; i < RCT12_MAX_STATIONS_PER_RIDE; i++)
{
dst->station_starts[i] = src->station_starts[i];
dst->station_heights[i] = src->station_heights[i];
dst->station_length[i] = src->station_length[i];
dst->station_depart[i] = src->station_depart[i];
dst->train_at_station[i] = src->train_at_station[i];
dst->station_starts[i] = src->stations[i].Start;
dst->station_heights[i] = src->stations[i].Height;
dst->station_length[i] = src->stations[i].Length;
dst->station_depart[i] = src->stations[i].Depart;
dst->train_at_station[i] = src->stations[i].TrainAtStation;
TileCoordsXYZD entrance = ride_get_entrance_location(src, i);
if (entrance.isNull())
@ -516,14 +516,14 @@ void S6Exporter::ExportRide(rct2_ride* dst, const Ride* src)
else
dst->exits[i] = { (uint8_t)exit.x, (uint8_t)exit.y };
dst->last_peep_in_queue[i] = src->last_peep_in_queue[i];
dst->last_peep_in_queue[i] = src->stations[i].LastPeepInQueue;
dst->length[i] = src->length[i];
dst->time[i] = src->time[i];
dst->length[i] = src->stations[i].SegmentLength;
dst->time[i] = src->stations[i].SegmentTime;
dst->queue_time[i] = src->queue_time[i];
dst->queue_time[i] = src->stations[i].QueueTime;
dst->queue_length[i] = src->queue_length[i];
dst->queue_length[i] = src->stations[i].QueueLength;
}
for (uint8_t i = 0; i < RCT2_MAX_VEHICLES_PER_RIDE; i++)

View File

@ -540,11 +540,11 @@ public:
for (int32_t i = 0; i < RCT12_MAX_STATIONS_PER_RIDE; i++)
{
dst->station_starts[i] = src->station_starts[i];
dst->station_heights[i] = src->station_heights[i];
dst->station_length[i] = src->station_length[i];
dst->station_depart[i] = src->station_depart[i];
dst->train_at_station[i] = src->train_at_station[i];
dst->stations[i].Start = src->station_starts[i];
dst->stations[i].Height = src->station_heights[i];
dst->stations[i].Length = src->station_length[i];
dst->stations[i].Depart = src->station_depart[i];
dst->stations[i].TrainAtStation = src->train_at_station[i];
// Direction is fixed later.
if (src->entrances[i].xy == RCT_XY8_UNDEFINED)
@ -557,23 +557,23 @@ public:
else
ride_set_exit_location(dst, i, { src->entrances[i].x, src->entrances[i].y, src->station_heights[i], 0 });
dst->last_peep_in_queue[i] = src->last_peep_in_queue[i];
dst->stations[i].LastPeepInQueue = src->last_peep_in_queue[i];
dst->length[i] = src->length[i];
dst->time[i] = src->time[i];
dst->stations[i].SegmentLength = src->length[i];
dst->stations[i].SegmentTime = src->time[i];
dst->queue_time[i] = src->queue_time[i];
dst->stations[i].QueueTime = src->queue_time[i];
dst->queue_length[i] = src->queue_length[i];
dst->stations[i].QueueLength = src->queue_length[i];
}
// 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++)
{
dst->station_starts[i].xy = RCT_XY8_UNDEFINED;
dst->train_at_station[i] = 255;
dst->stations[i].Start.xy = RCT_XY8_UNDEFINED;
dst->stations[i].TrainAtStation = 255;
ride_clear_entrance_location(dst, i);
ride_clear_exit_location(dst, i);
dst->last_peep_in_queue[i] = SPRITE_INDEX_NULL;
dst->stations[i].LastPeepInQueue = SPRITE_INDEX_NULL;
}
for (int32_t i = 0; i < RCT2_MAX_VEHICLES_PER_RIDE; i++)

View File

@ -350,7 +350,7 @@ int32_t ride_get_total_queue_length(Ride* ride)
int32_t i, queueLength = 0;
for (i = 0; i < MAX_STATIONS; i++)
if (!ride_get_entrance_location(ride, i).isNull())
queueLength += ride->queue_length[i];
queueLength += ride->stations[i].QueueLength;
return queueLength;
}
@ -359,7 +359,7 @@ int32_t ride_get_max_queue_time(Ride* ride)
uint8_t i, queueTime = 0;
for (i = 0; i < MAX_STATIONS; i++)
if (!ride_get_entrance_location(ride, i).isNull())
queueTime = std::max(queueTime, ride->queue_time[i]);
queueTime = std::max(queueTime, ride->stations[i].QueueTime);
return (int32_t)queueTime;
}
@ -367,7 +367,7 @@ rct_peep* ride_get_queue_head_guest(Ride* ride, int32_t stationIndex)
{
rct_peep* peep;
rct_peep* result = nullptr;
uint16_t spriteIndex = ride->last_peep_in_queue[stationIndex];
uint16_t spriteIndex = ride->stations[stationIndex].LastPeepInQueue;
while ((peep = try_get_guest(spriteIndex)) != nullptr)
{
spriteIndex = peep->next_in_queue;
@ -380,13 +380,13 @@ static void ride_update_queue_length(Ride* ride, int32_t stationIndex)
{
uint16_t count = 0;
rct_peep* peep;
uint16_t spriteIndex = ride->last_peep_in_queue[stationIndex];
uint16_t spriteIndex = ride->stations[stationIndex].LastPeepInQueue;
while ((peep = try_get_guest(spriteIndex)) != nullptr)
{
spriteIndex = peep->next_in_queue;
count++;
}
ride->queue_length[stationIndex] = count;
ride->stations[stationIndex].QueueLength = count;
}
void ride_queue_insert_guest_at_front(Ride* ride, int32_t stationIndex, rct_peep* peep)
@ -399,7 +399,7 @@ void ride_queue_insert_guest_at_front(Ride* ride, int32_t stationIndex, rct_peep
rct_peep* queueHeadGuest = ride_get_queue_head_guest(ride, peep->current_ride_station);
if (queueHeadGuest == nullptr)
{
ride->last_peep_in_queue[peep->current_ride_station] = peep->sprite_index;
ride->stations[peep->current_ride_station].LastPeepInQueue = peep->sprite_index;
}
else
{
@ -950,7 +950,7 @@ int32_t ride_get_total_length(Ride* ride)
{
int32_t i, totalLength = 0;
for (i = 0; i < ride->num_stations; i++)
totalLength += ride->length[i];
totalLength += ride->stations[i].SegmentLength;
return totalLength;
}
@ -958,7 +958,7 @@ int32_t ride_get_total_time(Ride* ride)
{
int32_t i, totalTime = 0;
for (i = 0; i < ride->num_stations; i++)
totalTime += ride->time[i];
totalTime += ride->stations[i].SegmentTime;
return totalTime;
}
@ -1123,7 +1123,7 @@ static void ride_remove_vehicles(Ride* ride)
}
for (size_t i = 0; i < MAX_STATIONS; i++)
ride->train_at_station[i] = 255;
ride->stations[i].TrainAtStation = 255;
}
}
@ -2349,11 +2349,11 @@ static void ride_spiral_slide_update(Ride* ride)
// Invalidate something related to station start
for (int32_t i = 0; i < MAX_STATIONS; i++)
{
if (ride->station_starts[i].xy == RCT_XY8_UNDEFINED)
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED)
continue;
int32_t x = ride->station_starts[i].x;
int32_t y = ride->station_starts[i].y;
int32_t x = ride->stations[i].Start.x;
int32_t y = ride->stations[i].Start.y;
TileElement* tileElement = ride_get_station_start_track_element(ride, i);
if (tileElement == nullptr)
@ -3040,9 +3040,9 @@ static void ride_music_update(int32_t rideIndex)
return;
}
int32_t x = ride->station_starts[0].x * 32 + 16;
int32_t y = ride->station_starts[0].y * 32 + 16;
int32_t z = ride->station_heights[0] * 8;
int32_t x = ride->stations[0].Start.x * 32 + 16;
int32_t y = ride->stations[0].Start.y * 32 + 16;
int32_t z = ride->stations[0].Height * 8;
int32_t sampleRate = 22050;
@ -3468,7 +3468,7 @@ static void ride_entrance_exit_connected(Ride* ride, int32_t ride_idx)
{
for (int32_t i = 0; i < MAX_STATIONS; ++i)
{
LocationXY8 station_start = ride->station_starts[i];
LocationXY8 station_start = ride->stations[i].Start;
TileCoordsXYZD entrance = ride_get_entrance_location(ride_idx, i);
TileCoordsXYZD exit = ride_get_exit_location(ride_idx, i);
@ -3505,7 +3505,7 @@ static void ride_shop_connected(Ride* ride, int32_t ride_idx)
int32_t x, y, count;
TileElement* tileElement;
LocationXY8 coordinates = ride->station_starts[0];
LocationXY8 coordinates = ride->stations[0].Start;
if (coordinates.xy == RCT_XY8_UNDEFINED)
return;
@ -3629,7 +3629,7 @@ static void ride_station_set_map_tooltip(TileElement* tileElement)
stationIndex = tileElement->AsTrack()->GetStationIndex();
for (i = stationIndex; i >= 0; i--)
if (ride->station_starts[i].xy == RCT_XY8_UNDEFINED)
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED)
stationIndex--;
set_map_tooltip_format_arg(0, rct_string_id, STR_RIDE_MAP_TIP);
@ -3657,7 +3657,7 @@ static void ride_entrance_set_map_tooltip(TileElement* tileElement)
// Get the station
stationIndex = tileElement->AsEntrance()->GetStationIndex();
for (i = stationIndex; i >= 0; i--)
if (ride->station_starts[i].xy == RCT_XY8_UNDEFINED)
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED)
stationIndex--;
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE)
@ -3665,7 +3665,7 @@ static void ride_entrance_set_map_tooltip(TileElement* tileElement)
// Get the queue length
int32_t queueLength = 0;
if (!ride_get_entrance_location(ride, stationIndex).isNull())
queueLength = ride->queue_length[stationIndex];
queueLength = ride->stations[stationIndex].QueueLength;
set_map_tooltip_format_arg(0, rct_string_id, STR_RIDE_MAP_TIP);
set_map_tooltip_format_arg(2, rct_string_id, ride->num_stations <= 1 ? STR_RIDE_ENTRANCE : STR_RIDE_STATION_X_ENTRANCE);
@ -3691,7 +3691,7 @@ static void ride_entrance_set_map_tooltip(TileElement* tileElement)
// Get the station
stationIndex = tileElement->AsEntrance()->GetStationIndex();
for (i = stationIndex; i >= 0; i--)
if (ride->station_starts[i].xy == RCT_XY8_UNDEFINED)
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED)
stationIndex--;
set_map_tooltip_format_arg(0, rct_string_id, ride->num_stations <= 1 ? STR_RIDE_EXIT : STR_RIDE_STATION_X_EXIT);
@ -4313,7 +4313,7 @@ static int32_t ride_mode_check_valid_station_numbers(Ride* ride)
uint8_t no_stations = 0;
for (uint8_t station_index = 0; station_index < MAX_STATIONS; ++station_index)
{
if (ride->station_starts[station_index].xy != RCT_XY8_UNDEFINED)
if (ride->stations[station_index].Start.xy != RCT_XY8_UNDEFINED)
{
no_stations++;
}
@ -4387,7 +4387,7 @@ static int32_t ride_check_for_entrance_exit(int32_t rideIndex)
uint8_t exit = 0;
for (i = 0; i < MAX_STATIONS; i++)
{
if (ride->station_starts[i].xy == RCT_XY8_UNDEFINED)
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED)
continue;
if (!ride_get_entrance_location(ride, i).isNull())
@ -5300,7 +5300,7 @@ static bool ride_create_vehicles(Ride* ride, int32_t rideIndex, CoordsXYE* eleme
ride->lifecycle_flags |= RIDE_LIFECYCLE_ON_TRACK;
for (int32_t i = 0; i < MAX_STATIONS; i++)
{
ride->station_depart[i] = (ride->station_depart[i] & 0x80) | 1;
ride->stations[i].Depart = (ride->stations[i].Depart & 0x80) | 1;
}
//
@ -5409,7 +5409,7 @@ static bool ride_initialise_cable_lift_track(Ride* ride, bool isApplying)
int32_t stationIndex;
for (stationIndex = 0; stationIndex < MAX_STATIONS; stationIndex++)
{
location = ride->station_starts[stationIndex];
location = ride->stations[stationIndex].Start;
if (location.xy != RCT_XY8_UNDEFINED)
break;
if (stationIndex == 3)
@ -5421,7 +5421,7 @@ static bool ride_initialise_cable_lift_track(Ride* ride, bool isApplying)
int32_t x = location.x * 32;
int32_t y = location.y * 32;
int32_t z = ride->station_heights[stationIndex];
int32_t z = ride->stations[stationIndex].Height;
bool success = false;
TileElement* tileElement = map_get_first_element_at(location.x, location.y);
@ -5608,7 +5608,7 @@ static void loc_6B51C0(int32_t rideIndex)
int32_t i;
for (i = 0; i < MAX_STATIONS; i++)
{
if (ride->station_starts[i].xy == RCT_XY8_UNDEFINED)
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED)
continue;
if (ride_get_entrance_location(rideIndex, i).isNull())
@ -5629,9 +5629,9 @@ static void loc_6B51C0(int32_t rideIndex)
if (ride->type != RIDE_TYPE_MAZE)
{
int32_t x = ride->station_starts[i].x * 32;
int32_t y = ride->station_starts[i].y * 32;
int32_t z = ride->station_heights[i] * 8;
int32_t x = ride->stations[i].Start.x * 32;
int32_t y = ride->stations[i].Start.y * 32;
int32_t z = ride->stations[i].Height * 8;
window_scroll_to_location(w, x, y, z);
CoordsXYE trackElement;
@ -5731,9 +5731,9 @@ int32_t ride_is_valid_for_test(int32_t rideIndex, int32_t goingToBeOpen, int32_t
ride->lifecycle_flags |= RIDE_LIFECYCLE_EVER_BEEN_OPENED;
}
// z = ride->station_heights[i] * 8;
trackElement.x = ride->station_starts[stationIndex].x * 32;
trackElement.y = ride->station_starts[stationIndex].y * 32;
// z = ride->stations[i].Height * 8;
trackElement.x = ride->stations[stationIndex].Start.x * 32;
trackElement.y = ride->stations[stationIndex].Start.y * 32;
trackElement.element = loc_6B4F6B(rideIndex, trackElement.x, trackElement.y);
if (trackElement.element == nullptr)
{
@ -5870,9 +5870,9 @@ int32_t ride_is_valid_for_open(int32_t rideIndex, int32_t goingToBeOpen, int32_t
ride->lifecycle_flags |= RIDE_LIFECYCLE_EVER_BEEN_OPENED;
}
// z = ride->station_heights[i] * 8;
trackElement.x = ride->station_starts[stationIndex].x * 32;
trackElement.y = ride->station_starts[stationIndex].y * 32;
// z = ride->stations[i].Height * 8;
trackElement.x = ride->stations[stationIndex].Start.x * 32;
trackElement.y = ride->stations[stationIndex].Start.y * 32;
trackElement.element = loc_6B4F6B(rideIndex, trackElement.x, trackElement.y);
if (trackElement.element == nullptr)
{
@ -7170,7 +7170,7 @@ void ride_get_entrance_or_exit_position_from_screen_position(
}
ride = get_ride(gRideEntranceExitPlaceRideIndex);
stationHeight = ride->station_heights[gRideEntranceExitPlaceStationIndex];
stationHeight = ride->stations[gRideEntranceExitPlaceStationIndex].Height;
screen_get_map_xy_with_z(screenX, screenY, stationHeight * 8, &mapX, &mapY);
if (mapX == LOCATION_NULL)
@ -7189,7 +7189,7 @@ void ride_get_entrance_or_exit_position_from_screen_position(
if (ride->type == RIDE_TYPE_NULL)
return;
LocationXY8 stationStart = ride->station_starts[gRideEntranceExitPlaceStationIndex];
LocationXY8 stationStart = ride->stations[gRideEntranceExitPlaceStationIndex].Start;
if (stationStart.xy == RCT_XY8_UNDEFINED)
return;
@ -7394,7 +7394,7 @@ bool ride_are_all_possible_entrances_and_exits_built(Ride* ride)
for (int32_t i = 0; i < MAX_STATIONS; i++)
{
if (ride->station_starts[i].xy == RCT_XY8_UNDEFINED)
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED)
{
continue;
}
@ -7590,9 +7590,9 @@ static int32_t ride_get_smallest_station_length(Ride* ride)
auto result = std::numeric_limits<int32_t>::max();
for (int32_t i = 0; i < MAX_STATIONS; i++)
{
if (ride->station_starts[i].xy != RCT_XY8_UNDEFINED)
if (ride->stations[i].Start.xy != RCT_XY8_UNDEFINED)
{
result = std::min<int32_t>(result, ride->station_length[i]);
result = std::min<int32_t>(result, ride->stations[i].Length);
}
}
return result;
@ -7612,13 +7612,13 @@ static int32_t ride_get_track_length(Ride* ride)
for (int32_t i = 0; i < MAX_STATIONS && !foundTrack; i++)
{
LocationXY8 location = ride->station_starts[i];
LocationXY8 location = ride->stations[i].Start;
if (location.xy == RCT_XY8_UNDEFINED)
continue;
x = location.x * 32;
y = location.y * 32;
z = ride->station_heights[i];
z = ride->stations[i].Height;
tileElement = map_get_first_element_at(x >> 5, y >> 5);
do
@ -8057,13 +8057,13 @@ void sub_6CB945(int32_t rideIndex)
{
for (uint8_t stationId = 0; stationId < MAX_STATIONS; ++stationId)
{
if (ride->station_starts[stationId].xy == RCT_XY8_UNDEFINED)
if (ride->stations[stationId].Start.xy == RCT_XY8_UNDEFINED)
continue;
LocationXYZ16 location = {
(int16_t)(ride->station_starts[stationId].x * 32),
(int16_t)(ride->station_starts[stationId].y * 32),
(ride->station_heights[stationId]),
(int16_t)(ride->stations[stationId].Start.x * 32),
(int16_t)(ride->stations[stationId].Start.y * 32),
(ride->stations[stationId].Height),
};
uint8_t direction = 0xFF;
@ -8240,7 +8240,7 @@ void sub_6CB945(int32_t rideIndex)
ride_set_exit_location(
ride, stationId,
{ location.x / 32, location.y / 32, ride->station_heights[stationId],
{ location.x / 32, location.y / 32, ride->stations[stationId].Height,
(uint8_t)tileElement->GetDirection() });
}
else
@ -8251,7 +8251,7 @@ void sub_6CB945(int32_t rideIndex)
TileCoordsXYZD entranceLocation = {
location.x / 32,
location.y / 32,
ride->station_heights[stationId],
ride->stations[stationId].Height,
(uint8_t)tileElement->GetDirection(),
};
ride_set_entrance_location(ride, stationId, entranceLocation);
@ -8532,12 +8532,12 @@ bool ride_has_adjacent_station(Ride* ride)
* adjacent station on either side. */
for (int32_t stationNum = 0; stationNum < MAX_STATIONS; stationNum++)
{
if (ride->station_starts[stationNum].xy != RCT_XY8_UNDEFINED)
if (ride->stations[stationNum].Start.xy != RCT_XY8_UNDEFINED)
{
/* Get the map element for the station start. */
uint16_t stationX = ride->station_starts[stationNum].x * 32;
uint16_t stationY = ride->station_starts[stationNum].y * 32;
uint8_t stationZ = ride->station_heights[stationNum];
uint16_t stationX = ride->stations[stationNum].Start.x * 32;
uint16_t stationY = ride->stations[stationNum].Start.y * 32;
uint8_t stationZ = ride->stations[stationNum].Height;
TileElement* stationElement = get_station_platform(stationX, stationY, stationZ, 0);
if (stationElement == nullptr)
@ -8854,8 +8854,8 @@ void determine_ride_entrance_and_exit_locations()
{
for (int32_t stationIndex = 0; stationIndex < MAX_STATIONS; stationIndex++)
{
TileCoordsXYZD entranceLoc = ride->entrances[stationIndex];
TileCoordsXYZD exitLoc = ride->exits[stationIndex];
TileCoordsXYZD entranceLoc = ride->stations[stationIndex].Entrance;
TileCoordsXYZD exitLoc = ride->stations[stationIndex].Exit;
bool fixEntrance = false;
bool fixExit = false;
@ -8872,7 +8872,7 @@ void determine_ride_entrance_and_exit_locations()
}
else
{
ride->entrances[stationIndex].direction = (uint8_t)entranceElement->GetDirection();
ride->stations[stationIndex].Entrance.direction = (uint8_t)entranceElement->GetDirection();
}
}
@ -8888,7 +8888,7 @@ void determine_ride_entrance_and_exit_locations()
}
else
{
ride->exits[stationIndex].direction = (uint8_t)entranceElement->GetDirection();
ride->stations[stationIndex].Exit.direction = (uint8_t)entranceElement->GetDirection();
}
}
@ -8926,15 +8926,15 @@ void determine_ride_entrance_and_exit_locations()
}
// The expected height is where entrances and exit reside in non-hacked parks.
const uint8_t expectedHeight = ride->station_heights[stationIndex];
const uint8_t expectedHeight = ride->stations[stationIndex].Height;
if (fixEntrance && entranceElement->GetEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE)
{
if (alreadyFoundEntrance)
{
if (ride->entrances[stationIndex].z == expectedHeight)
if (ride->stations[stationIndex].Entrance.z == expectedHeight)
continue;
if (ride->entrances[stationIndex].z > entranceElement->base_height)
if (ride->stations[stationIndex].Entrance.z > entranceElement->base_height)
continue;
}
@ -8956,9 +8956,9 @@ void determine_ride_entrance_and_exit_locations()
{
if (alreadyFoundExit)
{
if (ride->exits[stationIndex].z == expectedHeight)
if (ride->stations[stationIndex].Exit.z == expectedHeight)
continue;
if (ride->exits[stationIndex].z > entranceElement->base_height)
if (ride->stations[stationIndex].Exit.z > entranceElement->base_height)
continue;
}

View File

@ -136,6 +136,22 @@ struct rct_ride_entry
#pragma pack(pop)
struct RideStation
{
LocationXY8 Start;
uint8_t Height;
uint8_t Length;
uint8_t Depart;
uint8_t TrainAtStation;
TileCoordsXYZD Entrance;
TileCoordsXYZD Exit;
int32_t SegmentLength;
uint16_t SegmentTime;
uint8_t QueueTime;
uint16_t QueueLength;
uint16_t LastPeepInQueue;
};
/**
* Ride structure.
*
@ -164,16 +180,6 @@ struct Ride
};
};
LocationXY8 overall_view;
LocationXY8 station_starts[MAX_STATIONS];
uint8_t station_heights[MAX_STATIONS];
uint8_t station_length[MAX_STATIONS];
uint8_t station_depart[MAX_STATIONS];
// ride->vehicle index for current train waiting for passengers
// at station
uint8_t train_at_station[MAX_STATIONS];
TileCoordsXYZD entrances[MAX_STATIONS];
TileCoordsXYZD exits[MAX_STATIONS];
uint16_t last_peep_in_queue[MAX_STATIONS];
uint16_t vehicles[MAX_VEHICLES_PER_RIDE]; // Points to the first car in the train
uint8_t depart_flags;
uint8_t num_stations;
@ -209,8 +215,6 @@ struct Ride
int32_t average_speed;
uint8_t current_test_segment;
uint8_t average_speed_test_timeout;
int32_t length[MAX_STATIONS];
uint16_t time[MAX_STATIONS];
fixed16_2dp max_positive_vertical_g;
fixed16_2dp max_negative_vertical_g;
fixed16_2dp max_lateral_g;
@ -322,7 +326,6 @@ struct Ride
uint8_t connected_message_throttle;
money32 income_per_hour;
money32 profit;
uint8_t queue_time[MAX_STATIONS];
uint8_t track_colour_main[NUM_COLOUR_SCHEMES];
uint8_t track_colour_additional[NUM_COLOUR_SCHEMES];
uint8_t track_colour_supports[NUM_COLOUR_SCHEMES];
@ -340,12 +343,13 @@ struct Ride
int16_t cable_lift_y;
uint8_t cable_lift_z;
uint16_t cable_lift;
uint16_t queue_length[MAX_STATIONS];
// These fields are used to warn users about issues.
// Such issue can be hacked rides with incompatible options set.
// They don't require export/import.
uint8_t current_issues;
uint32_t last_issue_time;
RideStation stations[MAX_STATIONS];
bool CanBreakDown() const;
};

View File

@ -368,7 +368,7 @@ static void ride_ratings_begin_proximity_loop()
for (int32_t i = 0; i < MAX_STATIONS; i++)
{
if (ride->station_starts[i].xy != RCT_XY8_UNDEFINED)
if (ride->stations[i].Start.xy != RCT_XY8_UNDEFINED)
{
gRideRatingsCalcData.station_flags &= ~RIDE_RATING_STATION_FLAG_NO_ENTRANCE;
if (ride_get_entrance_location(rideIndex, i).isNull())
@ -376,9 +376,9 @@ static void ride_ratings_begin_proximity_loop()
gRideRatingsCalcData.station_flags |= RIDE_RATING_STATION_FLAG_NO_ENTRANCE;
}
int32_t x = ride->station_starts[i].x * 32;
int32_t y = ride->station_starts[i].y * 32;
int32_t z = ride->station_heights[i] * 8;
int32_t x = ride->stations[i].Start.x * 32;
int32_t y = ride->stations[i].Start.y * 32;
int32_t z = ride->stations[i].Height * 8;
gRideRatingsCalcData.proximity_x = x;
gRideRatingsCalcData.proximity_y = y;
@ -1403,7 +1403,7 @@ static int32_t ride_ratings_get_scenery_score(Ride* ride)
}
else
{
LocationXY8 location = ride->station_starts[i];
LocationXY8 location = ride->stations[i].Start;
x = location.x;
y = location.y;
}
@ -1411,7 +1411,7 @@ static int32_t ride_ratings_get_scenery_score(Ride* ride)
int32_t z = tile_element_height(x * 32, y * 32) & 0xFFFF;
// Check if station is underground, returns a fixed mediocre score since you can't have scenery underground
if (z > ride->station_heights[i] * 8)
if (z > ride->stations[i].Height * 8)
{
return 40;
}
@ -1642,7 +1642,7 @@ static void ride_ratings_apply_first_length_penalty(
rating_tuple* ratings, Ride* ride, int32_t minFirstLength, int32_t excitementPenalty, int32_t intensityPenalty,
int32_t nauseaPenalty)
{
if (ride->length[0] < minFirstLength)
if (ride->stations[0].SegmentLength < minFirstLength)
{
ratings->excitement /= excitementPenalty;
ratings->intensity /= intensityPenalty;

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)
{
if (ride->station_starts[stationIndex].xy == RCT_XY8_UNDEFINED)
if (ride->stations[stationIndex].Start.xy == RCT_XY8_UNDEFINED)
return;
switch (ride->mode)
@ -58,17 +58,17 @@ static void ride_update_station_blocksection(Ride* ride, int32_t stationIndex)
if ((ride->status == RIDE_STATUS_CLOSED && ride->num_riders == 0) || (tileElement != nullptr && tileElement->flags & 0x20))
{
ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG;
ride->stations[stationIndex].Depart &= ~STATION_DEPART_FLAG;
if ((ride->station_depart[stationIndex] & STATION_DEPART_FLAG)
if ((ride->stations[stationIndex].Depart & STATION_DEPART_FLAG)
|| (tileElement != nullptr && tileElement->AsTrack()->HasGreenLight()))
ride_invalidate_station_start(ride, stationIndex, false);
}
else
{
if (!(ride->station_depart[stationIndex] & STATION_DEPART_FLAG))
if (!(ride->stations[stationIndex].Depart & STATION_DEPART_FLAG))
{
ride->station_depart[stationIndex] |= STATION_DEPART_FLAG;
ride->stations[stationIndex].Depart |= STATION_DEPART_FLAG;
ride_invalidate_station_start(ride, stationIndex, true);
}
else if (tileElement != nullptr && tileElement->AsTrack()->HasGreenLight())
@ -88,7 +88,7 @@ static void ride_update_station_bumpercar(Ride* ride, int32_t stationIndex)
// but since dodgems do not have station lights there is no point.
if (ride->status == RIDE_STATUS_CLOSED || (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)))
{
ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG;
ride->stations[stationIndex].Depart &= ~STATION_DEPART_FLAG;
return;
}
@ -109,12 +109,12 @@ static void ride_update_station_bumpercar(Ride* ride, int32_t stationIndex)
// End match
ride->lifecycle_flags &= ~RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING;
ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG;
ride->stations[stationIndex].Depart &= ~STATION_DEPART_FLAG;
return;
}
// Continue match
ride->station_depart[stationIndex] |= STATION_DEPART_FLAG;
ride->stations[stationIndex].Depart |= STATION_DEPART_FLAG;
}
else
{
@ -128,14 +128,14 @@ static void ride_update_station_bumpercar(Ride* ride, int32_t stationIndex)
rct_vehicle* vehicle = GET_VEHICLE(vehicleSpriteIdx);
if (vehicle->status != VEHICLE_STATUS_WAITING_TO_DEPART)
{
ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG;
ride->stations[stationIndex].Depart &= ~STATION_DEPART_FLAG;
return;
}
}
// Begin the match
ride->lifecycle_flags |= RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING;
ride->station_depart[stationIndex] |= STATION_DEPART_FLAG;
ride->stations[stationIndex].Depart |= STATION_DEPART_FLAG;
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST;
}
}
@ -146,21 +146,21 @@ static void ride_update_station_bumpercar(Ride* ride, int32_t stationIndex)
*/
static void ride_update_station_normal(Ride* ride, int32_t stationIndex)
{
int32_t time = ride->station_depart[stationIndex] & STATION_DEPART_MASK;
int32_t time = ride->stations[stationIndex].Depart & STATION_DEPART_MASK;
if ((ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED))
|| (ride->status == RIDE_STATUS_CLOSED && ride->num_riders == 0))
{
if (time != 0 && time != 127 && !(gCurrentTicks & 7))
time--;
ride->station_depart[stationIndex] = time;
ride->stations[stationIndex].Depart = time;
ride_invalidate_station_start(ride, stationIndex, false);
}
else
{
if (time == 0)
{
ride->station_depart[stationIndex] |= STATION_DEPART_FLAG;
ride->stations[stationIndex].Depart |= STATION_DEPART_FLAG;
ride_invalidate_station_start(ride, stationIndex, true);
}
else
@ -168,7 +168,7 @@ static void ride_update_station_normal(Ride* ride, int32_t stationIndex)
if (time != 127 && !(gCurrentTicks & 31))
time--;
ride->station_depart[stationIndex] = time;
ride->stations[stationIndex].Depart = time;
ride_invalidate_station_start(ride, stationIndex, false);
}
}
@ -182,9 +182,9 @@ static void ride_update_station_race(Ride* ride, int32_t stationIndex)
{
if (ride->status == RIDE_STATUS_CLOSED || (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)))
{
if (ride->station_depart[stationIndex] & STATION_DEPART_FLAG)
if (ride->stations[stationIndex].Depart & STATION_DEPART_FLAG)
{
ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG;
ride->stations[stationIndex].Depart &= ~STATION_DEPART_FLAG;
ride_invalidate_station_start(ride, stationIndex, false);
}
return;
@ -213,9 +213,9 @@ static void ride_update_station_race(Ride* ride, int32_t stationIndex)
// Race is over
ride->lifecycle_flags &= ~RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING;
if (ride->station_depart[stationIndex] & STATION_DEPART_FLAG)
if (ride->stations[stationIndex].Depart & STATION_DEPART_FLAG)
{
ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG;
ride->stations[stationIndex].Depart &= ~STATION_DEPART_FLAG;
ride_invalidate_station_start(ride, stationIndex, false);
}
return;
@ -223,7 +223,7 @@ static void ride_update_station_race(Ride* ride, int32_t stationIndex)
}
// Continue racing
ride->station_depart[stationIndex] |= STATION_DEPART_FLAG;
ride->stations[stationIndex].Depart |= STATION_DEPART_FLAG;
}
else
{
@ -237,9 +237,9 @@ static void ride_update_station_race(Ride* ride, int32_t stationIndex)
rct_vehicle* vehicle = GET_VEHICLE(vehicleSpriteIdx);
if (vehicle->status != VEHICLE_STATUS_WAITING_TO_DEPART && vehicle->status != VEHICLE_STATUS_DEPARTING)
{
if (ride->station_depart[stationIndex] & STATION_DEPART_FLAG)
if (ride->stations[stationIndex].Depart & STATION_DEPART_FLAG)
{
ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG;
ride->stations[stationIndex].Depart &= ~STATION_DEPART_FLAG;
ride_invalidate_station_start(ride, stationIndex, false);
}
return;
@ -249,9 +249,9 @@ static void ride_update_station_race(Ride* ride, int32_t stationIndex)
// Begin the race
ride_race_init_vehicle_speeds(ride);
ride->lifecycle_flags |= RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING;
if (!(ride->station_depart[stationIndex] & STATION_DEPART_FLAG))
if (!(ride->stations[stationIndex].Depart & STATION_DEPART_FLAG))
{
ride->station_depart[stationIndex] |= STATION_DEPART_FLAG;
ride->stations[stationIndex].Depart |= STATION_DEPART_FLAG;
ride_invalidate_station_start(ride, stationIndex, true);
}
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST;
@ -311,8 +311,8 @@ static void ride_race_init_vehicle_speeds(Ride* ride)
*/
static void ride_invalidate_station_start(Ride* ride, int32_t stationIndex, bool greenLight)
{
int32_t x = ride->station_starts[stationIndex].x * 32;
int32_t y = ride->station_starts[stationIndex].y * 32;
int32_t x = ride->stations[stationIndex].Start.x * 32;
int32_t y = ride->stations[stationIndex].Start.y * 32;
TileElement* tileElement = ride_get_station_start_track_element(ride, stationIndex);
// If no station track found return
@ -327,9 +327,9 @@ static void ride_invalidate_station_start(Ride* ride, int32_t stationIndex, bool
TileElement* ride_get_station_start_track_element(Ride* ride, int32_t stationIndex)
{
int32_t x = ride->station_starts[stationIndex].x;
int32_t y = ride->station_starts[stationIndex].y;
int32_t z = ride->station_heights[stationIndex];
int32_t x = ride->stations[stationIndex].Start.x;
int32_t y = ride->stations[stationIndex].Start.y;
int32_t z = ride->stations[stationIndex].Height;
// Find the station track element
TileElement* tileElement = map_get_first_element_at(x, y);
@ -360,7 +360,7 @@ int8_t ride_get_first_valid_station_exit(Ride* ride)
{
for (int32_t i = 0; i < MAX_STATIONS; i++)
{
if (ride->exits[i].x != COORDS_NULL)
if (ride->stations[i].Exit.x != COORDS_NULL)
{
return i;
}
@ -372,7 +372,7 @@ int8_t ride_get_first_valid_station_start(const Ride* ride)
{
for (int8_t i = 0; i < MAX_STATIONS; i++)
{
if (ride->station_starts[i].xy != RCT_XY8_UNDEFINED)
if (ride->stations[i].Start.xy != RCT_XY8_UNDEFINED)
{
return i;
}
@ -384,7 +384,7 @@ int8_t ride_get_first_empty_station_start(const Ride* ride)
{
for (int8_t i = 0; i < MAX_STATIONS; i++)
{
if (ride->station_starts[i].xy == RCT_XY8_UNDEFINED)
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED)
{
return i;
}
@ -395,41 +395,41 @@ int8_t ride_get_first_empty_station_start(const Ride* ride)
TileCoordsXYZD ride_get_entrance_location(const int32_t rideIndex, const int32_t stationIndex)
{
const Ride* ride = get_ride(rideIndex);
return ride->entrances[stationIndex];
return ride->stations[stationIndex].Entrance;
}
TileCoordsXYZD ride_get_exit_location(const int32_t rideIndex, const int32_t stationIndex)
{
const Ride* ride = get_ride(rideIndex);
return ride->exits[stationIndex];
return ride->stations[stationIndex].Exit;
}
TileCoordsXYZD ride_get_entrance_location(const Ride* ride, const int32_t stationIndex)
{
return ride->entrances[stationIndex];
return ride->stations[stationIndex].Entrance;
}
TileCoordsXYZD ride_get_exit_location(const Ride* ride, const int32_t stationIndex)
{
return ride->exits[stationIndex];
return ride->stations[stationIndex].Exit;
}
void ride_clear_entrance_location(Ride* ride, const int32_t stationIndex)
{
ride->entrances[stationIndex].x = COORDS_NULL;
ride->stations[stationIndex].Entrance.x = COORDS_NULL;
}
void ride_clear_exit_location(Ride* ride, const int32_t stationIndex)
{
ride->exits[stationIndex].x = COORDS_NULL;
ride->stations[stationIndex].Exit.x = COORDS_NULL;
}
void ride_set_entrance_location(Ride* ride, const int32_t stationIndex, const TileCoordsXYZD location)
{
ride->entrances[stationIndex] = location;
ride->stations[stationIndex].Entrance = location;
}
void ride_set_exit_location(Ride* ride, const int32_t stationIndex, const TileCoordsXYZD location)
{
ride->exits[stationIndex] = location;
ride->stations[stationIndex].Exit = location;
}

View File

@ -623,9 +623,9 @@ static void ride_remove_station(Ride* ride, int32_t x, int32_t y, int32_t z)
{
for (int32_t i = 0; i < MAX_STATIONS; i++)
{
if (ride->station_starts[i].x == (x >> 5) && ride->station_starts[i].y == (y >> 5) && ride->station_heights[i] == z)
if (ride->stations[i].Start.x == (x >> 5) && ride->stations[i].Start.y == (y >> 5) && ride->stations[i].Height == z)
{
ride->station_starts[i].xy = RCT_XY8_UNDEFINED;
ride->stations[i].Start.xy = RCT_XY8_UNDEFINED;
ride->num_stations--;
break;
}
@ -657,11 +657,11 @@ static bool track_add_station_element(int32_t x, int32_t y, int32_t z, int32_t d
int8_t stationIndex = ride_get_first_empty_station_start(ride);
assert(stationIndex != -1);
ride->station_starts[stationIndex].x = (x >> 5);
ride->station_starts[stationIndex].y = (y >> 5);
ride->station_heights[stationIndex] = z;
ride->station_depart[stationIndex] = 1;
ride->station_length[stationIndex] = 0;
ride->stations[stationIndex].Start.x = (x >> 5);
ride->stations[stationIndex].Start.y = (y >> 5);
ride->stations[stationIndex].Height = z;
ride->stations[stationIndex].Depart = 1;
ride->stations[stationIndex].Length = 0;
ride->num_stations++;
}
return true;
@ -750,11 +750,11 @@ static bool track_add_station_element(int32_t x, int32_t y, int32_t z, int32_t d
int8_t stationIndex = ride_get_first_empty_station_start(ride);
assert(stationIndex != -1);
ride->station_starts[stationIndex].x = (x >> 5);
ride->station_starts[stationIndex].y = (y >> 5);
ride->station_heights[stationIndex] = z;
ride->station_depart[stationIndex] = 1;
ride->station_length[stationIndex] = stationLength;
ride->stations[stationIndex].Start.x = (x >> 5);
ride->stations[stationIndex].Start.y = (y >> 5);
ride->stations[stationIndex].Height = z;
ride->stations[stationIndex].Depart = 1;
ride->stations[stationIndex].Length = stationLength;
ride->num_stations++;
targetTrackType = TRACK_ELEM_END_STATION;
@ -893,11 +893,11 @@ static bool track_remove_station_element(int32_t x, int32_t y, int32_t z, int32_
int8_t stationIndex = ride_get_first_empty_station_start(ride);
assert(stationIndex != -1);
ride->station_starts[stationIndex].x = (x >> 5);
ride->station_starts[stationIndex].y = (y >> 5);
ride->station_heights[stationIndex] = z;
ride->station_depart[stationIndex] = 1;
ride->station_length[stationIndex] = stationLength != 0 ? stationLength : byte_F441D1;
ride->stations[stationIndex].Start.x = (x >> 5);
ride->stations[stationIndex].Start.y = (y >> 5);
ride->stations[stationIndex].Height = z;
ride->stations[stationIndex].Depart = 1;
ride->stations[stationIndex].Length = stationLength != 0 ? stationLength : byte_F441D1;
ride->num_stations++;
stationLength = 0;
@ -2372,4 +2372,4 @@ void TrackElement::SetHighlight(bool on)
type &= ~TILE_ELEMENT_TYPE_FLAG_HIGHLIGHT;
if (on)
type |= TILE_ELEMENT_TYPE_FLAG_HIGHLIGHT;
}
}

View File

@ -2125,8 +2125,8 @@ static money32 place_maze_design(uint8_t flags, uint8_t rideIndex, uint16_t maze
map_invalidate_element(fx, fy, tileElement);
ride->maze_tiles++;
ride->station_heights[0] = tileElement->base_height;
ride->station_starts[0].xy = 0;
ride->stations[0].Height = tileElement->base_height;
ride->stations[0].Start.xy = 0;
if (ride->maze_tiles == 1)
{
ride->overall_view.x = fx / 32;

View File

@ -1108,7 +1108,7 @@ static bool track_design_save_to_td6_for_tracked_ride(uint8_t rideIndex, rct_tra
{
for (int32_t station_index = 0; station_index < RCT12_MAX_STATIONS_PER_RIDE; station_index++)
{
z = ride->station_heights[station_index];
z = ride->stations[station_index].Height;
TileCoordsXYZD location;
if (i == 0)

View File

@ -1542,13 +1542,14 @@ static void vehicle_update_measurements(rct_vehicle* vehicle)
if (ride->average_speed_test_timeout == 0 && velocity > 0x8000)
{
ride->average_speed = add_clamp_int32_t(ride->average_speed, velocity);
ride->time[test_segment]++;
ride->stations[test_segment].SegmentTime++;
}
int32_t distance = abs(((vehicle->velocity + vehicle->acceleration) >> 10) * 42);
if (vehicle->var_CE == 0)
{
ride->length[test_segment] = add_clamp_int32_t(ride->length[test_segment], distance);
ride->stations[test_segment].SegmentLength = add_clamp_int32_t(
ride->stations[test_segment].SegmentLength, distance);
}
if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_G_FORCES))
@ -2157,7 +2158,7 @@ static void train_ready_to_depart(rct_vehicle* vehicle, uint8_t num_peeps_on_tra
// Boat Hire with passengers on it.
if (ride->status != RIDE_STATUS_CLOSED || (ride->num_riders != 0 && ride->type != RIDE_TYPE_BOAT_HIRE))
{
ride->train_at_station[vehicle->current_station] = 0xFF;
ride->stations[vehicle->current_station].TrainAtStation = 0xFF;
vehicle->sub_state = 2;
return;
}
@ -2168,7 +2169,7 @@ static void train_ready_to_depart(rct_vehicle* vehicle, uint8_t num_peeps_on_tra
uint8_t peep = ((-vehicle->vehicle_sprite_type) / 8) & 0xF;
if (vehicle->peep[peep] != SPRITE_INDEX_NULL)
{
ride->train_at_station[vehicle->current_station] = 0xFF;
ride->stations[vehicle->current_station].TrainAtStation = 0xFF;
vehicle->status = VEHICLE_STATUS_UNLOADING_PASSENGERS;
vehicle->sub_state = 0;
vehicle_invalidate_window(vehicle);
@ -2178,7 +2179,7 @@ static void train_ready_to_depart(rct_vehicle* vehicle, uint8_t num_peeps_on_tra
if (vehicle->num_peeps == 0)
return;
ride->train_at_station[vehicle->current_station] = 0xFF;
ride->stations[vehicle->current_station].TrainAtStation = 0xFF;
vehicle->sub_state = 2;
return;
}
@ -2186,7 +2187,7 @@ static void train_ready_to_depart(rct_vehicle* vehicle, uint8_t num_peeps_on_tra
if (num_peeps_on_train == 0)
return;
ride->train_at_station[vehicle->current_station] = 0xFF;
ride->stations[vehicle->current_station].TrainAtStation = 0xFF;
vehicle->status = VEHICLE_STATUS_WAITING_FOR_PASSENGERS;
vehicle->sub_state = 0;
vehicle_invalidate_window(vehicle);
@ -2230,7 +2231,7 @@ static void vehicle_update_waiting_for_passengers(rct_vehicle* vehicle)
if (ride_get_entrance_location(ride, vehicle->current_station).isNull())
{
ride->train_at_station[vehicle->current_station] = 0xFF;
ride->stations[vehicle->current_station].TrainAtStation = 0xFF;
vehicle->sub_state = 2;
return;
}
@ -2241,10 +2242,10 @@ static void vehicle_update_waiting_for_passengers(rct_vehicle* vehicle)
return;
}
if (ride->train_at_station[vehicle->current_station] != 0xFF)
if (ride->stations[vehicle->current_station].TrainAtStation != 0xFF)
return;
ride->train_at_station[vehicle->current_station] = trainIndex;
ride->stations[vehicle->current_station].TrainAtStation = trainIndex;
vehicle->sub_state = 1;
vehicle->time_waiting = 0;
@ -2535,7 +2536,7 @@ static void vehicle_update_waiting_to_depart(rct_vehicle* vehicle)
if (skipCheck == false)
{
if (!(ride->station_depart[vehicle->current_station] & STATION_DEPART_FLAG))
if (!(ride->stations[vehicle->current_station].Depart & STATION_DEPART_FLAG))
return;
}
@ -2770,7 +2771,7 @@ static bool try_add_synchronised_station(int32_t x, int32_t y, int32_t z)
/* Station is not ready to depart, so just return;
* vehicle_id for this station is SPRITE_INDEX_NULL. */
if (!(ride->station_depart[stationIndex] & STATION_DEPART_FLAG))
if (!(ride->stations[stationIndex].Depart & STATION_DEPART_FLAG))
{
return true;
}
@ -2827,10 +2828,10 @@ static bool vehicle_can_depart_synchronised(rct_vehicle* vehicle)
{
Ride* ride = get_ride(vehicle->ride);
int32_t station = vehicle->current_station;
LocationXY8 location = ride->station_starts[station];
LocationXY8 location = ride->stations[station].Start;
int32_t x = location.x * 32;
int32_t y = location.y * 32;
int32_t z = ride->station_heights[station];
int32_t z = ride->stations[station].Height;
TileElement* tileElement = map_get_track_element_at(x, y, z);
if (tileElement == nullptr)
@ -2904,7 +2905,7 @@ static bool vehicle_can_depart_synchronised(rct_vehicle* vehicle)
{
if (ride_is_block_sectioned(sv_ride))
{
if (!(sv_ride->station_depart[sv->station_id] & STATION_DEPART_FLAG))
if (!(sv_ride->stations[sv->station_id].Depart & STATION_DEPART_FLAG))
{
sv = _synchronisedVehicles;
uint8_t rideId = 0xFF;
@ -3050,22 +3051,22 @@ void vehicle_update_test_finish(rct_vehicle* vehicle)
for (int32_t i = ride->num_stations - 1; i >= 1; i--)
{
if (ride->time[i - 1] != 0)
if (ride->stations[i - 1].SegmentTime != 0)
continue;
uint16_t oldTime = ride->time[i - 1];
ride->time[i - 1] = ride->time[i];
ride->time[i] = oldTime;
uint16_t oldTime = ride->stations[i - 1].SegmentTime;
ride->stations[i - 1].SegmentTime = ride->stations[i].SegmentTime;
ride->stations[i].SegmentTime = oldTime;
int32_t oldLength = ride->length[i - 1];
ride->length[i - 1] = ride->length[i];
ride->length[i] = oldLength;
int32_t oldLength = ride->stations[i - 1].SegmentLength;
ride->stations[i - 1].SegmentLength = ride->stations[i].SegmentLength;
ride->stations[i].SegmentLength = oldLength;
}
uint32_t totalTime = 0;
for (uint8_t i = 0; i < ride->num_stations; ++i)
{
totalTime += ride->time[i];
totalTime += ride->stations[i].SegmentTime;
}
totalTime = std::max(totalTime, 1u);
@ -3107,8 +3108,11 @@ void vehicle_test_reset(rct_vehicle* vehicle)
ride->num_sheltered_sections = 0;
ride->highest_drop_height = 0;
ride->special_track_elements = 0;
std::fill_n(ride->length, MAX_STATIONS, 0);
std::fill_n(ride->time, MAX_STATIONS, 0);
for (auto& station : ride->stations)
{
station.SegmentLength = 0;
station.SegmentTime = 0;
}
ride->total_air_time = 0;
ride->current_test_station = vehicle->current_station;
window_invalidate_by_number(WC_RIDE, vehicle->ride);
@ -3170,10 +3174,10 @@ static void vehicle_update_departing_boat_hire(rct_vehicle* vehicle)
vehicle->lost_time_out = 0;
Ride* ride = get_ride(vehicle->ride);
ride->station_depart[vehicle->current_station] &= STATION_DEPART_FLAG;
ride->stations[vehicle->current_station].Depart &= STATION_DEPART_FLAG;
uint8_t waitingTime = std::max(ride->min_waiting_time, static_cast<uint8_t>(3));
waitingTime = std::min(waitingTime, static_cast<uint8_t>(127));
ride->station_depart[vehicle->current_station] |= waitingTime;
ride->stations[vehicle->current_station].Depart |= waitingTime;
vehicle_update_travelling_boat_hire_setup(vehicle);
}
@ -3440,7 +3444,7 @@ static void vehicle_finish_departing(rct_vehicle* vehicle)
if (ride->mode != RIDE_MODE_RACE && ride->mode != RIDE_MODE_CONTINUOUS_CIRCUIT_BLOCK_SECTIONED
&& ride->mode != RIDE_MODE_POWERED_LAUNCH_BLOCK_SECTIONED)
{
ride->station_depart[vehicle->current_station] &= STATION_DEPART_FLAG;
ride->stations[vehicle->current_station].Depart &= STATION_DEPART_FLAG;
uint8_t waitingTime = 3;
if (ride->depart_flags & RIDE_DEPART_WAIT_FOR_MINIMUM_LENGTH)
{
@ -3448,7 +3452,7 @@ static void vehicle_finish_departing(rct_vehicle* vehicle)
waitingTime = std::min(waitingTime, static_cast<uint8_t>(127));
}
ride->station_depart[vehicle->current_station] |= waitingTime;
ride->stations[vehicle->current_station].Depart |= waitingTime;
}
vehicle->status = VEHICLE_STATUS_TRAVELLING;
@ -4237,7 +4241,7 @@ static void vehicle_update_travelling_cable_lift(rct_vehicle* vehicle)
return;
// This is slightly different to the vanilla function
ride->station_depart[vehicle->current_station] &= STATION_DEPART_FLAG;
ride->stations[vehicle->current_station].Depart &= STATION_DEPART_FLAG;
uint8_t waitingTime = 3;
if (ride->depart_flags & RIDE_DEPART_WAIT_FOR_MINIMUM_LENGTH)
{
@ -4245,7 +4249,7 @@ static void vehicle_update_travelling_cable_lift(rct_vehicle* vehicle)
waitingTime = std::min(waitingTime, static_cast<uint8_t>(127));
}
ride->station_depart[vehicle->current_station] |= waitingTime;
ride->stations[vehicle->current_station].Depart |= waitingTime;
}
/**
@ -9298,11 +9302,11 @@ loc_6DCE68:
regs.dl = vehicle->track_z >> 3;
for (int32_t i = 0; i < MAX_STATIONS; i++)
{
if ((uint16_t)regs.ax != ride->station_starts[i].xy)
if ((uint16_t)regs.ax != ride->stations[i].Start.xy)
{
continue;
}
if ((uint16_t)regs.dl != ride->station_heights[i])
if ((uint16_t)regs.dl != ride->stations[i].Height)
{
continue;
}

View File

@ -218,7 +218,7 @@ static money32 RideEntranceExitPlace(
}
}
z = ride->station_heights[stationNum] * 8;
z = ride->stations[stationNum].Height * 8;
gCommandPosition.z = z;
if ((flags & GAME_COMMAND_FLAG_APPLY) && !(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED)
@ -283,8 +283,8 @@ static money32 RideEntranceExitPlace(
else
{
ride_set_entrance_location(ride, stationNum, { x / 32, y / 32, z / 8, (uint8_t)tileElement->GetDirection() });
ride->last_peep_in_queue[stationNum] = SPRITE_INDEX_NULL;
ride->queue_length[stationNum] = 0;
ride->stations[stationNum].LastPeepInQueue = SPRITE_INDEX_NULL;
ride->stations[stationNum].QueueLength = 0;
map_animation_create(MAP_ANIMATION_TYPE_RIDE_ENTRANCE, x, y, z / 8);
}

View File

@ -865,7 +865,7 @@ uint32_t Park::CalculateSuggestedMaxGuests() const
continue;
if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_DATA_LOGGING))
continue;
if (ride->length[0] < (600 << 16))
if (ride->stations[0].SegmentLength < (600 << 16))
continue;
if (ride->excitement < RIDE_RATING(6, 00))
continue;

View File

@ -377,12 +377,12 @@ void TrackElement::SetHasChain(bool on)
TileCoordsXYZD ride_get_entrance_location(const Ride* ride, const int32_t stationIndex)
{
return ride->entrances[stationIndex];
return ride->stations[stationIndex].Entrance;
}
TileCoordsXYZD ride_get_exit_location(const Ride* ride, const int32_t stationIndex)
{
return ride->exits[stationIndex];
return ride->stations[stationIndex].Exit;
}
void TileElementBase::SetType(uint8_t newType)