Skip to content

Fix model types to CHandlingManager #4068

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

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions Server/mods/deathmatch/logic/CHandlingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ static tHandlingData m_OriginalHandlingData[HT_MAX];
static std::unique_ptr<CHandlingEntry> m_OriginalEntries[HT_MAX];

// Model handling data
static std::unordered_map<std::size_t, std::unique_ptr<CHandlingEntry>> m_ModelEntries;
static std::unordered_map<std::size_t, bool> m_bModelHandlingChanged;
static std::unordered_map<std::uint32_t, std::unique_ptr<CHandlingEntry>> m_ModelEntries;
static std::unordered_map<std::uint32_t, bool> g_ModelHandlingChanged;

static std::map<std::string, eHandlingProperty> m_HandlingNames;

Expand Down Expand Up @@ -135,28 +135,28 @@ eHandlingProperty CHandlingManager::GetPropertyEnumFromName(const std::string& n
return it != m_HandlingNames.end() ? it->second : HANDLING_MAX;
}

bool CHandlingManager::HasModelHandlingChanged(std::uint32_t model) const noexcept
bool CHandlingManager::HasModelHandlingChanged(std::uint32_t model) noexcept
{
// Within range?
if (!CVehicleManager::IsValidModel(model))
return false;

// Return if we have changed
return m_bModelHandlingChanged[model];
return g_ModelHandlingChanged[model];
}

void CHandlingManager::SetModelHandlingHasChanged(std::uint32_t model, bool bChanged) const noexcept
void CHandlingManager::SetModelHandlingHasChanged(std::uint32_t model, bool changed) noexcept
{
// Within range?
if (!CVehicleManager::IsValidModel(model))
return;

// Return if we have changed.
m_bModelHandlingChanged[model] = bChanged;
g_ModelHandlingChanged[model] = changed;
}

// Return the handling manager id
eHandlingTypes CHandlingManager::GetHandlingID(std::uint32_t model) const noexcept
eHandlingTypes CHandlingManager::GetHandlingID(std::uint32_t model) noexcept
{
switch (model)
{
Expand Down
6 changes: 3 additions & 3 deletions Server/mods/deathmatch/logic/CHandlingManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class CHandlingManager
const CHandlingEntry* GetOriginalHandlingData(std::uint32_t model) const noexcept;
CHandlingEntry* GetModelHandlingData(std::uint32_t model) const noexcept;

eHandlingTypes GetHandlingID(std::uint32_t model) const noexcept;
static eHandlingTypes GetHandlingID(std::uint32_t model) noexcept;

// Helper functions
eHandlingProperty GetPropertyEnumFromName(const std::string& name) const noexcept;
bool HasModelHandlingChanged(std::uint32_t model) const noexcept;
void SetModelHandlingHasChanged(std::uint32_t model, bool bChanged) const noexcept;
static bool HasModelHandlingChanged(std::uint32_t model) noexcept;
static void SetModelHandlingHasChanged(std::uint32_t model, bool changed) noexcept;

private:
void InitializeDefaultHandlings() noexcept;
Expand Down
10 changes: 5 additions & 5 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5651,7 +5651,7 @@ bool CStaticFunctionDefinitions::SetModelHandling(std::uint32_t model, eHandling
if (!SetEntryHandling(pEntry, eProperty, fValue))
return false;

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

Expand All @@ -5664,7 +5664,7 @@ bool CStaticFunctionDefinitions::SetModelHandling(std::uint32_t model, eHandling
if (!SetEntryHandling(pEntry, eProperty, vecValue))
return false;

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

Expand All @@ -5677,7 +5677,7 @@ bool CStaticFunctionDefinitions::SetModelHandling(std::uint32_t model, eHandling
if (!SetEntryHandling(pEntry, eProperty, strValue))
return false;

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

Expand All @@ -5690,7 +5690,7 @@ bool CStaticFunctionDefinitions::SetModelHandling(std::uint32_t model, eHandling
if (!SetEntryHandling(pEntry, eProperty, ucValue))
return false;

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

Expand All @@ -5703,7 +5703,7 @@ bool CStaticFunctionDefinitions::SetModelHandling(std::uint32_t model, eHandling
if (!SetEntryHandling(pEntry, eProperty, uiValue))
return false;

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

Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/packets/CEntityAddPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ bool CEntityAddPacket::Write(NetBitStreamInterface& BitStream) const
BitStream.WriteBit(false);

// Write handling
if (g_pGame->GetHandlingManager()->HasModelHandlingChanged(pVehicle->GetModel()) || pVehicle->HasHandlingChanged())
if (CHandlingManager::HasModelHandlingChanged(pVehicle->GetModel()) || pVehicle->HasHandlingChanged())
{
BitStream.WriteBit(true);
SVehicleHandlingSync handling;
Expand Down
Loading