- insertsprite

This commit is contained in:
Christoph Oelckers 2021-11-14 18:39:49 +01:00
parent 486066e02d
commit d039c82037
16 changed files with 110 additions and 125 deletions

View file

@ -604,8 +604,8 @@ void processfluid(DWHActor* actor, Collision& florHit, boolean fly) {
void castspell(PLAYER& plr, DWHActor* actor) {
auto& spr = actor->s();
int j = insertsprite(spr.sectnum, MISSILE);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(spr.sectnum, MISSILE);
auto& spawned = spawnedactor->s();
spawned.x = spr.x;
spawned.y = spr.y;
@ -643,8 +643,8 @@ void castspell(PLAYER& plr, DWHActor* actor) {
void skullycastspell(PLAYER& plr, int i) {
auto& spr = sprite[i];
int j = insertsprite(spr.sectnum, MISSILE);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(spr.sectnum, MISSILE);
auto& spawned = spawnedactor->s();
spawned.x = spr.x;
spawned.y = spr.y;
@ -1007,9 +1007,9 @@ void monsterweapon(int i) {
if ((krand() % 100) < 75)
return;
int j = insertsprite(sprite[i].sectnum, (short)0);
auto spawnedactor = InsertActor(sprite[i].sectnum, (short)0);
auto& weap = spawnedactor->s();
SPRITE& weap = sprite[j];
weap.x = sprite[i].x;
weap.y = sprite[i].y;
weap.z = sprite[i].z - (24 << 8);

View file

@ -341,10 +341,7 @@ static void firebreath(PLAYER& plr, DWHActor* actor, int a, int b, int c)
{
auto& spr = actor->s();
for (int k = 0; k <= a; k++) {
int j = insertsprite(spr.sectnum, MISSILE);
if (j == -1)
return;
auto spawnedactor = &whActors[j];
auto spawnedactor = InsertActor(spr.sectnum, MISSILE);
auto& spawned = spawnedactor->s();
spawned.x = spr.x;

View file

@ -248,11 +248,9 @@ static void throwspank(PLAYER& plr, DWHActor* actor)
int i = actor->GetSpriteIndex();
SPRITE& spr = actor->s();
int j = insertsprite(spr.sectnum, MISSILE);
if (j == -1)
return;
auto spawnedactor = InsertActor(spr.sectnum, MISSILE);
auto& spawned = spawnedactor->s();
auto& spawned = sprite[j];
spritesound(S_WITCHTHROW, actor);
spawned.x = spr.x;

View file

@ -658,11 +658,8 @@ static boolean patrolprocess(PLAYER& plr, DWHActor* actor)
}
static void gonzopike(short s, PLAYER& plr) {
int j = insertsprite(sprite[s].sectnum, JAVLIN);
if (j == -1)
return;
SPRITE& spr = sprite[j];
auto spawnedactor = InsertActor(sprite[s].sectnum, JAVLIN);
auto& spr = spawnedactor->s();
spr.x = sprite[s].x;
spr.y = sprite[s].y;
@ -796,8 +793,9 @@ void premapGonzo(short i) {
void deaddude(short sn) {
auto& spr = sprite[sn];
int j = insertsprite(spr.sectnum, DEAD);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(spr.sectnum, DEAD);
auto& spawned = spawnedactor->s();
spawned.x = spr.x;
spawned.y = spr.y;
spawned.z = spr.z;

View file

@ -453,12 +453,9 @@ static void checkexplgron(PLAYER& plr, DWHActor* actor)
}
static void throwhalberd(int s) {
int j = insertsprite(sprite[s].sectnum, JAVLIN);
auto spawnedactor = &whActors[j];
if (j == -1)
return;
auto spawnedactor = InsertActor(sprite[s].sectnum, JAVLIN);
SPRITE& spr = spawnedactor->s();
spr.x = sprite[s].x;
spr.y = sprite[s].y;
spr.z = sprite[s].z - (40 << 8);

View file

@ -379,8 +379,8 @@ void judyOperate(PLAYER& plr)
void spawnabaddy(DWHActor* actor, int monster) {
auto& spr = actor->s();
short j = insertsprite(spr.sectnum, FACE);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(spr.sectnum, FACE);
auto& spawned = spawnedactor->s();
spawned.x = spr.x + (krand() & 2048) - 1024;
spawned.y = spr.y + (krand() & 2048) - 1024;
@ -391,20 +391,20 @@ void spawnabaddy(DWHActor* actor, int monster) {
spawned.cstat = 0;
if (monster == WILLOW)
premapWillow(j);
premapWillow(spawnedactor->GetSpriteIndex());
else if (monster == SPIDER)
premapSpider(j);
premapSpider(spawnedactor->GetSpriteIndex());
else if (monster == GRONSW)
premapGron(j);
premapGron(spawnedactor->GetSpriteIndex());
else if (monster == SKELETON)
premapSkeleton(j);
premapSkeleton(spawnedactor->GetSpriteIndex());
else if (monster == GONZOGSH)
premapGonzo(j);
premapGonzo(spawnedactor->GetSpriteIndex());
spawned.picnum = (short)monster;
killcnt++;
setsprite(j, spawned.x, spawned.y, spawned.z);
SetActorPos(spawnedactor, &spawned.pos);
spawned.backuploc();
}

View file

@ -362,12 +362,9 @@ static void castnewguy(PLAYER& plr, DWHActor* actor)
}
static void newguyarrow(short s, PLAYER& plr) {
int j = insertsprite(sprite[s].sectnum, JAVLIN);
if (j == -1)
return;
SPRITE& spr = sprite[j];
auto spawnedactor = InsertActor(sprite[s].sectnum, JAVLIN);
auto& spr = spawnedactor->s();
spr.x = sprite[s].x;
spr.y = sprite[s].y;
spr.z = sprite[s].z - (40 << 8);

View file

@ -140,8 +140,8 @@ void randompotion(int i) {
if ((krand() % 100) > 20)
return;
int j = insertsprite(sprite[i].sectnum, (short)0);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(sprite[i].sectnum, (short)0);
auto& spawned = spawnedactor->s();
spawned.x = sprite[i].x;
spawned.y = sprite[i].y;

View file

@ -262,8 +262,9 @@ void nukespell(PLAYER& plr, short const j) {
spr.hitag = 0;
addscore(&plr, 150);
int k = insertsprite(spr.sectnum, NUKED);
auto& spawned = sprite[k];
auto spawnedactor = InsertActor(spr.sectnum, NUKED);
auto& spawned = spawnedactor->s();
spawned.lotag = 360;
spawned.xrepeat = 30;
spawned.yrepeat = 12;

View file

@ -896,7 +896,6 @@ void madenoise(PLAYER& plr, int val, int x, int y, int z) {
void shootgun(PLAYER& plr, float ang, int guntype) {
int k = 0, daz2;
short j;
DWHActor* hitActor = nullptr;
int daang = (int) ang;
@ -1705,9 +1704,9 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
ntag, 1024, 3);
if (ntag.tagsector < 0) {
j = insertsprite(pHitInfo.hitsect, (short) 0);
auto spawnedactor = &whActors[j];
auto spawnedactor = InsertActor(pHitInfo.hitsect, (short) 0);
auto& spawned = spawnedactor->s();
spawned.x = pHitInfo.hitx;
spawned.y = pHitInfo.hity;
spawned.z = pHitInfo.hitz + (8 << 8);
@ -1728,9 +1727,9 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
spritesound(S_ARROWHIT, spawnedactor);
if (isWh2() && plr.weapon[6] == 3 && plr.currweapon == 6) {
auto spawnedactor = &whActors[j];
auto spawnedactor = InsertActor(pHitInfo.hitsect, FIRECHUNK);
auto& spawned = spawnedactor->s();
j = insertsprite(pHitInfo.hitsect, FIRECHUNK);
spawned.x = pHitInfo.hitx;
spawned.y = pHitInfo.hity;
spawned.z = pHitInfo.hitz + (14 << 8);
@ -1756,9 +1755,9 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
}
}
if (pHitInfo.hitwall > 0 && pHitInfo.hitsprite > 0) {
j = insertsprite(pHitInfo.hitsect, FX);
auto spawnedactor = &whActors[j];
auto spawnedactor = InsertActor(pHitInfo.hitsect, FX);
auto& spawned = spawnedactor->s();
spawned.x = pHitInfo.hitx;
spawned.y = pHitInfo.hity;
spawned.z = pHitInfo.hitz + (8 << 8);
@ -1956,10 +1955,10 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
}
if (plr.weapon[plr.currweapon] == 3) {
j = insertsprite(plr.sector, MISSILE);
auto spawnedactor = &whActors[j];
auto spawnedactor = InsertActor(plr.sector, MISSILE);
auto& spawned = spawnedactor->s();
throwpikesprite[throwpikecnt] = j;
throwpikesprite[throwpikecnt] = spawnedactor->GetSpriteIndex();
spawned.x = plr.x;
spawned.y = plr.y;
spawned.z = plr.z + (24 << 8);
@ -1985,12 +1984,13 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
spawned.pal = 0;
movesprite(spawnedactor, (bcos(spawned.extra) * TICSPERFRAME) << 3,
(bsin(spawned.extra) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
setsprite((short) j, spawned.x, spawned.y, spawned.z);
SetActorPos(spawnedactor, &spawned.pos);
spawned.backuploc();
} else {
j = insertsprite(plr.sector, MISSILE);
auto& spawned = sprite[j];
throwpikesprite[throwpikecnt] = j;
auto spawnedactor = InsertActor(plr.sector, MISSILE);
auto& spawned = spawnedactor->s();
throwpikesprite[throwpikecnt] = spawnedactor->GetSpriteIndex();
spawned.x = plr.x;
spawned.y = plr.y;
spawned.z = plr.z + (24 << 8);
@ -2012,8 +2012,8 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
spawned.backuploc();
}
} else {
j = insertsprite(plr.sector, MISSILE);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(plr.sector, MISSILE);
auto& spawned = spawnedactor->s();
spawned.x = plr.x;
spawned.y = plr.y;
@ -2055,10 +2055,10 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
if (plr.weapon[plr.currweapon] == 3) {
j = insertsprite(plr.sector, MISSILE);
auto spawnedactor = &whActors[j];
auto spawnedactor = InsertActor(plr.sector, MISSILE);
auto& spawned = spawnedactor->s();
throwpikesprite[throwpikecnt] = j;
throwpikesprite[throwpikecnt] = spawnedactor->GetSpriteIndex();
spawned.x = plr.x;
spawned.y = plr.y;
spawned.z = plr.z + (24 << 8);
@ -2081,13 +2081,13 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
spawned.pal = 0;
movesprite(spawnedactor, (bcos(spawned.extra) * TICSPERFRAME) << 3,
(bsin(spawned.extra) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
setsprite((short) j, spawned.x, spawned.y, spawned.z);
SetActorPos(spawnedactor, &spawned.pos);
spawned.backuploc();
} else {
j = insertsprite(plr.sector, MISSILE);
auto spawnedactor = &whActors[j];
auto spawnedactor = InsertActor(plr.sector, MISSILE);
auto& spawned = spawnedactor->s();
throwpikesprite[throwpikecnt] = j;
throwpikesprite[throwpikecnt] = spawnedactor->GetSpriteIndex();
spawned.x = plr.x;
spawned.y = plr.y;
spawned.z = plr.z + (24 << 8);
@ -2109,8 +2109,8 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
spawned.backuploc();
}
} else {
j = insertsprite(plr.sector, MISSILE);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(plr.sector, MISSILE);
auto& spawned = spawnedactor->s();
spawned.x = plr.x;
spawned.y = plr.y;
@ -2145,8 +2145,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
// netshootgun(-1,12);
}
j = insertsprite(plr.sector, MISSILE);
auto spawnedactor = &whActors[j];
auto spawnedactor = InsertActor(plr.sector, MISSILE);
auto& spawned = spawnedactor->s();
spawned.x = plr.x;
@ -2176,7 +2175,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
movesprite(spawnedactor, (bcos(spawned.ang) * TICSPERFRAME) << 3,
(bsin(spawned.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
setsprite(j, spawned.x, spawned.y, spawned.z);
SetActorPos(spawnedactor, &spawned.pos);
spawned.backuploc();
break;
@ -2187,8 +2186,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
// netshootgun(-1,13);
}
j = insertsprite(plr.sector, MISSILE);
auto spawnedactor = &whActors[j];
auto spawnedactor = InsertActor(plr.sector, MISSILE);
auto& spawned = spawnedactor->s();
spawned.x = plr.x;
@ -2221,7 +2219,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
movesprite(spawnedactor, (bcos(spawned.ang) * TICSPERFRAME) << 3,
(bsin(spawned.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
setsprite(j, spawned.x, spawned.y, spawned.z);
SetActorPos(spawnedactor, &spawned.pos);
spawned.backuploc();
break;

View file

@ -213,4 +213,9 @@ inline void DeleteActor(DWHActor* actor)
deletesprite(actor->GetSpriteIndex());
}
inline DWHActor* InsertActor(int sectnum, int statnum)
{
return &whActors[insertsprite(sectnum, statnum)];
}
END_WH_NS

View file

@ -254,8 +254,9 @@ void animateobjs(PLAYER& plr) {
spr.extra = 12;
}
} else {
j = insertsprite(spr.sectnum, FACE);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(spr.sectnum, FACE);
auto& spawned = spawnedactor->s();
enemy[GONZOTYPE].info.set(spawned);
spawned.x = spr.x;
spawned.y = spr.y;
@ -1330,8 +1331,8 @@ void animateobjs(PLAYER& plr) {
spr.lotag -= TICSPERFRAME;
if (krand() % 100 > 90) {
j = insertsprite(spr.sectnum, SMOKE);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(spr.sectnum, SMOKE);
auto& spawned = spawnedactor->s();
spawned.x = spr.x;
spawned.y = spr.y;

View file

@ -799,8 +799,7 @@ void thesplash() {
}
void makeasplash(int picnum, PLAYER& plr) {
int j = insertsprite(plr.sector, MASPLASH);
auto spawnedactor = &whActors[j];
auto spawnedactor = InsertActor(plr.sector, MASPLASH);
auto& spawned = spawnedactor->s();
spawned.x = plr.x;
@ -838,9 +837,9 @@ void makemonstersplash(int picnum, int i) {
if (sprite[i].picnum == FISH)
return;
int j = insertsprite(sprite[i].sectnum, MASPLASH);
auto spawnedactor = &whActors[j];
auto spawnedactor = InsertActor(sprite[i].sectnum, MASPLASH);
auto& spawned = spawnedactor->s();
spawned.x = sprite[i].x;
spawned.y = sprite[i].y;
spawned.z = sector[sprite[i].sectnum].floorz + (tileHeight(picnum) << 8);
@ -891,8 +890,9 @@ void makemonstersplash(int picnum, int i) {
}
void bats(PLAYER& plr, int k) {
short j = insertsprite(sprite[k].sectnum, FLOCK);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(sprite[k].sectnum, FLOCK);
auto& spawned = spawnedactor->s();
spawned.x = sprite[k].x;
spawned.y = sprite[k].y;
spawned.z = sprite[k].z;
@ -909,10 +909,10 @@ void bats(PLAYER& plr, int k) {
spawned.extra = 0;
spawned.backuploc();
newstatus(j, FLOCK);
SetNewStatus(spawnedactor, FLOCK);
if (sprite[k].extra == 1)
lastbat = j;
lastbat = spawnedactor->GetSpriteIndex();
}
void cracks() {
@ -998,8 +998,7 @@ void lavadryland() {
void warpfxsprite(int s) {
PLAYER& plr = player[pyrn];
int j = insertsprite(sprite[s].sectnum, WARPFX);
auto spawnedactor = &whActors[j];
auto spawnedactor = InsertActor(sprite[s].sectnum, WARPFX);
auto& spawned = spawnedactor->s();
spawned.x = sprite[s].x;
@ -1095,24 +1094,21 @@ void weaponpowerup(PLAYER& plr) {
void makesparks(short i, int type) {
int j = -1;
DWHActor* spawnedactor = nullptr;
switch (type) {
case 1:
j = insertsprite(sprite[i].sectnum, SPARKS);
spawnedactor = InsertActor(sprite[i].sectnum, SPARKS);
break;
case 2:
j = insertsprite(sprite[i].sectnum, SPARKSUP);
spawnedactor = InsertActor(sprite[i].sectnum, SPARKSUP);
break;
case 3:
j = insertsprite(sprite[i].sectnum, SPARKSDN);
spawnedactor = InsertActor(sprite[i].sectnum, SPARKSDN);
break;
}
if (j == -1)
return;
auto& spawned = sprite[j];
auto& spawned = spawnedactor->s();
spawned.x = sprite[i].x;
spawned.y = sprite[i].y;
@ -1134,8 +1130,8 @@ void makesparks(short i, int type) {
}
void shards(int i, int type) {
short j = insertsprite(sprite[i].sectnum, SHARDOFGLASS);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(sprite[i].sectnum, SHARDOFGLASS);
auto& spawned = spawnedactor->s();
spawned.x = sprite[i].x + (((krand() % 512) - 256) << 2);
spawned.y = sprite[i].y + (((krand() % 512) - 256) << 2);

View file

@ -758,9 +758,8 @@ boolean prepareboard(const char* fname) {
if(mapon == 13) {
if(sector[427].floorpicnum == 291) {
int s = insertsprite((short)427, (short)0);
if(s != -1) {
SPRITE& sp = sprite[s];
auto spawnedActor = InsertActor(427, 0);
SPRITE& sp = spawnedActor->s();
sp.x = 27136;
sp.y = 51712;
sp.z = 7168;
@ -772,7 +771,6 @@ boolean prepareboard(const char* fname) {
}
}
}
}
if (justteleported) { // next level
plr.hvel = 0;

View file

@ -1372,9 +1372,9 @@ void newstatus(short sn, int seq) {
}
void makeafire(int i, int firetype) {
short j = insertsprite(sprite[i].sectnum, FIRE);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(sprite[i].sectnum, FIRE);
auto& spawned = spawnedactor->s();
spawned.x = sprite[i].x + (krand() & 1024) - 512;
spawned.y = sprite[i].y + (krand() & 1024) - 512;
spawned.z = sprite[i].z;
@ -1389,13 +1389,13 @@ void makeafire(int i, int firetype) {
spawned.owner = sprite[i].owner;
spawned.lotag = 2047;
spawned.hitag = 0;
changespritestat(j, FIRE);
ChangeActorStat(spawnedactor, FIRE);
spawned.backuploc();
}
void explosion(int i, int x, int y, int z, int owner) {
int j = insertsprite(sprite[i].sectnum, EXPLO);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(sprite[i].sectnum, EXPLO);
auto& spawned = spawnedactor->s();
boolean isWH2 = isWh2();
@ -1432,8 +1432,8 @@ void explosion(int i, int x, int y, int z, int owner) {
}
void explosion2(int i, int x, int y, int z, int owner) {
int j = insertsprite(sprite[i].sectnum, EXPLO);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(sprite[i].sectnum, EXPLO);
auto& spawned = spawnedactor->s();
boolean isWH2 = isWh2();
@ -1474,8 +1474,8 @@ void explosion2(int i, int x, int y, int z, int owner) {
void trailingsmoke(DWHActor* actor, boolean ball) {
auto& spr = actor->s();
int j = insertsprite(spr.sectnum, SMOKE);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(spr.sectnum, SMOKE);
auto& spawned = spawnedactor->s();
spawned.x = spr.x;
spawned.y = spr.y;
@ -1503,8 +1503,8 @@ void trailingsmoke(DWHActor* actor, boolean ball) {
void icecubes(int i, int x, int y, int z, int owner) {
auto actor = &whActors[i];
auto& spr = actor->s();
int j = insertsprite(spr.sectnum, FX);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(spr.sectnum, FX);
auto& spawned = spawnedactor->s();
spawned.x = x;
spawned.y = y;
@ -1788,8 +1788,8 @@ Collision movesprite(DWHActor* actor, int dx, int dy, int dz, int ceildist, int
}
void trowajavlin(int s) {
int j = insertsprite(sprite[s].sectnum, JAVLIN);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(sprite[s].sectnum, JAVLIN);
auto& spawned = spawnedactor->s();
spawned.x = sprite[s].x;
spawned.y = sprite[s].y;
@ -1842,8 +1842,9 @@ void trowajavlin(int s) {
}
void spawnhornskull(short i) {
short j = insertsprite(sprite[i].sectnum, (short) 0);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(sprite[i].sectnum, (short) 0);
auto& spawned = spawnedactor->s();
spawned.x = sprite[i].x;
spawned.y = sprite[i].y;
spawned.z = sprite[i].z - (24 << 8);
@ -1860,8 +1861,8 @@ void spawnhornskull(short i) {
}
void spawnapentagram(int sn) {
short j = insertsprite(sprite[sn].sectnum, (short) 0);
auto& spawned = sprite[j];
auto spawnedactor = InsertActor(sprite[sn].sectnum, (short) 0);
auto& spawned = spawnedactor->s();
spawned.x = sprite[sn].x;
spawned.y = sprite[sn].y;
@ -1878,7 +1879,7 @@ void spawnapentagram(int sn) {
spawned.picnum = PENTAGRAM;
spawned.detail = PENTAGRAMTYPE;
setsprite(j, spawned.x, spawned.y, spawned.z);
SetActorPos(spawnedactor, &spawned.pos);
spawned.backuploc();
}

View file

@ -282,7 +282,6 @@ void plruse(PLAYER& plr) {
void chunksofmeat(PLAYER& plr, DWHActor* hitActor, int hitx, int hity, int hitz, short hitsect, int daang) {
int j;
short k;
short zgore = 0;
int chunk = REDCHUNKSTART;
@ -346,8 +345,7 @@ void chunksofmeat(PLAYER& plr, DWHActor* hitActor, int hitx, int hity, int hitz,
for (k = 0; k < zgore; k++) {
newchunk = 0;
j = insertsprite(hitsect, CHUNKOMEAT);
auto spawnedactor = &whActors[j];
auto spawnedactor = InsertActor(hitsect, CHUNKOMEAT);
auto& spawned = spawnedactor->s();
spawned.x = hitx;