diff --git a/source/games/duke/src/prediction.cpp b/source/games/duke/src/prediction.cpp index 5f0631022..97dc9cb29 100644 --- a/source/games/duke/src/prediction.cpp +++ b/source/games/duke/src/prediction.cpp @@ -180,7 +180,7 @@ void fakedomovethings(void) psectlotag = 0; spritebridge = 1; } - if(badguy(chz.actor) && sprite[j].xrepeat > 24 && klabs(p->GetActor()->s.z- chz.actor->s.z) < (84<<8) ) + if(badguy(chz.actor) && chz.actor->s.xrepeat > 24 && klabs(p->GetActor()->s.z- chz.actor->s.z) < (84<<8) ) { j = getangle(chz.actor->s.x-myx, chz.actor->s.y-myy); myxvel -= sintable[(j+512)&2047]<<4; diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index 81e05c633..bcf9ef621 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -58,104 +58,118 @@ static int tempsectorz[MAXSECTORS]; static int tempsectorpicnum[MAXSECTORS]; //short tempcursectnum; -void SE40_Draw(int tag, int spnum, int x, int y, int z, binangle a, fixedhoriz h, int smoothratio) +void SE40_Draw(int tag, spritetype *spr, int x, int y, int z, binangle a, fixedhoriz h, int smoothratio) { int i, j = 0, k = 0; - int floor1, floor2 = 0, ok = 0, fofmode = 0; + int ok = 0, fofmode = 0; int offx, offy; + spritetype* floor1, *floor2 = nullptr; - if (sprite[spnum].ang != 512) return; + if (spr->ang != 512) return; i = FOF; //Effect TILE tileDelete(FOF); if (!(gotpic[i >> 3] & (1 << (i & 7)))) return; gotpic[i >> 3] &= ~(1 << (i & 7)); - floor1 = spnum; + floor1 = spr; - if (sprite[spnum].lotag == tag + 2) fofmode = tag + 0; - if (sprite[spnum].lotag == tag + 3) fofmode = tag + 1; - if (sprite[spnum].lotag == tag + 4) fofmode = tag + 0; - if (sprite[spnum].lotag == tag + 5) fofmode = tag + 1; + if (spr->lotag == tag + 2) fofmode = tag + 0; + if (spr->lotag == tag + 3) fofmode = tag + 1; + if (spr->lotag == tag + 4) fofmode = tag + 0; + if (spr->lotag == tag + 5) fofmode = tag + 1; ok++; - for (j = 0; j < MAXSPRITES; j++) + DukeStatIterator it(STAT_RAROR); + while (auto act = it.Next()) { + auto spr = &act->s; if ( - sprite[j].picnum == 1 && - sprite[j].lotag == fofmode && - sprite[j].hitag == sprite[floor1].hitag - ) { - floor1 = j; fofmode = sprite[j].lotag; ok++; break; + spr->picnum == SECTOREFFECTOR && + spr->lotag == fofmode && + spr->hitag == floor1->hitag + ) + { + floor1 = spr; + fofmode = spr->lotag; + ok++; + break; } } // if(ok==1) { Message("no floor1",RED); return; } if (fofmode == tag + 0) k = tag + 1; else k = tag + 0; - for (j = 0; j < MAXSPRITES; j++) + it.Reset(STAT_RAROR); + while (auto act = it.Next()) { + auto spr = &act->s; if ( - sprite[j].picnum == 1 && - sprite[j].lotag == k && - sprite[j].hitag == sprite[floor1].hitag - ) { - floor2 = j; ok++; break; + spr->picnum == SECTOREFFECTOR && + spr->lotag == k && + spr->hitag == floor1->hitag + ) + { + floor2 = spr; + ok++; + break; } } // if(ok==2) { Message("no floor2",RED); return; } - for (j = 0; j < MAXSPRITES; j++) // raise ceiling or floor + it.Reset(STAT_RAROR); + while (auto act = it.Next()) { - if (sprite[j].picnum == 1 && - sprite[j].lotag == k + 2 && - sprite[j].hitag == sprite[floor1].hitag + auto spr = &act->s; + if (spr->picnum == SECTOREFFECTOR && + spr->lotag == k + 2 && + spr->hitag == floor1->hitag ) { if (k == tag + 0) { - tempsectorz[sprite[j].sectnum] = sector[sprite[j].sectnum].floorz; - sector[sprite[j].sectnum].floorz += (((z - sector[sprite[j].sectnum].floorz) / 32768) + 1) * 32768; - tempsectorpicnum[sprite[j].sectnum] = sector[sprite[j].sectnum].floorpicnum; - sector[sprite[j].sectnum].floorpicnum = 13; + tempsectorz[spr->sectnum] = sector[spr->sectnum].floorz; + sector[spr->sectnum].floorz += (((z - sector[spr->sectnum].floorz) / 32768) + 1) * 32768; + tempsectorpicnum[spr->sectnum] = sector[spr->sectnum].floorpicnum; + sector[spr->sectnum].floorpicnum = 13; } if (k == tag + 1) { - tempsectorz[sprite[j].sectnum] = sector[sprite[j].sectnum].ceilingz; - sector[sprite[j].sectnum].ceilingz += (((z - sector[sprite[j].sectnum].ceilingz) / 32768) - 1) * 32768; - tempsectorpicnum[sprite[j].sectnum] = sector[sprite[j].sectnum].ceilingpicnum; - sector[sprite[j].sectnum].ceilingpicnum = 13; + tempsectorz[spr->sectnum] = sector[spr->sectnum].ceilingz; + sector[spr->sectnum].ceilingz += (((z - sector[spr->sectnum].ceilingz) / 32768) - 1) * 32768; + tempsectorpicnum[spr->sectnum] = sector[spr->sectnum].ceilingpicnum; + sector[spr->sectnum].ceilingpicnum = 13; } } } - i = floor1; - offx = x - sprite[i].x; - offy = y - sprite[i].y; - i = floor2; + offx = x - floor1->x; + offy = y - floor1->y; - renderDrawRoomsQ16(sprite[i].x + offx, sprite[i].y + offy, z, a.asq16(), h.asq16(), sprite[i].sectnum); - fi.animatesprites(offx + sprite[i].x, offy + sprite[i].y, a.asbuild(), smoothratio); + renderDrawRoomsQ16(floor2->x + offx, floor2->y + offy, z, a.asq16(), h.asq16(), floor2->sectnum); + fi.animatesprites(offx + floor2->x, offy + floor2->y, a.asbuild(), smoothratio); renderDrawMasks(); - for (j = 0; j < MAXSPRITES; j++) // restore ceiling or floor + it.Reset(STAT_RAROR); + while (auto act = it.Next()) { - if (sprite[j].picnum == 1 && - sprite[j].lotag == k + 2 && - sprite[j].hitag == sprite[floor1].hitag + auto spr = &act->s; + if (spr->picnum == 1 && + spr->lotag == k + 2 && + spr->hitag == floor1->hitag ) { if (k == tag + 0) { - sector[sprite[j].sectnum].floorz = tempsectorz[sprite[j].sectnum]; - sector[sprite[j].sectnum].floorpicnum = tempsectorpicnum[sprite[j].sectnum]; + sector[spr->sectnum].floorz = tempsectorz[spr->sectnum]; + sector[spr->sectnum].floorpicnum = tempsectorpicnum[spr->sectnum]; } if (k == tag + 1) { - sector[sprite[j].sectnum].ceilingz = tempsectorz[sprite[j].sectnum]; - sector[sprite[j].sectnum].ceilingpicnum = tempsectorpicnum[sprite[j].sectnum]; + sector[spr->sectnum].ceilingz = tempsectorz[spr->sectnum]; + sector[spr->sectnum].ceilingpicnum = tempsectorpicnum[spr->sectnum]; } }// end if }// end for @@ -171,15 +185,15 @@ void SE40_Draw(int tag, int spnum, int x, int y, int z, binangle a, fixedhoriz h void se40code(int x, int y, int z, binangle a, fixedhoriz h, int smoothratio) { - int i, tag; + int tag; if (!isRR()) tag = 40; else if (isRRRA()) tag = 150; else return; - StatIterator it(STAT_RAROR); - while ((i = it.NextIndex()) >= 0) + DukeStatIterator it(STAT_RAROR); + while (auto act = it.Next()) { - switch (sprite[i].lotag - tag + 40) + switch (act->s.lotag - tag + 40) { // case 40: // case 41: @@ -189,8 +203,8 @@ void se40code(int x, int y, int z, binangle a, fixedhoriz h, int smoothratio) case 43: case 44: case 45: - if (ps[screenpeek].cursectnum == sprite[i].sectnum) - SE40_Draw(tag, i, x, y, z, a, h, smoothratio); + if (ps[screenpeek].cursectnum == act->s.sectnum) + SE40_Draw(tag, &act->s, x, y, z, a, h, smoothratio); break; } }