diff options
Diffstat (limited to '')
39 files changed, 350 insertions, 23 deletions
diff --git a/src/entities/Automobile.cpp b/src/entities/Automobile.cpp index 89fac33e..e74013be 100644 --- a/src/entities/Automobile.cpp +++ b/src/entities/Automobile.cpp @@ -2,4 +2,15 @@ #include "patcher.h" #include "Automobile.h" -WRAPPER void CAutomobile::SetDoorDamage(int32, uint32, bool) { EAXJMP(0x530200); }
\ No newline at end of file +CAutomobile::CAutomobile(int mi, uint8 owner) +{ + ctor(mi, owner); +} + +WRAPPER CAutomobile* CAutomobile::ctor(int, uint8) { EAXJMP(0x52C6B0); } + +WRAPPER void CAutomobile::SetDoorDamage(int32, uint32, bool) { EAXJMP(0x530200); } + +STARTPATCHES +InjectHook(0x52D170, &CAutomobile::dtor, PATCH_JUMP); +ENDPATCHES
\ No newline at end of file diff --git a/src/entities/Automobile.h b/src/entities/Automobile.h index 7422112b..246943a7 100644 --- a/src/entities/Automobile.h +++ b/src/entities/Automobile.h @@ -18,9 +18,14 @@ public: float m_afWheelRotation[4]; uint8 stuff3[200]; float m_fCarGunLR; - uint8 stuff4[36]; + uint8 stuff4[13]; + uint8 m_nDriveWheelsOnGround; + uint8 stuff5[22]; + CAutomobile(int, uint8); + CAutomobile* ctor(int, uint8); void SetDoorDamage(int32, uint32, bool); /* TODO: eDoors */ + void dtor() { this->CAutomobile::~CAutomobile(); } }; static_assert(sizeof(CAutomobile) == 0x5A8, "CAutomobile: error"); static_assert(offsetof(CAutomobile, m_afWheelSuspDist) == 0x46C, "CAutomobile: error"); diff --git a/src/entities/Boat.cpp b/src/entities/Boat.cpp new file mode 100644 index 00000000..076a910e --- /dev/null +++ b/src/entities/Boat.cpp @@ -0,0 +1,14 @@ +#include "common.h" +#include "patcher.h" +#include "Boat.h" + +CBoat::CBoat(int mi, uint8 owner) +{ + ctor(mi, owner); +} + +WRAPPER CBoat* CBoat::ctor(int, uint8) { EAXJMP(0x53E3E0); } + +STARTPATCHES +InjectHook(0x53E790, &CBoat::dtor, PATCH_JUMP); +ENDPATCHES
\ No newline at end of file diff --git a/src/entities/Boat.h b/src/entities/Boat.h index b66ab107..6d6482a4 100644 --- a/src/entities/Boat.h +++ b/src/entities/Boat.h @@ -6,6 +6,12 @@ class CBoat : public CVehicle { public: // 0x288 - uint8 stuff[508]; + uint8 stuff1[57]; + bool m_bIsAnchored; + uint8 stuff[450]; + + CBoat(int, uint8); + CBoat* ctor(int, uint8); + void dtor() { this->CBoat::~CBoat(); }; }; static_assert(sizeof(CBoat) == 0x484, "CBoat: error"); diff --git a/src/entities/Building.cpp b/src/entities/Building.cpp index d69a65fe..b9fca96f 100644 --- a/src/entities/Building.cpp +++ b/src/entities/Building.cpp @@ -23,5 +23,6 @@ CBuilding::ReplaceWithNewModel(int32 id) STARTPATCHES InjectHook(0x4057D0, &CBuilding::ctor, PATCH_JUMP); + InjectHook(0x405800, &CBuilding::dtor, PATCH_JUMP); InjectHook(0x405850, &CBuilding::ReplaceWithNewModel, PATCH_JUMP); ENDPATCHES diff --git a/src/entities/Building.h b/src/entities/Building.h index b1f96bae..89d0a460 100644 --- a/src/entities/Building.h +++ b/src/entities/Building.h @@ -17,5 +17,6 @@ public: virtual bool GetIsATreadable(void) { return false; } CBuilding *ctor(void) { return ::new (this) CBuilding(); } + void dtor(void) { this->CBuilding::~CBuilding(); } }; static_assert(sizeof(CBuilding) == 0x64, "CBuilding: error"); diff --git a/src/entities/CivilianPed.cpp b/src/entities/CivilianPed.cpp new file mode 100644 index 00000000..cf589211 --- /dev/null +++ b/src/entities/CivilianPed.cpp @@ -0,0 +1,14 @@ +#include "common.h" +#include "patcher.h" +#include "CivilianPed.h" + +CCivilianPed::CCivilianPed(int pedtype, int mi) +{ + ctor(pedtype, mi); +} + +WRAPPER CCivilianPed* CCivilianPed::ctor(int pedtype, int mi) { EAXJMP(0x4BFF30); } + +STARTPATCHES + InjectHook(0x4BFFC0, &CCivilianPed::dtor, PATCH_JUMP); +ENDPATCHES
\ No newline at end of file diff --git a/src/entities/CivilianPed.h b/src/entities/CivilianPed.h index 7a592279..4d3346d3 100644 --- a/src/entities/CivilianPed.h +++ b/src/entities/CivilianPed.h @@ -5,5 +5,8 @@ class CCivilianPed : public CPed { public: + CCivilianPed(int, int); + CCivilianPed* ctor(int, int); + void dtor(void) { this->CCivilianPed::~CCivilianPed(); } }; static_assert(sizeof(CCivilianPed) == 0x53C, "CCivilianPed: error"); diff --git a/src/entities/CopPed.cpp b/src/entities/CopPed.cpp new file mode 100644 index 00000000..041185ee --- /dev/null +++ b/src/entities/CopPed.cpp @@ -0,0 +1,14 @@ +#include "common.h" +#include "patcher.h" +#include "CopPed.h" + +CCopPed::~CCopPed() +{ + ClearPursuit(); +} + +WRAPPER void CCopPed::ClearPursuit(void) { EAXJMP(0x4C28C0); } + +STARTPATCHES + InjectHook(0x4C13E0, &CCopPed::dtor, PATCH_JUMP); +ENDPATCHES
\ No newline at end of file diff --git a/src/entities/CopPed.h b/src/entities/CopPed.h index 23d52ad0..b938dfc2 100644 --- a/src/entities/CopPed.h +++ b/src/entities/CopPed.h @@ -63,6 +63,11 @@ public: int8 field_1365; int8 field_1366; int8 field_1367; + + ~CCopPed(); + void dtor(void) { this->CCopPed::~CCopPed(); } + + void ClearPursuit(void); }; static_assert(sizeof(CCopPed) == 0x558, "CCopPed: error"); diff --git a/src/entities/CutsceneObject.cpp b/src/entities/CutsceneObject.cpp index a7bca122..ede5be5b 100644 --- a/src/entities/CutsceneObject.cpp +++ b/src/entities/CutsceneObject.cpp @@ -1,14 +1,14 @@ #include "common.h" #include "patcher.h" #include "main.h" -#include "lights.h" +#include "Lights.h" #include "PointLights.h" #include "RpAnimBlend.h" #include "AnimBlendClumpData.h" #include "Renderer.h" #include "ModelIndices.h" #include "Shadows.h" -#include "TimeCycle.h" +#include "Timecycle.h" #include "CutsceneObject.h" CCutsceneObject::CCutsceneObject(void) @@ -90,6 +90,7 @@ CCutsceneObject::RemoveLighting(bool reset) } STARTPATCHES + InjectHook(0x4BA960, &CCutsceneObject::dtor, PATCH_JUMP); InjectHook(0x4BA980, &CCutsceneObject::SetModelIndex_, PATCH_JUMP); InjectHook(0x4BA9C0, &CCutsceneObject::ProcessControl_, PATCH_JUMP); InjectHook(0x4BAA40, &CCutsceneObject::PreRender_, PATCH_JUMP); diff --git a/src/entities/CutsceneObject.h b/src/entities/CutsceneObject.h index 182d8612..b4325f4b 100644 --- a/src/entities/CutsceneObject.h +++ b/src/entities/CutsceneObject.h @@ -14,7 +14,7 @@ public: bool SetupLighting(void); void RemoveLighting(bool reset); - + void dtor(void) { this->CCutsceneObject::~CCutsceneObject(); } void SetModelIndex_(uint32 id) { CCutsceneObject::SetModelIndex(id); } void ProcessControl_(void) { CCutsceneObject::ProcessControl(); } void PreRender_(void) { CCutsceneObject::PreRender(); } diff --git a/src/entities/Dummy.cpp b/src/entities/Dummy.cpp index 68b67b5c..5401c1fa 100644 --- a/src/entities/Dummy.cpp +++ b/src/entities/Dummy.cpp @@ -31,7 +31,7 @@ CDummy::Add(void) for(x = xstart; x <= xend; x++){ s = CWorld::GetSector(x, y); if(x == xmid && y == ymid) - list = &s->m_lists[ENTITYLIST_OBJECTS]; + list = &s->m_lists[ENTITYLIST_DUMMIES]; else list = &s->m_lists[ENTITYLIST_DUMMIES_OVERLAP]; CPtrNode *node = list->InsertItem(this); @@ -52,6 +52,7 @@ CDummy::Remove(void) } STARTPATCHES + InjectHook(0x473810, &CDummy::dtor, PATCH_JUMP); InjectHook(0x473860, &CDummy::Add_, PATCH_JUMP); InjectHook(0x473AD0, &CDummy::Remove_, PATCH_JUMP); ENDPATCHES diff --git a/src/entities/Dummy.h b/src/entities/Dummy.h index 4cfef2e2..59359bb5 100644 --- a/src/entities/Dummy.h +++ b/src/entities/Dummy.h @@ -18,5 +18,6 @@ public: // to make patching virtual functions possible void Add_(void) { CDummy::Add(); } void Remove_(void) { CDummy::Remove(); } + void dtor(void) { this->CDummy::~CDummy(); } }; static_assert(sizeof(CDummy) == 0x68, "CDummy: error"); diff --git a/src/entities/DummyObject.cpp b/src/entities/DummyObject.cpp index 083ad6c6..1e4b2ae0 100644 --- a/src/entities/DummyObject.cpp +++ b/src/entities/DummyObject.cpp @@ -11,3 +11,7 @@ CDummyObject::CDummyObject(CObject *obj) obj->DetachFromRwObject(); m_level = obj->m_level; } + +STARTPATCHES + InjectHook(0x4BAB70, &CDummyObject::dtor, PATCH_JUMP); +ENDPATCHES
\ No newline at end of file diff --git a/src/entities/DummyObject.h b/src/entities/DummyObject.h index d4dce609..10554bdd 100644 --- a/src/entities/DummyObject.h +++ b/src/entities/DummyObject.h @@ -9,5 +9,6 @@ class CDummyObject : public CDummy public: CDummyObject(void) {} CDummyObject(CObject *obj); + void dtor(void) { this->CDummyObject::~CDummyObject(); } }; static_assert(sizeof(CDummyObject) == 0x68, "CDummyObject: error"); diff --git a/src/entities/EmergencyPed.h b/src/entities/EmergencyPed.h index f21996e8..fa07f3ee 100644 --- a/src/entities/EmergencyPed.h +++ b/src/entities/EmergencyPed.h @@ -7,5 +7,7 @@ class CEmergencyPed : public CPed public: // 0x53C uint8 stuff[24]; + + void dtor(void) { this->CEmergencyPed::~CEmergencyPed(); } }; static_assert(sizeof(CEmergencyPed) == 0x554, "CEmergencyPed: error"); diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp index e9b35cd5..a5fbe92d 100644 --- a/src/entities/Entity.cpp +++ b/src/entities/Entity.cpp @@ -449,6 +449,8 @@ CEntity::PruneReferences(void) STARTPATCHES InjectHook(0x473C30, &CEntity::ctor, PATCH_JUMP); + InjectHook(0x473E40, &CEntity::dtor, PATCH_JUMP); + InjectHook(0x473E70, &CEntity::SetModelIndex_, PATCH_JUMP); InjectHook(0x4742C0, (void (CEntity::*)(CVector&))&CEntity::GetBoundCentre, PATCH_JUMP); InjectHook(0x474310, &CEntity::GetBoundRadius, PATCH_JUMP); InjectHook(0x474C10, &CEntity::GetIsTouching, PATCH_JUMP); diff --git a/src/entities/Entity.h b/src/entities/Entity.h index 27dd8c14..26a6e46b 100644 --- a/src/entities/Entity.h +++ b/src/entities/Entity.h @@ -156,8 +156,10 @@ public: // to make patching virtual functions possible CEntity *ctor(void) { return ::new (this) CEntity(); } + void dtor(void) { this->CEntity::~CEntity(); } void Add_(void) { CEntity::Add(); } void Remove_(void) { CEntity::Remove(); } + void SetModelIndex_(uint32 i) { CEntity::SetModelIndex(i); } void CreateRwObject_(void) { CEntity::CreateRwObject(); } void DeleteRwObject_(void) { CEntity::DeleteRwObject(); } CRect GetBoundRect_(void) { return CEntity::GetBoundRect(); } diff --git a/src/entities/Heli.cpp b/src/entities/Heli.cpp index 21731fed..01ee5375 100644 --- a/src/entities/Heli.cpp +++ b/src/entities/Heli.cpp @@ -2,4 +2,14 @@ #include "patcher.h" #include "Heli.h" +CHeli::CHeli(int mi, uint8 owner) +{ + ctor(mi, owner); +} + +WRAPPER CHeli* CHeli::ctor(int, uint8) { EAXJMP(0x547220); } WRAPPER void CHeli::SpecialHeliPreRender(void) { EAXJMP(0x54AE10); } + +STARTPATCHES +InjectHook(0x5474A0, &CHeli::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/entities/Heli.h b/src/entities/Heli.h index 57c3db0f..da7bb171 100644 --- a/src/entities/Heli.h +++ b/src/entities/Heli.h @@ -8,6 +8,10 @@ public: // 0x288 uint8 stuff[180]; + CHeli(int, uint8); + CHeli* ctor(int, uint8); + void dtor(void) { this->CHeli::~CHeli(); } + static void SpecialHeliPreRender(void); }; static_assert(sizeof(CHeli) == 0x33C, "CHeli: error"); diff --git a/src/entities/Object.cpp b/src/entities/Object.cpp index 8c7cc4c9..1feecbdf 100644 --- a/src/entities/Object.cpp +++ b/src/entities/Object.cpp @@ -66,5 +66,6 @@ CObject::Render(void) WRAPPER void CObject::DeleteAllTempObjectInArea(CVector, float) { EAXJMP(0x4BBED0); } STARTPATCHES + InjectHook(0x4BAE00, &CObject::dtor, PATCH_JUMP); InjectHook(0x4BB1E0, &CObject::Render_, PATCH_JUMP); ENDPATCHES diff --git a/src/entities/Object.h b/src/entities/Object.h index a156609c..0cb951e2 100644 --- a/src/entities/Object.h +++ b/src/entities/Object.h @@ -73,6 +73,7 @@ public: static void DeleteAllTempObjectInArea(CVector, float); + void dtor(void) { this->CObject::~CObject(); } void Render_(void) { CObject::Render(); } }; static_assert(sizeof(CObject) == 0x198, "CObject: error"); diff --git a/src/entities/Ped.cpp b/src/entities/Ped.cpp index 7f83ea84..14aad60a 100644 --- a/src/entities/Ped.cpp +++ b/src/entities/Ped.cpp @@ -4,7 +4,7 @@ #include "Particle.h" #include "Stats.h" #include "World.h" -#include "DMaudio.h" +#include "DMAudio.h" #include "RpAnimBlend.h" #include "Ped.h" #include "PlayerPed.h" @@ -17,6 +17,7 @@ #include "Shadows.h" #include "Weather.h" #include "CullZones.h" +#include "Population.h" bool &CPed::bNastyLimbsCheat = *(bool*)0x95CD44; bool &CPed::bPedCheat2 = *(bool*)0x95CD5A; @@ -27,8 +28,66 @@ CVector &CPed::offsetToOpenLowCarDoor = *(CVector*)0x62E03C; CVector &CPed::offsetToOpenVanDoor = *(CVector*)0x62E048; void *CPed::operator new(size_t sz) { return CPools::GetPedPool()->New(); } +void *CPed::operator new(size_t sz, int handle) { return CPools::GetPedPool()->New(handle); } void CPed::operator delete(void *p, size_t sz) { CPools::GetPedPool()->Delete((CPed*)p); } +void CPed::operator delete(void *p, int handle) { CPools::GetPedPool()->Delete((CPed*)p); } +CPed::~CPed(void) +{ + CWorld::Remove(this); + CRadar::ClearBlipForEntity(BLIP_CHAR, CPools::GetPedPool()->GetIndex(this)); + if (bInVehicle && m_pMyVehicle){ + uint8 door_flag = 0; + switch (m_vehEnterType) { + case VEHICLE_ENTER_FRONT_LEFT: door_flag = 1; break; + case VEHICLE_ENTER_REAR_LEFT: door_flag = 2; break; + case VEHICLE_ENTER_FRONT_RIGHT: door_flag = 4; break; + case VEHICLE_ENTER_REAR_RIGHT: door_flag = 8; break; + default: break; + } + if (m_pMyVehicle->pDriver == this) + m_pMyVehicle->pDriver = nil; + else { + for (int i = 0; i < m_pMyVehicle->m_nNumMaxPassengers; i++) { + if (m_pMyVehicle->pPassengers[i] == this) + m_pMyVehicle->pPassengers[i] = nil; + } + } + if (m_nPedState == PED_EXIT_CAR || m_nPedState == PED_DRAG_FROM_CAR) + m_pMyVehicle->m_nGettingOutFlags &= ~door_flag; + bInVehicle = false; + m_pMyVehicle = nil; + }else if (m_nPedState == PED_ENTER_CAR || m_nPedState == PED_CARJACK){ + QuitEnteringCar(); + } + if (m_pFire) + m_pFire->Extinguish(); + CPopulation::UpdatePedCount(m_nPedType, true); + DMAudio.DestroyEntity(m_audioEntityId); +} + +void CPed::FlagToDestroyWhenNextProcessed(void) +{ + bRemoveFromWorld = true; + if (!bInVehicle || !m_pMyVehicle) + return; + if (m_pMyVehicle->pDriver == this){ + m_pMyVehicle->pDriver = nil; + if (IsPlayer() && m_pMyVehicle->m_status != STATUS_WRECKED) + m_pMyVehicle->m_status = STATUS_ABANDONED; + }else{ + m_pMyVehicle->RemovePassenger(this); + } + bInVehicle = false; + m_pMyVehicle = nil; + if (m_nCreatedBy == 2) /* TODO: enum (MISSION) */ + m_nPedState = PED_DEAD; + else + m_nPedState = PED_NONE; + m_pVehicleAnim = nil; +} + +WRAPPER void CPed::QuitEnteringCar() { EAXJMP(0x4E0E00); } WRAPPER void CPed::KillPedWithCar(CVehicle *veh, float impulse) { EAXJMP(0x4EC430); } WRAPPER void CPed::Say(uint16 audio) { EAXJMP(0x4E5A10); } WRAPPER void CPed::SetDie(AnimationId anim, float arg1, float arg2) { EAXJMP(0x4D37D0); } @@ -416,7 +475,7 @@ CPed::RemoveBodyPart(PedNode nodeId, int8 unk) if (nodeId != PED_HEAD) CPed::SpawnFlyingComponent(nodeId, unk); - RecurseFrameChildrenVisibilityCB(frame, 0); + RecurseFrameChildrenVisibilityCB(frame, nil); pos.x = 0.0f; pos.y = 0.0f; pos.z = 0.0f; @@ -447,7 +506,7 @@ CPed::RemoveBodyPart(PedNode nodeId, int8 unk) RwObject* CPed::SetPedAtomicVisibilityCB(RwObject *object, void *data) { - if (data == 0) + if (data == nil) RpAtomicSetFlags(object, 0); return object; } @@ -456,7 +515,7 @@ RwFrame* CPed::RecurseFrameChildrenVisibilityCB(RwFrame *frame, void *data) { RwFrameForAllObjects(frame, SetPedAtomicVisibilityCB, data); - RwFrameForAllChildren(frame, RecurseFrameChildrenVisibilityCB, 0); + RwFrameForAllChildren(frame, RecurseFrameChildrenVisibilityCB, nil); return frame; } @@ -824,7 +883,7 @@ CPed::Attack(void) && GetWeapon()->m_eWeaponState != WEAPONSTATE_RELOADING) { weaponAnim = weaponAnimAssoc->animId; - if (ourWeaponFire != WEAPON_FIRE_MELEE || CheckForPedsOnGroundToAttack(((CPlayerPed*)this), 0) < PED_ON_THE_FLOOR) { + if (ourWeaponFire != WEAPON_FIRE_MELEE || CheckForPedsOnGroundToAttack(((CPlayerPed*)this), nil) < PED_ON_THE_FLOOR) { if (weaponAnim != ourWeapon->m_Anim2ToPlay || weaponAnim == ANIM_RBLOCK_CSHOOT) { weaponAnimAssoc->Start(ourWeapon->m_fAnimLoopStart); } else { @@ -873,7 +932,7 @@ CPed::Attack(void) if (lastReloadWasInFuture) { if (ourWeaponFire != WEAPON_FIRE_PROJECTILE || !CPed::IsPlayer() || ((CPlayerPed*)this)->field_1380) { - if (!CGame::nastyGame || ourWeaponFire != WEAPON_FIRE_MELEE || CheckForPedsOnGroundToAttack(((CPlayerPed*)this), 0) < PED_ON_THE_FLOOR) { + if (!CGame::nastyGame || ourWeaponFire != WEAPON_FIRE_MELEE || CheckForPedsOnGroundToAttack(((CPlayerPed*)this), nil) < PED_ON_THE_FLOOR) { weaponAnimAssoc = CAnimManager::BlendAnimation((RpClump*)m_rwObject, ASSOCGRP_STD, ourWeapon->m_AnimToPlay, 8.0f); } else { weaponAnimAssoc = CAnimManager::BlendAnimation((RpClump*)m_rwObject, ASSOCGRP_STD, ourWeapon->m_Anim2ToPlay, 8.0f); @@ -892,14 +951,14 @@ CPed::Attack(void) } } else - CPed::FinishedAttackCB(0, this); + CPed::FinishedAttackCB(nil, this); } void CPed::RemoveWeaponModel(int modelId) { // modelId is not used!! This function just removes the current weapon. - RwFrameForAllObjects(GetNodeFrame(PED_HANDR),RemoveAllModelCB,0); + RwFrameForAllObjects(GetNodeFrame(PED_HANDR),RemoveAllModelCB,nil); m_wepModelID = -1; } @@ -1621,10 +1680,11 @@ WRAPPER void CPed::FinishFightMoveCB(CAnimBlendAssociation *assoc, void *arg) { WRAPPER void CPed::PedAnimDoorCloseRollingCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4E4B90); } WRAPPER void CPed::FinishJumpCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4D7A50); } WRAPPER void CPed::PedLandCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4CE8A0); } -WRAPPER void FinishFuckUCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4C6620); } +WRAPPER void FinishFuckUCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4C6580); } WRAPPER void CPed::RestoreHeadingRateCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4D6550); } STARTPATCHES + InjectHook(0x4C50D0, &CPed::dtor, PATCH_JUMP); InjectHook(0x4CF8F0, &CPed::AddWeaponModel, PATCH_JUMP); InjectHook(0x4C6AA0, &CPed::AimGun, PATCH_JUMP); InjectHook(0x4EB470, &CPed::ApplyHeadShot, PATCH_JUMP); diff --git a/src/entities/Ped.h b/src/entities/Ped.h index 9b2ec31f..8f4939fc 100644 --- a/src/entities/Ped.h +++ b/src/entities/Ped.h @@ -9,6 +9,7 @@ #include "AnimBlendClumpData.h" #include "AnimBlendAssociation.h" #include "WeaponInfo.h" +#include "Fire.h" struct CPathNode; @@ -85,15 +86,15 @@ enum PedState PED_PASSENGER, PED_TAXI_PASSENGER, PED_OPEN_DOOR, - PED_DIE, - PED_DEAD, + PED_DIE = 48, + PED_DEAD = 49, PED_CARJACK, PED_DRAG_FROM_CAR, PED_ENTER_CAR, PED_STEAL_CAR, PED_EXIT_CAR, PED_HANDS_UP, - PED_ARRESTED, + PED_ARRESTED = 56, }; enum { @@ -184,7 +185,9 @@ public: uint8 m_ped_flagI20 : 1; uint8 m_ped_flagI40 : 1; uint8 m_ped_flagI80 : 1; - uint8 stuff10[15]; + uint8 stuff10[3]; + uint8 m_nCreatedBy; + uint8 stuff14[11]; CPed *m_field_16C; uint8 stuff12[44]; int32 m_pEventEntity; @@ -243,7 +246,8 @@ public: uint8 stuff[2]; int32 m_pPointGunAt; CVector m_vecHitLastPos; - uint8 stuff8[12]; + uint8 stuff8[8]; + CFire* m_pFire; CEntity *m_pLookTarget; float m_fLookDirection; int32 m_wepModelID; @@ -266,7 +270,14 @@ public: uint8 stuff11[30]; static void *operator new(size_t); + static void *operator new(size_t, int); static void operator delete(void*, size_t); + static void operator delete(void*, int); + + ~CPed(void); + void FlagToDestroyWhenNextProcessed(void); + + void dtor(void) { this->CPed::~CPed(); } bool IsPlayer(void); bool UseGroundColModel(void); @@ -301,6 +312,7 @@ public: void LineUpPedWithCar(PedLineUpPhase phase); void SetPedPositionInCar(void); void PlayFootSteps(void); + void QuitEnteringCar(void); static void GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enterType, float offset); static void GetPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enterType, float seatPosMult); static void GetPositionToOpenCarDoor(CVector* output, CVehicle* veh, uint32 enterType); diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp index 64e0fb8b..b570efd9 100644 --- a/src/entities/Physical.cpp +++ b/src/entities/Physical.cpp @@ -1895,6 +1895,7 @@ CPhysical::ProcessCollision(void) STARTPATCHES + InjectHook(0x495130, &CPhysical::dtor, PATCH_JUMP); InjectHook(0x4951F0, &CPhysical::Add_, PATCH_JUMP); InjectHook(0x4954B0, &CPhysical::Remove_, PATCH_JUMP); InjectHook(0x495540, &CPhysical::RemoveAndAdd, PATCH_JUMP); diff --git a/src/entities/Physical.h b/src/entities/Physical.h index 749e2dd8..25bc1185 100644 --- a/src/entities/Physical.h +++ b/src/entities/Physical.h @@ -134,6 +134,7 @@ public: void ProcessCollision(void); // to make patching virtual functions possible + void dtor(void) { this->CPhysical::~CPhysical(); } void Add_(void) { CPhysical::Add(); } void Remove_(void) { CPhysical::Remove(); } CRect GetBoundRect_(void) { return CPhysical::GetBoundRect(); } diff --git a/src/entities/Plane.cpp b/src/entities/Plane.cpp new file mode 100644 index 00000000..6e30bced --- /dev/null +++ b/src/entities/Plane.cpp @@ -0,0 +1,19 @@ +#include "common.h" +#include "patcher.h" +#include "Plane.h" + +CPlane::CPlane(int mi, uint8 owner) +{ + ctor(mi, owner); +} + +WRAPPER CPlane* CPlane::ctor(int, uint8) { EAXJMP(0x54B170); } + +CPlane::~CPlane() +{ + DeleteRwObject(); +} + +STARTPATCHES +InjectHook(0x54B270, &CPlane::dtor, PATCH_JUMP); +ENDPATCHES
\ No newline at end of file diff --git a/src/entities/Plane.h b/src/entities/Plane.h index 9acc24ec..e26008f6 100644 --- a/src/entities/Plane.h +++ b/src/entities/Plane.h @@ -1,5 +1,6 @@ #pragma once +#include "common.h" #include "Vehicle.h" class CPlane : public CVehicle @@ -7,5 +8,11 @@ class CPlane : public CVehicle public: // 0x288 uint8 stuff[20]; + + CPlane(int, uint8); + ~CPlane(void); + CPlane* ctor(int, uint8); + void dtor(void) { this->CPlane::~CPlane(); } + void FlagToDestroyWhenNextProcessed() { bRemoveFromWorld = true; } }; static_assert(sizeof(CPlane) == 0x29C, "CPlane: error"); diff --git a/src/entities/PlayerPed.cpp b/src/entities/PlayerPed.cpp new file mode 100644 index 00000000..2d67d5b2 --- /dev/null +++ b/src/entities/PlayerPed.cpp @@ -0,0 +1,14 @@ +#include "common.h" +#include "patcher.h" +#include "PlayerPed.h" + +CPlayerPed::~CPlayerPed() +{ + delete m_pWanted; +} + +WRAPPER void CPlayerPed::ReApplyMoveAnims(void) { EAXJMP(0x4F07C0); } + +STARTPATCHES + InjectHook(0x4EFB30, &CPlayerPed::dtor, PATCH_JUMP); +ENDPATCHES
\ No newline at end of file diff --git a/src/entities/PlayerPed.h b/src/entities/PlayerPed.h index 23e7dae5..d09deb49 100644 --- a/src/entities/PlayerPed.h +++ b/src/entities/PlayerPed.h @@ -38,6 +38,11 @@ public: int32 field_1488[6]; float field_1512; float m_fFPSMoveHeading; + + ~CPlayerPed(); + + void dtor(void) { this->CPlayerPed::~CPlayerPed(); } + void ReApplyMoveAnims(void); }; static_assert(sizeof(CPlayerPed) == 0x5F0, "CPlayerPed: error"); diff --git a/src/entities/Projectile.cpp b/src/entities/Projectile.cpp new file mode 100644 index 00000000..e21323de --- /dev/null +++ b/src/entities/Projectile.cpp @@ -0,0 +1,7 @@ +#include "common.h" +#include "patcher.h" +#include "Projectile.h" + +STARTPATCHES + InjectHook(0x4BFED0, &CProjectile::dtor, PATCH_JUMP); +ENDPATCHES
\ No newline at end of file diff --git a/src/entities/Projectile.h b/src/entities/Projectile.h new file mode 100644 index 00000000..a8e826b6 --- /dev/null +++ b/src/entities/Projectile.h @@ -0,0 +1,11 @@ +#pragma once + +#pragma once + +#include "Object.h" + +class CProjectile : public CObject +{ +public: + void dtor(void) { this->CProjectile::~CProjectile(); } +}; diff --git a/src/entities/Train.cpp b/src/entities/Train.cpp new file mode 100644 index 00000000..62fd53ec --- /dev/null +++ b/src/entities/Train.cpp @@ -0,0 +1,14 @@ +#include "common.h" +#include "patcher.h" +#include "Train.h" + +CTrain::CTrain(int mi, uint8 owner) +{ + ctor(mi, owner); +} + +WRAPPER CTrain* CTrain::ctor(int, uint8) { EAXJMP(0x54E2A0); } + +STARTPATCHES +InjectHook(0x54E450, &CTrain::dtor, PATCH_JUMP); +ENDPATCHES
\ No newline at end of file diff --git a/src/entities/Train.h b/src/entities/Train.h index f3fb9a40..84b6faf5 100644 --- a/src/entities/Train.h +++ b/src/entities/Train.h @@ -1,5 +1,7 @@ #pragma once +#include "common.h" +#include "patcher.h" #include "Vehicle.h" enum @@ -16,5 +18,9 @@ public: uint8 stuff2[7]; int16 m_doorState; uint8 stuff3[62]; + + CTrain(int, uint8); + CTrain* ctor(int, uint8); + void dtor(void) { this->CTrain::~CTrain(); } }; static_assert(sizeof(CTrain) == 0x2E4, "CTrain: error"); diff --git a/src/entities/Treadable.cpp b/src/entities/Treadable.cpp index e2eca36a..230d1633 100644 --- a/src/entities/Treadable.cpp +++ b/src/entities/Treadable.cpp @@ -1,7 +1,12 @@ #include "common.h" +#include "patcher.h" #include "rpworld.h" #include "Treadable.h" #include "Pools.h" void *CTreadable::operator new(size_t sz) { return CPools::GetTreadablePool()->New(); } void CTreadable::operator delete(void *p, size_t sz) { CPools::GetTreadablePool()->Delete((CTreadable*)p); } + +STARTPATCHES + InjectHook(0x405A10, &CTreadable::dtor, PATCH_JUMP); +ENDPATCHES
\ No newline at end of file diff --git a/src/entities/Treadable.h b/src/entities/Treadable.h index df5c9ee0..2194638d 100644 --- a/src/entities/Treadable.h +++ b/src/entities/Treadable.h @@ -12,5 +12,6 @@ public: int16 m_nodeIndicesPeds[12]; virtual bool GetIsATreadable(void) { return true; } + void dtor(void) { this->CTreadable::~CTreadable(); } }; static_assert(sizeof(CTreadable) == 0x94, "CTreadable: error"); diff --git a/src/entities/Vehicle.cpp b/src/entities/Vehicle.cpp index ced504a3..8c1ef515 100644 --- a/src/entities/Vehicle.cpp +++ b/src/entities/Vehicle.cpp @@ -4,6 +4,8 @@ #include "Pools.h" #include "CarCtrl.h" #include "ModelIndices.h" +#include "DMAudio.h" +#include "Radar.h" bool &CVehicle::bWheelsOnlyCheat = *(bool *)0x95CD78; bool &CVehicle::bAllDodosCheat = *(bool *)0x95CD75; @@ -12,7 +14,36 @@ bool &CVehicle::bCheat4 = *(bool *)0x95CD65; bool &CVehicle::bCheat5 = *(bool *)0x95CD64; void *CVehicle::operator new(size_t sz) { return CPools::GetVehiclePool()->New(); } +void *CVehicle::operator new(size_t sz, int handle) { return CPools::GetVehiclePool()->New(handle); } void CVehicle::operator delete(void *p, size_t sz) { CPools::GetVehiclePool()->Delete((CVehicle*)p); } +void CVehicle::operator delete(void *p, int handle) { CPools::GetVehiclePool()->Delete((CVehicle*)p); } + +CVehicle::~CVehicle() +{ + m_nAlarmState = 0; + if (m_audioEntityId >= 0){ + DMAudio.DestroyEntity(m_audioEntityId); + m_audioEntityId = -5; + } + CRadar::ClearBlipForEntity(BLIP_CAR, CPools::GetVehiclePool()->GetIndex(this)); + if (pDriver) + pDriver->FlagToDestroyWhenNextProcessed(); + for (int i = 0; i < m_nNumMaxPassengers; i++){ + if (pPassengers[i]) + pPassengers[i]->FlagToDestroyWhenNextProcessed(); + } + if (m_pCarFire) + m_pCarFire->Extinguish(); + CCarCtrl::UpdateCarCount(this, true); + if (bIsAmbulanceOnDuty){ + CCarCtrl::NumAmbulancesOnDuty--; + bIsAmbulanceOnDuty = false; + } + if (bIsFiretruckOnDuty){ + CCarCtrl::NumFiretrucksOnDuty--; + bIsFiretruckOnDuty = false; + } +} bool CVehicle::IsLawEnforcementVehicle(void) @@ -47,6 +78,28 @@ CVehicle::ChangeLawEnforcerState(bool enable) } void +CVehicle::RemovePassenger(CPed *p) +{ + if (IsTrain()){ + for (int i = 0; i < 8; i++){ + if (pPassengers[i] == p) { + pPassengers[i] = nil; + m_nNumPassengers--; + return; + } + } + return; + } + for (int i = 0; i < m_nNumMaxPassengers; i++){ + if (pPassengers[i] == p){ + pPassengers[i] = nil; + m_nNumPassengers--; + return; + } + } +} + +void CVehicle::RemoveDriver(void) { m_status = STATUS_ABANDONED; diff --git a/src/entities/Vehicle.h b/src/entities/Vehicle.h index f11e9e97..997720f6 100644 --- a/src/entities/Vehicle.h +++ b/src/entities/Vehicle.h @@ -50,8 +50,8 @@ public: float m_fBreakPedal; uint8 m_nCreatedBy; // eVehicleCreatedBy uint8 bIsLawEnforcer : 1; - uint8 m_veh_flagA2 : 1; - uint8 m_veh_flagA4 : 1; + uint8 bIsAmbulanceOnDuty : 1; + uint8 bIsFiretruckOnDuty : 1; uint8 m_veh_flagA8 : 1; uint8 m_veh_flagA10 : 1; uint8 m_veh_flagA20 : 1; @@ -111,7 +111,13 @@ public: eVehicleType m_vehType; static void *operator new(size_t); + static void *operator new(size_t sz, int slot); static void operator delete(void*, size_t); + static void operator delete(void*, int); + + ~CVehicle(void); + + void dtor(void) { this->CVehicle::~CVehicle(); } bool IsCar(void) { return m_vehType == VEHICLE_TYPE_CAR; } bool IsBoat(void) { return m_vehType == VEHICLE_TYPE_BOAT; } @@ -120,6 +126,7 @@ public: bool IsPlane(void) { return m_vehType == VEHICLE_TYPE_PLANE; } bool IsLawEnforcementVehicle(void); void ChangeLawEnforcerState(bool enable); + void RemovePassenger(CPed *); void RemoveDriver(void); bool IsUpsideDown(void); |