- operateactivators and operatemasterswitches.

This commit is contained in:
Christoph Oelckers 2020-10-23 19:35:59 +02:00
parent 7635fc9ad6
commit 4236f800f6
7 changed files with 36 additions and 45 deletions

View file

@ -107,7 +107,7 @@ static const char* cheatUnlock()
{ {
if (j & (0xffff - 16384)) if (j & (0xffff - 16384))
sector[i].lotag &= (0xffff - 16384); sector[i].lotag &= (0xffff - 16384);
operatesectors(i, ps[myconnectindex].i); operatesectors(i, ps[myconnectindex].GetActor());
} }
} }
fi.operateforcefields(ps[myconnectindex].i, -1); fi.operateforcefields(ps[myconnectindex].i, -1);

View file

@ -279,11 +279,6 @@ inline int findplayer(spritetype* act, int* x)
return findplayer(&hittype[act - sprite], x); return findplayer(&hittype[act - sprite], x);
} }
inline void operatesectors(int s, DDukeActor* i)
{
operatesectors(s, i->GetIndex());
}
inline void detonate(int i, int explosion) inline void detonate(int i, int explosion)
{ {
detonate(&hittype[i], explosion); detonate(&hittype[i], explosion);

View file

@ -151,7 +151,7 @@ int check_activator_motion(int lotag);
void operateactivators(int l, int w); void operateactivators(int l, int w);
void operateforcefields_common(int s, int low, const std::initializer_list<int>& tiles); void operateforcefields_common(int s, int low, const std::initializer_list<int>& tiles);
void operatemasterswitches(int lotag); void operatemasterswitches(int lotag);
void operatesectors(int s, int i); void operatesectors(int s, DDukeActor* i);
void hud_input(int playerNum); void hud_input(int playerNum);
int getanimationgoal(int animtype, int animindex); int getanimationgoal(int animtype, int animindex);
bool isanearoperator(int lotag); bool isanearoperator(int lotag);

View file

@ -2519,7 +2519,7 @@ int ParseState::parse(void)
break; break;
} }
if (j == -1) if (j == -1)
operatesectors(neartagsector, g_i); operatesectors(neartagsector, g_ac);
} }
} }
break; break;

View file

