Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization Handling (part 3) and Remove big use eVehicleTypes #3848

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
394df3a
Update
Moris-Onz Nov 8, 2024
b84fa60
Update 2
Moris-Onz Nov 8, 2024
6e8565e
Update 3
Moris-Onz Nov 8, 2024
203fb7c
Fix by TracerDS 1
Moris-Onz Nov 8, 2024
8ca57f0
Update 4
Moris-Onz Nov 9, 2024
1e6992d
Update 4 (mini fix)
Moris-Onz Nov 9, 2024
9610dbc
Fix crash
Moris-Onz Nov 9, 2024
b066bc3
Refactor AddVehicle and AddTrain
Moris-Onz Nov 10, 2024
e5113de
Update 5
Moris-Onz Nov 10, 2024
ffd2ba7
Update 5 (Fix)
Moris-Onz Nov 10, 2024
434457a
Update 6
Moris-Onz Nov 10, 2024
bea11d6
std::shared_ptr from CHandlingManagerSA
Moris-Onz Nov 10, 2024
96a3cc4
std::shared_ptr for CPoolsSA (Test)
Moris-Onz Nov 10, 2024
0f6246e
Revert "std::shared_ptr for CPoolsSA (Test)"
Moris-Onz Nov 10, 2024
3d0b407
std::unique_ptr for CPoolsSA
Moris-Onz Nov 10, 2024
f901042
Update 7
Moris-Onz Nov 11, 2024
bd79171
Add CModelInfoSA::IsVehicleModel
Moris-Onz Nov 11, 2024
0462828
Merge branch 'master' into clean-eVehicleTypes
G-Moris Nov 12, 2024
4888066
Merge branch 'master' into clean-eVehicleTypes
G-Moris Nov 15, 2024
1e87d4a
Merge branch 'master' into clean-eVehicleTypes
G-Moris Nov 16, 2024
e3b6707
Merge branch 'master' into clean-eVehicleTypes
G-Moris Nov 20, 2024
77efe2d
Merge branch 'master' into clean-eVehicleTypes
Dutchman101 Nov 21, 2024
55098d6
Merge branch 'master' into clean-eVehicleTypes
G-Moris Nov 21, 2024
fcc2c93
Merge branch 'master' into clean-eVehicleTypes
G-Moris Nov 22, 2024
8641aba
Merge branch 'master' into clean-eVehicleTypes
G-Moris Nov 27, 2024
d46c9df
Merge branch 'master' into clean-eVehicleTypes
G-Moris Nov 29, 2024
47068d4
Fixes by TheNormalnij
Moris-Onz Nov 29, 2024
b0cddf5
Merge branch 'clean-eVehicleTypes' of https://github.com/G-Moris/mtas…
Moris-Onz Nov 29, 2024
0486d25
Fix style
Moris-Onz Nov 29, 2024
ece4318
Merge branch 'master' into clean-eVehicleTypes
G-Moris Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 31 additions & 12 deletions Client/game_sa/CHandlingEntrySA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ extern CGameSA* pGame;
CHandlingEntrySA::CHandlingEntrySA()
{
// Create a new interface and zero it
m_pHandlingSA = new tHandlingDataSA;
memset(m_pHandlingSA, 0, sizeof(tHandlingDataSA));
m_pHandlingSA = new (std::nothrow) tHandlingDataSA;
G-Moris marked this conversation as resolved.
Show resolved Hide resolved
if (m_pHandlingSA)
{
memset(m_pHandlingSA, 0, sizeof(tHandlingDataSA));
}
m_bDeleteInterface = true;
}

Expand All @@ -29,7 +32,11 @@ CHandlingEntrySA::CHandlingEntrySA(tHandlingDataSA* pOriginal)
// Store gta's pointer
m_pHandlingSA = nullptr;
m_bDeleteInterface = false;
memcpy(&m_Handling, pOriginal, sizeof(tHandlingDataSA));

