From ba1486f763477a42437d7c2a2952e9b9bbd01b53 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Dec 2024 01:40:42 +0100 Subject: [PATCH] dont dereference potential null mobjs in software projectsprite --- src/r_things.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 0feacb0af..fc7eed623 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1156,9 +1156,6 @@ static void R_ProjectSprite(mobj_t *thing) size_t rot; UINT8 flip; - boolean mirrored = thing->mirrored; - boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); - INT32 lindex; vissprite_t *vis; @@ -1170,7 +1167,6 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t iscale; fixed_t scalestep; // toast '16 fixed_t offset, offset2; - boolean papersprite = (thing->frame & FF_PAPERSPRITE); fixed_t paperoffset = 0, paperdistance = 0; angle_t centerangle = 0; INT32 lightnum; @@ -1198,6 +1194,11 @@ static void R_ProjectSprite(mobj_t *thing) if (P_MobjWasRemoved(thing) || thing->subsector == NULL) return; + const boolean mirrored = thing->mirrored; + const boolean vflip = (thing->eflags & MFE_VERTICALFLIP); + const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); + const boolean papersprite = (thing->frame & FF_PAPERSPRITE); + if (cv_maxinterpdist.value) dist = R_QuickCamDist(thing->x, thing->y); @@ -1575,7 +1576,7 @@ static void R_ProjectSprite(mobj_t *thing) } //SoM: 3/17/2000: Disregard sprites that are out of view.. - if (thing->eflags & MFE_VERTICALFLIP) + if (vflip) { // When vertical flipped, draw sprites from the top down, at least as far as offsets are concerned. // sprite height - sprite topoffset is the proper inverse of the vertical offset, of course. @@ -1782,10 +1783,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->precip = false; - if (thing->eflags & MFE_VERTICALFLIP) - vis->vflip = true; - else - vis->vflip = false; + vis->vflip = vflip; vis->isScaled = false;