From 9f19a1315b43ffd8afaa0b6e46e8d648181aa974 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 4 Oct 2022 19:25:06 +0200 Subject: [PATCH] - replaced most native_clipdist() calls Only those in nnext using internal int storage remain. --- source/games/blood/src/actor.cpp | 4 ++-- source/games/blood/src/aiunicult.cpp | 6 +++--- source/games/blood/src/nnexts.cpp | 4 ++-- source/games/duke/src/player_r.cpp | 4 ++-- source/games/exhumed/src/gun.cpp | 18 ------------------ source/games/sw/src/jweapon.cpp | 2 +- source/games/sw/src/weapon.cpp | 2 +- 7 files changed, 11 insertions(+), 29 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index ad7cc1162..3a68d285b 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -4166,7 +4166,7 @@ static void checkCeilHit(DBloodActor* actor) } if (mass1 > mass2) { - int dmg = abs((mass1 - mass2) * (actor2->native_clipdist()) - actor->native_clipdist()); + int dmg = 4 * (abs((mass1 - mass2) * actor2->clipdist) - actor->clipdist); if (actor2->IsDudeActor()) { if (dmg > 0) actDamageSprite(actor2, actor, (Chance(0x2000)) ? kDamageFall : (Chance(0x4000)) ? kDamageExplode : kDamageBullet, dmg); @@ -4330,7 +4330,7 @@ static void checkFloorHit(DBloodActor* actor) if ((actor2->IsPlayerActor() && Chance(0x500)) || !actor2->IsPlayerActor()) actKickObject(actor, actor2); - int dmg = (mass1 - mass2) + actor->native_clipdist(); + int dmg = (mass1 - mass2) + actor->clipdist * 4; if (dmg > 0) actDamageSprite(actor, actor2, (Chance(0x2000)) ? kDamageFall : kDamageBullet, dmg); } } diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index 49aba832f..c51e955ed 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -487,7 +487,7 @@ static void unicultThinkChase(DBloodActor* actor) // so i use fake velocity with fixed value and pass it as argument. auto velocity = actor->vel; if (inAttack(actor->xspr.aiState)) - velocity.X = velocity.Y = FixedToFloat(ClipLow(actor->native_clipdist() >> 1, 1)); + velocity.X = velocity.Y = max(actor->clipdist, 0.5) / 32768; aiGenDudeChooseDirection(actor, nAngle, velocity); @@ -1895,7 +1895,7 @@ DBloodActor* genDudeSpawn(DBloodActor* source, DBloodActor* actor, double nDist) spawned->xspr.busyTime = source->xspr.busyTime; // inherit clipdist? - if (source->native_clipdist() > 0) + if (source->clipdist > 0) spawned->copy_clipdist(source); // inherit custom hp settings @@ -2261,7 +2261,7 @@ bool genDudePrepare(DBloodActor* actor, int propId) pExtra->moveSpeed = getGenDudeMoveSpeed(actor, 0, true, false); pExtra->initVals[0] = actor->spr.xrepeat; pExtra->initVals[1] = actor->spr.yrepeat; - pExtra->initVals[2] = actor->native_clipdist(); + pExtra->initVals[2] = actor->spr.clipdist; if (propId) break; [[fallthrough]]; diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index df4de18bb..1b6152cd2 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1170,7 +1170,7 @@ void nnExtProcessSuperSprites() if (!pProx->xspr.Proximity || (!pProx->xspr.Interrutable && pProx->xspr.state != pProx->xspr.restState) || pProx->xspr.locked == 1 || pProx->xspr.isTriggered) continue; // don't process locked or triggered sprites - int okDist = (pProx->IsDudeActor()) ? 96 : ClipLow(pProx->native_clipdist() * 3, 32); + int okDist = (pProx->IsDudeActor()) ? 96 : max(int(pProx->clipdist * 12), 32); auto pos = pProx->spr.pos; auto pSect = pProx->sector(); @@ -4575,7 +4575,7 @@ bool condCheckSprite(DBloodActor* aCond, int cmpOp, bool PUSH) case 5: return condCmp(objActor->spr.statnum, arg1, arg2, cmpOp); case 6: return ((objActor->spr.flags & kHitagRespawn) || objActor->spr.statnum == kStatRespawn); case 7: return condCmp(spriteGetSlope(objActor), arg1, arg2, cmpOp); - case 10: return condCmp(objActor->native_clipdist(), arg1, arg2, cmpOp); + case 10: return condCmp(int(objActor->clipdist * 4), arg1, arg2, cmpOp); case 15: if (!objActor->GetOwner()) return false; else if (PUSH) condPush(aCond, objActor->GetOwner()); diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 2b4e88b79..9d28aed96 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3395,7 +3395,7 @@ void processinput_r(int snum) shrunk = (pact->spr.yrepeat < 8); double tempfz; - if (pact->native_clipdist() == 64) + if (pact->clipdist == 16) { getzrange(p->pos, psectp, &ceilingz, chz, &floorz, clz, 10.1875, CLIPMASK0); tempfz = getflorzofslopeptr(psectp, p->pos); @@ -3918,7 +3918,7 @@ HORIZONLY: while (ud.clipping == 0) { int blocked; - if (pact->native_clipdist() == 64) + if (pact->clipdist == 16) blocked = (pushmove(p->pos, &p->cursector, 8, 4, 4, CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < DAngle90); else blocked = (pushmove(p->pos, &p->cursector, 1, 4, 4, CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < DAngle90); diff --git a/source/games/exhumed/src/gun.cpp b/source/games/exhumed/src/gun.cpp index c7a49985e..22aa253ef 100644 --- a/source/games/exhumed/src/gun.cpp +++ b/source/games/exhumed/src/gun.cpp @@ -705,24 +705,6 @@ loc_flag: DAngle nAngle = pPlayerActor->spr.angle; auto thePos = pPlayerActor->spr.pos; - int ebp = nAngle.Cos() * (1 << 14) * (pPlayerActor->native_clipdist() << 3); - int ebx = nAngle.Sin() * (1 << 14) * (pPlayerActor->native_clipdist() << 3); - - if (WeaponInfo[nWeapon].c) - { - int ecx; - - int theVal = (totalmoves + 101) & (WeaponInfo[nWeapon].c - 1); - if (theVal & 1) - ecx = -theVal; - else - ecx = theVal; - - DAngle angle = (nAngle + DAngle90).Normalized360(); - ebp += angle.Cos() * (1 << 3) * ecx; - ebx += angle.Sin() * (1 << 3) * ecx; - } - double nHeight = GetActorHeight(pPlayerActor) * -0.5; if (nAction < 6) diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index fd0c0569a..d64228d26 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -1744,7 +1744,7 @@ int InitPhosphorus(DSWActor* actor) actorNew->spr.xrepeat = 64; actorNew->spr.shade = -15; // !FRANK - clipbox must be <= weapon otherwise can clip thru walls - if (actor->native_clipdist() > 0) + if (actor->clipdist > 0) actorNew->clipdist -= 0.25; else actorNew->copy_clipdist(actor); diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 4ecffbeeb..3d748a74d 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -5409,7 +5409,7 @@ int GetDamage(DSWActor* actor, DSWActor* weapActor, int DamageNdx) // take off the box around the player or else you'll never get // the max_damage; - dist -= (((int)actor->native_clipdist())<(2)); + dist -= int(actor->clipdist * worldtoint); if (dist < 0) dist = 0;