- experimented a bit with optimizing the spawn function's use.

This commit is contained in:
Christoph Oelckers 2020-10-24 09:05:54 +02:00
parent 356060e127
commit 87e4c0fa7d
2 changed files with 38 additions and 34 deletions

View file

@ -1404,19 +1404,20 @@ void movetongue(int i, int tongue, int jaw)
void rpgexplode(int i, int j, const vec3_t &pos, int EXPLOSION2, int newextra, int playsound) void rpgexplode(int i, int j, const vec3_t &pos, int EXPLOSION2, int newextra, int playsound)
{ {
auto s = &sprite[i]; auto act = &hittype[i];
int k = fi.spawn(i, EXPLOSION2); auto s = &act->s;
sprite[k].pos = pos; auto k = spawn(act, EXPLOSION2);
k->s.pos = pos;
if (s->xrepeat < 10) if (s->xrepeat < 10)
{ {
sprite[k].xrepeat = 6; k->s.xrepeat = 6;
sprite[k].yrepeat = 6; k->s.yrepeat = 6;
} }
else if ((j & kHitTypeMask) == kHitSector) else if ((j & kHitTypeMask) == kHitSector)
{ {
sprite[k].cstat |= 8; k->s.cstat |= 8;
sprite[k].z += (48 << 8); k->s.z += (48 << 8);
} }
if (newextra > 0) s->extra = newextra; if (newextra > 0) s->extra = newextra;
S_PlayActorSound(playsound, i); S_PlayActorSound(playsound, i);
@ -1596,8 +1597,9 @@ bool queball(int i, int pocket, int queball, int stripeball)
void forcesphere(int i, int forcesphere) void forcesphere(int i, int forcesphere)
{ {
spritetype* s = &sprite[i]; auto act = &hittype[i];
auto t = &hittype[i].temp_data[0]; auto s = &act->s;
auto t = &act->temp_data[0];
int sect = s->sectnum; int sect = s->sectnum;
if (s->yvel == 0) if (s->yvel == 0)
{ {
@ -1606,13 +1608,13 @@ void forcesphere(int i, int forcesphere)
for (int l = 512; l < (2048 - 512); l += 128) for (int l = 512; l < (2048 - 512); l += 128)
for (int j = 0; j < 2048; j += 128) for (int j = 0; j < 2048; j += 128)
{ {
int k = fi.spawn(i, forcesphere); auto k = spawn(act, forcesphere);
sprite[k].cstat = 257 + 128; k->s.cstat = 257 + 128;
sprite[k].clipdist = 64; k->s.clipdist = 64;
sprite[k].ang = j; k->s.ang = j;
sprite[k].zvel = sintable[l & 2047] >> 5; k->s.zvel = sintable[l & 2047] >> 5;
sprite[k].xvel = sintable[(l + 512) & 2047] >> 9; k->s.xvel = sintable[(l + 512) & 2047] >> 9;
sprite[k].owner = i; k->s.owner = i;
} }
} }
@ -4703,8 +4705,9 @@ void handle_se128(int i)
void handle_se130(int i, int countmax, int EXPLOSION2) void handle_se130(int i, int countmax, int EXPLOSION2)
{ {
spritetype* s = &sprite[i]; auto act = &hittype[i];
auto t = &hittype[i].temp_data[0]; spritetype* s = &act->s;
auto t = &act->temp_data[0];
auto sc = &sector[s->sectnum]; auto sc = &sector[s->sectnum];
if (t[0] > countmax) if (t[0] > countmax)
@ -4718,11 +4721,11 @@ void handle_se130(int i, int countmax, int EXPLOSION2)
if (rnd(64)) if (rnd(64))
{ {
int k = fi.spawn(i, EXPLOSION2); auto k = spawn(act, EXPLOSION2);
sprite[k].xrepeat = sprite[k].yrepeat = 2 + (krand() & 7); k->s.xrepeat = k->s.yrepeat = 2 + (krand() & 7);
sprite[k].z = sc->floorz - (krand() % x); k->s.z = sc->floorz - (krand() % x);
sprite[k].ang += 256 - (krand() % 511); k->s.ang += 256 - (krand() % 511);
sprite[k].xvel = krand() & 127; k->s.xvel = krand() & 127;
ssp(k, CLIPMASK0); ssp(k, CLIPMASK0);
} }
} }

View file

@ -1273,7 +1273,8 @@ static bool weaponhitsprite(int i, int j, const vec3_t &oldpos)
static bool weaponhitwall(int i, int j, const vec3_t& oldpos) static bool weaponhitwall(int i, int j, const vec3_t& oldpos)
{ {
auto s = &sprite[i]; auto act = &hittype[i];
auto s = &act->s;
if (isRRRA() && sprite[s->owner].picnum == MAMA) if (isRRRA() && sprite[s->owner].picnum == MAMA)
{ {
@ -1327,12 +1328,12 @@ static bool weaponhitwall(int i, int j, const vec3_t& oldpos)
s->y += sintable[s->ang & 2047] >> 7; s->y += sintable[s->ang & 2047] >> 7;
if (!isRRRA() || (sprite[s->owner].picnum != CHEER && sprite[s->owner].picnum != CHEERSTAYPUT)) if (!isRRRA() || (sprite[s->owner].picnum != CHEER && sprite[s->owner].picnum != CHEERSTAYPUT))
{ {
j = fi.spawn(i, CIRCLESTUCK); auto j = spawn(act, CIRCLESTUCK);
sprite[j].xrepeat = 8; j->s.xrepeat = 8;
sprite[j].yrepeat = 8; j->s.yrepeat = 8;
sprite[j].cstat = 16; j->s.cstat = 16;
sprite[j].ang = (sprite[j].ang + 512) & 2047; j->s.ang = (j->s.ang + 512) & 2047;
sprite[j].clipdist = mulscale7(s->xrepeat, tilesiz[s->picnum].x); j->s.clipdist = mulscale7(s->xrepeat, tilesiz[s->picnum].x);
} }
deletesprite(i); deletesprite(i);
return true; return true;
@ -2523,10 +2524,10 @@ void rr_specialstats()
s->lotag--; s->lotag--;
if (s->lotag < 0) if (s->lotag < 0)
{ {
guts_r(&sprite[i], JIBS1, 1, myconnectindex); guts_r(s, JIBS1, 1, myconnectindex);
guts_r(&sprite[i], JIBS2, 1, myconnectindex); guts_r(s, JIBS2, 1, myconnectindex);
guts_r(&sprite[i], JIBS3, 1, myconnectindex); guts_r(s, JIBS3, 1, myconnectindex);
guts_r(&sprite[i], JIBS4, 1, myconnectindex); guts_r(s, JIBS4, 1, myconnectindex);
s->lotag = 256; s->lotag = 256;
} }
break; break;