Skip to content

Commit

Permalink
Other fixes for #3848 (#3900)
Browse files Browse the repository at this point in the history
* Update

* Update 2

* Update 3

---------

Co-authored-by: G_Moris <129879037+Black-Sun-Team@users.noreply.github.com>
  • Loading branch information
G-Moris and G_Moris authored Dec 23, 2024
1 parent f985702 commit 36416b2
Show file tree
Hide file tree
Showing 10 changed files with 543 additions and 507 deletions.
337 changes: 181 additions & 156 deletions Client/game_sa/CGameSA.cpp

Large diffs are not rendered by default.

16 changes: 5 additions & 11 deletions Client/game_sa/CHandlingEntrySA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ CHandlingEntrySA::CHandlingEntrySA()
// Create a new interface and zero it
if (m_HandlingSA = std::make_unique<tHandlingDataSA>())
{
MemSet(m_HandlingSA.get(), 0, sizeof(tHandlingDataSA));
MemSetFast(m_HandlingSA.get(), 0, sizeof(tHandlingDataSA));
}
}

Expand All @@ -31,7 +31,7 @@ CHandlingEntrySA::CHandlingEntrySA(const tHandlingDataSA* const pOriginal)
m_HandlingSA = nullptr;
if (pOriginal)
{
MemCpy(&m_Handling, pOriginal, sizeof(tHandlingDataSA));
MemCpyFast(&m_Handling, pOriginal, sizeof(tHandlingDataSA));
}
}

Expand All @@ -52,15 +52,9 @@ void CHandlingEntrySA::Recalculate() noexcept
if (!m_HandlingSA)
return;

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

void CHandlingEntrySA::SetSuspensionForceLevel(float fForce) noexcept
Expand Down
398 changes: 206 additions & 192 deletions Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ bool CGame::Start(int iArgumentCount, char* szArguments[])
m_pPlayerManager = new CPlayerManager;
m_pRadarAreaManager = new CRadarAreaManager;
m_pMarkerManager = new CMarkerManager(m_pColManager);
m_HandlingManager = std::make_shared<CHandlingManager>();
m_HandlingManager = std::make_unique<CHandlingManager>();
m_pVehicleManager = new CVehicleManager;
m_pPacketTranslator = new CPacketTranslator(m_pPlayerManager);
m_pBanManager = new CBanManager;
Expand Down
4 changes: 2 additions & 2 deletions Server/mods/deathmatch/logic/CGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class CGame
bool IsFinished() { return m_bIsFinished; };

CMainConfig* GetConfig() { return m_pMainConfig; }
std::shared_ptr<CHandlingManager> GetHandlingManager() { return m_HandlingManager; }
CHandlingManager* GetHandlingManager() const noexcept { return m_HandlingManager.get(); }
CMapManager* GetMapManager() { return m_pMapManager; }
CPlayerManager* GetPlayerManager() { return m_pPlayerManager; }
CObjectManager* GetObjectManager() { return m_pObjectManager; }
Expand Down Expand Up @@ -571,7 +571,7 @@ class CGame
CSettings* m_pSettings;
CZoneNames* m_pZoneNames;
ASE* m_pASE;
std::shared_ptr<CHandlingManager> m_HandlingManager;
std::unique_ptr<CHandlingManager> m_HandlingManager;
CRPCFunctions* m_pRPCFunctions;
CLanBroadcast* m_pLanBroadcast;
CWaterManager* m_pWaterManager;
Expand Down
54 changes: 27 additions & 27 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static CBanManager* m_pBanManager;
static CPedManager* m_pPedManager;
static CWaterManager* m_pWaterManager;
static CCustomWeaponManager* m_pCustomWeaponManager;
static std::shared_ptr<CHandlingManager> m_HandlingManager;
static CHandlingManager* m_pHandlingManager;

// Used to run a function on all the children of the elements too
#define RUN_CHILDREN(func) \
Expand Down Expand Up @@ -135,7 +135,7 @@ CStaticFunctionDefinitions::CStaticFunctionDefinitions(CGame* pGame)
m_pPedManager = pGame->GetPedManager();
m_pWaterManager = pGame->GetWaterManager();
m_pCustomWeaponManager = pGame->GetCustomWeaponManager();
m_HandlingManager = pGame->GetHandlingManager();
m_pHandlingManager = pGame->GetHandlingManager();
}

