From 7a5a19a87493c4e62534182c940f5c9c88fa7a4b Mon Sep 17 00:00:00 2001 From: helixhorned Date: Thu, 12 Jan 2012 20:48:00 +0000 Subject: [PATCH] Fix actor[].dispicnum becoming negative. Since the original source code release of Duke3D, there was a potentially dangerous hack where actor[].dispicnum was set to -4 to signal "this actor should not have a floor shadow for this moment" (it doesn't really work, if you ask me). Now, use another bit of actor[].flags for that purpose because setting any picnum members to negative values asks for trouble. git-svn-id: https://svn.eduke32.com/eduke32@2249 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/actors.h | 1 + polymer/eduke32/source/game.c | 9 ++++++++- polymer/eduke32/source/gameexec.c | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/polymer/eduke32/source/actors.h b/polymer/eduke32/source/actors.h index 0363907f1..874101fa5 100644 --- a/polymer/eduke32/source/actors.h +++ b/polymer/eduke32/source/actors.h @@ -149,6 +149,7 @@ enum sflags_t { SPRITE_USEACTIVATOR = 0x00000200, SPRITE_NULL = 0x00000400, // null sprite in multiplayer SPRITE_NOCLIP = 0x00000800, // clipmove it with cliptype 0 + SPRITE_NOFLOORSHADOW= 0x00001000, // for temp. internal use, per-tile flag not checked }; // custom projectiles diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index e9ffadfa3..a3c30d5ff 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -6513,10 +6513,17 @@ skip: { if (actor[i].dispicnum < 0) { + // a negative actor[i].dispicnum used to mean 'no floor shadow please' but + // that was a bad hack since the value could propagate to sprite[].picnum + OSD_Printf(OSD_ERROR "actor[%d].dispicnum = %d\n", i, actor[i].dispicnum); actor[i].dispicnum++; continue; } - else if (ud.shadows && spritesortcnt < (MAXSPRITESONSCREEN-2) && getrendermode() != 4) + + if (actor[i].flags & SPRITE_NOFLOORSHADOW) + continue; + + if (ud.shadows && spritesortcnt < (MAXSPRITESONSCREEN-2) && getrendermode() != 4) { int32_t daz,xrep,yrep; diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 2458c3c95..83a18aed2 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -302,6 +302,8 @@ void A_GetZLimits(int32_t iActor) s->cstat = cstat; + actor[iActor].flags &= ~SPRITE_NOFLOORSHADOW; + if ((lz&49152) == 49152 && (sprite[lz&(MAXSPRITES-1)].cstat&48) == 0) { const spritetype *hitspr = &sprite[lz&(MAXSPRITES-1)]; @@ -311,7 +313,8 @@ void A_GetZLimits(int32_t iActor) if ((A_CheckEnemySprite(hitspr) && hitspr->pal != 1 && s->statnum != STAT_PROJECTILE) || (hitspr->picnum == APLAYER && A_CheckEnemySprite(s))) { - actor[iActor].dispicnum = -4; // No shadows on actors + actor[iActor].flags |= SPRITE_NOFLOORSHADOW; // No shadows on actors +// actor[iActor].dispicnum = -4; // No shadows on actors s->xvel = -256; A_SetSprite(iActor,CLIPMASK0); }