summaryrefslogtreecommitdiffstats
path: root/src/entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/entities')
-rw-r--r--src/entities/Building.cpp11
-rw-r--r--src/entities/Building.h3
-rw-r--r--src/entities/Dummy.cpp14
-rw-r--r--src/entities/Dummy.h5
-rw-r--r--src/entities/Entity.cpp60
-rw-r--r--src/entities/Entity.h22
-rw-r--r--src/entities/Physical.cpp79
-rw-r--r--src/entities/Physical.h48
-rw-r--r--src/entities/Treadable.cpp10
-rw-r--r--src/entities/Treadable.h3
10 files changed, 147 insertions, 108 deletions
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..10677bdf 100644
--- a/src/entities/Entity.cpp
+++ b/src/entities/Entity.cpp
@@ -632,7 +632,7 @@ CEntity::ProcessLightsForEntity(void)
lightOn = true;
else
lightFlickering = true;
- if((CTimer::GetTimeInMilliseconds()>>1 ^ m_randomSeed) & 3)
+ if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed) & 3)
lightOn = true;
break;
case LIGHT_FLICKER_NIGHT:
@@ -641,7 +641,7 @@ CEntity::ProcessLightsForEntity(void)
lightOn = true;
else
lightFlickering = true;
- if((CTimer::GetTimeInMilliseconds()>>1 ^ m_randomSeed) & 3)
+ if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed) & 3)
lightOn = true;
}
break;
@@ -680,7 +680,7 @@ CEntity::ProcessLightsForEntity(void)
lightOn = true;
else
lightFlickering = true;
- if((CTimer::GetTimeInMilliseconds()>>1 ^ m_randomSeed*8) & 3)
+ if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed*8) & 3)
lightOn = true;
}
break;
@@ -693,7 +693,7 @@ CEntity::ProcessLightsForEntity(void)
lightOn = true;
else
lightFlickering = true;
- if((CTimer::GetTimeInMilliseconds()>>1 ^ m_randomSeed*8) & 3)
+ if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed*8) & 3)
lightOn = true;
}
}
@@ -806,17 +806,17 @@ CEntity::ModifyMatrixForTreeInWind(void)
}else if(CWeather::Wind >= 0.2){
t = (uintptr)this + CTimer::GetTimeInMilliseconds();
f = (t & 0xFFF)/(float)0x1000;
- flutter = sin(f * 6.28f);
+ flutter = Sin(f * 6.28f);
strength = 0.008f;
}else{
t = (uintptr)this + CTimer::GetTimeInMilliseconds();
f = (t & 0xFFF)/(float)0x1000;
- flutter = sin(f * 6.28f);
+ flutter = Sin(f * 6.28f);
strength = 0.005f;
}
- mat.GetUp()->x = strength * flutter;
- mat.GetUp()->y = mat.GetUp()->x;
+ mat.GetUp().x = strength * flutter;
+ mat.GetUp().y = mat.GetUp().x;
mat.UpdateRW();
UpdateRwFrame();
@@ -847,7 +847,7 @@ CEntity::ModifyMatrixForBannerInWind(void)
else
strength = 0.66f;
- t = ((int)(GetMatrix().GetPosition()->x + GetMatrix().GetPosition()->y) << 10) + 16*CTimer::GetTimeInMilliseconds();
+ t = ((int)(GetMatrix().GetPosition().x + GetMatrix().GetPosition().y) << 10) + 16*CTimer::GetTimeInMilliseconds();
f = (t & 0x7FF)/(float)0x800;
flutter = f * BannerWindTabel[(t>>11)+1 & 0x1F] +
(1.0f - f) * BannerWindTabel[(t>>11) & 0x1F];
@@ -857,7 +857,7 @@ CEntity::ModifyMatrixForBannerInWind(void)
right.z = 0.0f;
right.Normalise();
up = right * flutter;
- up.z = sqrt(sq(1.0f) - sq(flutter));
+ up.z = Sqrt(sq(1.0f) - sq(flutter));
GetRight() = CrossProduct(GetForward(), up);
GetUp() = up;
@@ -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..12a631d2 100644
--- a/src/entities/Entity.h
+++ b/src/entities/Entity.h
@@ -94,13 +94,15 @@ public:
uint16 m_level; // int16
CReference *m_pFirstReference;
+ CColModel *GetColModel(void) { return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(); }
+
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 +147,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..55ed5380 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"
@@ -32,7 +33,7 @@ CPhysical::CPhysical(void)
m_nCollisionRecords = 0;
for(i = 0; i < 6; i++)
- m_aCollisionRecords[0] = nil;
+ m_aCollisionRecords[i] = nil;
field_EF = false;
@@ -61,7 +62,7 @@ CPhysical::CPhysical(void)
m_phy_flagA10 = false;
m_phy_flagA20 = false;
- m_nLastCollType = 0;
+ m_nSurfaceTouched = SURFACE_DEFAULT;
}
CPhysical::~CPhysical(void)
@@ -456,7 +457,7 @@ CPhysical::ApplySpringCollision(float springConst, CVector &springDir, CVector &
float compression = 1.0f - springRatio;
if(compression > 0.0f){
float step = min(CTimer::GetTimeStep(), 3.0f);
- float impulse = -0.008f*m_fMass*step * springConst * compression * bias*2.0f;
+ float impulse = -GRAVITY*m_fMass*step * springConst * compression * bias*2.0f;
ApplyMoveForce(springDir*impulse);
ApplyTurnForce(springDir*impulse, point);
}
@@ -475,7 +476,7 @@ CPhysical::ApplySpringDampening(float damping, CVector &springDir, CVector &poin
// what is this?
float a = m_fTurnMass / ((point.MagnitudeSqr() + 1.0f) * 2.0f * m_fMass);
a = min(a, 1.0f);
- float b = fabs(impulse / (speedB * m_fMass));
+ float b = Abs(impulse / (speedB * m_fMass));
if(a < b)
impulse *= a/b;
@@ -488,7 +489,7 @@ void
CPhysical::ApplyGravity(void)
{
if(bAffectedByGravity)
- m_vecMoveSpeed.z -= 0.008f * CTimer::GetTimeStep();
+ m_vecMoveSpeed.z -= GRAVITY * CTimer::GetTimeStep();
}
void
@@ -504,11 +505,11 @@ void
CPhysical::ApplyAirResistance(void)
{
if(m_fAirResistance > 0.1f){
- float f = powf(m_fAirResistance, CTimer::GetTimeStep());
+ float f = Pow(m_fAirResistance, CTimer::GetTimeStep());
m_vecMoveSpeed *= f;
m_vecTurnSpeed *= f;
}else{
- float f = powf(1.0f/(m_fAirResistance*0.5f*m_vecMoveSpeed.MagnitudeSqr() + 1.0f), CTimer::GetTimeStep());
+ float f = Pow(1.0f/(m_fAirResistance*0.5f*m_vecMoveSpeed.MagnitudeSqr() + 1.0f), CTimer::GetTimeStep());
m_vecMoveSpeed *= f;
m_vecTurnSpeed *= 0.99f;
}
@@ -718,7 +719,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
if(!B->bInfiniteMass){
if(fB.z < 0.0f){
fB.z = 0.0f;
- if(fabs(speedA) < 0.01f)
+ if(Abs(speedA) < 0.01f)
fB *= 0.5f;
}
if(ispedcontactA){
@@ -814,9 +815,9 @@ CPhysical::ApplyCollisionAlt(CEntity *B, CColPoint &colpoint, float &impulse, CV
float minspeed = 0.0104f * CTimer::GetTimeStep();
if((IsObject() || IsVehicle() && GetUp().z < -0.3f) &&
!bHasContacted &&
- fabs(m_vecMoveSpeed.x) < minspeed &&
- fabs(m_vecMoveSpeed.y) < minspeed &&
- fabs(m_vecMoveSpeed.z) < minspeed*2.0f)
+ Abs(m_vecMoveSpeed.x) < minspeed &&
+ Abs(m_vecMoveSpeed.y) < minspeed &&
+ Abs(m_vecMoveSpeed.z) < minspeed*2.0f)
e = -1.0f;
else
e = -(m_fElasticity + 1.0f);
@@ -1149,14 +1150,14 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
shift += dir * colpoints[mostColliding].depth * 0.5f;
}else if(A->IsPed() && B->IsVehicle() && ((CVehicle*)B)->IsBoat()){
CVector dir = colpoints[mostColliding].normal;
- float f = min(fabs(dir.z), 0.9f);
+ float f = min(Abs(dir.z), 0.9f);
dir.z = 0.0f;
dir.Normalise();
shift += dir * colpoints[mostColliding].depth / (1.0f - f);
boat = B;
}else if(B->IsPed() && A->IsVehicle() && ((CVehicle*)A)->IsBoat()){
CVector dir = colpoints[mostColliding].normal * -1.0f;
- float f = min(fabs(dir.z), 0.9f);
+ float f = min(Abs(dir.z), 0.9f);
dir.z = 0.0f;
dir.Normalise();
B->GetPosition() += dir * colpoints[mostColliding].depth / (1.0f - f);
@@ -1497,8 +1498,8 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float imp = impulseA;
if(A->IsVehicle() && A->GetUp().z < -0.6f &&
- fabs(A->m_vecMoveSpeed.x) < 0.05f &&
- fabs(A->m_vecMoveSpeed.y) < 0.05f)
+ Abs(A->m_vecMoveSpeed.x) < 0.05f &&
+ Abs(A->m_vecMoveSpeed.y) < 0.05f)
imp *= 0.1f;
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
@@ -1518,8 +1519,8 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float imp = impulseA;
if(A->IsVehicle() && A->GetUp().z < -0.6f &&
- fabs(A->m_vecMoveSpeed.x) < 0.05f &&
- fabs(A->m_vecMoveSpeed.y) < 0.05f)
+ Abs(A->m_vecMoveSpeed.x) < 0.05f &&
+ Abs(A->m_vecMoveSpeed.y) < 0.05f)
imp *= 0.1f;
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
@@ -1556,8 +1557,8 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
m_vecTurnSpeed += turnSpeed / numResponses;
if(!CWorld::bNoMoreCollisionTorque &&
A->m_status == STATUS_PLAYER && A->IsVehicle() &&
- fabs(A->m_vecMoveSpeed.x) > 0.2f &&
- fabs(A->m_vecMoveSpeed.y) > 0.2f){
+ Abs(A->m_vecMoveSpeed.x) > 0.2f &&
+ Abs(A->m_vecMoveSpeed.y) > 0.2f){
A->m_vecMoveFriction.x += moveSpeed.x * -0.3f / numCollisions;
A->m_vecMoveFriction.y += moveSpeed.y * -0.3f / numCollisions;
A->m_vecTurnFriction += turnSpeed * -0.3f / numCollisions;
@@ -1782,13 +1783,13 @@ CPhysical::ProcessShift(void)
}
bIsStuck = false;
bIsInSafePosition = true;
- m_fDistanceTravelled = (GetPosition() - *matrix.GetPosition()).Magnitude();
+ m_fDistanceTravelled = (GetPosition() - matrix.GetPosition()).Magnitude();
RemoveAndAdd();
}
}
// x is the number of units (m) we would like to step
-#define NUMSTEPS(x) ceil(sqrt(distSq) * (1.0f/(x)))
+#define NUMSTEPS(x) ceil(Sqrt(distSq) * (1.0f/(x)))
void
CPhysical::ProcessCollision(void)
@@ -1882,7 +1883,7 @@ CPhysical::ProcessCollision(void)
if(IsPed() && m_vecMoveSpeed.z == 0.0f &&
!ped->m_ped_flagA2 &&
ped->bIsStanding)
- savedMatrix.GetPosition()->z = GetPosition().z;
+ savedMatrix.GetPosition().z = GetPosition().z;
GetMatrix() = savedMatrix;
CTimer::SetTimeStep(savedTimeStep);
return;
@@ -1890,7 +1891,7 @@ CPhysical::ProcessCollision(void)
if(IsPed() && m_vecMoveSpeed.z == 0.0f &&
!ped->m_ped_flagA2 &&
ped->bIsStanding)
- savedMatrix.GetPosition()->z = GetPosition().z;
+ savedMatrix.GetPosition().z = GetPosition().z;
GetMatrix() = savedMatrix;
CTimer::SetTimeStep(savedTimeStep);
if(IsVehicle()){
@@ -1917,14 +1918,14 @@ CPhysical::ProcessCollision(void)
bHitByTrain ||
m_status == STATUS_PLAYER || IsPed() && ped->IsPlayer()){
if(IsVehicle())
- ((CVehicle*)this)->m_veh_flagD4 = true;
+ ((CVehicle*)this)->bVehicleColProcessed = true;
if(CheckCollision()){
GetMatrix() = savedMatrix;
return;
}
}
bHitByTrain = false;
- m_fDistanceTravelled = (GetPosition() - *savedMatrix.GetPosition()).Magnitude();
+ m_fDistanceTravelled = (GetPosition() - savedMatrix.GetPosition()).Magnitude();
m_phy_flagA80 = false;
bIsStuck = false;
@@ -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..5bd98815 100644
--- a/src/entities/Physical.h
+++ b/src/entities/Physical.h
@@ -3,12 +3,15 @@
#include "Lists.h"
#include "Timer.h"
#include "Entity.h"
-#include "Treadable.h"
enum {
PHYSICAL_MAX_COLLISIONRECORDS = 6
};
+#define GRAVITY (0.008f)
+
+class CTreadable;
+
class CPhysical : public CEntity
{
public:
@@ -58,20 +61,21 @@ public:
uint8 bHitByTrain : 1; // from nick
uint8 m_phy_flagA80 : 1;
- uint8 m_nLastCollType;
+ uint8 m_nSurfaceTouched;
uint8 m_nZoneLevel;
CPhysical(void);
~CPhysical(void);
// from CEntity
- virtual void Add(void);
- virtual void Remove(void);
- virtual CRect GetBoundRect(void);
- virtual void ProcessControl(void);
- virtual int32 ProcessEntityCollision(CEntity *ent, CColPoint *point);
- virtual void ProcessShift(void);
- virtual void ProcessCollision(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 *colpoints);
void RemoveAndAdd(void);
void AddToMovingList(void);
@@ -106,7 +110,23 @@ public:
}
const CVector &GetMoveSpeed() { return m_vecMoveSpeed; }
+ void SetMoveSpeed(float x, float y, float z) {
+ m_vecMoveSpeed.x = x;
+ m_vecMoveSpeed.y = y;
+ m_vecMoveSpeed.z = z;
+ }
const CVector &GetTurnSpeed() { return m_vecTurnSpeed; }
+ void SetTurnSpeed(float x, float y, float z) {
+ m_vecTurnSpeed.x = x;
+ m_vecTurnSpeed.y = y;
+ m_vecTurnSpeed.z = z;
+ }
+ const CVector &GetCenterOfMass() { return m_vecCentreOfMass; }
+ void SetCenterOfMass(float x, float y, float z) {
+ m_vecCentreOfMass.x = x;
+ m_vecCentreOfMass.y = y;
+ m_vecCentreOfMass.z = z;
+ }
void ApplyMoveSpeed(void);
void ApplyTurnSpeed(void);
@@ -137,15 +157,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");