From 8fd0fe595582cfbabd3c023765103c24d5496399 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Oct 2020 09:40:10 +0200 Subject: [PATCH] - changed the spriteq to use pointers instead of indices. --- source/games/duke/src/actors.cpp | 20 ++++++++++++-------- source/games/duke/src/funct.h | 2 +- source/games/duke/src/global.cpp | 2 +- source/games/duke/src/global.h | 2 +- source/games/duke/src/premap.cpp | 2 +- source/games/duke/src/sectors_r.cpp | 2 +- source/games/duke/src/spawn.cpp | 22 ++-------------------- source/games/duke/src/spawn_d.cpp | 6 +++--- source/games/duke/src/spawn_r.cpp | 4 ++-- 9 files changed, 24 insertions(+), 38 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 15fac999a..a8342be53 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -240,16 +240,21 @@ int ssp(DDukeActor* const actor, unsigned int cliptype) //The set sprite functio // //--------------------------------------------------------------------------- -void insertspriteq(int i) +void insertspriteq(DDukeActor* const actor) { if (spriteqamount > 0) { - if (spriteq[spriteqloc] >= 0) - sprite[spriteq[spriteqloc]].xrepeat = 0; - spriteq[spriteqloc] = i; + if (spriteq[spriteqloc] != nullptr) + { + // Why is this not deleted here? + // Also todo: Make list size a CVAR. + spriteq[spriteqloc]->s.xrepeat = 0; + // deletesprite(spriteq[spriteqloc]); + } + spriteq[spriteqloc] = actor; spriteqloc = (spriteqloc + 1) % spriteqamount; } - else sprite[i].xrepeat = sprite[i].yrepeat = 0; + else actor->s.xrepeat = actor->s.yrepeat = 0; } //--------------------------------------------------------------------------- @@ -264,7 +269,6 @@ void lotsofstuff(DDukeActor* actor, int n, int spawntype) for (int i = n; i > 0; i--) { int r1 = krand(), r2 = krand(); // using the RANDCORRECT version from RR. - // TRANSITIONAL RedNukem sets the spawner as owner. auto j = EGS(s->sectnum, s->x, s->y, s->z - (r2 % (47 << 8)), spawntype, -32, 8, 8, r1 & 2047, 0, 0, actor, 5); j->s.cstat = krand() & 12; } @@ -2217,7 +2221,7 @@ bool money(int i, int BLOODPOOL) { s->z = l; - insertspriteq(i); + insertspriteq(&hittype[i]); sprite[i].picnum++; StatIterator it(STAT_MISC); @@ -2379,7 +2383,7 @@ bool bloodpool(int i, bool puke, int TIRE) deletesprite(i); return false; } - else insertspriteq(i); + else insertspriteq(&hittype[i]); } makeitfall(i); diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index f1370db4d..c74167dbc 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -101,7 +101,7 @@ void deletesprite(DDukeActor* num); void addammo(int weapon, struct player_struct* p, int amount); int ssp(DDukeActor* i, unsigned int cliptype); //The set sprite function -void insertspriteq(int i); +void insertspriteq(DDukeActor *i); int wakeup(int sn, int pn); diff --git a/source/games/duke/src/global.cpp b/source/games/duke/src/global.cpp index d6c28f35f..8d049f2ee 100644 --- a/source/games/duke/src/global.cpp +++ b/source/games/duke/src/global.cpp @@ -106,7 +106,7 @@ int16_t cloudx; int16_t cloudy; int cloudclock; -int16_t spriteq[1024]; +DDukeActor *spriteq[1024]; int16_t cyclers[MAXCYCLERS][6]; int16_t mirrorsector[64]; int16_t mirrorwall[64]; diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index b336e35b3..92138011e 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -99,7 +99,7 @@ extern int16_t cloudx; extern int16_t cloudy; extern int cloudclock; -extern int16_t spriteq[1024]; +extern DDukeActor *spriteq[1024]; extern int16_t cyclers[MAXCYCLERS][6]; extern int16_t mirrorsector[64]; extern int16_t mirrorwall[64]; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 65e2b7612..98f6b3530 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -388,7 +388,7 @@ void resetprestat(int snum,int g) p = &ps[snum]; spriteqloc = 0; - for(i=0;ihbomb_on = 0; p->pals.a = 0; diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 553b8ff49..a931108dd 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -1076,7 +1076,7 @@ void checkhitwall_r(int spr, int dawallnum, int x, int y, int z, int atwith) s = &sprite[jj]; if (s->lotag == 6) { - for (j = 0; j < 16; j++) RANDOMSCRAP(s, -1); + //for (j = 0; j < 16; j++) RANDOMSCRAP(s, -1); This never spawned anything due to the -1. hittype[jj].spriteextra++; if (hittype[jj].spriteextra == 25) { diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 945510406..02f652df2 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -41,6 +41,7 @@ source as it is released. BEGIN_DUKE_NS + //--------------------------------------------------------------------------- // // @@ -412,7 +413,7 @@ void initfootprint(int j, int i) if (sector[sect].lotag != 1 && sector[sect].lotag != 2) sp->xrepeat = sp->yrepeat = 32; - insertspriteq(i); + insertspriteq(&hittype[i]); changespritestat(i, STAT_MISC); } @@ -1084,25 +1085,6 @@ void spawneffector(int i) } -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void vglass(int x, int y, int a, int wn, int n) -{ - int z, zincs; - int sect; - - sect = wall[wn].nextsector; - if (sect == -1) return; - zincs = (sector[sect].floorz - sector[sect].ceilingz) / n; - - for (z = sector[sect].ceilingz; z < sector[sect].floorz; z += zincs) - EGS(sect, x, y, z - (krand() & 8191), TILE_GLASSPIECES + (z & (krand() % 3)), -32, 36, 36, a + 128 - (krand() & 255), 16 + (krand() & 31), 0, -1, 5); -} - //--------------------------------------------------------------------------- // // diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index 30ea61b43..052392f20 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -321,7 +321,7 @@ int spawn_d(int j, int pn) sp->z -= (16<<8); if(j >= 0 && spj->pal == 6) sp->pal = 6; - insertspriteq(i); + insertspriteq(&hittype[i]); changespritestat(i, STAT_MISC); break; @@ -543,7 +543,7 @@ int spawn_d(int j, int pn) case BULLETHOLE: sp->xrepeat = sp->yrepeat = 3; sp->cstat = 16+(krand()&12); - insertspriteq(i); + insertspriteq(&hittype[i]); case MONEY: case MAIL: case PAPER: @@ -917,7 +917,7 @@ int spawn_d(int j, int pn) { if( spj->picnum == NUKEBARREL ) sp->pal = 8; - insertspriteq(i); + insertspriteq(&hittype[i]); } changespritestat(i,1); diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp index eeb7c04f5..b04b9894a 100644 --- a/source/games/duke/src/spawn_r.cpp +++ b/source/games/duke/src/spawn_r.cpp @@ -362,7 +362,7 @@ int spawn_r(int j, int pn) sp->z -= (16<<8); if(j >= 0 && spj->pal == 6) sp->pal = 6; - insertspriteq(i); + insertspriteq(&hittype[i]); changespritestat(i, STAT_MISC); break; @@ -576,7 +576,7 @@ int spawn_r(int j, int pn) case BULLETHOLE: sp->xrepeat = sp->yrepeat = 3; sp->cstat = 16+(krand()&12); - insertspriteq(i); + insertspriteq(&hittype[i]); case MONEY: if(sp->picnum == MONEY) {