diff --git a/source/games/duke/src/actors.h b/source/games/duke/src/actors.h index eceabe233..c72e54ea8 100644 --- a/source/games/duke/src/actors.h +++ b/source/games/duke/src/actors.h @@ -241,11 +241,6 @@ inline int LocateTheLocator(int const tag, int const sectNum) return A_FindLocator(tag, sectNum); } -int A_CheckSwitchTile(int spriteNum); -inline int wallswitchcheck(int s) -{ - return A_CheckSwitchTile(s); -} int A_IncurDamage(int spriteNum); void A_AddToDeleteQueue(int spriteNum); void A_DeleteSprite(int spriteNum); diff --git a/source/games/duke/src/flags_d.cpp b/source/games/duke/src/flags_d.cpp index 695bd44d9..c00151378 100644 --- a/source/games/duke/src/flags_d.cpp +++ b/source/games/duke/src/flags_d.cpp @@ -88,6 +88,49 @@ void initactorflags_d() { setflag(SFLAG_INTERNAL_BADGUY|SFLAG_NODAMAGEPUSH, { FIREFLY, BOSS5, BOSS5STAYPUT }); } -} + + settileflag(TFLAG_WALLSWITCH, { + HANDPRINTSWITCH, + HANDPRINTSWITCH+1, + ALIENSWITCH, + ALIENSWITCH+1, + MULTISWITCH, + MULTISWITCH+1, + MULTISWITCH+2, + MULTISWITCH+3, + ACCESSSWITCH, + ACCESSSWITCH2, + PULLSWITCH, + PULLSWITCH+1, + HANDSWITCH, + HANDSWITCH+1, + SLOTDOOR, + SLOTDOOR+1, + LIGHTSWITCH, + LIGHTSWITCH+1, + SPACELIGHTSWITCH, + SPACELIGHTSWITCH+1, + SPACEDOORSWITCH, + SPACEDOORSWITCH+1, + FRANKENSTINESWITCH, + FRANKENSTINESWITCH+1, + LIGHTSWITCH2, + LIGHTSWITCH2+1, + POWERSWITCH1, + POWERSWITCH1+1, + LOCKSWITCH1, + LOCKSWITCH1+1, + POWERSWITCH2, + POWERSWITCH2+1, + DIPSWITCH, + DIPSWITCH+1, + DIPSWITCH2, + DIPSWITCH2+1, + TECHSWITCH, + TECHSWITCH+1, + DIPSWITCH3, + DIPSWITCH3+1}); +} + END_DUKE_NS diff --git a/source/games/duke/src/flags_r.cpp b/source/games/duke/src/flags_r.cpp index 602bf8903..a83584047 100644 --- a/source/games/duke/src/flags_r.cpp +++ b/source/games/duke/src/flags_r.cpp @@ -102,6 +102,57 @@ void initactorflags_r() { setflag(SFLAG_NODAMAGEPUSH, { HULK, SBMOVE }); } + + settileflag(TFLAG_WALLSWITCH, { + HANDPRINTSWITCH, + HANDPRINTSWITCH+1, + ALIENSWITCH, + ALIENSWITCH+1, + MULTISWITCH, + MULTISWITCH+1, + MULTISWITCH+2, + MULTISWITCH+3, + ACCESSSWITCH, + ACCESSSWITCH2, + PULLSWITCH, + PULLSWITCH+1, + HANDSWITCH, + HANDSWITCH+1, + SLOTDOOR, + SLOTDOOR+1, + LIGHTSWITCH, + LIGHTSWITCH+1, + SPACELIGHTSWITCH, + SPACELIGHTSWITCH+1, + SPACEDOORSWITCH, + SPACEDOORSWITCH+1, + FRANKENSTINESWITCH, + FRANKENSTINESWITCH+1, + LIGHTSWITCH2, + LIGHTSWITCH2+1, + POWERSWITCH1, + POWERSWITCH1+1, + LOCKSWITCH1, + LOCKSWITCH1+1, + POWERSWITCH2, + POWERSWITCH2+1, + DIPSWITCH, + DIPSWITCH+1, + DIPSWITCH2, + DIPSWITCH2+1, + TECHSWITCH, + TECHSWITCH+1, + DIPSWITCH3, + DIPSWITCH3+1, + NUKEBUTTON, + NUKEBUTTON+1}); + if (isRRRA()) settileflag(TFLAG_WALLSWITCH, { + MULTISWITCH2, + MULTISWITCH2+1, + MULTISWITCH2+2, + MULTISWITCH2+3, + RRTILE8464, + RRTILE8464+1}); } END_DUKE_NS \ No newline at end of file diff --git a/source/games/duke/src/game.h b/source/games/duke/src/game.h index f76aaa934..3cb377b6f 100644 --- a/source/games/duke/src/game.h +++ b/source/games/duke/src/game.h @@ -303,6 +303,17 @@ inline int32_t G_GetTeamPalette(int32_t team) return pal[team]; } +enum +{ + TFLAG_WALLSWITCH = 1 +}; +// for now just flags not related to actors, may get more info later. +struct TileInfo +{ + int flags; +}; +extern TileInfo tileinfo[MAXTILES]; + inline int actorflag(int spritenum, int mask) { return (((actorinfo[sprite[spritenum].picnum].flags/* ^ actor[spritenum].flags*/) & mask) != 0); @@ -321,6 +332,19 @@ inline void setflag(int flag, const std::initializer_list& types) } } +inline void settileflag(int flag, const std::initializer_list& types) +{ + for (auto val : types) + { + tileinfo[val].flags |= flag; + } +} + +inline bool wallswitchcheck(int s) +{ + return !!(tileinfo[s].flags & TFLAG_WALLSWITCH); +} + // (unsigned)iPicnum check: AMC TC Rusty Nails, bayonet MG alt. fire, iPicnum == -1 (via aplWeaponShoots) #define A_CheckSpriteTileFlags(iPicnum, iType) (((unsigned)iPicnum < MAXTILES) && (actorinfo[iPicnum].flags & iType) != 0) #define S_StopSound(num) S_StopEnvSound(num, -1) diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 488732c79..eed7f0fef 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -177,7 +177,7 @@ int initspriteforspawn(int j, int pn, const std::initializer_list &excludes if (!isIn(sp->picnum, excludes) && (sp->cstat & 48)) { if (sp->shade == 127) return i; - if (wallswitchcheck(i) == 1 && (sp->cstat & 16)) + if (wallswitchcheck(i) && (sp->cstat & 16)) { if (sp->picnum != TILE_ACCESSSWITCH && sp->picnum != TILE_ACCESSSWITCH2 && sprite[i].pal) { diff --git a/source/games/duke/src/zz_actors.cpp b/source/games/duke/src/zz_actors.cpp index 76c21afee..aa301f581 100644 --- a/source/games/duke/src/zz_actors.cpp +++ b/source/games/duke/src/zz_actors.cpp @@ -245,58 +245,7 @@ void A_PlayAlertSound(int spriteNum) } } -int A_CheckSwitchTile(int spriteNum) -{ - // picnum 0 would oob in the switch below, - - if (PN(spriteNum) <= 0) - return 0; - - // TILE_MULTISWITCH has 4 states so deal with it separately, - // TILE_ACCESSSWITCH and TILE_ACCESSSWITCH2 are only active in one state so deal with - // them separately. - - if ((PN(spriteNum) >= TILE_MULTISWITCH && PN(spriteNum) <= TILE_MULTISWITCH + 3) || (PN(spriteNum) == TILE_ACCESSSWITCH || PN(spriteNum) == TILE_ACCESSSWITCH2)) - return 1; - - if (RRRA && PN(spriteNum) >= TILE_MULTISWITCH2 && PN(spriteNum) <= TILE_MULTISWITCH2 + 3) - return 1; - - // Loop to catch both states of switches. - for (bssize_t j=1; j>=0; j--) - { - switch (DYNAMICTILEMAP(PN(spriteNum)-j)) - { - case RRTILE8464__STATICRR: - if (RRRA) return 1; - break; - case NUKEBUTTON__STATIC: - if (RR) return 1; - break; - case HANDPRINTSWITCH__STATIC: - case ALIENSWITCH__STATIC: - case MULTISWITCH__STATIC: - case PULLSWITCH__STATIC: - case HANDSWITCH__STATIC: - case SLOTDOOR__STATIC: - case LIGHTSWITCH__STATIC: - case SPACELIGHTSWITCH__STATIC: - case SPACEDOORSWITCH__STATIC: - case FRANKENSTINESWITCH__STATIC: - case LIGHTSWITCH2__STATIC: - case POWERSWITCH1__STATIC: - case LOCKSWITCH1__STATIC: - case POWERSWITCH2__STATIC: - case DIPSWITCH__STATIC: - case DIPSWITCH2__STATIC: - case TECHSWITCH__STATIC: - case DIPSWITCH3__STATIC: - return 1; - } - } - - return 0; -} +TileInfo tileinfo[MAXTILES]; void movefta_d(void);