- replaced most deletesprite calls outside the item interface.

This commit is contained in:
Christoph Oelckers 2021-11-13 23:26:57 +01:00
parent e261a17d2c
commit 99f0c89e4e
19 changed files with 78 additions and 72 deletions

View file

@ -307,12 +307,11 @@ void aiProcess() {
while (auto actor = it.Next())
{
SPRITE& spr = actor->s();
i = actor->GetSpriteIndex();
if (spr.picnum == ZFIRE) {
spr.lotag -= TICSPERFRAME;
if (spr.lotag <= 0)
deletesprite(i);
DeleteActor(actor);
}
else {
if (enemy[spr.detail].nuked != nullptr)
@ -551,7 +550,7 @@ boolean checksector6(DWHActor* actor) {
if (sector[spr.sectnum].lotag == 6)
SetNewStatus(actor, DIE);
else {
deletesprite(actor->GetSpriteIndex());
DeleteActor(actor);
return true;
}
}

View file

@ -248,7 +248,7 @@ static void nukeddevil(PLAYER& plr, DWHActor* actor)
spr.lotag = 24;
if (spr.picnum == DEVILCHAR + 4) {
trailingsmoke(actor,false);
deletesprite(i);
DeleteActor(actor);
}
}
}

View file

@ -259,7 +259,7 @@ static void nukeddragon(PLAYER& plr, DWHActor* actor)
spr.lotag = 24;
if (spr.picnum == DRAGONCHAR + 4) {
trailingsmoke(actor,false);
deletesprite(i);
DeleteActor(actor);
}
}
}

View file

@ -95,7 +95,7 @@ static void nukedfatwitch(PLAYER& plr, DWHActor* actor)
spr.lotag = 24;
if (spr.picnum == FATWITCHCHAR + 4) {
trailingsmoke(actor,false);
deletesprite(i);
DeleteActor(actor);
}
}
}

View file

@ -82,7 +82,7 @@ static void chasefish(PLAYER& plr, DWHActor* actor)
static void diefish(PLAYER& plr, DWHActor* actor)
{
int i = actor->GetSpriteIndex();
deletesprite(i);
DeleteActor(actor);
}
static void attackfish(PLAYER& plr, DWHActor* actor)

View file

@ -318,7 +318,7 @@ static void nukedgoblin(PLAYER& plr, DWHActor* actor)
spr.lotag = 24;
if (spr.picnum == GOBLINCHAR + 4) {
trailingsmoke(actor,false);
deletesprite(i);
DeleteActor(actor);
}
}
}

View file

@ -206,7 +206,7 @@ static void nukedgron(PLAYER& plr, DWHActor* actor)
spr.lotag = 24;
if (spr.picnum == GRONCHAR + 4) {
trailingsmoke(actor,false);
deletesprite(i);
DeleteActor(actor);
}
}
}

View file

@ -91,7 +91,7 @@ static void nukedguardian(PLAYER& plr, DWHActor* actor)
spr.lotag = 24;
if (spr.picnum == GUARDIANCHAR + 4) {
trailingsmoke(actor,false);
deletesprite(i);
DeleteActor(actor);
}
}
}

View file

@ -21,7 +21,7 @@ static void chasejudy(PLAYER& plr, DWHActor* actor)
if (spr.extra < 0) {
for (int j = 0; j < 8; j++)
trailingsmoke(actor,true);
deletesprite((short)i);
DeleteActor(actor);
return;
}
}
@ -106,7 +106,7 @@ static void nukedjudy(PLAYER& plr, DWHActor* actor)
spr.lotag = 24;
if (spr.picnum == JUDYCHAR + 4) {
trailingsmoke(actor,false);
deletesprite(i);
DeleteActor(actor);
}
}
}

View file

@ -298,7 +298,7 @@ static void nukedkobold(PLAYER& plr, DWHActor* actor)
spr.lotag = 24;
if (spr.picnum == KOBOLDCHAR + 4) {
trailingsmoke(actor,false);
deletesprite(i);
DeleteActor(actor);
}
}
}

View file

