Skip to content

Commit 5c3d1ba

Browse files
authored
Merge branch 'master' into 260624_Refactoring_Part-4
2 parents 825a480 + 4e7afa2 commit 5c3d1ba

File tree

22 files changed

+21
-175
lines changed

22 files changed

+21
-175
lines changed

.github/workflows/dockerimage.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ on:
1212
- 'Dockerfile.i386'
1313
- 'Dockerfile.armhf'
1414
- 'Dockerfile.arm64'
15-
- 'Dockerfile.osx-x64'
16-
- 'Dockerfile.osx-arm64'
1715

1816
jobs:
1917
build:
@@ -28,10 +26,6 @@ jobs:
2826
dockerfile: Dockerfile.armhf
2927
- tag: arm64
3028
dockerfile: Dockerfile.arm64
31-
- tag: osx-x64
32-
dockerfile: Dockerfile.osx-x64
33-
- tag: osx-arm64
34-
dockerfile: Dockerfile.osx-arm64
3529
runs-on: ubuntu-latest
3630
steps:
3731
- uses: actions/checkout@v4

Client/core/CCore.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,11 +2181,6 @@ CModelCacheManager* CCore::GetModelCacheManager()
21812181
return m_pModelCacheManager;
21822182
}
21832183

2184-
void CCore::AddModelToPersistentCache(ushort usModelId)
2185-
{
2186-
return GetModelCacheManager()->AddModelToPersistentCache(usModelId);
2187-
}
2188-
21892184
void CCore::StaticIdleHandler()
21902185
{
21912186
g_pCore->IdleHandler();

Client/core/CCore.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ class CCore : public CCoreInterface, public CSingleton<CCore>
253253
EDiagnosticDebugType GetDiagnosticDebug();
254254
void SetDiagnosticDebug(EDiagnosticDebugType value);
255255
CModelCacheManager* GetModelCacheManager();
256-
void AddModelToPersistentCache(ushort usModelId);
257256

258257
static void StaticIdleHandler();
259258
void IdleHandler();

Client/core/CModelCacheManager.cpp

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class CModelCacheManagerImpl : public CModelCacheManager
4747
virtual void OnClientClose();
4848
virtual void UpdatePedModelCaching(const std::map<ushort, float>& newNeedCacheList);
4949
virtual void UpdateVehicleModelCaching(const std::map<ushort, float>& newNeedCacheList);
50-
virtual void AddModelToPersistentCache(ushort usModelId);
5150
virtual void SetCustomLimits(std::optional<size_t> numVehicles, std::optional<size_t> numPeds);
5251

5352
// CModelCacheManagerImpl methods
@@ -72,7 +71,6 @@ class CModelCacheManagerImpl : public CModelCacheManager
7271
bool m_IsUsingCustomVehicleCacheLimit{}; //< If `true` the value is set by the scripter, otherwise is calculated in `DoPulse()`
7372
std::map<ushort, SModelCacheInfo> m_PedModelCacheInfoMap{};
7473
std::map<ushort, SModelCacheInfo> m_VehicleModelCacheInfoMap{};
75-
std::set<ushort> m_PermoLoadedModels{};
7674
};
7775

7876
///////////////////////////////////////////////////////////////
@@ -266,22 +264,6 @@ void CModelCacheManagerImpl::DoPulse()
266264
}
267265
}
268266

269-
///////////////////////////////////////////////////////////////
270-
//
271-
// CModelCacheManagerImpl::AddModelToPersistentCache
272-
//
273-
// Keep this model around 4 evar now
274-
//
275-
///////////////////////////////////////////////////////////////
276-
void CModelCacheManagerImpl::AddModelToPersistentCache(ushort usModelId)
277-
{
278-
if (!MapContains(m_PermoLoadedModels, usModelId))
279-
{
280-
AddModelRefCount(usModelId);
281-
MapInsert(m_PermoLoadedModels, usModelId);
282-
}
283-
}
284-
285267
///////////////////////////////////////////////////////////////
286268
//
287269
// CModelCacheManagerImpl::UpdatePedModelCaching
@@ -542,13 +524,5 @@ void CModelCacheManagerImpl::OnRestreamModel(ushort usModelId)
542524
OutputDebugLine(SString("[Cache] End caching model %d (OnRestreamModel)", usModelId));
543525
}
544526
}
545-
}
546-
547-
// Also check the permo list
548-
if (MapContains(m_PermoLoadedModels, usModelId))
549-
{
550-
SubModelRefCount(usModelId);
551-
MapRemove(m_PermoLoadedModels, usModelId);
552-
OutputDebugLine(SString("[Cache] End permo-caching model %d (OnRestreamModel)", usModelId));
553-
}
527+
}
554528
}

