Skip to content

Commit

Permalink
Update due to code revision
Browse files Browse the repository at this point in the history
  • Loading branch information
W3lac3 committed Jan 25, 2025
1 parent 93606b5 commit 0b8106c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 18 deletions.
41 changes: 25 additions & 16 deletions Client/mods/deathmatch/logic/CClientDFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,6 @@ void CClientDFF::UnloadDFF()

bool CClientDFF::ReplaceModel(unsigned short usModel, bool bAlphaTransparency)
{
if (usModel >= CLOTHES_MODEL_ID_FIRST && usModel <= CLOTHES_MODEL_ID_LAST)
{
if (m_RawDataBuffer.empty() && m_bIsRawData)
return false;

if (m_RawDataBuffer.empty())
{
if (!FileLoad(std::nothrow, m_strDffFilename, m_RawDataBuffer))
return false;
}

g_pGame->GetRenderWare()->ClothesAddReplacement(m_RawDataBuffer.data(), usModel - CLOTHES_MODEL_ID_FIRST);
return true;
}

// Record attempt in case it all goes wrong
CArgMap argMap;
argMap.Set("id", usModel);
Expand Down Expand Up @@ -154,6 +139,9 @@ bool CClientDFF::DoReplaceModel(unsigned short usModel, bool bAlphaTransparency)
if (!CClientDFFManager::IsReplacableModel(usModel))
return false;

if (CClientPlayerClothes::IsValidModel(usModel))
return ReplaceClothes(usModel);

// Get clump loaded for this model id
RpClump* pClump = GetLoadedClump(usModel);

Expand Down Expand Up @@ -246,7 +234,6 @@ void CClientDFF::RestoreModels()

// Clear the list
m_Replaced.clear();
g_pGame->GetRenderWare()->ClothesRemoveReplacement(m_RawDataBuffer.data());
}

void CClientDFF::InternalRestoreModel(unsigned short usModel)
Expand Down Expand Up @@ -284,6 +271,12 @@ void CClientDFF::InternalRestoreModel(unsigned short usModel)
m_pManager->GetObjectManager()->RestreamObjects(usModel);
g_pGame->GetModelInfo(usModel)->RestreamIPL();
}
// Is This a clothe ID?
else if (CClientPlayerClothes::IsValidModel(usModel))
{
g_pGame->GetRenderWare()->ClothesRemoveReplacement(m_RawDataBuffer.data());
return;
}
else
return;

Expand Down Expand Up @@ -312,6 +305,22 @@ void CClientDFF::InternalRestoreModel(unsigned short usModel)
}
}

bool CClientDFF::ReplaceClothes(ushort usModel)
{
if (m_RawDataBuffer.empty() && m_bIsRawData)
return false;

if (m_RawDataBuffer.empty())
{
if (!FileLoad(std::nothrow, m_strDffFilename, m_RawDataBuffer))
return false;
}

m_Replaced.push_back(usModel);
g_pGame->GetRenderWare()->ClothesAddReplacement(m_RawDataBuffer.data(), usModel - CLOTHES_MODEL_ID_FIRST);
return true;
}

bool CClientDFF::ReplaceObjectModel(RpClump* pClump, ushort usModel, bool bAlphaTransparency)
{
// Stream out all the object models with matching ID.
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientDFF.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class CClientDFF final : public CClientEntity
void UnloadDFF();
void InternalRestoreModel(unsigned short usModel);

bool ReplaceClothes(ushort usModel);
bool ReplaceObjectModel(RpClump* pClump, ushort usModel, bool bAlphaTransparency);
bool ReplaceVehicleModel(RpClump* pClump, ushort usModel, bool bAlphaTransparency);
bool ReplaceWeaponModel(RpClump* pClump, ushort usModel, bool bAlphaTransparency);
Expand Down
3 changes: 2 additions & 1 deletion Client/mods/deathmatch/logic/CClientDFFManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ CClientDFF* CClientDFFManager::GetElementThatReplaced(unsigned short usModel, CC
bool CClientDFFManager::IsReplacableModel(unsigned short usModel)
{
// Either a vehicle model or an object model
return CClientObjectManager::IsValidModel(usModel) || CClientVehicleManager::IsValidModel(usModel) || CClientPlayerManager::IsValidModel(usModel);
return CClientObjectManager::IsValidModel(usModel) || CClientVehicleManager::IsValidModel(usModel) || CClientPlayerManager::IsValidModel(usModel) ||
CClientPlayerClothes::IsValidModel(usModel);
}

bool CClientDFFManager::RestoreModel(unsigned short usModel)
Expand Down
5 changes: 5 additions & 0 deletions Client/mods/deathmatch/logic/CClientPlayerClothes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,3 +577,8 @@ const int CClientPlayerClothes::GetClothingGroupMax(unsigned char ucType)

return 0;
}

bool CClientPlayerClothes::IsValidModel(unsigned short usModel)
{
return usModel >= CLOTHES_MODEL_ID_FIRST && usModel <= CLOTHES_MODEL_ID_LAST;
}
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/CClientPlayerClothes.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CClientPlayerClothes

static const SPlayerClothing* GetClothingGroup(unsigned char ucType);
static const int GetClothingGroupMax(unsigned char ucType);

static bool IsValidModel(unsigned short usModel);
private:
static const SPlayerClothing* GetClothing(const char* szTexture, const char* szModel, unsigned char ucType);

Expand Down

0 comments on commit 0b8106c

Please sign in to comment.