From 4de0cbcb61a9bd3c4f8529931030f41b33fac2c9 Mon Sep 17 00:00:00 2001 From: Walace Date: Thu, 4 Sep 2025 11:27:14 -0300 Subject: [PATCH] Fix clothes file map initialization condition Updated the condition for initializing blockOffsetToFileIdMap and blockOffsetToFileNameMap to also trigger when ms_ClothesFileDataMap is not empty, ensuring proper map setup when clothes data is present. --- .../game_sa/CRenderWareSA.ClothesReplacing.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Client/game_sa/CRenderWareSA.ClothesReplacing.cpp b/Client/game_sa/CRenderWareSA.ClothesReplacing.cpp index 34bd2f4ce9b..5393d16795f 100644 --- a/Client/game_sa/CRenderWareSA.ClothesReplacing.cpp +++ b/Client/game_sa/CRenderWareSA.ClothesReplacing.cpp @@ -219,14 +219,15 @@ __declspec(noinline) bool _cdecl OnCStreaming_RequestModel_Mid(int flags, SImgGT if (ms_ReplacementClothesFileDataMap.empty() && ms_ClothesFileDataMap.empty()) return false; - // Initialze lookup map if needed - static std::map blockOffsetToFileIdMap; - static std::map blockOffsetToFileNameMap; - if (blockOffsetToFileIdMap.empty()) + static std::map blockOffsetToFileIdMap; + std::map blockOffsetToFileNameMap; + + if (blockOffsetToFileIdMap.empty() || ms_ClothesFileDataMap.size() > 0) { // Check is player.img dir has been loaded by GTA SPlayerImgItemArray* pItemArray = (SPlayerImgItemArray*)0x00BC12C0; - std::uint32_t maxArraySize = 542 + ms_ClothesFileDataMap.size(); + std::uint32_t defaultArraySize = 542; + std::uint32_t maxArraySize = defaultArraySize + ms_ClothesFileDataMap.size(); if (!pItemArray->pItems || pItemArray->uiArraySize != maxArraySize) return false; @@ -234,7 +235,10 @@ __declspec(noinline) bool _cdecl OnCStreaming_RequestModel_Mid(int flags, SImgGT for (std::uint32_t i = 0; i < pItemArray->uiArraySize; i++) { SPlayerImgItem* pImgItem = &pItemArray->pItems[i]; - MapSet(blockOffsetToFileIdMap, pImgItem->uiBlockOffset, i); + + if (i < defaultArraySize) + MapSet(blockOffsetToFileIdMap, pImgItem->uiBlockOffset, i); + MapSet(blockOffsetToFileNameMap, pImgItem->uiBlockOffset, pImgItem->szName); } }