From 13bdd324e16820ced3e23783f3ee2d49d0ff50dd Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Fri, 13 Aug 2021 14:25:51 +0200 Subject: [PATCH] hud models: add nullptr check for psprites without caller. --- src/r_data/models.cpp | 4 ++-- src/rendering/hwrenderer/scene/hw_weapon.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_data/models.cpp b/src/r_data/models.cpp index 2d7c0eb2e9..43d846a4de 100644 --- a/src/r_data/models.cpp +++ b/src/r_data/models.cpp @@ -183,7 +183,7 @@ void RenderModel(FModelRenderer *renderer, float x, float y, float z, FSpriteMod void RenderHUDModel(FModelRenderer *renderer, DPSprite *psp, float ofsX, float ofsY) { AActor * playermo = players[consoleplayer].camera; - FSpriteModelFrame *smf = FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false); + FSpriteModelFrame *smf = psp->Caller != nullptr ? FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false) : nullptr; // [BB] No model found for this sprite, so we can't render anything. if (smf == nullptr) @@ -783,7 +783,7 @@ bool IsHUDModelForPlayerAvailable (player_t * player) // [MK] check that at least one psprite uses models for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext()) { - FSpriteModelFrame *smf = FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false); + FSpriteModelFrame *smf = psp->Caller != nullptr ? FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false) : nullptr; if ( smf != nullptr ) return true; } return false; diff --git a/src/rendering/hwrenderer/scene/hw_weapon.cpp b/src/rendering/hwrenderer/scene/hw_weapon.cpp index c763ab15f5..f90ff4fd9a 100644 --- a/src/rendering/hwrenderer/scene/hw_weapon.cpp +++ b/src/rendering/hwrenderer/scene/hw_weapon.cpp @@ -614,7 +614,7 @@ void HWDrawInfo::PreparePlayerSprites(sector_t * viewsector, area_t in_area) for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext()) { if (!psp->GetState()) continue; - FSpriteModelFrame *smf = FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false); + FSpriteModelFrame *smf = psp->Caller != nullptr ? FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false) : nullptr; // This is an 'either-or' proposition. This maybe needs some work to allow overlays with weapon models but as originally implemented this just won't work. if (smf && !hudModelStep) continue; if (!smf && hudModelStep) continue;