- split off the extended sprite flags into their own word.

Some code overwrites the cstat field entirely (thanks Duke, for being sloppy with this...!)
This commit is contained in:
Christoph Oelckers 2021-09-05 12:25:52 +02:00
parent 99ecfe133d
commit 7f485bfab1
7 changed files with 15 additions and 11 deletions

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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.

View file

@ -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;

View file

@ -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;

View file

@ -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.
}
}