From 0c4fe5f91b71ef78a01b9ec621b4901dddd11801 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 17 Sep 2020 17:20:33 +1000 Subject: [PATCH] - Blood: Fix remaining issues such as starting horizon, remove q16look and clean up some remaining bits in nnexts.cpp. --- source/blood/src/nnexts.cpp | 25 +++++++++++++++---------- source/blood/src/player.cpp | 7 +++---- source/blood/src/player.h | 1 - source/blood/src/prediction.cpp | 1 - 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/source/blood/src/nnexts.cpp b/source/blood/src/nnexts.cpp index 4349e9bab..40176f6ca 100644 --- a/source/blood/src/nnexts.cpp +++ b/source/blood/src/nnexts.cpp @@ -1482,17 +1482,22 @@ void trPlayerCtrlSetScreenEffect(XSPRITE* pXSource, PLAYER* pPlayer) { } -void trPlayerCtrlSetLookAngle(XSPRITE* pXSource, PLAYER* pPlayer) { - - const int upAngle = 289; - const int downAngle = -347; - const double lookStepUp = 4.0 * upAngle / 60.0; - const double lookStepDown = -4.0 * downAngle / 60.0; - +void trPlayerCtrlSetLookAngle(XSPRITE* pXSource, PLAYER* pPlayer) +{ int look = pXSource->data2 << 5; - if (look > 0) pPlayer->q16look = min(mulscale8(FloatToFixed(lookStepUp), look), FloatToFixed(upAngle)); - else if (look < 0) pPlayer->q16look = -max(mulscale8(FloatToFixed(lookStepDown), abs(look)), FloatToFixed(downAngle)); - else pPlayer->q16look = 0; + + if (abs(look) > 0) + { + if (pPlayer->q16horiz != IntToFixed(100)) + { + // move q16horiz back to 100 + pPlayer->q16horiz += IntToFixed(25) - (pPlayer->q16horiz >> 2); + } + } + else + { + pPlayer->q16horiz = IntToFixed(100); + } } diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index 724cd1470..99a7234ac 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -721,9 +721,8 @@ void playerStart(int nPlayer, int bNewLevel) pPlayer->pXSprite->health = pDudeInfo->startHealth<<4; pPlayer->pSprite->cstat &= (unsigned short)~32768; pPlayer->bloodlust = 0; - pPlayer->q16horiz = 100; + pPlayer->q16horiz = IntToFixed(100); pPlayer->q16slopehoriz = 0; - pPlayer->q16look = 100; pPlayer->slope = 0; pPlayer->fraggerId = -1; pPlayer->underwaterTime = 1200; @@ -1362,7 +1361,7 @@ void sethorizon(PLAYER *pPlayer, fixed_t const q16horz, double const scaleAdjust InputPacket *pInput = &pPlayer->input; // Calculate adjustment as true pitch (Fixed point math really sucks...) - double horizAngle = clamp(atan2(pPlayer->q16look - IntToFixed(100), IntToFixed(128)) * (512. / pi::pi()), -180, 180); + double horizAngle = clamp(atan2(pPlayer->q16horiz - IntToFixed(100), IntToFixed(128)) * (512. / pi::pi()), -180, 180); if (q16horz) { @@ -1417,7 +1416,7 @@ void sethorizon(PLAYER *pPlayer, fixed_t const q16horz, double const scaleAdjust } // Convert back to Build's horizon and clamp. - pPlayer->q16horiz = pPlayer->q16look = clamp(IntToFixed(100) + xs_CRoundToInt(IntToFixed(128) * tan(horizAngle * (pi::pi() / 512.))), IntToFixed(PLAYER_HORIZ_MIN), IntToFixed(PLAYER_HORIZ_MAX)); + pPlayer->q16horiz = clamp(IntToFixed(100) + xs_CRoundToInt(IntToFixed(128) * tan(horizAngle * (pi::pi() / 512.))), IntToFixed(PLAYER_HORIZ_MIN), IntToFixed(PLAYER_HORIZ_MAX)); } //--------------------------------------------------------------------------- diff --git a/source/blood/src/player.h b/source/blood/src/player.h index 0b25ec5d4..8dc84bd86 100644 --- a/source/blood/src/player.h +++ b/source/blood/src/player.h @@ -108,7 +108,6 @@ struct PLAYER int zViewVel; int zWeapon; int zWeaponVel; - fixed_t q16look; fixed_t q16horiz; // horiz fixed_t q16slopehoriz; // horizoff int slope; diff --git a/source/blood/src/prediction.cpp b/source/blood/src/prediction.cpp index 03cfa333f..6908981c7 100644 --- a/source/blood/src/prediction.cpp +++ b/source/blood/src/prediction.cpp @@ -58,7 +58,6 @@ static VIEW predictFifo[256]; void viewInitializePrediction(void) { predict.at30 = gMe->q16ang; - predict.at20 = gMe->q16look; predict.at24 = gMe->q16horiz; predict.at28 = gMe->q16slopehoriz; predict.at2c = gMe->slope;