From f286565abc14de4a1829ba3d2d72ff014f04b110 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 28 Sep 2022 17:58:22 +0200 Subject: [PATCH] - floatifying player::slope, part 2 --- source/games/blood/src/player.cpp | 8 ++++---- source/games/blood/src/player.h | 5 ++--- source/games/blood/src/weapon.cpp | 8 ++++---- wadsrc/static/zscript/games/blood/bloodgame.zs | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 422777bc8..dfc9748bb 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -820,7 +820,7 @@ void playerStart(int nPlayer, int bNewLevel) pPlayer->actor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE; pPlayer->bloodlust = 0; pPlayer->horizon.horiz = pPlayer->horizon.horizoff = nullAngle; - pPlayer->_slope = 0; + pPlayer->slope = 0; pPlayer->fragger = nullptr; pPlayer->underwaterTime = 1200; pPlayer->bubbleTime = 0; @@ -1419,7 +1419,7 @@ int ActionScan(PLAYER* pPlayer, HitInfo* out) { auto plActor = pPlayer->actor; *out = {}; - auto pos = DVector3(plActor->spr.angle.ToVector(), pPlayer->flt_slope()); + auto pos = DVector3(plActor->spr.angle.ToVector(), pPlayer->slope); int hit = HitScan(pPlayer->actor, pPlayer->zView, pos, 0x10000040, 128); double hitDist = (plActor->spr.pos.XY() - gHitInfo.hitpos.XY()).Length(); if (hitDist < 64) @@ -1731,7 +1731,7 @@ void ProcessInput(PLAYER* pPlayer) pPlayer->angle.unlockinput(); pPlayer->horizon.unlockinput(); - pPlayer->_slope = -pPlayer->horizon.horiz.Tan() * 16384.; + pPlayer->slope = -pPlayer->horizon.horiz.Tan(); if (pInput->actions & SB_INVPREV) { pInput->actions &= ~SB_INVPREV; @@ -2462,7 +2462,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYER& w, PLAYER* ("zviewvel", w.zViewVel) ("zweapon", w.zWeapon) ("zweaponvel", w.zWeaponVel) - ("slope", w._slope) + ("slope", w.slope) ("underwater", w.isUnderwater) .Array("haskey", w.hasKey, 8) ("hasflag", w.hasFlag) diff --git a/source/games/blood/src/player.h b/source/games/blood/src/player.h index 9b0a8f299..ad7a4c31d 100644 --- a/source/games/blood/src/player.h +++ b/source/games/blood/src/player.h @@ -113,9 +113,8 @@ struct PLAYER double zWeapon; double ozWeapon; double zWeaponVel; - int _slope; // Q18.14, like dudeslope - int int_slope() const { return _slope; } - int flt_slope() const { return _slope / 16384.; } + double slope; + int int_slope() const { return slope * 16384; } bool isUnderwater; bool hasKey[8]; int8_t hasFlag; diff --git a/source/games/blood/src/weapon.cpp b/source/games/blood/src/weapon.cpp index a05e2a455..3c036ef58 100644 --- a/source/games/blood/src/weapon.cpp +++ b/source/games/blood/src/weapon.cpp @@ -424,7 +424,7 @@ void UpdateAimVector(PLAYER* pPlayer) assert(pPlayer != NULL); auto plActor = pPlayer->actor; DVector3 pos(plActor->spr.pos.XY(), pPlayer->zWeapon); - DVector3 Aim(plActor->spr.angle.ToVector(), pPlayer->flt_slope()); + DVector3 Aim(plActor->spr.angle.ToVector(), pPlayer->slope); WEAPONTRACK* pWeaponTrack = &gWeaponTrack[pPlayer->curWeapon]; DBloodActor* targetactor = nullptr; @@ -455,7 +455,7 @@ void UpdateAimVector(PLAYER* pPlayer) double t = nDist * 4096 / pWeaponTrack->seeker; pos2 += actor->vel * t; } - DVector3 lpos = pos + DVector3(plActor->spr.angle.ToVector(), pPlayer->flt_slope()) * nDist; + DVector3 lpos = pos + DVector3(plActor->spr.angle.ToVector(), pPlayer->slope) * nDist; double zRange = nDist * (9460 / 16384.); double top, bottom; @@ -502,7 +502,7 @@ void UpdateAimVector(PLAYER* pPlayer) if (nDist == 0 || nDist > 3200) continue; - DVector3 lpos = pos + DVector3(plActor->spr.angle.ToVector(), pPlayer->flt_slope()) * nDist; + DVector3 lpos = pos + DVector3(plActor->spr.angle.ToVector(), pPlayer->slope) * nDist; double zRange = nDist * (9460 / 16384.); double top, bottom; @@ -533,7 +533,7 @@ void UpdateAimVector(PLAYER* pPlayer) } DVector3 Aim2(Aim); Aim2.XY() = Aim2.XY().Rotated(-plActor->spr.angle); - Aim2.Z -= pPlayer->flt_slope(); + Aim2.Z -= pPlayer->slope; pPlayer->relAim.dx = interpolatedvalue(pPlayer->relAim.dx, int(Aim2.X * 16384), FixedToFloat(pWeaponTrack->aimSpeedHorz)); pPlayer->relAim.dy = interpolatedvalue(pPlayer->relAim.dy, int(Aim2.Y * 16384), FixedToFloat(pWeaponTrack->aimSpeedHorz)); diff --git a/wadsrc/static/zscript/games/blood/bloodgame.zs b/wadsrc/static/zscript/games/blood/bloodgame.zs index f2a5f675f..7331fd43a 100644 --- a/wadsrc/static/zscript/games/blood/bloodgame.zs +++ b/wadsrc/static/zscript/games/blood/bloodgame.zs @@ -77,7 +77,7 @@ struct BloodPlayer native native double zViewVel; native double zWeapon; native double zWeaponVel; - native int slope; + native double slope; native bool isUnderwater; native bool hasKey[8]; native int8 hasFlag;