Skip to content

Commit 93606b5

Browse files
committed
Adds replacement CJ clothing models
1 parent bf689fd commit 93606b5

File tree

5 files changed

+30
-14
lines changed

5 files changed

+30
-14
lines changed

Client/game_sa/CRenderWareSA.ClothesReplacing.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ namespace
5252

5353
////////////////////////////////////////////////////////////////
5454
//
55-
// CRenderWareSA::ClothesAddReplacementTxd
55+
// CRenderWareSA::ClothesAddReplacement
5656
//
57-
// Add replacement txd for a clothing component
57+
// Add replacement txd/dff for a clothing component
5858
//
5959
////////////////////////////////////////////////////////////////
60-
void CRenderWareSA::ClothesAddReplacementTxd(char* pFileData, ushort usFileId)
60+
void CRenderWareSA::ClothesAddReplacement(char* pFileData, ushort usFileId)
6161
{
6262
if (!pFileData)
6363
return;
@@ -70,12 +70,12 @@ void CRenderWareSA::ClothesAddReplacementTxd(char* pFileData, ushort usFileId)
7070

7171
////////////////////////////////////////////////////////////////
7272
//
73-
// CRenderWareSA::ClothesRemoveReplacementTxd
73+
// CRenderWareSA::ClothesRemoveReplacement
7474
//
75-
// Remove replacement txd for a clothing component
75+
// Remove replacement txd/dff for a clothing component
7676
//
7777
////////////////////////////////////////////////////////////////
78-
void CRenderWareSA::ClothesRemoveReplacementTxd(char* pFileData)
78+
void CRenderWareSA::ClothesRemoveReplacement(char* pFileData)
7979
{
8080
if (!pFileData)
8181
return;
@@ -110,7 +110,7 @@ bool CRenderWareSA::HasClothesReplacementChanged()
110110
// CStreaming_RequestModel_Mid
111111
//
112112
// If request is for a file inside player.img (imgId 5)
113-
// then maybe switch to replacement txd file data
113+
// then maybe switch to replacement txd/dff file data
114114
//
115115
////////////////////////////////////////////////////////////////
116116
__declspec(noinline) bool _cdecl OnCStreaming_RequestModel_Mid(int flags, SImgGTAItemInfo* pImgGTAInfo)

Client/game_sa/CRenderWareSA.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class CRenderWareSA : public CRenderWare
3232
bool ModelInfoTXDLoadTextures(SReplacementTextures* pReplacementTextures, const SString& strFilename, const SString& buffer, bool bFilteringEnabled);
3333
bool ModelInfoTXDAddTextures(SReplacementTextures* pReplacementTextures, ushort usModelId);
3434
void ModelInfoTXDRemoveTextures(SReplacementTextures* pReplacementTextures);
35-
void ClothesAddReplacementTxd(char* pFileData, ushort usFileId);
36-
void ClothesRemoveReplacementTxd(char* pFileData);
35+
void ClothesAddReplacement(char* pFileData, ushort usFileId);
36+
void ClothesRemoveReplacement(char* pFileData);
3737
bool HasClothesReplacementChanged();
3838

3939
// Reads and parses a TXD file specified by a path (szTXD)

Client/mods/deathmatch/logic/CClientDFF.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,21 @@ 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+
104119
// Record attempt in case it all goes wrong
105120
CArgMap argMap;
106121
argMap.Set("id", usModel);
@@ -231,6 +246,7 @@ void CClientDFF::RestoreModels()
231246

232247
// Clear the list
233248
m_Replaced.clear();
249+
g_pGame->GetRenderWare()->ClothesRemoveReplacement(m_RawDataBuffer.data());
234250
}
235251

236252
void CClientDFF::InternalRestoreModel(unsigned short usModel)

Client/mods/deathmatch/logic/CClientTXD.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ CClientTXD::~CClientTXD()
2929
}
3030

3131
// Remove us from all the clothes replacement doo dah
32-
g_pGame->GetRenderWare()->ClothesRemoveReplacementTxd(m_FileData.data());
32+
g_pGame->GetRenderWare()->ClothesRemoveReplacement(m_FileData.data());
3333
}
3434

3535
bool CClientTXD::Load(bool isRaw, SString input, bool enableFiltering)
@@ -75,8 +75,8 @@ bool CClientTXD::Import(unsigned short usModelID)
7575
return false;
7676
}
7777
m_bUsingFileDataForClothes = true;
78-
// Note: ClothesAddReplacementTxd uses the pointer from m_FileData, so don't touch m_FileData until matching ClothesRemove call
79-
g_pGame->GetRenderWare()->ClothesAddReplacementTxd(m_FileData.data(), usModelID - CLOTHES_MODEL_ID_FIRST);
78+
// Note: ClothesAddReplacement uses the pointer from m_FileData, so don't touch m_FileData until matching ClothesRemove call
79+
g_pGame->GetRenderWare()->ClothesAddReplacement(m_FileData.data(), usModelID - CLOTHES_MODEL_ID_FIRST);
8080
return true;
8181
}
8282
else

Client/sdk/game/CRenderWare.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ class CRenderWare
7676
bool bFilteringEnabled) = 0;
7777
virtual bool ModelInfoTXDAddTextures(SReplacementTextures* pReplacementTextures, ushort usModelId) = 0;
7878
virtual void ModelInfoTXDRemoveTextures(SReplacementTextures* pReplacementTextures) = 0;
79-
virtual void ClothesAddReplacementTxd(char* pFileData, ushort usFileId) = 0;
80-
virtual void ClothesRemoveReplacementTxd(char* pFileData) = 0;
79+
virtual void ClothesAddReplacement(char* pFileData, ushort usFileId) = 0;
80+
virtual void ClothesRemoveReplacement(char* pFileData) = 0;
8181
virtual bool HasClothesReplacementChanged() = 0;
8282
virtual RwTexDictionary* ReadTXD(const SString& strFilename, const SString& buffer) = 0;
8383
virtual RpClump* ReadDFF(const SString& strFilename, const SString& buffer, unsigned short usModelID, bool bLoadEmbeddedCollisions) = 0;

0 commit comments

Comments
 (0)