summaryrefslogtreecommitdiffstats
path: root/src/vehicles
diff options
context:
space:
mode:
Diffstat (limited to 'src/vehicles')
-rw-r--r--src/vehicles/Automobile.cpp192
-rw-r--r--src/vehicles/Automobile.h8
-rw-r--r--src/vehicles/Bike.cpp31
-rw-r--r--src/vehicles/Bike.h1
-rw-r--r--src/vehicles/Boat.cpp36
-rw-r--r--src/vehicles/CarGen.cpp2
-rw-r--r--src/vehicles/Cranes.cpp8
-rw-r--r--src/vehicles/Cranes.h10
-rw-r--r--src/vehicles/Floater.cpp2
-rw-r--r--src/vehicles/HandlingMgr.cpp37
-rw-r--r--src/vehicles/HandlingMgr.h14
-rw-r--r--src/vehicles/Heli.cpp8
-rw-r--r--src/vehicles/Heli.h3
-rw-r--r--src/vehicles/Plane.cpp11
-rw-r--r--src/vehicles/Train.cpp2
-rw-r--r--src/vehicles/Transmission.cpp4
-rw-r--r--src/vehicles/Transmission.h2
-rw-r--r--src/vehicles/Vehicle.cpp52
-rw-r--r--src/vehicles/Vehicle.h24
19 files changed, 252 insertions, 195 deletions
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index 251dac30..961b8108 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -49,8 +49,7 @@
#include "Object.h"
#include "Automobile.h"
#include "Bike.h"
-
-//--MIAMI: file done
+#include "Wanted.h"
bool bAllCarCheat;
@@ -252,12 +251,15 @@ CVector vecHunterRocketPos(2.5f, 1.0f, -0.5f);
CVector vecDAMAGE_ENGINE_POS_SMALL(-0.1f, -0.1f, 0.0f);
CVector vecDAMAGE_ENGINE_POS_BIG(-0.5f, -0.3f, 0.0f);
+#pragma optimize("", off) // a workaround for another compiler bug
+
void
CAutomobile::ProcessControl(void)
{
int i;
float wheelRot;
CColModel *colModel;
+ float brake = 0.0f;
if(bUsingSpecialColModel)
colModel = &CWorld::Players[CWorld::PlayerInFocus].m_ColModel;
@@ -285,17 +287,17 @@ CAutomobile::ProcessControl(void)
// Improve grip of vehicles in certain cases
bool strongGrip1 = false;
bool strongGrip2 = false;
- if(FindPlayerVehicle() && this != FindPlayerVehicle() &&
+ if(FindPlayerVehicle() && this != FindPlayerVehicle() && FindPlayerPed()->m_pWanted->GetWantedLevel() > 3 &&
(AutoPilot.m_nCarMission == MISSION_RAMPLAYER_FARAWAY || AutoPilot.m_nCarMission == MISSION_RAMPLAYER_CLOSE ||
- AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_FARAWAY || AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_CLOSE)){
- if(FindPlayerSpeed().Magnitude() > 0.3f){
- strongGrip1 = true;
- if(FindPlayerSpeed().Magnitude() > 0.4f &&
- m_vecMoveSpeed.Magnitude() < 0.3f)
- strongGrip2 = true;
- else if((GetPosition() - FindPlayerCoors()).Magnitude() > 50.0f)
- strongGrip2 = true;
- }
+ AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_FARAWAY || AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_CLOSE) &&
+ FindPlayerSpeed().Magnitude() > 0.3f){
+
+ strongGrip1 = true;
+ if(FindPlayerSpeed().Magnitude() > 0.4f &&
+ m_vecMoveSpeed.Magnitude() < 0.3f)
+ strongGrip2 = true;
+ else if((GetPosition() - FindPlayerCoors()).Magnitude() > 50.0f)
+ strongGrip2 = true;
}else if(GetModelIndex() == MI_RCBANDIT && GetStatus() != STATUS_PLAYER_REMOTE)
strongGrip1 = true;
@@ -448,7 +450,7 @@ CAutomobile::ProcessControl(void)
m_fBrakePedal = 1.0f;
m_fGasPedal = 0.0f;
}
- if(CPad::GetPad(0)->WeaponJustDown())
+ if(CPad::GetPad(0)->CarGunJustDown())
ActivateBomb();
break;
@@ -680,7 +682,6 @@ CAutomobile::ProcessControl(void)
AutoPilot.m_nCarMission == MISSION_PLANE_FLYTOCOORS)
skipPhysics = true;
- float brake;
if(skipPhysics){
bHasContacted = false;
bIsInSafePosition = false;
@@ -735,7 +736,7 @@ CAutomobile::ProcessControl(void)
float fwdSpeed = Abs(DotProduct(m_vecMoveSpeed, GetForward()));
CVector contactPoints[4]; // relative to model
CVector contactSpeeds[4]; // speed at contact points
- CVector springDirections[4]; // normalized, in model space
+ CVector springDirections[4]; // normalized, in world space
for(i = 0; i < 4; i++){
// Set spring under certain circumstances
@@ -809,7 +810,7 @@ CAutomobile::ProcessControl(void)
// dampen springs
for(i = 0; i < 4; i++)
- if(m_aSuspensionSpringRatio[i] < 1.0f)
+ if(m_aSuspensionSpringRatio[i] < 0.99999f)
ApplySpringDampening(pHandling->fSuspensionDampingLevel,
springDirections[i], contactPoints[i], contactSpeeds[i]);
@@ -835,11 +836,16 @@ CAutomobile::ProcessControl(void)
if(bAudioChangingGear && m_fGasPedal > 0.4f && m_fBrakePedal < 0.1f && fwdSpeed > 0.15f &&
this == FindPlayerVehicle() && TheCamera.Cams[TheCamera.ActiveCam].Mode != CCam::MODE_1STPERSON){
- if(GetStatus() == STATUS_PLAYER && pHandling->Flags & HANDLING_IS_BUS){
+ if(GetStatus() == STATUS_PLAYER && !(pHandling->Flags & HANDLING_IS_BUS)){
if(m_nBusDoorTimerEnd == 0)
m_nBusDoorTimerEnd = 1000;
- else if(m_nBusDoorTimerEnd > CTimer::GetTimeStepInMilliseconds())
- m_nBusDoorTimerEnd -= CTimer::GetTimeStepInMilliseconds();
+ else {
+ uint32 timeStepInMs = CTimer::GetTimeStepInMilliseconds();
+ if(m_nBusDoorTimerEnd > timeStepInMs)
+ m_nBusDoorTimerEnd -= timeStepInMs;
+ else
+ m_nBusDoorTimerEnd = 0;
+ }
}
if((m_aSuspensionSpringRatio[0] < 1.0f || m_aSuspensionSpringRatio[2] < 1.0f) &&
@@ -850,7 +856,7 @@ CAutomobile::ProcessControl(void)
brake = m_fBrakePedal * pHandling->fBrakeDeceleration * CTimer::GetTimeStep();
bool neutralHandling = GetStatus() != STATUS_PLAYER && GetStatus() != STATUS_PLAYER_REMOTE && (pHandling->Flags & HANDLING_NEUTRALHANDLING);
float brakeBiasFront = neutralHandling ? 1.0f : 2.0f*pHandling->fBrakeBias;
- float brakeBiasRear = neutralHandling ? 1.0f : 2.0f*(1.0f-pHandling->fBrakeBias);
+ float brakeBiasRear = neutralHandling ? 1.0f : 2.0f-pHandling->fBrakeBias; // looks like a bug, but it was correct in III...
float tractionBiasFront = neutralHandling ? 1.0f : 2.0f*pHandling->fTractionBias;
float tractionBiasRear = neutralHandling ? 1.0f : 2.0f-tractionBiasFront;
@@ -918,10 +924,10 @@ CAutomobile::ProcessControl(void)
CVector wheelFwd, wheelRight, tmp;
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] > 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
wheelFwd = GetForward();
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_LEFT].normal)*m_aWheelColPoints[CARWHEEL_FRONT_LEFT].normal;
@@ -938,7 +944,7 @@ CAutomobile::ProcessControl(void)
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceB);
WheelState[CARWHEEL_FRONT_LEFT] = m_aWheelState[CARWHEEL_FRONT_LEFT];
- if(Damage.GetWheelStatus(VEHWHEEL_FRONT_LEFT) == WHEEL_STATUS_BURST)
+ if(Damage.GetWheelStatus(CARWHEEL_FRONT_LEFT) == WHEEL_STATUS_BURST)
ProcessWheel(wheelFwd, wheelRight,
contactSpeeds[CARWHEEL_FRONT_LEFT], contactPoints[CARWHEEL_FRONT_LEFT],
m_nWheelsOnGround, fThrust,
@@ -961,10 +967,10 @@ CAutomobile::ProcessControl(void)
}
if(m_aWheelTimer[CARWHEEL_FRONT_RIGHT] > 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
wheelFwd = GetForward();
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].normal)*m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].normal;
@@ -981,7 +987,7 @@ CAutomobile::ProcessControl(void)
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceB);
WheelState[CARWHEEL_FRONT_RIGHT] = m_aWheelState[CARWHEEL_FRONT_RIGHT];
- if(Damage.GetWheelStatus(VEHWHEEL_FRONT_RIGHT) == WHEEL_STATUS_BURST)
+ if(Damage.GetWheelStatus(CARWHEEL_FRONT_RIGHT) == WHEEL_STATUS_BURST)
ProcessWheel(wheelFwd, wheelRight,
contactSpeeds[CARWHEEL_FRONT_RIGHT], contactPoints[CARWHEEL_FRONT_RIGHT],
m_nWheelsOnGround, fThrust,
@@ -1008,9 +1014,7 @@ CAutomobile::ProcessControl(void)
if(!IsRealHeli()){
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] <= 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_FRONT_LEFT] *= 0.95f;
- else{
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_FRONT_LEFT] < 2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] -= 0.2f;
@@ -1018,13 +1022,13 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_FRONT_LEFT] > -2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_FRONT_LEFT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_FRONT_LEFT] += m_aWheelSpeed[CARWHEEL_FRONT_LEFT];
}
if(m_aWheelTimer[CARWHEEL_FRONT_RIGHT] <= 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] *= 0.95f;
- else{
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] < 2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] -= 0.2f;
@@ -1032,6 +1036,8 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] > -2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_FRONT_RIGHT] += m_aWheelSpeed[CARWHEEL_FRONT_RIGHT];
}
@@ -1042,7 +1048,7 @@ CAutomobile::ProcessControl(void)
if(m_aWheelTimer[CARWHEEL_REAR_LEFT] > 0.0f || m_aWheelTimer[CARWHEEL_REAR_RIGHT] > 0.0f){
CVector wheelFwd = GetForward();
- CVector wheelRight = GetRight();
+ CVector wheelRight = GetRight(); // overwritten for resp. wheel
float rearBrake = brake;
float rearTraction = traction;
@@ -1058,7 +1064,7 @@ CAutomobile::ProcessControl(void)
if(m_fTireTemperature > 2.0f)
m_fTireTemperature = 2.0f;
}
- }else if(m_doingBurnout && !mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier)){
+ }else if(m_doingBurnout && mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier)){
rearBrake = 0.0f;
rearTraction = 0.0f;
// BUG: missing timestep
@@ -1068,12 +1074,11 @@ CAutomobile::ProcessControl(void)
}
if(m_aWheelTimer[CARWHEEL_REAR_LEFT] > 0.0f){
- if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
- wheelFwd = GetForward();
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_REAR_LEFT].normal)*m_aWheelColPoints[CARWHEEL_REAR_LEFT].normal;
wheelFwd.Normalise();
wheelRight = CrossProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_REAR_LEFT].normal);
@@ -1085,7 +1090,7 @@ CAutomobile::ProcessControl(void)
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_REAR_LEFT].surfaceB);
WheelState[CARWHEEL_REAR_LEFT] = m_aWheelState[CARWHEEL_REAR_LEFT];
- if(Damage.GetWheelStatus(VEHWHEEL_REAR_LEFT) == WHEEL_STATUS_BURST)
+ if(Damage.GetWheelStatus(CARWHEEL_REAR_LEFT) == WHEEL_STATUS_BURST)
ProcessWheel(wheelFwd, wheelRight,
contactSpeeds[CARWHEEL_REAR_LEFT], contactPoints[CARWHEEL_REAR_LEFT],
m_nWheelsOnGround, fThrust,
@@ -1110,16 +1115,15 @@ CAutomobile::ProcessControl(void)
#ifdef FIX_BUGS
// Shouldn't we reset these after the left wheel?
wheelFwd = GetForward();
- wheelRight = GetRight();
+ wheelRight = GetRight(); // actually useless
#endif
if(m_aWheelTimer[CARWHEEL_REAR_RIGHT] > 0.0f){
- if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
- wheelFwd = GetForward();
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_REAR_RIGHT].normal)*m_aWheelColPoints[CARWHEEL_REAR_RIGHT].normal;
wheelFwd.Normalise();
wheelRight = CrossProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_REAR_RIGHT].normal);
@@ -1131,7 +1135,7 @@ CAutomobile::ProcessControl(void)
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_REAR_RIGHT].surfaceB);
WheelState[CARWHEEL_REAR_RIGHT] = m_aWheelState[CARWHEEL_REAR_RIGHT];
- if(Damage.GetWheelStatus(VEHWHEEL_REAR_RIGHT) == WHEEL_STATUS_BURST)
+ if(Damage.GetWheelStatus(CARWHEEL_REAR_RIGHT) == WHEEL_STATUS_BURST)
ProcessWheel(wheelFwd, wheelRight,
contactSpeeds[CARWHEEL_REAR_RIGHT], contactPoints[CARWHEEL_REAR_RIGHT],
m_nWheelsOnGround, fThrust,
@@ -1154,7 +1158,7 @@ CAutomobile::ProcessControl(void)
}
}
- if(m_doingBurnout && !mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) &&
+ if(m_doingBurnout && mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) &&
(m_aWheelState[CARWHEEL_REAR_LEFT] == WHEEL_STATE_SPINNING || m_aWheelState[CARWHEEL_REAR_RIGHT] == WHEEL_STATE_SPINNING)){
m_fTireTemperature += 0.001f*CTimer::GetTimeStep();
if(m_fTireTemperature > 3.0f)
@@ -1167,9 +1171,9 @@ CAutomobile::ProcessControl(void)
if(!IsRealHeli()){
if(m_aWheelTimer[CARWHEEL_REAR_LEFT] <= 0.0f){
- if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_REAR_LEFT] *= 0.95f;
- else{
+ if(bIsHandbrakeOn)
+ m_aWheelSpeed[CARWHEEL_REAR_LEFT] = 0.0f;
+ else if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_REAR_LEFT] < 2.0f)
m_aWheelSpeed[CARWHEEL_REAR_LEFT] -= 0.2f;
@@ -1177,13 +1181,15 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_REAR_LEFT] > -2.0f)
m_aWheelSpeed[CARWHEEL_REAR_LEFT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_REAR_LEFT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_REAR_LEFT] += m_aWheelSpeed[CARWHEEL_REAR_LEFT];
}
if(m_aWheelTimer[CARWHEEL_REAR_RIGHT] <= 0.0f){
- if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_REAR_RIGHT] *= 0.95f;
- else{
+ if(bIsHandbrakeOn)
+ m_aWheelSpeed[CARWHEEL_REAR_RIGHT] = 0.0f;
+ else if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_REAR_RIGHT] < 2.0f)
m_aWheelSpeed[CARWHEEL_REAR_RIGHT] -= 0.2f;
@@ -1191,6 +1197,8 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_REAR_RIGHT] > -2.0f)
m_aWheelSpeed[CARWHEEL_REAR_RIGHT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_REAR_RIGHT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_REAR_RIGHT] += m_aWheelSpeed[CARWHEEL_REAR_RIGHT];
}
@@ -1206,10 +1214,10 @@ CAutomobile::ProcessControl(void)
CVector wheelFwd, wheelRight, tmp;
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] > 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
wheelFwd = GetForward();
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_LEFT].normal)*m_aWheelColPoints[CARWHEEL_FRONT_LEFT].normal;
@@ -1226,7 +1234,7 @@ CAutomobile::ProcessControl(void)
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceB);
WheelState[CARWHEEL_FRONT_LEFT] = m_aWheelState[CARWHEEL_FRONT_LEFT];
- if(Damage.GetWheelStatus(VEHWHEEL_FRONT_LEFT) == WHEEL_STATUS_BURST)
+ if(Damage.GetWheelStatus(CARWHEEL_FRONT_LEFT) == WHEEL_STATUS_BURST)
ProcessWheel(wheelFwd, wheelRight,
contactSpeeds[CARWHEEL_FRONT_LEFT], contactPoints[CARWHEEL_FRONT_LEFT],
m_nWheelsOnGround, fThrust,
@@ -1249,10 +1257,10 @@ CAutomobile::ProcessControl(void)
}
if(m_aWheelTimer[CARWHEEL_FRONT_RIGHT] > 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier))
- fThrust = 0.0f;
- else
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier))
fThrust = acceleration;
+ else
+ fThrust = 0.0f;
wheelFwd = GetForward();
wheelFwd -= DotProduct(wheelFwd, m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].normal)*m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].normal;
@@ -1269,7 +1277,7 @@ CAutomobile::ProcessControl(void)
adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceB);
WheelState[CARWHEEL_FRONT_RIGHT] = m_aWheelState[CARWHEEL_FRONT_RIGHT];
- if(Damage.GetWheelStatus(VEHWHEEL_FRONT_RIGHT) == WHEEL_STATUS_BURST)
+ if(Damage.GetWheelStatus(CARWHEEL_FRONT_RIGHT) == WHEEL_STATUS_BURST)
ProcessWheel(wheelFwd, wheelRight,
contactSpeeds[CARWHEEL_FRONT_RIGHT], contactPoints[CARWHEEL_FRONT_RIGHT],
m_nWheelsOnGround, fThrust,
@@ -1296,9 +1304,7 @@ CAutomobile::ProcessControl(void)
if (!IsRealHeli()) {
if(m_aWheelTimer[CARWHEEL_FRONT_LEFT] <= 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_FRONT_LEFT] *= 0.95f;
- else{
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_FRONT_LEFT] < 2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] -= 0.2f;
@@ -1306,13 +1312,13 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_FRONT_LEFT] > -2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_LEFT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_FRONT_LEFT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_FRONT_LEFT] += m_aWheelSpeed[CARWHEEL_FRONT_LEFT];
}
if(m_aWheelTimer[CARWHEEL_FRONT_RIGHT] <= 0.0f){
- if(mod_HandlingManager.HasRearWheelDrive(pHandling->nIdentifier) || acceleration == 0.0f)
- m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] *= 0.95f;
- else{
+ if(mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) && acceleration != 0.0f){
if(acceleration > 0.0f){
if(m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] < 2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] -= 0.2f;
@@ -1320,6 +1326,8 @@ CAutomobile::ProcessControl(void)
if(m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] > -2.0f)
m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] += 0.1f;
}
+ }else{
+ m_aWheelSpeed[CARWHEEL_FRONT_RIGHT] *= 0.95f;
}
m_aWheelRotation[CARWHEEL_FRONT_RIGHT] += m_aWheelSpeed[CARWHEEL_FRONT_RIGHT];
}
@@ -1415,7 +1423,12 @@ CAutomobile::ProcessControl(void)
if (GetModelIndex() == MI_RCRAIDER || GetModelIndex() == MI_RCGOBLIN)
FlyingControl(FLIGHT_MODEL_RCHELI);
else if (m_nWheelsOnGround < 4 && !(GetModelIndex() == MI_SEASPAR && bTouchingWater) ||
- CPad::GetPad(0)->GetAccelerate() != 0 || CPad::GetPad(0)->GetCarGunUpDown() > 1.0f ||
+ CPad::GetPad(0)->GetAccelerate() != 0 ||
+#ifndef FREE_CAM
+ CPad::GetPad(0)->GetCarGunUpDown() > 1.0f ||
+#else
+ ((!CCamera::bFreeCam || (CCamera::bFreeCam && !CPad::IsAffectedByController)) && CPad::GetPad(0)->GetCarGunUpDown() > 1.0f) ||
+#endif
Abs(m_vecMoveSpeed.x) > 0.02f ||
Abs(m_vecMoveSpeed.y) > 0.02f ||
Abs(m_vecMoveSpeed.z) > 0.02f)
@@ -1674,8 +1687,8 @@ CAutomobile::ProcessControl(void)
Abs(m_vecMoveSpeed.y) < 0.005f &&
Abs(m_vecMoveSpeed.z) < 0.005f &&
!(m_fDamageImpulse > 0.0f && m_pDamageEntity == FindPlayerPed()) &&
- (m_aSuspensionSpringRatioPrev[0] < 1.0f && m_aSuspensionSpringRatioPrev[1] < 1.0f &&
- m_aSuspensionSpringRatioPrev[2] < 1.0f && m_aSuspensionSpringRatioPrev[3] < 1.0f)){
+ (m_aSuspensionSpringRatioPrev[0] < 1.0f || m_aSuspensionSpringRatioPrev[1] < 1.0f ||
+ m_aSuspensionSpringRatioPrev[2] < 1.0f || m_aSuspensionSpringRatioPrev[3] < 1.0f)){
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
m_vecTurnSpeed.z = 0.0f;
}
@@ -1699,6 +1712,8 @@ CAutomobile::ProcessControl(void)
}
}
+#pragma optimize("", on)
+
void
CAutomobile::Teleport(CVector pos)
{
@@ -1720,11 +1735,11 @@ CAutomobile::PreRender(void)
int i, j, n;
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex());
- if(GetModelIndex() == MI_RHINO && m_aCarNodes[CAR_BONNET]){
+ if(GetModelIndex() == MI_RHINO && m_aCarNodes[CAR_WINDSCREEN]){
// Rotate Rhino turret
CMatrix m;
CVector p;
- m.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_BONNET]));
+ m.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WINDSCREEN]));
p = m.GetPosition();
m.SetRotateZ(m_fCarGunLR);
m.Translate(p);
@@ -3188,7 +3203,11 @@ CAutomobile::ProcessControlInputs(uint8 pad)
// Brake if player isn't in control
// BUG: game always uses pad 0 here
+#ifdef FIX_BUGS
if(CPad::GetPad(pad)->ArePlayerControlsDisabled()){
+#else
+ if(CPad::GetPad(0)->ArePlayerControlsDisabled()){
+#endif
m_fBrakePedal = 1.0f;
bIsHandbrakeOn = true;
m_fGasPedal = 0.0f;
@@ -3206,7 +3225,7 @@ void
CAutomobile::FireTruckControl(void)
{
if(this == FindPlayerVehicle()){
- if(!CPad::GetPad(0)->GetWeapon())
+ if(!CPad::GetPad(0)->GetCarGunFired())
return;
#ifdef FREE_CAM
if (!CCamera::bFreeCam)
@@ -3835,7 +3854,7 @@ CAutomobile::DoDriveByShootings(void)
return;
CWeapon *weapon = pDriver->GetWeapon();
- if(CWeaponInfo::GetWeaponInfo(weapon->m_eWeaponType)->m_nWeaponSlot != 5)
+ if(CWeaponInfo::GetWeaponInfo(weapon->m_eWeaponType)->m_nWeaponSlot != WEAPONSLOT_SUBMACHINEGUN)
return;
weapon->Update(pDriver->m_audioEntityId, nil);
@@ -4862,10 +4881,10 @@ CAutomobile::BurstTyre(uint8 wheel, bool applyForces)
return;
switch(wheel){
- case CAR_PIECE_WHEEL_LF: wheel = VEHWHEEL_FRONT_LEFT; break;
- case CAR_PIECE_WHEEL_LR: wheel = VEHWHEEL_REAR_LEFT; break;
- case CAR_PIECE_WHEEL_RF: wheel = VEHWHEEL_FRONT_RIGHT; break;
- case CAR_PIECE_WHEEL_RR: wheel = VEHWHEEL_REAR_RIGHT; break;
+ case CAR_PIECE_WHEEL_LF: wheel = CARWHEEL_FRONT_LEFT; break;
+ case CAR_PIECE_WHEEL_RF: wheel = CARWHEEL_FRONT_RIGHT; break;
+ case CAR_PIECE_WHEEL_LR: wheel = CARWHEEL_REAR_LEFT; break;
+ case CAR_PIECE_WHEEL_RR: wheel = CARWHEEL_REAR_RIGHT; break;
}
int status = Damage.GetWheelStatus(wheel);
@@ -5074,7 +5093,7 @@ CAutomobile::BlowUpCarsInPath(void)
m_aCollisionRecords[i]->GetModelIndex() != MI_RHINO &&
!m_aCollisionRecords[i]->bRenderScorched){
if(this == FindPlayerVehicle())
- CEventList::RegisterEvent(EVENT_EXPLOSION, EVENT_ENTITY_VEHICLE, this, FindPlayerPed(), 2000);
+ CEventList::RegisterEvent(EVENT_EXPLOSION, EVENT_ENTITY_VEHICLE, m_aCollisionRecords[i], FindPlayerPed(), 2000);
((CVehicle*)m_aCollisionRecords[i])->BlowUpCar(this);
}
}
@@ -5110,7 +5129,6 @@ CAutomobile::HasCarStoppedBecauseOfLight(void)
return false;
}
-// --MIAMI: Done
void
CPed::DeadPedMakesTyresBloody(void)
{
@@ -5134,7 +5152,6 @@ CPed::DeadPedMakesTyresBloody(void)
}
}
-// --MIAMI: Done
void
CPed::MakeTyresMuddySectorList(CPtrList &list)
{
@@ -5245,7 +5262,6 @@ CPed::MakeTyresMuddySectorList(CPtrList &list)
}
}
-
void
CAutomobile::SetBusDoorTimer(uint32 timer, uint8 type)
{
@@ -5602,7 +5618,7 @@ CAutomobile::SetBumperDamage(int32 component, ePanels panel, bool noFlyingCompon
int status = Damage.GetPanelStatus(panel);
if(m_aCarNodes[component] == nil){
printf("Trying to damage component %d of %s\n",
- component, CModelInfo::GetModelInfo(GetModelIndex())->GetName());
+ component, CModelInfo::GetModelInfo(GetModelIndex())->GetModelName());
return;
}
if(status == PANEL_STATUS_SMASHED1){
@@ -5622,7 +5638,7 @@ 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());
+ component, CModelInfo::GetModelInfo(GetModelIndex())->GetModelName());
return;
}
@@ -5764,7 +5780,7 @@ CAutomobile::PopBoot(void)
case DOOR_STATUS_OK:
case DOOR_STATUS_SMASHED:
Doors[DOOR_BOOT].m_fAngle = Doors[DOOR_BOOT].m_fMinAngle;
- CMatrix mat(RwFrameGetMatrix(m_aCarNodes[DOOR_BOOT]));
+ CMatrix mat(RwFrameGetMatrix(m_aCarNodes[CAR_BOOT]));
CVector pos = mat.GetPosition();
float axes[3] = { 0.0f, 0.0f, 0.0f };
axes[Doors[DOOR_BOOT].m_nAxis] = Doors[DOOR_BOOT].m_fAngle;
@@ -5781,7 +5797,7 @@ CAutomobile::PopBootUsingPhysics(void)
case DOOR_STATUS_OK:
case DOOR_STATUS_SMASHED:
Damage.SetDoorStatus(DOOR_BOOT, DOOR_STATUS_SWINGING);
- Doors[DOOR_BOOT].m_fAngle = -2.0f;
+ Doors[DOOR_BOOT].m_fAngVel = -2.0f;
}
void
@@ -5809,7 +5825,7 @@ CAutomobile::KnockPedOutCar(eWeaponType weapon, uint16 door, CPed *ped)
if(ped == nil)
return;
- ped->m_vehEnterType = door;
+ ped->m_vehDoor = door;
ped->SetPedState(PED_IDLE);
CAnimManager::BlendAnimation(ped->GetClump(), ped->m_animGroup, ANIM_IDLE_STANCE, 100.0f);
CPed::PedSetOutCarCB(nil, ped);
diff --git a/src/vehicles/Automobile.h b/src/vehicles/Automobile.h
index b2f0643c..16d86917 100644
--- a/src/vehicles/Automobile.h
+++ b/src/vehicles/Automobile.h
@@ -7,8 +7,6 @@
class CObject;
-// These are used for all the wheel arrays
-// DON'T confuse with VEHWHEEL, which are vehicle components
enum {
CARWHEEL_FRONT_LEFT,
CARWHEEL_REAR_LEFT,
@@ -35,6 +33,9 @@ public:
float m_aWheelPosition[4];
float m_aWheelSpeed[4];
uint8 m_auto_unused2;
+#if (defined GTA_PS2 && !defined FIX_BUGS)
+ uint8 m_bombType : 3;
+#endif
uint8 bTaxiLight : 1;
uint8 bFixedColour : 1;
uint8 bBigWheels : 1;
@@ -44,6 +45,9 @@ public:
uint8 bTankDetonateCars : 1;
uint8 bStuckInSand : 1;
uint8 bHeliDestroyed : 1;
+#if (defined GTA_PS2 && !defined FIX_BUGS)
+ CEntity* m_pBombRigger;
+#endif
int16 m_doingBurnout;
uint16 m_hydraulicState;
uint32 m_nBusDoorTimerEnd;
diff --git a/src/vehicles/Bike.cpp b/src/vehicles/Bike.cpp
index 30d63aca..a84a43e5 100644
--- a/src/vehicles/Bike.cpp
+++ b/src/vehicles/Bike.cpp
@@ -37,8 +37,6 @@
#include "Bike.h"
#include "Debug.h"
-//--MIAMI: file done
-
const uint32 CBike::nSaveStructSize =
#ifdef COMPATIBLE_SAVES
1260;
@@ -202,9 +200,11 @@ CVector vecTestResistance(0.9995f, 0.9f, 0.95f);
float fDAxisX = 1.0f;
float fDAxisXExtra = 100.0f;
float fDAxisY = 1000.0f;
-float fInAirXRes = 0.88f;
+float fInAirXRes = 0.98f;
float fFlySpeedMult = -0.6f;
+#pragma optimize("", off) // a workaround for another compiler bug =P, original had optimize off for this function too though
+
void
CBike::ProcessControl(void)
{
@@ -476,7 +476,7 @@ CBike::ProcessControl(void)
if(m_vecMoveSpeedAvg.MagnitudeSqr() <= sq(moveSpeedLimit*CTimer::GetTimeStep()) &&
m_vecTurnSpeedAvg.MagnitudeSqr() <= sq(turnSpeedLimit*CTimer::GetTimeStep()) &&
- m_fDistanceTravelled < distanceLimit &&
+ m_fDistanceTravelled < distanceLimit ||
makeStatic){
m_nStaticFrames++;
@@ -1144,7 +1144,12 @@ CBike::ProcessControl(void)
float suspChange = m_aSuspensionSpringRatioPrev[i] - m_aSuspensionSpringRatio[i];
if(suspChange > 0.3f && (i == BIKESUSP_F1 || i == BIKESUSP_R1) && speedsq > 0.04f){
if(GetStatus() == STATUS_PLAYER || GetStatus() == STATUS_PHYSICS){
+#ifdef FIX_BUGS
+ // only two wheels but 4 suspensions
+ if(m_wheelStatus[i/2] == WHEEL_STATUS_BURST)
+#else
if(m_wheelStatus[i] == WHEEL_STATUS_BURST)
+#endif
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_JUMP_2, suspChange);
else
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_JUMP, suspChange);
@@ -1213,7 +1218,8 @@ CBike::ProcessControl(void)
// Balance bike
if(bBalancedByRider || bIsBeingPickedUp || bIsStanding){
- float onSideness = clamp(DotProduct(GetRight(), m_vecAvgSurfaceNormal), -1.0f, 1.0f);
+ float onSideness = DotProduct(GetRight(), m_vecAvgSurfaceNormal);
+ onSideness = clamp(onSideness, -1.0f, 1.0f);
CVector worldCOM = Multiply3x3(GetMatrix(), m_vecCentreOfMass);
// Keep bike upright
if(bBalancedByRider){
@@ -1256,6 +1262,8 @@ CBike::ProcessControl(void)
}
}
+#pragma optimize("", on)
+
void
CBike::Teleport(CVector pos)
{
@@ -1596,7 +1604,7 @@ CBike::PreRender(void)
CVector forkAxis(0.0f, Sin(DEGTORAD(mi->m_bikeSteerAngle)), -Cos(DEGTORAD(mi->m_bikeSteerAngle)));
forkAxis.Normalise(); // as if that's not already the case
CQuaternion quat;
- quat.Set((RwV3d*)&forkAxis, -m_fWheelAngle);
+ quat.Set(&forkAxis, -m_fWheelAngle);
quat.Get(rot.m_attachment);
rot.Update();
@@ -1834,7 +1842,12 @@ CBike::ProcessControlInputs(uint8 pad)
m_fSteerInput = clamp(m_fSteerInput, -1.0f, 1.0f);
// Lean forward/backward
- float updown = -CPad::GetPad(pad)->GetSteeringUpDown()/128.0f + CPad::GetPad(pad)->GetCarGunUpDown()/128.0f;
+ float updown;
+#ifdef FREE_CAM
+ if (CCamera::bFreeCam) updown = CPad::IsAffectedByController ? -CPad::GetPad(pad)->GetSteeringUpDown()/128.0f : CPad::GetPad(pad)->GetCarGunUpDown()/128.0f;
+ else
+#endif
+ updown = -CPad::GetPad(pad)->GetSteeringUpDown()/128.0f + CPad::GetPad(pad)->GetCarGunUpDown()/128.0f;
m_fLeanInput += (updown - m_fLeanInput)*0.2f*CTimer::GetTimeStep();
m_fLeanInput = clamp(m_fLeanInput, -1.0f, 1.0f);
@@ -2599,7 +2612,7 @@ CBike::KnockOffRider(eWeaponType weapon, uint8 direction, CPed *ped, bool bGetBa
ped->SetPedState(PED_IDLE);
CAnimManager::BlendAnimation(ped->GetClump(), ped->m_animGroup, ANIM_IDLE_STANCE, 100.0f);
- ped->m_vehEnterType = CAR_DOOR_LF;
+ ped->m_vehDoor = CAR_DOOR_LF;
CPed::PedSetOutCarCB(nil, ped);
ped->SetMoveState(PEDMOVE_STILL);
if(GetUp().z < 0.0f)
@@ -2684,7 +2697,7 @@ CBike::KnockOffRider(eWeaponType weapon, uint8 direction, CPed *ped, bool bGetBa
switch(direction){
case 0: anim = ANIM_KO_SKID_BACK; break;
case 1: anim = ANIM_KD_RIGHT; break;
- case 2: anim = ANIM_KO_SKID_FRONT; break;
+ case 2: anim = ANIM_BIKE_FALL_R; break;
case 3: anim = ANIM_KD_LEFT; break;
}
if(m_nWheelsOnGround == 0)
diff --git a/src/vehicles/Bike.h b/src/vehicles/Bike.h
index 3fcf66a2..219d8872 100644
--- a/src/vehicles/Bike.h
+++ b/src/vehicles/Bike.h
@@ -2,6 +2,7 @@
#include "Vehicle.h"
#include "Skidmarks.h"
+#include "AnimManager.h"
enum eBikeNodes {
BIKE_NODE_NONE,
diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp
index feaa80de..5aed5814 100644
--- a/src/vehicles/Boat.cpp
+++ b/src/vehicles/Boat.cpp
@@ -27,20 +27,19 @@
#include "RpAnimBlend.h"
#include "Record.h"
#include "Shadows.h"
-
-//--MIAMI: file done
+#include "Wanted.h"
#define INVALID_ORIENTATION (-9999.99f)
-float fShapeLength = 0.4f;
-float fShapeTime = 0.05f;
-float fRangeMult = 0.6f;
-float fTimeMult;
-
float CBoat::MAX_WAKE_LENGTH = 50.0f;
float CBoat::MIN_WAKE_INTERVAL = 2.0f;
float CBoat::WAKE_LIFETIME = 150.0f;
+float fShapeLength = 0.4f;
+float fShapeTime = 0.05f;
+float fRangeMult = 0.6f;
+float fTimeMult = 1.2f/CBoat::WAKE_LIFETIME;
+
CBoat *CBoat::apFrameWakeGeneratingBoats[4];
const uint32 CBoat::nSaveStructSize =
@@ -135,9 +134,9 @@ CBoat::ProcessControl(void)
m_fBuoyancy *= 0.99f;
#ifdef FIX_BUGS
- if(FindPlayerPed() && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && GetModelIndex() == MI_PREDATOR){
+ if(FindPlayerPed() && FindPlayerPed()->m_pWanted->GetWantedLevel() > 0 && GetModelIndex() == MI_PREDATOR){
#else
- if(FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && GetModelIndex() == MI_PREDATOR){
+ if(FindPlayerPed()->m_pWanted->GetWantedLevel() > 0 && GetModelIndex() == MI_PREDATOR){
#endif
CVehicle *playerVeh = FindPlayerVehicle();
if(playerVeh && playerVeh->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT &&
@@ -443,7 +442,7 @@ CBoat::ProcessControl(void)
CVector wakePos = GetPosition() + sternPos;
// no actual particles for player...
}else if(IsVisible() && ((CTimer::GetFrameCounter() + m_randomSeed) & 1) &&
- CVisibilityPlugins::GetDistanceSquaredFromCamera((RwV3d*)&propellerWorld) < SQR(70.0f * TheCamera.GenerationDistMultiplier)){
+ CVisibilityPlugins::GetDistanceSquaredFromCamera(&propellerWorld) < SQR(70.0f * TheCamera.GenerationDistMultiplier)){
jetDir.z = 0.015f;
jetDir.x *= 3.5f;
jetDir.y *= 3.5f;
@@ -613,7 +612,7 @@ CBoat::ProcessControl(void)
splashDir.z += 0.0003f*m_nDeltaVolumeUnderWater;
CWaterLevel::GetWaterLevel(splashPos, &waterLevel, true);
if(splashPos.z-waterLevel < 3.0f &&
- CVisibilityPlugins::GetDistanceSquaredFromCamera((RwV3d*)&splashPos) < SQR(70.0f * TheCamera.GenerationDistMultiplier)){
+ CVisibilityPlugins::GetDistanceSquaredFromCamera(&splashPos) < SQR(70.0f * TheCamera.GenerationDistMultiplier)){
splashPos.z = waterLevel + 0.1f;
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashPos, 0.75f*splashDir, nil, splashSize+0.1f, splashColor,
CGeneral::GetRandomNumberInRange(0.0f, 10.0f), CGeneral::GetRandomNumberInRange(0.0f, 90.0f),
@@ -670,7 +669,7 @@ CBoat::ProcessControl(void)
splashDir.z += 0.0003f*m_nDeltaVolumeUnderWater;
CWaterLevel::GetWaterLevel(splashPos, &waterLevel, true);
if(splashPos.z-waterLevel < 3.0f &&
- CVisibilityPlugins::GetDistanceSquaredFromCamera((RwV3d*)&splashPos) < SQR(70.0f * TheCamera.GenerationDistMultiplier)){
+ CVisibilityPlugins::GetDistanceSquaredFromCamera(&splashPos) < SQR(70.0f * TheCamera.GenerationDistMultiplier)){
splashPos.z = waterLevel + 0.1f;
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashPos, 0.75f*splashDir, nil, splashSize+0.1f, splashColor,
CGeneral::GetRandomNumberInRange(0.0f, 10.0f), CGeneral::GetRandomNumberInRange(0.0f, 90.0f),
@@ -964,7 +963,14 @@ CBoat::PreRender(void)
// FIX: Planes can also be controlled with GetCarGunUpDown
#ifdef FIX_BUGS
static float steeringUpDown = 0.0f;
- steeringUpDown += ((Abs(CPad::GetPad(0)->GetCarGunUpDown()) > 1.0f ? (-CPad::GetPad(0)->GetCarGunUpDown() / 128.0f) : (-CPad::GetPad(0)->GetSteeringUpDown() / 128.0f)) - steeringUpDown) * Min(1.f, CTimer::GetTimeStep() / 5.f);
+#ifdef FREE_CAM
+ if(!CCamera::bFreeCam || (CCamera::bFreeCam && !CPad::IsAffectedByController))
+#endif
+ steeringUpDown += ((Abs(CPad::GetPad(0)->GetCarGunUpDown()) > 1.0f ? (-CPad::GetPad(0)->GetCarGunUpDown()/128.0f) : (-CPad::GetPad(0)->GetSteeringUpDown()/128.0f)) - steeringUpDown) * Min(1.f, CTimer::GetTimeStep()/5.f);
+#ifdef FREE_CAM
+ else
+ steeringUpDown = -CPad::GetPad(0)->GetSteeringUpDown()/128.0f;
+#endif
#else
float steeringUpDown = -CPad::GetPad(0)->GetSteeringUpDown()/128.0f;
#endif
@@ -1246,7 +1252,7 @@ CBoat::Teleport(CVector v)
CWorld::Add(this);
}
-//--MIAMI: unused
+// unused
bool
CBoat::IsSectorAffectedByWake(CVector2D sector, float fSize, CBoat **apBoats)
{
@@ -1278,7 +1284,7 @@ CBoat::IsSectorAffectedByWake(CVector2D sector, float fSize, CBoat **apBoats)
return numVerts != 0;
}
-//--MIAMI: unused
+// unused
float
CBoat::IsVertexAffectedByWake(CVector vecVertex, CBoat *pBoat)
{
diff --git a/src/vehicles/CarGen.cpp b/src/vehicles/CarGen.cpp
index 77d66cbf..78e67d49 100644
--- a/src/vehicles/CarGen.cpp
+++ b/src/vehicles/CarGen.cpp
@@ -18,8 +18,6 @@
#include "Zones.h"
#include "Occlusion.h"
-// --MIAMI: file done
-
uint8 CTheCarGenerators::ProcessCounter;
uint32 CTheCarGenerators::NumOfCarGenerators;
CCarGenerator CTheCarGenerators::CarGeneratorArray[NUM_CARGENS];
diff --git a/src/vehicles/Cranes.cpp b/src/vehicles/Cranes.cpp
index 2a571a67..b5926867 100644
--- a/src/vehicles/Cranes.cpp
+++ b/src/vehicles/Cranes.cpp
@@ -12,8 +12,6 @@
#include "Object.h"
#include "World.h"
-// --MIAMI: file done
-
#define MAX_DISTANCE_TO_FIND_CRANE (10.0f)
#define CRANE_UPDATE_RADIUS (300.0f)
#define CRANE_MOVEMENT_PROCESSING_RADIUS (150.0f)
@@ -629,11 +627,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/Cranes.h b/src/vehicles/Cranes.h
index 45ea7a8d..e842ed3f 100644
--- a/src/vehicles/Cranes.h
+++ b/src/vehicles/Cranes.h
@@ -11,7 +11,7 @@ class CBuilding;
class CCrane
{
public:
- enum CraneState : uint8 {
+ enum CraneState {
IDLE = 0,
GOING_TOWARDS_TARGET = 1,
LIFTING_TARGET = 2,
@@ -19,7 +19,7 @@ public:
ROTATING_TARGET = 4,
DROPPING_TARGET = 5
};
- enum CraneStatus : uint8 {
+ enum CraneStatus {
NONE = 0,
ACTIVATED = 1,
DEACTIVATED = 2
@@ -46,8 +46,8 @@ public:
CVector2D m_vecHookVelocity;
CVehicle *m_pVehiclePickedUp;
uint32 m_nTimeForNextCheck;
- CraneStatus m_nCraneStatus;
- CraneState m_nCraneState;
+ uint8 m_nCraneStatus;
+ uint8 m_nCraneState;
uint8 m_nVehiclesCollected;
bool m_bIsCrusher;
bool m_bIsMilitaryCrane;
@@ -88,7 +88,7 @@ public:
static bool IsThisCarBeingCarriedByAnyCrane(CVehicle* pVehicle);
static bool IsThisCarBeingTargettedByAnyCrane(CVehicle* pVehicle);
static void Save(uint8* buf, uint32* size);
- static void Load(uint8* buf, uint32 size); // on mobile it's CranesLoad outside of the class
+ static void Load(uint8* buf, uint32 size); // out of class in III PC and later because of SecuROM
static uint32 CarsCollectedMilitaryCrane;
static int32 NumCranes;
diff --git a/src/vehicles/Floater.cpp b/src/vehicles/Floater.cpp
index 92e3d80e..08688a3c 100644
--- a/src/vehicles/Floater.cpp
+++ b/src/vehicles/Floater.cpp
@@ -7,8 +7,6 @@
#include "Vehicle.h"
#include "Floater.h"
-//--MIAMI: done
-
cBuoyancy mod_Buoyancy;
float fVolMultiplier = 1.0f;
diff --git a/src/vehicles/HandlingMgr.cpp b/src/vehicles/HandlingMgr.cpp
index f96835d3..8438c5c9 100644
--- a/src/vehicles/HandlingMgr.cpp
+++ b/src/vehicles/HandlingMgr.cpp
@@ -2,10 +2,9 @@
#include "main.h"
#include "FileMgr.h"
+#include "Physical.h"
#include "HandlingMgr.h"
-//--MIAMI: done
-
cHandlingDataMgr mod_HandlingManager;
const char *HandlingFilename = "HANDLING.CFG";
@@ -172,7 +171,7 @@ cHandlingDataMgr::LoadHandlingData(void)
end = start+1;
// yeah, this is kinda crappy
- if(strncmp(line, ";the end", 9) == 0)
+ if(strcmp(line, ";the end") == 0)
keepGoing = 0;
else if(line[0] != ';'){
if(line[0] == '!'){
@@ -299,7 +298,7 @@ cHandlingDataMgr::LoadHandlingData(void)
case 11: handling->fTractionBias = atof(word); break;
case 12: handling->Transmission.nNumberOfGears = atoi(word); break;
case 13: handling->Transmission.fMaxVelocity = atof(word); break;
- case 14: handling->Transmission.fEngineAcceleration = atof(word) * 0.4f; break;
+ case 14: handling->Transmission.fEngineAcceleration = atof(word) * 0.4; break;
case 15: handling->Transmission.nDriveType = word[0]; break;
case 16: handling->Transmission.nEngineType = word[0]; break;
case 17: handling->fBrakeDeceleration = atof(word); break;
@@ -348,39 +347,45 @@ cHandlingDataMgr::FindExactWord(const char *word, const char *words, int wordLen
void
cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
{
- // TODO: figure out what exactly is being converted here
- float velocity, a, b, specificVolume;
+ // convert distance to m, time to 1/50s
+ float velocity, a, b;
- handling->Transmission.fEngineAcceleration /= 2500.0f;
- handling->Transmission.fMaxVelocity /= 180.0f;
- handling->fBrakeDeceleration /= 2500.0f;
+ handling->Transmission.fEngineAcceleration *= 1.0f/(50.0f*50.0f);
+ handling->Transmission.fMaxVelocity *= 1000.0f/(60.0f*60.0f * 50.0f);
+ handling->fBrakeDeceleration *= 1.0f/(50.0f*50.0f);
handling->fTurnMass = (sq(handling->Dimension.x) + sq(handling->Dimension.y)) * handling->fMass / 12.0f;
if(handling->fTurnMass < 10.0f)
handling->fTurnMass *= 5.0f;
handling->fInvMass = 1.0f/handling->fMass;
handling->fCollisionDamageMultiplier *= 2000.0f/handling->fMass;
- handling->fBuoyancy = 100.0f/handling->nPercentSubmerged * 0.008f*handling->fMass;
+ handling->fBuoyancy = 100.0f/handling->nPercentSubmerged * GRAVITY*handling->fMass;
- // What the hell is going on here?
- specificVolume = handling->Dimension.x*handling->Dimension.z*0.5f / handling->fMass; // ?
+ // Don't quite understand this. What seems to be going on is that
+ // we calculate a drag (air resistance) deceleration for a given velocity and
+ // find the intersection between that and the max engine acceleration.
+ // at that point the car cannot accelerate any further and we've found the max velocity.
a = 0.0f;
b = 100.0f;
velocity = handling->Transmission.fMaxVelocity;
while(a < b && velocity > 0.0f){
velocity -= 0.01f;
+ // what's the 1/6?
a = handling->Transmission.fEngineAcceleration/6.0f;
- b = -velocity * (1.0f/(specificVolume * sq(velocity) + 1.0f) - 1.0f);
+ // no density or drag coefficient here...
+ float a_drag = 0.5f*SQR(velocity) * handling->Dimension.x*handling->Dimension.z / handling->fMass;
+ // can't make sense of this... maybe v - v/(drag + 1) ? but that doesn't make so much sense either
+ b = -velocity * (1.0f/(a_drag + 1.0f) - 1.0f);
}
if(handling->nIdentifier == HANDLING_RCBANDIT){
- handling->Transmission.fUnkMaxVelocity = handling->Transmission.fMaxVelocity;
+ handling->Transmission.fMaxCruiseVelocity = handling->Transmission.fMaxVelocity;
handling->Transmission.fMaxReverseVelocity = -handling->Transmission.fMaxVelocity;
}else if(handling->nIdentifier >= HANDLING_BIKE && handling->nIdentifier <= HANDLING_FREEWAY){
- handling->Transmission.fUnkMaxVelocity = velocity;
+ handling->Transmission.fMaxCruiseVelocity = velocity;
handling->Transmission.fMaxVelocity = velocity * 1.2f;
handling->Transmission.fMaxReverseVelocity = -0.05f;
}else{
- handling->Transmission.fUnkMaxVelocity = velocity;
+ handling->Transmission.fMaxCruiseVelocity = velocity;
handling->Transmission.fMaxVelocity = velocity * 1.2f;
handling->Transmission.fMaxReverseVelocity = -0.2f;
}
diff --git a/src/vehicles/HandlingMgr.h b/src/vehicles/HandlingMgr.h
index 52e69441..8d290f7d 100644
--- a/src/vehicles/HandlingMgr.h
+++ b/src/vehicles/HandlingMgr.h
@@ -120,6 +120,11 @@ enum tVehicleType
NUMBOATHANDLINGS = HANDLING_SEAPLANE+1 - HANDLING_PREDATOR,
};
+enum tField // most likely a handling field enum, never used so :shrug:
+{
+
+};
+
enum
{
HANDLING_1G_BOOST = 1,
@@ -170,7 +175,7 @@ struct tHandlingData
float fSteeringLock;
float fTractionLoss;
float fTractionBias;
- float fABS; // should be VC leftover
+ float fUnused;
float fSuspensionForceLevel;
float fSuspensionDampingLevel;
float fSuspensionUpperLimit;
@@ -239,6 +244,8 @@ struct tFlyingHandlingData
CVector vecSpeedRes;
};
+class CVehicle;
+
class cHandlingDataMgr
{
float field_0; // unused it seems
@@ -258,6 +265,7 @@ 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 ConvertBikeDataToGameUnits(tBikeHandlingData *handling);
int32 GetHandlingId(const char *name);
@@ -265,7 +273,7 @@ public:
tBikeHandlingData *GetBikePointer(uint8 id) { return &BikeHandlingData[id-HANDLING_BIKE]; }
tFlyingHandlingData *GetFlyingPointer(uint8 id);
tBoatHandlingData *GetBoatPointer(uint8 id);
- bool HasRearWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType == 'R'; }
- bool HasFrontWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType == 'F'; }
+ bool HasRearWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType != 'F'; }
+ bool HasFrontWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType != 'R'; }
};
extern cHandlingDataMgr mod_HandlingManager;
diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp
index 644fdde8..38550c38 100644
--- a/src/vehicles/Heli.cpp
+++ b/src/vehicles/Heli.cpp
@@ -32,8 +32,6 @@
#include "Replay.h"
#endif
-//--MIAMI: done
-
enum
{
HELI_STATUS_HOVER,
@@ -480,7 +478,7 @@ CHeli::ProcessControl(void)
// Shoot
int shootTimeout;
if (m_heliType == HELI_TYPE_RANDOM) {
- switch (FindPlayerPed()->m_pWanted->m_nWantedLevel) {
+ switch (FindPlayerPed()->m_pWanted->GetWantedLevel()) {
case 0:
case 1:
case 2: shootTimeout = 999999; break;
@@ -762,7 +760,7 @@ CHeli::InitHelis(void)
}
CHeli*
-GenerateHeli(bool catalina)
+CHeli::GenerateHeli(bool catalina)
{
CHeli *heli;
CVector heliPos;
@@ -800,7 +798,7 @@ GenerateHeli(bool catalina)
id++;
found = true;
for(i = 0; i < 4; i++)
- if(CHeli::pHelis[i] && CHeli::pHelis[i]->m_nHeliId == id)
+ if(pHelis[i] && pHelis[i]->m_nHeliId == id)
found = false;
}
heli->m_nHeliId = id;
diff --git a/src/vehicles/Heli.h b/src/vehicles/Heli.h
index 1f372e42..c5ae08e2 100644
--- a/src/vehicles/Heli.h
+++ b/src/vehicles/Heli.h
@@ -83,13 +83,14 @@ public:
bool SendDownSwat(void);
static void InitHelis(void);
+ static CHeli *GenerateHeli(bool catalina); // out of class in III PC and later because of SecuROM
static void UpdateHelis(void);
static void SpecialHeliPreRender(void);
static bool TestRocketCollision(CVector *coors);
static bool TestBulletCollision(CVector *line0, CVector *line1, CVector *bulletPos, int32 damage);
static bool TestSniperCollision(CVector *line0, CVector *line1);
- static void StartCatalinaFlyBy(void);
+ static void StartCatalinaFlyBy(void); // out of class in III PC and later because of SecuROM
static void RemoveCatalinaHeli(void);
static CHeli *FindPointerToCatalinasHeli(void);
static void CatalinaTakeOff(void);
diff --git a/src/vehicles/Plane.cpp b/src/vehicles/Plane.cpp
index 620a04fb..48f7b8c0 100644
--- a/src/vehicles/Plane.cpp
+++ b/src/vehicles/Plane.cpp
@@ -18,8 +18,7 @@
#include "HandlingMgr.h"
#include "Heli.h"
#include "Plane.h"
-
-//--MIAMI: file done
+#include "MemoryHeap.h"
CPlaneNode *pPathNodes;
CPlaneNode *pPath2Nodes;
@@ -564,7 +563,9 @@ 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.AttachRW(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic*)m_rwObject)));
}
@@ -1001,7 +1002,7 @@ CPlane::TestRocketCollision(CVector *rocketPos)
return false;
}
-//--MIAMI: unused
+// unused
// BUG: not in CPlane in the game
void
CPlane::CreateIncomingCesna(void)
@@ -1025,7 +1026,7 @@ CPlane::CreateIncomingCesna(void)
printf("CPlane::CreateIncomingCesna(void)\n");
}
-//--MIAMI: unused
+// unused
void
CPlane::CreateDropOffCesna(void)
{
@@ -1048,7 +1049,7 @@ CPlane::CreateDropOffCesna(void)
printf("CPlane::CreateDropOffCesna(void)\n");
}
-//--MIAMI: all unused
+// all unused
const CVector CPlane::FindDrugPlaneCoordinates(void) { return pDrugRunCesna->GetPosition(); }
const CVector CPlane::FindDropOffCesnaCoordinates(void) { return pDropOffCesna->GetPosition(); }
bool CPlane::HasCesnaLanded(void) { return CesnaMissionStatus == CESNA_STATUS_LANDED; }
diff --git a/src/vehicles/Train.cpp b/src/vehicles/Train.cpp
index 1a4af307..5f0cf36a 100644
--- a/src/vehicles/Train.cpp
+++ b/src/vehicles/Train.cpp
@@ -388,7 +388,7 @@ void
CTrain::AddPassenger(CPed *ped)
{
#ifdef GTA_TRAIN
- int i = ped->m_vehEnterType;
+ int i = ped->m_vehDoor;
if((i == TRAIN_POS_LEFT_ENTRY || i == TRAIN_POS_MID_ENTRY || i == TRAIN_POS_RIGHT_ENTRY) && pPassengers[i] == nil){
pPassengers[i] = ped;
m_nNumPassengers++;
diff --git a/src/vehicles/Transmission.cpp b/src/vehicles/Transmission.cpp
index cc994ac6..1aeabfe0 100644
--- a/src/vehicles/Transmission.cpp
+++ b/src/vehicles/Transmission.cpp
@@ -4,8 +4,6 @@
#include "HandlingMgr.h"
#include "Transmission.h"
-//--MIAMI: done
-
void
cTransmission::InitGearRatios(void)
{
@@ -123,7 +121,7 @@ cTransmission::CalculateDriveAcceleration(const float &gasPedal, uint8 &gear, fl
else
fCheat = 1.0f;
float targetVelocity = Gears[gear].fMaxVelocity*speedMul*fCheat;
- float accel = fEngineAcceleration*accelMul * (targetVelocity - fVelocity)/Abs(targetVelocity);
+ float accel = (targetVelocity - fVelocity) * (fEngineAcceleration*accelMul) / Abs(targetVelocity);
if(Abs(fVelocity) < Abs(Gears[gear].fMaxVelocity*fCheat))
fAcceleration = gasPedal * accel * CTimer::GetTimeStep();
else
diff --git a/src/vehicles/Transmission.h b/src/vehicles/Transmission.h
index 8eeef1e8..a3d15513 100644
--- a/src/vehicles/Transmission.h
+++ b/src/vehicles/Transmission.h
@@ -18,7 +18,7 @@ public:
uint8 Flags;
float fEngineAcceleration;
float fMaxVelocity;
- float fUnkMaxVelocity;
+ float fMaxCruiseVelocity;
float fMaxReverseVelocity;
float fCurVelocity;
diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp
index 228c4f66..0ecc5004 100644
--- a/src/vehicles/Vehicle.cpp
+++ b/src/vehicles/Vehicle.cpp
@@ -33,8 +33,6 @@
#include "Weather.h"
#include "Coronas.h"
-//--MIAMI: done
-
bool CVehicle::bWheelsOnlyCheat;
bool CVehicle::bAllDodosCheat;
bool CVehicle::bCheat3;
@@ -48,6 +46,9 @@ bool CVehicle::bAllTaxisHaveNitro;
bool CVehicle::m_bDisableMouseSteering = true;
bool CVehicle::bDisableRemoteDetonation;
bool CVehicle::bDisableRemoteDetonationOnContact;
+#ifndef MASTER
+bool CVehicle::m_bDisplayHandlingInfo;
+#endif
void *CVehicle::operator new(size_t sz) { return CPools::GetVehiclePool()->New(); }
void *CVehicle::operator new(size_t sz, int handle) { return CPools::GetVehiclePool()->New(handle); }
@@ -146,6 +147,7 @@ CVehicle::CVehicle(uint8 CreatedBy)
m_nAlarmState = 0;
m_nDoorLock = CARLOCK_UNLOCKED;
m_nLastWeaponDamage = -1;
+ m_pLastDamageEntity = nil;
m_fMapObjectHeightAhead = m_fMapObjectHeightBehind = 0.0f;
m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, this);
if(m_audioEntityId >= 0)
@@ -330,6 +332,9 @@ CVehicle::FlyingControl(eFlightModel flightModel)
float fSteerLR = CPad::GetPad(0)->GetSteeringLeftRight() / 128.0f;
float fSteerUD = CPad::GetPad(0)->GetSteeringUpDown() / 128.0f;
float fGunUD = Abs(CPad::GetPad(0)->GetCarGunUpDown());
+#ifdef FREE_CAM
+ if(!CCamera::bFreeCam || (CCamera::bFreeCam && !CPad::IsAffectedByController))
+#endif
if(fGunUD > 1.0f)
fSteerUD = -CPad::GetPad(0)->GetCarGunUpDown() / 128.0f;
@@ -503,9 +508,15 @@ CVehicle::FlyingControl(eFlightModel flightModel)
fYaw = CPad::GetPad(0)->GetLookRight();
if (CPad::GetPad(0)->GetLookLeft())
fYaw = -1.0f;
+#ifdef FREE_CAM
+ if (!CCamera::bFreeCam || (CCamera::bFreeCam && !CPad::IsAffectedByController))
+#endif
if(Abs(CPad::GetPad(0)->GetCarGunLeftRight()) > 1.0f)
fYaw = CPad::GetPad(0)->GetCarGunLeftRight() / 128.0f;
}
+#ifdef FREE_CAM
+ if(!CCamera::bFreeCam || (CCamera::bFreeCam && !CPad::IsAffectedByController))
+#endif
if(Abs(CPad::GetPad(0)->GetCarGunUpDown()) > 1.0f)
fPitch = -CPad::GetPad(0)->GetCarGunUpDown() / 128.0f;
if (CPad::GetPad(0)->GetHorn()) {
@@ -836,11 +847,11 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon
if(IsBike())
brake = 0.6f * mod_HandlingManager.fWheelFriction / (pHandling->fMass + 200.0f);
else if(pHandling->fMass < 500.0f)
- brake = mod_HandlingManager.fWheelFriction / m_fMass;
+ brake = 0.2f * mod_HandlingManager.fWheelFriction / pHandling->fMass;
else if(GetModelIndex() == MI_RCBANDIT)
- brake = 0.2f * mod_HandlingManager.fWheelFriction / m_fMass;
+ brake = 0.2f * mod_HandlingManager.fWheelFriction / pHandling->fMass;
else
- brake = mod_HandlingManager.fWheelFriction / m_fMass;
+ brake = mod_HandlingManager.fWheelFriction / pHandling->fMass;
#ifdef FIX_BUGS
brake *= CTimer::GetTimeStepFix();
#endif
@@ -909,7 +920,7 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon
float turnImpulse = turnSpeed*GetMass(wheelContactPoint, turnDirection);
ApplyMoveForce(impulse * direction);
- ApplyTurnForce(turnImpulse * direction, wheelContactPoint);
+ ApplyTurnForce(turnImpulse * turnDirection, wheelContactPoint);
}
}
@@ -1232,7 +1243,7 @@ CVehicle::InflictDamage(CEntity *damagedBy, eWeaponType weaponType, float damage
if (m_randomSeed < DAMAGE_FLEE_IN_CAR_PROBABILITY_VALUE) {
CCarCtrl::SwitchVehicleToRealPhysics(this);
AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
- AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * pHandling->Transmission.fUnkMaxVelocity;
+ AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * pHandling->Transmission.fMaxCruiseVelocity;
SetStatus(STATUS_PHYSICS);
}
}
@@ -1426,13 +1437,13 @@ CVehicle::ShufflePassengersToMakeSpace(void)
if (!pPassengers[2] && !(m_nGettingInFlags & CAR_DOOR_FLAG_RR)) {
pPassengers[2] = pPassengers[1];
pPassengers[1] = nil;
- pPassengers[2]->m_vehEnterType = CAR_DOOR_RR;
+ pPassengers[2]->m_vehDoor = CAR_DOOR_RR;
return true;
}
if (!pPassengers[0] && !(m_nGettingInFlags & CAR_DOOR_FLAG_RF)) {
pPassengers[0] = pPassengers[1];
pPassengers[1] = nil;
- pPassengers[0]->m_vehEnterType = CAR_DOOR_RF;
+ pPassengers[0]->m_vehDoor = CAR_DOOR_RF;
return true;
}
return false;
@@ -1443,13 +1454,13 @@ CVehicle::ShufflePassengersToMakeSpace(void)
if (!pPassengers[1] && !(m_nGettingInFlags & CAR_DOOR_FLAG_LR)) {
pPassengers[1] = pPassengers[2];
pPassengers[2] = nil;
- pPassengers[1]->m_vehEnterType = CAR_DOOR_LR;
+ pPassengers[1]->m_vehDoor = CAR_DOOR_LR;
return true;
}
if (!pPassengers[0] && !(m_nGettingInFlags & CAR_DOOR_FLAG_RF)) {
pPassengers[0] = pPassengers[2];
pPassengers[2] = nil;
- pPassengers[0]->m_vehEnterType = CAR_DOOR_RF;
+ pPassengers[0]->m_vehDoor = CAR_DOOR_RF;
return true;
}
return false;
@@ -1460,13 +1471,13 @@ CVehicle::ShufflePassengersToMakeSpace(void)
if (!pPassengers[1] && !(m_nGettingInFlags & CAR_DOOR_FLAG_LR)) {
pPassengers[1] = pPassengers[0];
pPassengers[0] = nil;
- pPassengers[1]->m_vehEnterType = CAR_DOOR_LR;
+ pPassengers[1]->m_vehDoor = CAR_DOOR_LR;
return true;
}
if (!pPassengers[2] && !(m_nGettingInFlags & CAR_DOOR_FLAG_RR)) {
pPassengers[2] = pPassengers[0];
pPassengers[0] = nil;
- pPassengers[2]->m_vehEnterType = CAR_DOOR_RR;
+ pPassengers[2]->m_vehDoor = CAR_DOOR_RR;
return true;
}
return false;
@@ -1482,7 +1493,7 @@ CVehicle::MakeNonDraggedPedsLeaveVehicle(CPed *ped1, CPed *ped2, CPlayerPed *&pl
cop = nil;
if(ped1->IsPlayer() && ped2->m_nPedType == PEDTYPE_COP &&
- ((CPlayerPed*)ped1)->m_pWanted->m_nWantedLevel > 0 &&
+ ((CPlayerPed*)ped1)->m_pWanted->GetWantedLevel() > 0 &&
ped2->m_pedInObjective == ped1){
player = (CPlayerPed*)ped1;
cop = (CCopPed*)ped2;
@@ -1512,7 +1523,7 @@ CVehicle::MakeNonDraggedPedsLeaveVehicle(CPed *ped1, CPed *ped2, CPlayerPed *&pl
int numPeds3 = 0;
for(i = 0; i < numPeds; i++){
if(peds[i]->IsPlayer() && ped2->m_nPedType == PEDTYPE_COP &&
- ((CPlayerPed*)peds[i])->m_pWanted->m_nWantedLevel > 0 &&
+ ((CPlayerPed*)peds[i])->m_pWanted->GetWantedLevel() > 0 &&
ped2->m_pedInObjective == peds[i]){
player = (CPlayerPed*)peds[i];
cop = (CCopPed*)ped2;
@@ -1873,7 +1884,7 @@ CVehicle::AddPassenger(CPed *passenger)
int i;
if(IsBike())
- ApplyTurnForce(-0.2f*passenger->m_fMass * GetUp(), -0.1f*GetForward());
+ ApplyTurnForce(-0.02f*passenger->m_fMass * GetUp(), -0.1f*GetForward());
else
ApplyTurnForce(0.0f, 0.0f, -0.2f*passenger->m_fMass,
passenger->GetPosition().x - GetPosition().x,
@@ -1896,7 +1907,7 @@ CVehicle::AddPassenger(CPed *passenger, uint8 n)
return AddPassenger(passenger);
if(IsBike())
- ApplyTurnForce(-0.2f*passenger->m_fMass * GetUp(), -0.1f*GetForward());
+ ApplyTurnForce(-0.02f*passenger->m_fMass * GetUp(), -0.1f*GetForward());
else
ApplyTurnForce(0.0f, 0.0f, -0.2f*passenger->m_fMass,
passenger->GetPosition().x - GetPosition().x,
@@ -1914,7 +1925,10 @@ CVehicle::AddPassenger(CPed *passenger, uint8 n)
void
CVehicle::RemoveDriver(void)
{
- SetStatus(STATUS_ABANDONED);
+#ifdef FIX_BUGS
+ if (GetStatus() != STATUS_WRECKED)
+#endif
+ SetStatus(STATUS_ABANDONED);
if(pDriver == FindPlayerPed()){
if(GetModelIndex() == MI_POLICE && CStreaming::HasModelLoaded(MI_SHOTGUN)){
if(bFreebies){
@@ -2492,7 +2506,7 @@ IsVehiclePointerValid(CVehicle* pVehicle)
{
if (!pVehicle)
return false;
- int index = CPools::GetVehiclePool()->GetJustIndex(pVehicle);
+ int index = CPools::GetVehiclePool()->GetJustIndex_NoFreeAssert(pVehicle);
#ifdef FIX_BUGS
if (index < 0 || index >= NUMVEHICLES)
#else
diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h
index 004f1fd9..4a361215 100644
--- a/src/vehicles/Vehicle.h
+++ b/src/vehicles/Vehicle.h
@@ -3,15 +3,15 @@
#include "Physical.h"
#include "AutoPilot.h"
#include "ModelIndices.h"
-#include "AnimManager.h"
-#include "Weapon.h"
+#include "AnimationId.h"
+#include "WeaponType.h"
+#include "Collision.h"
#include "HandlingMgr.h"
class CPed;
class CPlayerPed;
class CCopPed;
class CFire;
-struct tHandlingData;
enum {
RANDOM_VEHICLE = 1,
@@ -102,14 +102,6 @@ enum eLights
VEHLIGHT_REAR_RIGHT,
};
-enum eWheels
-{
- VEHWHEEL_FRONT_LEFT,
- VEHWHEEL_FRONT_RIGHT,
- VEHWHEEL_REAR_LEFT,
- VEHWHEEL_REAR_RIGHT,
-};
-
enum
{
CAR_PIECE_BONNET = 1,
@@ -248,8 +240,9 @@ public:
uint8 bRestingOnPhysical : 1; // Dont go static cause car is sitting on a physical object that might get removed
uint8 bParking : 1;
uint8 bCanPark : 1;
-
+#if (!defined GTA_PS2 || defined FIX_BUGS)
uint8 m_bombType : 3;
+#endif
uint8 bDriverLastFrame : 1;
int8 m_numPedsUseItAsCover;
@@ -259,7 +252,9 @@ public:
float m_fHealth; // 1000.0f = full health. 250.0f = fire. 0 -> explode
uint8 m_nCurrentGear;
float m_fChangeGearTime;
+#if (!defined GTA_PS2 || defined FIX_BUGS)
CEntity* m_pBombRigger;
+#endif
uint32 m_nSetPieceExtendedRangeTime;
uint32 m_nGunFiringTime; // last time when gun on vehicle was fired (used on boats)
uint32 m_nTimeOfDeath;
@@ -281,7 +276,7 @@ public:
int8 m_comedyControlState;
CStoredCollPoly m_aCollPolys[2]; // poly which is under front/rear part of car
float m_fSteerInput;
- eVehicleType m_vehType;
+ uint8 m_vehType;
static void *operator new(size_t);
static void *operator new(size_t sz, int slot);
@@ -407,6 +402,9 @@ public:
static bool m_bDisableMouseSteering;
static bool bDisableRemoteDetonation;
static bool bDisableRemoteDetonationOnContact;
+#ifndef MASTER
+ static bool m_bDisplayHandlingInfo;
+#endif
};
void DestroyVehicleAndDriverAndPassengers(CVehicle* pVehicle);