- 6 simple loops in sectors_r.cpp.

This commit is contained in:
Christoph Oelckers 2020-11-02 20:33:44 +01:00
parent bb23d9131e
commit 6a8dc8217f

View file

@ -1076,27 +1076,26 @@ void checkhitwall_r(DDukeActor* spr, int dawallnum, int x, int y, int z, int atw
{ {
int sect; int sect;
int unk = 0; int unk = 0;
int jj;
int startwall, endwall; int startwall, endwall;
sect = wall[wal->nextwall].nextsector; sect = wall[wal->nextwall].nextsector;
SectIterator it(sect); DukeSectIterator it(sect);
while ((jj = it.NextIndex()) >= 0) while (auto act = it.Next())
{ {
s = &sprite[jj]; s = &act->s;
if (s->lotag == 6) if (s->lotag == 6)
{ {
//for (j = 0; j < 16; j++) RANDOMSCRAP(s, -1); This never spawned anything due to the -1. //for (j = 0; j < 16; j++) RANDOMSCRAP(s, -1); This never spawned anything due to the -1.
hittype[jj].spriteextra++; act->spriteextra++;
if (hittype[jj].spriteextra == 25) if (act->spriteextra == 25)
{ {
startwall = sector[s->sectnum].wallptr; startwall = sector[s->sectnum].wallptr;
endwall = startwall + sector[s->sectnum].wallnum; endwall = startwall + sector[s->sectnum].wallnum;
for (i = startwall; i < endwall; i++) for (i = startwall; i < endwall; i++)
sector[wall[i].nextsector].lotag = 0; sector[wall[i].nextsector].lotag = 0;
sector[s->sectnum].lotag = 0; sector[s->sectnum].lotag = 0;
S_StopSound(sprite[jj].lotag); S_StopSound(act->s.lotag);
S_PlayActorSound(400, jj); S_PlayActorSound(400, act);
deletesprite(jj); deletesprite(act);
} }
} }
} }
@ -1352,14 +1351,14 @@ void checkhitwall_r(DDukeActor* spr, int dawallnum, int x, int y, int z, int atw
darkestwall = wal->shade; darkestwall = wal->shade;
j = krand() & 1; j = krand() & 1;
StatIterator it(STAT_EFFECTOR); DukeStatIterator it(STAT_EFFECTOR);
while ((i = it.NextIndex()) >= 0) while (auto act = it.Next())
{ {
if (sprite[i].hitag == wall[dawallnum].lotag && sprite[i].lotag == 3) if (act->s.hitag == wall[dawallnum].lotag && act->s.lotag == 3)
{ {
hittype[i].temp_data[2] = j; act->temp_data[2] = j;
hittype[i].temp_data[3] = darkestwall; act->temp_data[3] = darkestwall;
hittype[i].temp_data[4] = 1; act->temp_data[4] = 1;
} }
} }
break; break;
@ -1431,7 +1430,7 @@ void checkplayerhurt_r(struct player_struct* p, const Collision &coll)
bool checkhitceiling_r(int sn) bool checkhitceiling_r(int sn)
{ {
short i, j; short j;
switch (sector[sn].ceilingpicnum) switch (sector[sn].ceilingpicnum)
{ {
@ -1491,16 +1490,17 @@ bool checkhitceiling_r(int sn)
if (!sector[sn].hitag) if (!sector[sn].hitag)
{ {
SectIterator it(sn); DukeSectIterator it(sn);
while ((i = it.NextIndex()) >= 0) while (auto act1 = it.Next())
{ {
if (sprite[i].picnum == SECTOREFFECTOR && (sprite[i].lotag == 12 || (isRRRA() && (sprite[i].lotag == 47 || sprite[i].lotag == 48)))) auto spr1 = &act1->s;
if (spr1->picnum == SECTOREFFECTOR && (spr1->lotag == 12 || (isRRRA() && (spr1->lotag == 47 || spr1->lotag == 48))))
{ {
StatIterator it(STAT_EFFECTOR); DukeStatIterator it(STAT_EFFECTOR);
while ((j = it.NextIndex()) >= 0) while (auto act2 = it.Next())
{ {
if (sprite[j].hitag == sprite[i].hitag) if (act2->s.hitag == spr1->hitag)
hittype[j].temp_data[3] = 1; act2->temp_data[3] = 1;
} }
break; break;
} }
@ -1508,13 +1508,14 @@ bool checkhitceiling_r(int sn)
} }
j = krand() & 1; j = krand() & 1;
StatIterator it(STAT_EFFECTOR); DukeStatIterator it(STAT_EFFECTOR);
while ((i = it.NextIndex()) >= 0) while (auto act1 = it.Next())
{ {
if (sprite[i].hitag == (sector[sn].hitag) && sprite[i].lotag == 3) auto spr1 = &act1->s;
if (spr1->hitag == (sector[sn].hitag) && spr1->lotag == 3)
{ {
hittype[i].temp_data[2] = j; act1->temp_data[2] = j;
hittype[i].temp_data[4] = 1; act1->temp_data[4] = 1;
} }
} }
@ -2250,12 +2251,18 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj)
deletesprite(targ); deletesprite(targ);
break; break;
case FORCESPHERE: case FORCESPHERE:
{
s->xrepeat = 0; s->xrepeat = 0;
hittype[s->owner].temp_data[0] = 32; auto Owner = targ->GetOwner();
hittype[s->owner].temp_data[1] = !hittype[s->owner].temp_data[1]; if (Owner)
hittype[s->owner].temp_data[2] ++; {
Owner->temp_data[0] = 32;
Owner->temp_data[1] = !Owner->temp_data[1];
Owner->temp_data[2] ++;
}
spawn(targ, EXPLOSION2); spawn(targ, EXPLOSION2);
break; break;
}
case TOILET: case TOILET:
s->picnum = TOILETBROKE; s->picnum = TOILETBROKE;
s->cstat |= (krand() & 1) << 2; s->cstat |= (krand() & 1) << 2;
@ -2897,14 +2904,13 @@ void dofurniture(int wl, int sect, int snum)
void tearitup(int sect) void tearitup(int sect)
{ {
int j; DukeSectIterator it(sect);
SectIterator it(sect); while (auto act = it.Next())
while ((j = it.NextIndex()) >= 0)
{ {
if (sprite[j].picnum == DESTRUCTO) if (act->s.picnum == DESTRUCTO)
{ {
hittype[j].picnum = SHOTSPARK1; act->picnum = SHOTSPARK1;
hittype[j].extra = 1; act->extra = 1;
} }
} }
} }