forked from rosebudai/OpenRCT2-Web
Part of #9473: Create Vehicle::TrainHead and Vehicle::TrainTail
Converted from vehicle_get_head and vehicle_get_tail
This commit is contained in:
1 parent
90cd90e738
commit
d69cc1c877
6 files changed
+20
-18
No files matched your search
@@ -1696,7 +1696,7 @@ rct_window* window_ride_open_track(TileElement* tileElement)
|
||||
*/
|
||||
rct_window* window_ride_open_vehicle(Vehicle* vehicle)
|
||||
{
|
||||
Vehicle* headVehicle = vehicle_get_head(vehicle);
|
||||
Vehicle* headVehicle = vehicle->TrainHead();
|
||||
uint16_t headVehicleSpriteIndex = headVehicle->sprite_index;
|
||||
auto ride = get_ride(headVehicle->ride);
|
||||
if (ride == nullptr)
|
||||
|
||||
@@ -725,7 +725,7 @@ void lightfx_add_lights_magic_vehicle(const Vehicle* vehicle)
|
||||
break;
|
||||
case RIDE_TYPE_MINE_TRAIN_COASTER:
|
||||
case RIDE_TYPE_GHOST_TRAIN:
|
||||
if (vehicle == vehicle_get_head(vehicle))
|
||||
if (vehicle == vehicle->TrainHead())
|
||||
{
|
||||
place_x -= offsetLookup[(vehicle->sprite_direction + 0) % 32] * 2;
|
||||
place_y -= offsetLookup[(vehicle->sprite_direction + 8) % 32] * 2;
|
||||
@@ -748,7 +748,7 @@ void lightfx_add_lights_magic_vehicle(const Vehicle* vehicle)
|
||||
case RIDE_TYPE_SPLASH_BOATS:
|
||||
case RIDE_TYPE_WATER_COASTER:
|
||||
{
|
||||
Vehicle* vehicle_draw = vehicle_get_head(vehicle);
|
||||
Vehicle* vehicle_draw = vehicle->TrainHead();
|
||||
if (vehicle_draw->next_vehicle_on_train != SPRITE_INDEX_NULL)
|
||||
{
|
||||
vehicle_draw = GET_VEHICLE(vehicle_draw->next_vehicle_on_train);
|
||||
@@ -770,7 +770,7 @@ void lightfx_add_lights_magic_vehicle(const Vehicle* vehicle)
|
||||
lightfx_add_3d_light(
|
||||
vehicleID, 0x0000 | LIGHTFX_LIGHT_QUALIFIER_SPRITE, vehicle->x, vehicle->y, vehicle->z + 12,
|
||||
LIGHTFX_LIGHT_TYPE_SPOT_2);
|
||||
if (vehicle == vehicle_get_head(vehicle))
|
||||
if (vehicle == vehicle->TrainHead())
|
||||
{
|
||||
place_x -= offsetLookup[(vehicle->sprite_direction + 0) % 32] * 2;
|
||||
place_y -= offsetLookup[(vehicle->sprite_direction + 8) % 32] * 2;
|
||||
@@ -783,7 +783,7 @@ void lightfx_add_lights_magic_vehicle(const Vehicle* vehicle)
|
||||
vehicleID, 0x0200 | LIGHTFX_LIGHT_QUALIFIER_SPRITE, place_x, place_y, place_z + 2,
|
||||
LIGHTFX_LIGHT_TYPE_LANTERN_3);
|
||||
}
|
||||
if (vehicle == vehicle_get_tail(vehicle))
|
||||
if (vehicle == vehicle->TrainTail())
|
||||
{
|
||||
place_x += offsetLookup[(vehicle->sprite_direction + 0) % 32] * 2;
|
||||
place_y += offsetLookup[(vehicle->sprite_direction + 8) % 32] * 2;
|
||||
@@ -798,7 +798,7 @@ void lightfx_add_lights_magic_vehicle(const Vehicle* vehicle)
|
||||
}
|
||||
break;
|
||||
case RIDE_TYPE_MINIATURE_RAILWAY:
|
||||
if (vehicle == vehicle_get_head(vehicle))
|
||||
if (vehicle == vehicle->TrainHead())
|
||||
{
|
||||
place_x -= offsetLookup[(vehicle->sprite_direction + 0) % 32] * 2;
|
||||
place_y -= offsetLookup[(vehicle->sprite_direction + 8) % 32] * 2;
|
||||
|
||||
@@ -377,7 +377,7 @@ int32_t cable_lift_update_track_motion(Vehicle* cableLift)
|
||||
Vehicle* frontVehicle = cableLift;
|
||||
if (cableLift->velocity < 0)
|
||||
{
|
||||
frontVehicle = vehicle_get_tail(cableLift);
|
||||
frontVehicle = cableLift->TrainTail();
|
||||
}
|
||||
|
||||
_vehicleFrontVehicle = frontVehicle;
|
||||
|
||||
@@ -6180,8 +6180,9 @@ void vehicle_set_map_toolbar(const Vehicle* vehicle)
|
||||
}
|
||||
}
|
||||
|
||||
Vehicle* vehicle_get_head(const Vehicle* vehicle)
|
||||
Vehicle* Vehicle::TrainHead() const
|
||||
{
|
||||
const Vehicle* vehicle = this;
|
||||
Vehicle* prevVehicle;
|
||||
|
||||
for (;;)
|
||||
@@ -6198,8 +6199,9 @@ Vehicle* vehicle_get_head(const Vehicle* vehicle)
|
||||
return const_cast<Vehicle*>(vehicle);
|
||||
}
|
||||
|
||||
Vehicle* vehicle_get_tail(const Vehicle* vehicle)
|
||||
Vehicle* Vehicle::TrainTail() const
|
||||
{
|
||||
const Vehicle* vehicle = this;
|
||||
uint16_t spriteIndex;
|
||||
|
||||
while ((spriteIndex = vehicle->next_vehicle_on_train) != SPRITE_INDEX_NULL)
|
||||
@@ -8293,7 +8295,7 @@ loc_6DB967:
|
||||
remaining_distance = -1;
|
||||
|
||||
// Might need to be bp rather than this, but hopefully not
|
||||
Vehicle* head = vehicle_get_head(GET_VEHICLE(regs.bp));
|
||||
auto head = (GET_VEHICLE(regs.bp))->TrainHead();
|
||||
|
||||
regs.eax = abs(velocity - head->velocity);
|
||||
if (!(rideEntry->flags & RIDE_ENTRY_FLAG_DISABLE_COLLISION_CRASHES))
|
||||
@@ -8664,7 +8666,7 @@ static int32_t vehicle_update_track_motion_mini_golf(Vehicle* vehicle, int32_t*
|
||||
_vehicleVelocityF64E0C = (vehicle->velocity >> 10) * 42;
|
||||
if (_vehicleVelocityF64E08 < 0)
|
||||
{
|
||||
vehicle = vehicle_get_tail(vehicle);
|
||||
vehicle = vehicle->TrainTail();
|
||||
}
|
||||
_vehicleFrontVehicle = vehicle;
|
||||
|
||||
@@ -9530,7 +9532,7 @@ int32_t Vehicle::UpdateTrackMotion(int32_t* outStation)
|
||||
Vehicle* vehicle = this;
|
||||
if (_vehicleVelocityF64E08 < 0)
|
||||
{
|
||||
vehicle = vehicle_get_tail(vehicle);
|
||||
vehicle = vehicle->TrainTail();
|
||||
}
|
||||
// This will be the front vehicle even when traveling
|
||||
// backwards.
|
||||
@@ -9795,7 +9797,7 @@ void vehicle_invalidate_window(Vehicle* vehicle)
|
||||
|
||||
void Vehicle::UpdateCrossings() const
|
||||
{
|
||||
if (vehicle_get_head(this) != this)
|
||||
if (TrainHead() != this)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -9808,11 +9810,11 @@ void Vehicle::UpdateCrossings() const
|
||||
if (travellingForwards)
|
||||
{
|
||||
frontVehicle = this;
|
||||
backVehicle = vehicle_get_tail(this);
|
||||
backVehicle = TrainTail();
|
||||
}
|
||||
else
|
||||
{
|
||||
frontVehicle = vehicle_get_tail(this);
|
||||
frontVehicle = TrainTail();
|
||||
backVehicle = this;
|
||||
}
|
||||
|
||||
|
||||
@@ -308,6 +308,8 @@ struct Vehicle : SpriteBase
|
||||
bool UpdateDodgemsCollision(int16_t x, int16_t y, uint16_t* spriteId);
|
||||
int32_t UpdateTrackMotion(int32_t* outStation);
|
||||
rct_ride_entry_vehicle* Entry() const;
|
||||
Vehicle* TrainHead() const;
|
||||
Vehicle* TrainTail() const;
|
||||
|
||||
private:
|
||||
bool SoundCanPlay() const;
|
||||
@@ -561,8 +563,6 @@ void vehicle_invalidate_window(Vehicle* vehicle);
|
||||
void vehicle_update_test_finish(Vehicle* vehicle);
|
||||
void vehicle_test_reset(Vehicle* vehicle);
|
||||
void vehicle_peep_easteregg_here_we_are(const Vehicle* vehicle);
|
||||
Vehicle* vehicle_get_head(const Vehicle* vehicle);
|
||||
Vehicle* vehicle_get_tail(const Vehicle* vehicle);
|
||||
const rct_vehicle_info* vehicle_get_move_info(int32_t trackSubposition, int32_t typeAndDirection, int32_t offset);
|
||||
uint16_t vehicle_get_move_info_size(int32_t trackSubposition, int32_t typeAndDirection);
|
||||
|
||||
|
||||
@@ -2976,7 +2976,7 @@ static void vehicle_visual_splash1_effect(paint_session* session, int32_t z, con
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (vehicle_get_head(vehicle)->velocity <= 0x50000)
|
||||
if (vehicle->TrainHead()->velocity <= 0x50000)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user