if (pOriginal)
{
memcpy(&m_Handling, pOriginal, sizeof(tHandlingDataSA));
G-Moris marked this conversation as resolved.
Show resolved Hide resolved
}
}

CHandlingEntrySA::~CHandlingEntrySA()
Expand All @@ -41,25 +48,37 @@ CHandlingEntrySA::~CHandlingEntrySA()
}

// Apply the handlingdata from another data
void CHandlingEntrySA::Assign(const CHandlingEntry* pEntry)
void CHandlingEntrySA::Assign(const CHandlingEntry* pEntry) noexcept
{
if (!pEntry)
return;

// Copy the data
const CHandlingEntrySA* pEntrySA = static_cast<const CHandlingEntrySA*>(pEntry);
m_Handling = pEntrySA->m_Handling;
try
{
// Copy the data
const CHandlingEntrySA* pEntrySA = static_cast<const CHandlingEntrySA*>(pEntry);
m_Handling = pEntrySA->m_Handling;
}
catch (...)
{
}
}

void CHandlingEntrySA::Recalculate()
void CHandlingEntrySA::Recalculate() noexcept
{
// Real GTA class?
if (!m_pHandlingSA)
return;

// Copy our stored field to GTA's
memcpy(m_pHandlingSA, &m_Handling, sizeof(m_Handling));
((void(_stdcall*)(tHandlingDataSA*))FUNC_HandlingDataMgr_ConvertDataToGameUnits)(m_pHandlingSA);
try
{
// Copy our stored field to GTA's
memcpy(m_pHandlingSA, &m_Handling, sizeof(m_Handling));
((void(_stdcall*)(tHandlingDataSA*))FUNC_HandlingDataMgr_ConvertDataToGameUnits)(m_pHandlingSA);
}
catch (...)
{
}
}

void CHandlingEntrySA::SetSuspensionForceLevel(float fForce) noexcept
Expand Down Expand Up @@ -104,7 +123,7 @@ void CHandlingEntrySA::SetSuspensionAntiDiveMultiplier(float fAntidive) noexcept
m_Handling.fSuspensionAntiDiveMultiplier = fAntidive;
}

void CHandlingEntrySA::CheckSuspensionChanges() noexcept
void CHandlingEntrySA::CheckSuspensionChanges() const noexcept
{
pGame->GetHandlingManager()->CheckSuspensionChanges(this);
}
128 changes: 64 additions & 64 deletions Client/game_sa/CHandlingEntrySA.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,78 +96,78 @@ class CHandlingEntrySA : public CHandlingEntry
virtual ~CHandlingEntrySA();

// Use this to copy data from an another handling class to this
void Assign(const CHandlingEntry* pEntry);
void Assign(const CHandlingEntry* pEntry) noexcept;

// Get functions
float GetMass() const { return m_Handling.fMass; }
float GetTurnMass() const { return m_Handling.fTurnMass; }
float GetDragCoeff() const { return m_Handling.fDragCoeff; }
const CVector& GetCenterOfMass() const { return m_Handling.vecCenterOfMass; }
float GetMass() const noexcept { return m_Handling.fMass; }
float GetTurnMass() const noexcept { return m_Handling.fTurnMass; }
float GetDragCoeff() const noexcept { return m_Handling.fDragCoeff; }
const CVector& GetCenterOfMass() const noexcept { return m_Handling.vecCenterOfMass; }

unsigned int GetPercentSubmerged() const { return m_Handling.uiPercentSubmerged; }
float GetTractionMultiplier() const { return m_Handling.fTractionMultiplier; }
unsigned int GetPercentSubmerged() const noexcept { return m_Handling.uiPercentSubmerged; }
float GetTractionMultiplier() const noexcept { return m_Handling.fTractionMultiplier; }

