engine: make neartag accept a sprite-blacklist function and use it in sector.c.

Internally, the last argument to neartag is now a pointer to a function
  int32_t (*blacklist_sprite_func)(int32_t i),
which is supposed to return 1 if sprite[i] should NOT be considered for hitting.

This is now used in the hard-coded neartag() calls in sector.c, but not in any
way in CON (there's neither a C blacklist function provided, nor is there a
possibility to define one in CON).  There, all sprites with picnums >=1 and <=10
(i.e. the effectors) will be blacklisted.  This remedies problems where such
sprites would get in the way of switches.

Note that a whitelist approach (only consider a predefined set, namely those
picnums which will be checked afterwards) has back-compatibility implications
since people may have used e.g. lotagged window sprites to cover a switch.

Also, the >=1 to <=10 range is [sic] (the static, not dynamic values are used),
since anyone redefining effector picnums is clearly out of their mind.

git-svn-id: https://svn.eduke32.com/eduke32@2373 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-02-20 19:54:24 +00:00
parent 1ec1e3e45c
commit 80bd1bb4e4
5 changed files with 30 additions and 10 deletions

View file

@ -618,7 +618,10 @@ int32_t clipinsideboxline(int32_t x, int32_t y, int32_t x1, int32_t y1, int32_
int32_t pushmove(vec3_t *vect, int16_t *sectnum, int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2))); int32_t pushmove(vec3_t *vect, int16_t *sectnum, int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2)));
void getzrange(const vec3_t *vect, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz, int32_t *florhit, int32_t walldist, uint32_t cliptype) ATTRIBUTE((nonnull(1,3,4,5,6))); void getzrange(const vec3_t *vect, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz, int32_t *florhit, int32_t walldist, uint32_t cliptype) ATTRIBUTE((nonnull(1,3,4,5,6)));
int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32_t vz, hitdata_t *hitinfo, uint32_t cliptype) ATTRIBUTE((nonnull(1,6))); int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32_t vz, hitdata_t *hitinfo, uint32_t cliptype) ATTRIBUTE((nonnull(1,6)));
void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, int16_t *neartagsector, int16_t *neartagwall, int16_t *neartagsprite, int32_t *neartaghitdist, int32_t neartagrange, uint8_t tagsearch) ATTRIBUTE((nonnull(6,7,8))); void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange,
int16_t *neartagsector, int16_t *neartagwall, int16_t *neartagsprite,
int32_t *neartaghitdist, int32_t neartagrange, uint8_t tagsearch,
int32_t (*blacklist_sprite_func)(int32_t)) ATTRIBUTE((nonnull(6,7,8)));
int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, int32_t y2, int32_t z2, int16_t sect2); int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, int32_t y2, int32_t z2, int16_t sect2);
void updatesector(int32_t x, int32_t y, int16_t *sectnum) ATTRIBUTE((nonnull(3))); void updatesector(int32_t x, int32_t y, int16_t *sectnum) ATTRIBUTE((nonnull(3)));
void updatesector_onlynextwalls(int32_t x, int32_t y, int16_t *sectnum) ATTRIBUTE((nonnull(3))); void updatesector_onlynextwalls(int32_t x, int32_t y, int16_t *sectnum) ATTRIBUTE((nonnull(3)));

View file

