Skip to content

Commit 0b8106c

Browse files
committed
Update due to code revision
1 parent 93606b5 commit 0b8106c

File tree

5 files changed

+34
-18
lines changed

5 files changed

+34
-18
lines changed

Client/mods/deathmatch/logic/CClientDFF.cpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,6 @@ void CClientDFF::UnloadDFF()
101101

102102
bool CClientDFF::ReplaceModel(unsigned short usModel, bool bAlphaTransparency)
103103
{
104-
if (usModel >= CLOTHES_MODEL_ID_FIRST && usModel <= CLOTHES_MODEL_ID_LAST)
105-
{
106-
if (m_RawDataBuffer.empty() && m_bIsRawData)
107-
return false;
108-
109-
if (m_RawDataBuffer.empty())
110-
{
111-
if (!FileLoad(std::nothrow, m_strDffFilename, m_RawDataBuffer))
112-
return false;
113-
}
114-
115-
g_pGame->GetRenderWare()->ClothesAddReplacement(m_RawDataBuffer.data(), usModel - CLOTHES_MODEL_ID_FIRST);
116-
return true;
117-
}
118-
119104
// Record attempt in case it all goes wrong
120105
CArgMap argMap;
121106
argMap.Set("id", usModel);
@@ -154,6 +139,9 @@ bool CClientDFF::DoReplaceModel(unsigned short usModel, bool bAlphaTransparency)
154139
if (!CClientDFFManager::IsReplacableModel(usModel))
155140
return false;
156141

142+
if (CClientPlayerClothes::IsValidModel(usModel))
143+
return ReplaceClothes(usModel);
144+
157145
// Get clump loaded for this model id
158146
RpClump* pClump = GetLoadedClump(usModel);
159147

@@ -246,7 +234,6 @@ void CClientDFF::RestoreModels()
246234

247235
// Clear the list
248236
m_Replaced.clear();
249-
g_pGame->GetRenderWare()->ClothesRemoveReplacement(m_RawDataBuffer.data());
250237
}
251238

252239
void CClientDFF::InternalRestoreModel(unsigned short usModel)
@@ -284,6 +271,12 @@ void CClientDFF::InternalRestoreModel(unsigned short usModel)
284271
m_pManager->GetObjectManager()->RestreamObjects(usModel);
285272
g_pGame->GetModelInfo(usModel)->RestreamIPL();
286273
}
274+
// Is This a clothe ID?
275+
else if (CClientPlayerClothes::IsValidModel(usModel))
276+
{
277+
g_pGame->GetRenderWare()->ClothesRemoveReplacement(m_RawDataBuffer.data());
278+
return;
279+
}
287280
else
288281
return;
289282

@@ -312,6 +305,22 @@ void CClientDFF::InternalRestoreModel(unsigned short usModel)
312305
}
313306
}
314307

308+
bool CClientDFF::ReplaceClothes(ushort usModel)
309+
{
310+
if (m_RawDataBuffer.empty() && m_bIsRawData)
311+
return false;
312+
313+
if (m_RawDataBuffer.empty())
314+
{
315+
if (!FileLoad(std::nothrow, m_strDffFilename, m_RawDataBuffer))
316+
return false;
317+
}
318+
319+
m_Replaced.push_back(usModel);
320+
g_pGame->GetRenderWare()->ClothesAddReplacement(m_RawDataBuffer.data(), usModel - CLOTHES_MODEL_ID_FIRST);
321+
return true;
322+
}
323+
315324
bool CClientDFF::ReplaceObjectModel(RpClump* pClump, ushort usModel, bool bAlphaTransparency)
316325
{
317326
// Stream out all the object models with matching ID.

Client/mods/deathmatch/logic/CClientDFF.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class CClientDFF final : public CClientEntity
5959
void UnloadDFF();
6060
void InternalRestoreModel(unsigned short usModel);
6161

62+
bool ReplaceClothes(ushort usModel);
6263
bool ReplaceObjectModel(RpClump* pClump, ushort usModel, bool bAlphaTransparency);
6364
bool ReplaceVehicleModel(RpClump* pClump, ushort usModel, bool bAlphaTransparency);
6465
bool ReplaceWeaponModel(RpClump* pClump, ushort usModel, bool bAlphaTransparency);

Client/mods/deathmatch/logic/CClientDFFManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ CClientDFF* CClientDFFManager::GetElementThatReplaced(unsigned short usModel, CC
7979
bool CClientDFFManager::IsReplacableModel(unsigned short usModel)
8080
{
8181
// Either a vehicle model or an object model
82-
return CClientObjectManager::IsValidModel(usModel) || CClientVehicleManager::IsValidModel(usModel) || CClientPlayerManager::IsValidModel(usModel);
82+
return CClientObjectManager::IsValidModel(usModel) || CClientVehicleManager::IsValidModel(usModel) || CClientPlayerManager::IsValidModel(usModel) ||
83+
CClientPlayerClothes::IsValidModel(usModel);
8384
}
8485

8586
bool CClientDFFManager::RestoreModel(unsigned short usModel)

Client/mods/deathmatch/logic/CClientPlayerClothes.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,3 +577,8 @@ const int CClientPlayerClothes::GetClothingGroupMax(unsigned char ucType)
577577

578578
return 0;
579579
}
580+
581+
bool CClientPlayerClothes::IsValidModel(unsigned short usModel)
582+
{
583+
return usModel >= CLOTHES_MODEL_ID_FIRST && usModel <= CLOTHES_MODEL_ID_LAST;
584+
}

Client/mods/deathmatch/logic/CClientPlayerClothes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class CClientPlayerClothes
6767

6868
static const SPlayerClothing* GetClothingGroup(unsigned char ucType);
6969
static const int GetClothingGroupMax(unsigned char ucType);
70-
70+
static bool IsValidModel(unsigned short usModel);
7171
private:
7272
static const SPlayerClothing* GetClothing(const char* szTexture, const char* szModel, unsigned char ucType);
7373

0 commit comments

Comments
 (0)