eDriveType GetCarDriveType() const { return static_cast<eDriveType>(m_Handling.Transmission.ucDriveType); }
eEngineType GetCarEngineType() const { return static_cast<eEngineType>(m_Handling.Transmission.ucEngineType); }
unsigned char GetNumberOfGears() const { return m_Handling.Transmission.ucNumberOfGears; }
eDriveType GetCarDriveType() const noexcept { return static_cast<eDriveType>(m_Handling.Transmission.ucDriveType); }
eEngineType GetCarEngineType() const noexcept { return static_cast<eEngineType>(m_Handling.Transmission.ucEngineType); }
unsigned char GetNumberOfGears() const noexcept { return m_Handling.Transmission.ucNumberOfGears; }

float GetEngineAcceleration() const { return m_Handling.Transmission.fEngineAcceleration; }
float GetEngineInertia() const { return m_Handling.Transmission.fEngineInertia; }
float GetMaxVelocity() const { return m_Handling.Transmission.fMaxVelocity; }
float GetEngineAcceleration() const noexcept { return m_Handling.Transmission.fEngineAcceleration; }
float GetEngineInertia() const noexcept { return m_Handling.Transmission.fEngineInertia; }
float GetMaxVelocity() const noexcept { return m_Handling.Transmission.fMaxVelocity; }

float GetBrakeDeceleration() const { return m_Handling.fBrakeDeceleration; }
float GetBrakeBias() const { return m_Handling.fBrakeBias; }
bool GetABS() const { return m_Handling.bABS; }
float GetBrakeDeceleration() const noexcept { return m_Handling.fBrakeDeceleration; }
float GetBrakeBias() const noexcept { return m_Handling.fBrakeBias; }
bool GetABS() const noexcept { return m_Handling.bABS; }

float GetSteeringLock() const { return m_Handling.fSteeringLock; }
float GetTractionLoss() const { return m_Handling.fTractionLoss; }
float GetTractionBias() const { return m_Handling.fTractionBias; }
float GetSteeringLock() const noexcept { return m_Handling.fSteeringLock; }
float GetTractionLoss() const noexcept { return m_Handling.fTractionLoss; }
float GetTractionBias() const noexcept { return m_Handling.fTractionBias; }

float GetSuspensionForceLevel() const { return m_Handling.fSuspensionForceLevel; }
float GetSuspensionDamping() const { return m_Handling.fSuspensionDamping; }
float GetSuspensionHighSpeedDamping() const { return m_Handling.fSuspensionHighSpdDamping; }
float GetSuspensionUpperLimit() const { return m_Handling.fSuspensionUpperLimit; }
float GetSuspensionLowerLimit() const { return m_Handling.fSuspensionLowerLimit; }
float GetSuspensionFrontRearBias() const { return m_Handling.fSuspensionFrontRearBias; }
float GetSuspensionAntiDiveMultiplier() const { return m_Handling.fSuspensionAntiDiveMultiplier; }
float GetSuspensionForceLevel() const noexcept { return m_Handling.fSuspensionForceLevel; }
float GetSuspensionDamping() const noexcept { return m_Handling.fSuspensionDamping; }
float GetSuspensionHighSpeedDamping() const noexcept { return m_Handling.fSuspensionHighSpdDamping; }
float GetSuspensionUpperLimit() const noexcept { return m_Handling.fSuspensionUpperLimit; }
float GetSuspensionLowerLimit() const noexcept { return m_Handling.fSuspensionLowerLimit; }
float GetSuspensionFrontRearBias() const noexcept { return m_Handling.fSuspensionFrontRearBias; }
float GetSuspensionAntiDiveMultiplier() const noexcept { return m_Handling.fSuspensionAntiDiveMultiplier; }

float GetCollisionDamageMultiplier() const { return m_Handling.fCollisionDamageMultiplier; }
float GetCollisionDamageMultiplier() const noexcept { return m_Handling.fCollisionDamageMultiplier; }

unsigned int GetHandlingFlags() const { return m_Handling.uiHandlingFlags; }
unsigned int GetModelFlags() const { return m_Handling.uiModelFlags; }
float GetSeatOffsetDistance() const { return m_Handling.fSeatOffsetDistance; }
unsigned int GetMonetary() const { return m_Handling.uiMonetary; }
unsigned int GetHandlingFlags() const noexcept { return m_Handling.uiHandlingFlags; }
unsigned int GetModelFlags() const noexcept { return m_Handling.uiModelFlags; }
float GetSeatOffsetDistance() const noexcept { return m_Handling.fSeatOffsetDistance; }
unsigned int GetMonetary() const noexcept { return m_Handling.uiMonetary; }

