From 13093aef56f116c1fc01591624852c44160d6ed9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Oct 2020 23:06:08 +0200 Subject: [PATCH] - a few quick ones, mostly simple search & replace. --- source/games/duke/src/actors.cpp | 9 +++--- source/games/duke/src/actors_d.cpp | 45 +++++++++++++------------- source/games/duke/src/player_r.cpp | 51 ++++++++++++++++-------------- 3 files changed, 55 insertions(+), 50 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index f0218f0ce..9829f004f 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -1837,8 +1837,9 @@ void reactor(int i, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BUR if (t[4] == 1) { - int j = headspritesect[sect]; - while (j >= 0) + SectIterator it(sect); + int j; + while ((j = it.NextIndex()) >= 0) { auto sprj = &sprite[j]; if (sprj->picnum == SECTOREFFECTOR) @@ -1861,9 +1862,7 @@ void reactor(int i, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BUR { sprj->cstat = (short)32768; } - j = nextspritesect[j]; - } - return; + } return; } if (t[1] >= 20) diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 173d03857..9faab1bd8 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -3699,11 +3699,12 @@ void moveeffectors_d(void) //STATNUM 3 while (j >= 0) { nextj = nextspritesect[j]; - if (sprite[j].zvel >= 0) - switch (sprite[j].statnum) + auto sprj = &sprite[j]; + if (sprj->zvel >= 0) + switch (sprj->statnum) { case 5: - switch (sprite[j].picnum) + switch (sprj->picnum) { case BLOODPOOL: case PUKE: @@ -3716,7 +3717,7 @@ void moveeffectors_d(void) //STATNUM 3 case BLOODSPLAT2: case BLOODSPLAT3: case BLOODSPLAT4: - sprite[j].xrepeat = sprite[j].yrepeat = 0; + sprj->xrepeat = sprj->yrepeat = 0; j = nextj; continue; case LASERLINE: @@ -3724,36 +3725,36 @@ void moveeffectors_d(void) //STATNUM 3 continue; } case 6: - if (sprite[j].picnum == TRIPBOMB) break; + if (sprj->picnum == TRIPBOMB) break; case 1: case 0: if ( - sprite[j].picnum == BOLT1 || - sprite[j].picnum == BOLT1 + 1 || - sprite[j].picnum == BOLT1 + 2 || - sprite[j].picnum == BOLT1 + 3 || - sprite[j].picnum == SIDEBOLT1 || - sprite[j].picnum == SIDEBOLT1 + 1 || - sprite[j].picnum == SIDEBOLT1 + 2 || - sprite[j].picnum == SIDEBOLT1 + 3 || + sprj->picnum == BOLT1 || + sprj->picnum == BOLT1 + 1 || + sprj->picnum == BOLT1 + 2 || + sprj->picnum == BOLT1 + 3 || + sprj->picnum == SIDEBOLT1 || + sprj->picnum == SIDEBOLT1 + 1 || + sprj->picnum == SIDEBOLT1 + 2 || + sprj->picnum == SIDEBOLT1 + 3 || wallswitchcheck(j) ) break; - if (!(sprite[j].picnum >= CRANE && sprite[j].picnum <= (CRANE + 3))) + if (!(sprj->picnum >= CRANE && sprj->picnum <= (CRANE + 3))) { - if (sprite[j].z > (hittype[j].floorz - (16 << 8))) + if (sprj->z > (hittype[j].floorz - (16 << 8))) { - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; + hittype[j].bposx = sprj->x; + hittype[j].bposy = sprj->y; - sprite[j].x += x >> 2; - sprite[j].y += l >> 2; + sprj->x += x >> 2; + sprj->y += l >> 2; - setsprite(j, sprite[j].x, sprite[j].y, sprite[j].z); + setsprite(j, sprj->x, sprj->y, sprj->z); - if (sector[sprite[j].sectnum].floorstat & 2) - if (sprite[j].statnum == 2) + if (sector[sprj->sectnum].floorstat & 2) + if (sprj->statnum == 2) makeitfall(j); } } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 210fdcea0..504d8b985 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -2573,40 +2573,42 @@ void onBoatMove(int snum, int psect, int j) void onMotorcycleHit(int snum, int var60) { auto p = &ps[snum]; - - if (badguy(&sprite[var60]) || sprite[var60].picnum == APLAYER) + auto s = &sprite[var60]; + auto ht = &hittype[var60]; + if (badguy(s) || s->picnum == APLAYER) { - if (sprite[var60].picnum != APLAYER) + if (s->picnum != APLAYER) { if (numplayers == 1) { fi.movesprite(var60, sintable[int(p->TiltStatus * 20 + p->angle.ang.asbuild() + 512) & 2047] >> 8, - sintable[int(p->TiltStatus * 20 + p->angle.ang.asbuild()) & 2047] >> 8, sprite[var60].zvel, CLIPMASK0); + sintable[int(p->TiltStatus * 20 + p->angle.ang.asbuild()) & 2047] >> 8, s->zvel, CLIPMASK0); } } else - hittype[var60].owner = p->i; - hittype[var60].picnum = MOTOHIT; - hittype[var60].extra = p->MotoSpeed >> 1; + ht->owner = p->i; + ht->picnum = MOTOHIT; + ht->extra = p->MotoSpeed >> 1; p->MotoSpeed -= p->MotoSpeed >> 2; p->TurbCount = 6; } - else if ((sprite[var60].picnum == RRTILE2431 || sprite[var60].picnum == RRTILE2443 || sprite[var60].picnum == RRTILE2451 || sprite[var60].picnum == RRTILE2455) - && sprite[var60].picnum != ACTIVATORLOCKED && p->MotoSpeed > 45) + else if ((s->picnum == RRTILE2431 || s->picnum == RRTILE2443 || s->picnum == RRTILE2451 || s->picnum == RRTILE2455) + && s->picnum != ACTIVATORLOCKED && p->MotoSpeed > 45) { S_PlayActorSound(SQUISHED, var60); - if (sprite[var60].picnum == RRTILE2431 || sprite[var60].picnum == RRTILE2451) + if (s->picnum == RRTILE2431 || s->picnum == RRTILE2451) { - if (sprite[var60].lotag != 0) + if (s->lotag != 0) { for (int j = 0; j < MAXSPRITES; j++) { - if ((sprite[j].picnum == RRTILE2431 || sprite[j].picnum == RRTILE2451) && sprite[j].pal == 4) + auto sprj = &sprite[j]; + if ((sprj->picnum == RRTILE2431 || sprj->picnum == RRTILE2451) && sprj->pal == 4) { - if (sprite[var60].lotag == sprite[j].lotag) + if (s->lotag == sprj->lotag) { - sprite[j].xrepeat = 0; - sprite[j].yrepeat = 0; + sprj->xrepeat = 0; + sprj->yrepeat = 0; } } } @@ -2617,8 +2619,8 @@ void onMotorcycleHit(int snum, int var60) else fi.guts(&sprite[var60], RRTILE2465, 3, myconnectindex); fi.guts(&sprite[var60], RRTILE2465, 3, myconnectindex); - sprite[var60].xrepeat = 0; - sprite[var60].yrepeat = 0; + s->xrepeat = 0; + s->yrepeat = 0; } } @@ -2631,20 +2633,23 @@ void onMotorcycleHit(int snum, int var60) void onBoatHit(int snum, int var60) { auto p = &ps[snum]; - if (badguy(&sprite[var60]) || sprite[var60].picnum == APLAYER) + auto s = &sprite[var60]; + auto ht = &hittype[var60]; + + if (badguy(s) || s->picnum == APLAYER) { - if (sprite[var60].picnum != APLAYER) + if (s->picnum != APLAYER) { if (numplayers == 1) { fi.movesprite(var60, sintable[int(p->TiltStatus * 20 + p->angle.ang.asbuild() + 512) & 2047] >> 9, - sintable[int(p->TiltStatus * 20 + p->angle.ang.asbuild()) & 2047] >> 9, sprite[var60].zvel, CLIPMASK0); + sintable[int(p->TiltStatus * 20 + p->angle.ang.asbuild()) & 2047] >> 9, s->zvel, CLIPMASK0); } } else - hittype[var60].owner = p->i; - hittype[var60].picnum = MOTOHIT; - hittype[var60].extra = p->MotoSpeed >> 2; + ht->owner = p->i; + ht->picnum = MOTOHIT; + ht->extra = p->MotoSpeed >> 2; p->MotoSpeed -= p->MotoSpeed >> 2; p->TurbCount = 6; }