- the remaining StatIterators.

This commit is contained in:
Christoph Oelckers 2021-11-13 20:38:08 +01:00
parent 2a72a5860e
commit 847877d6de
7 changed files with 70 additions and 45 deletions

View file

@ -290,9 +290,11 @@ static void facedragon(PLAYER& plr, short i) {
void dragonProcess(PLAYER& plr)
{
for (short i = headspritestat[ATTACK2], nextsprite; i >= 0; i = nextsprite) {
nextsprite = nextspritestat[i];
SPRITE& spr = sprite[i];
WHStatIterator it(ATTACK2);
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
switch (spr.detail) {
case DRAGON:

View file

@ -492,9 +492,12 @@ static void goblinWar(PLAYER& plr, short i) {
void goblinWarProcess(PLAYER& plr)
{
for (short i = headspritestat[WAR], nextsprite; i >= 0; i = nextsprite) {
nextsprite = nextspritestat[i];
SPRITE& spr = sprite[i];
WHStatIterator it(WAR);
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
switch (spr.detail) {
case GOBLINTYPE:
goblinWar(plr, i);

View file

@ -507,11 +507,12 @@ static void diegonzo(PLAYER& plr, short i) {
void gonzoProcess(PLAYER& plr)
{
short nextsprite;
for (short i = headspritestat[LAND]; i >= 0; i = nextsprite) {
nextsprite = nextspritestat[i];
WHStatIterator it(LAND);
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
SPRITE& spr = sprite[i];
spr.lotag -= TICSPERFRAME;
if (spr.lotag < 0) {
spr.lotag = 12;
@ -537,10 +538,12 @@ void gonzoProcess(PLAYER& plr)
}
short movestat;
for (short i = headspritestat[AMBUSH]; i >= 0; i = nextsprite) {
nextsprite = nextspritestat[i];
it.Reset(AMBUSH);
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
SPRITE& spr = sprite[i];
switch (spr.extra) {
case 1: // forward
spr.zvel += TICSPERFRAME << 3;
@ -602,16 +605,18 @@ void gonzoProcess(PLAYER& plr)
static short searchpatrol(SPRITE& spr) {
int mindist = 0x7fffffff;
short target = -1;
short j = headspritestat[APATROLPOINT];
while (j != -1) {
short nextj = nextspritestat[j];
SPRITE& tspr = sprite[j];
WHStatIterator it(ATTACK2);
while (auto actor = it.Next())
{
SPRITE& tspr = actor->s();
int j = actor->GetSpriteIndex();
int dist = abs(tspr.x - spr.x) + abs(tspr.y - spr.y);
if (dist < mindist) {
mindist = dist;
target = j;
}
j = nextj;
}
return target;

View file

@ -223,13 +223,15 @@ static void castjudy(PLAYER& plr, short i) {
else {
if (krand() % 100 > 40) {
// raise the dead
short j = headspritestat[DEAD];
while (j >= 0) {
short nextj = nextspritestat[j];
sprite[j].lotag = (short)((krand() % 120) + 120);
WHStatIterator it(DEAD);
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int j = actor->GetSpriteIndex();
spr.lotag = (short)((krand() % 120) + 120);
kills--;
newstatus(j, RESURECT);
j = nextj;
}
}
else {
@ -339,10 +341,12 @@ static void diejudy(PLAYER& plr, short i) {
void judyOperate(PLAYER& plr)
{
short nextsprite;
for (short i = headspritestat[WITCHSIT]; i >= 0; i = nextsprite) {
nextsprite = nextspritestat[i];
auto& spri = sprite[i];
WHStatIterator it(WITCHSIT);
while (auto actor = it.Next())
{
SPRITE& spri = actor->s();
int i = actor->GetSpriteIndex();
spri.ang = (short)(getangle(plr.x - spri.x, plr.y - spri.y) & 2047);
if (cansee(plr.x, plr.y, plr.z, plr.sector, spri.x, spri.y,

View file

@ -239,9 +239,11 @@ static void nukedwillow(PLAYER& plr, short i) {
void willowProcess(PLAYER& plr)
{
for (short i = headspritestat[DRAIN], nextsprite; i >= 0; i = nextsprite) {
nextsprite = nextspritestat[i];
SPRITE& spr = sprite[i];
WHStatIterator it(DRAIN);
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
switch (spr.detail) {
case WILLOWTYPE:

View file

@ -883,10 +883,13 @@ void weaponsprocess(int snum) {
}
void madenoise(PLAYER& plr, int val, int x, int y, int z) {
short nextsprite;
for (short i = headspritestat[FACE]; i >= 0; i = nextsprite) {
nextsprite = nextspritestat[i];
if ((abs(x - sprite[i].x) + abs(y - sprite[i].y) < (val * 4096)))
WHStatIterator it(FACE);
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
if ((abs(x - spr.x) + abs(y - spr.y) < (val * 4096)))
newstatus(i, FINDME);
}
}

View file

@ -879,7 +879,7 @@ void operatesector(PLAYER& plr, int s) {
void animatetags(int nPlayer) {
int endwall, good, j, k, oldang, startwall;
short i, nexti;
short i;
int dasector;
PLAYER& plr = player[nPlayer];
@ -890,12 +890,15 @@ void animatetags(int nPlayer) {
if (sector[i].hitag == sector[plr.sector].hitag)
if (sector[i].lotag != 2)
operatesector(plr, i);
i = headspritestat[0];
while (i != -1) {
nexti = nextspritestat[i];
if (sprite[i].hitag == sector[plr.sector].hitag)
WHStatIterator it(0);
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
if (spr.hitag == sector[plr.sector].hitag)
operatesprite(plr, i);
i = nexti;
}
sector[plr.sector].lotag = 0;
@ -906,12 +909,15 @@ void animatetags(int nPlayer) {
if (sector[i].hitag == sector[plr.sector].hitag)
if (sector[i].lotag != 2)
operatesector(plr, i);
i = headspritestat[0];
while (i != -1) {
nexti = nextspritestat[i];
if (sprite[i].hitag == sector[plr.sector].hitag)
WHStatIterator it(0);
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
int i = actor->GetSpriteIndex();
if (spr.hitag == sector[plr.sector].hitag)
operatesprite(plr, i);
i = nexti;
}
}
}