Skip to content

Commit 0f89a90

Browse files
committed
New argument
1 parent fa33d11 commit 0f89a90

File tree

10 files changed

+25
-42
lines changed

10 files changed

+25
-42
lines changed

Client/game_sa/CHeliSA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "StdInc.h"
1212
#include "CHeliSA.h"
1313

14-
CHeliSA::CHeliSA(CHeliSAInterface* pInterface) : m_rotorState(true)
14+
CHeliSA::CHeliSA(CHeliSAInterface* pInterface)
1515
{
1616
SetInterface(pInterface);
1717
Init();

Client/game_sa/CHeliSA.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,4 @@ class CHeliSA final : public virtual CHeli, public virtual CAutomobileSA
5353
{
5454
public:
5555
CHeliSA(CHeliSAInterface* pInterface);
56-
57-
// Not SA
58-
bool GetHeliRotorState() noexcept override { return m_rotorState; }
59-
void SetHeliRotorState(bool state) noexcept override { m_rotorState = state; }
60-
61-
private:
62-
bool m_rotorState;
6356
};

Client/game_sa/CVehicleSA.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ bool CanProcessFlyingCarStuff(CHeliSAInterface* heliInterface)
5858
if (!vehicle || !vehicle->pEntity)
5959
return true;
6060

61-
auto* heli = reinterpret_cast<CHeliSA*>(vehicle->pEntity);
62-
if (!heli)
63-
return true;
64-
65-
return heli->GetHeliRotorState();
61+
return vehicle->pEntity->GetHeliRotorState();
6662
}
6763

6864
void _declspec(naked) HOOK_CHeli_ProcessFlyingCarStuff()
@@ -540,6 +536,14 @@ void CVehicleSA::SetHeliRotorSpeed(float speed)
540536
heliInterface->m_wheelSpeed[1] = speed;
541537
}
542538

539+
void CVehicleSA::SetHeliRotorState(bool state, bool stopRotor) noexcept
540+
{
541+
m_heliRotorState = state;
542+
543+
if (!state && stopRotor)
544+
SetHeliRotorSpeed(0.0f);
545+
}
546+
543547
void CVehicleSA::SetPlaneRotorSpeed(float fSpeed)
544548
{
545549
auto pInterface = static_cast<CPlaneSAInterface*>(GetInterface());

Client/game_sa/CVehicleSA.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ class CVehicleSA : public virtual CVehicle, public virtual CPhysicalSA
415415
unsigned char m_ucVariant2;
416416
unsigned char m_ucVariantCount{0};
417417
bool m_doorsUndamageable{false};
418+
bool m_heliRotorState{true};
418419

419420
std::array<CVector, VEHICLE_DUMMY_COUNT> m_dummyPositions;
420421

@@ -546,6 +547,7 @@ class CVehicleSA : public virtual CVehicle, public virtual CPhysicalSA
546547
bool GetTyresDontBurst() { return GetVehicleInterface()->m_nVehicleFlags.bTyresDontBurst; };
547548
unsigned short GetAdjustablePropertyValue() { return *reinterpret_cast<unsigned short*>(reinterpret_cast<unsigned long>(m_pInterface) + 2156); };
548549
float GetHeliRotorSpeed();
550+
bool GetHeliRotorState() const noexcept override { return m_heliRotorState; }
549551
float GetPlaneRotorSpeed();
550552

551553
unsigned long GetExplodeTime() { return *reinterpret_cast<unsigned long*>(reinterpret_cast<unsigned int>(m_pInterface) + 1240); };
@@ -572,6 +574,7 @@ class CVehicleSA : public virtual CVehicle, public virtual CPhysicalSA
572574
*reinterpret_cast<unsigned short*>(reinterpret_cast<unsigned int>(m_pInterface) + 2156) = usAdjustableProperty;
573575
};
574576
void SetHeliRotorSpeed(float speed);
577+
void SetHeliRotorState(bool state, bool stopRotor) noexcept override;
575578
void SetPlaneRotorSpeed(float fSpeed);
576579
bool SetVehicleWheelRotation(float fWheelRot1, float fWheelRot2, float fWheelRot3, float fWheelRot4) noexcept;
577580
void SetExplodeTime(unsigned long ulTime) { *reinterpret_cast<unsigned long*>(reinterpret_cast<unsigned int>(m_pInterface) + 1240) = ulTime; };

