Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds replacement CJ clothing models #3967

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Client/game_sa/CRenderWareSA.ClothesReplacing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ namespace

////////////////////////////////////////////////////////////////
//
// CRenderWareSA::ClothesAddReplacementTxd
// CRenderWareSA::ClothesAddReplacement
//
// Add replacement txd for a clothing component
// Add replacement txd/dff for a clothing component
//
////////////////////////////////////////////////////////////////
void CRenderWareSA::ClothesAddReplacementTxd(char* pFileData, ushort usFileId)
void CRenderWareSA::ClothesAddReplacement(char* pFileData, ushort usFileId)
{
if (!pFileData)
return;
Expand All @@ -70,12 +70,12 @@ void CRenderWareSA::ClothesAddReplacementTxd(char* pFileData, ushort usFileId)

////////////////////////////////////////////////////////////////
//
// CRenderWareSA::ClothesRemoveReplacementTxd
// CRenderWareSA::ClothesRemoveReplacement
//
// Remove replacement txd for a clothing component
// Remove replacement txd/dff for a clothing component
//
////////////////////////////////////////////////////////////////
void CRenderWareSA::ClothesRemoveReplacementTxd(char* pFileData)
void CRenderWareSA::ClothesRemoveReplacement(char* pFileData)
{
if (!pFileData)
return;
Expand Down Expand Up @@ -110,7 +110,7 @@ bool CRenderWareSA::HasClothesReplacementChanged()
// CStreaming_RequestModel_Mid
//
// If request is for a file inside player.img (imgId 5)
// then maybe switch to replacement txd file data
// then maybe switch to replacement txd/dff file data
//
////////////////////////////////////////////////////////////////
__declspec(noinline) bool _cdecl OnCStreaming_RequestModel_Mid(int flags, SImgGTAItemInfo* pImgGTAInfo)
Expand Down
4 changes: 2 additions & 2 deletions Client/game_sa/CRenderWareSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class CRenderWareSA : public CRenderWare
bool ModelInfoTXDLoadTextures(SReplacementTextures* pReplacementTextures, const SString& strFilename, const SString& buffer, bool bFilteringEnabled);
bool ModelInfoTXDAddTextures(SReplacementTextures* pReplacementTextures, ushort usModelId);
void ModelInfoTXDRemoveTextures(SReplacementTextures* pReplacementTextures);
void ClothesAddReplacementTxd(char* pFileData, ushort usFileId);
void ClothesRemoveReplacementTxd(char* pFileData);
void ClothesAddReplacement(char* pFileData, ushort usFileId);
void ClothesRemoveReplacement(char* pFileData);
bool HasClothesReplacementChanged();

// Reads and parses a TXD file specified by a path (szTXD)
Expand Down
16 changes: 16 additions & 0 deletions Client/mods/deathmatch/logic/CClientDFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ void CClientDFF::UnloadDFF()

bool CClientDFF::ReplaceModel(unsigned short usModel, bool bAlphaTransparency)
{
if (usModel >= CLOTHES_MODEL_ID_FIRST && usModel <= CLOTHES_MODEL_ID_LAST)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add CPlayerClothes::IsValidClothingModelId for this check

{
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;
}

Comment on lines +104 to +118
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract this method as ReplaceClothes(uint32_t model)
Call it in DoReplaceModel

        if (CPlayerClothes::IsValidClothingModelId(usModel))
        {
            return ReplaceClothes(usModel);
        }

// Record attempt in case it all goes wrong
CArgMap argMap;
argMap.Set("id", usModel);
Expand Down Expand Up @@ -231,6 +246,7 @@ void CClientDFF::RestoreModels()

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

@TheNormalnij TheNormalnij Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move it into InternalRestoreModel as

        else if (CPlayerClothes::IsValidClothingModelId(usModel))
        {
            g_pGame->GetRenderWare()->ClothesRemoveReplacement(m_RawDataBuffer.data());
            return;
        }

}

void CClientDFF::InternalRestoreModel(unsigned short usModel)
Expand Down
6 changes: 3 additions & 3 deletions Client/mods/deathmatch/logic/CClientTXD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CClientTXD::~CClientTXD()
}

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

bool CClientTXD::Load(bool isRaw, SString input, bool enableFiltering)
Expand Down Expand Up @@ -75,8 +75,8 @@ bool CClientTXD::Import(unsigned short usModelID)
return false;
}
m_bUsingFileDataForClothes = true;
// Note: ClothesAddReplacementTxd uses the pointer from m_FileData, so don't touch m_FileData until matching ClothesRemove call
g_pGame->GetRenderWare()->ClothesAddReplacementTxd(m_FileData.data(), usModelID - CLOTHES_MODEL_ID_FIRST);
// Note: ClothesAddReplacement uses the pointer from m_FileData, so don't touch m_FileData until matching ClothesRemove call
g_pGame->GetRenderWare()->ClothesAddReplacement(m_FileData.data(), usModelID - CLOTHES_MODEL_ID_FIRST);
return true;
}
else
Expand Down
4 changes: 2 additions & 2 deletions Client/sdk/game/CRenderWare.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ class CRenderWare
bool bFilteringEnabled) = 0;
virtual bool ModelInfoTXDAddTextures(SReplacementTextures* pReplacementTextures, ushort usModelId) = 0;
virtual void ModelInfoTXDRemoveTextures(SReplacementTextures* pReplacementTextures) = 0;
virtual void ClothesAddReplacementTxd(char* pFileData, ushort usFileId) = 0;
virtual void ClothesRemoveReplacementTxd(char* pFileData) = 0;
virtual void ClothesAddReplacement(char* pFileData, ushort usFileId) = 0;
virtual void ClothesRemoveReplacement(char* pFileData) = 0;
virtual bool HasClothesReplacementChanged() = 0;
virtual RwTexDictionary* ReadTXD(const SString& strFilename, const SString& buffer) = 0;
virtual RpClump* ReadDFF(const SString& strFilename, const SString& buffer, unsigned short usModelID, bool bLoadEmbeddedCollisions) = 0;
Expand Down
Loading