- replaced several sector iterators in Duke code.

This commit is contained in:
Christoph Oelckers 2020-10-14 21:16:54 +02:00
parent 5c9b261823
commit 758fab1804
8 changed files with 58 additions and 69 deletions

View file

@ -105,17 +105,14 @@ short checkpins(short sect)
short i, pin;
int x, y;
short pins[10];
short nexti, tag;
short tag;
pin = 0;
for(i=0;i<10;i++) pins[i] = 0;
i = headspritesect[sect];
while (i >= 0)
SectIterator it(sect);
while ((i = it.NextIndex()) >= 0)
{
nexti = nextspritesect[i];
if (sprite[i].picnum == RRTILE3440)
{
pin++;
@ -125,8 +122,6 @@ short checkpins(short sect)
{
tag = sprite[i].hitag;
}
i = nexti;
}
if (tag)
@ -190,20 +185,17 @@ short checkpins(short sect)
void resetpins(short sect)
{
short i, j, nexti, tag;
short i, j, tag;
int x, y;
i = headspritesect[sect];
while (i >= 0)
SectIterator it(sect);
while ((i = it.NextIndex()) >= 0)
{
nexti = headspritesect[i];
if (sprite[i].picnum == 3440)
deletesprite(i);
i = nexti;
}
i = headspritesect[sect];
while (i >= 0)
it.Reset(sect);
while ((i = it.NextIndex()) >= 0)
{
nexti = nextspritesect[i];
if (sprite[i].picnum == 283)
{
j = fi.spawn(i,3440);
@ -220,7 +212,6 @@ void resetpins(short sect)
}
if (sprite[i].picnum == 280)
tag = sprite[i].hitag;
i = nexti;
}
if (tag)
{

View file

@ -417,7 +417,8 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang)
for (i = 0; i < numsectors; i++)
{
if (!gFullMap || !show2dsector[i]) continue;
for (j = headspritesect[i]; j >= 0; j = nextspritesect[j])
SectIterator it(i);
while ((j = it.NextIndex()) >= 0)
{
spr = &sprite[j];

View file

@ -2507,18 +2507,17 @@ int ParseState::parse(void)
if( neartagsector >= 0 && isanearoperator(sector[neartagsector].lotag) )
if( (sector[neartagsector].lotag&0xff) == ST_23_SWINGING_DOOR || sector[neartagsector].floorz == sector[neartagsector].ceilingz )
if( (sector[neartagsector].lotag&16384) == 0 )
if( (sector[neartagsector].lotag&32768) == 0 )
{
j = headspritesect[neartagsector];
while(j >= 0)
if ((sector[neartagsector].lotag & 32768) == 0)
{
if(sprite[j].picnum == ACTIVATOR)
break;
j = nextspritesect[j];
SectIterator it(neartagsector);
while ((j = it.NextIndex()) >= 0)
{
if (sprite[j].picnum == ACTIVATOR)
break;
}
if (j == -1)
operatesectors(neartagsector, g_i);
}
if(j == -1)
operatesectors(neartagsector,g_i);
}
}
break;
case concmd_ifinspace:

View file

@ -533,11 +533,14 @@ void footprints(int snum)
if ((sector[p->cursectnum].floorstat & 2) != 2)
{
int j;
for (j = headspritesect[psect]; j >= 0; j = nextspritesect[j])
SectIterator it(psect);
while ((j = it.NextIndex()) >= 0)
{
if (sprite[j].picnum == TILE_FOOTPRINTS || sprite[j].picnum == TILE_FOOTPRINTS2 || sprite[j].picnum == TILE_FOOTPRINTS3 || sprite[j].picnum == TILE_FOOTPRINTS4)
if (abs(sprite[j].x - p->posx) < 384)
if (abs(sprite[j].y - p->posy) < 384)
break;
}
if (j < 0)
{
p->footprintcount--;

View file

@ -328,8 +328,8 @@ void shoot_d(int i, int atwith)
{
if (wall[hitwall].nextsector >= 0)
{
k = headspritesect[wall[hitwall].nextsector];
while (k >= 0)
SectIterator it(wall[hitwall].nextsector);
while ((k = it.NextIndex()) >= 0)
{
if (sprite[k].statnum == 3 && sprite[k].lotag == 13)
return;
@ -587,8 +587,8 @@ void shoot_d(int i, int atwith)
{
if (wall[hitwall].nextsector >= 0)
{
l = headspritesect[wall[hitwall].nextsector];
while (l >= 0)
SectIterator it(wall[hitwall].nextsector);
while ((l = it.NextIndex()) >= 0)
{
if (sprite[l].statnum == 3 && sprite[l].lotag == 13)
goto SKIPBULLETHOLE;
@ -1953,13 +1953,14 @@ int operateTripbomb(int snum)
if (wall[hw].overpicnum == BIGFORCE)
return 0;
int j = headspritesect[sect];
while (j >= 0)
int j;
SectIterator it(sect);
while ((j = it.NextIndex()) >= 0)
{
if (sprite[j].picnum == TRIPBOMB &&
abs(sprite[j].z - sz) < (12 << 8) && ((sprite[j].x - sx) * (sprite[j].x - sx) + (sprite[j].y - sy) * (sprite[j].y - sy)) < (290 * 290))
auto sj = &sprite[j];
if (sj->picnum == TRIPBOMB &&
abs(sj->z - sz) < (12 << 8) && ((sj->x - sx) * (sj->x - sx) + (sj->y - sy) * (sj->y - sy)) < (290 * 290))
return 0;
j = nextspritesect[j];
}
if (j == -1 && hw >= 0 && (wall[hw].cstat & 16) == 0)

View file

@ -217,8 +217,8 @@ void shoot_r(int i, int atwith)
{
if (wall[hitwall].nextsector >= 0)
{
k = headspritesect[wall[hitwall].nextsector];
while (k >= 0)
SectIterator it(wall[hitwall].nextsector);
while ((k = it.NextIndex()) >= 0)
{
if (sprite[k].statnum == 3 && sprite[k].lotag == 13)
return;
@ -500,8 +500,8 @@ void shoot_r(int i, int atwith)
{
if (wall[hitwall].nextsector >= 0)
{
l = headspritesect[wall[hitwall].nextsector];
while (l >= 0)
SectIterator it(wall[hitwall].nextsector);
while ((l = it.NextIndex()) >= 0)
{
if (sprite[l].statnum == 3 && sprite[l].lotag == 13)
goto SKIPBULLETHOLE;
@ -3492,15 +3492,12 @@ void processinput_r(int snum)
if (psectlotag == 867)
{
short sj, nextsj;
sj = headspritesect[psect];
while (sj >= 0)
SectIterator it(psect);
while ((j = it.NextIndex()) >= 0)
{
nextsj = nextspritesect[sj];
if (sprite[sj].picnum == RRTILE380)
if (sprite[sj].z - (8 << 8) < p->posz)
if (sprite[j].picnum == RRTILE380)
if (sprite[j].z - (8 << 8) < p->posz)
psectlotag = 2;
sj = nextsj;
}
}
else if (psectlotag == 7777)

View file

@ -252,12 +252,11 @@ void cacheit_d(void)
}
}
j = headspritesect[i];
while (j >= 0)
SectIterator it(i);
while ((j = it.NextIndex()) >= 0)
{
if (sprite[j].xrepeat != 0 && sprite[j].yrepeat != 0 && (sprite[j].cstat & 32768) == 0)
cachespritenum(j);
j = nextspritesect[j];
}
precacheMarkedTiles();

View file

@ -427,12 +427,11 @@ void cacheit_r(void)
}
}
j = headspritesect[i];
while(j >= 0)
SectIterator it(i);
while ((j = it.NextIndex()) >= 0)
{
if(sprite[j].xrepeat != 0 && sprite[j].yrepeat != 0 && (sprite[j].cstat&32768) == 0)
cachespritenum(j);
j = nextspritesect[j];
}
precacheMarkedTiles();
}
@ -495,10 +494,10 @@ void prelevel_r(int g)
switch (sector[i].lotag)
{
case 41:
k = headspritesect[i];
while (k != -1)
{
SectIterator it(i);
while ((k = it.NextIndex()) >= 0)
{
nexti = nextspritesect[k];
if (sprite[k].picnum == RRTILE11)
{
dist = sprite[k].lotag << 4;
@ -510,7 +509,6 @@ void prelevel_r(int g)
sound = sprite[k].lotag;
deletesprite(k);
}
k = nexti;
}
for (j = 0; j < numsectors; j++)
{
@ -520,22 +518,23 @@ void prelevel_r(int g)
}
}
break;
}
case 42:
{
short ii;
int childsectnum = -1;
k = headspritesect[i];
while (k != -1)
SectIterator it(i);
while ((k = it.NextIndex()) >= 0)
{
nexti = nextspritesect[k];
if (sprite[k].picnum == RRTILE64)
auto sj = &sprite[k];
if (sj->picnum == RRTILE64)
{
dist = sprite[k].lotag << 4;
speed = sprite[k].hitag;
dist = sj->lotag << 4;
speed = sj->hitag;
for (ii = 0; ii < MAXSPRITES; ii++)
{
if (sprite[ii].picnum == RRTILE66)
if (sprite[ii].lotag == sprite[k].sectnum)
if (sprite[ii].lotag == sj->sectnum)
{
childsectnum = sprite[ii].sectnum;
deletesprite(ii);
@ -543,12 +542,11 @@ void prelevel_r(int g)
}
deletesprite(k);
}
if (sprite[k].picnum == RRTILE65)
if (sj->picnum == RRTILE65)
{
sound = sprite[k].lotag;
sound = sj->lotag;
deletesprite(k);
}
k = nexti;
}
addminecart(dist, speed, i, sector[i].hitag, sound, childsectnum);
break;