Skip to content

Commit

Permalink
- When keeping around a dummy sprite, make sure that the engine's uti…
Browse files Browse the repository at this point in the history
…lities 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.
  • Loading branch information
coelckers committed Apr 17, 2021
1 parent 962e313 commit 42b8736
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions source/build/include/buildtypes.h
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions source/build/src/clip.cpp
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions source/build/src/engine.cpp
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/actors.cpp
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 42b8736

Please sign in to comment.