@ -150,7 +150,7 @@ static void nukedminotaur(PLAYER& plr, DWHActor* actor)
spr.lotag = 24;
if (spr.picnum == MINOTAURCHAR + 4) {
trailingsmoke(actor,false);
deletesprite(i);
DeleteActor(actor);
}
}
}

View file

@ -28,7 +28,7 @@ static void facerat(PLAYER& plr, DWHActor* actor)
static void dierat(PLAYER& plr, DWHActor* actor)
{
int i = actor->GetSpriteIndex();
deletesprite(i);
DeleteActor(actor);
}
static void fleerat(PLAYER& plr, DWHActor* actor)

View file

@ -305,7 +305,7 @@ static void nukedskeleton(PLAYER& plr, DWHActor* actor)
spr.lotag = 24;
if (spr.picnum == SKELETONCHAR + 4) {
trailingsmoke(actor,false);
deletesprite(i);
DeleteActor(actor);
}
}
}

View file

@ -92,7 +92,7 @@ static void nukedskully(PLAYER& plr, DWHActor* actor)
spr.lotag = 24;
if (spr.picnum == SKULLYCHAR + 4) {
trailingsmoke(actor,false);
deletesprite(i);
DeleteActor(actor);
}
}
}

View file

@ -208,4 +208,9 @@ inline void SetActorPos(DWHActor* actor, vec3_t* pos)
setsprite(actor->GetSpriteIndex(), pos);
}
inline void DeleteActor(DWHActor* actor)
{
deletesprite(actor->GetSpriteIndex());
}
END_WH_NS

View file

