summaryrefslogtreecommitdiffstats
path: root/src/vehicles
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-07-08 08:46:42 +0200
committeraap <aap@papnet.eu>2019-07-08 08:46:42 +0200
commit12af85ca3d29e155f40323ad07a77f96a4aececf (patch)
tree7a6d7c8ed51ec1c527903835bbe4ee39eef2ab8b /src/vehicles
parentMerge pull request #111 from gennariarmando/master (diff)
downloadre3-12af85ca3d29e155f40323ad07a77f96a4aececf.tar
re3-12af85ca3d29e155f40323ad07a77f96a4aececf.tar.gz
re3-12af85ca3d29e155f40323ad07a77f96a4aececf.tar.bz2
re3-12af85ca3d29e155f40323ad07a77f96a4aececf.tar.lz
re3-12af85ca3d29e155f40323ad07a77f96a4aececf.tar.xz
re3-12af85ca3d29e155f40323ad07a77f96a4aececf.tar.zst
re3-12af85ca3d29e155f40323ad07a77f96a4aececf.zip
Diffstat (limited to '')
-rw-r--r--src/vehicles/Automobile.cpp308
-rw-r--r--src/vehicles/Automobile.h62
-rw-r--r--src/vehicles/Boat.cpp10
-rw-r--r--src/vehicles/Boat.h1
-rw-r--r--src/vehicles/DamageManager.cpp1
-rw-r--r--src/vehicles/DamageManager.h34
-rw-r--r--src/vehicles/Heli.cpp8
-rw-r--r--src/vehicles/Heli.h1
-rw-r--r--src/vehicles/Plane.cpp10
-rw-r--r--src/vehicles/Plane.h1
-rw-r--r--src/vehicles/Train.cpp10
-rw-r--r--src/vehicles/Train.h1
-rw-r--r--src/vehicles/Vehicle.cpp19
-rw-r--r--src/vehicles/Vehicle.h30
14 files changed, 444 insertions, 52 deletions
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");