@ -11456,7 +11456,8 @@ restart_grand:
// neartag // neartag
// //
void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, int16_t *neartagsector, int16_t *neartagwall, void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, int16_t *neartagsector, int16_t *neartagwall,
int16_t *neartagsprite, int32_t *neartaghitdist, int32_t neartagrange, uint8_t tagsearch) int16_t *neartagsprite, int32_t *neartaghitdist, int32_t neartagrange, uint8_t tagsearch,
int32_t (*blacklist_sprite_func)(int32_t))
{ {
walltype *wal, *wal2; walltype *wal, *wal2;
spritetype *spr; spritetype *spr;
@ -11526,6 +11527,9 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange,
for (z=headspritesect[dasector]; z>=0; z=nextspritesect[z]) for (z=headspritesect[dasector]; z>=0; z=nextspritesect[z])
{ {
if (blacklist_sprite_func && blacklist_sprite_func(z))
continue;
spr = &sprite[z]; spr = &sprite[z];
good = 0; good = 0;

View file

@ -2735,7 +2735,8 @@ nullquote:
OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],sectnum); OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],sectnum);
continue; continue;
} }
neartag(x, y, z, sectnum, ang, &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, neartagrange, tagsearch); neartag(x, y, z, sectnum, ang, &neartagsector, &neartagwall, &neartagsprite,
&neartaghitdist, neartagrange, tagsearch, NULL);
Gv_SetVarX(neartagsectorvar, neartagsector); Gv_SetVarX(neartagsectorvar, neartagsector);
Gv_SetVarX(neartagwallvar, neartagwall); Gv_SetVarX(neartagwallvar, neartagwall);
@ -3264,7 +3265,8 @@ nullquote:
if (sector[vm.g_sp->sectnum].lotag == 0) if (sector[vm.g_sp->sectnum].lotag == 0)
{ {
neartag(vm.g_sp->x,vm.g_sp->y,vm.g_sp->z-(32<<8),vm.g_sp->sectnum,vm.g_sp->ang, neartag(vm.g_sp->x,vm.g_sp->y,vm.g_sp->z-(32<<8),vm.g_sp->sectnum,vm.g_sp->ang,
&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,768L,5); &neartagsector,&neartagwall,&neartagsprite,&neartaghitdist, 768, 4+1, NULL);
if (neartagsector >= 0 && isanearoperator(sector[neartagsector].lotag)) if (neartagsector >= 0 && isanearoperator(sector[neartagsector].lotag))
if ((sector[neartagsector].lotag&0xff) == 23 || sector[neartagsector].floorz == sector[neartagsector].ceilingz) if ((sector[neartagsector].lotag&0xff) == 23 || sector[neartagsector].floorz == sector[neartagsector].ceilingz)
if ((sector[neartagsector].lotag&16384) == 0) if ((sector[neartagsector].lotag&16384) == 0)

View file

@ -1918,7 +1918,8 @@ badindex:
int32_t neartaghitdist; int32_t neartaghitdist;
X_ERROR_INVALIDSECT(sectnum); X_ERROR_INVALIDSECT(sectnum);
neartag(x, y, z, sectnum, ang, &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, neartagrange, tagsearch); neartag(x, y, z, sectnum, ang, &neartagsector, &neartagwall, &neartagsprite,
&neartaghitdist, neartagrange, tagsearch, NULL);
Gv_SetVarX(neartagsectorvar, neartagsector); Gv_SetVarX(neartagsectorvar, neartagsector);
Gv_SetVarX(neartagwallvar, neartagwall); Gv_SetVarX(neartagwallvar, neartagwall);

View file

@ -3052,6 +3052,11 @@ static int32_t P_FindWall(DukePlayer_t *p,int16_t *hitw)
return (FindDistance2D(hitinfo.pos.x-p->pos.x,hitinfo.pos.y-p->pos.y)); return (FindDistance2D(hitinfo.pos.x-p->pos.x,hitinfo.pos.y-p->pos.y));
} }
// returns 1 if sprite i should not be considered by neartag
static int32_t our_neartag_blacklist(int32_t i)
{
return sprite[i].picnum >= SECTOREFFECTOR__STATIC && sprite[i].picnum <= GPSPEED__STATIC;
}
void P_CheckSectors(int32_t snum) void P_CheckSectors(int32_t snum)
{ {
@ -3163,17 +3168,22 @@ void P_CheckSectors(int32_t snum)
} }
if (p->newowner >= 0) if (p->newowner >= 0)
neartag(p->opos.x,p->opos.y,p->opos.z,sprite[p->i].sectnum,p->oang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,1280L,1); neartag(p->opos.x,p->opos.y,p->opos.z,sprite[p->i].sectnum,p->oang,&neartagsector,
&neartagwall,&neartagsprite,&neartaghitdist, 1280, 1, our_neartag_blacklist);
else else
{ {
neartag(p->pos.x,p->pos.y,p->pos.z,sprite[p->i].sectnum,p->oang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,1280L,1); neartag(p->pos.x,p->pos.y,p->pos.z,sprite[p->i].sectnum,p->oang,&neartagsector,
&neartagwall,&neartagsprite,&neartaghitdist, 1280, 1, our_neartag_blacklist);
if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1)
neartag(p->pos.x,p->pos.y,p->pos.z+(8<<8),sprite[p->i].sectnum,p->oang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,1280L,1); neartag(p->pos.x,p->pos.y,p->pos.z+(8<<8),sprite[p->i].sectnum,p->oang,&neartagsector,
&neartagwall,&neartagsprite,&neartaghitdist, 1280, 1, our_neartag_blacklist);
if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1)
neartag(p->pos.x,p->pos.y,p->pos.z+(16<<8),sprite[p->i].sectnum,p->oang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,1280L,1); neartag(p->pos.x,p->pos.y,p->pos.z+(16<<8),sprite[p->i].sectnum,p->oang,&neartagsector,
&neartagwall,&neartagsprite,&neartaghitdist, 1280, 1, our_neartag_blacklist);
if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1)
{ {
neartag(p->pos.x,p->pos.y,p->pos.z+(16<<8),sprite[p->i].sectnum,p->oang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,1280L,3); neartag(p->pos.x,p->pos.y,p->pos.z+(16<<8),sprite[p->i].sectnum,p->oang,&neartagsector,
&neartagwall,&neartagsprite,&neartaghitdist, 1280, 3, our_neartag_blacklist);
if (neartagsprite >= 0) if (neartagsprite >= 0)
{ {
switch (DYNAMICTILEMAP(sprite[neartagsprite].picnum)) switch (DYNAMICTILEMAP(sprite[neartagsprite].picnum))