Simplify some code in Vehicle.cpp (#8595)

* Simplify some code in Vehicle.cpp

This reduces amount of code that depends on registers struct

* Simplify code in Vehicle.cpp

This removes one goto.
This commit is contained in:
Michał Janiszewski 2019-03-03 15:25:47 +01:00 committed by GitHub
parent a2e45b56c0
commit 1fa5606509
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 33 deletions

View File

@ -8231,7 +8231,10 @@ loc_6DAEB9:
if (!vehicle_update_track_motion_forwards_get_new_track(vehicle, trackType, ride, rideEntry))
{
goto loc_6DB94A;
_vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5;
_vehicleVelocityF64E0C -= vehicle->remaining_distance + 1;
vehicle->remaining_distance = -1;
return false;
}
regs.ax = 0;
}
@ -8322,18 +8325,9 @@ loc_6DAEB9:
_vehicleUnkF64E10++;
goto loc_6DAEB9;
loc_6DB94A:
_vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5;
regs.eax = vehicle->remaining_distance + 1;
_vehicleVelocityF64E0C -= regs.eax;
vehicle->remaining_distance = 0xFFFFFFFF;
regs.ebx = vehicle->vehicle_sprite_type;
return false;
loc_6DB967:
regs.eax = vehicle->remaining_distance + 1;
_vehicleVelocityF64E0C -= regs.eax;
vehicle->remaining_distance -= regs.eax;
_vehicleVelocityF64E0C -= vehicle->remaining_distance + 1;
vehicle->remaining_distance = -1;
// Might need to be bp rather than vehicle, but hopefully not
rct_vehicle* head = vehicle_get_head(GET_VEHICLE(regs.bp));
@ -8647,24 +8641,20 @@ loc_6DBA33:;
loc_6DBE5E:
_vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5;
regs.eax = vehicle->remaining_distance - 0x368A;
_vehicleVelocityF64E0C -= regs.eax;
vehicle->remaining_distance -= regs.eax;
regs.ebx = vehicle->vehicle_sprite_type;
_vehicleVelocityF64E0C -= vehicle->remaining_distance - 0x368A;
vehicle->remaining_distance = 0x368A;
return false;
loc_6DBE7F:
regs.eax = vehicle->remaining_distance - 0x368A;
_vehicleVelocityF64E0C -= regs.eax;
vehicle->remaining_distance -= regs.eax;
_vehicleVelocityF64E0C -= vehicle->remaining_distance - 0x368A;
vehicle->remaining_distance = 0x368A;
rct_vehicle* v3 = GET_VEHICLE(regs.bp);
rct_vehicle* v4 = gCurrentVehicle;
regs.eax = abs(v4->velocity - v3->velocity);
if (!(rideEntry->flags & RIDE_ENTRY_FLAG_DISABLE_COLLISION_CRASHES))
{
if (regs.eax > 0xE0000)
if (abs(v4->velocity - v3->velocity) > 0xE0000)
{
if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_BOAT_HIRE_COLLISION_DETECTION))
{
@ -9063,10 +9053,8 @@ loc_6DC99A:
loc_6DC9BC:
_vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5;
regs.eax = vehicle->remaining_distance + 1;
_vehicleVelocityF64E0C -= regs.eax;
vehicle->remaining_distance -= regs.eax;
regs.ebx = vehicle->vehicle_sprite_type;
_vehicleVelocityF64E0C -= vehicle->remaining_distance + 1;
vehicle->remaining_distance = -1;
goto loc_6DCD2B;
/////////////////////////////////////////
@ -9216,16 +9204,14 @@ loc_6DCD2B:
loc_6DCD4A:
_vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5;
regs.eax = vehicle->remaining_distance - 0x368A;
_vehicleVelocityF64E0C -= regs.eax;
vehicle->remaining_distance -= regs.eax;
_vehicleVelocityF64E0C -= vehicle->remaining_distance - 0x368A;
vehicle->remaining_distance = 0x368A;
regs.ebx = vehicle->vehicle_sprite_type;
goto loc_6DC99A;
loc_6DCD6B:
regs.eax = vehicle->remaining_distance - 0x368A;
_vehicleVelocityF64E0C -= regs.eax;
vehicle->remaining_distance -= regs.eax;
_vehicleVelocityF64E0C -= vehicle->remaining_distance - 0x368A;
vehicle->remaining_distance = 0x368A;
{
rct_vehicle* vEBP = GET_VEHICLE(regs.bp);
rct_vehicle* vEDI = gCurrentVehicle;
@ -9626,8 +9612,7 @@ int32_t vehicle_update_track_motion(rct_vehicle* vehicle, int32_t* outStation)
car->acceleration = dword_9A2970[car->vehicle_sprite_type];
_vehicleUnkF64E10 = 1;
regs.eax = _vehicleVelocityF64E0C + car->remaining_distance;
car->remaining_distance = regs.eax;
car->remaining_distance += _vehicleVelocityF64E0C;
car->sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL;
unk_F64E20.x = car->x;