- changed the spriteq to use pointers instead of indices.

This commit is contained in:
Christoph Oelckers 2020-10-24 09:40:10 +02:00
parent 34e39dd221
commit 8fd0fe5955
9 changed files with 24 additions and 38 deletions

View file

@ -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 (spriteqamount > 0)
{ {
if (spriteq[spriteqloc] >= 0) if (spriteq[spriteqloc] != nullptr)
sprite[spriteq[spriteqloc]].xrepeat = 0; {
spriteq[spriteqloc] = i; // 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; 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--) for (int i = n; i > 0; i--)
{ {
int r1 = krand(), r2 = krand(); // using the RANDCORRECT version from RR. 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); 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; j->s.cstat = krand() & 12;
} }
@ -2217,7 +2221,7 @@ bool money(int i, int BLOODPOOL)
{ {
s->z = l; s->z = l;
insertspriteq(i); insertspriteq(&hittype[i]);
sprite[i].picnum++; sprite[i].picnum++;
StatIterator it(STAT_MISC); StatIterator it(STAT_MISC);
@ -2379,7 +2383,7 @@ bool bloodpool(int i, bool puke, int TIRE)
deletesprite(i); deletesprite(i);
return false; return false;
} }
else insertspriteq(i); else insertspriteq(&hittype[i]);
} }
makeitfall(i); makeitfall(i);

View file

@ -101,7 +101,7 @@ void deletesprite(DDukeActor* num);
void addammo(int weapon, struct player_struct* p, int amount); void addammo(int weapon, struct player_struct* p, int amount);
int ssp(DDukeActor* i, unsigned int cliptype); //The set sprite function 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); int wakeup(int sn, int pn);

View file

@ -106,7 +106,7 @@ int16_t cloudx;
int16_t cloudy; int16_t cloudy;
int cloudclock; int cloudclock;
int16_t spriteq[1024]; DDukeActor *spriteq[1024];
int16_t cyclers[MAXCYCLERS][6]; int16_t cyclers[MAXCYCLERS][6];
int16_t mirrorsector[64]; int16_t mirrorsector[64];
int16_t mirrorwall[64]; int16_t mirrorwall[64];

View file

@ -99,7 +99,7 @@ extern int16_t cloudx;
extern int16_t cloudy; extern int16_t cloudy;
extern int cloudclock; extern int cloudclock;
extern int16_t spriteq[1024]; extern DDukeActor *spriteq[1024];
extern int16_t cyclers[MAXCYCLERS][6]; extern int16_t cyclers[MAXCYCLERS][6];
extern int16_t mirrorsector[64]; extern int16_t mirrorsector[64];
extern int16_t mirrorwall[64]; extern int16_t mirrorwall[64];

View file

@ -388,7 +388,7 @@ void resetprestat(int snum,int g)
p = &ps[snum]; p = &ps[snum];
spriteqloc = 0; spriteqloc = 0;
for(i=0;i<spriteqamount;i++) spriteq[i] = -1; for(i=0;i<spriteqamount;i++) spriteq[i] = nullptr;
p->hbomb_on = 0; p->hbomb_on = 0;
p->pals.a = 0; p->pals.a = 0;

View file

@ -1076,7 +1076,7 @@ void checkhitwall_r(int spr, int dawallnum, int x, int y, int z, int atwith)
s = &sprite[jj]; s = &sprite[jj];
if (s->lotag == 6) 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++; hittype[jj].spriteextra++;
if (hittype[jj].spriteextra == 25) if (hittype[jj].spriteextra == 25)
{ {

View file

@ -41,6 +41,7 @@ source as it is released.
BEGIN_DUKE_NS BEGIN_DUKE_NS
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// //
@ -412,7 +413,7 @@ void initfootprint(int j, int i)
if (sector[sect].lotag != 1 && sector[sect].lotag != 2) if (sector[sect].lotag != 1 && sector[sect].lotag != 2)
sp->xrepeat = sp->yrepeat = 32; sp->xrepeat = sp->yrepeat = 32;
insertspriteq(i); insertspriteq(&hittype[i]);
changespritestat(i, STAT_MISC); 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);
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// //

View file

@ -321,7 +321,7 @@ int spawn_d(int j, int pn)
sp->z -= (16<<8); sp->z -= (16<<8);
if(j >= 0 && spj->pal == 6) if(j >= 0 && spj->pal == 6)
sp->pal = 6; sp->pal = 6;
insertspriteq(i); insertspriteq(&hittype[i]);
changespritestat(i, STAT_MISC); changespritestat(i, STAT_MISC);
break; break;
@ -543,7 +543,7 @@ int spawn_d(int j, int pn)
case BULLETHOLE: case BULLETHOLE:
sp->xrepeat = sp->yrepeat = 3; sp->xrepeat = sp->yrepeat = 3;
sp->cstat = 16+(krand()&12); sp->cstat = 16+(krand()&12);
insertspriteq(i); insertspriteq(&hittype[i]);
case MONEY: case MONEY:
case MAIL: case MAIL:
case PAPER: case PAPER:
@ -917,7 +917,7 @@ int spawn_d(int j, int pn)
{ {
if( spj->picnum == NUKEBARREL ) if( spj->picnum == NUKEBARREL )
sp->pal = 8; sp->pal = 8;
insertspriteq(i); insertspriteq(&hittype[i]);
} }
changespritestat(i,1); changespritestat(i,1);

View file

@ -362,7 +362,7 @@ int spawn_r(int j, int pn)
sp->z -= (16<<8); sp->z -= (16<<8);
if(j >= 0 && spj->pal == 6) if(j >= 0 && spj->pal == 6)
sp->pal = 6; sp->pal = 6;
insertspriteq(i); insertspriteq(&hittype[i]);
changespritestat(i, STAT_MISC); changespritestat(i, STAT_MISC);
break; break;
@ -576,7 +576,7 @@ int spawn_r(int j, int pn)
case BULLETHOLE: case BULLETHOLE:
sp->xrepeat = sp->yrepeat = 3; sp->xrepeat = sp->yrepeat = 3;
sp->cstat = 16+(krand()&12); sp->cstat = 16+(krand()&12);
insertspriteq(i); insertspriteq(&hittype[i]);
case MONEY: case MONEY:
if(sp->picnum == MONEY) if(sp->picnum == MONEY)
{ {