summaryrefslogtreecommitdiffstats
path: root/src/entities
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/entities/Building.cpp2
-rw-r--r--src/entities/Building.h4
-rw-r--r--src/entities/Dummy.h4
-rw-r--r--src/entities/Entity.cpp114
-rw-r--r--src/entities/Entity.h25
-rw-r--r--src/entities/Physical.cpp90
-rw-r--r--src/entities/Physical.h5
-rw-r--r--src/entities/Treadable.h4
8 files changed, 187 insertions, 61 deletions
diff --git a/src/entities/Building.cpp b/src/entities/Building.cpp
index aad2d402..3c096636 100644
--- a/src/entities/Building.cpp
+++ b/src/entities/Building.cpp
@@ -12,7 +12,7 @@ CBuilding::ReplaceWithNewModel(int32 id)
{
DeleteRwObject();
- if(CModelInfo::GetModelInfo(m_modelIndex)->m_refCount == 0)
+ if (CModelInfo::GetModelInfo(m_modelIndex)->GetNumRefs() == 0)
CStreaming::RemoveModel(m_modelIndex);
m_modelIndex = id;
diff --git a/src/entities/Building.h b/src/entities/Building.h
index 7b837f46..3586a8dc 100644
--- a/src/entities/Building.h
+++ b/src/entities/Building.h
@@ -16,4 +16,6 @@ public:
virtual bool GetIsATreadable(void) { return false; }
};
-static_assert(sizeof(CBuilding) == 0x64, "CBuilding: error");
+
+VALIDATE_SIZE(CBuilding, 0x64);
+
diff --git a/src/entities/Dummy.h b/src/entities/Dummy.h
index fcfd23fb..3717a01c 100644
--- a/src/entities/Dummy.h
+++ b/src/entities/Dummy.h
@@ -15,4 +15,6 @@ public:
static void *operator new(size_t);
static void operator delete(void*, size_t);
};
-static_assert(sizeof(CDummy) == 0x68, "CDummy: error");
+
+VALIDATE_SIZE(CDummy, 0x68);
+
diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp
index ee4faa82..ec50dd30 100644
--- a/src/entities/Entity.cpp
+++ b/src/entities/Entity.cpp
@@ -27,6 +27,7 @@
#include "Zones.h"
#include "Bones.h"
#include "Debug.h"
+#include "Renderer.h"
int gBuildings;
@@ -330,7 +331,7 @@ CEntity::SetupBigBuilding(void)
bIsBIGBuilding = true;
bStreamingDontDelete = true;
bUsesCollision = false;
- m_level = CTheZones::GetLevelFromPosition(GetPosition());
+ m_level = CTheZones::GetLevelFromPosition(&GetPosition());
if(m_level == LEVEL_NONE){
if(mi->GetTxdSlot() != CTxdStore::FindTxdSlot("generic")){
mi->SetTexDictionary("generic");
@@ -452,7 +453,7 @@ CEntity::PreRender(void)
break;
}
- if(CModelInfo::GetModelInfo(GetModelIndex())->m_num2dEffects != 0)
+ if (CModelInfo::GetModelInfo(GetModelIndex())->GetNum2dEffects() != 0)
ProcessLightsForEntity();
}
@@ -611,7 +612,7 @@ CEntity::AddSteamsFromGround(CVector *unused)
C2dEffect *effect;
CVector pos;
- n = CModelInfo::GetModelInfo(GetModelIndex())->m_num2dEffects;
+ n = CModelInfo::GetModelInfo(GetModelIndex())->GetNum2dEffects();
for(i = 0; i < n; i++){
effect = CModelInfo::GetModelInfo(GetModelIndex())->Get2dEffect(i);
if(effect->type != EFFECT_PARTICLE)
@@ -654,7 +655,7 @@ CEntity::ProcessLightsForEntity(void)
flashTimer2 = 0;
flashTimer3 = 0;
- n = CModelInfo::GetModelInfo(GetModelIndex())->m_num2dEffects;
+ n = CModelInfo::GetModelInfo(GetModelIndex())->GetNum2dEffects();
for(i = 0; i < n; i++, flashTimer1 += 0x80, flashTimer2 += 0x100, flashTimer3 += 0x200){
effect = CModelInfo::GetModelInfo(GetModelIndex())->Get2dEffect(i);
@@ -920,3 +921,108 @@ CEntity::AddSteamsFromGround(CPtrList& list)
pNode = pNode->next;
}
}
+
+#ifdef COMPATIBLE_SAVES
+void
+CEntity::SaveEntityFlags(uint8*& buf)
+{
+ uint32 tmp = 0;
+ tmp |= (m_type & (BIT(3) - 1));
+ tmp |= (m_status & (BIT(5) - 1)) << 3;
+
+ if (bUsesCollision) tmp |= BIT(8);
+ if (bCollisionProcessed) tmp |= BIT(9);
+ if (bIsStatic) tmp |= BIT(10);
+ if (bHasContacted) tmp |= BIT(11);
+ if (bPedPhysics) tmp |= BIT(12);
+ if (bIsStuck) tmp |= BIT(13);
+ if (bIsInSafePosition) tmp |= BIT(14);
+ if (bUseCollisionRecords) tmp |= BIT(15);
+
+ if (bWasPostponed) tmp |= BIT(16);
+ if (bExplosionProof) tmp |= BIT(17);
+ if (bIsVisible) tmp |= BIT(18);
+ if (bHasCollided) tmp |= BIT(19);
+ if (bRenderScorched) tmp |= BIT(20);
+ if (bHasBlip) tmp |= BIT(21);
+ if (bIsBIGBuilding) tmp |= BIT(22);
+ if (bRenderDamaged) tmp |= BIT(23);
+
+ if (bBulletProof) tmp |= BIT(24);
+ if (bFireProof) tmp |= BIT(25);
+ if (bCollisionProof) tmp |= BIT(26);
+ if (bMeleeProof) tmp |= BIT(27);
+ if (bOnlyDamagedByPlayer) tmp |= BIT(28);
+ if (bStreamingDontDelete) tmp |= BIT(29);
+ if (bZoneCulled) tmp |= BIT(30);
+ if (bZoneCulled2) tmp |= BIT(31);
+
+ WriteSaveBuf<uint32>(buf, tmp);
+
+ tmp = 0;
+
+ if (bRemoveFromWorld) tmp |= BIT(0);
+ if (bHasHitWall) tmp |= BIT(1);
+ if (bImBeingRendered) tmp |= BIT(2);
+ if (bTouchingWater) tmp |= BIT(3);
+ if (bIsSubway) tmp |= BIT(4);
+ if (bDrawLast) tmp |= BIT(5);
+ if (bNoBrightHeadLights) tmp |= BIT(6);
+ if (bDoNotRender) tmp |= BIT(7);
+
+ if (bDistanceFade) tmp |= BIT(8);
+ if (m_flagE2) tmp |= BIT(9);
+
+ WriteSaveBuf<uint32>(buf, tmp);
+}
+
+void
+CEntity::LoadEntityFlags(uint8*& buf)
+{
+ uint32 tmp = ReadSaveBuf<uint32>(buf);
+ m_type = (tmp & ((BIT(3) - 1)));
+ m_status = ((tmp >> 3) & (BIT(5) - 1));
+
+ bUsesCollision = !!(tmp & BIT(8));
+ bCollisionProcessed = !!(tmp & BIT(9));
+ bIsStatic = !!(tmp & BIT(10));
+ bHasContacted = !!(tmp & BIT(11));
+ bPedPhysics = !!(tmp & BIT(12));
+ bIsStuck = !!(tmp & BIT(13));
+ bIsInSafePosition = !!(tmp & BIT(14));
+ bUseCollisionRecords = !!(tmp & BIT(15));
+
+ bWasPostponed = !!(tmp & BIT(16));
+ bExplosionProof = !!(tmp & BIT(17));
+ bIsVisible = !!(tmp & BIT(18));
+ bHasCollided = !!(tmp & BIT(19));
+ bRenderScorched = !!(tmp & BIT(20));
+ bHasBlip = !!(tmp & BIT(21));
+ bIsBIGBuilding = !!(tmp & BIT(22));
+ bRenderDamaged = !!(tmp & BIT(23));
+
+ bBulletProof = !!(tmp & BIT(24));
+ bFireProof = !!(tmp & BIT(25));
+ bCollisionProof = !!(tmp & BIT(26));
+ bMeleeProof = !!(tmp & BIT(27));
+ bOnlyDamagedByPlayer = !!(tmp & BIT(28));
+ bStreamingDontDelete = !!(tmp & BIT(29));
+ bZoneCulled = !!(tmp & BIT(30));
+ bZoneCulled2 = !!(tmp & BIT(31));
+
+ tmp = ReadSaveBuf<uint32>(buf);
+
+ bRemoveFromWorld = !!(tmp & BIT(0));
+ bHasHitWall = !!(tmp & BIT(1));
+ bImBeingRendered = !!(tmp & BIT(2));
+ bTouchingWater = !!(tmp & BIT(3));
+ bIsSubway = !!(tmp & BIT(4));
+ bDrawLast = !!(tmp & BIT(5));
+ bNoBrightHeadLights = !!(tmp & BIT(6));
+ bDoNotRender = !!(tmp & BIT(7));
+
+ bDistanceFade = !!(tmp & BIT(8));
+ m_flagE2 = !!(tmp & BIT(9));
+}
+
+#endif
diff --git a/src/entities/Entity.h b/src/entities/Entity.h
index ee9e6490..eca462cd 100644
--- a/src/entities/Entity.h
+++ b/src/entities/Entity.h
@@ -6,7 +6,7 @@
struct CReference;
class CPtrList;
-enum eEntityType
+enum eEntityType : uint8
{
ENTITY_TYPE_NOTHING = 0,
ENTITY_TYPE_BUILDING,
@@ -16,7 +16,7 @@ enum eEntityType
ENTITY_TYPE_DUMMY,
};
-enum eEntityStatus
+enum eEntityStatus : uint8
{
STATUS_PLAYER,
STATUS_PLAYER_PLAYBACKFROMBUFFER,
@@ -36,9 +36,11 @@ class CEntity : public CPlaceable
{
public:
RwObject *m_rwObject;
+protected:
uint32 m_type : 3;
+private:
uint32 m_status : 5;
-
+public:
// flagsA
uint32 bUsesCollision : 1; // does entity use collision
uint32 bCollisionProcessed : 1; // has object been processed by a ProcessEntityCollision function
@@ -57,7 +59,6 @@ public:
uint32 bRenderScorched : 1;
uint32 bHasBlip : 1;
uint32 bIsBIGBuilding : 1; // Set if this entity is a big building
- // VC inserts one more flag here: if drawdist <= 2000
uint32 bRenderDamaged : 1; // use damaged LOD models for objects with applicable damage
// flagsC
@@ -90,8 +91,19 @@ public:
uint16 m_level; // int16
CReference *m_pFirstReference;
+public:
+ eEntityType GetType() const { return (eEntityType)m_type; }
+ void SetType(eEntityType type) { m_type = type; }
+ eEntityStatus GetStatus() const { return (eEntityStatus)m_status; }
+ void SetStatus(eEntityStatus status) { m_status = status; }
CColModel *GetColModel(void) { return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(); }
+ bool IsStatic(void) { return bIsStatic; }
+#ifdef COMPATIBLE_SAVES
+ void SaveEntityFlags(uint8*& buf);
+ void LoadEntityFlags(uint8*& buf);
+#else
uint32* GetAddressOfEntityProperties() { /* AWFUL */ return (uint32*)((char*)&m_rwObject + sizeof(m_rwObject)); }
+#endif
CEntity(void);
~CEntity(void);
@@ -137,7 +149,7 @@ public:
bool GetIsOnScreenComplex(void);
bool IsVisible(void) { return m_rwObject && bIsVisible && GetIsOnScreen(); }
bool IsVisibleComplex(void) { return m_rwObject && bIsVisible && GetIsOnScreenComplex(); }
- int GetModelIndex(void) { return m_modelIndex; }
+ int16 GetModelIndex(void) const { return m_modelIndex; }
void UpdateRwFrame(void);
void SetupBigBuilding(void);
@@ -160,4 +172,5 @@ public:
static void AddSteamsFromGround(CPtrList& list);
};
-static_assert(sizeof(CEntity) == 0x64, "CEntity: error");
+
+VALIDATE_SIZE(CEntity, 0x64);
diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp
index d37405ec..64358cbf 100644
--- a/src/entities/Physical.cpp
+++ b/src/entities/Physical.cpp
@@ -54,7 +54,7 @@ CPhysical::CPhysical(void)
bInfiniteMass = false;
bIsInWater = false;
bHitByTrain = false;
- m_phy_flagA80 = false;
+ bSkipLineCol = false;
m_fDistanceTravelled = 0.0f;
m_treadable[PATH_CAR] = nil;
@@ -315,7 +315,7 @@ CPhysical::PlacePhysicalRelativeToOtherPhysical(CPhysical *other, CPhysical *phy
CWorld::Remove(phys);
phys->GetMatrix() = other->GetMatrix();
- phys->GetPosition() = pos;
+ phys->SetPosition(pos);
phys->m_vecMoveSpeed = other->m_vecMoveSpeed;
phys->GetMatrix().UpdateRW();
phys->UpdateRwFrame();
@@ -326,15 +326,15 @@ int32
CPhysical::ProcessEntityCollision(CEntity *ent, CColPoint *colpoints)
{
int32 numSpheres = CCollision::ProcessColModels(
- GetMatrix(), *CModelInfo::GetModelInfo(GetModelIndex())->GetColModel(),
- ent->GetMatrix(), *CModelInfo::GetModelInfo(ent->GetModelIndex())->GetColModel(),
+ GetMatrix(), *GetColModel(),
+ ent->GetMatrix(), *ent->GetColModel(),
colpoints,
nil, nil); // No Lines allowed!
if(numSpheres > 0){
AddCollisionRecord(ent);
if(!ent->IsBuilding()) // Can't this catch dummies too?
((CPhysical*)ent)->AddCollisionRecord(this);
- if(ent->IsBuilding() || ent->bIsStatic)
+ if(ent->IsBuilding() || ent->IsStatic())
this->bHasHitWall = true;
}
return numSpheres;
@@ -350,7 +350,7 @@ CPhysical::ProcessControl(void)
bWasPostponed = false;
bHasHitWall = false;
- if(m_status == STATUS_SIMPLE)
+ if(GetStatus() == STATUS_SIMPLE)
return;
m_nCollisionRecords = 0;
@@ -410,7 +410,7 @@ CPhysical::GetSpeed(const CVector &r)
void
CPhysical::ApplyMoveSpeed(void)
{
- GetPosition() += m_vecMoveSpeed * CTimer::GetTimeStep();
+ GetMatrix().Translate(m_vecMoveSpeed * CTimer::GetTimeStep());
}
void
@@ -538,7 +538,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
float timestepB;
if(A->bPedPhysics){
if(A->IsPed() && ((CPed*)A)->IsPlayer() && B->IsVehicle() &&
- (B->m_status == STATUS_ABANDONED || B->m_status == STATUS_WRECKED || A->bHasHitWall))
+ (B->GetStatus() == STATUS_ABANDONED || B->GetStatus() == STATUS_WRECKED || A->bHasHitWall))
timestepB = 2200.0f / B->m_fMass;
else
timestepB = 10.0f;
@@ -549,7 +549,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
timestepB = B->bIsHeavy ? 2.0f : 1.0f;
float speedA, speedB;
- if(B->bIsStatic){
+ if(B->IsStatic()){
if(A->bPedPhysics){
speedA = DotProduct(A->m_vecMoveSpeed, colpoint.normal);
if(speedA < 0.0f){
@@ -632,7 +632,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
}
}
- if(B->bIsStatic)
+ if(B->IsStatic())
return false;
if(!B->bInfiniteMass)
B->AddToMovingList();
@@ -757,7 +757,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
fA.y *= 1.4f;
if(colpoint.normal.z < 0.7f)
fA.z *= 0.3f;
- if(A->m_status == STATUS_PLAYER)
+ if(A->GetStatus() == STATUS_PLAYER)
pointposA *= 0.8f;
if(CWorld::bNoMoreCollisionTorque){
A->ApplyFrictionMoveForce(fA*-0.3f);
@@ -769,7 +769,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
fB.y *= 1.4f;
if(colpoint.normal.z < 0.7f)
fB.z *= 0.3f;
- if(B->m_status == STATUS_PLAYER)
+ if(B->GetStatus() == STATUS_PLAYER)
pointposB *= 0.8f;
if(CWorld::bNoMoreCollisionTorque){
// BUG: the game actually uses A here, but this can't be right
@@ -815,7 +815,7 @@ CPhysical::ApplyCollisionAlt(CEntity *B, CColPoint &colpoint, float &impulse, CV
if(normalSpeed < 0.0f){
float minspeed = 0.0104f * CTimer::GetTimeStep();
#ifdef GTA3_1_1_PATCH
- if ((IsObject() || IsVehicle() && (GetUp().z < -0.3f || ((CVehicle*)this)->IsBike() && (m_status == STATUS_ABANDONED || m_status == STATUS_WRECKED))) &&
+ if ((IsObject() || IsVehicle() && (GetUp().z < -0.3f || ((CVehicle*)this)->IsBike() && (GetStatus() == STATUS_ABANDONED || GetStatus() == STATUS_WRECKED))) &&
#else
if((IsObject() || IsVehicle() && GetUp().z < -0.3f) &&
#endif
@@ -1089,7 +1089,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
CObject *Aobj = (CObject*)A;
if(Aobj->ObjectCreatedBy != TEMP_OBJECT &&
!Aobj->bHasBeenDamaged &&
- Aobj->bIsStatic){
+ Aobj->IsStatic()){
if(Aobj->m_pCollidingEntity == B)
Aobj->m_pCollidingEntity = nil;
}else if(Aobj->m_pCollidingEntity != B){
@@ -1106,7 +1106,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
CObject *Bobj = (CObject*)B;
if(Bobj->ObjectCreatedBy != TEMP_OBJECT &&
!Bobj->bHasBeenDamaged &&
- Bobj->bIsStatic){
+ Bobj->IsStatic()){
if(Bobj->m_pCollidingEntity == A)
Bobj->m_pCollidingEntity = nil;
}else if(Bobj->m_pCollidingEntity != A){
@@ -1165,7 +1165,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
float f = Min(Abs(dir.z), 0.9f);
dir.z = 0.0f;
dir.Normalise();
- B->GetPosition() += dir * colpoints[mostColliding].depth / (1.0f - f);
+ B->GetMatrix().Translate(dir * colpoints[mostColliding].depth / (1.0f - f));
// BUG? how can that ever happen? A is a Ped
if(B->IsVehicle())
B->ProcessEntityCollision(A, colpoints);
@@ -1182,7 +1182,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
if(!doShift)
return false;
- GetPosition() += shift;
+ GetMatrix().Translate(shift);
if(boat)
ProcessEntityCollision(boat, colpoints);
return true;
@@ -1341,8 +1341,8 @@ collision:
}
}
- if(B->m_status == STATUS_SIMPLE){
- B->m_status = STATUS_PHYSICS;
+ if(B->GetStatus() == STATUS_SIMPLE){
+ B->SetStatus(STATUS_PHYSICS);
if(B->IsVehicle())
CCarCtrl::SwitchVehicleToRealPhysics((CVehicle*)B);
}
@@ -1401,7 +1401,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
continue;
}
- A->m_phy_flagA80 = false;
+ A->bSkipLineCol = false;
skipCollision = false;
altcollision = false;
@@ -1411,20 +1411,20 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
(B->IsVehicle() || B->IsPed()) &&
A->GetUp().z < 0.66f){
skipCollision = true;
- A->m_phy_flagA80 = true;
+ A->bSkipLineCol = true;
Aobj->m_pCollidingEntity = B;
}else if((A->IsVehicle() || A->IsPed()) &&
B->GetUp().z < 0.66f &&
IsTrafficLight(B->GetModelIndex())){
skipCollision = true;
- A->m_phy_flagA80 = true;
+ A->bSkipLineCol = true;
Bobj->m_pCollidingEntity = A;
}else if(A->IsObject() && B->IsVehicle()){
if(A->GetModelIndex() == MI_CAR_BUMPER || A->GetModelIndex() == MI_FILES)
skipCollision = true;
else if(Aobj->ObjectCreatedBy == TEMP_OBJECT ||
Aobj->bHasBeenDamaged ||
- !Aobj->bIsStatic){
+ !Aobj->IsStatic()){
if(Aobj->m_pCollidingEntity == B)
skipCollision = true;
else{
@@ -1443,7 +1443,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
skipCollision = true;
else if(Bobj->ObjectCreatedBy == TEMP_OBJECT ||
Bobj->bHasBeenDamaged ||
- !Bobj->bIsStatic){
+ !Bobj->IsStatic()){
if(Bobj->m_pCollidingEntity == A)
skipCollision = true;
else{
@@ -1460,18 +1460,18 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
skipCollision = true;
}else if(A->IsPed() && IsBodyPart(B->GetModelIndex())){
skipCollision = true;
- A->m_phy_flagA80 = true;
+ A->bSkipLineCol = true;
}else if(A->IsPed() && Aped->m_pCollidingEntity == B){
skipCollision = true;
if(!Aped->bKnockedUpIntoAir)
- A->m_phy_flagA80 = true;
+ A->bSkipLineCol = true;
}else if(B->IsPed() && Bped->m_pCollidingEntity == A){
skipCollision = true;
- A->m_phy_flagA80 = true;
+ A->bSkipLineCol = true;
}else if(A->GetModelIndex() == MI_RCBANDIT && (B->IsPed() || B->IsVehicle()) ||
B->GetModelIndex() == MI_RCBANDIT && (A->IsPed() || A->IsVehicle())){
skipCollision = true;
- A->m_phy_flagA80 = true;
+ A->bSkipLineCol = true;
}else if(A->IsPed() && B->IsObject() && Bobj->m_fUprootLimit > 0.0f)
altcollision = true;
@@ -1544,7 +1544,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
}else
adhesion = 0.0f;
}else if(A->IsVehicle()){
- if(A->m_status == STATUS_WRECKED)
+ if(A->GetStatus() == STATUS_WRECKED)
adhesion *= 3.0f;
else if(A->GetUp().z > 0.3f)
adhesion = 0.0f;
@@ -1561,7 +1561,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
m_vecMoveSpeed += moveSpeed / numResponses;
m_vecTurnSpeed += turnSpeed / numResponses;
if(!CWorld::bNoMoreCollisionTorque &&
- A->m_status == STATUS_PLAYER && A->IsVehicle() &&
+ A->GetStatus() == STATUS_PLAYER && A->IsVehicle() &&
Abs(A->m_vecMoveSpeed.x) > 0.2f &&
Abs(A->m_vecMoveSpeed.y) > 0.2f){
A->m_vecMoveFriction.x += moveSpeed.x * -0.3f / numCollisions;
@@ -1713,8 +1713,8 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
Aobj->ObjectDamage(maxImpulseB);
}
- if(B->m_status == STATUS_SIMPLE){
- B->m_status = STATUS_PHYSICS;
+ if(B->GetStatus() == STATUS_SIMPLE){
+ B->SetStatus(STATUS_PHYSICS);
if(B->IsVehicle())
CCarCtrl::SwitchVehicleToRealPhysics((CVehicle*)B);
}
@@ -1758,7 +1758,7 @@ void
CPhysical::ProcessShift(void)
{
m_fDistanceTravelled = 0.0f;
- if(m_status == STATUS_SIMPLE){
+ if(GetStatus() == STATUS_SIMPLE){
bIsStuck = false;
bIsInSafePosition = true;
RemoveAndAdd();
@@ -1804,7 +1804,7 @@ CPhysical::ProcessCollision(void)
m_fDistanceTravelled = 0.0f;
m_bIsVehicleBeingShifted = false;
- m_phy_flagA80 = false;
+ bSkipLineCol = false;
if(!bUsesCollision){
bIsStuck = false;
@@ -1813,9 +1813,9 @@ CPhysical::ProcessCollision(void)
return;
}
- if(m_status == STATUS_SIMPLE){
- if(CheckCollision_SimpleCar() && m_status == STATUS_SIMPLE){
- m_status = STATUS_PHYSICS;
+ if(GetStatus() == STATUS_SIMPLE){
+ if(CheckCollision_SimpleCar() && GetStatus() == STATUS_SIMPLE){
+ SetStatus(STATUS_PHYSICS);
if(IsVehicle())
CCarCtrl::SwitchVehicleToRealPhysics((CVehicle*)this);
}
@@ -1840,14 +1840,14 @@ CPhysical::ProcessCollision(void)
n = NUMSTEPS(0.3f);
step = savedTimeStep / n;
}else if(IsVehicle() && distSq >= sq(0.4f)){
- if(m_status == STATUS_PLAYER)
+ if(GetStatus() == STATUS_PLAYER)
n = NUMSTEPS(0.2f);
else
n = distSq > 0.32f ? NUMSTEPS(0.3f) : NUMSTEPS(0.4f);
step = savedTimeStep / n;
}else if(IsObject()){
int responsecase = ((CObject*)this)->m_nSpecialCollisionResponseCases;
- if(responsecase == COLLRESPONSE_CHANGE_MODEL){
+ if(responsecase == COLLRESPONSE_LAMPOST){
CVector speedUp = { 0.0f, 0.0f, 0.0f };
CVector speedDown = { 0.0f, 0.0f, 0.0f };
speedUp.z = GetBoundRadius();
@@ -1866,7 +1866,7 @@ CPhysical::ProcessCollision(void)
n = NUMSTEPS(0.09f);
step = savedTimeStep / n;
}
- }else if(responsecase == COLLRESPONSE_SPLIT_MODEL || responsecase == COLLRESPONSE_CHANGE_THEN_SMASH){
+ }else if(responsecase == COLLRESPONSE_SMALLBOX || responsecase == COLLRESPONSE_FENCEPART){
if(distSq >= sq(0.15f)){
n = NUMSTEPS(0.15f);
step = savedTimeStep / n;
@@ -1886,7 +1886,7 @@ CPhysical::ProcessCollision(void)
// TODO: get rid of copy paste?
if(CheckCollision()){
if(IsPed() && m_vecMoveSpeed.z == 0.0f &&
- !ped->m_ped_flagA2 &&
+ !ped->bWasStanding &&
ped->bIsStanding)
savedMatrix.GetPosition().z = GetPosition().z;
GetMatrix() = savedMatrix;
@@ -1894,7 +1894,7 @@ CPhysical::ProcessCollision(void)
return;
}
if(IsPed() && m_vecMoveSpeed.z == 0.0f &&
- !ped->m_ped_flagA2 &&
+ !ped->bWasStanding &&
ped->bIsStanding)
savedMatrix.GetPosition().z = GetPosition().z;
GetMatrix() = savedMatrix;
@@ -1917,11 +1917,11 @@ CPhysical::ProcessCollision(void)
ApplyTurnSpeed();
GetMatrix().Reorthogonalise();
m_bIsVehicleBeingShifted = false;
- m_phy_flagA80 = false;
+ bSkipLineCol = false;
if(!m_vecMoveSpeed.IsZero() ||
!m_vecTurnSpeed.IsZero() ||
bHitByTrain ||
- m_status == STATUS_PLAYER || IsPed() && ped->IsPlayer()){
+ GetStatus() == STATUS_PLAYER || IsPed() && ped->IsPlayer()){
if(IsVehicle())
((CVehicle*)this)->bVehicleColProcessed = true;
if(CheckCollision()){
@@ -1931,7 +1931,7 @@ CPhysical::ProcessCollision(void)
}
bHitByTrain = false;
m_fDistanceTravelled = (GetPosition() - savedMatrix.GetPosition()).Magnitude();
- m_phy_flagA80 = false;
+ bSkipLineCol = false;
bIsStuck = false;
bIsInSafePosition = true;
diff --git a/src/entities/Physical.h b/src/entities/Physical.h
index fa5ada05..c84686ed 100644
--- a/src/entities/Physical.h
+++ b/src/entities/Physical.h
@@ -58,7 +58,7 @@ public:
uint8 m_phy_flagA10 : 1; // unused
uint8 m_phy_flagA20 : 1; // unused
uint8 bHitByTrain : 1;
- uint8 m_phy_flagA80 : 1;
+ uint8 bSkipLineCol : 1;
uint8 m_nSurfaceTouched;
int8 m_nZoneLevel;
@@ -160,4 +160,5 @@ public:
bool CheckCollision(void);
bool CheckCollision_SimpleCar(void);
};
-static_assert(sizeof(CPhysical) == 0x128, "CPhysical: error");
+
+VALIDATE_SIZE(CPhysical, 0x128);
diff --git a/src/entities/Treadable.h b/src/entities/Treadable.h
index 9e4de59a..c3160f47 100644
--- a/src/entities/Treadable.h
+++ b/src/entities/Treadable.h
@@ -12,4 +12,6 @@ public:
bool GetIsATreadable(void) { return true; }
};
-static_assert(sizeof(CTreadable) == 0x94, "CTreadable: error");
+
+VALIDATE_SIZE(CTreadable, 0x94);
+