summaryrefslogtreecommitdiffstats
path: root/src/entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/entities')
-rw-r--r--src/entities/Building.cpp17
-rw-r--r--src/entities/Dummy.cpp16
-rw-r--r--src/entities/Entity.cpp109
-rw-r--r--src/entities/Entity.h43
-rw-r--r--src/entities/Physical.cpp117
-rw-r--r--src/entities/Physical.h6
-rw-r--r--src/entities/Treadable.cpp12
7 files changed, 118 insertions, 202 deletions
diff --git a/src/entities/Building.cpp b/src/entities/Building.cpp
index 7813c87f..aad2d402 100644
--- a/src/entities/Building.cpp
+++ b/src/entities/Building.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-#include "patcher.h"
+
#include "Building.h"
#include "Streaming.h"
#include "Pools.h"
@@ -20,18 +20,3 @@ CBuilding::ReplaceWithNewModel(int32 id)
if(m_level == LEVEL_NONE || m_level == CGame::currLevel)
CStreaming::RequestModel(id, STREAMFLAGS_DONT_REMOVE);
}
-
-#include <new>
-
-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(0x405850, &CBuilding::ReplaceWithNewModel, PATCH_JUMP);
-ENDPATCHES
diff --git a/src/entities/Dummy.cpp b/src/entities/Dummy.cpp
index 176e5682..8a4bfd5f 100644
--- a/src/entities/Dummy.cpp
+++ b/src/entities/Dummy.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-#include "patcher.h"
+
#include "Pools.h"
#include "World.h"
#include "Dummy.h"
@@ -50,17 +50,3 @@ CDummy::Remove(void)
m_entryInfoList.DeleteNode(node);
}
}
-
-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);
-ENDPATCHES
diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp
index 25e5db48..ee4faa82 100644
--- a/src/entities/Entity.cpp
+++ b/src/entities/Entity.cpp
@@ -1,6 +1,7 @@
#include "common.h"
-#include "patcher.h"
+
#include "General.h"
+#include "RwHelper.h"
#include "ModelIndices.h"
#include "Timer.h"
#include "Placeable.h"
@@ -24,6 +25,8 @@
#include "References.h"
#include "TxdStore.h"
#include "Zones.h"
+#include "Bones.h"
+#include "Debug.h"
int gBuildings;
@@ -293,8 +296,13 @@ CEntity::DeleteRwObject(void)
f = RpAtomicGetFrame((RpAtomic*)m_rwObject);
RpAtomicDestroy((RpAtomic*)m_rwObject);
RwFrameDestroy(f);
- }else if(RwObjectGetType(m_rwObject) == rpCLUMP)
+ }else if(RwObjectGetType(m_rwObject) == rpCLUMP){
+#ifdef PED_SKIN
+ if(IsClumpSkinned((RpClump*)m_rwObject))
+ RpClumpForAllAtomics((RpClump*)m_rwObject, AtomicRemoveAnimFromSkinCB, nil);
+#endif
RpClumpDestroy((RpClump*)m_rwObject);
+ }
m_rwObject = nil;
CModelInfo::GetModelInfo(m_modelIndex)->RemoveRef();
if(IsBuilding())
@@ -558,6 +566,44 @@ CEntity::PruneReferences(void)
}
}
+#ifdef PED_SKIN
+void
+CEntity::UpdateRpHAnim(void)
+{
+ RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump());
+ RpHAnimHierarchyUpdateMatrices(hier);
+
+#if 0
+ int i;
+ char buf[256];
+ if(this == (CEntity*)FindPlayerPed())
+ for(i = 0; i < hier->numNodes; i++){
+ RpHAnimStdKeyFrame *kf = (RpHAnimStdKeyFrame*)rpHANIMHIERARCHYGETINTERPFRAME(hier, i);
+ sprintf(buf, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %d %s",
+ kf->q.imag.x, kf->q.imag.y, kf->q.imag.z, kf->q.real,
+ kf->t.x, kf->t.y, kf->t.z,
+ HIERNODEID(hier, i),
+ ConvertBoneTag2BoneName(HIERNODEID(hier, i)));
+ CDebug::PrintAt(buf, 10, 1+i*3);
+
+ RwMatrix *m = &RpHAnimHierarchyGetMatrixArray(hier)[i];
+ sprintf(buf, "%6.3f %6.3f %6.3f %6.3f",
+ m->right.x, m->up.x, m->at.x, m->pos.x);
+ CDebug::PrintAt(buf, 80, 1+i*3+0);
+ sprintf(buf, "%6.3f %6.3f %6.3f %6.3f",
+ m->right.y, m->up.y, m->at.y, m->pos.y);
+ CDebug::PrintAt(buf, 80, 1+i*3+1);
+ sprintf(buf, "%6.3f %6.3f %6.3f %6.3f",
+ m->right.z, m->up.z, m->at.z, m->pos.z);
+ CDebug::PrintAt(buf, 80, 1+i*3+2);
+ }
+
+ void RenderSkeleton(RpHAnimHierarchy *hier);
+ RenderSkeleton(hier);
+#endif
+}
+#endif
+
void
CEntity::AddSteamsFromGround(CVector *unused)
{
@@ -865,55 +911,12 @@ CEntity::ModifyMatrixForBannerInWind(void)
UpdateRwFrame();
}
-#include <new>
-
-class CEntity_ : public CEntity
+void
+CEntity::AddSteamsFromGround(CPtrList& list)
{
-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(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);
- InjectHook(0x474CC0, &CEntity::GetIsOnScreen, PATCH_JUMP);
- InjectHook(0x474D20, &CEntity::GetIsOnScreenComplex, PATCH_JUMP);
- InjectHook(0x474CA0, &CEntity::IsVisible, PATCH_JUMP);
- InjectHook(0x474330, &CEntity::UpdateRwFrame, PATCH_JUMP);
- InjectHook(0x4755E0, &CEntity::SetupBigBuilding, PATCH_JUMP);
- InjectHook(0x4A7480, &CEntity::RegisterReference, PATCH_JUMP);
- InjectHook(0x4A74E0, &CEntity::ResolveReferences, PATCH_JUMP);
- InjectHook(0x4A7530, &CEntity::PruneReferences, PATCH_JUMP);
-
- InjectHook(0x473F10, &CEntity::AttachToRwObject, PATCH_JUMP);
- InjectHook(0x473F60, &CEntity::DetachFromRwObject, PATCH_JUMP);
-
- InjectHook(0x475A20, &CEntity::PreRenderForGlassWindow, PATCH_JUMP);
- InjectHook(0x50CE40, &CEntity::AddSteamsFromGround, PATCH_JUMP);
- InjectHook(0x475670, &CEntity::ModifyMatrixForTreeInWind, PATCH_JUMP);
- InjectHook(0x475830, &CEntity::ModifyMatrixForBannerInWind, PATCH_JUMP);
- InjectHook(0x4FA530, &CEntity::ProcessLightsForEntity, PATCH_JUMP);
-ENDPATCHES
+ CPtrNode *pNode = list.first;
+ while (pNode) {
+ ((CEntity*)pNode->item)->AddSteamsFromGround(nil);
+ pNode = pNode->next;
+ }
+}
diff --git a/src/entities/Entity.h b/src/entities/Entity.h
index ca501ba4..ee9e6490 100644
--- a/src/entities/Entity.h
+++ b/src/entities/Entity.h
@@ -4,6 +4,7 @@
#include "Placeable.h"
struct CReference;
+class CPtrList;
enum eEntityType
{
@@ -39,25 +40,25 @@ public:
uint32 m_status : 5;
// flagsA
- uint32 bUsesCollision : 1;
- uint32 bCollisionProcessed : 1;
- uint32 bIsStatic : 1;
- uint32 bHasContacted : 1;
+ uint32 bUsesCollision : 1; // does entity use collision
+ uint32 bCollisionProcessed : 1; // has object been processed by a ProcessEntityCollision function
+ uint32 bIsStatic : 1; // is entity static
+ uint32 bHasContacted : 1; // has entity processed some contact forces
uint32 bPedPhysics : 1;
- uint32 bIsStuck : 1;
- uint32 bIsInSafePosition : 1;
+ uint32 bIsStuck : 1; // is entity stuck
+ uint32 bIsInSafePosition : 1; // is entity in a collision free safe position
uint32 bUseCollisionRecords : 1;
// flagsB
- uint32 bWasPostponed : 1;
+ uint32 bWasPostponed : 1; // was entity control processing postponed
uint32 bExplosionProof : 1;
- uint32 bIsVisible : 1;
- uint32 bHasCollided : 1; //
+ uint32 bIsVisible : 1; //is the entity visible
+ uint32 bHasCollided : 1;
uint32 bRenderScorched : 1;
uint32 bHasBlip : 1;
- uint32 bIsBIGBuilding : 1;
+ uint32 bIsBIGBuilding : 1; // Set if this entity is a big building
// VC inserts one more flag here: if drawdist <= 2000
- uint32 bRenderDamaged : 1;
+ uint32 bRenderDamaged : 1; // use damaged LOD models for objects with applicable damage
// flagsC
uint32 bBulletProof : 1;
@@ -65,22 +66,22 @@ public:
uint32 bCollisionProof : 1;
uint32 bMeleeProof : 1;
uint32 bOnlyDamagedByPlayer : 1;
- uint32 bStreamingDontDelete : 1;
+ uint32 bStreamingDontDelete : 1; // Dont let the streaming remove this
uint32 bZoneCulled : 1;
- uint32 bZoneCulled2 : 1; // only treadables+10m
+ uint32 bZoneCulled2 : 1; // only treadables+10m
// flagsD
- uint32 bRemoveFromWorld : 1;
- uint32 bHasHitWall : 1;
- uint32 bImBeingRendered : 1;
+ uint32 bRemoveFromWorld : 1; // remove this entity next time it should be processed
+ uint32 bHasHitWall : 1; // has collided with a building (changes subsequent collisions)
+ uint32 bImBeingRendered : 1; // don't delete me because I'm being rendered
uint32 bTouchingWater : 1; // used by cBuoyancy::ProcessBuoyancy
uint32 bIsSubway : 1; // set when subway, but maybe different meaning?
- uint32 bDrawLast : 1;
+ uint32 bDrawLast : 1; // draw object last
uint32 bNoBrightHeadLights : 1;
uint32 bDoNotRender : 1;
// flagsE
- uint32 bDistanceFade : 1;
+ uint32 bDistanceFade : 1; // Fade entity because it is far away
uint32 m_flagE2 : 1;
uint16 m_scanCode;
@@ -147,10 +148,16 @@ public:
void ResolveReferences(void);
void PruneReferences(void);
+#ifdef PED_SKIN
+ void UpdateRpHAnim(void);
+#endif
+
void PreRenderForGlassWindow(void);
void AddSteamsFromGround(CVector *unused);
void ModifyMatrixForTreeInWind(void);
void ModifyMatrixForBannerInWind(void);
void ProcessLightsForEntity(void);
+
+ static void AddSteamsFromGround(CPtrList& list);
};
static_assert(sizeof(CEntity) == 0x64, "CEntity: error");
diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp
index 9fc77a8c..a27e4d7b 100644
--- a/src/entities/Physical.cpp
+++ b/src/entities/Physical.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-#include "patcher.h"
+
#include "World.h"
#include "Timer.h"
#include "ModelIndices.h"
@@ -36,7 +36,7 @@ CPhysical::CPhysical(void)
for(i = 0; i < 6; i++)
m_aCollisionRecords[i] = nil;
- field_EF = false;
+ m_bIsVehicleBeingShifted = false;
m_nDamagePieceType = 0;
m_fDamageImpulse = 0.0f;
@@ -63,7 +63,7 @@ CPhysical::CPhysical(void)
m_phy_flagA10 = false;
m_phy_flagA20 = false;
- m_nZoneLevel = 0;
+ m_nZoneLevel = LEVEL_NONE;
}
CPhysical::~CPhysical(void)
@@ -457,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 step = Min(CTimer::GetTimeStep(), 3.0f);
float impulse = -GRAVITY*m_fMass*step * springConst * compression * bias*2.0f;
ApplyMoveForce(springDir*impulse);
ApplyTurnForce(springDir*impulse, point);
@@ -471,12 +471,12 @@ CPhysical::ApplySpringDampening(float damping, CVector &springDir, CVector &poin
{
float speedA = DotProduct(speed, springDir);
float speedB = DotProduct(GetSpeed(point), springDir);
- float step = min(CTimer::GetTimeStep(), 3.0f);
+ float step = Min(CTimer::GetTimeStep(), 3.0f);
float impulse = -damping * (speedA + speedB)/2.0f * m_fMass * step * 0.53f;
// what is this?
float a = m_fTurnMass / ((point.MagnitudeSqr() + 1.0f) * 2.0f * m_fMass);
- a = min(a, 1.0f);
+ a = Min(a, 1.0f);
float b = Abs(impulse / (speedB * m_fMass));
if(a < b)
impulse *= a/b;
@@ -612,7 +612,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
if(model == MI_FIRE_HYDRANT && !Bobj->bHasBeenDamaged){
CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, B->GetPosition() - CVector(0.0f, 0.0f, 0.5f), true);
Bobj->bHasBeenDamaged = true;
- }else if(B->IsObject() && model != MI_EXPLODINGBARREL && model != MI_PETROLPUMP)
+ }else if(B->IsObject() && !IsExplosiveThingModel(model))
Bobj->bHasBeenDamaged = true;
}else{
if(IsGlass(B->GetModelIndex()))
@@ -646,7 +646,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
// positive if B is moving towards A
// not interested in how much B moves into A apparently?
// only interested in cases where A collided into B
- speedB = max(0.0f, DotProduct(B->m_vecMoveSpeed, colpoint.normal));
+ speedB = Max(0.0f, DotProduct(B->m_vecMoveSpeed, colpoint.normal));
// A has moved into B
if(speedA < speedB){
if(!A->bHasHitWall)
@@ -1037,7 +1037,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
int numCollisions;
int mostColliding;
- CColPoint colpoints[32];
+ CColPoint colpoints[MAX_COLLISION_POINTS];
CVector shift = { 0.0f, 0.0f, 0.0f };
bool doShift = false;
CEntity *boat = nil;
@@ -1147,18 +1147,18 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
CVector dir = A->GetPosition() - B->GetPosition();
dir.Normalise();
if(dir.z < 0.0f && dir.z < A->GetForward().z && dir.z < A->GetRight().z)
- dir.z = min(0.0f, min(A->GetForward().z, A->GetRight().z));
+ dir.z = Min(0.0f, Min(A->GetForward().z, A->GetRight().z));
shift += dir * colpoints[mostColliding].depth * 0.5f;
}else if(A->IsPed() && B->IsVehicle() && ((CVehicle*)B)->IsBoat()){
CVector dir = colpoints[mostColliding].normal;
- float f = min(Abs(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(Abs(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);
@@ -1187,7 +1187,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
bool
CPhysical::ProcessCollisionSectorList_SimpleCar(CPtrList *lists)
{
- static CColPoint aColPoints[32];
+ static CColPoint aColPoints[MAX_COLLISION_POINTS];
float radius;
CVector center;
int listtype;
@@ -1246,7 +1246,7 @@ collision:
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
- DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
+ DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
}
}else if(A->bHasContacted){
CVector savedMoveFriction = A->m_vecMoveFriction;
@@ -1268,7 +1268,7 @@ collision:
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
- DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
+ DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){
A->bHasContacted = true;
@@ -1301,7 +1301,7 @@ collision:
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
- DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
+ DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){
A->bHasContacted = true;
@@ -1328,7 +1328,7 @@ collision:
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
- DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
+ DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){
A->bHasContacted = true;
@@ -1349,7 +1349,7 @@ collision:
bool
CPhysical::ProcessCollisionSectorList(CPtrList *lists)
{
- static CColPoint aColPoints[32];
+ static CColPoint aColPoints[MAX_COLLISION_POINTS];
float radius;
CVector center;
CPtrList *list;
@@ -1506,7 +1506,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
float moveSpeedDiff = A->m_vecMoveSpeed.MagnitudeSqr();
- DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, imp, max(turnSpeedDiff, moveSpeedDiff));
+ DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, imp, Max(turnSpeedDiff, moveSpeedDiff));
}
}else{
for(i = 0; i < numCollisions; i++){
@@ -1527,7 +1527,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
float moveSpeedDiff = A->m_vecMoveSpeed.MagnitudeSqr();
- DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, imp, max(turnSpeedDiff, moveSpeedDiff));
+ DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, imp, Max(turnSpeedDiff, moveSpeedDiff));
float adhesion = CSurfaceTable::GetAdhesiveLimit(aColPoints[i]) / numCollisions;
@@ -1545,7 +1545,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
else if(A->GetUp().z > 0.3f)
adhesion = 0.0f;
else
- adhesion *= min(5.0f, 0.03f*impulseA + 1.0f);
+ adhesion *= Min(5.0f, 0.03f*impulseA + 1.0f);
}
if(A->ApplyFriction(adhesion, aColPoints[i]))
@@ -1594,7 +1594,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
- DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
+ DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
}
}else if(A->bHasContacted){
CVector savedMoveFriction = A->m_vecMoveFriction;
@@ -1619,7 +1619,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
- DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
+ DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){
A->bHasContacted = true;
@@ -1655,7 +1655,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
- DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
+ DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){
A->bHasContacted = true;
@@ -1685,7 +1685,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr();
float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr();
- DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff));
+ DMAudio.ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, Max(turnSpeedDiff, moveSpeedDiff));
if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){
A->bHasContacted = true;
@@ -1767,13 +1767,13 @@ CPhysical::ProcessShift(void)
CWorld::AdvanceCurrentScanCode();
if(IsVehicle())
- field_EF = true;
+ m_bIsVehicleBeingShifted = true;
CEntryInfoNode *node;
bool hasshifted = false; // whatever that means...
for(node = m_entryInfoList.first; node; node = node->next)
hasshifted |= ProcessShiftSectorList(node->sector->m_lists);
- field_EF = false;
+ m_bIsVehicleBeingShifted = false;
if(hasshifted){
CWorld::AdvanceCurrentScanCode();
for(node = m_entryInfoList.first; node; node = node->next)
@@ -1799,7 +1799,7 @@ CPhysical::ProcessCollision(void)
CPed *ped = (CPed*)this;
m_fDistanceTravelled = 0.0f;
- field_EF = 0;
+ m_bIsVehicleBeingShifted = false;
m_phy_flagA80 = false;
if(!bUsesCollision){
@@ -1831,7 +1831,7 @@ CPhysical::ProcessCollision(void)
if(IsPed() && (distSq >= sq(0.2f) || ped->IsPlayer())){
if(ped->IsPlayer())
- n = max(NUMSTEPS(0.2f), 2.0f);
+ n = Max(NUMSTEPS(0.2f), 2.0f);
else
n = NUMSTEPS(0.3f);
step = savedTimeStep / n;
@@ -1852,7 +1852,7 @@ CPhysical::ProcessCollision(void)
speedDown = Multiply3x3(GetMatrix(), speedDown);
speedUp = GetSpeed(speedUp);
speedDown = GetSpeed(speedDown);
- distSq = max(speedUp.MagnitudeSqr(), speedDown.MagnitudeSqr()) * sq(CTimer::GetTimeStep());
+ distSq = Max(speedUp.MagnitudeSqr(), speedDown.MagnitudeSqr()) * sq(CTimer::GetTimeStep());
if(distSq >= sq(0.3f)){
n = NUMSTEPS(0.3f);
step = savedTimeStep / n;
@@ -1912,7 +1912,7 @@ CPhysical::ProcessCollision(void)
ApplyMoveSpeed();
ApplyTurnSpeed();
GetMatrix().Reorthogonalise();
- field_EF = 0;
+ m_bIsVehicleBeingShifted = false;
m_phy_flagA80 = false;
if(!m_vecMoveSpeed.IsZero() ||
!m_vecTurnSpeed.IsZero() ||
@@ -1933,58 +1933,3 @@ CPhysical::ProcessCollision(void)
bIsInSafePosition = true;
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(0x4958F0, &CPhysical::AddToMovingList, PATCH_JUMP);
- InjectHook(0x495940, &CPhysical::RemoveFromMovingList, PATCH_JUMP);
- InjectHook(0x497180, &CPhysical::AddCollisionRecord, PATCH_JUMP);
- InjectHook(0x4970C0, &CPhysical::AddCollisionRecord_Treadable, PATCH_JUMP);
- InjectHook(0x497240, &CPhysical::GetHasCollidedWith, PATCH_JUMP);
- InjectHook(0x49F820, &CPhysical::RemoveRefsToEntity, PATCH_JUMP);
- InjectHook(0x49F890, &CPhysical::PlacePhysicalRelativeToOtherPhysical, PATCH_JUMP);
-
-#define F3 float, float, float
- InjectHook(0x495B10, &CPhysical::ApplyMoveSpeed, PATCH_JUMP);
- InjectHook(0x497280, &CPhysical::ApplyTurnSpeed, PATCH_JUMP);
- InjectHook(0x4959A0, (void (CPhysical::*)(F3))&CPhysical::ApplyMoveForce, PATCH_JUMP);
- InjectHook(0x495A10, (void (CPhysical::*)(F3, F3))&CPhysical::ApplyTurnForce, PATCH_JUMP);
- InjectHook(0x495D90, (void (CPhysical::*)(F3))&CPhysical::ApplyFrictionMoveForce, PATCH_JUMP);
- InjectHook(0x495E10, (void (CPhysical::*)(F3, F3))&CPhysical::ApplyFrictionTurnForce, PATCH_JUMP);
- InjectHook(0x499890, &CPhysical::ApplySpringCollision, PATCH_JUMP);
- InjectHook(0x499990, &CPhysical::ApplySpringDampening, PATCH_JUMP);
- InjectHook(0x495B50, &CPhysical::ApplyGravity, PATCH_JUMP);
- InjectHook(0x495B80, (void (CPhysical::*)(void))&CPhysical::ApplyFriction, PATCH_JUMP);
- InjectHook(0x495C20, &CPhysical::ApplyAirResistance, PATCH_JUMP);
-
- InjectHook(0x4973A0, &CPhysical::ApplyCollision, PATCH_JUMP);
- InjectHook(0x4992A0, &CPhysical::ApplyCollisionAlt, PATCH_JUMP);
- InjectHook(0x499BE0, (bool (CPhysical::*)(float, CColPoint&))&CPhysical::ApplyFriction, PATCH_JUMP);
- InjectHook(0x49A180, (bool (CPhysical::*)(CPhysical*, float, CColPoint&))&CPhysical::ApplyFriction, PATCH_JUMP);
-
- InjectHook(0x49DA10, &CPhysical::ProcessShiftSectorList, PATCH_JUMP);
- InjectHook(0x49E790, &CPhysical::ProcessCollisionSectorList_SimpleCar, PATCH_JUMP);
- InjectHook(0x49B620, &CPhysical::ProcessCollisionSectorList, PATCH_JUMP);
- InjectHook(0x496E50, &CPhysical::CheckCollision, PATCH_JUMP);
- InjectHook(0x496EB0, &CPhysical::CheckCollision_SimpleCar, PATCH_JUMP);
-ENDPATCHES
diff --git a/src/entities/Physical.h b/src/entities/Physical.h
index 6fbc3ffd..fa5ada05 100644
--- a/src/entities/Physical.h
+++ b/src/entities/Physical.h
@@ -40,7 +40,7 @@ public:
char field_EC;
uint8 m_nStaticFrames;
uint8 m_nCollisionRecords;
- bool field_EF;
+ bool m_bIsVehicleBeingShifted;
CEntity *m_aCollisionRecords[PHYSICAL_MAX_COLLISIONRECORDS];
float m_fDistanceTravelled;
@@ -55,8 +55,8 @@ public:
uint8 bAffectedByGravity : 1;
uint8 bInfiniteMass : 1;
uint8 bIsInWater : 1;
- uint8 m_phy_flagA10 : 1;
- uint8 m_phy_flagA20 : 1;
+ uint8 m_phy_flagA10 : 1; // unused
+ uint8 m_phy_flagA20 : 1; // unused
uint8 bHitByTrain : 1;
uint8 m_phy_flagA80 : 1;
diff --git a/src/entities/Treadable.cpp b/src/entities/Treadable.cpp
index ea949f00..00abbe13 100644
--- a/src/entities/Treadable.cpp
+++ b/src/entities/Treadable.cpp
@@ -1,18 +1,8 @@
#include "common.h"
-#include "patcher.h"
+
#include "rpworld.h"
#include "Treadable.h"
#include "Pools.h"
void *CTreadable::operator new(size_t sz) { return CPools::GetTreadablePool()->New(); }
void CTreadable::operator delete(void *p, size_t sz) { CPools::GetTreadablePool()->Delete((CTreadable*)p); }
-
-class CTreadable_ : public CTreadable
-{
-public:
- void dtor(void) { CTreadable::~CTreadable(); }
-};
-
-STARTPATCHES
- InjectHook(0x405A10, &CTreadable_::dtor, PATCH_JUMP);
-ENDPATCHES