- When keeping around a dummy sprite, make sure that the engine's utilities cannot find it anymore.

This was causing issues with the master switch sprites in Duke that have to be kept for sound purposes.
Unfortunately, both hitscan and neartag are far too dumb to analyze sprites they may hit in any way and needed some help skipping such sprites.
This commit is contained in:
Christoph Oelckers 2021-04-17 09:37:38 +02:00
parent 962e313eb2
commit 42b87362ee
4 changed files with 8 additions and 1 deletions

View file

@ -152,6 +152,7 @@ enum
// 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

View file

@ -1428,6 +1428,10 @@ 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)
continue;
#ifdef USE_OPENGL
if (!hitallsprites)
#endif

View file

@ -2360,6 +2360,8 @@ 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)
continue;
if (blacklist_sprite_func && blacklist_sprite_func(z))
continue;

View file

@ -1014,7 +1014,7 @@ void movemasterswitch(DDukeActor *actor, int spectype1, int spectype2)
// This originally depended on undefined behavior as the deleted sprite was still used for the sound
// with no checking if it got reused in the mean time.
spri->picnum = 0; // give it a picnum without any behavior attached, just in case
spri->cstat |= CSTAT_SPRITE_INVISIBLE;
spri->cstat |= CSTAT_SPRITE_INVISIBLE|CSTAT_SPRITE_NOFIND;
changespritestat(actor->GetIndex(), STAT_REMOVED);
}
}