Client/core/CModelCacheManager.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class CModelCacheManager
2424
virtual void OnClientClose() = 0;
2525
virtual void UpdatePedModelCaching(const std::map<ushort, float>& newNeedCacheList) = 0;
2626
virtual void UpdateVehicleModelCaching(const std::map<ushort, float>& newNeedCacheList) = 0;
27-
virtual void AddModelToPersistentCache(ushort usModelId) = 0;
2827
virtual void SetCustomLimits(std::optional<size_t> numVehicles, std::optional<size_t> numPeds) = 0;
2928
};
3029

Client/game_sa/CPedSA.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ void CPedSA::Init()
9898

9999
void CPedSA::SetModelIndex(DWORD dwModelIndex)
100100
{
101-
DWORD dwFunction = FUNC_SetModelIndex;
101+
// Delete any existing RwObject first
102+
GetPedInterface()->DeleteRwObject();
103+
104+
// Set new model
102105
DWORD dwThis = (DWORD)GetInterface();
106+
DWORD dwFunction = FUNC_SetModelIndex;
103107
_asm
104108
{
105109
mov ecx, dwThis
@@ -116,16 +120,6 @@ void CPedSA::SetModelIndex(DWORD dwModelIndex)
116120
}
117121
}
118122

119-
// Hacky thing done for the local player when changing model
120-
void CPedSA::RemoveGeometryRef()
121-
{
122-
RpClump* pClump = (RpClump*)GetInterface()->m_pRwObject;
123-
RpAtomic* pAtomic = (RpAtomic*)((pClump->atomics.root.next) - 0x8);
124-
RpGeometry* pGeometry = pAtomic->geometry;
125-
if (pGeometry->refs > 1)
126-
pGeometry->refs--;
127-
}
128-
129123
bool CPedSA::IsInWater()
130124
{
131125
CTask* pTask = m_pPedIntelligence->GetTaskManager()->GetTask(TASK_PRIORITY_EVENT_RESPONSE_NONTEMP);

Client/game_sa/CPedSA.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA
295295
CPedSAInterface* GetPedInterface() { return (CPedSAInterface*)GetInterface(); }
296296
void Init();
297297
void SetModelIndex(DWORD dwModelIndex);
298-
void RemoveGeometryRef();
299298
void AttachPedToEntity(DWORD dwEntityInterface, CVector* vector, unsigned short sDirection, float fRotationLimit, eWeaponType weaponType,
300299
bool bChangeCamera);
301300
void DetachPedFromEntity();

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3927,22 +3927,7 @@ void CClientPed::_ChangeModel()
39273927
// So make sure clothes geometry is built now...
39283928
m_pClothes->AddAllToModel();
39293929
m_pPlayerPed->RebuildPlayer();
3930-
3931-
// ...and decrement the extra ref
3932-
#ifdef NO_CRASH_FIX_TEST2
3933-
m_pPlayerPed->RemoveGeometryRef();
3934-
#endif
3935-
}
3936-
else
3937-
{
3938-
// When the local player changes to another (non CJ) model, the geometry gets an extra ref from somewhere, causing a memory leak.
3939-
// So decrement the extra ref here
3940-
#ifdef NO_CRASH_FIX_TEST
3941-
m_pPlayerPed->RemoveGeometryRef();
3942-
#endif
3943-
// As we will have problem removing the geometry later, we might as well keep the model cached until exit
3944-
g_pCore->AddModelToPersistentCache((ushort)m_ulModel);
3945-
}
3930+
}
39463931

39473932
// Remove reference to the old model we used (Flag extra GTA reference to be removed as well)
39483933
pLoadedModel->RemoveRef(true);

Client/mods/deathmatch/logic/CResourceModelStreamer.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ void CResourceModelStreamer::ReleaseAll()
106106

107107
void CResourceModelStreamer::FullyReleaseModel(std::uint16_t modelId)
108108
{
109-
std::uint16_t &refsCount = m_requestedModels[modelId];
109+
auto refs = m_requestedModels.find(modelId);
110+
if (refs == m_requestedModels.end())
111+
return;
112+
113+
std::uint16_t& refsCount = refs->second;
110114

111115
if (refsCount > 0)
112116
{

Client/sdk/core/CCoreInterface.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ class CCoreInterface
160160
virtual EDiagnosticDebugType GetDiagnosticDebug() = 0;
161161
virtual void SetDiagnosticDebug(EDiagnosticDebugType value) = 0;
162162
virtual CModelCacheManager* GetModelCacheManager() = 0;
163-
virtual void AddModelToPersistentCache(ushort usModelId) = 0;
164163
virtual void UpdateDummyProgress(int iValue = -1, const char* szType = "") = 0;
165164
virtual void SetDummyProgressUpdateAlways(bool bAlways) = 0;
166165

0 commit comments

Comments
 (0)