eLightType GetHeadLight() const { return static_cast<eLightType>(m_Handling.ucHeadLight); }
eLightType GetTailLight() const { return static_cast<eLightType>(m_Handling.ucTailLight); }
unsigned char GetAnimGroup() const { return m_Handling.ucAnimGroup; }
eLightType GetHeadLight() const noexcept { return static_cast<eLightType>(m_Handling.ucHeadLight); }
eLightType GetTailLight() const noexcept { return static_cast<eLightType>(m_Handling.ucTailLight); }
unsigned char GetAnimGroup() const noexcept { return m_Handling.ucAnimGroup; }

std::uint16_t GetVehicleID() const { return static_cast<std::uint16_t>(m_Handling.iVehicleID); }
eHandlingTypes GetHandlingID() const noexcept { return static_cast<eHandlingTypes>(m_Handling.iVehicleID); }
G-Moris marked this conversation as resolved.
Show resolved Hide resolved

// Set functions
void SetMass(float fMass) { m_Handling.fMass = fMass; }
void SetTurnMass(float fTurnMass) { m_Handling.fTurnMass = fTurnMass; }
void SetDragCoeff(float fDrag) { m_Handling.fDragCoeff = fDrag; }
void SetCenterOfMass(const CVector& vecCenter) { m_Handling.vecCenterOfMass = vecCenter; }
void SetMass(float fMass) noexcept { m_Handling.fMass = fMass; }
void SetTurnMass(float fTurnMass) noexcept { m_Handling.fTurnMass = fTurnMass; }
void SetDragCoeff(float fDrag) noexcept { m_Handling.fDragCoeff = fDrag; }
void SetCenterOfMass(const CVector& vecCenter) noexcept { m_Handling.vecCenterOfMass = vecCenter; }

void SetPercentSubmerged(unsigned int uiPercent) { m_Handling.uiPercentSubmerged = uiPercent; }
void SetTractionMultiplier(float fTractionMultiplier) { m_Handling.fTractionMultiplier = fTractionMultiplier; }
void SetPercentSubmerged(unsigned int uiPercent) noexcept { m_Handling.uiPercentSubmerged = uiPercent; }
void SetTractionMultiplier(float fTractionMultiplier) noexcept { m_Handling.fTractionMultiplier = fTractionMultiplier; }

void SetCarDriveType(eDriveType Type) { m_Handling.Transmission.ucDriveType = Type; }
void SetCarEngineType(eEngineType Type) { m_Handling.Transmission.ucEngineType = Type; }
void SetNumberOfGears(unsigned char ucNumber) { m_Handling.Transmission.ucNumberOfGears = ucNumber; }
void SetCarDriveType(eDriveType Type) noexcept { m_Handling.Transmission.ucDriveType = Type; }
void SetCarEngineType(eEngineType Type) noexcept { m_Handling.Transmission.ucEngineType = Type; }
void SetNumberOfGears(unsigned char ucNumber) noexcept { m_Handling.Transmission.ucNumberOfGears = ucNumber; }

void SetEngineAcceleration(float fAcceleration) { m_Handling.Transmission.fEngineAcceleration = fAcceleration; }
void SetEngineInertia(float fInertia) { m_Handling.Transmission.fEngineInertia = fInertia; }
void SetMaxVelocity(float fVelocity) { m_Handling.Transmission.fMaxVelocity = fVelocity; }
void SetEngineAcceleration(float fAcceleration) noexcept { m_Handling.Transmission.fEngineAcceleration = fAcceleration; }
void SetEngineInertia(float fInertia) noexcept { m_Handling.Transmission.fEngineInertia = fInertia; }
void SetMaxVelocity(float fVelocity) noexcept { m_Handling.Transmission.fMaxVelocity = fVelocity; }

