From 98b06697f718b52f63e8e64079bdd56b694bfbe6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Aug 2022 16:03:46 +0200 Subject: [PATCH] - pass position pointers to DISTANCE. --- source/games/sw/src/ai.cpp | 8 +++---- source/games/sw/src/bunny.cpp | 2 +- source/games/sw/src/eel.cpp | 4 ++-- source/games/sw/src/game.h | 10 ++++----- source/games/sw/src/hornet.cpp | 4 ++-- source/games/sw/src/jweapon.cpp | 6 ++--- source/games/sw/src/player.cpp | 2 +- source/games/sw/src/sector.cpp | 2 +- source/games/sw/src/skull.cpp | 8 +++---- source/games/sw/src/sprite.cpp | 4 ++-- source/games/sw/src/weapon.cpp | 40 ++++++++++++++++----------------- 11 files changed, 45 insertions(+), 45 deletions(-) diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index 6676dcce3..835e88d8a 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -324,7 +324,7 @@ int DoActorPickClosePlayer(DSWActor* actor) // continue; } - DISTANCE(actor->int_pos().X, actor->int_pos().Y, pp->int_ppos().X, pp->int_ppos().Y, dist, a, b, c); + DISTANCE(actor->spr.pos, pp->pos, dist, a, b, c); if (dist < near_dist) { @@ -350,7 +350,7 @@ int DoActorPickClosePlayer(DSWActor* actor) continue; } - DISTANCE(actor->int_pos().X, actor->int_pos().Y, pp->int_ppos().X, pp->int_ppos().Y, dist, a, b, c); + DISTANCE(actor->spr.pos, pp->pos, dist, a, b, c); DSWActor* plActor = pp->actor; if (dist < near_dist && FAFcansee(actor->int_pos().X, actor->int_pos().Y, look_height, actor->sector(), plActor->int_pos().X, plActor->int_pos().Y, int_ActorUpperZ(plActor), plActor->sector())) @@ -377,7 +377,7 @@ TARGETACTOR: if ((itActor->user.Flags & (SPR_SUICIDE | SPR_DEAD))) continue; - DISTANCE(actor->int_pos().X, actor->int_pos().Y, itActor->int_pos().X, itActor->int_pos().Y, dist, a, b, c); + DISTANCE(actor->spr.pos, itActor->spr.pos, dist, a, b, c); if (dist < near_dist && FAFcansee(actor->int_pos().X, actor->int_pos().Y, look_height, actor->sector(), itActor->int_pos().X, itActor->int_pos().Y, int_ActorUpperZ(itActor), itActor->sector())) { @@ -1169,7 +1169,7 @@ int DoActorAttack(DSWActor* actor) DoActorNoise(ChooseAction(actor->user.Personality->Broadcast),actor); - DISTANCE(actor->int_pos().X, actor->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y, dist, a, b, c); + DISTANCE(actor->spr.pos, actor->user.targetActor->spr.pos, dist, a, b, c); auto pActor = GetPlayerSpriteNum(actor); if ((actor->user.ActorActionSet->CloseAttack[0] && dist < CloseRangeDist(actor, actor->user.targetActor)) || diff --git a/source/games/sw/src/bunny.cpp b/source/games/sw/src/bunny.cpp index e397ded1e..aeb78a3a6 100644 --- a/source/games/sw/src/bunny.cpp +++ b/source/games/sw/src/bunny.cpp @@ -903,7 +903,7 @@ void DoPickCloseBunny(DSWActor* actor) if (itActor->user.ID != BUNNY_RUN_R0) continue; - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, a, b, c); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, a, b, c); if (dist > near_dist) continue; diff --git a/source/games/sw/src/eel.cpp b/source/games/sw/src/eel.cpp index e2dda3f7a..5a609b9bc 100644 --- a/source/games/sw/src/eel.cpp +++ b/source/games/sw/src/eel.cpp @@ -459,7 +459,7 @@ int DoEelMatchPlayerZ(DSWActor* actor) double bound; if (actor->user.lowActor && actor->user.targetActor == actor->user.highActor) // this doesn't look right... { - DISTANCE(actor->int_pos().X, actor->int_pos().Y, actor->user.lowActor->int_pos().X, actor->user.lowActor->int_pos().Y, dist, a, b, c); + DISTANCE(actor->spr.pos, actor->user.lowActor->spr.pos, dist, a, b, c); if (dist <= 300) bound = actor->user.pos.Z; else @@ -476,7 +476,7 @@ int DoEelMatchPlayerZ(DSWActor* actor) // upper bound if (actor->user.highActor && actor->user.targetActor == actor->user.highActor) { - DISTANCE(actor->int_pos().X, actor->int_pos().Y, actor->user.highActor->int_pos().X, actor->user.highActor->int_pos().Y, dist, a, b, c); + DISTANCE(actor->spr.pos, actor->user.highActor->spr.pos, dist, a, b, c); if (dist <= 300) bound = actor->user.pos.Z; else diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index d604ec93f..85048ed52 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -209,12 +209,12 @@ inline int DIST(int x1, int y1, int x2, int y2) // Distance macro - tx, ty, tmin are holding vars that must be declared in the routine // that uses this macro -inline void DISTANCE(int x1, int y1, int x2, int y2, int& dist, int& tx, int& ty, int& tmin) +inline void DISTANCE(const DVector2& p1, const DVector2& p2, int& dist, int& tx, int& ty, int& tmin) { - tx = abs(x2 - x1); - ty = abs(y2 - y1); - tmin = min(tx, ty); - dist = tx + ty - (tmin >> 1); + tx = int(abs(p2.X - p1.X) * worldtoint); + ty = int(abs(p2.Y - p1.Y) * worldtoint); + tmin = min(tx, ty); + dist = tx + ty - (tmin >> 1); } inline int GetSpriteSizeY(const spritetypebase* sp) diff --git a/source/games/sw/src/hornet.cpp b/source/games/sw/src/hornet.cpp index e628c3a11..0436ed669 100644 --- a/source/games/sw/src/hornet.cpp +++ b/source/games/sw/src/hornet.cpp @@ -539,7 +539,7 @@ int DoCheckSwarm(DSWActor* actor) if (actor->user.targetActor->user.PlayerP) { pp = actor->user.targetActor->user.PlayerP; - DISTANCE(actor->int_pos().X, actor->int_pos().Y, pp->int_ppos().X, pp->int_ppos().Y, pdist, a, b, c); + DISTANCE(actor->spr.pos, pp->pos, pdist, a, b, c); } else return 0; @@ -552,7 +552,7 @@ int DoCheckSwarm(DSWActor* actor) if (itActor->spr.hitag != TAG_SWARMSPOT || itActor->spr.lotag != 2) continue; - DISTANCE(actor->int_pos().X, actor->int_pos().Y, itActor->int_pos().X, itActor->int_pos().Y, dist, a, b, c); + DISTANCE(actor->spr.pos, itActor->spr.pos, dist, a, b, c); if (dist < pdist && actor->user.ID == itActor->user.ID) // Only flock to your own kind { diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index 3e7196136..185f13c4a 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -1425,7 +1425,7 @@ int PlayerInitFlashBomb(PLAYER* pp) if (itActor == pp->actor) break; - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, tx, ty, tmin); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, tx, ty, tmin); if (dist > 16384) // Flash radius continue; @@ -1484,7 +1484,7 @@ int InitFlashBomb(DSWActor* actor) SWStatIterator it(StatDamageList[stat]); while (auto itActor = it.Next()) { - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, tx, ty, tmin); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, tx, ty, tmin); if (dist > 16384) // Flash radius continue; @@ -1880,7 +1880,7 @@ DSWActor* DoFlagRangeTest(DSWActor* actor, int range) SWStatIterator it(StatDamageList[stat]); while (auto itActor = it.Next()) { - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, tx, ty, tmin); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, tx, ty, tmin); if (dist > range) continue; diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index c687c90de..58e5ff67a 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -5779,7 +5779,7 @@ void DoPlayerDeathCheckKick(PLAYER* pp) if (!(itActor->spr.extra & SPRX_PLAYER_OR_ENEMY)) continue; - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, plActor->int_pos().X, plActor->int_pos().Y, dist, a, b, c); + DISTANCE(itActor->spr.pos, plActor->spr.pos, dist, a, b, c); if (unsigned(dist) < itActor->user.Radius + 100) { diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 3317e6dbb..d4a626aaf 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -2670,7 +2670,7 @@ void DoSector(void) } else { - DISTANCE(pp->int_ppos().X, pp->int_ppos().Y, sop->int_pmid().X, sop->int_pmid().Y, dist, a, b, c); + DISTANCE(pp->pos, sop->pmid, dist, a, b, c); if (dist < min_dist) min_dist = dist; } diff --git a/source/games/sw/src/skull.cpp b/source/games/sw/src/skull.cpp index a25d64f03..401916363 100644 --- a/source/games/sw/src/skull.cpp +++ b/source/games/sw/src/skull.cpp @@ -363,7 +363,7 @@ int DoSkullJump(DSWActor* actor) int dist,a,b,c; - DISTANCE(actor->int_pos().X, actor->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y, dist, a, b, c); + DISTANCE(actor->spr.pos, actor->user.targetActor->spr.pos, dist, a, b, c); if (dist < 1000 && SpriteOverlapZ(actor, actor->user.targetActor, Z(32))) @@ -424,7 +424,7 @@ int DoSkullWait(DSWActor* actor) { int a,b,c,dist; - DISTANCE(actor->int_pos().X, actor->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y, dist, a, b, c); + DISTANCE(actor->spr.pos, actor->user.targetActor->spr.pos, dist, a, b, c); DoActorPickClosePlayer(actor); @@ -740,7 +740,7 @@ int DoBettyJump(DSWActor* actor) { int dist,a,b,c; - DISTANCE(actor->int_pos().X, actor->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y, dist, a, b, c); + DISTANCE(actor->spr.pos, actor->user.targetActor->spr.pos, dist, a, b, c); if (dist < 1000 && SpriteOverlapZ(actor, actor->user.targetActor, Z(32))) @@ -798,7 +798,7 @@ int DoBettyWait(DSWActor* actor) { int a,b,c,dist; - DISTANCE(actor->int_pos().X, actor->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y, dist, a, b, c); + DISTANCE(actor->spr.pos, actor->user.targetActor->spr.pos, dist, a, b, c); DoActorPickClosePlayer(actor); diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index a082fd203..2505d66a2 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -5021,7 +5021,7 @@ int DoGet(DSWActor* actor) if (pp->Flags & (PF_DEAD)) continue; - DISTANCE(pp->int_ppos().X, pp->int_ppos().Y, actor->int_pos().X, actor->int_pos().Y, dist, a,b,c); + DISTANCE(pp->pos, actor->spr.pos, dist, a,b,c); if ((unsigned)dist > (plActor->user.Radius + actor->user.Radius)) { continue; @@ -6056,7 +6056,7 @@ void SpriteControl(void) pp = &Player[pnum]; // Only update the ones closest - DISTANCE(pp->int_ppos().X, pp->int_ppos().Y, actor->int_pos().X, actor->int_pos().Y, dist, tx, ty, tmin); + DISTANCE(pp->pos, actor->spr.pos, dist, tx, ty, tmin); AdjustActiveRange(pp, actor, dist); diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 4c8c42114..34dc4e173 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -5292,7 +5292,7 @@ int GetDamage(DSWActor* actor, DSWActor* weapActor, int DamageNdx) int damage_per_pixel, damage_force, damage_amt; - DISTANCE(weapActor->int_pos().X,weapActor->int_pos().Y,actor->int_pos().X,actor->int_pos().Y,dist,a,b,c); + DISTANCE(weapActor->spr.pos, actor->spr.pos,dist,a,b,c); // take off the box around the player or else you'll never get // the max_damage; @@ -7028,7 +7028,7 @@ int DoDamageTest(DSWActor* actor) SWStatIterator it(StatDamageList[stat]); while (auto itActor = it.Next()) { - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, tx, ty, tmin); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, tx, ty, tmin); if ((unsigned)dist > actor->user.Radius + itActor->user.Radius) continue; @@ -7099,7 +7099,7 @@ int DoFlamesDamageTest(DSWActor* actor) continue; } - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, tx, ty, tmin); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, tx, ty, tmin); if ((unsigned)dist > actor->user.Radius + itActor->user.Radius) continue; @@ -7236,7 +7236,7 @@ int DoExpDamageTest(DSWActor* actor) SWStatIterator it(StatDamageList[stat]); while (auto itActor = it.Next()) { - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, tx, ty, tmin); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, tx, ty, tmin); if ((unsigned)dist > actor->user.Radius + itActor->user.Radius) continue; @@ -7281,7 +7281,7 @@ int DoExpDamageTest(DSWActor* actor) SWStatIterator it(StatBreakList[stat]); while (auto itActor = it.Next()) { - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, tx, ty, tmin); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, tx, ty, tmin); if ((unsigned)dist > actor->user.Radius) continue; @@ -7309,7 +7309,7 @@ int DoExpDamageTest(DSWActor* actor) SWStatIterator it(STAT_WALL_MOVE); while (auto itActor = it.Next()) { - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, tx, ty, tmin); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, tx, ty, tmin); if ((unsigned)dist > actor->user.Radius/4) continue; @@ -7355,7 +7355,7 @@ int DoMineExpMine(DSWActor* actor) SWStatIterator it(STAT_MINE_STUCK); while (auto itActor = it.Next()) { - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, tx, ty, tmin); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, tx, ty, tmin); if ((unsigned)dist > actor->user.Radius + itActor->user.Radius) continue; @@ -8583,7 +8583,7 @@ int DoMineRangeTest(DSWActor* actor, int range) SWStatIterator it(StatDamageList[stat]); while (auto itActor = it.Next()) { - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, tx, ty, tmin); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, tx, ty, tmin); if (dist > range) continue; @@ -9296,7 +9296,7 @@ int DoRocket(DSWActor* actor) if ((actor->user.FlagOwner -= ACTORMOVETICS)<=0 && actor->user.spal == 20) { - DISTANCE(actor->int_pos().X, actor->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y, dist, a, b, c); + DISTANCE(actor->spr.pos, actor->user.targetActor->spr.pos, dist, a, b, c); actor->user.FlagOwner = dist>>6; // Special warn sound attached to each seeker spawned PlaySound(DIGI_MINEBEEP, actor, v3df_follow); @@ -11336,7 +11336,7 @@ int DoSerpRing(DSWActor* actor) !(tActor->user.PlayerP->Flags & PF_DEAD)) { actor->user.targetActor = own->user.targetActor; - DISTANCE(actor->int_pos().X, actor->int_pos().Y, actor->user.targetActor->int_pos().X, actor->user.targetActor->int_pos().Y, dist, a,b,c); + DISTANCE(actor->spr.pos, actor->user.targetActor->spr.pos, dist, a,b,c); // if ((dist ok and random ok) OR very few skulls left) if ((dist < 18000 && (RANDOM_P2(2048<<5)>>5) < 16) || own->user.Counter < 4) @@ -13768,7 +13768,7 @@ int InitRipperSlash(DSWActor* actor) if ((unsigned)FindDistance3D(actor->int_pos() - itActor->int_pos()) > itActor->user.Radius + actor->user.Radius) continue; - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, a, b, c); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, a, b, c); if (dist < CloseRangeDist(actor, itActor, 600) && FacingRange(itActor, actor,150)) { @@ -13796,7 +13796,7 @@ int InitBunnySlash(DSWActor* actor) if (itActor == actor) break; - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, a, b, c); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, a, b, c); if (dist < CloseRangeDist(actor, itActor, 600) && FacingRange(itActor, actor,150)) { @@ -13825,7 +13825,7 @@ int InitSerpSlash(DSWActor* actor) if (itActor == actor) break; - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, a, b, c); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, a, b, c); if (dist < CloseRangeDist(actor, itActor, 800) && FacingRange(itActor, actor,150)) { @@ -13862,7 +13862,7 @@ int DoBladeDamage(DSWActor* actor) if (!(itActor->spr.extra & SPRX_PLAYER_OR_ENEMY)) continue; - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, a, b, c); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, a, b, c); if (dist > 2000) continue; @@ -13899,7 +13899,7 @@ int DoStaticFlamesDamage(DSWActor* actor) if (!(itActor->spr.extra & SPRX_PLAYER_OR_ENEMY)) continue; - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, a, b, c); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, a, b, c); if (dist > 2000) continue; @@ -13942,7 +13942,7 @@ int InitCoolgBash(DSWActor* actor) if (!(itActor->spr.extra & SPRX_PLAYER_OR_ENEMY)) continue; - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, a, b, c); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, a, b, c); if (dist < CloseRangeDist(actor, itActor, 600) && FacingRange(itActor, actor,150)) { @@ -13970,7 +13970,7 @@ int InitSkelSlash(DSWActor* actor) if (itActor == actor) break; - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, a, b, c); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, a, b, c); if (dist < CloseRangeDist(actor, itActor, 600) && FacingRange(itActor, actor,150)) { @@ -13998,7 +13998,7 @@ int InitGoroChop(DSWActor* actor) if (itActor == actor) break; - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, a, b, c); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, a, b, c); if (dist < CloseRangeDist(actor, itActor, 700) && FacingRange(itActor, actor,150)) { @@ -14696,7 +14696,7 @@ int InitEelFire(DSWActor* actor) if ((unsigned)FindDistance3D(actor->int_pos() - itActor->int_pos()) > itActor->user.Radius + actor->user.Radius) continue; - DISTANCE(itActor->int_pos().X, itActor->int_pos().Y, actor->int_pos().X, actor->int_pos().Y, dist, a, b, c); + DISTANCE(itActor->spr.pos, actor->spr.pos, dist, a, b, c); if (dist < CloseRangeDist(actor, itActor, 600) && FacingRange(itActor, actor,150)) { @@ -17755,7 +17755,7 @@ int DoFloorBlood(DSWActor* actor) { pp = &Player[pnum]; - DISTANCE(actor->int_pos().X, actor->int_pos().Y, pp->int_ppos().X, pp->int_ppos().Y, dist, a, b, c); + DISTANCE(actor->spr.pos, pp->pos, dist, a, b, c); if (dist < near_dist) {