diff --git a/polymer/eduke32/build/include/m32script.h b/polymer/eduke32/build/include/m32script.h index f95b17748..f1b9d59f4 100644 --- a/polymer/eduke32/build/include/m32script.h +++ b/polymer/eduke32/build/include/m32script.h @@ -39,9 +39,6 @@ typedef int32_t ofstype; extern char *ScriptQuotes[MAXQUOTES+1], *ScriptQuoteRedefinitions[MAXQUOTES+1]; extern int32_t g_numQuoteRedefinitions; -//extern int16_t neartagsector, neartagwall, neartagsprite; -//extern int32_t neartaghitdist; - extern int32_t VM_Execute(int32_t once); extern void VM_OnEvent(register int32_t iEventID, register int32_t iActor); diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 883ef7c00..088ae27d4 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -12707,8 +12707,9 @@ restart_grand: // // neartag // -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, +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, /* out */ + int32_t neartagrange, uint8_t tagsearch, int32_t (*blacklist_sprite_func)(int32_t)) { int16_t tempshortcnt, tempshortnum; diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index a7fbdf4cd..e54e57d4d 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -3064,6 +3064,9 @@ nullquote: int32_t neartagsectorvar=*insptr++, neartagwallvar=*insptr++, neartagspritevar=*insptr++, neartaghitdistvar=*insptr++; int32_t neartagrange=Gv_GetVarX(*insptr++), tagsearch=Gv_GetVarX(*insptr++); + int16_t neartagsector, neartagwall, neartagsprite; + int32_t neartaghitdist; + if ((unsigned)sectnum >= (unsigned)numsectors) { CON_ERRPRINTF("Invalid sector %d\n", sectnum); @@ -3548,24 +3551,25 @@ nullquote: insptr++; if (sector[vm.g_sp->sectnum].lotag == 0) { + int16_t neartagsector, neartagwall, neartagsprite; + int32_t neartaghitdist; + 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, 768, 4+1, NULL); if (neartagsector >= 0 && isanearoperator(sector[neartagsector].lotag)) if ((sector[neartagsector].lotag&0xff) == ST_23_SWINGING_DOOR || sector[neartagsector].floorz == sector[neartagsector].ceilingz) - if ((sector[neartagsector].lotag&16384) == 0) - if ((sector[neartagsector].lotag&32768) == 0) - { - int32_t j = headspritesect[neartagsector]; - while (j >= 0) - { - if (sprite[j].picnum == ACTIVATOR) - break; - j = nextspritesect[j]; - } - if (j == -1) - G_OperateSectors(neartagsector,vm.g_i); - } + if ((sector[neartagsector].lotag&(16384|32768)) == 0) + { + int32_t j; + + for (SPRITES_OF_SECT(neartagsector, j)) + if (sprite[j].picnum == ACTIVATOR) + break; + + if (j == -1) + G_OperateSectors(neartagsector,vm.g_i); + } } continue; diff --git a/polymer/eduke32/source/global.h b/polymer/eduke32/source/global.h index 1f5bbba97..29a41b774 100644 --- a/polymer/eduke32/source/global.h +++ b/polymer/eduke32/source/global.h @@ -82,7 +82,6 @@ G_EXTERN int16_t g_numAnimWalls; G_EXTERN int16_t g_numClouds,clouds[128],cloudx[128],cloudy[128]; G_EXTERN int16_t myang,omyang,mycursectnum,myjumpingcounter; G_EXTERN int16_t myhoriz,omyhoriz,myhorizoff,omyhorizoff; -G_EXTERN int16_t neartagsector,neartagwall,neartagsprite; // XXX: these ought to be globals? G_EXTERN int32_t *animateptr[MAXANIMATES]; G_EXTERN int32_t animategoal[MAXANIMATES],animatevel[MAXANIMATES],g_animateCount; G_EXTERN int32_t cloudtotalclock; diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index 3adb61ae0..c6551e253 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -1281,8 +1281,10 @@ function _operate(spritenum) if (tag.sector >= 0) then local sect = sector[tag.sector] local lotag = sect.lotag - if (NEAROP[band(lotag, 0xff)]) then - if (lotag==23 or sect.floorz==sect.ceilingz) then + local lotag_lo = band(lotag, 0xff) + + if (NEAROP[lotag_lo]) then + if (lotag_lo == 23 or sect.floorz == sect.ceilingz) then if (band(lotag, 32768+16384) == 0) then for j in spritesofsect(tag.sector) do if (ispic(sprite[j].picnum, "ACTIVATOR")) then diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index f0f062005..ea374b68f 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -2993,6 +2993,9 @@ void P_CheckSectors(int32_t snum) { int16_t hitscanwall; + int16_t neartagsector, neartagwall, neartagsprite; + int32_t neartaghitdist; + if (TEST_SYNC_KEY(g_player[snum].sync->bits, SK_ESCAPE)) { if (p->newowner >= 0)