From 7f485bfab1c5066327c1bb6c7abe16d98d4f71b3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Sep 2021 12:25:52 +0200 Subject: [PATCH] - split off the extended sprite flags into their own word. Some code overwrites the cstat field entirely (thanks Duke, for being sloppy with this...!) --- source/build/include/buildtypes.h | 11 +++++++---- source/build/src/clip.cpp | 4 ++-- source/build/src/engine.cpp | 2 +- source/build/src/polymost.cpp | 2 +- source/core/rendering/scene/hw_sprites.cpp | 2 +- source/core/savegamehelp.cpp | 1 + source/games/blood/src/animatesprite.cpp | 4 ++-- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/source/build/include/buildtypes.h b/source/build/include/buildtypes.h index 4e9288795..97f922eb3 100644 --- a/source/build/include/buildtypes.h +++ b/source/build/include/buildtypes.h @@ -185,10 +185,12 @@ enum CSTAT_SPRITE_RESERVED5 = 1u<<14u, // used by Duke 3D (Polymer), Shadow Warrior, Blood CSTAT_SPRITE_INVISIBLE = 1u<<15u, +}; - // Raze extensions, using the higher bits to avoid conflitcs with the reserved and undocumented bits above. - CSTAT_SPRITE_MDLROTATE = 1u<<16u, // Only for tsprites: rotate if this is a model or voxel. - CSTAT_SPRITE_NOFIND = 1u<<17u, // Invisible to neartag and hitscan +enum +{ + CSTAT2_SPRITE_MDLROTATE = 1, // Only for tsprites: rotate if this is a model or voxel. + CSTAT2_SPRITE_NOFIND = 2, // Invisible to neartag and hitscan }; enum @@ -245,7 +247,7 @@ struct spritetype }; vec3_t opos; }; - uint32_t cstat; + uint16_t cstat; int16_t picnum; int8_t shade; uint8_t pal, clipdist, blend; @@ -270,6 +272,7 @@ struct spritetype int16_t detail; int time; int16_t wall; + uint16_t cstat2; int8_t wdist; diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index 663acdd3d..165f7122c 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -1081,7 +1081,7 @@ void getzrange(const vec3_t *pos, int16_t sectnum, const int32_t cstat = sprite[j].cstat; int32_t daz, daz2; - if (cstat & CSTAT_SPRITE_NOFIND) continue; + if (sprite[j].cstat2 & CSTAT2_SPRITE_NOFIND) continue; if (cstat&dasprclipmask) { int32_t clipyou = 0; @@ -1417,7 +1417,7 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32 auto const spr = (uspriteptr_t)&sprite[z]; uint32_t const cstat = spr->cstat; - if (cstat & CSTAT_SPRITE_NOFIND) + if (spr->cstat2 & CSTAT2_SPRITE_NOFIND) continue; #ifdef USE_OPENGL diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 0ea687699..51c5c9160 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -1152,7 +1152,7 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, { auto const spr = (uspriteptr_t)&sprite[z]; - if (spr->cstat & CSTAT_SPRITE_NOFIND) + if (spr->cstat2 & CSTAT2_SPRITE_NOFIND) continue; if (blacklist_sprite_func && blacklist_sprite_func(z)) continue; diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 8dfa4dc59..89d248e11 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -3807,7 +3807,7 @@ int32_t polymost_voxdraw(voxmodel_t* m, tspriteptr_t const tspr, bool rotate) if ((tspr->cstat & 48) == 32) return 0; - if ((tspr->cstat & CSTAT_SPRITE_MDLROTATE) || rotate) + if ((tspr->cstat2 & CSTAT2_SPRITE_MDLROTATE) || rotate) { int myclock = (PlayClock << 3) + MulScale(4 << 3, pm_smoothratio, 16); tspr->ang = (tspr->ang + myclock) & 2047; // will be applied in md3_vox_calcmat_common. diff --git a/source/core/rendering/scene/hw_sprites.cpp b/source/core/rendering/scene/hw_sprites.cpp index a29c9f16f..d9223194e 100644 --- a/source/core/rendering/scene/hw_sprites.cpp +++ b/source/core/rendering/scene/hw_sprites.cpp @@ -459,7 +459,7 @@ bool HWSprite::ProcessVoxel(HWDrawInfo* di, voxmodel_t* vox, spritetype* spr, se voxel = vox; auto ang = spr->ang + sprext->angoff; - if ((spr->cstat & CSTAT_SPRITE_MDLROTATE) || rotate) + if ((spr->cstat2 & CSTAT2_SPRITE_MDLROTATE) || rotate) { int myclock = (PlayClock << 3) + MulScale(4 << 3, (int)di->Viewpoint.TicFrac, 16); ang = (ang + myclock) & 2047; diff --git a/source/core/savegamehelp.cpp b/source/core/savegamehelp.cpp index c3fa929fb..bbeca4999 100644 --- a/source/core/savegamehelp.cpp +++ b/source/core/savegamehelp.cpp @@ -465,6 +465,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, spritetype &c, spritet ("extra", c.extra, def->extra) ("detail", c.detail, def->detail) ("time", c.time, def->time) + ("cstat2", c.cstat2, def->cstat2) .EndObject(); } return arc; diff --git a/source/games/blood/src/animatesprite.cpp b/source/games/blood/src/animatesprite.cpp index 6ba582c01..c0a348494 100644 --- a/source/games/blood/src/animatesprite.cpp +++ b/source/games/blood/src/animatesprite.cpp @@ -659,7 +659,7 @@ void viewProcessSprites(spritetype* tsprite, int& spritesortcnt, int32_t cX, int int const nVoxel = tiletovox[pTSprite->picnum]; if (nVoxel != -1 && (picanm[nRootTile].extra & 7) == 7) - pTSprite->cstat |= CSTAT_SPRITE_MDLROTATE; // per-sprite rotation setting. + pTSprite->cstat2 |= CSTAT2_SPRITE_MDLROTATE; // per-sprite rotation setting. } if ((pTSprite->cstat&48) != 48 && hw_models && !(spriteext[nSprite].flags&SPREXT_NOTMD)) @@ -674,7 +674,7 @@ void viewProcessSprites(spritetype* tsprite, int& spritesortcnt, int32_t cX, int pTSprite->xoffset += tileLeftOffset(nAnimTile); if ((picanm[nRootTile].extra&7) == 7) - pTSprite->cstat |= CSTAT_SPRITE_MDLROTATE; // per-sprite rotation setting. + pTSprite->cstat2 |= CSTAT2_SPRITE_MDLROTATE; // per-sprite rotation setting. } }