- checkhitswitch_d

This commit is contained in:
Christoph Oelckers 2021-11-17 23:01:27 +01:00
parent 8cf3963901
commit 7268e779a7

View file

@ -225,8 +225,9 @@ void operateforcefields_d(DDukeActor* act, int low)
bool checkhitswitch_d(int snum, int ww, DDukeActor *act)
{
uint8_t switchpal;
int i, x, lotag, hitag, picnum, correctdips, numdips;
int lotag, hitag, picnum, correctdips, numdips;
int sx, sy;
walltype* wwal = nullptr;
if (ww < 0 && act == nullptr) return 0;
correctdips = 1;
@ -244,14 +245,14 @@ bool checkhitswitch_d(int snum, int ww, DDukeActor *act)
}
else
{
auto wal = &wall[ww];
lotag = wal->lotag;
wwal = &wall[ww];
lotag = wwal->lotag;
if (lotag == 0) return 0;
hitag = wal->hitag;
sx = wal->x;
sy = wal->y;
picnum = wal->picnum;
switchpal = wal->pal;
hitag = wwal->hitag;
sx = wwal->x;
sy = wwal->y;
picnum = wwal->picnum;
switchpal = wwal->pal;
}
switch (picnum)
@ -415,33 +416,32 @@ bool checkhitswitch_d(int snum, int ww, DDukeActor *act)
}
}
for (i = 0; i < numwalls; i++)
for (auto& wal : walls())
{
x = i;
if (lotag == wall[x].lotag)
switch (wall[x].picnum)
if (lotag == wal.lotag)
switch (wal.picnum)
{
case DIPSWITCH:
case TECHSWITCH:
case ALIENSWITCH:
if (!act && i == ww) wall[x].picnum++;
else if (wall[x].hitag == 0) correctdips++;
if (!act && &wal == wwal) wal.picnum++;
else if (wal.hitag == 0) correctdips++;
numdips++;
break;
case DIPSWITCH + 1:
case TECHSWITCH + 1:
case ALIENSWITCH + 1:
if (!act && i == ww) wall[x].picnum--;
else if (wall[x].hitag == 1) correctdips++;
if (!act && &wal == wwal) wal.picnum--;
else if (wal.hitag == 1) correctdips++;
numdips++;
break;
case MULTISWITCH:
case MULTISWITCH + 1:
case MULTISWITCH + 2:
case MULTISWITCH + 3:
wall[x].picnum++;
if (wall[x].picnum > (MULTISWITCH + 3))
wall[x].picnum = MULTISWITCH;
wal.picnum++;
if (wal.picnum > (MULTISWITCH + 3))
wal.picnum = MULTISWITCH;
break;
case ACCESSSWITCH:
case ACCESSSWITCH2:
@ -457,7 +457,7 @@ bool checkhitswitch_d(int snum, int ww, DDukeActor *act)
case HANDSWITCH:
case DIPSWITCH2:
case DIPSWITCH3:
wall[x].picnum++;
wal.picnum++;
break;
case HANDSWITCH + 1:
case PULLSWITCH + 1:
@ -471,7 +471,7 @@ bool checkhitswitch_d(int snum, int ww, DDukeActor *act)
case SPACEDOORSWITCH + 1:
case DIPSWITCH2 + 1:
case DIPSWITCH3 + 1:
wall[x].picnum--;
wal.picnum--;
break;
}
}