- handle the remaining old-style iterators.

This commit is contained in:
Christoph Oelckers 2021-10-20 22:27:16 +02:00
parent 2397bf48f2
commit 345667f945
6 changed files with 51 additions and 59 deletions

View file

@ -341,7 +341,6 @@ void FuncSpark(int, int, int, int);
void SnapBobs(short nSectorA, short nSectorB);
short FindWallSprites(short nSector);
void AddMovingSector(int nSector, int edx, int ebx, int ecx);
DExhumedActor* BuildWallSprite(int nSector);
void ProcessTrailSprite(int nSprite, int nLotag, int nHitag);
void AddSectorBob(int nSector, int nHitag, int bx);
int BuildObject(int const nSprite, int nOjectType, int nHitag);

View file

@ -173,11 +173,10 @@ void DebugOut(const char *fmt, ...)
void DoClockBeep()
{
int i;
StatIterator it(407);
while ((i = it.NextIndex()) >= 0)
ExhumedStatIterator it(407);
while (auto i = it.Next())
{
PlayFX2(StaticSound[kSound74], i);
PlayFX2(StaticSound[kSound74], i->GetSpriteIndex());
}
}

View file

@ -348,11 +348,10 @@ void AddFlash(short nSector, int x, int y, int z, int val)
}
}
int nSprite;
SectIterator it(nSector);
while ((nSprite = it.NextIndex()) >= 0)
ExhumedSectIterator it(nSector);
while (auto pActor = it.Next())
{
auto pSprite = &sprite[nSprite];
auto pSprite = &pActor->s();
if (pSprite->pal < 4)
{
short nFlash3 = GrabFlash();
@ -360,7 +359,7 @@ void AddFlash(short nSector, int x, int y, int z, int val)
{
sFlash[nFlash3].field_0 = var_20 | 4;
sFlash[nFlash3].shade = pSprite->shade;
sFlash[nFlash3].field_1 = nSprite;
sFlash[nFlash3].field_1 = pActor->GetSpriteIndex();
pSprite->pal += 7;

View file

@ -916,8 +916,6 @@ void CreatePushBlock(int nSector)
void MoveSector(short nSector, int nAngle, int *nXVel, int *nYVel)
{
int i;
if (nSector == -1) {
return;
}
@ -1042,37 +1040,38 @@ void MoveSector(short nSector, int nAngle, int *nXVel, int *nYVel)
// GREEN
if (yvect || xvect)
{
SectIterator it(nSector);
while ((i = it.NextIndex()) >= 0)
ExhumedSectIterator it(nSector);
while (auto pActor = it.Next())
{
if (sprite[i].statnum < 99)
auto sp = &pActor->s();
if (sp->statnum < 99)
{
sprite[i].x += xvect;
sprite[i].y += yvect;
sp->x += xvect;
sp->y += yvect;
}
else
{
z = sprite[i].z;
z = sp->z;
if ((nSectFlag & kSectUnderwater) || z != nZVal || sprite[i].cstat & 0x8000)
if ((nSectFlag & kSectUnderwater) || z != nZVal || sp->cstat & 0x8000)
{
x = sprite[i].x;
y = sprite[i].y;
x = sp->x;
y = sp->y;
nSectorB = nSector;
clipmove_old((int32_t*)&x, (int32_t*)&y, (int32_t*)&z, &nSectorB, -xvect, -yvect, 4 * sprite[i].clipdist, 0, 0, CLIPMASK0);
clipmove_old(&x, &y, &z, &nSectorB, -xvect, -yvect, 4 * sp->clipdist, 0, 0, CLIPMASK0);
if (nSectorB >= 0 && nSectorB < kMaxSectors && nSectorB != nSector) {
mychangespritesect(i, nSectorB);
ChangeActorSect(pActor, nSectorB);
}
}
}
}
it.Reset(nNextSector);
while ((i = it.NextIndex()) >= 0)
while (auto pActor = it.Next())
{
auto pSprite = &sprite[i];
auto pSprite = &pActor->s();
if (pSprite->statnum >= 99)
{
x = pSprite->x;
@ -1091,12 +1090,12 @@ void MoveSector(short nSector, int nAngle, int *nXVel, int *nYVel)
if (nSectorB != nSector || nFloorZ >= pSprite->z)
{
if (nSectorB >= 0 && nSectorB < kMaxSectors) {
mychangespritesect(i, nSectorB);
ChangeActorSect(pActor, nSectorB);
}
}
else
{
movesprite(i,
movesprite(pActor,
(xvect << 14) + bcos(nAngle) * pSprite->clipdist,
(yvect << 14) + bsin(nAngle) * pSprite->clipdist,
0, 0, 0, CLIPMASK0);
@ -1122,10 +1121,10 @@ void MoveSector(short nSector, int nAngle, int *nXVel, int *nYVel)
if (!(nSectFlag & kSectUnderwater))
{
SectIterator it(nSector);
while ((i = it.NextIndex()) >= 0)
ExhumedSectIterator it(nSector);
while (auto pActor = it.Next())
{
auto pSprite = &sprite[i];
auto pSprite = &pActor->s();
if (pSprite->statnum >= 99 && nZVal == pSprite->z && !(pSprite->cstat & 0x8000))
{
nSectorB = nSector;

View file

@ -643,12 +643,11 @@ int CheckSectorSprites(short nSector, int nVal)
{
int nZDiff = sector[nSector].floorz - sector[nSector].ceilingz;
int nSprite;
SectIterator it(nSector);
while ((nSprite = it.NextIndex()) >= 0)
ExhumedSectIterator it(nSector);
while (auto pActor= it.Next())
{
auto pSprite = &sprite[nSprite];
if ((pSprite->cstat & 0x101) && (nZDiff < GetSpriteHeight(nSprite)))
auto pSprite = &pActor->s();
if ((pSprite->cstat & 0x101) && (nZDiff < GetActorHeight(pActor)))
{
if (nVal != 1) {
return 1;
@ -656,26 +655,25 @@ int CheckSectorSprites(short nSector, int nVal)
b = 1;
runlist_DamageEnemy(nSprite, -1, 5);
runlist_DamageEnemy(pActor->GetSpriteIndex(), -1, 5);
if (pSprite->statnum == 100 && PlayerList[GetPlayerFromSprite(nSprite)].nHealth <= 0)
if (pSprite->statnum == 100 && PlayerList[GetPlayerFromActor(pActor)].nHealth <= 0)
{
PlayFXAtXYZ(StaticSound[kSoundJonFDie],
pSprite->x,
pSprite->y,
pSprite->z,
pSprite->sectnum | 0x4000);
pSprite->sectnum, CHANF_NONE, 0x4000);
}
}
}
}
else
{
int i;
SectIterator it(nSector);
while ((i = it.NextIndex()) >= 0)
ExhumedSectIterator it(nSector);
while (auto pActor = it.Next())
{
if (sprite[i].cstat & 0x101) {
if (pActor->s().cstat & 0x101) {
return 1;
}
}
@ -692,11 +690,10 @@ void MoveSectorSprites(int nSector, int z)
int oldz = newz - z;
int minz = std::min(newz, oldz);
int maxz = std::max(newz, oldz);
int nSprite;
SectIterator it(nSector);
while ((nSprite = it.NextIndex()) >= 0)
ExhumedSectIterator it(nSector);
while (auto pActor = it.Next())
{
auto pSprite = &sprite[nSprite];
auto pSprite = &pActor->s();
int z = pSprite->z;
if ((pSprite->statnum != 200 && z >= minz && z <= maxz) || pSprite->statnum >= 900)
{
@ -1771,11 +1768,10 @@ void KillCreatures()
{
if (v0 != 100)
{
int i;
StatIterator it(v1);
while ((i = it.NextIndex()) >= 0)
ExhumedStatIterator it(v1);
while (auto i = it.Next())
{
runlist_DamageEnemy(i, -1, 1600);
runlist_DamageEnemy(i->GetSpriteIndex(), -1, 1600);
}
}
++v0;

View file

@ -157,17 +157,17 @@ void feebtag(int x, int y, int z, int nSector, short *nSprite, int nVal2, int nV
{
if (nSector != -1)
{
int i;
SectIterator it(nSector);
while ((i = it.NextIndex()) >= 0)
ExhumedSectIterator it(nSector);
while (auto pActor = it.Next())
{
short nStat = sprite[i].statnum;
auto pSprite = &pActor->s();
short nStat = pSprite->statnum;
if (nStat >= 900 && !(sprite[i].cstat & 0x8000))
if (nStat >= 900 && !(pSprite->cstat & 0x8000))
{
uint32_t xDiff = abs(sprite[i].x - x);
uint32_t yDiff = abs(sprite[i].y - y);
int zDiff = sprite[i].z - z;
uint32_t xDiff = abs(pSprite->x - x);
uint32_t yDiff = abs(pSprite->y - y);
int zDiff = pSprite->z - z;
if (zDiff < 5120 && zDiff > -25600)
{
@ -184,7 +184,7 @@ void feebtag(int x, int y, int z, int nSector, short *nSprite, int nVal2, int nV
if (theSqrt < nVal3 && ((nStat != 950 && nStat != 949) || !(var_14 & 1)) && ((nStat != 912 && nStat != 913) || !(var_20 & 2)))
{
nVal3 = theSqrt;
*nSprite = i;
*nSprite = pActor->GetSpriteIndex();
}
}
}