From e7621b4e05354b0a670212c9b7e3b8a6a6cee8fe Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 10 May 2020 20:55:22 +1000 Subject: [PATCH] RR: Properly scale tilt_status on vehicles with input being tied to frame-rate. --- source/core/version.h | 4 ++-- source/rr/src/player.cpp | 40 ++++++++++++++++++++++++---------------- source/rr/src/player.h | 5 +++-- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/source/core/version.h b/source/core/version.h index 0d4a6e3ab..c226a380f 100644 --- a/source/core/version.h +++ b/source/core/version.h @@ -68,13 +68,13 @@ const char *GetVersionString(); #define MINSAVEVER_DN3D 7 #define MINSAVEVER_BLD 6 -#define MINSAVEVER_RR 6 +#define MINSAVEVER_RR 7 #define MINSAVEVER_SW 6 #define MINSAVEVER_PS 6 #define SAVEVER_DN3D 7 #define SAVEVER_BLD 6 -#define SAVEVER_RR 6 +#define SAVEVER_RR 7 #define SAVEVER_SW 6 #define SAVEVER_PS 6 diff --git a/source/rr/src/player.cpp b/source/rr/src/player.cpp index c39876d9c..ba3ee37c8 100644 --- a/source/rr/src/player.cpp +++ b/source/rr/src/player.cpp @@ -3681,13 +3681,13 @@ void P_GetInputMotorcycle(int playerNum) { if (turnLeft) { - pPlayer->tilt_status--; + pPlayer->tilt_status -= scaleAdjustmentToInterval(1); if (pPlayer->tilt_status < -10) pPlayer->tilt_status = -10; } else if (turnRight) { - pPlayer->tilt_status++; + pPlayer->tilt_status += scaleAdjustmentToInterval(1); if (pPlayer->tilt_status > 10) pPlayer->tilt_status = 10; } @@ -3697,7 +3697,7 @@ void P_GetInputMotorcycle(int playerNum) if (turnLeft || pPlayer->moto_drink < 0) { turnHeldTime += elapsedTics; - pPlayer->tilt_status--; + pPlayer->tilt_status -= scaleAdjustmentToInterval(1); if (pPlayer->tilt_status < -10) pPlayer->tilt_status = -10; if (turnHeldTime >= TURBOTURNTIME && pPlayer->moto_speed > 0) @@ -3718,7 +3718,7 @@ void P_GetInputMotorcycle(int playerNum) else if (turnRight || pPlayer->moto_drink > 0) { turnHeldTime += elapsedTics; - pPlayer->tilt_status++; + pPlayer->tilt_status += scaleAdjustmentToInterval(1); if (pPlayer->tilt_status > 10) pPlayer->tilt_status = 10; if (turnHeldTime >= TURBOTURNTIME && pPlayer->moto_speed > 0) @@ -3741,12 +3741,15 @@ void P_GetInputMotorcycle(int playerNum) turnHeldTime = 0; if (pPlayer->tilt_status > 0) - pPlayer->tilt_status--; + pPlayer->tilt_status -= scaleAdjustmentToInterval(1); else if (pPlayer->tilt_status < 0) - pPlayer->tilt_status++; + pPlayer->tilt_status += scaleAdjustmentToInterval(1); } } + if (pPlayer->tilt_status > -0.025 && pPlayer->tilt_status < 0.025) + pPlayer->tilt_status = 0; + if (pPlayer->moto_underwater) { pPlayer->moto_speed = 0; @@ -3913,7 +3916,7 @@ void P_GetInputBoat(int playerNum) turnHeldTime += elapsedTics; if (!pPlayer->not_on_water) { - pPlayer->tilt_status--; + pPlayer->tilt_status -= scaleAdjustmentToInterval(1); if (pPlayer->tilt_status < -10) pPlayer->tilt_status = -10; if (turnHeldTime >= TURBOTURNTIME) @@ -3932,7 +3935,7 @@ void P_GetInputBoat(int playerNum) turnHeldTime += elapsedTics; if (!pPlayer->not_on_water) { - pPlayer->tilt_status++; + pPlayer->tilt_status += scaleAdjustmentToInterval(1); if (pPlayer->tilt_status > 10) pPlayer->tilt_status = 10; if (turnHeldTime >= TURBOTURNTIME) @@ -3951,9 +3954,9 @@ void P_GetInputBoat(int playerNum) turnHeldTime = 0; if (pPlayer->tilt_status > 0) - pPlayer->tilt_status--; + pPlayer->tilt_status -= scaleAdjustmentToInterval(1); else if (pPlayer->tilt_status < 0) - pPlayer->tilt_status++; + pPlayer->tilt_status += scaleAdjustmentToInterval(1); } } else if (!pPlayer->not_on_water) @@ -3961,11 +3964,14 @@ void P_GetInputBoat(int playerNum) turnHeldTime = 0; if (pPlayer->tilt_status > 0) - pPlayer->tilt_status--; + pPlayer->tilt_status -= scaleAdjustmentToInterval(1); else if (pPlayer->tilt_status < 0) - pPlayer->tilt_status++; + pPlayer->tilt_status += scaleAdjustmentToInterval(1); } + if (pPlayer->tilt_status > -0.025 && pPlayer->tilt_status < 0.025) + pPlayer->tilt_status = 0; + input.fvel += pPlayer->moto_speed; input.q16avel = fix16_mul(input.q16avel, avelScale); @@ -8574,9 +8580,10 @@ HORIZONLY:; { if (numplayers == 1) { + int tilt_status = pPlayer->tilt_status; vec3_t const vect = { - sintable[(pPlayer->tilt_status*20+fix16_to_int(pPlayer->q16ang)+512)&2047]>>8, - sintable[(pPlayer->tilt_status*20+fix16_to_int(pPlayer->q16ang))&2047]>>8,sprite[spriteNum].zvel + sintable[(tilt_status*20+fix16_to_int(pPlayer->q16ang)+512)&2047]>>8, + sintable[(tilt_status*20+fix16_to_int(pPlayer->q16ang))&2047]>>8,sprite[spriteNum].zvel }; A_MoveSprite(spriteNum,&vect,CLIPMASK0); @@ -8627,9 +8634,10 @@ HORIZONLY:; { if (numplayers == 1) { + int tilt_status = pPlayer->tilt_status; vec3_t const vect = { - sintable[(pPlayer->tilt_status*20+fix16_to_int(pPlayer->q16ang)+512)&2047]>>9, - sintable[(pPlayer->tilt_status*20+fix16_to_int(pPlayer->q16ang))&2047]>>9,sprite[spriteNum].zvel + sintable[(tilt_status*20+fix16_to_int(pPlayer->q16ang)+512)&2047]>>9, + sintable[(tilt_status*20+fix16_to_int(pPlayer->q16ang))&2047]>>9,sprite[spriteNum].zvel }; A_MoveSprite(spriteNum,&vect,CLIPMASK0); diff --git a/source/rr/src/player.h b/source/rr/src/player.h index 2bd7c4565..d990b3ae3 100644 --- a/source/rr/src/player.h +++ b/source/rr/src/player.h @@ -210,7 +210,7 @@ typedef struct { int16_t drink_amt, eat_amt, drink_ang, eat_ang; int32_t drink_timer, eat_timer; int16_t level_end_timer; - int16_t moto_speed, tilt_status, moto_drink; + int16_t moto_speed, moto_drink; uint8_t on_motorcycle, on_boat, moto_underwater, not_on_water, moto_on_ground; uint8_t moto_do_bump, moto_bump_fast, moto_on_oil, moto_on_mud; int16_t moto_bump, moto_bump_target, moto_turb; @@ -220,11 +220,12 @@ typedef struct { int32_t drug_timer; int32_t sea_sick; uint8_t hurt_delay2, nocheat; + double tilt_status; int32_t dhat60f, dhat613, dhat617, dhat61b, dhat61f; int8_t crouch_toggle; - int8_t padding_[3]; + int8_t padding_[1]; } DukePlayer_t; // KEEPINSYNC lunatic/_defs_game.lua