From eb8b0757275928abc856b809af4670c5424a1a8c Mon Sep 17 00:00:00 2001 From: Mitch Richters Date: Mon, 1 Nov 2021 22:13:39 +1100 Subject: [PATCH] - `binaryangle.h`: Change `binangle` bitshift operators to operate on signed value to properly handle angles > 1024. --- source/core/binaryangle.h | 8 ++++---- source/core/gameinput.cpp | 4 ++-- source/games/duke/src/actors.cpp | 4 ++-- source/games/sw/src/player.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/core/binaryangle.h b/source/core/binaryangle.h index bd527bde9..42b45e31a 100644 --- a/source/core/binaryangle.h +++ b/source/core/binaryangle.h @@ -183,24 +183,24 @@ public: constexpr binangle &operator<<= (const uint8_t shift) { - value <<= shift; + value = tosigned() << shift; return *this; } constexpr binangle &operator>>= (const uint8_t shift) { - value >>= shift; + value = tosigned() >> shift; return *this; } constexpr binangle operator<< (const uint8_t shift) const { - return binangle(value << shift); + return binangle(tosigned() << shift); } constexpr binangle operator>> (const uint8_t shift) const { - return binangle(value >> shift); + return binangle(tosigned() >> shift); } }; diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 65524935b..aa6222a33 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -331,7 +331,7 @@ void PlayerAngle::applyinput(float const avel, ESyncBits* actions, double const if (*actions & SB_LOOK_LEFT) { // start looking left - look_ang += buildfang(scaleAdjust * -(4560. / GameTicRate)); + look_ang -= buildfang(scaleAdjust * (4560. / GameTicRate)); rotscrnang += buildfang(scaleAdjust * (720. / GameTicRate)); } @@ -339,7 +339,7 @@ void PlayerAngle::applyinput(float const avel, ESyncBits* actions, double const { // start looking right look_ang += buildfang(scaleAdjust * (4560. / GameTicRate)); - rotscrnang += buildfang(scaleAdjust * -(720. / GameTicRate)); + rotscrnang -= buildfang(scaleAdjust * (720. / GameTicRate)); } if (!movementlocked()) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index acf14f7fc..59f8c8fdb 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -459,7 +459,7 @@ void moveplayers(void) if (p->actorsqu != nullptr) { - p->angle.addadjustment(getincanglebam(p->angle.ang, bvectangbam(p->actorsqu->s->x - p->pos.x, p->actorsqu->s->y - p->pos.y)).signedbuild() >> 2); + p->angle.addadjustment(getincanglebam(p->angle.ang, bvectangbam(p->actorsqu->s->x - p->pos.x, p->actorsqu->s->y - p->pos.y)) >> 2); } if (spri->extra > 0) @@ -482,7 +482,7 @@ void moveplayers(void) if (p->wackedbyactor != nullptr && p->wackedbyactor->s->statnum < MAXSTATUS) { - p->angle.addadjustment(getincanglebam(p->angle.ang, bvectangbam(p->wackedbyactor->s->x - p->pos.x, p->wackedbyactor->s->y - p->pos.y)).signedbuild() >> 1); + p->angle.addadjustment(getincanglebam(p->angle.ang, bvectangbam(p->wackedbyactor->s->x - p->pos.x, p->wackedbyactor->s->y - p->pos.y)) >> 1); } } spri->ang = p->angle.ang.asbuild(); diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index dce57d568..e6acd7fc3 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -6142,7 +6142,7 @@ void DoPlayerDeathFollowKiller(PLAYERp pp) if (FAFcansee(kp->x, kp->y, SPRITEp_TOS(kp), kp->sectnum, pp->posx, pp->posy, pp->posz, pp->cursectnum)) { - pp->angle.addadjustment(getincanglebam(pp->angle.ang, bvectangbam(kp->x - pp->posx, kp->y - pp->posy)).signedbuild() >> 4); + pp->angle.addadjustment(getincanglebam(pp->angle.ang, bvectangbam(kp->x - pp->posx, kp->y - pp->posy)) >> 4); } } }