Skip to content

Commit

Permalink
Potentially fix Traffic Is X crashes
Browse files Browse the repository at this point in the history
Seems like there were 2 functions for ambulance and firetruck occupants where it forced a passenger at all times. For now we just hook them and set up the driver and passenger normally
  • Loading branch information
Lordmau5 committed Aug 27, 2024
1 parent 287e564 commit ce7b569
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/gtasa/effects/custom/vehicle/CustomVehicleSpawnsEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class CustomVehicleSpawnsEffect : public EffectBase
HOOK_ARGS (inst, Hooked_RandomizeTrafficCars, signed int (int *),
0x43022A);

// CCarCtrl::ChooseCarModelToLoad
HOOK (inst, Hooked_RandomizeCarToLoad, signed int (int *), 0x40B4CB,
0x40B596, 0x40B62F, 0x40ED07);

Expand All @@ -54,6 +55,22 @@ class CustomVehicleSpawnsEffect : public EffectBase
HOOK_METHOD_ARGS (inst, Hooked_RandomizeRoadblocks,
CVehicle * (CVehicle *, int, char, char), 0x462217,
0x4998F0, 0x42B909);

// Firetruck occupants
HOOK_ARGS (inst, Hooked_FixFiretruckAndAmbulanceOccupants,
void (uint8_t *), 0x42BC1A, 0x42BBFB);
}

static void
Hooked_FixFiretruckAndAmbulanceOccupants (auto &&cb, uint8_t *vehicle)
{
LoadCarModel ();

// 13 is some ped type I think?
// TODO: Figure out what 13 *is* and see if we can have it be emergency
// or fireman instead - for now this should fix crashes though
CCarCtrl::SetUpDriverAndPassengersForVehicle ((CVehicle *) vehicle, 13,
0, 0, 0, 99);
}

static bool
Expand Down

0 comments on commit ce7b569

Please sign in to comment.