void SetBrakeDeceleration(float fDeceleration) { m_Handling.fBrakeDeceleration = fDeceleration; }
void SetBrakeBias(float fBias) { m_Handling.fBrakeBias = fBias; }
void SetABS(bool bABS) { m_Handling.bABS = bABS; }
void SetBrakeDeceleration(float fDeceleration) noexcept { m_Handling.fBrakeDeceleration = fDeceleration; }
void SetBrakeBias(float fBias) noexcept { m_Handling.fBrakeBias = fBias; }
void SetABS(bool bABS) noexcept { m_Handling.bABS = bABS; }

void SetSteeringLock(float fSteeringLock) { m_Handling.fSteeringLock = fSteeringLock; }
void SetTractionLoss(float fTractionLoss) { m_Handling.fTractionLoss = fTractionLoss; }
void SetTractionBias(float fTractionBias) { m_Handling.fTractionBias = fTractionBias; }
void SetSteeringLock(float fSteeringLock) noexcept { m_Handling.fSteeringLock = fSteeringLock; }
void SetTractionLoss(float fTractionLoss) noexcept { m_Handling.fTractionLoss = fTractionLoss; }
void SetTractionBias(float fTractionBias) noexcept { m_Handling.fTractionBias = fTractionBias; }

void SetSuspensionForceLevel(float fForce) noexcept;
void SetSuspensionDamping(float fDamping) noexcept;
Expand All @@ -177,22 +177,22 @@ class CHandlingEntrySA : public CHandlingEntry
void SetSuspensionFrontRearBias(float fBias) noexcept;
void SetSuspensionAntiDiveMultiplier(float fAntidive) noexcept;

void SetCollisionDamageMultiplier(float fMultiplier) { m_Handling.fCollisionDamageMultiplier = fMultiplier; }
void SetCollisionDamageMultiplier(float fMultiplier) noexcept { m_Handling.fCollisionDamageMultiplier = fMultiplier; }

void SetHandlingFlags(unsigned int uiFlags) { m_Handling.uiHandlingFlags = uiFlags; }
void SetModelFlags(unsigned int uiFlags) { m_Handling.uiModelFlags = uiFlags; }
void SetSeatOffsetDistance(float fDistance) { m_Handling.fSeatOffsetDistance = fDistance; }
void SetMonetary(unsigned int uiMonetary) { m_Handling.uiMonetary = uiMonetary; }
void SetHandlingFlags(unsigned int uiFlags) noexcept { m_Handling.uiHandlingFlags = uiFlags; }
void SetModelFlags(unsigned int uiFlags) noexcept { m_Handling.uiModelFlags = uiFlags; }
void SetSeatOffsetDistance(float fDistance) noexcept { m_Handling.fSeatOffsetDistance = fDistance; }
void SetMonetary(unsigned int uiMonetary) noexcept { m_Handling.uiMonetary = uiMonetary; }

void SetHeadLight(eLightType Style) { m_Handling.ucHeadLight = Style; }
void SetTailLight(eLightType Style) { m_Handling.ucTailLight = Style; }
void SetAnimGroup(unsigned char ucGroup) { m_Handling.ucAnimGroup = ucGroup; }
void SetHeadLight(eLightType Style) noexcept { m_Handling.ucHeadLight = Style; }
void SetTailLight(eLightType Style) noexcept { m_Handling.ucTailLight = Style; }
void SetAnimGroup(unsigned char ucGroup) noexcept { m_Handling.ucAnimGroup = ucGroup; }

void CheckSuspensionChanges() noexcept;
void CheckSuspensionChanges() const noexcept;

void Recalculate();
void Recalculate() noexcept;

tHandlingDataSA* GetInterface() const { return m_pHandlingSA; }
tHandlingDataSA* GetInterface() const noexcept { return m_pHandlingSA; }

private:
tHandlingDataSA* m_pHandlingSA;
Expand Down
Loading
Loading