diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index c5dea9bdf..69b2ec9c6 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1010,24 +1010,6 @@ static void rrra_specialstats() tickstat(STAT_RABBITSPAWN); } -//--------------------------------------------------------------------------- -// -// this one's a hack. Can only be replaced with something better when -// the switch code has been redone. -// -//--------------------------------------------------------------------------- - -void resetswitch(int tag) -{ - DukeStatIterator it2(STAT_DEFAULT); - while (auto act2 = it2.Next()) - { - if (act2->spr.picnum == RTILE_DIPSWITCH3ON) - if (act2->spr.hitag == tag) - act2->spr.picnum = RTILE_DIPSWITCH3; - } -} - //--------------------------------------------------------------------------- // // diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index db1d81b3a..07a64084f 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -1429,7 +1429,28 @@ void moveclouds(double interpfrac) } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- +void resetswitch(int tag) +{ + DukeStatIterator it2(STAT_DEFAULT); + while (auto act2 = it2.Next()) + { + auto& ext = GetExtInfo(act2->spr.spritetexture()); + if (ext.switchindex > 0 && ext.switchphase == 1 && act2->spr.hitag == tag) + { + auto& swdef = switches[ext.switchindex]; + if (swdef.type == SwitchDef::Regular && swdef.flags & SwitchDef::resettable) + { + act2->spr.setspritetexture(swdef.states[0]); + } + } + } +} END_DUKE_NS