@ -48,7 +48,7 @@ void animateobjs(PLAYER& plr) {
break;
}
if (spr.lotag < 0) {
deletesprite(i);
DeleteActor(actor);
}
}
@ -270,7 +270,7 @@ void animateobjs(PLAYER& plr) {
spawned.lotag = 40;
spawned.hitag = 0;
spawned.detail = GONZOTYPE;
deletesprite((short) i);
DeleteActor(actor);
}
}
@ -312,7 +312,7 @@ void animateobjs(PLAYER& plr) {
}
}
if (spr.lotag < 0) {
deletesprite((short) i);
DeleteActor(actor);
// set back to normall
sector[plr.sector].ceilingshade = ceilingshadearray[plr.sector];
sector[plr.sector].floorshade = floorshadearray[plr.sector];
@ -409,7 +409,7 @@ void animateobjs(PLAYER& plr) {
spr.lotag = 12;
spr.picnum++;
if (spr.picnum == ANNIHILATE + 5) {
deletesprite((short) i);
DeleteActor(actor);
}
}
}
@ -475,7 +475,7 @@ void animateobjs(PLAYER& plr) {
if (i == lastbat) {
soundEngine->StopSound(CHAN_BAT);
}
deletesprite((short) i);
DeleteActor(actor);
continue;
} else {
movestat = (short) movesprite((short) i,
@ -486,7 +486,7 @@ void animateobjs(PLAYER& plr) {
if (i == lastbat) {
soundEngine->StopSound(CHAN_BAT);
}
deletesprite((short) i);
DeleteActor(actor);
continue;
}
if (movestat != 0)
@ -646,7 +646,7 @@ void animateobjs(PLAYER& plr) {
spr.picnum++;
spr.lotag = 8;
} else {
deletesprite((short) i);
DeleteActor(actor);
}
}
}
@ -692,7 +692,7 @@ void animateobjs(PLAYER& plr) {
spr.lotag = 2047;
break;
case SFIRE:
deletesprite(i);
DeleteActor(actor);
continue;
}
}
@ -739,7 +739,7 @@ void animateobjs(PLAYER& plr) {
if (spr.picnum == TORCH) {
for (k = 0; k < 16; k++)
makeafire(i, 0);
deletesprite(i);
DeleteActor(actor);
break;
}
ChangeActorStat(actor, 0);
@ -913,7 +913,7 @@ void animateobjs(PLAYER& plr) {
break;
if(!isValidSector(spr.sectnum)) {
deletesprite((short) i);
DeleteActor(actor);
continue;
}
@ -938,7 +938,7 @@ void animateobjs(PLAYER& plr) {
}
// if (spr.picnum != THROWPIKE) { //XXX
deletesprite((short) i);
DeleteActor(actor);
continue;
// }
}
@ -983,7 +983,7 @@ void animateobjs(PLAYER& plr) {
continue;
}
deletesprite((short) i);
DeleteActor(actor);
continue;
} else if ((hitobject & 0xc000) == 32768) { // hit a wall
@ -1000,7 +1000,7 @@ void animateobjs(PLAYER& plr) {
continue;
}
deletesprite((short) i);
DeleteActor(actor);
continue;
} else if (spr.lotag < 0 && spr.picnum == PLASMA)
hitobject = 1;
@ -1016,7 +1016,7 @@ void animateobjs(PLAYER& plr) {
if (spr.owner != hitobject)
hitdamage = damageactor(plr, hitobject, i);
if (hitdamage) {
deletesprite((short) i);
DeleteActor(actor);
continue;
}
}
@ -1035,7 +1035,7 @@ void animateobjs(PLAYER& plr) {
|| (spr.picnum == WH2THROWPIKE && !isWh2()))
break;
deletesprite((short) i);
DeleteActor(actor);
continue;
}
}
@ -1060,7 +1060,7 @@ void animateobjs(PLAYER& plr) {
|| sector[spr.sectnum].floorpicnum == FLOORMIRROR)
if (krand() % 100 > 60)
makemonstersplash(SPLASHAROO, i);
deletesprite((short) i);
DeleteActor(actor);
continue;
}
dax = spr.xvel;
@ -1126,13 +1126,13 @@ void animateobjs(PLAYER& plr) {
if (!hitdamage)
if (isBlades(sprite[j].picnum)) {
deletesprite((short) i);
DeleteActor(actor);
continue;
}
}
if (hitobject != 0) {
deletesprite((short) i);
DeleteActor(actor);
}
}
@ -1156,13 +1156,13 @@ void animateobjs(PLAYER& plr) {
spr.lotag = 8;
spr.picnum++;
if (spr.picnum == SMOKEFX + 3) {
deletesprite((short) i);
DeleteActor(actor);
continue;
}
}
} else {
if (spr.lotag < 0) {
deletesprite((short) i);
DeleteActor(actor);
}
}
}
@ -1205,7 +1205,7 @@ void animateobjs(PLAYER& plr) {
/* EG: Add check for parallax sky */
if (spr.picnum >= BONECHUNK1 && spr.picnum <= BONECHUNKEND
|| (daz >= zr_ceilz && (sector[spr.sectnum].ceilingstat & 1) != 0)) {
deletesprite(i);
DeleteActor(actor);
} else {
spr.cstat |= 0x0020;
spr.lotag = 1200;
@ -1214,14 +1214,14 @@ void animateobjs(PLAYER& plr) {
}
} else if ((movestat & 0xc000) == 32768) {
if (spr.picnum >= BONECHUNK1 && spr.picnum <= BONECHUNKEND) {
deletesprite((short) i);
DeleteActor(actor);
} else {
spr.lotag = 600;
SetNewStatus(actor, DRIP);
}
}
if (spr.lotag < 0) {
deletesprite(i);
DeleteActor(actor);
}
}
@ -1238,7 +1238,7 @@ void animateobjs(PLAYER& plr) {
spr.zvel = 0;
SetNewStatus(actor, DRIP);
} else {
deletesprite(i);
DeleteActor(actor);
}
}
}
@ -1282,7 +1282,7 @@ void animateobjs(PLAYER& plr) {
SetNewStatus(actor, BLOOD);
}
if (spr.lotag < 0) {
deletesprite((short) i);
DeleteActor(actor);
}
}
@ -1302,7 +1302,7 @@ void animateobjs(PLAYER& plr) {
// SetActorPos(actor, &spr.pos);
if (spr.lotag < 0) {
deletesprite((short) i);
DeleteActor(actor);
}
}
@ -1354,7 +1354,7 @@ void animateobjs(PLAYER& plr) {
}
if (spr.lotag < 0) {
deletesprite(i);
DeleteActor(actor);
}
}
} else {
@ -1405,7 +1405,7 @@ void animateobjs(PLAYER& plr) {
}
if (spr.picnum == EXPLOEND) {
deletesprite((short) i);
DeleteActor(actor);
}
}
}
@ -1491,7 +1491,7 @@ void animateobjs(PLAYER& plr) {
if (spr.picnum == PLASMA || spr.picnum == EXPLOSION || spr.picnum == FIREBALL
|| spr.picnum == MONSTERBALL || spr.picnum == FATSPANK
|| spr.picnum == ICECUBE) {
deletesprite(i);
DeleteActor(actor);
continue;
}
@ -1506,12 +1506,12 @@ void animateobjs(PLAYER& plr) {
else {
if (krand() % 100 > 60) {
makemonstersplash(SPLASHAROO, i);
deletesprite((short) i);
DeleteActor(actor);
}
}
} else {
if (spr.lotag < 0) {
deletesprite((short) i);
DeleteActor(actor);
}
}
}