@ -944,9 +944,8 @@ static void handle_st28(int sn, DDukeActor* actor)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void operatesectors(int sn, int ii) void operatesectors(int sn, DDukeActor *actor)
{ {
auto actor = &hittype[ii];
int j=0, startwall, endwall; int j=0, startwall, endwall;
int i; int i;
sectortype* sptr; sectortype* sptr;
@ -1064,7 +1063,7 @@ void operatesectors(int sn, int ii)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void operateactivators(int low, int snum) void operateactivators(int low, int plnum)
{ {
int i, j, k; int i, j, k;
short * p; short * p;
@ -1086,66 +1085,65 @@ void operateactivators(int low, int snum)
} }
k = -1; k = -1;
StatIterator it(STAT_ACTIVATOR); DukeStatIterator it(STAT_ACTIVATOR);
while ((i = it.NextIndex()) >= 0) while (auto act = it.Next())
{ {
auto si = &hittype[i].s; if (act->s.lotag == low)
if (si->lotag == low)
{ {
if (si->picnum == ACTIVATORLOCKED) if (act->s.picnum == ACTIVATORLOCKED)
{ {
sector[si->sectnum].lotag ^= 16384; sector[act->s.sectnum].lotag ^= 16384;
if (snum >= 0) if (plnum >= 0)
{ {
if (sector[si->sectnum].lotag & 16384) if (sector[act->s.sectnum].lotag & 16384)
FTA(4, &ps[snum]); FTA(4, &ps[plnum]);
else FTA(8, &ps[snum]); else FTA(8, &ps[plnum]);
} }
} }
else else
{ {
switch (si->hitag) switch (act->s.hitag)
{ {
case 0: case 0:
break; break;
case 1: case 1:
if (sector[si->sectnum].floorz != sector[si->sectnum].ceilingz) if (sector[act->s.sectnum].floorz != sector[act->s.sectnum].ceilingz)
{ {
continue; continue;
} }
break; break;
case 2: case 2:
if (sector[si->sectnum].floorz == sector[si->sectnum].ceilingz) if (sector[act->s.sectnum].floorz == sector[act->s.sectnum].ceilingz)
{ {
continue; continue;
} }
break; break;
} }
if (sector[si->sectnum].lotag < 3) if (sector[act->s.sectnum].lotag < 3)
{ {
SectIterator it(si->sectnum); DukeSectIterator it(act->s.sectnum);
while ((j = it.NextIndex()) >= 0) while (auto a2 = it.Next())
{ {
if (sprite[j].statnum == 3) switch (sprite[j].lotag) if (a2->s.statnum == 3) switch (a2->s.lotag)
{ {
case SE_18_INCREMENTAL_SECTOR_RISE_FALL: case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
if (isRRRA()) break; if (isRRRA()) break;
case SE_36_PROJ_SHOOTER: case SE_36_PROJ_SHOOTER:
case SE_31_FLOOR_RISE_FALL: case SE_31_FLOOR_RISE_FALL:
case SE_32_CEILING_RISE_FALL: case SE_32_CEILING_RISE_FALL:
hittype[j].temp_data[0] = 1 - hittype[j].temp_data[0]; a2->temp_data[0] = 1 - a2->temp_data[0];
callsound(si->sectnum, j); callsound(act->s.sectnum, a2);
break; break;
} }
} }
} }
if (k == -1 && (sector[si->sectnum].lotag & 0xff) == 22) if (k == -1 && (sector[act->s.sectnum].lotag & 0xff) == 22)
k = callsound(si->sectnum, i); k = callsound(act->s.sectnum, act);
operatesectors(si->sectnum, i); operatesectors(act->s.sectnum, act);
} }
} }
} }
@ -1161,13 +1159,11 @@ void operateactivators(int low, int snum)
void operatemasterswitches(int low) void operatemasterswitches(int low)
{ {
int i; DukeStatIterator it(STAT_STANDABLE);
while (auto act2 = it.Next())
StatIterator it(STAT_STANDABLE);
while ((i = it.NextIndex()) >= 0)
{ {
if (sprite[i].picnum == MASTERSWITCH && sprite[i].lotag == low && sprite[i].yvel == 0) if (act2->s.picnum == MASTERSWITCH && act2->s.lotag == low && act2->s.yvel == 0)
sprite[i].yvel = 1; act2->s.yvel = 1;
} }
} }

View file

@ -630,7 +630,7 @@ void activatebysector_d(int sect, int j)
} }
if (didit == 0) if (didit == 0)
operatesectors(sect, j); operatesectors(sect, &hittype[j]);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1775,7 +1775,7 @@ void checksectors_d(int snum)
if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH)
return; return;
} }
operatesectors(neartagsector, p->i); operatesectors(neartagsector, p->GetActor());
} }
else if ((sector[sprite[p->i].sectnum].lotag & 16384) == 0) else if ((sector[sprite[p->i].sectnum].lotag & 16384) == 0)
{ {
@ -1786,7 +1786,7 @@ void checksectors_d(int snum)
{ {
if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) return; if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) return;
} }
operatesectors(sprite[p->i].sectnum, p->i); operatesectors(sprite[p->i].sectnum, p->GetActor());
} }
else fi.checkhitswitch(snum, neartagwall, 0); else fi.checkhitswitch(snum, neartagwall, 0);
} }

View file

@ -906,7 +906,7 @@ void activatebysector_r(int sect, int j)
} }
if (sector[sect].lotag != 22) if (sector[sect].lotag != 22)
operatesectors(sect, j); operatesectors(sect, &hittype[j]);
} }
@ -2723,7 +2723,7 @@ void checksectors_r(int snum)
return; return;
} }
if (haskey(neartagsector, snum)) if (haskey(neartagsector, snum))
operatesectors(neartagsector, p->i); operatesectors(neartagsector, p->GetActor());
else else
{ {
if (hittype[neartagsprite].spriteextra > 3) if (hittype[neartagsprite].spriteextra > 3)
@ -2743,7 +2743,7 @@ void checksectors_r(int snum)
if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) return; if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) return;
} }
if (haskey(neartagsector, snum)) if (haskey(neartagsector, snum))
operatesectors(sprite[p->i].sectnum, p->i); operatesectors(sprite[p->i].sectnum, p->GetActor());
else else
{ {
if (hittype[neartagsprite].spriteextra > 3) if (hittype[neartagsprite].spriteextra > 3)