diff options
Diffstat (limited to 'src')
64 files changed, 772 insertions, 279 deletions
diff --git a/src/control/Script.h b/src/control/Script.h index 5759cf82..96e1aed5 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -1,10 +1,12 @@ #pragma once #include "common.h" -#include "Collision.h" -#include "Ped.h" -#include "Object.h" #include "Sprite2d.h" -#include "Vehicle.h" + +class CEntity; +class CBuilding; +class CVehicle; +class CPed; +class CObject; struct CScriptRectangle { diff --git a/src/core/Instance.cpp b/src/core/Instance.cpp new file mode 100644 index 00000000..5426605f --- /dev/null +++ b/src/core/Instance.cpp @@ -0,0 +1,13 @@ +#include "common.h" +#include "patcher.h" +#include "Instance.h" + +class CInstance_ : public CInstance +{ +public: + void dtor() { CInstance::~CInstance(); } +}; + +STARTPATCHES + InjectHook(0x50BE90, &CInstance_::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/core/Instance.h b/src/core/Instance.h new file mode 100644 index 00000000..1038c005 --- /dev/null +++ b/src/core/Instance.h @@ -0,0 +1,10 @@ +#pragma once + +#include "Placeable.h" + +// unused + +class CInstance : CPlaceable +{ +public: +}; diff --git a/src/core/Placeable.cpp b/src/core/Placeable.cpp index b4b2a37b..c1fe705e 100644 --- a/src/core/Placeable.cpp +++ b/src/core/Placeable.cpp @@ -63,9 +63,17 @@ CPlaceable::IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z1 <= GetPosition().z && GetPosition().z <= z2; } +class CPlaceable_ : public CPlaceable +{ +public: + CPlaceable *ctor(void) { return ::new (this) CPlaceable(); } + void dtor(void) { CPlaceable::~CPlaceable(); } +}; + STARTPATCHES - InjectHook(0x49F9A0, &CPlaceable::ctor, PATCH_JUMP); - InjectHook(0x49F9E0, &CPlaceable::dtor, PATCH_JUMP); + InjectHook(0x49F9A0, &CPlaceable_::ctor, PATCH_JUMP); + InjectHook(0x49F9E0, &CPlaceable_::dtor, PATCH_JUMP); + InjectHook(0x49FA00, &CPlaceable::SetHeading, PATCH_JUMP); InjectHook(0x49FA50, (bool (CPlaceable::*)(float, float, float, float))&CPlaceable::IsWithinArea, PATCH_JUMP); InjectHook(0x49FAF0, (bool (CPlaceable::*)(float, float, float, float, float, float))&CPlaceable::IsWithinArea, PATCH_JUMP); diff --git a/src/core/Placeable.h b/src/core/Placeable.h index 868ca9e7..bd1d50ab 100644 --- a/src/core/Placeable.h +++ b/src/core/Placeable.h @@ -19,8 +19,5 @@ public: void SetHeading(float angle); bool IsWithinArea(float x1, float y1, float x2, float y2); bool IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z2); - - CPlaceable *ctor(void) { return ::new (this) CPlaceable(); } - void dtor(void) { this->CPlaceable::~CPlaceable(); } }; static_assert(sizeof(CPlaceable) == 0x4C, "CPlaceable: error"); diff --git a/src/entities/Building.cpp b/src/entities/Building.cpp index b9fca96f..188cbfe7 100644 --- a/src/entities/Building.cpp +++ b/src/entities/Building.cpp @@ -21,8 +21,15 @@ CBuilding::ReplaceWithNewModel(int32 id) CStreaming::RequestModel(id, STREAMFLAGS_DONT_REMOVE); } +class CBuilding_ : public CBuilding +{ +public: + CBuilding *ctor(void) { return ::new (this) CBuilding(); } + void dtor(void) { CBuilding::~CBuilding(); } +}; + STARTPATCHES - InjectHook(0x4057D0, &CBuilding::ctor, PATCH_JUMP); - InjectHook(0x405800, &CBuilding::dtor, PATCH_JUMP); + 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 89d0a460..7b837f46 100644 --- a/src/entities/Building.h +++ b/src/entities/Building.h @@ -15,8 +15,5 @@ public: void ReplaceWithNewModel(int32 id); 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/Dummy.cpp b/src/entities/Dummy.cpp index 5401c1fa..176e5682 100644 --- a/src/entities/Dummy.cpp +++ b/src/entities/Dummy.cpp @@ -51,8 +51,16 @@ CDummy::Remove(void) } } +class CDummy_ : public CDummy +{ +public: + void Add_(void) { CDummy::Add(); } + void Remove_(void) { CDummy::Remove(); } + void dtor(void) { CDummy::~CDummy(); } +}; + STARTPATCHES - InjectHook(0x473810, &CDummy::dtor, PATCH_JUMP); - InjectHook(0x473860, &CDummy::Add_, PATCH_JUMP); - InjectHook(0x473AD0, &CDummy::Remove_, PATCH_JUMP); + 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 59359bb5..fcfd23fb 100644 --- a/src/entities/Dummy.h +++ b/src/entities/Dummy.h @@ -14,10 +14,5 @@ public: static void *operator new(size_t); static void operator delete(void*, size_t); - - // 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/Entity.cpp b/src/entities/Entity.cpp index fac7f17f..105f14c3 100644 --- a/src/entities/Entity.cpp +++ b/src/entities/Entity.cpp @@ -865,10 +865,35 @@ CEntity::ModifyMatrixForBannerInWind(void) UpdateRwFrame(); } +class CEntity_ : public CEntity +{ +public: + 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(); } + void PreRender_(void) { CEntity::PreRender(); } + void Render_(void) { CEntity::Render(); } + bool SetupLighting_(void) { return CEntity::SetupLighting(); } +}; + STARTPATCHES - InjectHook(0x473C30, &CEntity::ctor, PATCH_JUMP); - InjectHook(0x473E40, &CEntity::dtor, PATCH_JUMP); - InjectHook(0x473E70, &CEntity::SetModelIndex_, PATCH_JUMP); + InjectHook(0x473C30, &CEntity_::ctor, PATCH_JUMP); + InjectHook(0x473E40, &CEntity_::dtor, PATCH_JUMP); + InjectHook(0x473E70, &CEntity_::SetModelIndex_, PATCH_JUMP); + InjectHook(0x475080, &CEntity_::Add_, PATCH_JUMP); + InjectHook(0x475310, &CEntity_::Remove_, PATCH_JUMP); + InjectHook(0x473EA0, &CEntity_::CreateRwObject_, PATCH_JUMP); + InjectHook(0x473F90, &CEntity_::DeleteRwObject_, PATCH_JUMP); + InjectHook(0x474000, &CEntity_::GetBoundRect_, PATCH_JUMP); + InjectHook(0x474350, &CEntity_::PreRender_, PATCH_JUMP); + InjectHook(0x474BD0, &CEntity_::Render_, PATCH_JUMP); + InjectHook(0x4A7C60, &CEntity_::SetupLighting_, PATCH_JUMP); + InjectHook(0x4742C0, (void (CEntity::*)(CVector&))&CEntity::GetBoundCentre, PATCH_JUMP); InjectHook(0x474310, &CEntity::GetBoundRadius, PATCH_JUMP); InjectHook(0x474C10, &CEntity::GetIsTouching, PATCH_JUMP); @@ -889,13 +914,4 @@ STARTPATCHES InjectHook(0x475670, &CEntity::ModifyMatrixForTreeInWind, PATCH_JUMP); InjectHook(0x475830, &CEntity::ModifyMatrixForBannerInWind, PATCH_JUMP); InjectHook(0x4FA530, &CEntity::ProcessLightsForEntity, PATCH_JUMP); - - InjectHook(0x475080, &CEntity::Add_, PATCH_JUMP); - InjectHook(0x475310, &CEntity::Remove_, PATCH_JUMP); - InjectHook(0x473EA0, &CEntity::CreateRwObject_, PATCH_JUMP); - InjectHook(0x473F90, &CEntity::DeleteRwObject_, PATCH_JUMP); - InjectHook(0x474000, &CEntity::GetBoundRect_, PATCH_JUMP); - InjectHook(0x474350, &CEntity::PreRender_, PATCH_JUMP); - InjectHook(0x474BD0, &CEntity::Render_, PATCH_JUMP); - InjectHook(0x4A7C60, &CEntity::SetupLighting_, PATCH_JUMP); ENDPATCHES diff --git a/src/entities/Entity.h b/src/entities/Entity.h index 92c4c351..d055d25f 100644 --- a/src/entities/Entity.h +++ b/src/entities/Entity.h @@ -95,12 +95,12 @@ public: CReference *m_pFirstReference; CEntity(void); - virtual ~CEntity(void); + ~CEntity(void); virtual void Add(void); virtual void Remove(void); - virtual void SetModelIndex(uint32 i) { m_modelIndex = i; CreateRwObject(); } - virtual void SetModelIndexNoCreate(uint32 i) { m_modelIndex = i; } + virtual void SetModelIndex(uint32 id) { m_modelIndex = id; CreateRwObject(); } + virtual void SetModelIndexNoCreate(uint32 id) { m_modelIndex = id; } virtual void CreateRwObject(void); virtual void DeleteRwObject(void); virtual CRect GetBoundRect(void); @@ -145,19 +145,5 @@ public: void ModifyMatrixForTreeInWind(void); void ModifyMatrixForBannerInWind(void); void ProcessLightsForEntity(void); - - - // 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(); } - void PreRender_(void) { CEntity::PreRender(); } - void Render_(void) { CEntity::Render(); } - bool SetupLighting_(void) { return CEntity::SetupLighting(); } }; static_assert(sizeof(CEntity) == 0x64, "CEntity: error"); diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp index d6a82658..3d45bf52 100644 --- a/src/entities/Physical.cpp +++ b/src/entities/Physical.cpp @@ -3,6 +3,7 @@ #include "World.h" #include "Timer.h" #include "ModelIndices.h" +#include "Treadable.h" #include "Vehicle.h" #include "Ped.h" #include "Object.h" @@ -1932,16 +1933,28 @@ CPhysical::ProcessCollision(void) RemoveAndAdd(); } +class CPhysical_ : public CPhysical +{ +public: + void dtor(void) { CPhysical::~CPhysical(); } + void Add_(void) { CPhysical::Add(); } + void Remove_(void) { CPhysical::Remove(); } + CRect GetBoundRect_(void) { return CPhysical::GetBoundRect(); } + void ProcessControl_(void) { CPhysical::ProcessControl(); } + void ProcessShift_(void) { CPhysical::ProcessShift(); } + void ProcessCollision_(void) { CPhysical::ProcessCollision(); } + int32 ProcessEntityCollision_(CEntity *ent, CColPoint *point) { return CPhysical::ProcessEntityCollision(ent, point); } +}; 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); - InjectHook(0x495F10, &CPhysical::ProcessControl_, PATCH_JUMP); - InjectHook(0x496F10, &CPhysical::ProcessShift_, PATCH_JUMP); - InjectHook(0x4961A0, &CPhysical::ProcessCollision_, PATCH_JUMP); - InjectHook(0x49F790, &CPhysical::ProcessEntityCollision_, PATCH_JUMP); + InjectHook(0x495130, &CPhysical_::dtor, PATCH_JUMP); + InjectHook(0x4951F0, &CPhysical_::Add_, PATCH_JUMP); + InjectHook(0x4954B0, &CPhysical_::Remove_, PATCH_JUMP); + InjectHook(0x495540, &CPhysical_::RemoveAndAdd, PATCH_JUMP); + InjectHook(0x495F10, &CPhysical_::ProcessControl_, PATCH_JUMP); + InjectHook(0x496F10, &CPhysical_::ProcessShift_, PATCH_JUMP); + InjectHook(0x4961A0, &CPhysical_::ProcessCollision_, PATCH_JUMP); + InjectHook(0x49F790, &CPhysical_::ProcessEntityCollision_, PATCH_JUMP); InjectHook(0x4958F0, &CPhysical::AddToMovingList, PATCH_JUMP); InjectHook(0x495940, &CPhysical::RemoveFromMovingList, PATCH_JUMP); InjectHook(0x497180, &CPhysical::AddCollisionRecord, PATCH_JUMP); diff --git a/src/entities/Physical.h b/src/entities/Physical.h index 81d3d649..c1f9f1d9 100644 --- a/src/entities/Physical.h +++ b/src/entities/Physical.h @@ -3,12 +3,13 @@ #include "Lists.h" #include "Timer.h" #include "Entity.h" -#include "Treadable.h" enum { PHYSICAL_MAX_COLLISIONRECORDS = 6 }; +class CTreadable; + class CPhysical : public CEntity { public: @@ -65,13 +66,14 @@ public: ~CPhysical(void); // from CEntity - virtual void Add(void); - virtual void Remove(void); - virtual CRect GetBoundRect(void); - virtual void ProcessControl(void); + void Add(void); + void Remove(void); + CRect GetBoundRect(void); + void ProcessControl(void); + void ProcessShift(void); + void ProcessCollision(void); + virtual int32 ProcessEntityCollision(CEntity *ent, CColPoint *point); - virtual void ProcessShift(void); - virtual void ProcessCollision(void); void RemoveAndAdd(void); void AddToMovingList(void); @@ -137,15 +139,5 @@ public: bool ProcessCollisionSectorList(CPtrList *lists); bool CheckCollision(void); bool CheckCollision_SimpleCar(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(); } - void ProcessControl_(void) { CPhysical::ProcessControl(); } - void ProcessShift_(void) { CPhysical::ProcessShift(); } - void ProcessCollision_(void) { CPhysical::ProcessCollision(); } - int32 ProcessEntityCollision_(CEntity *ent, CColPoint *point) { return CPhysical::ProcessEntityCollision(ent, point); } }; static_assert(sizeof(CPhysical) == 0x128, "CPhysical: error"); diff --git a/src/entities/Treadable.cpp b/src/entities/Treadable.cpp index 230d1633..ea949f00 100644 --- a/src/entities/Treadable.cpp +++ b/src/entities/Treadable.cpp @@ -7,6 +7,12 @@ 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); } +class CTreadable_ : public CTreadable +{ +public: + void dtor(void) { CTreadable::~CTreadable(); } +}; + STARTPATCHES - InjectHook(0x405A10, &CTreadable::dtor, PATCH_JUMP); -ENDPATCHES
\ No newline at end of file + InjectHook(0x405A10, &CTreadable_::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/entities/Treadable.h b/src/entities/Treadable.h index 2194638d..d82ff52b 100644 --- a/src/entities/Treadable.h +++ b/src/entities/Treadable.h @@ -11,7 +11,6 @@ public: int16 m_nodeIndicesCars[12]; int16 m_nodeIndicesPeds[12]; - virtual bool GetIsATreadable(void) { return true; } - void dtor(void) { this->CTreadable::~CTreadable(); } + bool GetIsATreadable(void) { return true; } }; static_assert(sizeof(CTreadable) == 0x94, "CTreadable: error"); diff --git a/src/modelinfo/BaseModelInfo.cpp b/src/modelinfo/BaseModelInfo.cpp index 37f94c93..830ead51 100644 --- a/src/modelinfo/BaseModelInfo.cpp +++ b/src/modelinfo/BaseModelInfo.cpp @@ -101,9 +101,15 @@ CBaseModelInfo::Get2dEffect(int n) } +class CBaseModelInfo_ : public CBaseModelInfo +{ +public: + void Shutdown_(void) { CBaseModelInfo::Shutdown(); } +}; STARTPATCHES // can't easily replace ctor at 4F6A50 - InjectHook(0x4F6A90, &CBaseModelInfo::Shutdown_, PATCH_JUMP); + InjectHook(0x4F6A90, &CBaseModelInfo_::Shutdown_, PATCH_JUMP); + InjectHook(0x4F6AC0, &CBaseModelInfo::DeleteCollisionModel, PATCH_JUMP); InjectHook(0x4F6B70, &CBaseModelInfo::ClearTexDictionary, PATCH_JUMP); InjectHook(0x4F6BA0, &CBaseModelInfo::AddRef, PATCH_JUMP); diff --git a/src/modelinfo/BaseModelInfo.h b/src/modelinfo/BaseModelInfo.h index da72990f..a9bafb64 100644 --- a/src/modelinfo/BaseModelInfo.h +++ b/src/modelinfo/BaseModelInfo.h @@ -62,8 +62,6 @@ public: void Init2dEffects(void); void Add2dEffect(C2dEffect *fx); C2dEffect *Get2dEffect(int n); - - void Shutdown_(void) { this->CBaseModelInfo::Shutdown(); } }; static_assert(sizeof(CBaseModelInfo) == 0x30, "CBaseModelInfo: error"); diff --git a/src/modelinfo/ClumpModelInfo.cpp b/src/modelinfo/ClumpModelInfo.cpp index 24deed38..d666313b 100644 --- a/src/modelinfo/ClumpModelInfo.cpp +++ b/src/modelinfo/ClumpModelInfo.cpp @@ -139,12 +139,22 @@ CClumpModelInfo::GetFrameFromId(RpClump *clump, int32 id) } +class CClumpModelInfo_ : public CClumpModelInfo +{ +public: + void DeleteRwObject_(void) { this->CClumpModelInfo::DeleteRwObject(); } + RwObject *CreateInstance_1(void) { return CClumpModelInfo::CreateInstance(); } + RwObject *CreateInstance_2(RwMatrix *m) { return CClumpModelInfo::CreateInstance(m); } + RwObject *GetRwObject_(void) { return CClumpModelInfo::GetRwObject(); } + void SetClump_(RpClump *clump) { CClumpModelInfo::SetClump(clump); } +}; + STARTPATCHES - InjectHook(0x4F8800, &CClumpModelInfo::DeleteRwObject_, PATCH_JUMP); - InjectHook(0x4F8920, &CClumpModelInfo::CreateInstance_1, PATCH_JUMP); - InjectHook(0x4F88A0, &CClumpModelInfo::CreateInstance_2, PATCH_JUMP); - InjectHook(0x50C1C0, &CClumpModelInfo::GetRwObject_, PATCH_JUMP); - InjectHook(0x4F8830, &CClumpModelInfo::SetClump_, PATCH_JUMP); + InjectHook(0x4F8800, &CClumpModelInfo_::DeleteRwObject_, PATCH_JUMP); + InjectHook(0x4F8920, &CClumpModelInfo_::CreateInstance_1, PATCH_JUMP); + InjectHook(0x4F88A0, &CClumpModelInfo_::CreateInstance_2, PATCH_JUMP); + InjectHook(0x50C1C0, &CClumpModelInfo_::GetRwObject_, PATCH_JUMP); + InjectHook(0x4F8830, &CClumpModelInfo_::SetClump_, PATCH_JUMP); InjectHook(0x4F8940, &CClumpModelInfo::SetAtomicRendererCB, PATCH_JUMP); InjectHook(0x4F8960, &CClumpModelInfo::FindFrameFromNameCB, PATCH_JUMP); InjectHook(0x4F8A10, &CClumpModelInfo::FindFrameFromNameWithoutIdCB, PATCH_JUMP); diff --git a/src/modelinfo/ClumpModelInfo.h b/src/modelinfo/ClumpModelInfo.h index 909d241b..d491bdb9 100644 --- a/src/modelinfo/ClumpModelInfo.h +++ b/src/modelinfo/ClumpModelInfo.h @@ -49,12 +49,5 @@ public: static void FillFrameArray(RpClump *clump, RwFrame **frames); static RwFrame *FillFrameArrayCB(RwFrame *frame, void *data); static RwFrame *GetFrameFromId(RpClump *clump, int32 id); - - - void DeleteRwObject_(void) { this->CClumpModelInfo::DeleteRwObject(); } - RwObject *CreateInstance_1(void) { return this->CClumpModelInfo::CreateInstance(); } - RwObject *CreateInstance_2(RwMatrix *m) { return this->CClumpModelInfo::CreateInstance(m); } - RwObject *GetRwObject_(void) { return this->CClumpModelInfo::GetRwObject(); } - void SetClump_(RpClump *clump) { this->CClumpModelInfo::SetClump(clump); } }; static_assert(sizeof(CClumpModelInfo) == 0x34, "CClumpModelInfo: error"); diff --git a/src/modelinfo/MloInstance.cpp b/src/modelinfo/MloInstance.cpp deleted file mode 100644 index dbd83727..00000000 --- a/src/modelinfo/MloInstance.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "common.h" -#include "patcher.h" -#include "MloInstance.h" - -STARTPATCHES -InjectHook(0x50BE90, &CMloInstance::dtor, PATCH_JUMP); -ENDPATCHES
\ No newline at end of file diff --git a/src/modelinfo/MloInstance.h b/src/modelinfo/MloInstance.h deleted file mode 100644 index 00afc379..00000000 --- a/src/modelinfo/MloInstance.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include "Placeable.h" - -class CMloInstance : CPlaceable -{ -public: - void dtor() { this->CMloInstance::~CMloInstance(); } -};
\ No newline at end of file diff --git a/src/modelinfo/PedModelInfo.cpp b/src/modelinfo/PedModelInfo.cpp index 775148c9..747cbc99 100644 --- a/src/modelinfo/PedModelInfo.cpp +++ b/src/modelinfo/PedModelInfo.cpp @@ -189,9 +189,17 @@ CPedModelInfo::CreateHitColModel(void) m_hitColModel = colmodel; } + +class CPedModelInfo_ : public CPedModelInfo +{ +public: + void DeleteRwObject_(void) { CPedModelInfo::DeleteRwObject(); } + void SetClump_(RpClump *clump) { CPedModelInfo::SetClump(clump); } +}; + STARTPATCHES - InjectHook(0x510210, &CPedModelInfo::SetClump_, PATCH_JUMP); - InjectHook(0x510280, &CPedModelInfo::DeleteRwObject_, PATCH_JUMP); + InjectHook(0x510210, &CPedModelInfo_::SetClump_, PATCH_JUMP); + InjectHook(0x510280, &CPedModelInfo_::DeleteRwObject_, PATCH_JUMP); InjectHook(0x510390, &CPedModelInfo::SetLowDetailClump, PATCH_JUMP); InjectHook(0x5104D0, &CPedModelInfo::CreateHitColModel, PATCH_JUMP); ENDPATCHES diff --git a/src/modelinfo/PedModelInfo.h b/src/modelinfo/PedModelInfo.h index 7be2c195..bec46b4e 100644 --- a/src/modelinfo/PedModelInfo.h +++ b/src/modelinfo/PedModelInfo.h @@ -39,9 +39,5 @@ public: void SetLowDetailClump(RpClump*); void CreateHitColModel(void); CColModel *GetHitColModel(void) { return m_hitColModel; } - - - void DeleteRwObject_(void) { this->CPedModelInfo::DeleteRwObject(); } - void SetClump_(RpClump *clump) { this->CPedModelInfo::SetClump(clump); } }; static_assert(sizeof(CPedModelInfo) == 0x54, "CPedModelInfo: error"); diff --git a/src/modelinfo/SimpleModelInfo.cpp b/src/modelinfo/SimpleModelInfo.cpp index ea7a3f9e..dd5010fa 100644 --- a/src/modelinfo/SimpleModelInfo.cpp +++ b/src/modelinfo/SimpleModelInfo.cpp @@ -154,12 +154,20 @@ CSimpleModelInfo::SetupBigBuilding(void) } } +class CSimpleModelInfo_ : public CSimpleModelInfo +{ +public: + void DeleteRwObject_(void) { CSimpleModelInfo::DeleteRwObject(); } + RwObject *CreateInstance_1(void) { return CSimpleModelInfo::CreateInstance(); } + RwObject *CreateInstance_2(RwMatrix *m) { return CSimpleModelInfo::CreateInstance(m); } + RwObject *GetRwObject_(void) { return CSimpleModelInfo::GetRwObject(); } +}; STARTPATCHES - InjectHook(0x5179B0, &CSimpleModelInfo::DeleteRwObject_, PATCH_JUMP); - InjectHook(0x517B60, &CSimpleModelInfo::CreateInstance_1, PATCH_JUMP); - InjectHook(0x517AC0, &CSimpleModelInfo::CreateInstance_2, PATCH_JUMP); - InjectHook(0x4A9BA0, &CSimpleModelInfo::GetRwObject_, PATCH_JUMP); + InjectHook(0x5179B0, &CSimpleModelInfo_::DeleteRwObject_, PATCH_JUMP); + InjectHook(0x517B60, &CSimpleModelInfo_::CreateInstance_1, PATCH_JUMP); + InjectHook(0x517AC0, &CSimpleModelInfo_::CreateInstance_2, PATCH_JUMP); + InjectHook(0x4A9BA0, &CSimpleModelInfo_::GetRwObject_, PATCH_JUMP); InjectHook(0x517990, &CSimpleModelInfo::Init, PATCH_JUMP); InjectHook(0x517C60, &CSimpleModelInfo::IncreaseAlpha, PATCH_JUMP); InjectHook(0x517950, &CSimpleModelInfo::SetAtomic, PATCH_JUMP); diff --git a/src/modelinfo/SimpleModelInfo.h b/src/modelinfo/SimpleModelInfo.h index d5b572a6..35d48669 100644 --- a/src/modelinfo/SimpleModelInfo.h +++ b/src/modelinfo/SimpleModelInfo.h @@ -48,10 +48,5 @@ public: return (CSimpleModelInfo*)m_atomics[2]; } void SetRelatedModel(CSimpleModelInfo *m){ m_atomics[2] = (RpAtomic*)m; } - - void DeleteRwObject_(void) { this->CSimpleModelInfo::DeleteRwObject(); } - RwObject *CreateInstance_1(void) { return this->CSimpleModelInfo::CreateInstance(); } - RwObject *CreateInstance_2(RwMatrix *m) { return this->CSimpleModelInfo::CreateInstance(m); } - RwObject *GetRwObject_(void) { return this->CSimpleModelInfo::GetRwObject(); } }; static_assert(sizeof(CSimpleModelInfo) == 0x4C, "CSimpleModelInfo: error"); diff --git a/src/modelinfo/VehicleModelInfo.cpp b/src/modelinfo/VehicleModelInfo.cpp index f112d546..810ed042 100644 --- a/src/modelinfo/VehicleModelInfo.cpp +++ b/src/modelinfo/VehicleModelInfo.cpp @@ -1098,10 +1098,18 @@ CVehicleModelInfo::GetMaximumNumberOfPassengersFromNumberOfDoors(int id) return n - 1; } +class CVehicleModelInfo_ : public CVehicleModelInfo +{ +public: + void DeleteRwObject_(void) { CVehicleModelInfo::DeleteRwObject(); } + RwObject *CreateInstance_(void) { return CVehicleModelInfo::CreateInstance(); } + void SetClump_(RpClump *clump) { CVehicleModelInfo::SetClump(clump); } +}; + STARTPATCHES - InjectHook(0x51FDC0, &CVehicleModelInfo::DeleteRwObject_, PATCH_JUMP); - InjectHook(0x51FCB0, &CVehicleModelInfo::CreateInstance_, PATCH_JUMP); - InjectHook(0x51FC60, &CVehicleModelInfo::SetClump_, PATCH_JUMP); + InjectHook(0x51FDC0, &CVehicleModelInfo_::DeleteRwObject_, PATCH_JUMP); + InjectHook(0x51FCB0, &CVehicleModelInfo_::CreateInstance_, PATCH_JUMP); + InjectHook(0x51FC60, &CVehicleModelInfo_::SetClump_, PATCH_JUMP); InjectHook(0x51FE10, &CVehicleModelInfo::CollapseFramesCB, PATCH_JUMP); InjectHook(0x51FE50, &CVehicleModelInfo::MoveObjectsCB, PATCH_JUMP); diff --git a/src/modelinfo/VehicleModelInfo.h b/src/modelinfo/VehicleModelInfo.h index 2e2f1be2..f66bc21f 100644 --- a/src/modelinfo/VehicleModelInfo.h +++ b/src/modelinfo/VehicleModelInfo.h @@ -10,6 +10,7 @@ enum { }; enum { + ATOMIC_FLAG_NONE = 0x0, ATOMIC_FLAG_OK = 0x1, ATOMIC_FLAG_DAM = 0x2, ATOMIC_FLAG_LEFT = 0x4, @@ -131,9 +132,5 @@ public: static void ShutdownEnvironmentMaps(void); static int GetMaximumNumberOfPassengersFromNumberOfDoors(int id); - - void DeleteRwObject_(void) { this->CVehicleModelInfo::DeleteRwObject(); } - RwObject *CreateInstance_(void) { return this->CVehicleModelInfo::CreateInstance(); } - void SetClump_(RpClump *clump) { this->CVehicleModelInfo::SetClump(clump); } }; static_assert(sizeof(CVehicleModelInfo) == 0x1F8, "CVehicleModelInfo: error"); diff --git a/src/objects/CutsceneHead.cpp b/src/objects/CutsceneHead.cpp index a9c47777..c423d0b8 100644 --- a/src/objects/CutsceneHead.cpp +++ b/src/objects/CutsceneHead.cpp @@ -109,10 +109,19 @@ CCutsceneHead::PlayAnimation(const char *animName) } } +class CCutsceneHead_ : public CCutsceneHead +{ +public: + void CreateRwObject_(void) { CCutsceneHead::CreateRwObject(); } + void DeleteRwObject_(void) { CCutsceneHead::DeleteRwObject(); } + void ProcessControl_(void) { CCutsceneHead::ProcessControl(); } + void Render_(void) { CCutsceneHead::Render(); } +}; + STARTPATCHES - InjectHook(0x4BA650, &CCutsceneHead::CreateRwObject_, PATCH_JUMP); - InjectHook(0x4BA690, &CCutsceneHead::DeleteRwObject_, PATCH_JUMP); - InjectHook(0x4BA760, &CCutsceneHead::ProcessControl_, PATCH_JUMP); - InjectHook(0x4BA800, &CCutsceneHead::Render_, PATCH_JUMP); + InjectHook(0x4BA650, &CCutsceneHead_::CreateRwObject_, PATCH_JUMP); + InjectHook(0x4BA690, &CCutsceneHead_::DeleteRwObject_, PATCH_JUMP); + InjectHook(0x4BA760, &CCutsceneHead_::ProcessControl_, PATCH_JUMP); + InjectHook(0x4BA800, &CCutsceneHead_::Render_, PATCH_JUMP); InjectHook(0x4BA6A0, &CCutsceneHead::PlayAnimation, PATCH_JUMP); ENDPATCHES diff --git a/src/objects/CutsceneHead.h b/src/objects/CutsceneHead.h index de4f011f..52b66ede 100644 --- a/src/objects/CutsceneHead.h +++ b/src/objects/CutsceneHead.h @@ -15,10 +15,5 @@ public: void Render(void); void PlayAnimation(const char *animName); - - void CreateRwObject_(void) { CCutsceneHead::CreateRwObject(); } - void DeleteRwObject_(void) { CCutsceneHead::DeleteRwObject(); } - void ProcessControl_(void) { CCutsceneHead::ProcessControl(); } - void Render_(void) { CCutsceneHead::Render(); } }; static_assert(sizeof(CCutsceneHead) == 0x19C, "CCutsceneHead: error"); diff --git a/src/objects/CutsceneObject.cpp b/src/objects/CutsceneObject.cpp index ede5be5b..2f667a5d 100644 --- a/src/objects/CutsceneObject.cpp +++ b/src/objects/CutsceneObject.cpp @@ -89,12 +89,24 @@ CCutsceneObject::RemoveLighting(bool reset) CRenderer::RemoveVehiclePedLights(this, reset); } +class CCutsceneObject_ : public CCutsceneObject +{ +public: + void dtor(void) { this->CCutsceneObject::~CCutsceneObject(); } + void SetModelIndex_(uint32 id) { CCutsceneObject::SetModelIndex(id); } + void ProcessControl_(void) { CCutsceneObject::ProcessControl(); } + void PreRender_(void) { CCutsceneObject::PreRender(); } + void Render_(void) { CCutsceneObject::Render(); } + bool SetupLighting_(void) { return CCutsceneObject::SetupLighting(); } + void RemoveLighting_(bool reset) { CCutsceneObject::RemoveLighting(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); - InjectHook(0x4BAAA0, &CCutsceneObject::Render_, PATCH_JUMP); - InjectHook(0x4A7E70, &CCutsceneObject::SetupLighting_, PATCH_JUMP); - InjectHook(0x4A7F00, &CCutsceneObject::RemoveLighting_, PATCH_JUMP); + InjectHook(0x4BA960, &CCutsceneObject_::dtor, PATCH_JUMP); + InjectHook(0x4BA980, &CCutsceneObject_::SetModelIndex_, PATCH_JUMP); + InjectHook(0x4BA9C0, &CCutsceneObject_::ProcessControl_, PATCH_JUMP); + InjectHook(0x4BAA40, &CCutsceneObject_::PreRender_, PATCH_JUMP); + InjectHook(0x4BAAA0, &CCutsceneObject_::Render_, PATCH_JUMP); + InjectHook(0x4A7E70, &CCutsceneObject_::SetupLighting_, PATCH_JUMP); + InjectHook(0x4A7F00, &CCutsceneObject_::RemoveLighting_, PATCH_JUMP); ENDPATCHES diff --git a/src/objects/CutsceneObject.h b/src/objects/CutsceneObject.h index 9360651e..31c3a528 100644 --- a/src/objects/CutsceneObject.h +++ b/src/objects/CutsceneObject.h @@ -7,19 +7,11 @@ class CCutsceneObject : public CObject public: CCutsceneObject(void); - virtual void SetModelIndex(uint32 id); - virtual void ProcessControl(void); - virtual void PreRender(void); - virtual void Render(void); - virtual bool SetupLighting(void); - virtual 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(); } - void Render_(void) { CCutsceneObject::Render(); } - bool SetupLighting_(void) { return CCutsceneObject::SetupLighting(); } - void RemoveLighting_(bool reset) { CCutsceneObject::RemoveLighting(reset); } + void SetModelIndex(uint32 id); + void ProcessControl(void); + void PreRender(void); + void Render(void); + bool SetupLighting(void); + void RemoveLighting(bool reset); }; static_assert(sizeof(CCutsceneObject) == 0x198, "CCutsceneObject: error"); diff --git a/src/objects/DummyObject.cpp b/src/objects/DummyObject.cpp index 1e4b2ae0..41b15129 100644 --- a/src/objects/DummyObject.cpp +++ b/src/objects/DummyObject.cpp @@ -12,6 +12,12 @@ CDummyObject::CDummyObject(CObject *obj) m_level = obj->m_level; } +class CDummyObject_ : public CDummyObject +{ +public: + void dtor(void) { CDummyObject::~CDummyObject(); } +}; + STARTPATCHES - InjectHook(0x4BAB70, &CDummyObject::dtor, PATCH_JUMP); -ENDPATCHES
\ No newline at end of file + InjectHook(0x4BAB70, &CDummyObject_::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/objects/DummyObject.h b/src/objects/DummyObject.h index 10554bdd..d4dce609 100644 --- a/src/objects/DummyObject.h +++ b/src/objects/DummyObject.h @@ -9,6 +9,5 @@ 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/objects/Object.cpp b/src/objects/Object.cpp index 6712d77b..e13a2ad0 100644 --- a/src/objects/Object.cpp +++ b/src/objects/Object.cpp @@ -87,7 +87,14 @@ CObject::RemoveLighting(bool reset) WRAPPER void CObject::DeleteAllTempObjectInArea(CVector, float) { EAXJMP(0x4BBED0); } +class CObject_ : public CObject +{ +public: + void dtor(void) { this->CObject::~CObject(); } + void Render_(void) { CObject::Render(); } +}; + STARTPATCHES - InjectHook(0x4BAE00, &CObject::dtor, PATCH_JUMP); - InjectHook(0x4BB1E0, &CObject::Render_, PATCH_JUMP); + InjectHook(0x4BAE00, &CObject_::dtor, PATCH_JUMP); + InjectHook(0x4BB1E0, &CObject_::Render_, PATCH_JUMP); ENDPATCHES diff --git a/src/objects/Object.h b/src/objects/Object.h index de4c8e05..8afc4d0a 100644 --- a/src/objects/Object.h +++ b/src/objects/Object.h @@ -74,8 +74,5 @@ public: void ObjectDamage(float amount); 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/objects/ParticleObject.cpp b/src/objects/ParticleObject.cpp index cf6e84bf..25f223e1 100644 --- a/src/objects/ParticleObject.cpp +++ b/src/objects/ParticleObject.cpp @@ -18,6 +18,12 @@ void CParticleObject::UpdateAll() ((void (__cdecl *)())0x4BCA30)(); } +class CParticleObject_ : public CParticleObject +{ +public: + void dtor() { CParticleObject::~CParticleObject(); } +}; + STARTPATCHES - InjectHook(0x4BC420, &CParticleObject::dtor, PATCH_JUMP); -ENDPATCHES
\ No newline at end of file + InjectHook(0x4BC420, &CParticleObject_::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/objects/ParticleObject.h b/src/objects/ParticleObject.h index def7b7de..6ec090e7 100644 --- a/src/objects/ParticleObject.h +++ b/src/objects/ParticleObject.h @@ -34,6 +34,4 @@ public: static void AddObject(uint16 type, const CVector &pos, const CVector &dir, float size, bool remove); static void Initialise(); static void UpdateAll(); - - void dtor() { this->CParticleObject::~CParticleObject(); } }; diff --git a/src/objects/Projectile.cpp b/src/objects/Projectile.cpp index e21323de..c6c2d6e1 100644 --- a/src/objects/Projectile.cpp +++ b/src/objects/Projectile.cpp @@ -2,6 +2,12 @@ #include "patcher.h" #include "Projectile.h" +class CProjectile_ : public CProjectile +{ +public: + void dtor(void) { CProjectile::~CProjectile(); } +}; + STARTPATCHES - InjectHook(0x4BFED0, &CProjectile::dtor, PATCH_JUMP); -ENDPATCHES
\ No newline at end of file + InjectHook(0x4BFED0, &CProjectile_::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/objects/Projectile.h b/src/objects/Projectile.h index a8e826b6..4d5041f8 100644 --- a/src/objects/Projectile.h +++ b/src/objects/Projectile.h @@ -7,5 +7,4 @@ class CProjectile : public CObject { public: - void dtor(void) { this->CProjectile::~CProjectile(); } }; diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp index a4881e71..cf8a0580 100644 --- a/src/peds/CivilianPed.cpp +++ b/src/peds/CivilianPed.cpp @@ -13,7 +13,14 @@ CCivilianPed::CCivilianPed(int pedtype, int mi) : CPed(pedtype) } } +class CCivilianPed_ : public CCivilianPed +{ +public: + CCivilianPed *ctor(int pedtype, int mi) { return ::new (this) CCivilianPed(pedtype, mi); }; + void dtor(void) { CCivilianPed::~CCivilianPed(); } +}; + STARTPATCHES - InjectHook(0x4BFF30, &CCivilianPed::ctor, PATCH_JUMP); - InjectHook(0x4BFFC0, &CCivilianPed::dtor, PATCH_JUMP); -ENDPATCHES
\ No newline at end of file + InjectHook(0x4BFF30, &CCivilianPed_::ctor, PATCH_JUMP); + InjectHook(0x4BFFC0, &CCivilianPed_::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/peds/CivilianPed.h b/src/peds/CivilianPed.h index 8d004ad7..14859a5c 100644 --- a/src/peds/CivilianPed.h +++ b/src/peds/CivilianPed.h @@ -6,11 +6,8 @@ class CCivilianPed : public CPed { public: CCivilianPed(int, int); - virtual ~CCivilianPed(void) { } + ~CCivilianPed(void) { } - virtual void ProcessControl(void); - - CCivilianPed *ctor(int pedtype, int mi) { return ::new (this) CCivilianPed(pedtype, mi); }; - void dtor(void) { this->CCivilianPed::~CCivilianPed(); } + void ProcessControl(void); }; static_assert(sizeof(CCivilianPed) == 0x53C, "CCivilianPed: error"); diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp index 041185ee..0ac0473f 100644 --- a/src/peds/CopPed.cpp +++ b/src/peds/CopPed.cpp @@ -9,6 +9,12 @@ CCopPed::~CCopPed() WRAPPER void CCopPed::ClearPursuit(void) { EAXJMP(0x4C28C0); } +class CCopPed_ : public CCopPed +{ +public: + void dtor(void) { CCopPed::~CCopPed(); } +}; + STARTPATCHES - InjectHook(0x4C13E0, &CCopPed::dtor, PATCH_JUMP); -ENDPATCHES
\ No newline at end of file + InjectHook(0x4C13E0, &CCopPed_::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/peds/CopPed.h b/src/peds/CopPed.h index b938dfc2..5827f9bc 100644 --- a/src/peds/CopPed.h +++ b/src/peds/CopPed.h @@ -65,7 +65,6 @@ public: int8 field_1367; ~CCopPed(); - void dtor(void) { this->CCopPed::~CCopPed(); } void ClearPursuit(void); }; diff --git a/src/peds/EmergencyPed.cpp b/src/peds/EmergencyPed.cpp index 7b847896..664bd6f6 100644 --- a/src/peds/EmergencyPed.cpp +++ b/src/peds/EmergencyPed.cpp @@ -2,6 +2,12 @@ #include "patcher.h" #include "EmergencyPed.h" +class CEmergencyPed_ : public CEmergencyPed +{ +public: + void dtor(void) { CEmergencyPed::~CEmergencyPed(); } +}; + STARTPATCHES -InjectHook(0x4C2EF0, &CEmergencyPed::dtor, PATCH_JUMP); -ENDPATCHES
\ No newline at end of file + InjectHook(0x4C2EF0, &CEmergencyPed_::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/peds/EmergencyPed.h b/src/peds/EmergencyPed.h index fa07f3ee..f21996e8 100644 --- a/src/peds/EmergencyPed.h +++ b/src/peds/EmergencyPed.h @@ -7,7 +7,5 @@ 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/peds/Ped.cpp b/src/peds/Ped.cpp index 016fea2f..20f26688 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -2893,9 +2893,28 @@ WRAPPER void CPed::PedLandCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0 WRAPPER void FinishFuckUCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4C6580); } WRAPPER void CPed::RestoreHeadingRateCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4D6550); } +class CPed_ : public CPed +{ +public: + CPed* ctor(uint32 pedType) { return ::new (this) CPed(pedType); } + void dtor(void) { CPed::~CPed(); } + + void SetModelIndex_(uint32 mi) { CPed::SetModelIndex(mi); } + void FlagToDestroyWhenNextProcessed_(void) { CPed::FlagToDestroyWhenNextProcessed(); } + bool SetupLighting_(void) { return CPed::SetupLighting(); } + void RemoveLighting_(bool reset) { CPed::RemoveLighting(reset); } + void Teleport_(CVector pos) { CPed::Teleport(pos); } +}; + STARTPATCHES - InjectHook(0x4C41C0, &CPed::ctor, PATCH_JUMP); - InjectHook(0x4C50D0, &CPed::dtor, PATCH_JUMP); + InjectHook(0x4C41C0, &CPed_::ctor, PATCH_JUMP); + InjectHook(0x4C50D0, &CPed_::dtor, PATCH_JUMP); + InjectHook(0x4C52A0, &CPed_::SetModelIndex_, PATCH_JUMP); + InjectHook(0x4D6570, &CPed_::FlagToDestroyWhenNextProcessed_, PATCH_JUMP); + InjectHook(0x4A7D30, &CPed_::SetupLighting_, PATCH_JUMP); + InjectHook(0x4A7DC0, &CPed_::RemoveLighting_, PATCH_JUMP); + InjectHook(0x4D3E70, &CPed_::Teleport_, PATCH_JUMP); + InjectHook(0x4CF8F0, &CPed::AddWeaponModel, PATCH_JUMP); InjectHook(0x4C6AA0, &CPed::AimGun, PATCH_JUMP); InjectHook(0x4EB470, &CPed::ApplyHeadShot, PATCH_JUMP); @@ -2926,11 +2945,6 @@ STARTPATCHES InjectHook(0x4CC6C0, &CPed::PlayFootSteps, PATCH_JUMP); InjectHook(0x4C5350, &CPed::BuildPedLists, PATCH_JUMP); InjectHook(0x4CF9B0, &CPed::GiveWeapon, PATCH_JUMP); - InjectHook(0x4C52A0, &CPed::SetModelIndex_, PATCH_JUMP); - InjectHook(0x4D6570, &CPed::FlagToDestroyWhenNextProcessed_, PATCH_JUMP); - InjectHook(0x4A7D30, &CPed::SetupLighting_, PATCH_JUMP); - InjectHook(0x4A7DC0, &CPed::RemoveLighting_, PATCH_JUMP); - InjectHook(0x4D3E70, &CPed::Teleport_, PATCH_JUMP); InjectHook(0x4C7EA0, &CPed::CalculateNewOrientation, PATCH_JUMP); InjectHook(0x4C78F0, &CPed::WorkOutHeadingForMovingFirstPerson, PATCH_JUMP); InjectHook(0x4C73F0, &CPed::CalculateNewVelocity, PATCH_JUMP); diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 0493eeee..6b04404b 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -399,21 +399,19 @@ public: static void operator delete(void*, int); CPed(uint32 pedType); - virtual ~CPed(void); - - virtual void SetModelIndex(uint32 mi); - virtual void ProcessControl(void); - virtual void Teleport(CVector); - virtual void PreRender(void); - virtual void Render(void); - virtual bool SetupLighting(void); - virtual void RemoveLighting(bool); - virtual void FlagToDestroyWhenNextProcessed(void); - virtual int32 ProcessEntityCollision(CEntity*, CColPoint*); - virtual void SetMoveAnim(void); + ~CPed(void); + + void SetModelIndex(uint32 mi); + void ProcessControl(void); + void Teleport(CVector); + void PreRender(void); + void Render(void); + bool SetupLighting(void); + void RemoveLighting(bool); + void FlagToDestroyWhenNextProcessed(void); + int32 ProcessEntityCollision(CEntity*, CColPoint*); - CPed* ctor(uint32 pedType) { return ::new (this) CPed(pedType); } - void dtor(void) { this->CPed::~CPed(); } + virtual void SetMoveAnim(void); void AddWeaponModel(int id); void AimGun(void); @@ -465,7 +463,7 @@ public: void RegisterThreatWithGangPeds(CEntity*); bool TurnBody(void); void Chat(void); - void MakeChangesForNewWeapon(int8); + void MakeChangesForNewWeapon(int8); // Static methods @@ -545,13 +543,6 @@ public: PedState GetPedState(void) { return m_nPedState; } void SetPedState(PedState state) { m_nPedState = state; } - // to make patching virtual functions possible - void SetModelIndex_(uint32 mi) { CPed::SetModelIndex(mi); } - void FlagToDestroyWhenNextProcessed_(void) { CPed::FlagToDestroyWhenNextProcessed(); } - bool SetupLighting_(void) { return CPed::SetupLighting(); } - void RemoveLighting_(bool reset) { CPed::RemoveLighting(reset); } - void Teleport_(CVector pos) { CPed::Teleport(pos); } - // set by 0482:set_threat_reaction_range_multiplier opcode static uint16 &distanceMultToCountPedNear; diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 7eb01db0..07cb5541 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -21,8 +21,13 @@ void CPlayerPed::ClearWeaponTarget() ClearPointGunAt(); } -STARTPATCHES -InjectHook(0x4EFB30, &CPlayerPed::dtor, PATCH_JUMP); -InjectHook(0x4F28A0, &CPlayerPed::ClearWeaponTarget, PATCH_JUMP); +class CPlayerPed_ : public CPlayerPed +{ +public: + void dtor(void) { CPlayerPed::~CPlayerPed(); } +}; -ENDPATCHES
\ No newline at end of file +STARTPATCHES + InjectHook(0x4EFB30, &CPlayerPed_::dtor, PATCH_JUMP); + InjectHook(0x4F28A0, &CPlayerPed::ClearWeaponTarget, PATCH_JUMP); +ENDPATCHES diff --git a/src/peds/PlayerPed.h b/src/peds/PlayerPed.h index 4f325da3..1a106b38 100644 --- a/src/peds/PlayerPed.h +++ b/src/peds/PlayerPed.h @@ -41,7 +41,6 @@ public: ~CPlayerPed(); - void dtor(void) { this->CPlayerPed::~CPlayerPed(); } void ReApplyMoveAnims(void); void ClearWeaponTarget(); }; diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp index f825ba42..5a377214 100644 --- a/src/render/Draw.cpp +++ b/src/render/Draw.cpp @@ -29,6 +29,7 @@ CDraw::FindAspectRatio(void) switch (FrontEndMenuManager.m_PrefsUseWideScreen) { case AR_AUTO: return SCREEN_WIDTH / SCREEN_HEIGHT; + default: case AR_4_3: return 4.0f / 3.0f; case AR_16_9: diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 80131179..23fa8ba0 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -1,18 +1,316 @@ #include "common.h" #include "patcher.h" +#include "VisibilityPlugins.h" +#include "HandlingMgr.h" #include "Automobile.h" +bool &CAutomobile::m_sAllTaxiLights = *(bool*)0x95CD21; + +WRAPPER CAutomobile* CAutomobile::ctor(int, uint8) { EAXJMP(0x52C6B0); } + 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); } -WRAPPER void CAutomobile::SetPanelDamage(int32, uint32, bool) { EAXJMP(0x5301A0); } -WRAPPER void CAutomobile::SetBumperDamage(int32, uint32, bool) { EAXJMP(0x530120); } +void +CAutomobile::SetModelIndex(uint32 id) +{ + CVehicle::SetModelIndex(id); + SetupModelNodes(); +} + +WRAPPER void CAutomobile::ProcessControl(void) { EAXJMP(0x531470); } +WRAPPER void CAutomobile::Teleport(CVector v) { EAXJMP(0x535180); } +WRAPPER void CAutomobile::PreRender(void) { EAXJMP(0x535B40); } +WRAPPER void CAutomobile::Render(void) { EAXJMP(0x539EA0); } + + +WRAPPER void CAutomobile::ProcessControlInputs(uint8) { EAXJMP(0x53B660); } + +void +CAutomobile::GetComponentWorldPosition(int32 component, CVector &pos) +{ + if(m_aCarNodes[component] == nil){ + printf("CarNode missing: %d %d\n", GetModelIndex(), component); + return; + } + RwMatrix *ltm = RwFrameGetLTM(m_aCarNodes[component]); + pos = *RwMatrixGetPos(ltm); +} + +bool +CAutomobile::IsComponentPresent(int32 comp) +{ + return m_aCarNodes[comp] != nil; +} + +void +CAutomobile::SetComponentRotation(int32 component, CVector rotation) +{ + CMatrix mat(RwFrameGetMatrix(m_aCarNodes[component])); + CVector pos = *mat.GetPosition(); + // BUG: all these set the whole matrix + mat.SetRotateX(DEGTORAD(rotation.x)); + mat.SetRotateY(DEGTORAD(rotation.y)); + mat.SetRotateZ(DEGTORAD(rotation.z)); + *mat.GetPosition() += pos; + mat.UpdateRW(); +} + +WRAPPER void CAutomobile::OpenDoor(int32, eDoors door, float) { EAXJMP(0x52E750); } +WRAPPER void CAutomobile::ProcessOpenDoor(uint32, uint32, float) { EAXJMP(0x52E910); } + +bool +CAutomobile::IsDoorReady(eDoors door) +{ + if(Doors[door].IsClosed() || IsDoorMissing(door)) + return true; + int doorflag = 0; + // TODO: enum? + switch(door){ + case DOOR_FRONT_LEFT: doorflag = 1; break; + case DOOR_FRONT_RIGHT: doorflag = 4; break; + case DOOR_REAR_LEFT: doorflag = 2; break; + case DOOR_REAR_RIGHT: doorflag = 8; break; + } + return (doorflag & m_nGettingInFlags) == 0; +} + +bool +CAutomobile::IsDoorFullyOpen(eDoors door) +{ + return Doors[door].IsFullyOpen() || IsDoorMissing(door); +} + +bool +CAutomobile::IsDoorClosed(eDoors door) +{ + return !!Doors[door].IsClosed(); +} + +bool +CAutomobile::IsDoorMissing(eDoors door) +{ + return Damage.GetDoorStatus(door) == DOOR_STATUS_MISSING; +} + +void +CAutomobile::RemoveRefsToVehicle(CEntity *ent) +{ + int i; + for(i = 0; i < 4; i++) + if(m_aGroundPhysical[i] == ent) + m_aGroundPhysical[i] = nil; +} + +WRAPPER void CAutomobile::BlowUpCar(CEntity *ent) { EAXJMP(0x53BC60); } +WRAPPER bool CAutomobile::SetUpWheelColModel(CColModel *colModel) { EAXJMP(0x53BF70); } +WRAPPER void CAutomobile::BurstTyre(uint8 tyre) { EAXJMP(0x53C0E0); } +WRAPPER bool CAutomobile::IsRoomForPedToLeaveCar(uint32, CVector *) { EAXJMP(0x53C5B0); } + +float +CAutomobile::GetHeightAboveRoad(void) +{ + return m_fHeightAboveRoad; +} + +WRAPPER void CAutomobile::PlayCarHorn(void) { EAXJMP(0x53C450); } + + + + + +WRAPPER void CAutomobile::SpawnFlyingComponent(int32 component, uint32 type) { EAXJMP(0x530300); } + +void +CAutomobile::SetPanelDamage(int32 component, ePanels panel, bool noFlyingComponents) +{ + int status = Damage.GetPanelStatus(panel); + if(m_aCarNodes[component] == nil) + return; + if(status == PANEL_STATUS_SMASHED1){ + // show damaged part + SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_DAM); + }else if(status == PANEL_STATUS_MISSING){ + if(!noFlyingComponents) + SpawnFlyingComponent(component, COMPGROUP_PANEL); + // hide both + SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_NONE); + } +} + +void +CAutomobile::SetBumperDamage(int32 component, ePanels panel, bool noFlyingComponents) +{ + int status = Damage.GetPanelStatus(panel); + if(m_aCarNodes[component] == nil){ + printf("Trying to damage component %d of %s\n", + component, CModelInfo::GetModelInfo(GetModelIndex())->GetName()); + return; + } + if(status == PANEL_STATUS_SMASHED1){ + // show damaged part + SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_DAM); + }else if(status == PANEL_STATUS_MISSING){ + if(!noFlyingComponents) + SpawnFlyingComponent(component, COMPGROUP_BUMPER); + // hide both + SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_NONE); + } +} + +void +CAutomobile::SetDoorDamage(int32 component, eDoors door, bool noFlyingComponents) +{ + int status = Damage.GetDoorStatus(door); + if(m_aCarNodes[component] == nil){ + printf("Trying to damage component %d of %s\n", + component, CModelInfo::GetModelInfo(GetModelIndex())->GetName()); + return; + } + + if(door == DOOR_BOOT && status == DOOR_STATUS_SWINGING && m_handling->Flags & HANDLING_NOSWING_BOOT){ + Damage.SetDoorStatus(DOOR_BOOT, DOOR_STATUS_MISSING); + status = DOOR_STATUS_MISSING; + } + + if(status == DOOR_STATUS_SMASHED){ + // show damaged part + SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_DAM); + }else if(status == DOOR_STATUS_SWINGING){ + // turn off angle cull for swinging doors + RwFrameForAllObjects(m_aCarNodes[component], CVehicleModelInfo::SetAtomicFlagCB, (void*)ATOMIC_FLAG_NOCULL); + }else if(status == DOOR_STATUS_MISSING){ + if(!noFlyingComponents){ + if(door == DOOR_BONNET) + SpawnFlyingComponent(component, COMPGROUP_BONNET); + else if(door == DOOR_BOOT) + SpawnFlyingComponent(component, COMPGROUP_BOOT); + else + SpawnFlyingComponent(component, COMPGROUP_DOOR); + } + // hide both + SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_NONE); + } +} + + +static RwObject* +SetVehicleAtomicVisibilityCB(RwObject *object, void *data) +{ + uint32 flags = (uint32)(uintptr)data; + RpAtomic *atomic = (RpAtomic*)object; + if((CVisibilityPlugins::GetAtomicId(atomic) & (ATOMIC_FLAG_OK|ATOMIC_FLAG_DAM)) == flags) + RpAtomicSetFlags(atomic, rpATOMICRENDER); + else + RpAtomicSetFlags(atomic, 0); + return object; +} + +void +CAutomobile::SetComponentVisibility(RwFrame *frame, uint32 flags) +{ + HideAllComps(); + m_veh_flagC2 = true; + RwFrameForAllObjects(frame, SetVehicleAtomicVisibilityCB, (void*)flags); +} + +void +CAutomobile::SetupModelNodes(void) +{ + int i; + for(i = 0; i < NUM_CAR_NODES; i++) + m_aCarNodes[i] = nil; + CClumpModelInfo::FillFrameArray((RpClump*)m_rwObject, m_aCarNodes); +} + +void +CAutomobile::SetTaxiLight(bool light) +{ + bTaxiLight = light; +} + +bool +CAutomobile::GetAllWheelsOffGround(void) +{ + return m_nWheelsOnGround == 0; +} + +void +CAutomobile::HideAllComps(void) +{ + // empty +} + +void +CAutomobile::ShowAllComps(void) +{ + // empty +} + +void +CAutomobile::ReduceHornCounter(void) +{ + if(m_nCarHornTimer != 0) + m_nCarHornTimer--; +} + +void +CAutomobile::SetAllTaxiLights(bool set) +{ + m_sAllTaxiLights = set; +} + +class CAutomobile_ : public CAutomobile +{ +public: + void dtor() { CAutomobile::~CAutomobile(); } + void SetModelIndex_(uint32 id) { CAutomobile::SetModelIndex(id); } + void ProcessControl_(void) { CAutomobile::ProcessControl(); } + void Teleport_(CVector v) { CAutomobile::Teleport(v); } + void PreRender_(void) { CAutomobile::PreRender(); } + void Render_(void) { CAutomobile::Render(); } + + void ProcessControlInputs_(uint8 x) { CAutomobile::ProcessControlInputs(x); } + void GetComponentWorldPosition_(int32 component, CVector &pos) { CAutomobile::GetComponentWorldPosition(component, pos); } + bool IsComponentPresent_(int32 component) { return CAutomobile::IsComponentPresent(component); } + void SetComponentRotation_(int32 component, CVector rotation) { CAutomobile::SetComponentRotation(component, rotation); } + void OpenDoor_(int32 component, eDoors door, float ratio) { CAutomobile::OpenDoor(component, door, ratio); } + void ProcessOpenDoor_(uint32 component, uint32 anim, float time) { CAutomobile::ProcessOpenDoor(component, anim, time); } + bool IsDoorReady_(eDoors door) { return CAutomobile::IsDoorReady(door); } + bool IsDoorFullyOpen_(eDoors door) { return CAutomobile::IsDoorFullyOpen(door); } + bool IsDoorClosed_(eDoors door) { return CAutomobile::IsDoorClosed(door); } + bool IsDoorMissing_(eDoors door) { return CAutomobile::IsDoorMissing(door); } + void RemoveRefsToVehicle_(CEntity *ent) { CAutomobile::RemoveRefsToVehicle(ent); } + void BlowUpCar_(CEntity *ent) { CAutomobile::BlowUpCar(ent); } + bool SetUpWheelColModel_(CColModel *colModel) { CAutomobile::SetUpWheelColModel(colModel); } + void BurstTyre_(uint8 tyre) { CAutomobile::BurstTyre(tyre); } + bool IsRoomForPedToLeaveCar_(uint32 door, CVector *pos) { return CAutomobile::IsRoomForPedToLeaveCar(door, pos); } + float GetHeightAboveRoad_(void) { return CAutomobile::GetHeightAboveRoad(); } + void PlayCarHorn_(void) { CAutomobile::PlayCarHorn(); } +}; STARTPATCHES - InjectHook(0x52D170, &CAutomobile::dtor, PATCH_JUMP); + InjectHook(0x52D170, &CAutomobile_::dtor, PATCH_JUMP); + InjectHook(0x52D190, &CAutomobile_::SetModelIndex_, PATCH_JUMP); + InjectHook(0x52E5F0, &CAutomobile_::GetComponentWorldPosition_, PATCH_JUMP); + InjectHook(0x52E660, &CAutomobile_::IsComponentPresent_, PATCH_JUMP); + InjectHook(0x52E680, &CAutomobile_::SetComponentRotation_, PATCH_JUMP); + InjectHook(0x52EF10, &CAutomobile_::IsDoorReady_, PATCH_JUMP); + InjectHook(0x52EF90, &CAutomobile_::IsDoorFullyOpen_, PATCH_JUMP); + InjectHook(0x52EFD0, &CAutomobile_::IsDoorClosed_, PATCH_JUMP); + InjectHook(0x52F000, &CAutomobile_::IsDoorMissing_, PATCH_JUMP); + InjectHook(0x53BF40, &CAutomobile_::RemoveRefsToVehicle_, PATCH_JUMP); + InjectHook(0x437690, &CAutomobile_::GetHeightAboveRoad_, PATCH_JUMP); + InjectHook(0x5301A0, &CAutomobile::SetPanelDamage, PATCH_JUMP); + InjectHook(0x530120, &CAutomobile::SetBumperDamage, PATCH_JUMP); + InjectHook(0x530200, &CAutomobile::SetDoorDamage, PATCH_JUMP); + InjectHook(0x5300E0, &CAutomobile::SetComponentVisibility, PATCH_JUMP); + InjectHook(0x52D1B0, &CAutomobile::SetupModelNodes, PATCH_JUMP); + InjectHook(0x53C420, &CAutomobile::SetTaxiLight, PATCH_JUMP); + InjectHook(0x53BC40, &CAutomobile::GetAllWheelsOffGround, PATCH_JUMP); + InjectHook(0x5308C0, &CAutomobile::ReduceHornCounter, PATCH_JUMP); + InjectHook(0x53C440, &CAutomobile::SetAllTaxiLights, PATCH_JUMP); ENDPATCHES diff --git a/src/vehicles/Automobile.h b/src/vehicles/Automobile.h index c20d078b..a9def14f 100644 --- a/src/vehicles/Automobile.h +++ b/src/vehicles/Automobile.h @@ -15,13 +15,22 @@ public: float m_aSuspensionSpringRatio[4]; float m_aSuspensionSpringRatioPrev[4]; float m_aWheelSkidThing[4]; - int field_49C; + float field_49C; bool m_aWheelSkidmarkMuddy[4]; bool m_aWheelSkidmarkBloody[4]; float m_aWheelRotation[4]; float m_aWheelPosition[4]; float m_aWheelSpeed[4]; - uint8 stuff3[12]; + uint8 field_4D8; + uint8 m_auto_flagA1 : 1; + uint8 m_auto_flagA2 : 1; + uint8 m_auto_flagA4 : 1; + uint8 bTaxiLight : 1; + uint8 m_auto_flagA10 : 1; + uint8 m_auto_flagA20 : 1; + uint8 m_auto_flagA40 : 1; + uint8 m_auto_flagA80 : 1; + uint8 field_4DA[10]; uint32 m_nBusDoorTimerEnd; uint32 m_nBusDoorTimerStart; float m_aSuspensionSpringLength[4]; @@ -44,11 +53,52 @@ public: uint8 stuff5[5]; int32 m_aWheelState[4]; + static bool &m_sAllTaxiLights; + CAutomobile(int, uint8); + + // from CEntity + void SetModelIndex(uint32 id); + void ProcessControl(void); + void Teleport(CVector v); + void PreRender(void); + void Render(void); + + // from CVehicle + void ProcessControlInputs(uint8); + void GetComponentWorldPosition(int32 component, CVector &pos); + bool IsComponentPresent(int32 component); + void SetComponentRotation(int32 component, CVector rotation); + void OpenDoor(int32, eDoors door, float); + void ProcessOpenDoor(uint32, uint32, float); + bool IsDoorReady(eDoors door); + bool IsDoorFullyOpen(eDoors door); + bool IsDoorClosed(eDoors door); + bool IsDoorMissing(eDoors door); + void RemoveRefsToVehicle(CEntity *ent); + void BlowUpCar(CEntity *ent); + bool SetUpWheelColModel(CColModel *colModel); + void BurstTyre(uint8 tyre); + bool IsRoomForPedToLeaveCar(uint32, CVector *); + float GetHeightAboveRoad(void); + void PlayCarHorn(void); + + void SpawnFlyingComponent(int32 component, uint32 type); + + void SetPanelDamage(int32 component, ePanels panel, bool noFlyingComponents); + void SetBumperDamage(int32 component, ePanels panel, bool noFlyingComponents); + void SetDoorDamage(int32 component, eDoors door, bool noFlyingComponents); + + void SetComponentVisibility(RwFrame *frame, uint32 flags); + void SetupModelNodes(void); + void SetTaxiLight(bool light); + bool GetAllWheelsOffGround(void); + void HideAllComps(void); + void ShowAllComps(void); + void ReduceHornCounter(void); + + static void SetAllTaxiLights(bool set); + CAutomobile* ctor(int, uint8); - void SetDoorDamage(int32, uint32, bool); /* TODO: eDoors */ - void SetPanelDamage(int32, uint32, bool); /* TODO: ePanels */ - void SetBumperDamage(int32, uint32, bool); /* TODO: ePanels */ - void dtor() { this->CAutomobile::~CAutomobile(); } }; static_assert(sizeof(CAutomobile) == 0x5A8, "CAutomobile: error"); diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index 076a910e..e46d7247 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -9,6 +9,12 @@ CBoat::CBoat(int mi, uint8 owner) WRAPPER CBoat* CBoat::ctor(int, uint8) { EAXJMP(0x53E3E0); } +class CBoat_ : public CBoat +{ +public: + void dtor() { CBoat::~CBoat(); }; +}; + STARTPATCHES -InjectHook(0x53E790, &CBoat::dtor, PATCH_JUMP); -ENDPATCHES
\ No newline at end of file + InjectHook(0x53E790, &CBoat_::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/vehicles/Boat.h b/src/vehicles/Boat.h index 6d6482a4..6d365395 100644 --- a/src/vehicles/Boat.h +++ b/src/vehicles/Boat.h @@ -12,6 +12,5 @@ public: CBoat(int, uint8); CBoat* ctor(int, uint8); - void dtor() { this->CBoat::~CBoat(); }; }; static_assert(sizeof(CBoat) == 0x484, "CBoat: error"); diff --git a/src/vehicles/DamageManager.cpp b/src/vehicles/DamageManager.cpp index 1a7f25ed..380537f2 100644 --- a/src/vehicles/DamageManager.cpp +++ b/src/vehicles/DamageManager.cpp @@ -1,6 +1,7 @@ #include "common.h" #include "patcher.h" #include "General.h" +#include "Vehicle.h" #include "DamageManager.h" diff --git a/src/vehicles/DamageManager.h b/src/vehicles/DamageManager.h index 1fdbc6b1..0914ded3 100644 --- a/src/vehicles/DamageManager.h +++ b/src/vehicles/DamageManager.h @@ -4,6 +4,22 @@ // TODO: move some of this into Vehicle.h +enum eDoorStatus +{ + DOOR_STATUS_OK, + DOOR_STATUS_SMASHED, + DOOR_STATUS_SWINGING, + DOOR_STATUS_MISSING +}; + +enum ePanelStatus +{ + PANEL_STATUS_OK, + PANEL_STATUS_SMASHED1, + PANEL_STATUS_SMASHED2, + PANEL_STATUS_MISSING, +}; + enum tComponent { COMPONENT_DEFAULT, @@ -37,23 +53,7 @@ enum tComponentGroup COMPGROUP_DEFAULT, }; -enum eLights -{ - VEHLIGHT_FRONT_LEFT, - VEHLIGHT_FRONT_RIGHT, - VEHLIGHT_REAR_LEFT, - VEHLIGHT_REAR_RIGHT, -}; - -enum { - VEHPANEL_FRONT_LEFT, - VEHPANEL_FRONT_RIGHT, - VEHPANEL_REAR_LEFT, - VEHPANEL_REAR_RIGHT, - VEHPANEL_WINDSCREEN, - VEHBUMPER_FRONT, - VEHBUMPER_REAR, -}; +enum eLights; class CDamageManager { diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp index 01ee5375..d43e8c19 100644 --- a/src/vehicles/Heli.cpp +++ b/src/vehicles/Heli.cpp @@ -10,6 +10,12 @@ CHeli::CHeli(int mi, uint8 owner) WRAPPER CHeli* CHeli::ctor(int, uint8) { EAXJMP(0x547220); } WRAPPER void CHeli::SpecialHeliPreRender(void) { EAXJMP(0x54AE10); } +class CHeli_ : public CHeli +{ +public: + void dtor(void) { CHeli::~CHeli(); } +}; + STARTPATCHES -InjectHook(0x5474A0, &CHeli::dtor, PATCH_JUMP); + InjectHook(0x5474A0, &CHeli_::dtor, PATCH_JUMP); ENDPATCHES diff --git a/src/vehicles/Heli.h b/src/vehicles/Heli.h index da7bb171..db873ae2 100644 --- a/src/vehicles/Heli.h +++ b/src/vehicles/Heli.h @@ -10,7 +10,6 @@ public: CHeli(int, uint8); CHeli* ctor(int, uint8); - void dtor(void) { this->CHeli::~CHeli(); } static void SpecialHeliPreRender(void); }; diff --git a/src/vehicles/Plane.cpp b/src/vehicles/Plane.cpp index 6e30bced..3bad1e07 100644 --- a/src/vehicles/Plane.cpp +++ b/src/vehicles/Plane.cpp @@ -14,6 +14,12 @@ CPlane::~CPlane() DeleteRwObject(); } +class CPlane_ : public CPlane +{ +public: + void dtor(void) { CPlane::~CPlane(); } +}; + STARTPATCHES -InjectHook(0x54B270, &CPlane::dtor, PATCH_JUMP); -ENDPATCHES
\ No newline at end of file + InjectHook(0x54B270, &CPlane_::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/vehicles/Plane.h b/src/vehicles/Plane.h index e26008f6..1f54e529 100644 --- a/src/vehicles/Plane.h +++ b/src/vehicles/Plane.h @@ -12,7 +12,6 @@ public: 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/vehicles/Train.cpp b/src/vehicles/Train.cpp index 62fd53ec..b7fd6ca1 100644 --- a/src/vehicles/Train.cpp +++ b/src/vehicles/Train.cpp @@ -9,6 +9,12 @@ CTrain::CTrain(int mi, uint8 owner) WRAPPER CTrain* CTrain::ctor(int, uint8) { EAXJMP(0x54E2A0); } +class CTrain_ : public CTrain +{ +public: + void dtor(void) { CTrain::~CTrain(); } +}; + STARTPATCHES -InjectHook(0x54E450, &CTrain::dtor, PATCH_JUMP); -ENDPATCHES
\ No newline at end of file + InjectHook(0x54E450, &CTrain_::dtor, PATCH_JUMP); +ENDPATCHES diff --git a/src/vehicles/Train.h b/src/vehicles/Train.h index 84b6faf5..5e1e2e35 100644 --- a/src/vehicles/Train.h +++ b/src/vehicles/Train.h @@ -21,6 +21,5 @@ public: CTrain(int, uint8); CTrain* ctor(int, uint8); - void dtor(void) { this->CTrain::~CTrain(); } }; static_assert(sizeof(CTrain) == 0x2E4, "CTrain: error"); diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index dccd9195..1a22e98a 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -460,11 +460,22 @@ CVehicle::IsSphereTouchingVehicle(float sx, float sy, float sz, float radius) return true; } + +class CVehicle_ : public CVehicle +{ +public: + void dtor(void) { CVehicle::~CVehicle(); } + void SetModelIndex_(uint32 id) { CVehicle::SetModelIndex(id); } + bool SetupLighting_(void) { return CVehicle::SetupLighting(); } + void RemoveLighting_(bool reset) { CVehicle::RemoveLighting(reset); } + float GetHeightAboveRoad_(void) { return CVehicle::GetHeightAboveRoad(); } +}; + STARTPATCHES - InjectHook(0x551170, &CVehicle::SetModelIndex_, PATCH_JUMP); - InjectHook(0x4A7DD0, &CVehicle::SetupLighting_, PATCH_JUMP); - InjectHook(0x4A7E60, &CVehicle::RemoveLighting_, PATCH_JUMP); - InjectHook(0x417E60, &CVehicle::GetHeightAboveRoad_, PATCH_JUMP); + InjectHook(0x551170, &CVehicle_::SetModelIndex_, PATCH_JUMP); + InjectHook(0x4A7DD0, &CVehicle_::SetupLighting_, PATCH_JUMP); + InjectHook(0x4A7E60, &CVehicle_::RemoveLighting_, PATCH_JUMP); + InjectHook(0x417E60, &CVehicle_::GetHeightAboveRoad_, PATCH_JUMP); InjectHook(0x552880, &CVehicle::IsLawEnforcementVehicle, PATCH_JUMP); InjectHook(0x552820, &CVehicle::ChangeLawEnforcerState, PATCH_JUMP); diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h index 39a56fe0..0f9003db 100644 --- a/src/vehicles/Vehicle.h +++ b/src/vehicles/Vehicle.h @@ -69,6 +69,25 @@ enum eDoors DOOR_REAR_RIGHT }; +enum ePanels +{ + VEHPANEL_FRONT_LEFT, + VEHPANEL_FRONT_RIGHT, + VEHPANEL_REAR_LEFT, + VEHPANEL_REAR_RIGHT, + VEHPANEL_WINDSCREEN, + VEHBUMPER_FRONT, + VEHBUMPER_REAR, +}; + +enum eLights +{ + VEHLIGHT_FRONT_LEFT, + VEHLIGHT_FRONT_RIGHT, + VEHLIGHT_REAR_LEFT, + VEHLIGHT_REAR_RIGHT, +}; + class CVehicle : public CPhysical { public: @@ -115,7 +134,7 @@ public: uint8 m_veh_flagB80 : 1; uint8 m_veh_flagC1 : 1; - uint8 m_veh_flagC2 : 1; + uint8 m_veh_flagC2 : 1; // bIsDamaged uint8 m_veh_flagC4 : 1; uint8 m_veh_flagC8 : 1; uint8 m_veh_flagC10 : 1; @@ -169,7 +188,7 @@ public: ~CVehicle(void); // from CEntity - void SetModelIndex(uint32 i); + void SetModelIndex(uint32 id); bool SetupLighting(void); void RemoveLighting(bool); void FlagToDestroyWhenNextProcessed(void) {} @@ -225,13 +244,6 @@ public: static bool &bCheat4; static bool &bCheat5; static bool &m_bDisableMouseSteering; - - - void dtor(void) { CVehicle::~CVehicle(); } - void SetModelIndex_(uint32 id) { CVehicle::SetModelIndex(id); } - bool SetupLighting_(void) { return CVehicle::SetupLighting(); } - void RemoveLighting_(bool reset) { CVehicle::RemoveLighting(reset); } - float GetHeightAboveRoad_(void) { return CVehicle::GetHeightAboveRoad(); } }; static_assert(sizeof(CVehicle) == 0x288, "CVehicle: error"); |