Skip to content

Commit

Permalink
- do proper handling of the 'no shadow' case for Duke's bad guys.
Browse files Browse the repository at this point in the history
Using a flag like RedNukem instead of hacking dispicnum, which occasionally does reach the renderer and causes problems.
  • Loading branch information
coelckers committed Jan 12, 2022
1 parent a13612a commit 85cce11
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
5 changes: 3 additions & 2 deletions source/core/maptypes.h
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion source/core/rendering/scene/hw_drawinfo.cpp
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions source/games/duke/src/actors.cpp
Expand Up @@ -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);
}
Expand Down
12 changes: 5 additions & 7 deletions source/games/duke/src/animatesprites_d.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -623,7 +620,8 @@ void animatesprites_d(tspritetype* tsprite, int& spritesortcnt, int x, int y, in
t->shade = 0;
}
}

}
}

switch (h->spr.picnum)
{
Expand Down
12 changes: 6 additions & 6 deletions source/games/duke/src/animatesprites_r.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -772,6 +769,9 @@ void animatesprites_r(tspritetype* tsprite, int& spritesortcnt, int x, int y, in
}
}
}
}
}



switch (h->spr.picnum)
Expand Down

0 comments on commit 85cce11

Please sign in to comment.