summaryrefslogtreecommitdiff
path: root/src/vehicles
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2021-07-02 11:28:46 +0300
committerNikolay Korolev <nickvnuk@gmail.com>2021-07-02 11:28:46 +0300
commit10cc444482b52d6e82b624bbbb7d87c48dcf48e2 (patch)
tree2c80031552d77909220ed7bd66a7e055aa3e5b45 /src/vehicles
parent73e112a2179f7036f47fb34c6a1d24fbb1e3e2ce (diff)
parentdd790b00e511b4a15c7d09fe1393fb77b0983280 (diff)
Merge remote-tracking branch 'upstream/lcs' into lcs
Diffstat (limited to 'src/vehicles')
-rw-r--r--src/vehicles/Automobile.cpp27
-rw-r--r--src/vehicles/Bike.cpp17
-rw-r--r--src/vehicles/Boat.cpp23
-rw-r--r--src/vehicles/CarGen.cpp20
-rw-r--r--src/vehicles/Cranes.cpp7
-rw-r--r--src/vehicles/Door.cpp4
-rw-r--r--src/vehicles/Heli.cpp2
-rw-r--r--src/vehicles/Transmission.cpp2
-rw-r--r--src/vehicles/Vehicle.cpp79
9 files changed, 96 insertions, 85 deletions
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index 2df57a10..ef7fded0 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -50,6 +50,7 @@
#include "Automobile.h"
#include "Bike.h"
#include "Wanted.h"
+#include "SaveBuf.h"
bool bAllCarCheat;
@@ -932,7 +933,7 @@ CAutomobile::ProcessControl(void)
float adhesion = CSurfaceTable::GetAdhesiveLimit(point);
// i have no idea what's going on here
float magic = traction * adhesion * 16.0f / SQR(fwdSpeed);
- magic = clamp(magic, -1.0f, 1.0f);
+ magic = Clamp(magic, -1.0f, 1.0f);
magic = Asin(magic);
if(m_fSteerAngle < 0.0f && rightSpeed > 0.05f ||
m_fSteerAngle > 0.0f && rightSpeed < -0.05f ||
@@ -2080,7 +2081,7 @@ CAutomobile::PreRender(void)
// 1.0 if directly behind car, -1.0 if in front
float behindness = DotProduct(lookVector, GetForward());
- behindness = clamp(behindness, -1.0f, 1.0f); // shouldn't be necessary
+ behindness = Clamp(behindness, -1.0f, 1.0f); // shouldn't be necessary
// 0.0 if behind car, PI if in front
// Abs not necessary
float angle = Abs(Acos(behindness));
@@ -2438,7 +2439,7 @@ CAutomobile::PreRender(void)
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
if(GetModelIndex() == MI_VOODOO)
groundOffset *= 0.6f;
- mat.RotateY(Asin(clamp(-groundOffset, -1.0f, 1.0f)));
+ mat.RotateY(Asin(Clamp(-groundOffset, -1.0f, 1.0f)));
}
}
if(pHandling->Flags & HANDLING_FAT_REARW)
@@ -2479,7 +2480,7 @@ CAutomobile::PreRender(void)
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
if(GetModelIndex() == MI_VOODOO)
groundOffset *= 0.6f;
- mat.RotateY(Asin(clamp(groundOffset, -1.0f, 1.0f)));
+ mat.RotateY(Asin(Clamp(groundOffset, -1.0f, 1.0f)));
}
}
if(pHandling->Flags & HANDLING_FAT_REARW)
@@ -2512,7 +2513,7 @@ CAutomobile::PreRender(void)
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
if(GetModelIndex() == MI_VOODOO)
groundOffset *= 0.6f;
- mat.RotateY(Asin(clamp(-groundOffset, -1.0f, 1.0f)));
+ mat.RotateY(Asin(Clamp(-groundOffset, -1.0f, 1.0f)));
}
}
if(pHandling->Flags & HANDLING_FAT_REARW)
@@ -2546,7 +2547,7 @@ CAutomobile::PreRender(void)
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
if(GetModelIndex() == MI_VOODOO)
groundOffset *= 0.6f;
- mat.RotateY(Asin(clamp(groundOffset, -1.0f, 1.0f)));
+ mat.RotateY(Asin(Clamp(groundOffset, -1.0f, 1.0f)));
}
}
if(pHandling->Flags & HANDLING_FAT_REARW)
@@ -2680,7 +2681,7 @@ CAutomobile::PreRender(void)
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
if(GetModelIndex() == MI_VOODOO)
groundOffset *= 0.6f;
- mat.RotateY(Asin(clamp(-groundOffset, -1.0f, 1.0f)));
+ mat.RotateY(Asin(Clamp(-groundOffset, -1.0f, 1.0f)));
}
}
if(pHandling->Flags & HANDLING_NARROW_FRONTW)
@@ -2721,7 +2722,7 @@ CAutomobile::PreRender(void)
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
if(GetModelIndex() == MI_VOODOO)
groundOffset *= 0.6f;
- mat.RotateY(Asin(clamp(groundOffset, -1.0f, 1.0f)));
+ mat.RotateY(Asin(Clamp(groundOffset, -1.0f, 1.0f)));
}
}
if(pHandling->Flags & HANDLING_NARROW_FRONTW)
@@ -2947,7 +2948,7 @@ CAutomobile::ProcessControlInputs(uint8 pad)
0.2f*CTimer::GetTimeStep();
nLastControlInput = 0;
}
- m_fSteerInput = clamp(m_fSteerInput, -1.0f, 1.0f);
+ m_fSteerInput = Clamp(m_fSteerInput, -1.0f, 1.0f);
// Accelerate/Brake
float acceleration = (CPad::GetPad(pad)->GetAccelerate() - CPad::GetPad(pad)->GetBrake())/255.0f;
@@ -3067,7 +3068,7 @@ CAutomobile::FireTruckControl(void)
m_fCarGunLR += CPad::GetPad(0)->GetCarGunLeftRight() * 0.00025f * CTimer::GetTimeStep();
m_fCarGunUD += CPad::GetPad(0)->GetCarGunUpDown() * 0.0001f * CTimer::GetTimeStep();
}
- m_fCarGunUD = clamp(m_fCarGunUD, 0.05f, 0.3f);
+ m_fCarGunUD = Clamp(m_fCarGunUD, 0.05f, 0.3f);
CVector cannonPos(0.0f, 1.5f, 1.9f);
@@ -3492,7 +3493,7 @@ CAutomobile::HydraulicControl(void)
float limitDiff = extendedLowerLimit - normalLowerLimit;
if(limitDiff != 0.0f && Abs(maxDelta/limitDiff) > 0.01f){
float f = (maxDelta + limitDiff)/2.0f/limitDiff;
- f = clamp(f, 0.0f, 1.0f);
+ f = Clamp(f, 0.0f, 1.0f);
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_3, f);
if(f < 0.4f || f > 0.6f)
setPrevRatio = true;
@@ -5723,7 +5724,7 @@ void
CAutomobile::Save(uint8*& buf)
{
CVehicle::Save(buf);
- WriteSaveBuf<CDamageManager>(buf, Damage);
+ WriteSaveBuf(buf, Damage);
SkipSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager));
}
@@ -5731,7 +5732,7 @@ void
CAutomobile::Load(uint8*& buf)
{
CVehicle::Load(buf);
- Damage = ReadSaveBuf<CDamageManager>(buf);
+ ReadSaveBuf(&Damage, buf);
SkipSaveBuf(buf, 1500 - 672 - sizeof(CDamageManager));
SetupDamageAfterLoad();
}
diff --git a/src/vehicles/Bike.cpp b/src/vehicles/Bike.cpp
index ae567ae2..627cddbb 100644
--- a/src/vehicles/Bike.cpp
+++ b/src/vehicles/Bike.cpp
@@ -36,6 +36,7 @@
#include "Automobile.h"
#include "Bike.h"
#include "Debug.h"
+#include "SaveBuf.h"
const uint32 CBike::nSaveStructSize =
#ifdef COMPATIBLE_SAVES
@@ -535,7 +536,7 @@ CBike::ProcessControl(void)
m_fWheelAngle += DEGTORAD(1.0f)*CTimer::GetTimeStep();
if(bIsStanding){
float f = Pow(0.97f, CTimer::GetTimeStep());
- m_fLeanLRAngle2 = m_fLeanLRAngle2*f - (Asin(clamp(GetRight().z,-1.0f,1.0f))+DEGTORAD(15.0f))*(1.0f-f);
+ m_fLeanLRAngle2 = m_fLeanLRAngle2*f - (Asin(Clamp(GetRight().z,-1.0f,1.0f))+DEGTORAD(15.0f))*(1.0f-f);
m_fLeanLRAngle = m_fLeanLRAngle2;
}
}else{
@@ -1030,9 +1031,9 @@ CBike::ProcessControl(void)
lean = DotProduct(m_vecMoveSpeed-initialMoveSpeed, m_vecAvgSurfaceRight);
lean /= GRAVITY*Max(CTimer::GetTimeStep(), 0.01f);
if(m_wheelStatus[BIKEWHEEL_FRONT] == WHEEL_STATUS_BURST)
- lean = clamp(lean, -0.4f*pBikeHandling->fMaxLean, 0.4f*pBikeHandling->fMaxLean);
+ lean = Clamp(lean, -0.4f*pBikeHandling->fMaxLean, 0.4f*pBikeHandling->fMaxLean);
else
- lean = clamp(lean, -pBikeHandling->fMaxLean, pBikeHandling->fMaxLean);
+ lean = Clamp(lean, -pBikeHandling->fMaxLean, pBikeHandling->fMaxLean);
float f = Pow(pBikeHandling->fDesLean, CTimer::GetTimeStep());
m_fLeanLRAngle2 = (Asin(lean) - idleAngle)*(1.0f-f) + m_fLeanLRAngle2*f;
}else{
@@ -1055,11 +1056,11 @@ CBike::ProcessControl(void)
if(m_aSuspensionSpringRatio[BIKESUSP_R1] < 1.0f || m_aSuspensionSpringRatio[BIKESUSP_R2] < 1.0f){
// BUG: this clamp makes no sense and the arguments seem swapped too
ApplyTurnForce(contactPoints[BIKESUSP_R1],
- m_fTurnMass*Sin(m_fBrakeDestabilization)*clamp(fwdSpeed, 0.5f, 0.2f)*0.013f*GetRight()*CTimer::GetTimeStep());
+ m_fTurnMass*Sin(m_fBrakeDestabilization)*Clamp(fwdSpeed, 0.5f, 0.2f)*0.013f*GetRight()*CTimer::GetTimeStep());
}else{
// BUG: this clamp makes no sense and the arguments seem swapped too
ApplyTurnForce(contactPoints[BIKESUSP_R1],
- m_fTurnMass*Sin(m_fBrakeDestabilization)*clamp(fwdSpeed, 0.5f, 0.2f)*0.003f*GetRight()*CTimer::GetTimeStep());
+ m_fTurnMass*Sin(m_fBrakeDestabilization)*Clamp(fwdSpeed, 0.5f, 0.2f)*0.003f*GetRight()*CTimer::GetTimeStep());
}
}else
m_fBrakeDestabilization = 0.0f;
@@ -1222,7 +1223,7 @@ CBike::ProcessControl(void)
// Balance bike
if(bBalancedByRider || bIsBeingPickedUp || bIsStanding){
float onSideness = DotProduct(GetRight(), m_vecAvgSurfaceNormal);
- onSideness = clamp(onSideness, -1.0f, 1.0f);
+ onSideness = Clamp(onSideness, -1.0f, 1.0f);
CVector worldCOM = Multiply3x3(GetMatrix(), m_vecCentreOfMass);
// Keep bike upright
if(bBalancedByRider){
@@ -1842,7 +1843,7 @@ CBike::ProcessControlInputs(uint8 pad)
0.2f*CTimer::GetTimeStep();
nLastControlInput = 0;
}
- m_fSteerInput = clamp(m_fSteerInput, -1.0f, 1.0f);
+ m_fSteerInput = Clamp(m_fSteerInput, -1.0f, 1.0f);
// Lean forward/backward
float updown;
@@ -1852,7 +1853,7 @@ CBike::ProcessControlInputs(uint8 pad)
#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);
+ m_fLeanInput = Clamp(m_fLeanInput, -1.0f, 1.0f);
// Accelerate/Brake
float acceleration = (CPad::GetPad(pad)->GetAccelerate() - CPad::GetPad(pad)->GetBrake())/255.0f;
diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp
index 3b9290ea..ab70f19b 100644
--- a/src/vehicles/Boat.cpp
+++ b/src/vehicles/Boat.cpp
@@ -28,6 +28,7 @@
#include "Record.h"
#include "Shadows.h"
#include "Wanted.h"
+#include "SaveBuf.h"
#define INVALID_ORIENTATION (-9999.99f)
@@ -157,9 +158,9 @@ CBoat::ProcessControl(void)
r = 127.5f*(CTimeCycle::GetAmbientRed_Obj() + 0.5f*CTimeCycle::GetDirectionalRed());
g = 127.5f*(CTimeCycle::GetAmbientGreen_Obj() + 0.5f*CTimeCycle::GetDirectionalGreen());
b = 127.5f*(CTimeCycle::GetAmbientBlue_Obj() + 0.5f*CTimeCycle::GetDirectionalBlue());
- r = clamp(r, 0, 255);
- g = clamp(g, 0, 255);
- b = clamp(b, 0, 255);
+ r = Clamp(r, 0, 255);
+ g = Clamp(g, 0, 255);
+ b = Clamp(b, 0, 255);
splashColor.red = r;
splashColor.green = g;
splashColor.blue = b;
@@ -168,9 +169,9 @@ CBoat::ProcessControl(void)
r = 229.5f*(CTimeCycle::GetAmbientRed() + 0.85f*CTimeCycle::GetDirectionalRed());
g = 229.5f*(CTimeCycle::GetAmbientGreen() + 0.85f*CTimeCycle::GetDirectionalGreen());
b = 229.5f*(CTimeCycle::GetAmbientBlue() + 0.85f*CTimeCycle::GetDirectionalBlue());
- r = clamp(r, 0, 255);
- g = clamp(g, 0, 255);
- b = clamp(b, 0, 255);
+ r = Clamp(r, 0, 255);
+ g = Clamp(g, 0, 255);
+ b = Clamp(b, 0, 255);
jetColor.red = r;
jetColor.green = g;
jetColor.blue = b;
@@ -386,7 +387,7 @@ CBoat::ProcessControl(void)
if(CPad::GetPad(0)->GetHandBrake())
steerLoss *= 0.5f;
steerFactor -= steerLoss;
- steerFactor = clamp(steerFactor, 0.0f, 1.0f);
+ steerFactor = Clamp(steerFactor, 0.0f, 1.0f);
}
CVector boundMin = GetColModel()->boundingBox.min;
@@ -771,17 +772,17 @@ CBoat::ProcessControlInputs(uint8 pad)
m_nPadID = 3;
m_fBrake += (CPad::GetPad(pad)->GetBrake()/255.0f - m_fBrake)*0.1f;
- m_fBrake = clamp(m_fBrake, 0.0f, 1.0f);
+ m_fBrake = Clamp(m_fBrake, 0.0f, 1.0f);
if(m_fBrake < 0.05f){
m_fBrake = 0.0f;
m_fAccelerate += (CPad::GetPad(pad)->GetAccelerate()/255.0f - m_fAccelerate)*0.1f;
- m_fAccelerate = clamp(m_fAccelerate, 0.0f, 1.0f);
+ m_fAccelerate = Clamp(m_fAccelerate, 0.0f, 1.0f);
}else
m_fAccelerate = -m_fBrake*0.3f;
m_fSteeringLeftRight += (-CPad::GetPad(pad)->GetSteeringLeftRight()/128.0f - m_fSteeringLeftRight)*0.2f;
- m_fSteeringLeftRight = clamp(m_fSteeringLeftRight, -1.0f, 1.0f);
+ m_fSteeringLeftRight = Clamp(m_fSteeringLeftRight, -1.0f, 1.0f);
float steeringSq = m_fSteeringLeftRight < 0.0f ? -SQR(m_fSteeringLeftRight) : SQR(m_fSteeringLeftRight);
m_fSteerAngle = pHandling->fSteeringLock * DEGTORAD(steeringSq);
@@ -1064,7 +1065,7 @@ CBoat::PreRender(void)
rot = CGeneral::LimitRadianAngle(rot);
if(rot > HALFPI) rot = PI;
else if(rot < -HALFPI) rot = -PI;
- rot = clamp(rot, -DEGTORAD(63.0f), DEGTORAD(63.0f));
+ rot = Clamp(rot, -DEGTORAD(63.0f), DEGTORAD(63.0f));
m_fMovingSpeed += (0.008f * CWeather::Wind + 0.002f) * rot;
m_fMovingSpeed *= Pow(0.9985f, CTimer::GetTimeStep())/(500.0f*SQR(m_fMovingSpeed) + 1.0f);
diff --git a/src/vehicles/CarGen.cpp b/src/vehicles/CarGen.cpp
index 78e67d49..29d0c5c7 100644
--- a/src/vehicles/CarGen.cpp
+++ b/src/vehicles/CarGen.cpp
@@ -17,6 +17,7 @@
#include "World.h"
#include "Zones.h"
#include "Occlusion.h"
+#include "SaveBuf.h"
uint8 CTheCarGenerators::ProcessCounter;
uint32 CTheCarGenerators::NumOfCarGenerators;
@@ -292,14 +293,17 @@ void CTheCarGenerators::LoadAllCarGenerators(uint8* buffer, uint32 size)
Init();
INITSAVEBUF
CheckSaveHeader(buffer, 'C','G','N','\0', size - SAVE_HEADER_SIZE);
- assert(ReadSaveBuf<uint32>(buffer) == nGeneralDataSize);
- NumOfCarGenerators = ReadSaveBuf<uint32>(buffer);
- CurrentActiveCount = ReadSaveBuf<uint32>(buffer);
- ProcessCounter = ReadSaveBuf<uint8>(buffer);
- GenerateEvenIfPlayerIsCloseCounter = ReadSaveBuf<uint8>(buffer);
- ReadSaveBuf<int16>(buffer); // alignment
- assert(ReadSaveBuf<uint32>(buffer) == sizeof(CarGeneratorArray));
+ uint32 tmp;
+ ReadSaveBuf(&tmp, buffer);
+ assert(tmp == nGeneralDataSize);
+ ReadSaveBuf(&NumOfCarGenerators, buffer);
+ ReadSaveBuf(&CurrentActiveCount, buffer);
+ ReadSaveBuf(&ProcessCounter, buffer);
+ ReadSaveBuf(&GenerateEvenIfPlayerIsCloseCounter, buffer);
+ SkipSaveBuf(buffer, 2);
+ ReadSaveBuf(&tmp, buffer);
+ assert(tmp == sizeof(CarGeneratorArray));
for (int i = 0; i < NUM_CARGENS; i++)
- CarGeneratorArray[i] = ReadSaveBuf<CCarGenerator>(buffer);
+ ReadSaveBuf(&CarGeneratorArray[i], buffer);
VALIDATESAVEBUF(size)
}
diff --git a/src/vehicles/Cranes.cpp b/src/vehicles/Cranes.cpp
index a675fe4e..857b846f 100644
--- a/src/vehicles/Cranes.cpp
+++ b/src/vehicles/Cranes.cpp
@@ -11,6 +11,7 @@
#include "Replay.h"
#include "Object.h"
#include "World.h"
+#include "SaveBuf.h"
#define MAX_DISTANCE_TO_FIND_CRANE (100.0f)
#define CRANE_UPDATE_RADIUS (300.0f)
@@ -643,10 +644,10 @@ void CCranes::Load(uint8* buf, uint32 size)
{
INITSAVEBUF
- NumCranes = ReadSaveBuf<int32>(buf);
- CarsCollectedMilitaryCrane = ReadSaveBuf<uint32>(buf);
+ ReadSaveBuf(&NumCranes, buf);
+ ReadSaveBuf(&CarsCollectedMilitaryCrane, buf);
for (int i = 0; i < NUM_CRANES; i++)
- aCranes[i] = ReadSaveBuf<CCrane>(buf);
+ ReadSaveBuf(&aCranes[i], buf);
for (int i = 0; i < NUM_CRANES; i++) {
CCrane *pCrane = &aCranes[i];
if (pCrane->m_pCraneEntity != nil)
diff --git a/src/vehicles/Door.cpp b/src/vehicles/Door.cpp
index 72a30339..6e35c951 100644
--- a/src/vehicles/Door.cpp
+++ b/src/vehicles/Door.cpp
@@ -52,11 +52,11 @@ CDoor::Process(CVehicle *vehicle)
fSpeedDiff = vecSpeedDiff.y - vecSpeedDiff.x;
break;
}
- fSpeedDiff = clamp(fSpeedDiff, -0.2f, 0.2f);
+ fSpeedDiff = Clamp(fSpeedDiff, -0.2f, 0.2f);
if(Abs(fSpeedDiff) > 0.002f)
m_fAngVel += fSpeedDiff;
m_fAngVel *= 0.945f;
- m_fAngVel = clamp(m_fAngVel, -0.3f, 0.3f);
+ m_fAngVel = Clamp(m_fAngVel, -0.3f, 0.3f);
m_fAngle += m_fAngVel;
m_nDoorState = DOORST_SWINGING;
diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp
index 3f01ff41..a8423855 100644
--- a/src/vehicles/Heli.cpp
+++ b/src/vehicles/Heli.cpp
@@ -260,7 +260,7 @@ CHeli::ProcessControl(void)
// Move up if too low
if(GetPosition().z - 2.0f < groundZ && m_heliStatus != HELI_STATUS_SHOT_DOWN)
m_vecMoveSpeed.z += CTimer::GetTimeStep()*0.01f;
- m_vecMoveSpeed.z = clamp(m_vecMoveSpeed.z, -0.3f, 0.3f);
+ m_vecMoveSpeed.z = Clamp(m_vecMoveSpeed.z, -0.3f, 0.3f);
}
float fTargetDist = vTargetDist.Magnitude();
diff --git a/src/vehicles/Transmission.cpp b/src/vehicles/Transmission.cpp
index f7851f47..efc32079 100644
--- a/src/vehicles/Transmission.cpp
+++ b/src/vehicles/Transmission.cpp
@@ -150,7 +150,7 @@ cTransmission::CalculateDriveAcceleration(const float &gasPedal, uint8 &gear, fl
else if(cheat == 2)
inertiaMult *= TRANSMISSION_NITROS_INERTIA_MULT;
float var2target = 1.0f - inertiaMult*fEngineInertia;
- var2target = clamp(var2target, 0.1f, 1.0f);
+ var2target = Clamp(var2target, 0.1f, 1.0f);
*inertiaVar2 = (1.0f-TRANSMISSION_SMOOTHER_FRAC)*var2target + TRANSMISSION_SMOOTHER_FRAC*(*inertiaVar2);
*inertiaVar1 = var1;
fAcceleration *= *inertiaVar2;
diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp
index 6594e05f..e684aad7 100644
--- a/src/vehicles/Vehicle.cpp
+++ b/src/vehicles/Vehicle.cpp
@@ -32,6 +32,7 @@
#include "Timecycle.h"
#include "Weather.h"
#include "Coronas.h"
+#include "SaveBuf.h"
bool CVehicle::bWheelsOnlyCheat;
bool CVehicle::bAllDodosCheat;
@@ -479,11 +480,11 @@ CVehicle::FlyingControl(eFlightModel flightModel)
ApplyMoveForce(GRAVITY * GetUp() * fThrust * m_fMass * CTimer::GetTimeStep());
if (GetUp().z > 0.0f){
- float upRight = clamp(GetRight().z, -flyingHandling->fFormLift, flyingHandling->fFormLift);
+ float upRight = Clamp(GetRight().z, -flyingHandling->fFormLift, flyingHandling->fFormLift);
float upImpulseRight = -upRight * flyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep();
ApplyTurnForce(upImpulseRight * GetUp(), GetRight());
- float upFwd = clamp(GetForward().z, -flyingHandling->fFormLift, flyingHandling->fFormLift);
+ float upFwd = Clamp(GetForward().z, -flyingHandling->fFormLift, flyingHandling->fFormLift);
float upImpulseFwd = -upFwd * flyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep();
ApplyTurnForce(upImpulseFwd * GetUp(), GetForward());
}else{
@@ -522,8 +523,8 @@ CVehicle::FlyingControl(eFlightModel flightModel)
fPitch = -CPad::GetPad(0)->GetCarGunUpDown() / 128.0f;
if (CPad::GetPad(0)->GetHorn()) {
fYaw = 0.0f;
- fPitch = clamp(flyingHandling->fPitchStab * DotProduct(m_vecMoveSpeed, GetForward()), -200.0f, 1.3f);
- fRoll = clamp(flyingHandling->fRollStab * DotProduct(m_vecMoveSpeed, GetRight()), -200.0f, 1.3f);
+ fPitch = Clamp(flyingHandling->fPitchStab * DotProduct(m_vecMoveSpeed, GetForward()), -200.0f, 1.3f);
+ fRoll = Clamp(flyingHandling->fRollStab * DotProduct(m_vecMoveSpeed, GetRight()), -200.0f, 1.3f);
}
ApplyTurnForce(fPitch * GetUp() * flyingHandling->fPitch * m_fTurnMass * CTimer::GetTimeStep(), GetForward());
ApplyTurnForce(fRoll * GetUp() * flyingHandling->fRoll * m_fTurnMass * CTimer::GetTimeStep(), GetRight());
@@ -2173,9 +2174,9 @@ CVehicle::HeliDustGenerate(CEntity *heli, float radius, float ground, int rnd)
float red = (0.3*CTimeCycle::GetDirectionalRed() + CTimeCycle::GetAmbientRed_Obj())*255.0f/4.0f;
float green = (0.3*CTimeCycle::GetDirectionalGreen() + CTimeCycle::GetAmbientGreen_Obj())*255.0f/4.0f;
float blue = (0.3*CTimeCycle::GetDirectionalBlue() + CTimeCycle::GetAmbientBlue_Obj())*255.0f/4.0f;
- r = clamp(red, 0.0f, 255.0f);
- g = clamp(green, 0.0f, 255.0f);
- b = clamp(blue, 0.0f, 255.0f);
+ r = Clamp(red, 0.0f, 255.0f);
+ g = Clamp(green, 0.0f, 255.0f);
+ b = Clamp(blue, 0.0f, 255.0f);
RwRGBA col1 = { r, g, b, (RwUInt8)CGeneral::GetRandomNumberInRange(8, 32) };
RwRGBA col2 = { 255, 255, 255, 32 };
@@ -2438,43 +2439,44 @@ CVehicle::Load(uint8*& buf)
{
CMatrix tmp;
SkipSaveBuf(buf, 4);
- tmp.GetRight().x = ReadSaveBuf<float>(buf);
- tmp.GetRight().y = ReadSaveBuf<float>(buf);
- tmp.GetRight().z = ReadSaveBuf<float>(buf);
+ ReadSaveBuf(&tmp.GetRight().x, buf);
+ ReadSaveBuf(&tmp.GetRight().y, buf);
+ ReadSaveBuf(&tmp.GetRight().z, buf);
SkipSaveBuf(buf, 4);
- tmp.GetForward().x = ReadSaveBuf<float>(buf);
- tmp.GetForward().y = ReadSaveBuf<float>(buf);
- tmp.GetForward().z = ReadSaveBuf<float>(buf);
+ ReadSaveBuf(&tmp.GetForward().x, buf);
+ ReadSaveBuf(&tmp.GetForward().y, buf);
+ ReadSaveBuf(&tmp.GetForward().z, buf);
SkipSaveBuf(buf, 4);
- tmp.GetUp().x = ReadSaveBuf<float>(buf);
- tmp.GetUp().y = ReadSaveBuf<float>(buf);
- tmp.GetUp().z = ReadSaveBuf<float>(buf);
+ ReadSaveBuf(&tmp.GetUp().x, buf);
+ ReadSaveBuf(&tmp.GetUp().y, buf);
+ ReadSaveBuf(&tmp.GetUp().z, buf);
SkipSaveBuf(buf, 4);
- tmp.GetPosition().x = ReadSaveBuf<float>(buf);
- tmp.GetPosition().y = ReadSaveBuf<float>(buf);
- tmp.GetPosition().z = ReadSaveBuf<float>(buf);
+ ReadSaveBuf(&tmp.GetPosition().x, buf);
+ ReadSaveBuf(&tmp.GetPosition().y, buf);
+ ReadSaveBuf(&tmp.GetPosition().z, buf);
m_matrix = tmp;
SkipSaveBuf(buf, 16);
LoadEntityFlags(buf);
SkipSaveBuf(buf, 208);
AutoPilot.Load(buf);
- m_currentColour1 = ReadSaveBuf<int8>(buf);
- m_currentColour2 = ReadSaveBuf<int8>(buf);
+ ReadSaveBuf(&m_currentColour1, buf);
+ ReadSaveBuf(&m_currentColour2, buf);
SkipSaveBuf(buf, 2);
- m_nAlarmState = ReadSaveBuf<int16>(buf);
+ ReadSaveBuf(&m_nAlarmState, buf);
SkipSaveBuf(buf, 42);
- m_nNumMaxPassengers = ReadSaveBuf<int8>(buf);
+ ReadSaveBuf(&m_nNumMaxPassengers, buf);
SkipSaveBuf(buf, 3);
- field_1D0[0] = ReadSaveBuf<float>(buf);
- field_1D0[1] = ReadSaveBuf<float>(buf);
- field_1D0[2] = ReadSaveBuf<float>(buf);
- field_1D0[3] = ReadSaveBuf<float>(buf);
+ ReadSaveBuf(&field_1D0[0], buf);
+ ReadSaveBuf(&field_1D0[1], buf);
+ ReadSaveBuf(&field_1D0[2], buf);
+ ReadSaveBuf(&field_1D0[3], buf);
SkipSaveBuf(buf, 8);
- m_fSteerAngle = ReadSaveBuf<float>(buf);
- m_fGasPedal = ReadSaveBuf<float>(buf);
- m_fBrakePedal = ReadSaveBuf<float>(buf);
- VehicleCreatedBy = ReadSaveBuf<uint8>(buf);
- uint8 flags = ReadSaveBuf<uint8>(buf);
+ ReadSaveBuf(&m_fSteerAngle, buf);
+ ReadSaveBuf(&m_fGasPedal, buf);
+ ReadSaveBuf(&m_fBrakePedal, buf);
+ ReadSaveBuf(&VehicleCreatedBy, buf);
+ uint8 flags;
+ ReadSaveBuf(&flags, buf);
bIsLawEnforcer = !!(flags & BIT(0));
bIsLocked = !!(flags & BIT(3));
bEngineOn = !!(flags & BIT(4));
@@ -2482,16 +2484,17 @@ CVehicle::Load(uint8*& buf)
bLightsOn = !!(flags & BIT(6));
bFreebies = !!(flags & BIT(7));
SkipSaveBuf(buf, 10);
- m_fHealth = ReadSaveBuf<float>(buf);
- m_nCurrentGear = ReadSaveBuf<uint8>(buf);
+ ReadSaveBuf(&m_fHealth, buf);
+ ReadSaveBuf(&m_nCurrentGear, buf);
SkipSaveBuf(buf, 3);
- m_fChangeGearTime = ReadSaveBuf<float>(buf);
+ ReadSaveBuf(&m_fChangeGearTime, buf);
SkipSaveBuf(buf, 12);
- m_nTimeOfDeath = ReadSaveBuf<uint32>(buf);
+ ReadSaveBuf(&m_nTimeOfDeath, buf);
SkipSaveBuf(buf, 2);
- m_nBombTimer = ReadSaveBuf<int16>(buf);
+ ReadSaveBuf(&m_nBombTimer, buf);
SkipSaveBuf(buf, 12);
- m_nDoorLock = (eCarLock)ReadSaveBuf<int8>(buf);
+ ReadSaveBuf(&flags, buf);
+ m_nDoorLock = (eCarLock)flags;
SkipSaveBuf(buf, 111);
}
#endif