View file

@ -290,11 +290,11 @@ boolean prepareboard(const char* fname) {
// if (spr.picnum == RAT) {
// ratcnt++;
// if (ratcnt > 10)
// deletesprite((short) i);
// DeleteActor(actor);
// }
if (spr.picnum == SPAWN) {
deletesprite((short) i);
DeleteActor(actor);
}
if (spr.picnum == TORCH) {
@ -312,17 +312,17 @@ boolean prepareboard(const char* fname) {
if (spr.picnum == SNDEFFECT) {
sector[spr.sectnum].extra = spr.lotag;
deletesprite((short) i);
DeleteActor(actor);
}
if (spr.picnum == SNDLOOP) { // loop on
sector[spr.sectnum].extra = (short) (32768 | (spr.lotag << 1) | 1);
deletesprite((short) i);
DeleteActor(actor);
}
if (spr.picnum == SNDLOOPOFF) { // loop off
sector[spr.sectnum].extra = (short) (32768 | (spr.lotag << 1));
deletesprite((short) i);
DeleteActor(actor);
}
if (spr.lotag == 80) {
@ -750,6 +750,7 @@ boolean prepareboard(const char* fname) {
if(isWh2()) {
if(mapon == 5) {
// oh my... (todo: turn into a compat patch.
SPRITE& spr = sprite[185];
if(spr.picnum == 172 && spr.x == -36864 && spr.y == -53504)
deletesprite((short) 185);

View file

@ -118,15 +118,14 @@ void processobjs(PLAYER& plr) {
while (auto actor = it.Next())
{
SPRITE& tspr = actor->s();
int i = actor->GetSpriteIndex();
dx = abs(plr.x - tspr.x); // x distance to sprite
dy = abs(plr.y - tspr.y); // y distance to sprite
dz = abs((plr.z >> 8) - (tspr.z >> 8)); // z distance to sprite
dh = tileHeight(tspr.picnum) >> 1; // height of sprite
if (dx + dy < PICKDISTANCE && dz - dh <= getPickHeight()) {
if(isItemSprite(i))
items[(tspr.detail & 0xFF) - ITEMSBASE].pickup(plr, (short)i);
if(isItemSprite(actor->GetSpriteIndex()))
items[(tspr.detail & 0xFF) - ITEMSBASE].pickup(plr, actor);
if (tspr.picnum >= EXPLOSTART && tspr.picnum <= EXPLOEND && tspr.owner != sprite[plr.spritenum].owner)
if (plr.manatime < 1)
@ -819,7 +818,7 @@ void newstatus(short sn, int seq) {
spr.picnum = GONZOBSHPAIN;
if (spr.shade > 30) {
trailingsmoke(actor, false);
deletesprite((short) sn);
DeleteActor(actor);
return;
}
break;
@ -838,7 +837,7 @@ void newstatus(short sn, int seq) {
case DEMONTYPE:
spritesound(S_GUARDIANDIE, &spr);
explosion(sn, spr.x, spr.y, spr.z, spr.owner);
deletesprite((short) sn);
DeleteActor(actor);
addscore(aiGetPlayerTarget(sn), 1500);
kills++;
return;
@ -921,7 +920,7 @@ void newstatus(short sn, int seq) {
if (mapon < 24) {
for (int j = 0; j < 8; j++)
trailingsmoke(actor, true);
deletesprite((short) sn);
DeleteActor(actor);
return;
} else {
spr.picnum = JUDYDIE;
@ -932,7 +931,7 @@ void newstatus(short sn, int seq) {
spritesound(S_GUARDIANDIE, &spr);
for (int j = 0; j < 4; j++)
explosion(sn, spr.x, spr.y, spr.z, spr.owner);
deletesprite((short) sn);
DeleteActor(actor);
addscore(aiGetPlayerTarget(sn), 1500);
kills++;
return;
@ -1340,7 +1339,7 @@ void newstatus(short sn, int seq) {
spr.pal = 0;
spr.cstat &= ~3;
ChangeActorStat(actor, (short) 0);
deletesprite(sn);
DeleteActor(actor);
addscore(aiGetPlayerTarget(sn), isWh2() ? 15 : 150);
return;
}
@ -1362,7 +1361,7 @@ void newstatus(short sn, int seq) {
|| sector[spr.sectnum].floorpicnum == LAVA1
|| sector[spr.sectnum].floorpicnum == LAVA2)) {
trailingsmoke(actor, true);
deletesprite((short) sn);
DeleteActor(actor);
}
}
break;
@ -1529,23 +1528,25 @@ void icecubes(int i, int x, int y, int z, int owner) {
}
boolean damageactor(PLAYER& plr, int hitobject, short const i) {
boolean damageactor(PLAYER& plr, int hitobject, short const i)
{
auto actor = &whActors[i];
short const j = (short) (hitobject & 4095); // j is the spritenum that the bullet (spritenum i) hit
auto& spr = sprite[i];
auto& spr = actor->s();
auto& hitspr = sprite[j];
if (j == plr.spritenum && spr.owner == sprite[plr.spritenum].owner)
return false;
if (j == plr.spritenum && spr.owner != sprite[plr.spritenum].owner) {
if (plr.invincibletime > 0 || plr.godMode) {
deletesprite(i);
DeleteActor(actor);
return false;
}
// EG 17 Oct 2017: Mass backport of RULES.CFG behavior for resist/onyx ring
// EG 21 Aug 2017: New RULES.CFG behavior in place of the old #ifdef
if (plr.manatime > 0) {
if (/* eg_resist_blocks_traps && */spr.picnum != FATSPANK && spr.picnum != PLASMA) {
deletesprite(i);
DeleteActor(actor);
return false;
}
// Use "fixed" version: EXPLOSION and MONSTERBALL are the fire attacks, account
@ -1554,7 +1555,7 @@ boolean damageactor(PLAYER& plr, int hitobject, short const i) {
// exception for it.
else if ((spr.picnum >= EXPLOSION && spr.picnum <= (MONSTERBALL + 2)
&& spr.picnum != FATSPANK)) {
deletesprite(i);
DeleteActor(actor);
return false;
}
}
@ -1564,7 +1565,7 @@ boolean damageactor(PLAYER& plr, int hitobject, short const i) {
&& spr.picnum != PLASMA)) {
// if (eg_onyx_effect == 1 || (eg_onyx_effect == 2 && ((krand() & 32) > 16))) {
deletesprite(i);
DeleteActor(actor);
return false;
// }
}
@ -1600,7 +1601,7 @@ boolean damageactor(PLAYER& plr, int hitobject, short const i) {
startredflash(10);
/* EG 2017 - Trap fix */
deletesprite(i);
DeleteActor(actor);
return true;
}
@ -1666,7 +1667,7 @@ boolean damageactor(PLAYER& plr, int hitobject, short const i) {
if (hitspr.hitag <= 0) {
newstatus(j, DIE);
deletesprite(i);
DeleteActor(actor);
} else
newstatus(j, PAIN);
return true;
@ -1716,7 +1717,7 @@ boolean damageactor(PLAYER& plr, int hitobject, short const i) {
newstatus(j, BROKENVASE);
break;
default:
deletesprite(i);
DeleteActor(actor);
return true;
}
}

View file

@ -59,7 +59,7 @@ void operatesprite(PLAYER& plr, short s) {
for (int j = 0; j < 20; j++) {
shards(s, 2);
}
deletesprite((short) s);
DeleteActor(actor);
break;
}
break;