From a32aa2e6d9214511fe20b04e6fa777f2b9f4685f Mon Sep 17 00:00:00 2001 From: Federico Romero Date: Sun, 5 Jul 2026 13:22:57 -0300 Subject: [PATCH] Fix custom ped textures/skins persisting after resource stop or disconnect engineImportTXD replacements applied to a ped model never got visually reverted for the local player: the ped-restream gate checked IsStreamedIn(), which never becomes true for the local player since it's created via _CreateLocalModel() instead of the normal streaming path. Additionally, removing a replacement never forced the model to drop its loaded clump the way applying one does, so even when the restream did run it wasn't guaranteed to pick up the restored textures. Fixes #1877. --- Client/game_sa/CRenderWareSA.TextureReplacing.cpp | 8 ++++++++ Client/mods/deathmatch/logic/CClientPedManager.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Client/game_sa/CRenderWareSA.TextureReplacing.cpp b/Client/game_sa/CRenderWareSA.TextureReplacing.cpp index 68abac34c93..f0d9d05b011 100644 --- a/Client/game_sa/CRenderWareSA.TextureReplacing.cpp +++ b/Client/game_sa/CRenderWareSA.TextureReplacing.cpp @@ -213,6 +213,14 @@ bool CRenderWareSA::ModelInfoTXDAddTextures(SReplacementTextures* pReplacementTe //////////////////////////////////////////////////////////////// void CRenderWareSA::ModelInfoTXDRemoveTextures(SReplacementTextures* pReplacementTextures) { + // Force ped models to drop their loaded clump, mirroring the forced unload in GetModelTexturesInfo, so they pick up the restored textures below + for (ushort usModelId : pReplacementTextures->usedInModelIds) + { + CModelInfo* pModelInfo = pGame->GetModelInfo(usModelId); + if (pModelInfo && pModelInfo->GetModelType() == eModelInfoType::PED) + ((void(__cdecl*)(unsigned short))FUNC_RemoveModel)(usModelId); + } + // For each using txd for (uint i = 0; i < pReplacementTextures->perTxdList.size(); i++) { diff --git a/Client/mods/deathmatch/logic/CClientPedManager.cpp b/Client/mods/deathmatch/logic/CClientPedManager.cpp index 2f1c5fd5f7a..1d2dd243d51 100644 --- a/Client/mods/deathmatch/logic/CClientPedManager.cpp +++ b/Client/mods/deathmatch/logic/CClientPedManager.cpp @@ -106,8 +106,8 @@ void CClientPedManager::RestreamPeds(unsigned short usModel) { pPed = *iter; - // Streamed in and same vehicle ID? - if (pPed->IsStreamedIn() && pPed->GetModel() == usModel) + // Streamed in (or the local player, whose m_bStreamedIn never gets set, see CLuaElementDefs::IsElementStreamedIn) and same model ID? + if ((pPed->IsStreamedIn() || pPed->IsLocalPlayer()) && pPed->GetModel() == usModel) { // Stream it out for a while until streamed decides to stream it // back in eventually @@ -128,8 +128,8 @@ void CClientPedManager::RestreamAllPeds() { for (auto& pPed : m_List) { - // Streamed in and same vehicle ID? - if (pPed->IsStreamedIn()) + // Streamed in (or the local player - see RestreamPeds above)? + if (pPed->IsStreamedIn() || pPed->IsLocalPlayer()) { // Stream it out for a while until streamed decides to stream it // back in eventually