diff --git a/source/build/include/build.h b/source/build/include/build.h index ae1291e69..0f92de43c 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -369,6 +369,9 @@ typedef struct { enum { TSPR_FLAGS_MDHACK = 1u<<0u, + TSPR_FLAGS_DRAW_LAST = 1u<<1u, + TSPR_FLAGS_NO_SHADOW = 1u<<2u, + TSPR_FLAGS_INVISIBLE_WITH_SHADOW = 1u<<3u, }; EXTERN int32_t guniqhudid; diff --git a/source/build/include/buildtypes.h b/source/build/include/buildtypes.h index af8d810fc..995a32280 100644 --- a/source/build/include/buildtypes.h +++ b/source/build/include/buildtypes.h @@ -132,10 +132,6 @@ enum CSTAT_SPRITE_RESERVED4 = 1u<<13u, // used by Duke 3D (Polymer), Shadow Warrior, Blood CSTAT_SPRITE_RESERVED5 = 1u<<14u, // used by Duke 3D (Polymer), Shadow Warrior, Blood - // TODO: Make these two Duke3D-only by translating them to bits in tspr - CSTAT_SPRITE_NO_SHADOW = 1u<<13u, // re-defined in Shadow Warrior - CSTAT_SPRITE_INVISIBLE_WITH_SHADOW = 1u<<14u, // re-defined in Shadow Warrior - CSTAT_SPRITE_INVISIBLE = 1u<<15u, }; enum diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index edb13f814..dd88095ae 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -418,7 +418,7 @@ int32_t polymost_maskWallHasTranslucency(uwalltype const * const wall) int32_t polymost_spriteHasTranslucency(tspritetype const * const tspr) { - if ((tspr->cstat & (CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_RESERVED1)) || + if ((tspr->cstat & CSTAT_SPRITE_TRANSLUCENT) || (tspr->clipdist & TSPR_FLAGS_DRAW_LAST) || ((unsigned)tspr->owner < MAXSPRITES && spriteext[tspr->owner].alpha)) return true; diff --git a/source/duke3d/src/common_game.h b/source/duke3d/src/common_game.h index 709a137ec..f1e6aa386 100644 --- a/source/duke3d/src/common_game.h +++ b/source/duke3d/src/common_game.h @@ -7,6 +7,7 @@ #ifndef EDUKE32_COMMON_GAME_H_ #define EDUKE32_COMMON_GAME_H_ +#include "build.h" #include "gamecontrol.h" BEGIN_DUKE_NS @@ -55,5 +56,23 @@ extern void G_LoadLookups(void); ////////// +static inline void Duke_ApplySpritePropertiesToTSprite(tspriteptr_t tspr, uspriteptr_t spr) +{ + EDUKE32_STATIC_ASSERT(CSTAT_SPRITE_RESERVED1 >> 9 == TSPR_FLAGS_DRAW_LAST); + EDUKE32_STATIC_ASSERT(CSTAT_SPRITE_RESERVED4 >> 11 == TSPR_FLAGS_NO_SHADOW); + EDUKE32_STATIC_ASSERT(CSTAT_SPRITE_RESERVED5 >> 11 == TSPR_FLAGS_INVISIBLE_WITH_SHADOW); + + auto const cstat = spr->cstat; + tspr->clipdist |= ((cstat & CSTAT_SPRITE_RESERVED1) >> 9) | ((cstat & (CSTAT_SPRITE_RESERVED4|CSTAT_SPRITE_RESERVED5)) >> 11); +} + +void Duke_CommonCleanup(void); + +#if defined HAVE_FLAC || defined HAVE_VORBIS +# define FORMAT_UPGRADE_ELIGIBLE +extern int g_maybeUpgradeSoundFormats; +extern buildvfs_kfd S_OpenAudio(const char *fn, char searchfirst, uint8_t ismusic); +#else +# define S_OpenAudio(fn, searchfirst, ismusic) kopen4loadfrommod(fn, searchfirst) END_DUKE_NS #endif diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index c874077cc..e91e42e98 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -363,6 +363,7 @@ static void G_OROR_DupeSprites(spritetype const *sp) if (sprite[k].picnum != SECTOREFFECTOR && sprite[k].z >= sp->z) { tspriteptr_t tsp = renderAddTSpriteFromSprite(k); + Duke_ApplySpritePropertiesToTSprite(tsp, (uspriteptr_t)&sprite[k]); tsp->x += (refsp->x - sp->x); tsp->y += (refsp->y - sp->y); @@ -3502,6 +3503,8 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura const int32_t i = t->owner; auto const s = &sprite[i]; + Duke_ApplySpritePropertiesToTSprite(t, (uspriteptr_t)s); + switch (DYNAMICTILEMAP(s->picnum)) { case SECTOREFFECTOR__STATIC: @@ -3633,7 +3636,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura if (pSprite->picnum == NATURALLIGHTNING) { t->shade = -127; - t->cstat |= 8192; + t->clipdist |= TSPR_FLAGS_NO_SHADOW; } #endif if (t->statnum == TSPR_TEMP) @@ -3936,7 +3939,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura if ((!g_netServer && ud.multimode < 2) || ((g_netServer || ud.multimode > 1) && playerNum == screenpeek)) { if (videoGetRenderMode() == REND_POLYMER) - t->cstat |= 16384; + t->clipdist |= TSPR_FLAGS_INVISIBLE_WITH_SHADOW; else { t->owner = -1; @@ -4219,7 +4222,7 @@ skip: //g_restorePalette = 1; // JBF 20040101: why? } t->shade = -127; - t->cstat |= 8192+1024; + t->clipdist |= TSPR_FLAGS_DRAW_LAST | TSPR_FLAGS_NO_SHADOW; break; #ifndef EDUKE32_STANDALONE case FIRE__STATIC: @@ -4233,11 +4236,11 @@ skip: t->shade = -127; fallthrough__; case SMALLSMOKE__STATIC: - t->cstat |= 8192+1024; + t->clipdist |= TSPR_FLAGS_DRAW_LAST | TSPR_FLAGS_NO_SHADOW; break; case COOLEXPLOSION1__STATIC: t->shade = -127; - t->cstat |= 8192+1024; + t->clipdist |= TSPR_FLAGS_DRAW_LAST | TSPR_FLAGS_NO_SHADOW; t->picnum += (pSprite->shade>>1); break; case PLAYERONWATER__STATIC: