- use switch types to cut doen the first switch/case block in checkhitswitch

This commit is contained in:
Christoph Oelckers 2022-12-11 00:51:39 +01:00
parent 808fb3c433
commit 564e9d2905
2 changed files with 21 additions and 93 deletions

View file

@ -237,53 +237,24 @@ bool checkhitswitch_d(int snum, walltype* wwal, DDukeActor *act)
switchpal = wwal->pal; switchpal = wwal->pal;
} }
texid = tileGetTextureID(picnum); texid = tileGetTextureID(picnum);
auto& ext = GetExtInfo(texid);
auto& swdef = switches[ext.switchindex];
switch (picnum) switch (swdef.type)
{ {
case DTILE_DIPSWITCH: case SwitchDef::Combo:
case DTILE_DIPSWITCHON:
case DTILE_TECHSWITCH:
case DTILE_TECHSWITCHON:
case DTILE_ALIENSWITCH:
case DTILE_ALIENSWITCHON:
break; break;
case DTILE_ACCESSSWITCH:
case DTILE_ACCESSSWITCH2: case SwitchDef::Access:
if (checkaccessswitch_d(snum, switchpal, act, wwal)) if (checkaccessswitch_d(snum, switchpal, act, wwal))
return 0; return 0;
[[fallthrough]]; [[fallthrough]];
case DTILE_DIPSWITCH2:
case DTILE_DIPSWITCH2ON: case SwitchDef::Regular:
case DTILE_DIPSWITCH3: case SwitchDef::Multi:
case DTILE_DIPSWITCH3ON:
case DTILE_MULTISWITCH:
case DTILE_MULTISWITCH_2:
case DTILE_MULTISWITCH_3:
case DTILE_MULTISWITCH_4:
case DTILE_PULLSWITCH:
case DTILE_PULLSWITCHON:
case DTILE_HANDSWITCH:
case DTILE_HANDSWITCHON:
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:
if (check_activator_motion(lotag)) return 0; if (check_activator_motion(lotag)) return 0;
break; break;
default: default:
if (isadoorwall(texid) == 0) return 0; if (isadoorwall(texid) == 0) return 0;
break; break;

View file

@ -207,73 +207,30 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act)
switchpal = wwal->pal; switchpal = wwal->pal;
} }
texid = tileGetTextureID(picnum); texid = tileGetTextureID(picnum);
auto& ext = GetExtInfo(texid);
auto& swdef = switches[ext.switchindex];
switch (picnum) switch (swdef.type)
{ {
case RTILE_DIPSWITCH: case SwitchDef::Combo:
case RTILE_DIPSWITCHON:
case RTILE_TECHSWITCH:
case RTILE_TECHSWITCHON:
case RTILE_ALIENSWITCH:
case RTILE_ALIENSWITCHON:
break; break;
case RTILE_ACCESSSWITCH:
case RTILE_ACCESSSWITCH2: case SwitchDef::Access:
if (checkaccessswitch_r(snum, switchpal, act, wwal)) if (checkaccessswitch_r(snum, switchpal, act, wwal))
return 0; return 0;
goto goOn1;
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]]; [[fallthrough]];
case RTILE_DIPSWITCH2:
case RTILE_DIPSWITCH2ON: case SwitchDef::Regular:
case RTILE_DIPSWITCH3: case SwitchDef::Multi:
case RTILE_DIPSWITCH3ON:
case RTILE_MULTISWITCH:
case RTILE_MULTISWITCH_2:
case RTILE_MULTISWITCH_3:
case RTILE_MULTISWITCH_4:
case RTILE_PULLSWITCH:
case RTILE_PULLSWITCHON:
case RTILE_HANDSWITCH:
case RTILE_HANDSWITCHON:
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_CONTESTSWITCH:
case RTILE_ALERTSWITCH:
case RTILE_ALERTSWITCHON:
case RTILE_HANDLESWITCH:
case RTILE_HANDLESWITCHON:
goOn1:
if (check_activator_motion(lotag)) return 0; if (check_activator_motion(lotag)) return 0;
break; break;
default: default:
if (isadoorwall(texid) == 0) return 0; if (isadoorwall(texid) == 0) return 0;
break; break;
} }
DukeStatIterator it(STAT_DEFAULT); DukeStatIterator it(STAT_DEFAULT);
while (auto other = it.Next()) while (auto other = it.Next())
{ {