summaryrefslogtreecommitdiffstats
path: root/src/vehicles
diff options
context:
space:
mode:
authorFire-Head <Fire-Head@users.noreply.github.com>2020-12-07 19:50:18 +0100
committerFire-Head <Fire-Head@users.noreply.github.com>2020-12-07 19:50:18 +0100
commit87bca997a45c3364b3994fddb40230ef20a56d90 (patch)
tree1a4c6997451d097141386bf246dfeef97dd2794c /src/vehicles
parentps2 hud, restore original code (diff)
parentFixing the Ghost vehicle name. (diff)
downloadre3-87bca997a45c3364b3994fddb40230ef20a56d90.tar
re3-87bca997a45c3364b3994fddb40230ef20a56d90.tar.gz
re3-87bca997a45c3364b3994fddb40230ef20a56d90.tar.bz2
re3-87bca997a45c3364b3994fddb40230ef20a56d90.tar.lz
re3-87bca997a45c3364b3994fddb40230ef20a56d90.tar.xz
re3-87bca997a45c3364b3994fddb40230ef20a56d90.tar.zst
re3-87bca997a45c3364b3994fddb40230ef20a56d90.zip
Diffstat (limited to 'src/vehicles')
-rw-r--r--src/vehicles/Automobile.cpp89
-rw-r--r--src/vehicles/Boat.cpp2
-rw-r--r--src/vehicles/Cranes.cpp6
-rw-r--r--src/vehicles/HandlingMgr.cpp26
-rw-r--r--src/vehicles/HandlingMgr.h21
-rw-r--r--src/vehicles/Heli.cpp11
-rw-r--r--src/vehicles/Plane.cpp7
-rw-r--r--src/vehicles/Train.cpp2
-rw-r--r--src/vehicles/Vehicle.cpp9
-rw-r--r--src/vehicles/Vehicle.h11
10 files changed, 168 insertions, 16 deletions
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index 95a68769..ec71f690 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -75,7 +75,7 @@ CAutomobile::CAutomobile(int32 id, uint8 CreatedBy)
SetModelIndex(id);
- pHandling = mod_HandlingManager.GetHandlingData((eHandlingId)mi->m_handlingId);
+ pHandling = mod_HandlingManager.GetHandlingData((tVehicleType)mi->m_handlingId);
m_auto_unused1 = 20.0f;
m_auto_unused2 = 0;
@@ -4183,6 +4183,93 @@ CAutomobile::HasCarStoppedBecauseOfLight(void)
}
void
+CPed::DeadPedMakesTyresBloody(void)
+{
+ int minX = CWorld::GetSectorIndexX(GetPosition().x - 2.0f);
+ if (minX < 0) minX = 0;
+ int minY = CWorld::GetSectorIndexY(GetPosition().y - 2.0f);
+ if (minY < 0) minY = 0;
+ int maxX = CWorld::GetSectorIndexX(GetPosition().x + 2.0f);
+ if (maxX > NUMSECTORS_X-1) maxX = NUMSECTORS_X-1;
+ int maxY = CWorld::GetSectorIndexY(GetPosition().y + 2.0f);
+ if (maxY > NUMSECTORS_Y-1) maxY = NUMSECTORS_Y-1;
+
+ CWorld::AdvanceCurrentScanCode();
+
+ for (int curY = minY; curY <= maxY; curY++) {
+ for (int curX = minX; curX <= maxX; curX++) {
+ CSector *sector = CWorld::GetSector(curX, curY);
+ MakeTyresMuddySectorList(sector->m_lists[ENTITYLIST_VEHICLES]);
+ MakeTyresMuddySectorList(sector->m_lists[ENTITYLIST_VEHICLES_OVERLAP]);
+ }
+ }
+}
+
+void
+CPed::MakeTyresMuddySectorList(CPtrList &list)
+{
+ for (CPtrNode *node = list.first; node; node = node->next) {
+ CVehicle *veh = (CVehicle*)node->item;
+ if (veh->IsCar() && veh->m_scanCode != CWorld::GetCurrentScanCode()) {
+ veh->m_scanCode = CWorld::GetCurrentScanCode();
+
+ if (Abs(GetPosition().x - veh->GetPosition().x) < 10.0f) {
+
+ if (Abs(GetPosition().y - veh->GetPosition().y) < 10.0f
+ && veh->m_vecMoveSpeed.MagnitudeSqr2D() > 0.05f) {
+
+ for(int wheel = 0; wheel < 4; wheel++) {
+
+ if (!((CAutomobile*)veh)->m_aWheelSkidmarkBloody[wheel]
+ && ((CAutomobile*)veh)->m_aSuspensionSpringRatio[wheel] < 1.0f) {
+
+ CColModel *vehCol = veh->GetModelInfo()->GetColModel();
+ CVector approxWheelOffset;
+ switch (wheel) {
+ case 0:
+ approxWheelOffset = CVector(-vehCol->boundingBox.max.x, vehCol->boundingBox.max.y, 0.0f);
+ break;
+ case 1:
+ approxWheelOffset = CVector(-vehCol->boundingBox.max.x, vehCol->boundingBox.min.y, 0.0f);
+ break;
+ case 2:
+ approxWheelOffset = CVector(vehCol->boundingBox.max.x, vehCol->boundingBox.max.y, 0.0f);
+ break;
+ case 3:
+ approxWheelOffset = CVector(vehCol->boundingBox.max.x, vehCol->boundingBox.min.y, 0.0f);
+ break;
+ default:
+ break;
+ }
+
+ // I hope so
+ CVector wheelPos = veh->GetMatrix() * approxWheelOffset;
+ if (Abs(wheelPos.z - GetPosition().z) < 2.0f) {
+
+ if ((wheelPos - GetPosition()).MagnitudeSqr2D() < 1.0f) {
+ if (CGame::nastyGame) {
+ ((CAutomobile*)veh)->m_aWheelSkidmarkBloody[wheel] = true;
+ DMAudio.PlayOneShot(veh->m_audioEntityId, SOUND_SPLATTER, 0.0f);
+ }
+ veh->ApplyMoveForce(CVector(0.0f, 0.0f, 50.0f));
+
+ CVector vehAndWheelDist = wheelPos - veh->GetPosition();
+ veh->ApplyTurnForce(CVector(0.0f, 0.0f, 50.0f), vehAndWheelDist);
+
+ if (veh == FindPlayerVehicle()) {
+ CPad::GetPad(0)->StartShake(300, 70);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void
CAutomobile::SetBusDoorTimer(uint32 timer, uint8 type)
{
if(timer < 1000)
diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp
index dfe9d1d9..aba48bad 100644
--- a/src/vehicles/Boat.cpp
+++ b/src/vehicles/Boat.cpp
@@ -50,7 +50,7 @@ CBoat::CBoat(int mi, uint8 owner) : CVehicle(owner)
m_fMovingRotation = 0.0f;
SetModelIndex(mi);
- pHandling = mod_HandlingManager.GetHandlingData((eHandlingId)minfo->m_handlingId);
+ pHandling = mod_HandlingManager.GetHandlingData((tVehicleType)minfo->m_handlingId);
minfo->ChooseVehicleColour(m_currentColour1, m_currentColour2);
m_fMass = pHandling->fMass;
diff --git a/src/vehicles/Cranes.cpp b/src/vehicles/Cranes.cpp
index 757974a6..564f493d 100644
--- a/src/vehicles/Cranes.cpp
+++ b/src/vehicles/Cranes.cpp
@@ -639,11 +639,11 @@ void CCranes::Save(uint8* buf, uint32* size)
for (int i = 0; i < NUM_CRANES; i++) {
CCrane *pCrane = WriteSaveBuf(buf, aCranes[i]);
if (pCrane->m_pCraneEntity != nil)
- pCrane->m_pCraneEntity = (CBuilding*)(CPools::GetBuildingPool()->GetJustIndex(pCrane->m_pCraneEntity) + 1);
+ pCrane->m_pCraneEntity = (CBuilding*)(CPools::GetBuildingPool()->GetJustIndex_NoFreeAssert(pCrane->m_pCraneEntity) + 1);
if (pCrane->m_pHook != nil)
- pCrane->m_pHook = (CObject*)(CPools::GetObjectPool()->GetJustIndex(pCrane->m_pHook) + 1);
+ pCrane->m_pHook = (CObject*)(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert(pCrane->m_pHook) + 1);
if (pCrane->m_pVehiclePickedUp != nil)
- pCrane->m_pVehiclePickedUp = (CVehicle*)(CPools::GetVehiclePool()->GetJustIndex(pCrane->m_pVehiclePickedUp) + 1);
+ pCrane->m_pVehiclePickedUp = (CVehicle*)(CPools::GetVehiclePool()->GetJustIndex_NoFreeAssert(pCrane->m_pVehiclePickedUp) + 1);
}
VALIDATESAVEBUF(*size);
diff --git a/src/vehicles/HandlingMgr.cpp b/src/vehicles/HandlingMgr.cpp
index 5beed29e..18a2481e 100644
--- a/src/vehicles/HandlingMgr.cpp
+++ b/src/vehicles/HandlingMgr.cpp
@@ -127,7 +127,7 @@ cHandlingDataMgr::LoadHandlingData(void)
handlingId = FindExactWord(word, (const char*)VehicleNames, 14, NUMHANDLINGS);
assert(handlingId >= 0 && handlingId < NUMHANDLINGS);
handling = &HandlingData[handlingId];
- handling->nIdentifier = (eHandlingId)handlingId;
+ handling->nIdentifier = (tVehicleType)handlingId;
break;
case 1: handling->fMass = strtod(word, nil); break;
case 2: handling->Dimension.x = strtod(word, nil); break;
@@ -237,3 +237,27 @@ cHandlingDataMgr::GetHandlingId(const char *name)
break;
return i;
}
+
+void
+cHandlingDataMgr::ConvertDataToWorldUnits(tHandlingData *handling)
+{
+ // TODO: mobile code
+}
+
+void
+cHandlingDataMgr::RangeCheck(tHandlingData *handling)
+{
+ // TODO: mobile code
+}
+
+void
+cHandlingDataMgr::ModifyHandlingValue(CVehicle *, const tVehicleType &, const tField &, const bool &)
+{
+ // TODO: mobile code
+}
+
+void
+cHandlingDataMgr::DisplayHandlingData(CVehicle *, tHandlingData *, uint8, bool)
+{
+ // TODO: mobile code
+} \ No newline at end of file
diff --git a/src/vehicles/HandlingMgr.h b/src/vehicles/HandlingMgr.h
index 10e25573..4d3b8389 100644
--- a/src/vehicles/HandlingMgr.h
+++ b/src/vehicles/HandlingMgr.h
@@ -2,7 +2,7 @@
#include "Transmission.h"
-enum eHandlingId
+enum tVehicleType
{
HANDLING_LANDSTAL,
HANDLING_IDAHO,
@@ -65,6 +65,11 @@ enum eHandlingId
NUMHANDLINGS
};
+enum tField : uint32 // most likely a handling field enum, never used so :shrug:
+{
+
+};
+
enum
{
HANDLING_1G_BOOST = 1,
@@ -87,7 +92,7 @@ enum
struct tHandlingData
{
- eHandlingId nIdentifier;
+ tVehicleType nIdentifier;
float fMass;
float fInvMass;
float fTurnMass;
@@ -118,6 +123,8 @@ struct tHandlingData
};
VALIDATE_SIZE(tHandlingData, 0xD8);
+class CVehicle;
+
class cHandlingDataMgr
{
float field_0; // unused it seems
@@ -135,11 +142,15 @@ public:
void Initialise(void);
void LoadHandlingData(void);
int FindExactWord(const char *word, const char *words, int wordLen, int numWords);
+ void ConvertDataToWorldUnits(tHandlingData *handling);
void ConvertDataToGameUnits(tHandlingData *handling);
+ void RangeCheck(tHandlingData *handling);
+ void ModifyHandlingValue(CVehicle *, const tVehicleType &, const tField &, const bool &);
+ void DisplayHandlingData(CVehicle *, tHandlingData *, uint8, bool);
int32 GetHandlingId(const char *name);
- tHandlingData *GetHandlingData(eHandlingId id) { return &HandlingData[id]; }
- bool HasRearWheelDrive(eHandlingId id) { return HandlingData[id].Transmission.nDriveType == 'R'; }
- bool HasFrontWheelDrive(eHandlingId id) { return HandlingData[id].Transmission.nDriveType == 'F'; }
+ tHandlingData *GetHandlingData(tVehicleType id) { return &HandlingData[id]; }
+ bool HasRearWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType == 'R'; }
+ bool HasFrontWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType == 'F'; }
};
VALIDATE_SIZE(cHandlingDataMgr, 0x3030);
extern cHandlingDataMgr mod_HandlingManager;
diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp
index e1f662d8..7008818b 100644
--- a/src/vehicles/Heli.cpp
+++ b/src/vehicles/Heli.cpp
@@ -52,7 +52,7 @@ CHeli::CHeli(int32 id, uint8 CreatedBy)
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(id);
m_vehType = VEHICLE_TYPE_HELI;
- pHandling = mod_HandlingManager.GetHandlingData((eHandlingId)mi->m_handlingId);
+ pHandling = mod_HandlingManager.GetHandlingData((tVehicleType)mi->m_handlingId);
SetModelIndex(id);
m_heliStatus = HELI_STATUS_HOVER;
m_pathState = 0;
@@ -778,8 +778,10 @@ CHeli::InitHelis(void)
for(i = 0; i < NUM_HELIS; i++)
pHelis[i] = nil;
+#if GTA_VERSION >= GTA3_PS2_160
((CVehicleModelInfo*)CModelInfo::GetModelInfo(MI_ESCAPE))->SetColModel(&CTempColModels::ms_colModelPed1);
((CVehicleModelInfo*)CModelInfo::GetModelInfo(MI_CHOPPER))->SetColModel(&CTempColModels::ms_colModelPed1);
+#endif
}
CHeli*
@@ -789,6 +791,13 @@ GenerateHeli(bool catalina)
CVector heliPos;
int i;
+#if GTA_VERSION < GTA3_PS2_160
+ if(catalina)
+ ((CVehicleModelInfo*)CModelInfo::GetModelInfo(MI_ESCAPE))->SetColModel(&CTempColModels::ms_colModelPed1);
+ else
+ ((CVehicleModelInfo*)CModelInfo::GetModelInfo(MI_CHOPPER))->SetColModel(&CTempColModels::ms_colModelPed1);
+#endif
+
if(catalina)
heli = new CHeli(MI_ESCAPE, PERMANENT_VEHICLE);
else
diff --git a/src/vehicles/Plane.cpp b/src/vehicles/Plane.cpp
index b8a957cf..532be938 100644
--- a/src/vehicles/Plane.cpp
+++ b/src/vehicles/Plane.cpp
@@ -15,6 +15,7 @@
#include "World.h"
#include "HandlingMgr.h"
#include "Plane.h"
+#include "MemoryHeap.h"
CPlaneNode *pPathNodes;
CPlaneNode *pPath2Nodes;
@@ -68,7 +69,7 @@ CPlane::CPlane(int32 id, uint8 CreatedBy)
{
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(id);
m_vehType = VEHICLE_TYPE_PLANE;
- pHandling = mod_HandlingManager.GetHandlingData((eHandlingId)mi->m_handlingId);
+ pHandling = mod_HandlingManager.GetHandlingData((tVehicleType)mi->m_handlingId);
SetModelIndex(id);
m_fMass = 100000000.0f;
@@ -551,9 +552,11 @@ CPlane::ProcessControl(void)
if(m_rwObject && RwObjectGetType(m_rwObject) == rpCLUMP){
DeleteRwObject();
if(mi->m_planeLodId != -1){
+ PUSH_MEMID(MEMID_WORLD);
m_rwObject = CModelInfo::GetModelInfo(mi->m_planeLodId)->CreateInstance();
+ POP_MEMID();
if(m_rwObject)
- m_matrix.Attach(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic*)m_rwObject)));
+ m_matrix.AttachRW(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic*)m_rwObject)));
}
}
}else if(CStreaming::HasModelLoaded(GetModelIndex())){
diff --git a/src/vehicles/Train.cpp b/src/vehicles/Train.cpp
index 26d0dee7..4250f6f4 100644
--- a/src/vehicles/Train.cpp
+++ b/src/vehicles/Train.cpp
@@ -43,7 +43,7 @@ CTrain::CTrain(int32 id, uint8 CreatedBy)
{
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(id);
m_vehType = VEHICLE_TYPE_TRAIN;
- pHandling = mod_HandlingManager.GetHandlingData((eHandlingId)mi->m_handlingId);
+ pHandling = mod_HandlingManager.GetHandlingData((tVehicleType)mi->m_handlingId);
SetModelIndex(id);
Doors[0].Init(0.8f, 0.0f, 1, 0);
diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp
index bc77b011..9adcf148 100644
--- a/src/vehicles/Vehicle.cpp
+++ b/src/vehicles/Vehicle.cpp
@@ -405,7 +405,7 @@ CVehicle::FlyingControl(eFlightModel flightModel)
else
fThrust = fThrustVar * (CPad::GetPad(0)->GetAccelerate() - 2 * CPad::GetPad(0)->GetBrake()) / 255.0f + 0.95f;
fThrust -= fRotorFallOff * DotProduct(m_vecMoveSpeed, GetUp());
-#ifdef GTA3_1_1_PATCH
+#if GTA_VERSION >= GTA3_PC_11
if (fThrust > 0.9f && GetPosition().z > 80.0f)
fThrust = 0.9f;
#endif
@@ -582,6 +582,13 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon
}
}
+void
+CVehicle::ProcessBikeWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelContactSpeed, CVector &wheelContactPoint, int32 wheelsOnGround, float thrust,
+ float brake, float adhesion, int8 wheelId, float *wheelSpeed, tWheelState *wheelState, eBikeWheelSpecial special, uint16 wheelStatus)
+{
+ // TODO: mobile code
+}
+
float
CVehicle::ProcessWheelRotation(tWheelState state, const CVector &fwd, const CVector &speed, float radius)
{
diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h
index 999ee002..3933f1dd 100644
--- a/src/vehicles/Vehicle.h
+++ b/src/vehicles/Vehicle.h
@@ -103,6 +103,15 @@ enum eFlightModel
FLIGHT_MODEL_SEAPLANE
};
+// TODO: what is this even?
+enum eBikeWheelSpecial {
+ BIKE_WHEELSPEC_0, // both wheels on ground
+ BIKE_WHEELSPEC_1, // rear wheel on ground
+ BIKE_WHEELSPEC_2, // only front wheel on ground
+ BIKE_WHEELSPEC_3, // can't happen
+};
+
+
class CVehicle : public CPhysical
{
public:
@@ -237,6 +246,8 @@ public:
void FlyingControl(eFlightModel flightModel);
void ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelContactSpeed, CVector &wheelContactPoint,
int32 wheelsOnGround, float thrust, float brake, float adhesion, int8 wheelId, float *wheelSpeed, tWheelState *wheelState, uint16 wheelStatus);
+ void ProcessBikeWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelContactSpeed, CVector &wheelContactPoint, int32 wheelsOnGround, float thrust,
+ float brake, float adhesion, int8 wheelId, float *wheelSpeed, tWheelState *wheelState, eBikeWheelSpecial special, uint16 wheelStatus);
void ExtinguishCarFire(void);
void ProcessDelayedExplosion(void);
float ProcessWheelRotation(tWheelState state, const CVector &fwd, const CVector &speed, float radius);