Pass only TrackLocation instead of whole vehicle (#11954)

This commit is contained in:
Hudson Oliveira 2020-06-16 08:01:25 -03:00 committed by GitHub
parent 1336e8ad86
commit 994dea2722
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 17 deletions

View File

@ -6756,9 +6756,9 @@ void Vehicle::UpdateVelocity()
_vehicleVelocityF64E0C = (nextVelocity >> 10) * 42; _vehicleVelocityF64E0C = (nextVelocity >> 10) * 42;
} }
static void vehicle_update_block_brakes_open_previous_section(Vehicle* vehicle, TileElement* tileElement) static void block_brakes_open_previous_section(Ride& ride, const CoordsXYZ& vehicleTrackLocation, TileElement* tileElement)
{ {
auto location = vehicle->TrackLocation; auto location = vehicleTrackLocation;
track_begin_end trackBeginEnd, slowTrackBeginEnd; track_begin_end trackBeginEnd, slowTrackBeginEnd;
TileElement slowTileElement = *tileElement; TileElement slowTileElement = *tileElement;
bool counter = true; bool counter = true;
@ -6769,7 +6769,7 @@ static void vehicle_update_block_brakes_open_previous_section(Vehicle* vehicle,
{ {
return; return;
} }
if (trackBeginEnd.begin_x == vehicle->TrackLocation.x && trackBeginEnd.begin_y == vehicle->TrackLocation.y if (trackBeginEnd.begin_x == vehicleTrackLocation.x && trackBeginEnd.begin_y == vehicleTrackLocation.y
&& tileElement == trackBeginEnd.begin_element) && tileElement == trackBeginEnd.begin_element)
{ {
return; return;
@ -6810,8 +6810,7 @@ static void vehicle_update_block_brakes_open_previous_section(Vehicle* vehicle,
int32_t trackType = trackElement->GetTrackType(); int32_t trackType = trackElement->GetTrackType();
if (trackType == TRACK_ELEM_BLOCK_BRAKES || trackType == TRACK_ELEM_END_STATION) if (trackType == TRACK_ELEM_BLOCK_BRAKES || trackType == TRACK_ELEM_END_STATION)
{ {
auto ride = get_ride(vehicle->ride); if (ride.IsBlockSectioned())
if (ride != nullptr && ride->IsBlockSectioned())
{ {
audio_play_sound_at_location(SoundId::BlockBrakeClose, location); audio_play_sound_at_location(SoundId::BlockBrakeClose, location);
} }
@ -7418,7 +7417,7 @@ void Vehicle::UpdateAdditionalAnimation()
* *
* rct2: 0x006DEDB1 * rct2: 0x006DEDB1
*/ */
static void vehicle_play_scenery_door_open_sound(Vehicle* vehicle, WallElement* tileElement) static void play_scenery_door_open_sound(const CoordsXYZ& loc, WallElement* tileElement)
{ {
rct_scenery_entry* wallEntry = tileElement->GetEntry(); rct_scenery_entry* wallEntry = tileElement->GetEntry();
int32_t doorSoundType = wall_entry_get_door_sound(wallEntry); int32_t doorSoundType = wall_entry_get_door_sound(wallEntry);
@ -7427,7 +7426,7 @@ static void vehicle_play_scenery_door_open_sound(Vehicle* vehicle, WallElement*
auto soundId = DoorOpenSoundIds[doorSoundType - 1]; auto soundId = DoorOpenSoundIds[doorSoundType - 1];
if (soundId != SoundId::Null) if (soundId != SoundId::Null)
{ {
audio_play_sound_at_location(soundId, vehicle->TrackLocation); audio_play_sound_at_location(soundId, loc);
} }
} }
} }
@ -7436,7 +7435,7 @@ static void vehicle_play_scenery_door_open_sound(Vehicle* vehicle, WallElement*
* *
* rct2: 0x006DED7A * rct2: 0x006DED7A
*/ */
static void vehicle_play_scenery_door_close_sound(Vehicle* vehicle, WallElement* tileElement) static void play_scenery_door_close_sound(const CoordsXYZ& loc, WallElement* tileElement)
{ {
rct_scenery_entry* wallEntry = tileElement->GetEntry(); rct_scenery_entry* wallEntry = tileElement->GetEntry();
int32_t doorSoundType = wall_entry_get_door_sound(wallEntry); int32_t doorSoundType = wall_entry_get_door_sound(wallEntry);
@ -7445,7 +7444,7 @@ static void vehicle_play_scenery_door_close_sound(Vehicle* vehicle, WallElement*
auto soundId = DoorCloseSoundIds[doorSoundType - 1]; auto soundId = DoorCloseSoundIds[doorSoundType - 1];
if (soundId != SoundId::Null) if (soundId != SoundId::Null)
{ {
audio_play_sound_at_location(soundId, vehicle->TrackLocation); audio_play_sound_at_location(soundId, loc);
} }
} }
} }
@ -7478,14 +7477,14 @@ static void vehicle_update_scenery_door(Vehicle* vehicle)
tileElement->SetAnimationIsBackwards(false); tileElement->SetAnimationIsBackwards(false);
tileElement->SetAnimationFrame(1); tileElement->SetAnimationFrame(1);
map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, wallCoords); map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, wallCoords);
vehicle_play_scenery_door_open_sound(vehicle, tileElement); play_scenery_door_open_sound(vehicle->TrackLocation, tileElement);
} }
if (vehicle->next_vehicle_on_train == SPRITE_INDEX_NULL) if (vehicle->next_vehicle_on_train == SPRITE_INDEX_NULL)
{ {
tileElement->SetAnimationIsBackwards(false); tileElement->SetAnimationIsBackwards(false);
tileElement->SetAnimationFrame(6); tileElement->SetAnimationFrame(6);
vehicle_play_scenery_door_close_sound(vehicle, tileElement); play_scenery_door_close_sound(vehicle->TrackLocation, tileElement);
} }
} }
@ -7527,11 +7526,11 @@ static void VehicleUpdateGoKartAttemptSwitchLanes(Vehicle* vehicle)
* *
* rct2: 0x006DB545 * rct2: 0x006DB545
*/ */
static void vehicle_trigger_on_ride_photo(Vehicle* vehicle, TileElement* tileElement) static void trigger_on_ride_photo(const CoordsXYZ& loc, TileElement* tileElement)
{ {
tileElement->AsTrack()->SetPhotoTimeout(); tileElement->AsTrack()->SetPhotoTimeout();
map_animation_create(MAP_ANIMATION_TYPE_TRACK_ONRIDEPHOTO, { vehicle->TrackLocation, tileElement->GetBaseZ() }); map_animation_create(MAP_ANIMATION_TYPE_TRACK_ONRIDEPHOTO, { loc, tileElement->GetBaseZ() });
} }
/** /**
@ -7558,14 +7557,14 @@ static void vehicle_update_handle_scenery_door(Vehicle* vehicle)
tileElement->SetAnimationIsBackwards(true); tileElement->SetAnimationIsBackwards(true);
tileElement->SetAnimationFrame(1); tileElement->SetAnimationFrame(1);
map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, wallCoords); map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, wallCoords);
vehicle_play_scenery_door_open_sound(vehicle, tileElement); play_scenery_door_open_sound(vehicle->TrackLocation, tileElement);
} }
if (vehicle->next_vehicle_on_train == SPRITE_INDEX_NULL) if (vehicle->next_vehicle_on_train == SPRITE_INDEX_NULL)
{ {
tileElement->SetAnimationIsBackwards(true); tileElement->SetAnimationIsBackwards(true);
tileElement->SetAnimationFrame(6); tileElement->SetAnimationFrame(6);
vehicle_play_scenery_door_close_sound(vehicle, tileElement); play_scenery_door_close_sound(vehicle->TrackLocation, tileElement);
} }
} }
@ -7989,7 +7988,7 @@ bool Vehicle::UpdateTrackMotionForwardsGetNewTrack(uint16_t trackType, Ride* cur
} }
} }
map_invalidate_element(TrackLocation, tileElement); map_invalidate_element(TrackLocation, tileElement);
vehicle_update_block_brakes_open_previous_section(this, tileElement); block_brakes_open_previous_section(*curRide, TrackLocation, tileElement);
} }
} }
@ -8128,7 +8127,7 @@ bool Vehicle::UpdateTrackMotionForwardsGetNewTrack(uint16_t trackType, Ride* cur
brake_speed = tileElement->AsTrack()->GetBrakeBoosterSpeed(); brake_speed = tileElement->AsTrack()->GetBrakeBoosterSpeed();
if (trackType == TRACK_ELEM_ON_RIDE_PHOTO) if (trackType == TRACK_ELEM_ON_RIDE_PHOTO)
{ {
vehicle_trigger_on_ride_photo(this, tileElement); trigger_on_ride_photo(TrackLocation, tileElement);
} }
{ {
curRide = get_ride(tileElement->AsTrack()->GetRideIndex()); curRide = get_ride(tileElement->AsTrack()->GetRideIndex());