Skip to content

Commit 0f4915e

Browse files
committed
Addendum to 6d29fb5
1 parent 8f52043 commit 0f4915e

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

Client/game_sa/CRenderWareSA.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ CColModel* CRenderWareSA::ReadCOL(const SString& buffer)
480480

481481
// Validate version string is null-terminated
482482
bool versionValid = false;
483-
for (size_t i = 0; i < sizeof(header.version); ++i)
483+
for (std::size_t i = 0; i < sizeof(header.version); ++i)
484484
{
485485
if (header.version[i] == '\0')
486486
{
@@ -491,15 +491,15 @@ CColModel* CRenderWareSA::ReadCOL(const SString& buffer)
491491
if (!versionValid)
492492
{
493493
AddReportLog(8622, "ReadCOL: Invalid header - version field not null-terminated");
494-
return NULL;
494+
return nullptr;
495495
}
496496

497497
// Load the col model
498498
if (header.version[0] == 'C' && header.version[1] == 'O' && header.version[2] == 'L')
499499
{
500500
// Validate name field is null-terminated to prevent buffer overrun
501501
bool nameValid = false;
502-
for (size_t i = 0; i < sizeof(header.name); ++i)
502+
for (std::size_t i = 0; i < sizeof(header.name); ++i)
503503
{
504504
if (header.name[i] == '\0')
505505
{

Client/game_sa/CStreamingGC.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
extern CGameSA* pGame;
1717

1818
// Static member initialization
19-
std::unordered_map<uint32, uint32> CStreamingGC::ms_protectedModels;
20-
std::mutex CStreamingGC::ms_mutex;
21-
bool CStreamingGC::ms_bInitialized = false;
19+
std::unordered_map<std::uint32_t, std::uint32_t> CStreamingGC::ms_protectedModels;
20+
std::mutex CStreamingGC::ms_mutex;
21+
bool CStreamingGC::ms_bInitialized = false;
2222

2323
void CStreamingGC::Initialize()
2424
{
@@ -66,7 +66,7 @@ void CStreamingGC::Shutdown()
6666
ms_bInitialized = false;
6767
}
6868

69-
void CStreamingGC::ProtectModel(uint32 modelId)
69+
void CStreamingGC::ProtectModel(std::uint32_t modelId)
7070
{
7171
if (!ms_bInitialized) [[unlikely]]
7272
Initialize();
@@ -107,7 +107,7 @@ void CStreamingGC::ProtectModel(uint32 modelId)
107107
}
108108
}
109109

110-
bool CStreamingGC::UnprotectModel(uint32 modelId)
110+
bool CStreamingGC::UnprotectModel(std::uint32_t modelId)
111111
{
112112
if (!ms_bInitialized) [[unlikely]]
113113
return false;
@@ -144,7 +144,7 @@ bool CStreamingGC::UnprotectModel(uint32 modelId)
144144
return false;
145145
}
146146

147-
bool CStreamingGC::IsModelProtected(uint32 modelId)
147+
bool CStreamingGC::IsModelProtected(std::uint32_t modelId)
148148
{
149149
if (!ms_bInitialized) [[unlikely]]
150150
return false;
@@ -157,7 +157,7 @@ bool CStreamingGC::IsModelProtected(uint32 modelId)
157157
return ms_protectedModels.find(modelId) != ms_protectedModels.end();
158158
}
159159

160-
size_t CStreamingGC::GetProtectedCount()
160+
std::size_t CStreamingGC::GetProtectedCount()
161161
{
162162
std::lock_guard<std::mutex> lock(ms_mutex);
163163
return ms_protectedModels.size();
@@ -196,7 +196,7 @@ void CStreamingGC::ClearAllProtections()
196196
// Returns true if removal should proceed, false to block
197197
//
198198
////////////////////////////////////////////////////////////////
199-
bool CStreamingGC::OnRemoveModel(uint32 modelId)
199+
bool CStreamingGC::OnRemoveModel(std::uint32_t modelId)
200200
{
201201
// Validate model ID is within valid range
202202
if (modelId >= MODELINFO_MAX) [[unlikely]]

Client/game_sa/CStreamingGC.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,28 @@ class CStreamingGC
2727
static void Shutdown();
2828

2929
// Protect a model from garbage collection
30-
static void ProtectModel(uint32 modelId);
30+
static void ProtectModel(std::uint32_t modelId);
3131

3232
// Unprotect a model, allowing GC. Returns true if protection was removed
33-
[[nodiscard]] static bool UnprotectModel(uint32 modelId);
33+
[[nodiscard]] static bool UnprotectModel(std::uint32_t modelId);
3434

3535
// Check if model is protected. Returns true if model is protected from GC
36-
static bool IsModelProtected(uint32 modelId);
36+
static bool IsModelProtected(std::uint32_t modelId);
3737

3838
// Get count of currently protected models
39-
static size_t GetProtectedCount();
39+
static std::size_t GetProtectedCount();
4040

4141
// Clear all protections - releases all references (Be careful)
4242
static void ClearAllProtections();
4343

4444
// Hook callback for model removal - returns true to allow, false to block
45-
static bool OnRemoveModel(uint32 modelId);
45+
static bool OnRemoveModel(std::uint32_t modelId);
4646

4747
// Guard for automatic model protection
4848
class Guard
4949
{
5050
public:
51-
explicit Guard(uint32 modelId) : m_modelId(modelId), m_bActive(true) { ProtectModel(m_modelId); }
51+
explicit Guard(std::uint32_t modelId) : m_modelId(modelId), m_bActive(true) { ProtectModel(m_modelId); }
5252

5353
~Guard() noexcept
5454
{
@@ -78,12 +78,12 @@ class CStreamingGC
7878
}
7979

8080
private:
81-
uint32 m_modelId;
82-
bool m_bActive;
81+
std::uint32_t m_modelId;
82+
bool m_bActive;
8383
};
8484

8585
private:
86-
static std::unordered_map<uint32, uint32> ms_protectedModels;
87-
static std::mutex ms_mutex;
88-
static bool ms_bInitialized;
86+
static std::unordered_map<std::uint32_t, std::uint32_t> ms_protectedModels;
87+
static std::mutex ms_mutex;
88+
static bool ms_bInitialized;
8989
};

Client/game_sa/CVehicleSA.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "CWorldSA.h"
3131
#include "gamesa_renderware.h"
3232
#include "CFireManagerSA.h"
33+
#include "enums/VehicleType.h"
3334

3435
extern CCoreInterface* g_pCore;
3536
extern CGameSA* pGame;
@@ -1800,7 +1801,7 @@ void CVehicleSA::CopyGlobalSuspensionLinesToPrivate()
18001801
return;
18011802

18021803
// Determine copy size based on vehicle type
1803-
size_t copySize = 0;
1804+
std::size_t copySize = 0;
18041805
if (pModelInfo->IsMonsterTruck())
18051806
{
18061807
// Monster trucks: 0x90 bytes
@@ -1814,7 +1815,7 @@ void CVehicleSA::CopyGlobalSuspensionLinesToPrivate()
18141815
else
18151816
{
18161817
// CAutomobile: wheels * 0x20 bytes
1817-
const size_t numLines = std::min<size_t>(pColData->m_numSuspensionLines, MAX_SUSPENSION_LINES);
1818+
const std::size_t numLines = std::min<std::size_t>(pColData->m_numSuspensionLines, MAX_SUSPENSION_LINES);
18181819
copySize = numLines * SUSPENSION_SIZE_STANDARD;
18191820
}
18201821

@@ -1830,7 +1831,8 @@ void CVehicleSA::RecalculateSuspensionLines()
18301831
if (!pHandlingEntry) [[unlikely]]
18311832
return;
18321833

1833-
DWORD dwModel = GetModelIndex();
1834+
const std::uint32_t dwModel = GetModelIndex();
1835+
18341836
CModelInfo* pModelInfo = pGame->GetModelInfo(dwModel);
18351837
if (!pModelInfo) [[unlikely]]
18361838
return;
@@ -1840,7 +1842,8 @@ void CVehicleSA::RecalculateSuspensionLines()
18401842
return;
18411843

18421844
// Skip trains and their trailers (no suspension lines)
1843-
if (pModelInfo->IsTrain() || dwModel == 571 || dwModel == 570 || dwModel == 569 || dwModel == 590)
1845+
if (pModelInfo->IsTrain() || dwModel == static_cast<std::uint32_t>(VehicleType::VT_FREIFLAT) ||
1846+
dwModel == static_cast<std::uint32_t>(VehicleType::VT_STREAKC) || dwModel == static_cast<std::uint32_t>(VehicleType::VT_FREIBOX))
18441847
return;
18451848

18461849
// Protect collision model before accessing suspension data

Client/sdk/game/CStreamingGC.h

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)