CStaticFunctionDefinitions::~CStaticFunctionDefinitions()
Expand Down Expand Up @@ -5492,11 +5492,11 @@ bool CStaticFunctionDefinitions::GetModelHandling(std::uint32_t model, eHandling
const CHandlingEntry* pEntry = nullptr;
if (bOriginal)
{
pEntry = m_HandlingManager->GetOriginalHandlingData(model);
pEntry = m_pHandlingManager->GetOriginalHandlingData(model);
}
else
{
pEntry = m_HandlingManager->GetModelHandlingData(model);
pEntry = m_pHandlingManager->GetModelHandlingData(model);
}

if (!pEntry)
Expand All @@ -5516,11 +5516,11 @@ bool CStaticFunctionDefinitions::GetModelHandling(std::uint32_t model, eHandling
const CHandlingEntry* pEntry = nullptr;
if (bOriginal)
{
pEntry = m_HandlingManager->GetOriginalHandlingData(model);
pEntry = m_pHandlingManager->GetOriginalHandlingData(model);
}
else
{
pEntry = m_HandlingManager->GetModelHandlingData(model);
pEntry = m_pHandlingManager->GetModelHandlingData(model);
}

if (!pEntry)
Expand All @@ -5534,11 +5534,11 @@ bool CStaticFunctionDefinitions::GetModelHandling(std::uint32_t model, eHandling
const CHandlingEntry* pEntry = nullptr;
if (bOriginal)
{
pEntry = m_HandlingManager->GetOriginalHandlingData(model);
pEntry = m_pHandlingManager->GetOriginalHandlingData(model);
}
else
{
pEntry = m_HandlingManager->GetModelHandlingData(model);
pEntry = m_pHandlingManager->GetModelHandlingData(model);
}

if (!pEntry)
Expand All @@ -5552,11 +5552,11 @@ bool CStaticFunctionDefinitions::GetModelHandling(std::uint32_t model, eHandling
const CHandlingEntry* pEntry = nullptr;
if (bOriginal)
{
pEntry = m_HandlingManager->GetOriginalHandlingData(model);
pEntry = m_pHandlingManager->GetOriginalHandlingData(model);
}
else
{
pEntry = m_HandlingManager->GetModelHandlingData(model);
pEntry = m_pHandlingManager->GetModelHandlingData(model);
}

if (!pEntry)
Expand All @@ -5570,11 +5570,11 @@ bool CStaticFunctionDefinitions::GetModelHandling(std::uint32_t model, eHandling
const CHandlingEntry* pEntry = nullptr;
if (bOriginal)
{
pEntry = m_HandlingManager->GetOriginalHandlingData(model);
pEntry = m_pHandlingManager->GetOriginalHandlingData(model);
}
else
{
pEntry = m_HandlingManager->GetModelHandlingData(model);
pEntry = m_pHandlingManager->GetModelHandlingData(model);
}

if (!pEntry)
Expand All @@ -5585,66 +5585,66 @@ bool CStaticFunctionDefinitions::GetModelHandling(std::uint32_t model, eHandling

bool CStaticFunctionDefinitions::SetModelHandling(std::uint32_t model, eHandlingProperty eProperty, float fValue)
{
CHandlingEntry* pEntry = m_HandlingManager->GetModelHandlingData(model);
CHandlingEntry* pEntry = m_pHandlingManager->GetModelHandlingData(model);
if (!pEntry)
return false;

if (!SetEntryHandling(pEntry, eProperty, fValue))
return false;

m_HandlingManager->SetModelHandlingHasChanged(model, true);
m_pHandlingManager->SetModelHandlingHasChanged(model, true);
return true;
}

bool CStaticFunctionDefinitions::SetModelHandling(std::uint32_t model, eHandlingProperty eProperty, CVector vecValue)
{
CHandlingEntry* pEntry = m_HandlingManager->GetModelHandlingData(model);
CHandlingEntry* pEntry = m_pHandlingManager->GetModelHandlingData(model);
if (!pEntry)
return false;

if (!SetEntryHandling(pEntry, eProperty, vecValue))
return false;

m_HandlingManager->SetModelHandlingHasChanged(model, true);
m_pHandlingManager->SetModelHandlingHasChanged(model, true);
return true;
}

bool CStaticFunctionDefinitions::SetModelHandling(std::uint32_t model, eHandlingProperty eProperty, std::string strValue)
{
CHandlingEntry* pEntry = m_HandlingManager->GetModelHandlingData(model);
CHandlingEntry* pEntry = m_pHandlingManager->GetModelHandlingData(model);
if (!pEntry)
return false;

if (!SetEntryHandling(pEntry, eProperty, strValue))
return false;

m_HandlingManager->SetModelHandlingHasChanged(model, true);
m_pHandlingManager->SetModelHandlingHasChanged(model, true);
return true;
}

bool CStaticFunctionDefinitions::SetModelHandling(std::uint32_t model, eHandlingProperty eProperty, unsigned char ucValue)
{
CHandlingEntry* pEntry = m_HandlingManager->GetModelHandlingData(model);
CHandlingEntry* pEntry = m_pHandlingManager->GetModelHandlingData(model);
if (!pEntry)
return false;

if (!SetEntryHandling(pEntry, eProperty, ucValue))
return false;

m_HandlingManager->SetModelHandlingHasChanged(model, true);
m_pHandlingManager->SetModelHandlingHasChanged(model, true);
return true;
}

bool CStaticFunctionDefinitions::SetModelHandling(std::uint32_t model, eHandlingProperty eProperty, unsigned int uiValue)
{
CHandlingEntry* pEntry = m_HandlingManager->GetModelHandlingData(model);
CHandlingEntry* pEntry = m_pHandlingManager->GetModelHandlingData(model);
if (!pEntry)
return false;

if (!SetEntryHandling(pEntry, eProperty, uiValue))
return false;

m_HandlingManager->SetModelHandlingHasChanged(model, true);
m_pHandlingManager->SetModelHandlingHasChanged(model, true);
return true;
}

Expand Down Expand Up @@ -7406,15 +7406,15 @@ bool CStaticFunctionDefinitions::ResetVehicleHandling(CVehicle* pVehicle, bool b

if (bUseOriginal)
{
pNewEntry = m_HandlingManager->GetOriginalHandlingData(model);
pNewEntry = m_pHandlingManager->GetOriginalHandlingData(model);
if (!pNewEntry)
return false;

m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(pVehicle, RESET_VEHICLE_HANDLING, *BitStream.pBitStream));
}
else
{
pNewEntry = m_HandlingManager->GetModelHandlingData(model);
pNewEntry = m_pHandlingManager->GetModelHandlingData(model);
if (!pNewEntry)
return false;

Expand Down Expand Up @@ -7552,11 +7552,11 @@ bool CStaticFunctionDefinitions::ResetVehicleHandlingProperty(CVehicle* pVehicle

bool CStaticFunctionDefinitions::ResetModelHandling(std::uint32_t model)
{
CHandlingEntry* pEntry = m_HandlingManager->GetModelHandlingData(model);
CHandlingEntry* pEntry = m_pHandlingManager->GetModelHandlingData(model);
if (!pEntry)
return false;

const CHandlingEntry* pHandlingEntry = m_HandlingManager->GetOriginalHandlingData(model);
const CHandlingEntry* pHandlingEntry = m_pHandlingManager->GetOriginalHandlingData(model);
if (!pHandlingEntry)
return false;

Expand All @@ -7566,7 +7566,7 @@ bool CStaticFunctionDefinitions::ResetModelHandling(std::uint32_t model)

bool CStaticFunctionDefinitions::ResetModelHandlingProperty(std::uint32_t model, eHandlingProperty eProperty)
{
CHandlingEntry* pEntry = m_HandlingManager->GetModelHandlingData(model);
CHandlingEntry* pEntry = m_pHandlingManager->GetModelHandlingData(model);

float fValue;
CVector vecValue;
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/CVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ void CVehicle::GetInitialDoorStates(SFixedArray<unsigned char, MAX_DOORS>& ucOut

void CVehicle::GenerateHandlingData() noexcept
{
const auto handlingManager = g_pGame->GetHandlingManager();
const auto* handlingManager = g_pGame->GetHandlingManager();

// Make a new CHandlingEntry
if (!m_HandlingEntry)
Expand Down
4 changes: 2 additions & 2 deletions Server/mods/deathmatch/logic/luadefs/CLuaDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace

CElementDeleter* CLuaDefs::m_pElementDeleter = NULL;
CBlipManager* CLuaDefs::m_pBlipManager = NULL;
std::shared_ptr<CHandlingManager> CLuaDefs::m_HandlingManager = nullptr;
CHandlingManager* CLuaDefs::m_pHandlingManager = nullptr;
CLuaManager* CLuaDefs::m_pLuaManager = NULL;
CMarkerManager* CLuaDefs::m_pMarkerManager = NULL;
CObjectManager* CLuaDefs::m_pObjectManager = NULL;
Expand All @@ -63,7 +63,7 @@ void CLuaDefs::Initialize(CGame* pGame)
m_pRootElement = pGame->GetMapManager()->GetRootElement();
m_pElementDeleter = pGame->GetElementDeleter();
m_pBlipManager = pGame->GetBlipManager();
m_HandlingManager = pGame->GetHandlingManager();
m_pHandlingManager = pGame->GetHandlingManager();
m_pLuaManager = pGame->GetLuaManager();
m_pMarkerManager = pGame->GetMarkerManager();
m_pObjectManager = pGame->GetObjectManager();
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/luadefs/CLuaDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class CLuaDefs
protected:
static CElementDeleter* m_pElementDeleter;
static CBlipManager* m_pBlipManager;
static std::shared_ptr<CHandlingManager> m_HandlingManager;
static CHandlingManager* m_pHandlingManager;
static CLuaManager* m_pLuaManager;
static CMarkerManager* m_pMarkerManager;
static CObjectManager* m_pObjectManager;
Expand Down
Loading

0 comments on commit 36416b2

Please sign in to comment.