Client/mods/deathmatch/logic/CClientVehicle.cpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ CClientVehicle::CClientVehicle(CClientManager* pManager, ElementID ID, unsigned
171171
m_fNitroLevel = 1.0f;
172172
m_cNitroCount = 0;
173173
m_fWheelScale = 1.0f;
174-
m_heliRotorState = m_eVehicleType == CLIENTVEHICLE_HELI;
175174

176175
for (unsigned int i = 0; i < MAX_WINDOWS; ++i)
177176
{
@@ -1578,30 +1577,15 @@ void CClientVehicle::SetHeliRotorSpeed(float fSpeed)
15781577
m_fHeliRotorSpeed = fSpeed;
15791578
}
15801579

1581-
bool CClientVehicle::GetHeliRotorState()
1580+
bool CClientVehicle::GetHeliRotorState() const noexcept
15821581
{
1583-
if (m_pVehicle && m_eVehicleType == CLIENTVEHICLE_HELI)
1584-
{
1585-
auto* heli = reinterpret_cast<CHeli*>(m_pVehicle);
1586-
if (heli)
1587-
return heli->GetHeliRotorState();
1588-
}
1589-
1590-
return m_heliRotorState;
1582+
return m_pVehicle && m_eVehicleType == CLIENTVEHICLE_HELI ? m_pVehicle->GetHeliRotorState() : m_heliRotorState;
15911583
}
15921584

1593-
void CClientVehicle::SetHeliRotorState(bool state)
1585+
void CClientVehicle::SetHeliRotorState(bool state, bool stopRotor) noexcept
15941586
{
15951587
if (m_pVehicle && m_eVehicleType == CLIENTVEHICLE_HELI)
1596-
{
1597-
auto* heli = reinterpret_cast<CHeli*>(m_pVehicle);
1598-
if (heli)
1599-
{
1600-
heli->SetHeliRotorState(state);
1601-
if (!state)
1602-
heli->SetHeliRotorSpeed(0.0f);
1603-
}
1604-
}
1588+
m_pVehicle->SetHeliRotorState(state, stopRotor);
16051589

16061590
m_heliRotorState = state;
16071591
}

Client/mods/deathmatch/logic/CClientVehicle.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,12 @@ class CClientVehicle : public CClientStreamElement
299299
// TODO: Make the class remember on virtualization
300300
float GetHeliRotorSpeed();
301301
float GetPlaneRotorSpeed();
302-
bool GetHeliRotorState();
302+
bool GetHeliRotorState() const noexcept;
303303

304304
bool GetRotorSpeed(float&);
305305
bool SetRotorSpeed(float);
306306
bool SetWheelsRotation(float fRot1, float fRot2, float fRot3, float fRot4) noexcept;
307-
void SetHeliRotorState(bool state);
307+
void SetHeliRotorState(bool state, bool stopRotor) noexcept;
308308
void SetHeliRotorSpeed(float fSpeed);
309309
void SetPlaneRotorSpeed(float fSpeed);
310310
bool IsHeliSearchLightVisible();
@@ -673,7 +673,7 @@ class CClientVehicle : public CClientStreamElement
673673
uchar m_ucTrackID;
674674
bool m_bJustStreamedIn;
675675
bool m_bWheelScaleChanged;
676-
bool m_heliRotorState;
676+
bool m_heliRotorState{true};
677677

678678
// Time dependent error compensation interpolation
679679
struct

Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4279,12 +4279,12 @@ std::variant<bool, std::array<CVector, 4>> CLuaVehicleDefs::OOP_GetVehicleEntryP
42794279
return entryPoints;
42804280
}
42814281

4282-
bool CLuaVehicleDefs::SetHeliRotorState(CClientVehicle* vehicle, bool state)
4282+
bool CLuaVehicleDefs::SetHeliRotorState(CClientVehicle* vehicle, bool state, std::optional<bool> stopRotor)
42834283
{
42844284
if (vehicle->GetVehicleType() != eClientVehicleType::CLIENTVEHICLE_HELI)
42854285
return false;
42864286

4287-
vehicle->SetHeliRotorState(state);
4287+
vehicle->SetHeliRotorState(state, stopRotor.value_or(true));
42884288
return true;
42894289
}
42904290

Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class CLuaVehicleDefs : public CLuaDefs
166166
static bool SetVehicleModelWheelSize(const unsigned short usModel, const eResizableVehicleWheelGroup eWheelGroup, const float fWheelSize);
167167
static int GetVehicleWheelFrictionState(CClientVehicle* pVehicle, unsigned char wheel);
168168

169-
static bool SetHeliRotorState(CClientVehicle* const vehicle, bool state);
169+
static bool SetHeliRotorState(CClientVehicle* const vehicle, bool state, std::optional<bool> stopRotor);
170170
static bool GetHeliRotorState(CClientVehicle* const vehicle);
171171

172172
// Components

Client/sdk/game/CHeli.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,4 @@ class CHeli : public virtual CAutomobile
1616
{
1717
public:
1818
virtual ~CHeli(){};
19-
20-
virtual void SetHeliRotorState(bool state) = 0;
21-
virtual bool GetHeliRotorState() = 0;
2219
};

Client/sdk/game/CVehicle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ class CVehicle : public virtual CPhysical
199199
virtual bool GetTyresDontBurst() = 0;
200200
virtual unsigned short GetAdjustablePropertyValue() = 0;
201201
virtual float GetHeliRotorSpeed() = 0;
202+
virtual bool GetHeliRotorState() const noexcept = 0;
202203
virtual float GetPlaneRotorSpeed() = 0;
203204
virtual unsigned long GetExplodeTime() = 0;
204205

@@ -220,6 +221,7 @@ class CVehicle : public virtual CPhysical
220221
virtual void SetTyresDontBurst(bool bTyresDontBurst) = 0;
221222
virtual void SetAdjustablePropertyValue(unsigned short usAdjustableProperty) = 0;
222223
virtual void SetHeliRotorSpeed(float fSpeed) = 0;
224+
virtual void SetHeliRotorState(bool state, bool stopRotor) noexcept = 0;
223225
virtual void SetPlaneRotorSpeed(float fSpeed) = 0;
224226
virtual bool SetVehicleWheelRotation(float fRot1, float fRot2, float fRot3, float fRot4) noexcept = 0;
225227
virtual void SetTaxiLightOn(bool bLightState) = 0;

0 commit comments

Comments
 (0)