Skip to content

Commit 8674bfa

Browse files
Synchronize changes from 1.6 master branch [ci skip]
d3a311c Fix crash introduced by PR #4544
2 parents 2241bbe + d3a311c commit 8674bfa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Client/game_sa/CStreamingSA.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,16 @@ void CStreamingSA::SetStreamingInfo(uint modelid, unsigned char usStreamID, uint
340340
// In this case, we must force-remove the RwObject from memory, because it is no longer used,
341341
// and due to the archive change the streamer no longer detects it and therefore won't delete it.
342342
// As a result, a memory leak occurs after every call to engineImageLinkDFF.
343-
if (CModelInfo* modelInfo = g_pCore->GetGame()->GetModelInfo(modelid); modelInfo->GetRwObject())
344-
RemoveModel(modelid);
343+
const auto baseTxdId = g_pCore->GetGame()->GetBaseIDforTXD();
344+
if (modelid < static_cast<uint>(baseTxdId))
345+
{
346+
if (CModelInfo* modelInfo = g_pCore->GetGame()->GetModelInfo(modelid, true))
347+
{
348+
// Only DFF models got RwObjects, TXDs don't, so we only flush those here (or crash)
349+
if (modelInfo->GetRwObject())
350+
RemoveModel(modelid);
351+
}
352+
}
345353

346354
// Change nextInImg field for prev model
347355
for (CStreamingInfo& info : ms_aInfoForModel)

0 commit comments

Comments
 (0)