From 1e00a4ff1815de4915f11a95f9aa0edcbd431639 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 2 Nov 2021 20:58:26 +0100 Subject: [PATCH] - second batch of sector.cpp --- source/games/sw/src/ai.cpp | 14 ---------- source/games/sw/src/sector.cpp | 48 ++++++++++++++++------------------ source/games/sw/src/sector.h | 2 +- source/games/sw/src/weapon.cpp | 14 +--------- 4 files changed, 24 insertions(+), 54 deletions(-) diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index 087b184b4..ba3e2324f 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -495,20 +495,6 @@ int DoActorOperate(DSWActor* actor) &nearsector, &nearwall, &nearsprite, &nearhitdist, 1024L, NTAG_SEARCH_LO_HI, nullptr); - //DSPRINTF(ds,"nearsector = %d, nearwall = %d, nearsprite = %d hitdist == %ld\n",nearsector,nearwall,nearsprite,nearhitdist); - //MONO_PRINT(ds); - -#if 0 // Actors don't hit switches on a whim - if (nearsprite >= 0 && nearhitdist < 1024) - { - if (OperateSprite(nearsprite, false)) - { - u->WaitTics = 2 * 120; - - NewStateGroup(actor, u->ActorActionSet->Stand); - } - } -#endif } diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index fa9aa8122..cbb07bbe8 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -954,7 +954,7 @@ short AnimateSwitch(SPRITEp sp, short tgt_value) sp->picnum -= 1; - if (tgt_value == true) + if (tgt_value == int(true)) { AnimateSwitch(sp, tgt_value); return true; @@ -1312,10 +1312,10 @@ void KillMatchingCrackSprites(short match) } } -void WeaponExplodeSectorInRange(short weapon) +void WeaponExplodeSectorInRange(DSWActor* wActor) { - SPRITEp wp = &sprite[weapon]; - USERp wu = User[weapon].Data(); + SPRITEp wp = &wActor->s(); + USERp wu = wActor->u(); SPRITEp sp; int dist; int radius; @@ -1341,7 +1341,7 @@ void WeaponExplodeSectorInRange(short weapon) // pass in explosion type - MissileHitMatch(weapon, WPN_ROCKET, actor->GetSpriteIndex()); + MissileHitMatch(wActor->GetSpriteIndex(), WPN_ROCKET, actor->GetSpriteIndex()); } } @@ -1382,28 +1382,27 @@ void DoDeleteSpriteMatch(short match) }; int del_x = 0,del_y = 0; - int i; unsigned stat; - short found; while (true) { - found = -1; + DSWActor* found = nullptr; // search for a DELETE_SPRITE with same match tag - StatIterator it(STAT_DELETE_SPRITE); - while ((i = it.NextIndex()) >= 0) + SWStatIterator it(STAT_DELETE_SPRITE); + while (auto actor = it.Next()) { - if (sprite[i].lotag == match) + auto sp = &actor->s(); + if (sp->lotag == match) { - found = i; - del_x = sprite[i].x; - del_y = sprite[i].y; + found = actor; + del_x = sp->x; + del_y = sp->y; break; } } - if (found == -1) + if (found == nullptr) return; for (stat = 0; stat < SIZ(StatList); stat++) @@ -1431,20 +1430,19 @@ void DoDeleteSpriteMatch(short match) } // kill the DELETE_SPRITE - KillSprite(found); + KillActor(found); } } void DoChangorMatch(short match) { - int sn; SPRITEp sp; SECTORp sectp; - StatIterator it(STAT_CHANGOR); - while ((sn = it.NextIndex()) >= 0) + SWStatIterator it(STAT_CHANGOR); + while (auto actor = it.Next()) { - sp = &sprite[sn]; + auto sp = &actor->s(); sectp = §or[sp->sectnum]; if (SP_TAG2(sp) != match) @@ -1484,7 +1482,7 @@ void DoChangorMatch(short match) // if not set then go ahead and kill it if (TEST_BOOL2(sp) == 0) { - KillSprite(sn); + KillActor(actor); } } } @@ -1541,14 +1539,12 @@ void DoMatchEverything(PLAYERp pp, short match, short state) bool ComboSwitchTest(short combo_type, short match) { - int i; - SPRITEp sp; int state; - StatIterator it(STAT_DEFAULT); - while ((i = it.NextIndex()) >= 0) + SWStatIterator it(STAT_DEFAULT); + while (auto actor = it.Next()) { - sp = &sprite[i]; + auto sp = &actor->s(); if (sp->lotag == combo_type && sp->hitag == match) { diff --git a/source/games/sw/src/sector.h b/source/games/sw/src/sector.h index 5575128f6..2d2656be3 100644 --- a/source/games/sw/src/sector.h +++ b/source/games/sw/src/sector.h @@ -73,7 +73,7 @@ void DoSector(void); short AnimateSwitch(SPRITEp sp,short tgt_value); void ShootableSwitch(short SpriteNum); bool TestKillSectorObject(SECTOR_OBJECTp sop); -void WeaponExplodeSectorInRange(short weapon); +void WeaponExplodeSectorInRange(DSWActor*); void initlava(void); void movelava(char *dapic); diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index f08ab01a2..53a1916f6 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -3469,16 +3469,10 @@ AutoShrap: short spnum; short size; SPRITEp ep; -// USERp eu; spnum = SpawnLargeExp(ParentNum); ASSERT(spnum >= 0); - //spnum = SpawnSectorExp(ParentNum); ep = &sprite[spnum]; -// eu = User[spnum]; - - //eu->xchange = MOVEx(92, ep->ang); - //eu->ychange = MOVEy(92, ep->ang); size = ep->xrepeat; ep->xrepeat = ep->yrepeat = size + shrap_delta_size; @@ -3491,16 +3485,10 @@ AutoShrap: short spnum; short size; SPRITEp ep; -// USERp eu; - //spnum = SpawnSectorExp(ParentNum); spnum = SpawnLargeExp(ParentNum); ASSERT(spnum >= 0); ep = &sprite[spnum]; -// eu = User[spnum]; - - //eu->xchange = MOVEx(92, ep->ang); - //eu->ychange = MOVEy(92, ep->ang); size = ep->xrepeat; ep->xrepeat = ep->yrepeat = size + shrap_delta_size; @@ -7730,7 +7718,7 @@ int DoExpDamageTest(DSWActor* actor) // crack sprites if (wu->ID != MUSHROOM_CLOUD) - WeaponExplodeSectorInRange(Weapon); + WeaponExplodeSectorInRange(actor); // Just like DoDamageTest() except that it doesn't care about the Owner