- checkhitswitch_r part 1

This commit is contained in:
Christoph Oelckers 2020-10-26 06:55:16 +01:00
parent f13a8943ab
commit 2a23dfa0a8

View file

@ -352,25 +352,29 @@ bool checkhitswitch_r(int snum, int w, int switchtype)
if (w < 0) return 0; if (w < 0) return 0;
correctdips = 1; correctdips = 1;
numdips = 0; numdips = 0;
DDukeActor* act = nullptr;
auto act = &hittype[w]; if (switchtype == SWITCH_SPRITE) // A wall sprite
if (switchtype == 1) // A wall sprite
{ {
lotag = sprite[w].lotag; if (lotag == 0) return 0; act = &hittype[w];
hitag = sprite[w].hitag; lotag = act->s.lotag;
sx = sprite[w].x; if (lotag == 0) return 0;
sy = sprite[w].y; hitag = act->s.hitag;
picnum = sprite[w].picnum; sx = act->s.x;
switchpal = sprite[w].pal; sy = act->s.y;
picnum = act->s.picnum;
switchpal = act->s.pal;
} }
else else
{ {
lotag = wall[w].lotag; if (lotag == 0) return 0; auto wal = &wall[w];
hitag = wall[w].hitag; lotag = wal->lotag;
sx = wall[w].x; if (lotag == 0) return 0;
sy = wall[w].y; hitag = wal->hitag;
picnum = wall[w].picnum; sx = wal->x;
switchpal = wall[w].pal; sy = wal->y;
picnum = wal->picnum;
switchpal = wal->pal;
} }
switch (picnum) switch (picnum)
@ -697,17 +701,17 @@ bool checkhitswitch_r(int snum, int w, int switchtype)
if (picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1) if (picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1)
{ {
if (switchtype == SWITCH_SPRITE) if (switchtype == SWITCH_SPRITE)
S_PlaySound3D(ALIEN_SWITCH1, w, &v); S_PlaySound3D(ALIEN_SWITCH1, act, &v);
else S_PlaySound3D(ALIEN_SWITCH1, ps[snum].i, &v); else S_PlaySound3D(ALIEN_SWITCH1, ps[snum].GetActor(), &v);
} }
else else
{ {
if (switchtype == SWITCH_SPRITE) if (switchtype == SWITCH_SPRITE)
S_PlaySound3D(SWITCH_ON, w, &v); S_PlaySound3D(SWITCH_ON, act, &v);
else S_PlaySound3D(SWITCH_ON, ps[snum].i, &v); else S_PlaySound3D(SWITCH_ON, ps[snum].GetActor(), &v);
} }
if (numdips != correctdips) break; if (numdips != correctdips) break;
S_PlaySound3D(END_OF_LEVEL_WARN, ps[snum].i, &v); S_PlaySound3D(END_OF_LEVEL_WARN, ps[snum].GetActor(), &v);
} }
goto goOn2; goto goOn2;
case MULTISWITCH2: case MULTISWITCH2:
@ -760,18 +764,18 @@ bool checkhitswitch_r(int snum, int w, int switchtype)
{ {
BellTime = 132; BellTime = 132;
BellSprite = w; BellSprite = w;
sprite[w].picnum++; act->s.picnum++;
} }
else if (picnum == RRTILE8464) else if (picnum == RRTILE8464)
{ {
sprite[w].picnum = sprite[w].picnum + 1; act->s.picnum = act->s.picnum + 1;
if (hitag == 10001) if (hitag == 10001)
{ {
if (ps[snum].SeaSick == 0) if (ps[snum].SeaSick == 0)
ps[snum].SeaSick = 350; ps[snum].SeaSick = 350;
operateactivators(668, ps[snum].i); operateactivators(668, ps[snum].i);
operatemasterswitches(668); operatemasterswitches(668);
S_PlayActorSound(328, ps[snum].i); S_PlayActorSound(328, ps[snum].GetActor());
return 1; return 1;
} }
} }
@ -783,7 +787,7 @@ bool checkhitswitch_r(int snum, int w, int switchtype)
picnum == (MULTISWITCH2 + 2) || picnum == (MULTISWITCH2 + 3)) picnum == (MULTISWITCH2 + 2) || picnum == (MULTISWITCH2 + 3))
{ {
int switches[3], switchcount = 0, j; int switches[3], switchcount = 0, j;
S_PlaySound3D(SWITCH_ON, w, &v); S_PlaySound3D(SWITCH_ON, act, &v);
for (j = 0; j < MAXSPRITES; j++) for (j = 0; j < MAXSPRITES; j++)
{ {
int jpn = sprite[j].picnum; int jpn = sprite[j].picnum;
@ -799,7 +803,7 @@ bool checkhitswitch_r(int snum, int w, int switchtype)
} }
if (switchcount == 3) if (switchcount == 3)
{ {
S_PlaySound3D(78, w, &v); S_PlaySound3D(78, act, &v);
for (j = 0; j < switchcount; j++) for (j = 0; j < switchcount; j++)
{ {
sprite[switches[j]].hitag = 0; sprite[switches[j]].hitag = 0;
@ -868,17 +872,17 @@ bool checkhitswitch_r(int snum, int w, int switchtype)
if (hitag == 0 && fi.isadoorwall(picnum) == 0) if (hitag == 0 && fi.isadoorwall(picnum) == 0)
{ {
if (switchtype == SWITCH_SPRITE) if (switchtype == SWITCH_SPRITE)
S_PlaySound3D(SWITCH_ON, w, &v); S_PlaySound3D(SWITCH_ON, act, &v);
else S_PlaySound3D(SWITCH_ON, ps[snum].i, &v); else S_PlaySound3D(SWITCH_ON, ps[snum].GetActor(), &v);
} }
else if (hitag != 0) else if (hitag != 0)
{ {
auto flags = S_GetUserFlags(hitag); auto flags = S_GetUserFlags(hitag);
if (switchtype == SWITCH_SPRITE && (flags & SF_TALK) == 0) if (switchtype == SWITCH_SPRITE && (flags & SF_TALK) == 0)
S_PlaySound3D(hitag, w, &v); S_PlaySound3D(hitag, act, &v);
else else
S_PlayActorSound(hitag, ps[snum].i); S_PlayActorSound(hitag, ps[snum].GetActor());
} }
return 1; return 1;