From d933f77bf5e5ea58c9f8cdfac02f6573d57ce328 Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Thu, 2 Jun 2016 19:43:21 +0200 Subject: [PATCH] Fixed: the game could crash if some inventory items were destroyed in a certain way --- src/r_things.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 35b9a51fa..309d18bf4 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1651,7 +1651,10 @@ void R_DrawPlayerSprites () while (psp) { // [RH] Don't draw the targeter's crosshair if the player already has a crosshair set. - if (psp->GetID() != PSP_TARGETCENTER || CrosshairImage == nullptr) + // It's possible this psprite's caller is now null but the layer itself hasn't been destroyed + // because it didn't tick yet (if we typed 'take all' while in the console for example). + // In this case let's simply not draw it to avoid crashing. + if ((psp->GetID() != PSP_TARGETCENTER || CrosshairImage == nullptr) && psp->GetCaller() != nullptr) { R_DrawPSprite(psp, camera, bobx, boby, wx, wy, r_TicFracF); }