From 85cce1128a03b663aa37908f4a5b6bd52058247b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 13 Jan 2022 00:42:34 +0100 Subject: [PATCH] - do proper handling of the 'no shadow' case for Duke's bad guys. Using a flag like RedNukem instead of hacking dispicnum, which occasionally does reach the renderer and causes problems. --- source/core/maptypes.h | 5 +++-- source/core/rendering/scene/hw_drawinfo.cpp | 2 +- source/games/duke/src/actors.cpp | 5 +++-- source/games/duke/src/animatesprites_d.cpp | 12 +++++------- source/games/duke/src/animatesprites_r.cpp | 12 ++++++------ 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/source/core/maptypes.h b/source/core/maptypes.h index abbfe8c69..b30048766 100644 --- a/source/core/maptypes.h +++ b/source/core/maptypes.h @@ -166,8 +166,9 @@ DEFINE_TFLAGS_OPERATORS(ESpriteFlags) enum ESpriteBits2 { - CSTAT2_SPRITE_NOFIND = 1, // Invisible to neartag and hitscan - CSTAT2_SPRITE_MAPPED = 2, // sprite was mapped for automap + CSTAT2_SPRITE_NOFIND = 1, // Invisible to neartag and hitscan + CSTAT2_SPRITE_MAPPED = 2, // sprite was mapped for automap + CSTAT2_SPRITE_NOSHADOW = 4, // cast no shadow. }; // tsprite flags use the otherwise unused clipdist field. diff --git a/source/core/rendering/scene/hw_drawinfo.cpp b/source/core/rendering/scene/hw_drawinfo.cpp index ecd812cc7..e1035283a 100644 --- a/source/core/rendering/scene/hw_drawinfo.cpp +++ b/source/core/rendering/scene/hw_drawinfo.cpp @@ -279,7 +279,7 @@ void HWDrawInfo::DispatchSprites() int tilenum = tspr->picnum; auto actor = tspr->ownerActor; - if (actor == nullptr || tspr->xrepeat == 0 || tspr->yrepeat == 0 || tilenum >= MAXTILES) + if (actor == nullptr || tspr->xrepeat == 0 || tspr->yrepeat == 0 || (unsigned)tilenum >= MAXTILES) continue; actor->spr.cstat2 |= CSTAT2_SPRITE_MAPPED; diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 809b06e1b..4c362e816 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -4832,20 +4832,21 @@ void getglobalz(DDukeActor* actor) getzrange({ actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z - (FOURSLEIGHT) }, actor->sector(), &actor->ceilingz, hz, &actor->floorz, lz, zr, CLIPMASK0); actor->spr.cstat2 = cc; + actor->spr.cstat2 &= ~CSTAT2_SPRITE_NOSHADOW; if( lz.type == kHitSprite && (lz.actor()->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == 0 ) { if( badguy(lz.actor()) && lz.actor()->spr.pal != 1) { if( actor->spr.statnum != STAT_PROJECTILE) { - actor->dispicnum = -4; // No shadows on actors + actor->spr.cstat2 |= CSTAT2_SPRITE_NOSHADOW; // No shadows on actors actor->spr.xvel = -256; ssp(actor, CLIPMASK0); } } else if(lz.actor()->isPlayer() && badguy(actor) ) { - actor->dispicnum = -4; // No shadows on actors + actor->spr.cstat2 |= CSTAT2_SPRITE_NOSHADOW; // No shadows on actors actor->spr.xvel = -256; ssp(actor, CLIPMASK0); } diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index 1f2338a4d..6d7f04117 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -566,15 +566,12 @@ void animatesprites_d(tspritetype* tsprite, int& spritesortcnt, int x, int y, in } if (h->spr.statnum == STAT_DUMMYPLAYER || badguy(h) || (h->spr.picnum == APLAYER && h->GetOwner())) + { if (t->statnum != 99 && h->spr.picnum != EXPLOSION2 && h->spr.picnum != HANGLIGHT && h->spr.picnum != DOMELITE) + { if (h->spr.picnum != HOTMEAT) { - if (h->dispicnum < 0) - { - h->dispicnum++; - continue; - } - else if (r_shadows && spritesortcnt < (MAXSPRITESONSCREEN - 2)) + if (r_shadows && spritesortcnt < (MAXSPRITESONSCREEN - 2) && !(h->spr.cstat2 & CSTAT2_SPRITE_NOSHADOW)) { int daz; @@ -623,7 +620,8 @@ void animatesprites_d(tspritetype* tsprite, int& spritesortcnt, int x, int y, in t->shade = 0; } } - + } + } switch (h->spr.picnum) { diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index 83a45bd61..9db2c3d5d 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -720,15 +720,12 @@ void animatesprites_r(tspritetype* tsprite, int& spritesortcnt, int x, int y, in t->shade = -127; if (h->spr.statnum == STAT_DUMMYPLAYER || badguy(h) || (h->spr.picnum == APLAYER && h->GetOwner())) + { if ((h->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == 0 && t->statnum != 99) + { if (h->spr.picnum != EXPLOSION2 && h->spr.picnum != DOMELITE && h->spr.picnum != TORNADO && h->spr.picnum != EXPLOSION3 && (h->spr.picnum != SBMOVE || isRRRA())) { - if (h->dispicnum < 0) - { - h->dispicnum++; - continue; - } - else if (r_shadows && spritesortcnt < (MAXSPRITESONSCREEN - 2)) + if (r_shadows && spritesortcnt < (MAXSPRITESONSCREEN - 2) && !(h->spr.cstat2 & CSTAT2_SPRITE_NOSHADOW)) { int daz; @@ -772,6 +769,9 @@ void animatesprites_r(tspritetype* tsprite, int& spritesortcnt, int x, int y, in } } } + } + } + switch (h->spr.picnum)