From a6d3c2a826f60dfea41a27ec78f32e86be307119 Mon Sep 17 00:00:00 2001 From: FileEX Date: Fri, 20 Sep 2024 22:36:18 +0200 Subject: [PATCH] Fix possible crash --- Client/game_sa/C2DEffectSAInterface.h | 2 +- Client/game_sa/CModelInfoSA.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Client/game_sa/C2DEffectSAInterface.h b/Client/game_sa/C2DEffectSAInterface.h index 4c873fbcfb..88c3efe1e4 100644 --- a/Client/game_sa/C2DEffectSAInterface.h +++ b/Client/game_sa/C2DEffectSAInterface.h @@ -274,7 +274,7 @@ class C2DEffectSA static int effect2dPluginOffset; }; -static void PrepareTexturesForLightEffect(RwTexture* coronaTex, RwTexture* shadowTex, const char* coronaName, const char* shadowName, bool removeIfExist) +static void PrepareTexturesForLightEffect(RwTexture*& coronaTex, RwTexture*& shadowTex, const char* coronaName, const char* shadowName, bool removeIfExist) { // Call CTxdStore::PushCurrentTxd ((void(__cdecl*)())FUNC_PushCurrentTxd)(); diff --git a/Client/game_sa/CModelInfoSA.cpp b/Client/game_sa/CModelInfoSA.cpp index e04ea28b2e..550c8d6c9d 100644 --- a/Client/game_sa/CModelInfoSA.cpp +++ b/Client/game_sa/CModelInfoSA.cpp @@ -2089,7 +2089,10 @@ void CModelInfoSA::StoreDefault2DFXEffect(C2DEffectSAInterface* effect) // Create a copy of textures for the lights // We must to do this, because C2DEffect::Shutdown removes them if (copy->type == e2dEffectType::LIGHT) - PrepareTexturesForLightEffect(copy->effect.light.coronaTex, copy->effect.light.shadowTex, effect->effect.light.coronaTex->name, effect->effect.light.shadowTex->name, false); + { + if (effect->effect.light.coronaTex && effect->effect.light.shadowTex) + PrepareTexturesForLightEffect(copy->effect.light.coronaTex, copy->effect.light.shadowTex, effect->effect.light.coronaTex->name, effect->effect.light.shadowTex->name, false); + } else if (copy->type == e2dEffectType::ROADSIGN) { // Create a copy of text and atomic for the roadsign @@ -2181,9 +2184,6 @@ C2DEffectSAInterface* CModelInfoSA::Add2DFXEffect(const CVector& position, const // Save our effect d2fxEffects.push_back(effectInterface); - // Keep original effects - StoreDefault2DFXEffect(effectInterface); - return effectInterface; }