From 95a2b85fae3d409ab1cfbcc22f8a1898b32ad9c4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Dec 2022 15:42:33 +0100 Subject: [PATCH] - migrated the rest of the switch code to use the external data. --- source/games/duke/src/dispatch.cpp | 10 +- source/games/duke/src/duke3d.h | 2 +- source/games/duke/src/funct.h | 1 + source/games/duke/src/player_d.cpp | 12 +- source/games/duke/src/player_r.cpp | 12 +- source/games/duke/src/sectors.cpp | 171 ++++++++++++++++++- source/games/duke/src/sectors_d.cpp | 206 +---------------------- source/games/duke/src/sectors_r.cpp | 251 +--------------------------- 8 files changed, 194 insertions(+), 471 deletions(-) diff --git a/source/games/duke/src/dispatch.cpp b/source/games/duke/src/dispatch.cpp index 7504148dd..73ccf5849 100644 --- a/source/games/duke/src/dispatch.cpp +++ b/source/games/duke/src/dispatch.cpp @@ -39,8 +39,8 @@ void animatewalls_d(void); void animatewalls_r(void); void operateforcefields_r(DDukeActor* act, int low); void operateforcefields_d(DDukeActor* act, int low); -bool checkhitswitch_d(int snum, walltype* w, DDukeActor *act); -bool checkhitswitch_r(int snum, walltype* w, DDukeActor* act); +bool checkaccessswitch_d(int snum, int pal, DDukeActor *act, walltype* w); +bool checkaccessswitch_r(int snum, int pal, DDukeActor* act, walltype* w); void activatebysector_d(sectortype* sect, DDukeActor* j); void activatebysector_r(sectortype* sect, DDukeActor* j); void checkhitsprite_d(DDukeActor* i, DDukeActor* sn); @@ -101,7 +101,7 @@ void SetDispatcher() initactorflags_d, animatewalls_d, operateforcefields_d, - checkhitswitch_d, + checkaccessswitch_d, activatebysector_d, checkhitsprite_d, checkhitdefault_d, @@ -137,7 +137,7 @@ void SetDispatcher() initactorflags_r, animatewalls_r, operateforcefields_r, - checkhitswitch_r, + checkaccessswitch_r, activatebysector_r, checkhitsprite_r, checkhitdefault_r, @@ -185,8 +185,6 @@ int TILE_WATERBUBBLE; int TILE_SMALLSMOKE; int TILE_BLOODPOOL; int TILE_CLOUDYSKIES; -int TILE_ACCESSSWITCH; -int TILE_ACCESSSWITCH2; int TILE_HEN; int TILE_MIRRORBROKE; int TILE_LOADSCREEN; diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 96d3c7f86..9bd2fe6dd 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -75,7 +75,7 @@ struct Dispatcher void (*initactorflags)(); void (*animatewalls)(); void (*operateforcefields)(DDukeActor* act, int low); - bool (*checkhitswitch)(int snum, walltype* w, DDukeActor* act); + bool (*checkaccessswitch)(int snum, int switchpal, DDukeActor* act, walltype* w); void (*activatebysector)(sectortype* sect, DDukeActor* j); void (*checkhitsprite)(DDukeActor* i, DDukeActor* sn); void (*checkhitdefault)(DDukeActor* i, DDukeActor* sn); diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 3a881c63a..c32c47585 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -220,6 +220,7 @@ bool movementBlocked(player_struct *p); void loadcons(); void DrawStatusBar(); void thunder(void); +bool checkhitswitch(int snum, walltype* wwal, DDukeActor* act); void drawshadows(tspriteArray& tsprites, tspritetype* t, DDukeActor* h); void applyanimations(tspritetype* t, DDukeActor* h, const DVector2& viewVec, DAngle viewang); diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 0bd11fa7d..e8db7217a 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -271,7 +271,7 @@ static void shootknee(DDukeActor* actor, int p, DVector3 pos, DAngle ang) if (hit.actor() && ! isaccessswitch(hit.actor()->spr.spritetexture())) { fi.checkhitsprite(hit.actor(), knee); - if (p >= 0) fi.checkhitswitch(p, nullptr, hit.actor()); + if (p >= 0) checkhitswitch(p, nullptr, hit.actor()); } else if (hit.hitWall) @@ -284,7 +284,7 @@ static void shootknee(DDukeActor* actor, int p, DVector3 pos, DAngle ang) if (!isaccessswitch(hit.hitWall->walltexture())) { checkhitwall(knee, hit.hitWall, hit.hitpos); - if (p >= 0) fi.checkhitswitch(p, hit.hitWall, nullptr); + if (p >= 0) checkhitswitch(p, hit.hitWall, nullptr); } } } @@ -443,7 +443,7 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int if (p >= 0 && isshootableswitch(hit.actor()->spr.spritetexture())) { - fi.checkhitswitch(p, nullptr, hit.actor()); + checkhitswitch(p, nullptr, hit.actor()); return; } } @@ -457,7 +457,7 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int goto SKIPBULLETHOLE; if (p >= 0 && isshootableswitch(hit.hitWall->walltexture())) { - fi.checkhitswitch(p, hit.hitWall, nullptr); + checkhitswitch(p, hit.hitWall, nullptr); return; } @@ -1507,7 +1507,7 @@ int doincrements_d(player_struct* p) { if (p->access_spritenum != nullptr) { - fi.checkhitswitch(snum, nullptr, p->access_spritenum); + checkhitswitch(snum, nullptr, p->access_spritenum); switch (p->access_spritenum->spr.pal) { case 0:p->got_access &= (0xffff - 0x1); break; @@ -1518,7 +1518,7 @@ int doincrements_d(player_struct* p) } else { - fi.checkhitswitch(snum, p->access_wall, nullptr); + checkhitswitch(snum, p->access_wall, nullptr); switch (p->access_wall->pal) { case 0:p->got_access &= (0xffff - 0x1); break; diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index b1df7a68a..dc046fa5a 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -163,7 +163,7 @@ static void shootmelee(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int a if (hit.actor() && !isaccessswitch(hit.actor()->spr.spritetexture())) { fi.checkhitsprite(hit.actor(), wpn); - if (p >= 0) fi.checkhitswitch(p, nullptr, hit.actor()); + if (p >= 0) checkhitswitch(p, nullptr, hit.actor()); } else if (hit.hitWall) { @@ -175,7 +175,7 @@ static void shootmelee(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int a if (!isaccessswitch(hit.hitWall->walltexture())) { checkhitwall(wpn, hit.hitWall, hit.hitpos); - if (p >= 0) fi.checkhitswitch(p, hit.hitWall, nullptr); + if (p >= 0) checkhitswitch(p, hit.hitWall, nullptr); } } } @@ -336,7 +336,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int if (p >= 0 && isshootableswitch(hit.actor()->spr.spritetexture())) { - fi.checkhitswitch(p, nullptr, hit.actor()); + checkhitswitch(p, nullptr, hit.actor()); return; } } @@ -350,7 +350,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int goto SKIPBULLETHOLE; if (p >= 0 && isshootableswitch(hit.hitWall->walltexture())) { - fi.checkhitswitch(p, hit.hitWall, nullptr); + checkhitswitch(p, hit.hitWall, nullptr); return; } @@ -1286,7 +1286,7 @@ int doincrements_r(player_struct* p) { if (p->access_spritenum != nullptr) { - fi.checkhitswitch(snum, nullptr, p->access_spritenum); + checkhitswitch(snum, nullptr, p->access_spritenum); switch (p->access_spritenum->spr.pal) { case 0:p->keys[1] = 1; break; @@ -1297,7 +1297,7 @@ int doincrements_r(player_struct* p) } else { - fi.checkhitswitch(snum, p->access_wall, nullptr); + checkhitswitch(snum, p->access_wall, nullptr); switch (p->access_wall->pal) { case 0:p->keys[1] = 1; break; diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index b2d3413ff..5da8faa7c 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -1489,7 +1489,7 @@ void tag10000specialswitch(int snum, DDukeActor* act, const DVector3& v) { switches[j]->spr.hitag = 0; switches[j]->spr.setspritetexture(::switches[GetExtInfo(switches[j]->spr.spritetexture()).switchindex].states[3]); - fi.checkhitswitch(snum, nullptr, switches[j]); + checkhitswitch(snum, nullptr, switches[j]); } } } @@ -1597,4 +1597,173 @@ void togglewallswitches(walltype* wwal, const TexExtInfo& ext, int lotag, int& c } } +//--------------------------------------------------------------------------- +// +// how NOT to implement switches... +// (even after cleaning up the hard coded texture checks it's still a disaster) +// +//--------------------------------------------------------------------------- + +bool checkhitswitch(int snum, walltype* wwal, DDukeActor* act) +{ + uint8_t switchpal; + int lotag, hitag, correctdips, numdips; + DVector2 spos; + FTextureID texid; + + if (wwal == nullptr && act == nullptr) return 0; + correctdips = 1; + numdips = 0; + + if (act) + { + lotag = act->spr.lotag; + if (lotag == 0) return 0; + hitag = act->spr.hitag; + spos = act->spr.pos.XY(); + texid = act->spr.spritetexture(); + switchpal = act->spr.pal; + + // custom switches that maintain themselves can immediately abort. + if (CallTriggerSwitch(act, &ps[snum])) return true; + } + else + { + lotag = wwal->lotag; + if (lotag == 0) return 0; + hitag = wwal->hitag; + spos = wwal->pos; + texid = wwal->walltexture(); + switchpal = wwal->pal; + } + auto& ext = GetExtInfo(texid); + auto& swdef = switches[ext.switchindex]; + + // check if the switch may be activated. + switch (swdef.type) + { + case SwitchDef::Combo: + break; + + case SwitchDef::Access: + if (!fi.checkaccessswitch(snum, switchpal, act, wwal)) + return 0; + [[fallthrough]]; + + case SwitchDef::Regular: + case SwitchDef::Multi: + if (check_activator_motion(lotag)) return 0; + break; + + default: + if (isadoorwall(texid) == 0) return 0; + break; + } + + togglespriteswitches(act, ext, lotag, correctdips, numdips); + togglewallswitches(wwal, ext, lotag, correctdips, numdips); + + if (lotag == -1) + { + setnextmap(false); + return 1; + } + + DVector3 v(spos, ps[snum].GetActor()->getOffsetZ()); + + // Yet another crude RRRA hack that cannot be fully generalized. + if (hitag == 10001 && swdef.flags & SwitchDef::oneway && isRRRA()) + { + act->spr.setspritetexture(swdef.states[1]); + if (ps[snum].SeaSick == 0) + ps[snum].SeaSick = 350; + operateactivators(668, &ps[snum]); + operatemasterswitches(668); + S_PlayActorSound(328, ps[snum].GetActor()); + return 1; + } + + if (swdef.type != SwitchDef::None || isadoorwall(texid)) + { + if (swdef.type == SwitchDef::Combo) + { + FSoundID sound = swdef.soundid != NO_SOUND ? swdef.soundid : S_FindSoundByResID(SWITCH_ON); + if (act) S_PlaySound3D(sound, act, v); + else S_PlaySound3D(sound, ps[snum].GetActor(), v); + if (numdips != correctdips) return 0; + S_PlaySound3D(END_OF_LEVEL_WARN, ps[snum].GetActor(), v); + } + if (swdef.type == SwitchDef::Multi) + { + lotag += ext.switchphase; + if (hitag == 10000 && act && isRRRA()) // no idea if the game check is really needed for something this far off the beaten path... + { + tag10000specialswitch(snum, act, v); + return 1; + } + } + + DukeStatIterator itr(STAT_EFFECTOR); + while (auto other = itr.Next()) + { + if (other->spr.hitag == lotag) + { + switch (other->spr.lotag) + { + case 46: + case SE_47_LIGHT_SWITCH: + case SE_48_LIGHT_SWITCH: + if (!isRRRA()) break; + [[fallthrough]]; + + case SE_12_LIGHT_SWITCH: + other->sector()->floorpal = 0; + other->temp_data[0]++; + if (other->temp_data[0] == 2) + other->temp_data[0]++; + + break; + case SE_24_CONVEYOR: + case SE_34: + case SE_25_PISTON: + other->temp_data[4] = !other->temp_data[4]; + if (other->temp_data[4]) + FTA(15, &ps[snum]); + else FTA(2, &ps[snum]); + break; + case SE_21_DROP_FLOOR: + FTA(2, &ps[screenpeek]); + break; + } + } + } + + operateactivators(lotag, &ps[snum]); + fi.operateforcefields(ps[snum].GetActor(), lotag); + operatemasterswitches(lotag); + + if (swdef.type == SwitchDef::Combo) return 1; + + if (hitag == 0 && isadoorwall(texid) == 0) + { + FSoundID sound = swdef.soundid != NO_SOUND ? swdef.soundid : S_FindSoundByResID(SWITCH_ON); + if (act) S_PlaySound3D(sound, act, v); + else S_PlaySound3D(sound, ps[snum].GetActor(), v); + } + else if (hitag != 0) + { + auto flags = S_GetUserFlags(hitag); + + if (act && (flags & SF_TALK) == 0) + S_PlaySound3D(hitag, act, v); + else + S_PlayActorSound(hitag, ps[snum].GetActor()); + } + + return 1; + } + return 0; +} + + END_DUKE_NS diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index b9b1b9498..856215c01 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -198,206 +198,6 @@ bool checkaccessswitch_d(int snum, int switchpal, DDukeActor* act, walltype* wwa return 0; } -//--------------------------------------------------------------------------- -// -// how NOT to implement switch animations... -// -//--------------------------------------------------------------------------- -void togglespriteswitches(DDukeActor* act, const TexExtInfo& ext, int lotag, int& correctdips, int& numdips); -void togglewallswitches(walltype* wwal, const TexExtInfo& ext, int lotag, int& correctdips, int& numdips); - -bool checkhitswitch_d(int snum, walltype* wwal, DDukeActor *act) -{ - uint8_t switchpal; - int lotag, hitag, picnum, correctdips, numdips; - DVector2 spos; - FTextureID texid; - - if (wwal == nullptr && act == nullptr) return 0; - correctdips = 1; - numdips = 0; - - if (act) - { - lotag = act->spr.lotag; - if (lotag == 0) return 0; - hitag = act->spr.hitag; - spos = act->spr.pos.XY(); - picnum = act->spr.picnum; - switchpal = act->spr.pal; - - // custom switches that maintain themselves can immediately abort. - if (CallTriggerSwitch(act, &ps[snum])) return true; - } - else - { - lotag = wwal->lotag; - if (lotag == 0) return 0; - hitag = wwal->hitag; - spos = wwal->pos; - picnum = wwal->wallpicnum; - switchpal = wwal->pal; - } - texid = tileGetTextureID(picnum); - auto& ext = GetExtInfo(texid); - auto& swdef = switches[ext.switchindex]; - - switch (swdef.type) - { - case SwitchDef::Combo: - break; - - case SwitchDef::Access: - if (checkaccessswitch_d(snum, switchpal, act, wwal)) - return 0; - [[fallthrough]]; - - case SwitchDef::Regular: - case SwitchDef::Multi: - if (check_activator_motion(lotag)) return 0; - break; - - default: - if (isadoorwall(texid) == 0) return 0; - break; - } - - togglespriteswitches(act, ext, lotag, correctdips, numdips); - togglewallswitches(wwal, ext, lotag, correctdips, numdips); - - if (lotag == -1) - { - setnextmap(false); - return 1; - } - - DVector3 v(spos, ps[snum].GetActor()->getOffsetZ()); - switch (picnum) - { - default: - if (isadoorwall(texid) == 0) break; - [[fallthrough]]; - case DTILE_DIPSWITCH: - case DTILE_DIPSWITCHON: - case DTILE_TECHSWITCH: - case DTILE_TECHSWITCHON: - case DTILE_ALIENSWITCH: - case DTILE_ALIENSWITCHON: - if (picnum == DTILE_DIPSWITCH || picnum == DTILE_DIPSWITCHON || - picnum == DTILE_ALIENSWITCH || picnum == DTILE_ALIENSWITCHON || - picnum == DTILE_TECHSWITCH || picnum == DTILE_TECHSWITCHON) - { - if (picnum == DTILE_ALIENSWITCH || picnum == DTILE_ALIENSWITCHON) - { - if (act) - S_PlaySound3D(ALIEN_SWITCH1, act, v); - else S_PlaySound3D(ALIEN_SWITCH1, ps[snum].GetActor(), v); - } - else - { - if (act) - S_PlaySound3D(SWITCH_ON, act, v); - else S_PlaySound3D(SWITCH_ON, ps[snum].GetActor(), v); - } - if (numdips != correctdips) break; - S_PlaySound3D(END_OF_LEVEL_WARN, ps[snum].GetActor(), v); - } - [[fallthrough]]; - case DTILE_DIPSWITCH2: - case DTILE_DIPSWITCH2ON: - case DTILE_DIPSWITCH3: - case DTILE_DIPSWITCH3ON: - case DTILE_MULTISWITCH: - case DTILE_MULTISWITCH_2: - case DTILE_MULTISWITCH_3: - case DTILE_MULTISWITCH_4: - case DTILE_ACCESSSWITCH: - case DTILE_ACCESSSWITCH2: - case DTILE_SLOTDOOR: - case DTILE_SLOTDOORON: - case DTILE_LIGHTSWITCH: - case DTILE_LIGHTSWITCHON: - case DTILE_SPACELIGHTSWITCH: - case DTILE_SPACELIGHTSWITCHON: - case DTILE_SPACEDOORSWITCH: - case DTILE_SPACEDOORSWITCHON: - case DTILE_FRANKENSTINESWITCH: - case DTILE_FRANKENSTINESWITCHON: - case DTILE_LIGHTSWITCH2: - case DTILE_LIGHTSWITCH2ON: - case DTILE_POWERSWITCH1: - case DTILE_POWERSWITCH1ON: - case DTILE_LOCKSWITCH1: - case DTILE_LOCKSWITCH1ON: - case DTILE_POWERSWITCH2: - case DTILE_POWERSWITCH2ON: - case DTILE_HANDSWITCH: - case DTILE_HANDSWITCHON: - case DTILE_PULLSWITCH: - case DTILE_PULLSWITCHON: - - if (picnum == DTILE_MULTISWITCH || picnum == (DTILE_MULTISWITCH_2) || - picnum == (DTILE_MULTISWITCH_3) || picnum == (DTILE_MULTISWITCH_4)) - lotag += picnum - DTILE_MULTISWITCH; - - DukeStatIterator itr(STAT_EFFECTOR); - while (auto other = itr.Next()) - { - if (other->spr.hitag == lotag) - { - switch (other->spr.lotag) - { - case SE_12_LIGHT_SWITCH: - other->sector()->floorpal = 0; - other->temp_data[0]++; - if (other->temp_data[0] == 2) - other->temp_data[0]++; - - break; - case SE_24_CONVEYOR: - case SE_34: - case SE_25_PISTON: - other->temp_data[4] = !other->temp_data[4]; - if (other->temp_data[4]) - FTA(15, &ps[snum]); - else FTA(2, &ps[snum]); - break; - case SE_21_DROP_FLOOR: - FTA(2, &ps[screenpeek]); - break; - } - } - } - - operateactivators(lotag, &ps[snum]); - fi.operateforcefields(ps[snum].GetActor(), lotag); - operatemasterswitches(lotag); - - if (picnum == DTILE_DIPSWITCH || picnum == DTILE_DIPSWITCHON || - picnum == DTILE_ALIENSWITCH || picnum == DTILE_ALIENSWITCHON || - picnum == DTILE_TECHSWITCH || picnum == DTILE_TECHSWITCHON) return 1; - - if (hitag == 0 && isadoorwall(texid) == 0) - { - if (act) - S_PlaySound3D(SWITCH_ON, act, v); - else S_PlaySound3D(SWITCH_ON, ps[snum].GetActor(), v); - } - else if (hitag != 0) - { - auto flags = S_GetUserFlags(hitag); - - if (act && (flags & SF_TALK) == 0) - S_PlaySound3D(hitag, act, v); - else - S_PlayActorSound(hitag, ps[snum].GetActor()); - } - - return 1; - } - return 0; -} - //--------------------------------------------------------------------------- // // @@ -755,7 +555,7 @@ void checksectors_d(int snum) auto const neartagsprite = near.actor(); if (neartagsprite != nullptr) { - if (fi.checkhitswitch(snum, nullptr, neartagsprite)) return; + if (checkhitswitch(snum, nullptr, neartagsprite)) return; if (CallOnUse(neartagsprite, p)) return; @@ -782,7 +582,7 @@ void checksectors_d(int snum) if (near.hitWall->lotag > 0 && isadoorwall(near.hitWall->walltexture())) { if (hitscanwall == near.hitWall || hitscanwall == nullptr) - fi.checkhitswitch(snum, near.hitWall, nullptr); + checkhitswitch(snum, near.hitWall, nullptr); return; } else if (p->newOwner != nullptr) @@ -813,7 +613,7 @@ void checksectors_d(int snum) } operatesectors(p->GetActor()->sector(), p->GetActor()); } - else fi.checkhitswitch(snum, near.hitWall, nullptr); + else checkhitswitch(snum, near.hitWall, nullptr); } } } diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index b64ebcc6c..11cbe447f 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -168,251 +168,6 @@ bool checkaccessswitch_r(int snum, int switchpal, DDukeActor* act, walltype* wwa return 0; } -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- -void tag10000specialswitch(int snum, DDukeActor* act, const DVector3& v); -void togglespriteswitches(DDukeActor* act, const TexExtInfo& ext, int lotag, int& correctdips, int& numdips); -void togglewallswitches(walltype* wwal, const TexExtInfo& ext, int lotag, int& correctdips, int& numdips); - -bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act) -{ - uint8_t switchpal; - int lotag, hitag, picnum, correctdips, numdips; - DVector2 pos; - FTextureID texid; - - if (wwal == nullptr && act == nullptr) return 0; - correctdips = 1; - numdips = 0; - - if (act) - { - lotag = act->spr.lotag; - if (lotag == 0) return 0; - hitag = act->spr.hitag; - pos = act->spr.pos.XY(); - picnum = act->spr.picnum; - switchpal = act->spr.pal; - - // custom switches that maintain themselves can immediately abort. - if (CallTriggerSwitch(act, &ps[snum])) return true; - } - else - { - lotag = wwal->lotag; - if (lotag == 0) return 0; - hitag = wwal->hitag; - pos = wwal->pos; - picnum = wwal->wallpicnum; - switchpal = wwal->pal; - } - texid = tileGetTextureID(picnum); - auto& ext = GetExtInfo(texid); - auto& swdef = switches[ext.switchindex]; - - switch (swdef.type) - { - case SwitchDef::Combo: - break; - - case SwitchDef::Access: - if (checkaccessswitch_r(snum, switchpal, act, wwal)) - return 0; - [[fallthrough]]; - - case SwitchDef::Regular: - case SwitchDef::Multi: - if (check_activator_motion(lotag)) return 0; - break; - - default: - if (isadoorwall(texid) == 0) return 0; - break; - } - - togglespriteswitches(act, ext, lotag, correctdips, numdips); - togglewallswitches(wwal, ext, lotag, correctdips, numdips); - - if (lotag == -1) - { - setnextmap(false); - return 1; - } - - DVector3 v(pos, ps[snum].GetActor()->getOffsetZ()); - switch (picnum) - { - default: - if (isadoorwall(texid) == 0) break; - [[fallthrough]]; - case RTILE_DIPSWITCH: - case RTILE_DIPSWITCHON: - case RTILE_TECHSWITCH: - case RTILE_TECHSWITCHON: - case RTILE_ALIENSWITCH: - case RTILE_ALIENSWITCHON: - if (picnum == RTILE_DIPSWITCH || picnum == RTILE_DIPSWITCHON || - picnum == RTILE_ALIENSWITCH || picnum == RTILE_ALIENSWITCHON || - picnum == RTILE_TECHSWITCH || picnum == RTILE_TECHSWITCHON) - { - if (picnum == RTILE_ALIENSWITCH || picnum == RTILE_ALIENSWITCHON) - { - if (act) - S_PlaySound3D(ALIEN_SWITCH1, act, v); - else S_PlaySound3D(ALIEN_SWITCH1, ps[snum].GetActor(), v); - } - else - { - if (act) - S_PlaySound3D(SWITCH_ON, act, v); - else S_PlaySound3D(SWITCH_ON, ps[snum].GetActor(), v); - } - if (numdips != correctdips) break; - S_PlaySound3D(END_OF_LEVEL_WARN, ps[snum].GetActor(), v); - } - goto goOn2; - case RTILE_MULTISWITCH2: - case RTILE_MULTISWITCH2_2: - case RTILE_MULTISWITCH2_3: - case RTILE_MULTISWITCH2_4: - case RTILE_IRONWHEELSWITCH: - case RTILE_BELLSWITCH: - if (!isRRRA()) break; - [[fallthrough]]; - case RTILE_DIPSWITCH2: - case RTILE_DIPSWITCH2ON: - case RTILE_DIPSWITCH3: - case RTILE_DIPSWITCH3ON: - case RTILE_MULTISWITCH: - case RTILE_MULTISWITCH_2: - case RTILE_MULTISWITCH_3: - case RTILE_MULTISWITCH_4: - case RTILE_ACCESSSWITCH: - case RTILE_ACCESSSWITCH2: - case RTILE_SLOTDOOR: - case RTILE_SLOTDOORON: - case RTILE_LIGHTSWITCH: - case RTILE_LIGHTSWITCHON: - case RTILE_SPACELIGHTSWITCH: - case RTILE_SPACELIGHTSWITCHON: - case RTILE_SPACEDOORSWITCH: - case RTILE_SPACEDOORSWITCHON: - case RTILE_FRANKENSTINESWITCH: - case RTILE_FRANKENSTINESWITCHON: - case RTILE_LIGHTSWITCH2: - case RTILE_LIGHTSWITCH2ON: - case RTILE_POWERSWITCH1: - case RTILE_POWERSWITCH1ON: - case RTILE_LOCKSWITCH1: - case RTILE_LOCKSWITCH1ON: - case RTILE_POWERSWITCH2: - case RTILE_POWERSWITCH2ON: - case RTILE_HANDSWITCH: - case RTILE_HANDSWITCHON: - case RTILE_PULLSWITCH: - case RTILE_PULLSWITCHON: - case RTILE_ALERTSWITCH: - case RTILE_ALERTSWITCHON: - case RTILE_HANDLESWITCH: - case RTILE_HANDLESWITCHON: - goOn2: - if (isRRRA()) - { - if (picnum == RTILE_IRONWHEELSWITCH) - { - act->spr.picnum = act->spr.picnum + 1; - if (hitag == 10001) - { - if (ps[snum].SeaSick == 0) - ps[snum].SeaSick = 350; - operateactivators(668, &ps[snum]); - operatemasterswitches(668); - S_PlayActorSound(328, ps[snum].GetActor()); - return 1; - } - } - else if (hitag == 10000 && swdef.type == SwitchDef::Multi) - { - tag10000specialswitch(snum, act, v); - return 1; - } - } - if (picnum == RTILE_MULTISWITCH || picnum == (RTILE_MULTISWITCH_2) || - picnum == (RTILE_MULTISWITCH_3) || picnum == (RTILE_MULTISWITCH_4)) - lotag += picnum - RTILE_MULTISWITCH; - if (isRRRA()) - { - if (picnum == RTILE_MULTISWITCH2 || picnum == (RTILE_MULTISWITCH2_2) || - picnum == (RTILE_MULTISWITCH2_3) || picnum == (RTILE_MULTISWITCH2_4)) - lotag += picnum - RTILE_MULTISWITCH2; - } - - DukeStatIterator itr(STAT_EFFECTOR); - while (auto other = itr.Next()) - { - if (other->spr.hitag == lotag) - { - switch (other->spr.lotag) - { - case 46: - case SE_47_LIGHT_SWITCH: - case SE_48_LIGHT_SWITCH: - if (!isRRRA()) break; - [[fallthrough]]; - case SE_12_LIGHT_SWITCH: - other->sector()->floorpal = 0; - other->temp_data[0]++; - if (other->temp_data[0] == 2) - other->temp_data[0]++; - - break; - case SE_24_CONVEYOR: - case SE_34: - case SE_25_PISTON: - other->temp_data[4] = !other->temp_data[4]; - if (other->temp_data[4]) - FTA(15, &ps[snum]); - else FTA(2, &ps[snum]); - break; - case SE_21_DROP_FLOOR: - FTA(2, &ps[screenpeek]); - break; - } - } - } - - operateactivators(lotag, &ps[snum]); - fi.operateforcefields(ps[snum].GetActor(), lotag); - operatemasterswitches(lotag); - - if (picnum == RTILE_DIPSWITCH || picnum == RTILE_DIPSWITCHON || - picnum == RTILE_ALIENSWITCH || picnum == RTILE_ALIENSWITCHON || - picnum == RTILE_TECHSWITCH || picnum == RTILE_TECHSWITCHON) return 1; - - if (hitag == 0 && isadoorwall(texid) == 0) - { - if (act) - S_PlaySound3D(SWITCH_ON, act, v); - else S_PlaySound3D(SWITCH_ON, ps[snum].GetActor(), v); - } - else if (hitag != 0) - { - auto flags = S_GetUserFlags(hitag); - - if (act && (flags & SF_TALK) == 0) - S_PlaySound3D(hitag, act, v); - else - S_PlayActorSound(hitag, ps[snum].GetActor()); - } - - return 1; - } - return 0; -} - //--------------------------------------------------------------------------- // // @@ -757,7 +512,7 @@ void checksectors_r(int snum) auto const neartagsprite = near.actor(); if (neartagsprite != nullptr) { - if (fi.checkhitswitch(snum, nullptr, neartagsprite)) return; + if (checkhitswitch(snum, nullptr, neartagsprite)) return; if (neartagsprite->GetClass() != RUNTIME_CLASS(DDukeActor)) { @@ -782,7 +537,7 @@ void checksectors_r(int snum) if (near.hitWall->lotag > 0 && isadoorwall(near.hitWall->walltexture())) { if (hitscanwall == near.hitWall || hitscanwall == nullptr) - fi.checkhitswitch(snum, near.hitWall, nullptr); + checkhitswitch(snum, near.hitWall, nullptr); return; } } @@ -827,7 +582,7 @@ void checksectors_r(int snum) FTA(41, p); } } - else fi.checkhitswitch(snum, near.hitWall, nullptr); + else checkhitswitch(snum, near.hitWall, nullptr); } } }