From 5528725985d1b66ef802eda94ecf860fb6b8e3bc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 20 Nov 2022 19:25:23 +0100 Subject: [PATCH] - got rid of deletesprite, plus one new flag. --- source/games/duke/src/actors.cpp | 109 ++++++++++++--------------- source/games/duke/src/actors_d.cpp | 66 ++++++++--------- source/games/duke/src/actors_r.cpp | 111 +++++++++++++--------------- source/games/duke/src/bowling.cpp | 2 +- source/games/duke/src/ccmds.cpp | 4 +- source/games/duke/src/constants.h | 1 + source/games/duke/src/flags_d.cpp | 1 + source/games/duke/src/flags_r.cpp | 2 + source/games/duke/src/funct.h | 1 - source/games/duke/src/gameexec.cpp | 8 +- source/games/duke/src/player.cpp | 4 +- source/games/duke/src/player_r.cpp | 4 +- source/games/duke/src/premap.cpp | 2 +- source/games/duke/src/premap_r.cpp | 16 ++-- source/games/duke/src/sectors_d.cpp | 18 ++--- source/games/duke/src/sectors_r.cpp | 15 ++-- 16 files changed, 171 insertions(+), 193 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 0a0eef257..4d0844414 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -78,17 +78,6 @@ void RANDOMSCRAP(DDukeActor* origin) } } -//--------------------------------------------------------------------------- -// -// wrapper to ensure that if a sound actor is killed, the sound is stopped as well. -// -//--------------------------------------------------------------------------- - -void deletesprite(DDukeActor *const actor) -{ - actor->Destroy(); -} - //--------------------------------------------------------------------------- // // @@ -252,7 +241,7 @@ void insertspriteq(DDukeActor* const actor) if (spriteq[spriteqloc] != nullptr) { // todo: Make list size a CVAR. - deletesprite(spriteq[spriteqloc]); + spriteq[spriteqloc]->Destroy(); } spriteq[spriteqloc] = actor; spriteqloc = (spriteqloc + 1) % spriteqamount; @@ -364,7 +353,7 @@ void movedummyplayers(void) if ((!isRR() && ps[p].on_crane != nullptr) || !ps[p].insector() || ps[p].cursector->lotag != 1 || ps->GetActor()->spr.extra <= 0) { ps[p].dummyplayersprite = nullptr; - deletesprite(act); + act->Destroy(); continue; } else @@ -484,7 +473,7 @@ void moveplayers(void) { if (p->holoduke_on == nullptr) { - deletesprite(act); + act->Destroy(); continue; } @@ -606,7 +595,7 @@ void detonate(DDukeActor *actor, int explosion) if (actor->spr.scale.X != 0) for (int x = 0; x < 8; x++) RANDOMSCRAP(actor); - deletesprite(actor); + actor->Destroy(); } @@ -659,7 +648,7 @@ void movetongue(DDukeActor *actor, int tongue, int jaw) actor->temp_data[1] += 32; if (actor->temp_data[1] > 2047) { - deletesprite(actor); + actor->Destroy(); return; } @@ -669,7 +658,7 @@ void movetongue(DDukeActor *actor, int tongue, int jaw) if (Owner->spr.statnum == MAXSTATUS) if (badguy(Owner) == 0) { - deletesprite(actor); + actor->Destroy(); return; } @@ -752,7 +741,7 @@ bool respawnmarker(DDukeActor *actor, int yellow, int green) actor->temp_data[0]++; if (actor->temp_data[0] > gs.respawnitemtime) { - deletesprite(actor); + actor->Destroy(); return false; } if (actor->temp_data[0] >= (gs.respawnitemtime >> 1) && actor->temp_data[0] < ((gs.respawnitemtime >> 1) + (gs.respawnitemtime >> 2))) @@ -782,7 +771,7 @@ bool rat(DDukeActor* actor, bool makesound) actor->temp_data[0]++; if (actor->temp_data[0] > 1) { - deletesprite(actor); + actor->Destroy(); return false; } else actor->spr.angle = randomAngle(); @@ -809,7 +798,7 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball) double dist = (aa->spr.pos.XY() - actor->spr.pos.XY()).Length(); if (aa->spr.picnum == pocket && dist < 3.25) { - deletesprite(actor); + actor->Destroy(); return false; } } @@ -927,7 +916,7 @@ void forcesphere(DDukeActor* actor, int forcesphere) actor->temp_data[3]--; if (actor->temp_data[3] == 0) { - deletesprite(actor); + actor->Destroy(); return; } else if (actor->temp_data[2] > 10) @@ -1000,7 +989,7 @@ void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int p int sp = getspawn(actor); if (sp >= 0) spawn(actor, sp); ps[myconnectindex].actors_killed++; - deletesprite(actor); + actor->Destroy(); } return; } @@ -1111,7 +1100,7 @@ void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int p NewOwner = LocateTheLocator(actor->spr.hitag, nullptr); if (!NewOwner) { - deletesprite(actor); + actor->Destroy(); return; } } @@ -1258,7 +1247,7 @@ void reactor(DDukeActor* const actor, int REACTOR, int REACTOR2, int REACTORBURN { if (a2 != actor) { - deletesprite(a2); + a2->Destroy(); break; } } @@ -1318,7 +1307,7 @@ void forcesphereexplode(DDukeActor *actor) actor->temp_data[1]--; if (actor->temp_data[1] == 0) { - deletesprite(actor); + actor->Destroy(); return; } } @@ -1365,7 +1354,7 @@ void watersplash2(DDukeActor* actor) { if (sectp->lotag != 1 && sectp->lotag != 2) { - deletesprite(actor); + actor->Destroy(); return; } if (!S_CheckSoundPlaying(ITEM_SPLASH)) @@ -1377,7 +1366,7 @@ void watersplash2(DDukeActor* actor) actor->temp_data[1]++; } if (actor->temp_data[1] == 5) - deletesprite(actor); + actor->Destroy(); } //--------------------------------------------------------------------------- @@ -1395,7 +1384,7 @@ void frameeffect1(DDukeActor *actor) if (actor->temp_data[0] > 7) { - deletesprite(actor); + actor->Destroy(); return; } else if (actor->temp_data[0] > 4) actor->spr.cstat |= CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_TRANSLUCENT; @@ -1436,7 +1425,7 @@ bool money(DDukeActor* actor, int BLOODPOOL) if (!actor->insector()) { - deletesprite(actor); + actor->Destroy(); return false; } double l = getflorzofslopeptr(actor->sector(), actor->spr.pos); @@ -1484,7 +1473,7 @@ bool jibs(DDukeActor *actor, int JIBS6, bool timeout, bool callsetsprite, bool f actor->temp_data[5]++; else { - deletesprite(actor); + actor->Destroy(); return false; } } @@ -1500,7 +1489,7 @@ bool jibs(DDukeActor *actor, int JIBS6, bool timeout, bool callsetsprite, bool f // this was after the slope calls, but we should avoid calling that for invalid sectors. if (!actor->insector()) { - deletesprite(actor); + actor->Destroy(); return false; } @@ -1508,7 +1497,7 @@ bool jibs(DDukeActor *actor, int JIBS6, bool timeout, bool callsetsprite, bool f double cz = getceilzofslopeptr(sectp, actor->spr.pos); if (cz == fz) { - deletesprite(actor); + actor->Destroy(); return false; } @@ -1547,7 +1536,7 @@ bool jibs(DDukeActor *actor, int JIBS6, bool timeout, bool callsetsprite, bool f if (floorcheck && actor->spr.pos.Z >= actor->sector()->floorz) { - deletesprite(actor); + actor->Destroy(); return false; } } @@ -1555,19 +1544,19 @@ bool jibs(DDukeActor *actor, int JIBS6, bool timeout, bool callsetsprite, bool f { if (zcheck2) { - deletesprite(actor); + actor->Destroy(); return false; } if (actor->temp_data[2] == 0) { if (!actor->insector()) { - deletesprite(actor); + actor->Destroy(); return false; } if ((actor->sector()->floorstat & CSTAT_SECTOR_SLOPE)) { - deletesprite(actor); + actor->Destroy(); return false; } actor->temp_data[2]++; @@ -1584,7 +1573,7 @@ bool jibs(DDukeActor *actor, int JIBS6, bool timeout, bool callsetsprite, bool f actor->temp_data[0]++; if (actor->temp_data[1] > 20) { - deletesprite(actor); + actor->Destroy(); return false; } } @@ -1608,7 +1597,7 @@ bool bloodpool(DDukeActor* actor, bool puke) actor->temp_data[0] = 1; if (sectp->floorstat & CSTAT_SECTOR_SLOPE) { - deletesprite(actor); + actor->Destroy(); return false; } else insertspriteq(actor); @@ -1691,7 +1680,7 @@ void shell(DDukeActor* actor, bool morecheck) if (!actor->insector() || morecheck) { - deletesprite(actor); + actor->Destroy(); return; } @@ -1724,7 +1713,7 @@ void shell(DDukeActor* actor, bool morecheck) actor->vel.X -= 1/16.; else { - deletesprite(actor); + actor->Destroy(); } } } @@ -1744,7 +1733,7 @@ void glasspieces(DDukeActor* actor) if (actor->vel.Z > 16) actor->vel.Z = 16; if (!actor->insector()) { - deletesprite(actor); + actor->Destroy(); return; } @@ -1761,7 +1750,7 @@ void glasspieces(DDukeActor* actor) } else if (actor->temp_data[0] == 3) { - deletesprite(actor); + actor->Destroy(); return; } @@ -1829,7 +1818,7 @@ void handle_se00(DDukeActor* actor) if (!Owner || Owner->spr.lotag == -1) { - deletesprite(actor); + actor->Destroy(); return; } @@ -1906,7 +1895,7 @@ void handle_se00(DDukeActor* actor) if (Owner->temp_data[0] == 0) return; if (Owner->temp_data[0] == 2) { - deletesprite(actor); + actor->Destroy(); return; } @@ -2185,7 +2174,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) { gutsdir(a2, JIBS6, 72, myconnectindex); S_PlayActorSound(SQUISHED, actor); - deletesprite(a2); + a2->Destroy(); } } } @@ -2345,7 +2334,7 @@ void handle_se30(DDukeActor *actor, int JIBS6) { gutsdir(a2, JIBS6, 24, myconnectindex); S_PlayActorSound(SQUISHED, a2); - deletesprite(a2); + a2->Destroy(); } } } @@ -2383,7 +2372,7 @@ void handle_se02(DDukeActor* actor) { actor->temp_data[0] = -1; //Stop the quake actor->temp_data[4] = -1; - deletesprite(actor); + actor->Destroy(); return; } else @@ -2530,7 +2519,7 @@ void handle_se04(DDukeActor *actor) } if (actor->temp_data[4]) - deletesprite(actor); + actor->Destroy(); } @@ -2646,7 +2635,7 @@ void handle_se08(DDukeActor *actor, bool checkhitag1) actor->temp_data[4]++; if (actor->temp_data[4] > 8) { - deletesprite(actor); + actor->Destroy(); return; } goal = 1; @@ -2848,7 +2837,7 @@ void handle_se12(DDukeActor *actor, int planeonly) if (actor->temp_data[3] == 1) { - deletesprite(actor); + actor->Destroy(); return; } } @@ -2951,7 +2940,7 @@ void handle_se13(DDukeActor* actor) actor->temp_data[2]++; if (actor->temp_data[2] > 256) { - deletesprite(actor); + actor->Destroy(); return; } } @@ -3029,7 +3018,7 @@ void handle_se16(DDukeActor* actor, int REACTOR, int REACTOR2) } if (a2 == nullptr) { - deletesprite(actor); + actor->Destroy(); return; } else actor->spr.shade = 1; @@ -3175,7 +3164,7 @@ void handle_se18(DDukeActor *actor, bool morecheck) if (sc->ceilingz <= goal) { sc->setceilingz(goal); - deletesprite(actor); + actor->Destroy(); return; } } @@ -3201,7 +3190,7 @@ void handle_se18(DDukeActor *actor, bool morecheck) if (sc->floorz >= goal) { sc->setfloorz(goal); - deletesprite(actor); + actor->Destroy(); return; } } @@ -3214,7 +3203,7 @@ void handle_se18(DDukeActor *actor, bool morecheck) if (sc->ceilingz >= actor->spr.pos.Z) { sc->setceilingz(actor->spr.pos.Z); - deletesprite(actor); + actor->Destroy(); return; } } @@ -3240,7 +3229,7 @@ void handle_se18(DDukeActor *actor, bool morecheck) if (sc->floorz <= actor->spr.pos.Z) { sc->setfloorz(actor->spr.pos.Z); - deletesprite(actor); + actor->Destroy(); return; } } @@ -3322,7 +3311,7 @@ void handle_se19(DDukeActor *actor, int BIGFORCE) a2Owner->temp_data[0] = 2; } } - deletesprite(actor); + actor->Destroy(); return; } } @@ -3459,7 +3448,7 @@ void handle_se21(DDukeActor* actor) if (abs(lp - actor->spr.pos.Z) < 4) { lp = actor->spr.pos.Z; - deletesprite(actor); + actor->Destroy(); } if (actor->spr.intangle == 1536) @@ -3843,7 +3832,7 @@ void handle_se128(DDukeActor *actor) wal->cstat &= (CSTAT_WALL_TRANSLUCENT | CSTAT_WALL_1WAY | CSTAT_WALL_XFLIP | CSTAT_WALL_ALIGN_BOTTOM | CSTAT_WALL_BOTTOM_SWAP); if (nextwal) nextwal->cstat &= (CSTAT_WALL_TRANSLUCENT | CSTAT_WALL_1WAY | CSTAT_WALL_XFLIP | CSTAT_WALL_ALIGN_BOTTOM | CSTAT_WALL_BOTTOM_SWAP); - deletesprite(actor); + actor->Destroy(); } } @@ -3859,7 +3848,7 @@ void handle_se130(DDukeActor *actor, int countmax, int EXPLOSION2) if (actor->temp_data[0] > countmax) { - deletesprite(actor); + actor->Destroy(); return; } else actor->temp_data[0]++; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 36db7f01c..e834d24d5 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -780,7 +780,7 @@ void movefallers_d(void) { j = 1 + (krand() & 7); for (int x = 0; x < j; x++) RANDOMSCRAP(act); - deletesprite(act); + act->Destroy(); } } } @@ -801,9 +801,9 @@ void movestandables_d(void) { int picnum = act->spr.picnum; - if (!act->insector()) + if (!act->insector() || actorflag(act, SFLAG2_DIENOW)) { - deletesprite(act); + act->Destroy(); continue; } @@ -848,7 +848,7 @@ static bool movefireball(DDukeActor* actor) if (actor->sector()->lotag == 2) { - deletesprite(actor); + actor->Destroy(); return true; } @@ -909,7 +909,7 @@ static bool weaponhitsprite(DDukeActor* proj, DDukeActor *targ, bool fireball) spawned->spr.scale = DVector2(0.5, 0.5); } - deletesprite(proj); + proj->Destroy(); return true; } @@ -1006,7 +1006,7 @@ static bool weaponhitsector(DDukeActor* proj, const DVector3& oldpos, bool fireb if (proj->sector()->ceilingstat & CSTAT_SECTOR_SKY) if (proj->sector()->ceilingpal == 0) { - deletesprite(proj); + proj->Destroy(); return true; } @@ -1021,7 +1021,7 @@ static bool weaponhitsector(DDukeActor* proj, const DVector3& oldpos, bool fireb spawned->SetHitOwner(proj); spawned->spr.yint = proj->spr.yint; } - deletesprite(proj); + proj->Destroy(); return true; } @@ -1091,7 +1091,7 @@ static void weaponcommon_d(DDukeActor* proj) if (!proj->insector()) { - deletesprite(proj); + proj->Destroy(); return; } @@ -1201,7 +1201,7 @@ static void weaponcommon_d(DDukeActor* proj) } if (proj->spr.picnum != COOLEXPLOSION1) { - deletesprite(proj); + proj->Destroy(); return; } } @@ -1210,7 +1210,7 @@ static void weaponcommon_d(DDukeActor* proj) proj->spr.shade++; if (proj->spr.shade >= 40) { - deletesprite(proj); + proj->Destroy(); return; } } @@ -1229,19 +1229,15 @@ void moveweapons_d(void) DukeStatIterator it(STAT_PROJECTILE); while (auto act = it.Next()) { - if (!act->insector()) + if (!act->insector() || actorflag(act, SFLAG2_DIENOW)) { - deletesprite(act); + act->Destroy(); continue; } switch(act->spr.picnum) { - case RADIUSEXPLOSION: - case KNEE: - deletesprite(act); - continue; case TONGUE: movetongue(act, TONGUE, INNERJAW); continue; @@ -1255,7 +1251,7 @@ void moveweapons_d(void) spawned->spr.pal = 1; spawned->spr.scale = DVector2(0.5, 0.5); } - deletesprite(act); + act->Destroy(); continue; } [[fallthrough]]; @@ -1614,7 +1610,7 @@ static void greenslime(DDukeActor *actor) if (sectp->floorstat & CSTAT_SECTOR_SKY) { - deletesprite(actor); + actor->Destroy(); return; } @@ -1662,7 +1658,7 @@ static void greenslime(DDukeActor *actor) } ps[p].actors_killed++; S_PlayActorSound(GLASS_BREAKING, actor); - deletesprite(actor); + actor->Destroy(); } else if (xx < 64 && ps[p].quick_kick == 0) { @@ -1718,7 +1714,7 @@ static void greenslime(DDukeActor *actor) actor->temp_data[0] = -3; if (ps[p].somethingonplayer == actor) ps[p].somethingonplayer = nullptr; - deletesprite(actor); + actor->Destroy(); return; } @@ -1823,7 +1819,7 @@ static void greenslime(DDukeActor *actor) } } actor->temp_data[0] = -3; - deletesprite(actor); + actor->Destroy(); return; } // All weap @@ -2007,7 +2003,7 @@ static void flamethrowerflame(DDukeActor *actor) if (sectp->lotag == 2) { spawn(actor, EXPLOSION2)->spr.shade = 127; - deletesprite(actor); + actor->Destroy(); return; } @@ -2027,7 +2023,7 @@ static void flamethrowerflame(DDukeActor *actor) if (actor->temp_data[0] > 30) { spawn(actor, EXPLOSION2)->spr.shade = 127; - deletesprite(actor); + actor->Destroy(); return; } @@ -2036,7 +2032,7 @@ static void flamethrowerflame(DDukeActor *actor) if (!actor->insector()) { - deletesprite(actor); + actor->Destroy(); return; } @@ -2245,7 +2241,7 @@ DETONATEB: { if (Owner != actor || ud.respawn_items == 0) { - deletesprite(actor); + actor->Destroy(); return; } else @@ -2288,7 +2284,7 @@ DETONATEB: if (Owner == actor && ud.coop >= 1) return; - deletesprite(actor); + actor->Destroy(); return; } else @@ -2318,9 +2314,9 @@ void moveactors_d(void) { auto sectp = act->sector(); - if (act->spr.scale.X == 0 || sectp == nullptr) + if (act->spr.scale.X == 0 || sectp == nullptr || actorflag(act, SFLAG2_DIENOW)) { - deletesprite(act); + act->Destroy(); continue; } @@ -2402,7 +2398,7 @@ void moveactors_d(void) for (int j = 0; j < 32; j++) RANDOMSCRAP(act); earthquaketime = 16; - deletesprite(act); + act->Destroy(); continue; } else if ((act->temp_data[0] & 3) == 0) @@ -2495,7 +2491,7 @@ static void fireflyflyingeffect(DDukeActor *actor) auto Owner = actor->GetOwner(); if (!Owner || Owner->spr.picnum != FIREFLY) { - deletesprite(actor); + actor->Destroy(); return; } @@ -2512,7 +2508,7 @@ static void fireflyflyingeffect(DDukeActor *actor) if (Owner->spr.extra <= 0) { - deletesprite(actor); + actor->Destroy(); } } @@ -2532,7 +2528,7 @@ void moveexplosions_d(void) // STATNUM 5 { if (!act->insector() || act->spr.scale.X == 0) { - deletesprite(act); + act->Destroy(); continue; } @@ -2616,12 +2612,12 @@ void moveexplosions_d(void) // STATNUM 5 act->spr.extra = 999; else { - deletesprite(act); + act->Destroy(); continue; } break; case TONGUE: - deletesprite(act); + act->Destroy(); continue; case MONEY + 1: case MAIL + 1: @@ -3227,7 +3223,7 @@ void move_d(DDukeActor *actor, int playernum, int xvel) else actor->spr.shade += (actor->sector()->floorshade - actor->spr.shade) >> 1; if (actor->sector()->floorpicnum == MIRROR) - deletesprite(actor); + actor->Destroy(); } } diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index b5b7ec80a..baeb915c4 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -647,7 +647,7 @@ void movefallers_r(void) { int j = 1 + (krand() & 7); for (int x = 0; x < j; x++) RANDOMSCRAP(act); - deletesprite(act); + act->Destroy(); } } } @@ -656,13 +656,7 @@ void movefallers_r(void) //--------------------------------------------------------------------------- // -// split out of movestandables // -//--------------------------------------------------------------------------- - -//--------------------------------------------------------------------------- -// -// this has been broken up into lots of smaller subfunctions // //--------------------------------------------------------------------------- @@ -673,9 +667,9 @@ void movestandables_r(void) { int picnum = act->spr.picnum; - if (!act->insector()) + if (!act->insector() || actorflag(act, SFLAG2_DIENOW)) { - deletesprite(act); + act->Destroy(); continue; } @@ -784,7 +778,7 @@ static bool weaponhitsprite(DDukeActor *proj, DDukeActor *targ, const DVector3 & star->spr.scale = DVector2(0.5, 0.5); } - deletesprite(proj); + proj->Destroy(); return true; } @@ -874,7 +868,7 @@ static bool weaponhitwall(DDukeActor *proj, walltype* wal, const DVector3& oldpo { if (wal->picnum >= RRTILE3643 && wal->picnum < RRTILE3643 + 3) { - deletesprite(proj); + proj->Destroy(); } if (proj->spr.extra <= 0) { @@ -891,7 +885,7 @@ static bool weaponhitwall(DDukeActor *proj, walltype* wal, const DVector3& oldpo j->clipdist = proj->spr.scale.X * tileWidth(proj->spr.picnum) * 0.125; } } - deletesprite(proj); + proj->Destroy(); return true; } if (wal->overpicnum != MIRROR && wal->picnum != MIRROR) @@ -931,7 +925,7 @@ bool weaponhitsector(DDukeActor *proj, const DVector3& oldpos) if (proj->sector()->ceilingstat & CSTAT_SECTOR_SKY) if (proj->sector()->ceilingpal == 0) { - deletesprite(proj); + proj->Destroy(); return true; } @@ -1022,7 +1016,7 @@ static void weaponcommon_r(DDukeActor *proj) if (!proj->insector()) // || (isRR() && proj->sector()->filler == 800)) { - deletesprite(proj); + proj->Destroy(); return; } @@ -1099,7 +1093,7 @@ static void weaponcommon_r(DDukeActor *proj) } } } - deletesprite(proj); + proj->Destroy(); return; } if ((proj->spr.picnum == RPG || (isRRRA() && proj->spr.picnum == RPG2)) && proj->sector()->lotag == 2 && proj->spr.scale.X >= 0.15625 && rnd(184)) @@ -1118,17 +1112,14 @@ void moveweapons_r(void) DukeStatIterator it(STAT_PROJECTILE); while (auto proj = it.Next()) { - if (!proj->insector()) + if (!proj->insector() || actorflag(proj, SFLAG2_DIENOW)) { - deletesprite(proj); + proj->Destroy(); continue; } switch (proj->spr.picnum) { - case RADIUSEXPLOSION: - deletesprite(proj); - continue; case TONGUE: movetongue(proj, TONGUE, INNERJAW); continue; @@ -1142,7 +1133,7 @@ void moveweapons_r(void) star->spr.pal = 1; star->spr.scale = DVector2(0.5, 0.5); } - deletesprite(proj); + proj->Destroy(); continue; } [[fallthrough]]; @@ -1572,7 +1563,7 @@ static void rrra_specialstats() if (act->spr.extra <= -104) { spawn(act, act->spr.lotag); - deletesprite(act); + act->Destroy(); } } movesprite_ex(act, DVector3(0, 0, act->spr.extra / 128.), CLIPMASK0, coll); @@ -1716,12 +1707,12 @@ static void rrra_specialstats() if (j > 0) { S_PlayActorSound(PIPEBOMB_EXPLODE, act); - deletesprite(act); + act->Destroy(); } if (act->spr.extra == 0) { S_PlaySound(215); - deletesprite(act); + act->Destroy(); earthquaketime = 32; SetPlayerPal(&ps[myconnectindex], PalEntry(32, 32, 32, 48)); } @@ -2063,7 +2054,7 @@ void rr_specialstats() ChangeActorSect(pact, act2->sector()); ps[p].setCursector(pact->sector()); S_PlayActorSound(70, act2); - deletesprite(act2); + act2->Destroy(); } } } @@ -2247,13 +2238,13 @@ DETONATEB: if (actor->temp_data[4] > 20) { - deletesprite(actor); + actor->Destroy(); return; } if (actor->spr.picnum == CHEERBOMB) { spawn(actor, BURNING); - deletesprite(actor); + actor->Destroy(); return; } } @@ -2288,7 +2279,7 @@ DETONATEB: { if (actor->spr.picnum == DYNAMITE && Owner->spr.picnum != APLAYER && ud.coop) return; - deletesprite(actor); + actor->Destroy(); return; } else @@ -2316,7 +2307,7 @@ static int henstand(DDukeActor *actor) if (actor->spr.lotag == 0) { spawn(actor, HEN); - deletesprite(actor); + actor->Destroy(); return 1; } } @@ -2341,7 +2332,7 @@ static int henstand(DDukeActor *actor) if (hitact->spr.picnum == HEN) { auto ns = spawn(hitact, HENSTAND); - deletesprite(hitact); + hitact->Destroy(); if (ns) { ns->vel.X = 2; @@ -2368,18 +2359,18 @@ static int henstand(DDukeActor *actor) if (krand() & 1) actor->spr.picnum = HENSTAND + 1; if (actor->vel.X == 0) - return 2;//deletesprite(actor); still needs to run a script but should not do on a deleted object + return 2;//actor->Destroy(); still needs to run a script but should not do on a deleted object } if (actor->spr.picnum == BOWLINGPIN || (actor->spr.picnum == BOWLINGPIN + 1 && actor->vel.X == 0)) { - return 2;//deletesprite(actor); still needs to run a script but should not do on a deleted object + return 2;//actor->Destroy(); still needs to run a script but should not do on a deleted object } } else if (actor->sector()->lotag == 900) { if (actor->spr.picnum == BOWLINGBALL) ballreturn(actor); - deletesprite(actor); + actor->Destroy(); return 1; } return 0; @@ -2411,9 +2402,9 @@ void moveactors_r(void) { bool deleteafterexecute = false; // taking a cue here from RedNukem to not run scripts on deleted sprites. - if( act->spr.scale.X == 0 || !act->insector()) + if( act->spr.scale.X == 0 || !act->insector() || actorflag(act, SFLAG2_DIENOW)) { - deletesprite(act); + act->Destroy(); continue; } @@ -2438,7 +2429,7 @@ void moveactors_r(void) case RRTILE3192: if (!chickenplant) { - deletesprite(act); + act->Destroy(); continue; } if (sectp->lotag == 903) @@ -2455,18 +2446,18 @@ void moveactors_r(void) case 903: if (act->spr.pos.Z >= sectp->floorz - 8) { - deletesprite(act); + act->Destroy(); continue; } break; case 904: - deletesprite(act); + act->Destroy(); continue; break; } if (coll.type > kHitSector) { - deletesprite(act); + act->Destroy(); continue; } break; @@ -2477,27 +2468,27 @@ void moveactors_r(void) case RRTILE3124: if (!chickenplant) { - deletesprite(act); + act->Destroy(); continue; } makeitfall(act); movesprite_ex(act, DVector3(act->spr.angle.ToVector() * act->vel.X, act->vel.Z), CLIPMASK0, coll); if (coll.type > kHitSector) { - deletesprite(act); + act->Destroy(); continue; } if (sectp->lotag == 903) { if (act->spr.pos.Z >= sectp->floorz - 4) { - deletesprite(act); + act->Destroy(); continue; } } else if (sectp->lotag == 904) { - deletesprite(act); + act->Destroy(); continue; } break; @@ -2505,7 +2496,7 @@ void moveactors_r(void) case RRTILE3132: if (!chickenplant) { - deletesprite(act); + act->Destroy(); continue; } makeitfall(act); @@ -2517,7 +2508,7 @@ void moveactors_r(void) auto j = spawn(act, WATERSPLASH2); if (j) j->spr.pos.Z = j->sector()->floorz; } - deletesprite(act); + act->Destroy(); continue; } break; @@ -2530,7 +2521,7 @@ void moveactors_r(void) else { spawn(act,BOWLINGBALLSPRITE); - deletesprite(act); + act->Destroy(); continue; } if (act->sector()->lotag == 900) @@ -2644,7 +2635,7 @@ void moveactors_r(void) p = findplayer(act, &xx); execute(act,p,xx); - if (deleteafterexecute) deletesprite(act); + if (deleteafterexecute) act->Destroy(); } } @@ -2670,7 +2661,7 @@ void moveexplosions_r(void) // STATNUM 5 if (!act->insector() || act->spr.scale.X == 0) { - deletesprite(act); + act->Destroy(); continue; } @@ -2686,7 +2677,7 @@ void moveexplosions_r(void) // STATNUM 5 if (act->sector()->lotag == 800) if (act->spr.pos.Z >= act->sector()->floorz - 8) { - deletesprite(act); + act->Destroy(); continue; } break; @@ -2721,7 +2712,7 @@ void moveexplosions_r(void) // STATNUM 5 { if (sectp->floorpicnum != 3073) { - deletesprite(act); + act->Destroy(); continue; } if (S_CheckSoundPlaying(22)) @@ -2733,7 +2724,7 @@ void moveexplosions_r(void) // STATNUM 5 act->temp_data[1]++; } if (act->temp_data[1] == 5) - deletesprite(act); + act->Destroy(); continue; case WATERSPLASH2: @@ -2762,18 +2753,18 @@ void moveexplosions_r(void) // STATNUM 5 act->spr.extra = 999; else { - deletesprite(act); + act->Destroy(); continue; } break; case TONGUE: - deletesprite(act); + act->Destroy(); continue; case FEATHER + 1: // feather act->spr.pos.Z = act->floorz = getflorzofslopeptr(act->sector(), act->spr.pos.X, act->spr.pos.Y); if (act->sector()->lotag == 800) { - deletesprite(act); + act->Destroy(); continue; } break; @@ -2783,7 +2774,7 @@ void moveexplosions_r(void) // STATNUM 5 if (act->sector()->lotag == 800) if (act->spr.pos.Z >= act->sector()->floorz - 8) { - deletesprite(act); + act->Destroy(); continue; } @@ -2838,7 +2829,7 @@ void moveexplosions_r(void) // STATNUM 5 if (act->sector()->lotag == 800) if (act->spr.pos.Z >= act->sector()->floorz - 8) { - deletesprite(act); + act->Destroy(); continue; } @@ -2850,7 +2841,7 @@ void moveexplosions_r(void) // STATNUM 5 if (act->sector()->lotag == 800) if (act->spr.pos.Z >= act->sector()->floorz - 8) { - deletesprite(act); + act->Destroy(); } continue; @@ -2933,7 +2924,7 @@ void handle_se06_r(DDukeActor *actor) ns->spr.cstat |= CSTAT_SPRITE_INVISIBLE; ns->spr.pos.Z = actor->sector()->floorz - 24; } - deletesprite(actor); + actor->Destroy(); return; } } @@ -3492,7 +3483,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel) else actor->spr.shade += (actor->sector()->floorshade - actor->spr.shade) >> 1; if (actor->sector()->floorpicnum == MIRROR) - deletesprite(actor); + actor->Destroy(); } } @@ -3705,7 +3696,7 @@ void destroyit(DDukeActor *actor) case COOT: break; default: - deletesprite(a2); + a2->Destroy(); break; } } diff --git a/source/games/duke/src/bowling.cpp b/source/games/duke/src/bowling.cpp index 80824cb97..cde04afdc 100644 --- a/source/games/duke/src/bowling.cpp +++ b/source/games/duke/src/bowling.cpp @@ -170,7 +170,7 @@ void resetpins(sectortype* sect) while (auto a2 = it.Next()) { if (a2->spr.picnum == BOWLINGPIN) - deletesprite(a2); + a2->Destroy(); } it.Reset(sect); while (auto a2 = it.Next()) diff --git a/source/games/duke/src/ccmds.cpp b/source/games/duke/src/ccmds.cpp index f548707af..67ab599d4 100644 --- a/source/games/duke/src/ccmds.cpp +++ b/source/games/duke/src/ccmds.cpp @@ -103,8 +103,8 @@ static int ccmd_spawn(CCmdFuncPtr parm) if (spawned->sector() == nullptr) { - Printf("spawn: Sprite can't be spawned into null space\n"); - deletesprite(spawned); + Printf("spawn: Sprite cannot be spawned into null space\n"); + spawned->Destroy(); } } diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index c25baa9ab..8075138dc 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -361,6 +361,7 @@ enum sflags2_t SFLAG2_INTERPOLATEANGLE = 0x00000400, SFLAG2_GREENBLOOD = 0x00000800, SFLAG2_ALWAYSROTATE1 = 0x00001000, + SFLAG2_DIENOW = 0x00002000, }; using EDukeFlags2 = TFlags; diff --git a/source/games/duke/src/flags_d.cpp b/source/games/duke/src/flags_d.cpp index 1b2a0805d..0e3265612 100644 --- a/source/games/duke/src/flags_d.cpp +++ b/source/games/duke/src/flags_d.cpp @@ -226,6 +226,7 @@ void initactorflags_d() setflag(SFLAG2_INTERPOLATEANGLE, { BEARINGPLATE }); setflag(SFLAG2_GREENBLOOD, { OOZFILTER, NEWBEAST }); setflag(SFLAG2_ALWAYSROTATE1, { RAT, CAMERA1 }); + setflag(SFLAG2_DIENOW, { RADIUSEXPLOSION, KNEE }); if (isWorldTour()) { diff --git a/source/games/duke/src/flags_r.cpp b/source/games/duke/src/flags_r.cpp index 1b06cd13f..37ae5bbc4 100644 --- a/source/games/duke/src/flags_r.cpp +++ b/source/games/duke/src/flags_r.cpp @@ -253,6 +253,8 @@ void initactorflags_r() setflag(SFLAG2_CAMERA, { CAMERA1 }); setflag(SFLAG2_GREENBLOOD, { OOZFILTER }); setflag(SFLAG2_ALWAYSROTATE1, { RAT, CAMERA1 }); + setflag(SFLAG2_DIENOW, { RADIUSEXPLOSION }); + // Animals were not supposed to have this, but due to a coding bug the logic was unconditional for everything in the game. for (auto& ainf : gs.actorinfo) diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 9879a441c..26fff59a4 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -94,7 +94,6 @@ int dodge(DDukeActor*); void alterang(int ang, DDukeActor* actor, int g_p); void fall_common(DDukeActor* actor, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOTSPARK1, int squished, int thud, int(*fallspecial)(DDukeActor*, int)); void checkavailweapon(player_struct* p); -void deletesprite(DDukeActor* num); void addammo(int weapon, player_struct* p, int amount); int ssp(DDukeActor* i, unsigned int cliptype); //The set sprite function diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 559a53d8f..8d4617d55 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -3660,7 +3660,7 @@ void LoadActor(DDukeActor *actor, int p, int x) if(!actor->insector()) { - deletesprite(actor); + actor->Destroy(); return; } do @@ -3675,7 +3675,7 @@ void LoadActor(DDukeActor *actor, int p, int x) if (ps[p].actorsqu == actor) ps[p].actorsqu = nullptr; } - deletesprite(actor); + actor->Destroy(); } else { @@ -3726,7 +3726,7 @@ void execute(DDukeActor *actor,int p,double xx) { if(badguy(actor)) ps[p].actors_killed++; - deletesprite(actor); + actor->Destroy(); return; } @@ -3783,7 +3783,7 @@ void execute(DDukeActor *actor,int p,double xx) } } quit: - if (killthesprite) deletesprite(actor); + if (killthesprite) actor->Destroy(); killthesprite = false; } diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 8b4d1a941..f401d26e0 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -404,10 +404,10 @@ void dokneeattack(int snum, const std::initializer_list & respawnlist) } else if (badguy(p->actorsqu)) { - deletesprite(p->actorsqu); + p->actorsqu->Destroy(); p->actors_killed++; } - else deletesprite(p->actorsqu); + else p->actorsqu->Destroy(); } p->actorsqu = nullptr; } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 45e8e95c4..f0074a81a 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3994,7 +3994,7 @@ void OnMotorcycle(player_struct *p, DDukeActor* motosprite) p->pos.Y = motosprite->spr.pos.Y; p->angle.ang = motosprite->spr.angle; p->ammo_amount[MOTORCYCLE_WEAPON] = motosprite->saved_ammo; - deletesprite(motosprite); + motosprite->Destroy(); } p->over_shoulder_on = 0; p->OnMotorcycle = 1; @@ -4069,7 +4069,7 @@ void OnBoat(player_struct *p, DDukeActor* boat) p->pos.Y = boat->spr.pos.Y; p->angle.ang = boat->spr.angle; p->ammo_amount[BOAT_WEAPON] = boat->saved_ammo; - deletesprite(boat); + boat->Destroy(); } p->over_shoulder_on = 0; p->OnBoat = 1; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 65e764f56..3fd06606b 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -632,7 +632,7 @@ void resetpspritevars(int g) j = connectpoint2[j]; } - else deletesprite(act); + else act->Destroy(); } } diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index 5c2e71f72..115477417 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -429,7 +429,7 @@ void prelevel_r(int g, TArray& actors) if (actor->spr.pal == 100) { if (numplayers > 1) - deletesprite(actor); + actor->Destroy(); else actor->spr.pal = 0; } @@ -461,12 +461,12 @@ void prelevel_r(int g, TArray& actors) { dist = act->spr.lotag; speed = act->spr.hitag; - deletesprite(act); + act->Destroy(); } if (act->spr.picnum == RRJAILDOORSOUND) { sound = act->spr.lotag; - deletesprite(act); + act->Destroy(); } } if (dist == 0) @@ -508,15 +508,15 @@ void prelevel_r(int g, TArray& actors) if (act1->spr.lotag == act->sectno()) // bad map format design... Should have used a tag instead... { childsectnum = act1->sector(); - deletesprite(act1); + act1->Destroy(); } } - deletesprite(act); + act->Destroy(); } if (act->spr.picnum == RRMINECARTSOUND) { sound = act->spr.lotag; - deletesprite(act); + act->Destroy(); } } addminecart(dist, speed, sectp, sectp->hitag, sound, childsectnum); @@ -592,11 +592,11 @@ void prelevel_r(int g, TArray& actors) if (actor->spr.picnum == SECTOREFFECTOR && actor->spr.lotag == SE_14_SUBWAY_CAR) spriteinit_r(actor, actors); if (actor->spr.picnum == RRTILE19) - deletesprite(actor); + actor->Destroy(); if (actor->spr.picnum == RRTILE34) { actor->sector()->keyinfo = uint8_t(actor->spr.lotag); - deletesprite(actor); + actor->Destroy(); } } } diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index c3b70213e..98068ff84 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1105,7 +1105,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) break; S_PlayActorSound(GLASS_BREAKING, targ); lotsofglass(targ, nullptr, 10); - deletesprite(targ); + targ->Destroy(); return; case OCEANSPRITE1: @@ -1114,7 +1114,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) case OCEANSPRITE4: case OCEANSPRITE5: spawn(targ, SMALLSMOKE); - deletesprite(targ); + targ->Destroy(); break; case QUEBALL: case STRIPEBALL: @@ -1136,7 +1136,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) else { lotsofglass(targ, nullptr, 3); - deletesprite(targ); + targ->Destroy(); } } break; @@ -1151,7 +1151,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) if (spawned) spawned->spriteextra = Scrap1 + krand() & 15; } S_PlayActorSound(GLASS_HEAVYBREAK, targ); - deletesprite(targ); + targ->Destroy(); break; @@ -1182,7 +1182,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) } spawn(targ, EXPLOSION2); - deletesprite(targ); + targ->Destroy(); } break; case BOTTLE1: @@ -1225,7 +1225,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) S_PlayActorSound(GLASS_BREAKING, targ); targ->spr.angle = randomAngle(); lotsofglass(targ, nullptr, 8); - deletesprite(targ); + targ->Destroy(); break; case FETUS: targ->spr.picnum = FETUSBROKE; @@ -1244,7 +1244,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) case BOTTLE7: S_PlayActorSound(GLASS_BREAKING, targ); lotsofglass(targ, nullptr, 10); - deletesprite(targ); + targ->Destroy(); break; case HYDROPLANT: targ->spr.picnum = BROKEHYDROPLANT; @@ -1372,7 +1372,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) fi.guts(targ, JIBS5, 1, myconnectindex); fi.guts(targ, JIBS3, 6, myconnectindex); S_PlaySound(SQUISHED); - deletesprite(targ); + targ->Destroy(); break; } case CHAIR1: @@ -1392,7 +1392,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) case TRIPODCAMERA: S_PlayActorSound(GLASS_HEAVYBREAK, targ); for (j = 0; j < 16; j++) RANDOMSCRAP(targ); - deletesprite(targ); + targ->Destroy(); break; case PLAYERONWATER: targ = targ->GetOwner(); diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 1759aefce..9323ae09e 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -490,7 +490,6 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act) break; case RRTILE2214: - //if (ud.level_numbe r > 6) ud.level_numbe r = 0; ??? Looks like some leftover garbage. other->spr.picnum++; break; case RRTILE8660: @@ -528,7 +527,7 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act) S_PlayActorSound(474, other2); } else if (other2->spr.picnum == RRTILE295) - deletesprite(other2); + other2->Destroy(); } other->spr.picnum++; break; @@ -1057,7 +1056,7 @@ void checkhitwall_r(DDukeActor* spr, walltype* wal, const DVector3& pos, int atw act->sector()->lotag = 0; S_StopSound(act->spr.lotag); S_PlayActorSound(400, act); - deletesprite(act); + act->Destroy(); } } } @@ -2010,7 +2009,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) case RRTILE2455: S_PlayActorSound(SQUISHED, targ); fi.guts(targ, RRTILE2465, 3, myconnectindex); - deletesprite(targ); + targ->Destroy(); break; case RRTILE2451: if (targ->spr.pal != 4) @@ -2179,7 +2178,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) if (spawned) spawned->spriteextra = Scrap1 + krand() & 15; } spawn(targ, EXPLOSION2); - deletesprite(targ); + targ->Destroy(); } break; case RRTILE1824: @@ -2225,7 +2224,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) S_PlayActorSound(GLASS_BREAKING, targ); targ->spr.angle = randomAngle(); lotsofglass(targ, nullptr, 8); - deletesprite(targ); + targ->Destroy(); break; case RRTILE2654: case RRTILE2656: @@ -2235,7 +2234,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) case BOTTLE7: S_PlayActorSound(GLASS_BREAKING, targ); lotsofglass(targ, nullptr, 10); - deletesprite(targ); + targ->Destroy(); break; case FORCESPHERE: { @@ -2322,7 +2321,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) case POT3: S_PlayActorSound(GLASS_HEAVYBREAK, targ); for (j = 0; j < 16; j++) RANDOMSCRAP(targ); - deletesprite(targ); + targ->Destroy(); break; case PLAYERONWATER: targ = targ->GetOwner();