From ac635ebd0fc3ad26e5a571f92753d75304bc3472 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 22 Sep 2020 22:50:27 +1000 Subject: [PATCH] - Blood/RR: Replace a few `playerSet*()` calls with `playerAdd*()`. Because the setters continually set until target is reached, can cause some perceivable smoothness issues if ticker re-targets's player's angle/horizon before input code has reached target. --- source/blood/src/player.cpp | 7 ++++--- source/games/duke/src/player_r.cpp | 26 ++++++++++++++++++-------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index 5ae6c8325..6d0fd2781 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -1358,12 +1358,13 @@ void ProcessInput(PLAYER *pPlayer) char bSeqStat = playerSeqPlaying(pPlayer, 16); if (pPlayer->fraggerId != -1) { - pPlayer->angold = pSprite->ang = getangle(sprite[pPlayer->fraggerId].x - pSprite->x, sprite[pPlayer->fraggerId].y - pSprite->y); - playerSetAngle(&pPlayer->q16ang, &pPlayer->angTarget, pSprite->ang); + fixed_t fraggerAng = gethiq16angle(sprite[pPlayer->fraggerId].x - pSprite->x, sprite[pPlayer->fraggerId].y - pSprite->y); + pPlayer->angold = pSprite->ang = FixedToInt(fraggerAng); + playerAddAngle(&pPlayer->q16ang, &pPlayer->angAdjust, FixedToFloat(getincangleq16(pPlayer->q16ang, fraggerAng))); } pPlayer->deathTime += 4; if (!bSeqStat) - playerSetHoriz(&pPlayer->q16horiz, &pPlayer->horizTarget, FixedToFloat(mulscale16(0x8000-(Cos(ClipHigh(pPlayer->deathTime<<3, 1024))>>15), IntToFixed(120)))); + playerAddHoriz(&pPlayer->q16horiz, &pPlayer->horizAdjust, FixedToFloat(mulscale16(0x8000-(Cos(ClipHigh(pPlayer->deathTime<<3, 1024))>>15), IntToFixed(120)) - pPlayer->q16horiz)); if (pPlayer->curWeapon) pInput->setNewWeapon(pPlayer->curWeapon); if (pInput->actions & SB_OPEN) diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 978d07198..e6c885e19 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -1717,9 +1717,10 @@ static void onMotorcycle(int snum, ESyncBits &actions) p->moto_drink--; } } + + int horiz = 0; if (p->TurbCount) { - int horiz; if (p->TurbCount <= 1) { horiz = 100; @@ -1733,7 +1734,6 @@ static void onMotorcycle(int snum, ESyncBits &actions) p->TurbCount--; p->moto_drink = (krand() & 3) - 2; } - playerSetHoriz(&p->q16horiz, &p->horizTarget, horiz); } else if (p->VBumpTarget > p->VBumpNow) { @@ -1743,7 +1743,7 @@ static void onMotorcycle(int snum, ESyncBits &actions) p->VBumpNow++; if (p->VBumpTarget < p->VBumpNow) p->VBumpNow = p->VBumpTarget; - playerSetHoriz(&p->q16horiz, &p->horizTarget, 100 + p->VBumpNow / 3); + horiz = 100 + p->VBumpNow / 3; } else if (p->VBumpTarget < p->VBumpNow) { @@ -1753,13 +1753,18 @@ static void onMotorcycle(int snum, ESyncBits &actions) p->VBumpNow--; if (p->VBumpTarget > p->VBumpNow) p->VBumpNow = p->VBumpTarget; - playerSetHoriz(&p->q16horiz, &p->horizTarget, 100 + p->VBumpNow / 3); + horiz = 100 + p->VBumpNow / 3; } else { p->VBumpTarget = 0; p->moto_bump_fast = 0; } + if (horiz != 0) + { + playerAddHoriz(&p->q16horiz, &p->horizAdjust, horiz - FixedToFloat(p->q16horiz)); + } + if (p->MotoSpeed >= 20 && p->on_ground == 1 && (var74 || var7c)) { short var8c, var90, var94, var98; @@ -2041,9 +2046,10 @@ static void onBoat(int snum, ESyncBits &actions) p->moto_drink--; } } + + int horiz = 0; if (p->TurbCount) { - int horiz; if (p->TurbCount <= 1) { horiz = 100; @@ -2057,7 +2063,6 @@ static void onBoat(int snum, ESyncBits &actions) p->TurbCount--; p->moto_drink = (krand() & 3) - 2; } - playerSetHoriz(&p->q16horiz, &p->horizTarget, horiz); } else if (p->VBumpTarget > p->VBumpNow) { @@ -2067,7 +2072,7 @@ static void onBoat(int snum, ESyncBits &actions) p->VBumpNow++; if (p->VBumpTarget < p->VBumpNow) p->VBumpNow = p->VBumpTarget; - playerSetHoriz(&p->q16horiz, &p->horizTarget, 100 + p->VBumpNow / 3); + horiz = 100 + p->VBumpNow / 3; } else if (p->VBumpTarget < p->VBumpNow) { @@ -2077,13 +2082,18 @@ static void onBoat(int snum, ESyncBits &actions) p->VBumpNow--; if (p->VBumpTarget > p->VBumpNow) p->VBumpNow = p->VBumpTarget; - playerSetHoriz(&p->q16horiz, &p->horizTarget, 100 + p->VBumpNow / 3); + horiz = 100 + p->VBumpNow / 3; } else { p->VBumpTarget = 0; p->moto_bump_fast = 0; } + if (horiz != 0) + { + playerAddHoriz(&p->q16horiz, &p->horizAdjust, horiz - FixedToFloat(p->q16horiz)); + } + if (p->MotoSpeed > 0 && p->on_ground == 1 && (varbc || varc4)) { short vard4, vard8, vardc, vare0;