From 32733ae5998ada3576b0bd0d9a9d10ad150c8f9e Mon Sep 17 00:00:00 2001 From: Uladzislau Nikalayevich Date: Sat, 23 Sep 2023 21:23:16 +0300 Subject: [PATCH 1/2] Fix assert when model info is missing #3192 --- Client/game_sa/CModelInfoSA.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Client/game_sa/CModelInfoSA.cpp b/Client/game_sa/CModelInfoSA.cpp index cf132ee9b3..5d1a433c16 100644 --- a/Client/game_sa/CModelInfoSA.cpp +++ b/Client/game_sa/CModelInfoSA.cpp @@ -812,10 +812,18 @@ void CModelInfoSA::ResetTextureDictionaryID() void CModelInfoSA::StaticResetTextureDictionaries() { - while (!ms_DefaultTxdIDMap.empty()) { + while (!ms_DefaultTxdIDMap.empty()) + { const auto mi = pGame->GetModelInfo(ms_DefaultTxdIDMap.begin()->first); - assert(mi); - mi->ResetTextureDictionaryID(); + if (mi) + { + mi->ResetTextureDictionaryID(); + } + else + { + // Model was dealocated. Skip it and remove from list + ms_DefaultTxdIDMap.erase(ms_DefaultTxdIDMap.begin()->first); + } } } From 88bf632f0372448b45b92c7da1bcc36d6301aad2 Mon Sep 17 00:00:00 2001 From: Uladzislau Nikalayevich Date: Sat, 23 Sep 2023 21:54:05 +0300 Subject: [PATCH 2/2] Update Client/game_sa/CModelInfoSA.cpp Co-authored-by: Marek Kulik --- Client/game_sa/CModelInfoSA.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/game_sa/CModelInfoSA.cpp b/Client/game_sa/CModelInfoSA.cpp index 5d1a433c16..da81fb4f23 100644 --- a/Client/game_sa/CModelInfoSA.cpp +++ b/Client/game_sa/CModelInfoSA.cpp @@ -821,8 +821,8 @@ void CModelInfoSA::StaticResetTextureDictionaries() } else { - // Model was dealocated. Skip it and remove from list - ms_DefaultTxdIDMap.erase(ms_DefaultTxdIDMap.begin()->first); + // Model was deallocated. Skip and remove it from our list. + ms_DefaultTxdIDMap.erase(ms_DefaultTxdIDMap.begin()); } } }