From 3325ef272eda7743e737d052c62e50f8cdb1b482 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 21 Jun 2020 13:08:46 +1000 Subject: [PATCH 01/16] - make r_ambientlight work globally for all games by performing adjustment engine-side. --- source/blood/src/view.cpp | 4 ++-- source/build/src/polymost.cpp | 2 +- source/core/gamecvars.cpp | 3 --- source/core/gamecvars.h | 1 - source/duke3d/src/game.cpp | 2 +- source/exhumed/src/osdcmds.h | 2 -- source/rr/src/game.cpp | 2 +- 7 files changed, 5 insertions(+), 11 deletions(-) diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 19020c6c5..8a397d1a6 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -3277,7 +3277,7 @@ void viewDrawScreen(bool sceneonly) } memcpy(bakMirrorGotpic, gotpic + 510, 2); memcpy(gotpic + 510, otherMirrorGotpic, 2); - g_visibility = (int32_t)(ClipLow(gVisibility - 32 * pOther->visibility, 0) * (numplayers > 1 ? 1.f : r_ambientlightrecip)); + g_visibility = (int32_t)(ClipLow(gVisibility - 32 * pOther->visibility, 0)); int vc4, vc8; getzsofslope(vcc, vd8, vd4, &vc8, &vc4); if (vd0 >= vc4) @@ -3351,7 +3351,7 @@ void viewDrawScreen(bool sceneonly) } nSprite = nextspritestat[nSprite]; } - g_visibility = (int32_t)(ClipLow(gVisibility - 32 * gView->visibility - unk, 0) * (numplayers > 1 ? 1.f : r_ambientlightrecip)); + g_visibility = (int32_t)(ClipLow(gVisibility - 32 * gView->visibility - unk, 0)); cA = (cA + interpolateangfix16(fix16_from_int(deliriumTurnO), fix16_from_int(deliriumTurn), gInterpolate)) & 0x7ffffff; int vfc, vf8; getzsofslope(nSectnum, cX, cY, &vfc, &vf8); diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index f06e2a07b..549882ffb 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -266,7 +266,7 @@ static void polymost_updaterotmat(void) }; multiplyMatrix4f(matrix, tiltmatrix); renderSetViewMatrix(matrix); - renderSetVisibility(g_visibility * fviewingrange * (4.f / (65536.f * 65536.f))); + renderSetVisibility(((float)(g_visibility) / r_ambientlight) * fviewingrange * (4.f / (65536.f * 65536.f))); } static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, int32_t method, const vec2_16_t& tilesiz); diff --git a/source/core/gamecvars.cpp b/source/core/gamecvars.cpp index 1bee17dff..edd0a0cb3 100644 --- a/source/core/gamecvars.cpp +++ b/source/core/gamecvars.cpp @@ -343,13 +343,10 @@ CUSTOM_CVARD(Int, r_showfpsperiod, 0, 0, "time in seconds before averaging min a if (self < 0 || self > 5) self = 1; } -float r_ambientlightrecip; - CUSTOM_CVARD(Float, r_ambientlight, 1.0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "sets the global map light level") { if (self < 0.1f) self = 0.1f; else if (self > 10.f) self = 10.f; - else r_ambientlightrecip = 1.f / self; } CVARD(Bool, r_shadows, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable sprite and model shadows") diff --git a/source/core/gamecvars.h b/source/core/gamecvars.h index 011f96c37..92e716aab 100644 --- a/source/core/gamecvars.h +++ b/source/core/gamecvars.h @@ -115,7 +115,6 @@ EXTERN_CVAR(Int, playercolor) EXTERN_CVAR(Int, playerteam) extern bool gNoAutoLoad; -extern float r_ambientlightrecip; extern int hud_statusbarrange; // will be set by the game's configuration setup. bool G_ChangeHudLayout(int direction); bool G_CheckAutorun(bool button); diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index ae36a8060..63356d940 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -650,7 +650,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) smoothRatio = 65536; int const playerVis = pPlayer->visibility; - g_visibility = (playerVis <= 0) ? 0 : (int32_t)(playerVis * (numplayers > 1 ? 1.f : r_ambientlightrecip)); + g_visibility = (playerVis <= 0) ? 0 : (int32_t)(playerVis); CAMERA(sect) = pPlayer->cursectnum; diff --git a/source/exhumed/src/osdcmds.h b/source/exhumed/src/osdcmds.h index 02a2d63a0..e45295bcb 100644 --- a/source/exhumed/src/osdcmds.h +++ b/source/exhumed/src/osdcmds.h @@ -30,8 +30,6 @@ int32_t registerosdcommands(void); void GAME_onshowosd(int shown); void GAME_clearbackground(int numcols, int numrows); -//extern float r_ambientlight,r_ambientlightrecip; - extern const char *const ConsoleButtons[]; //extern uint32_t cl_cheatmask; diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index 5cf5668f7..6fa0ff901 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -860,7 +860,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) pPlayer->visibility = ud.const_visibility; int const playerVis = pPlayer->visibility; - g_visibility = (playerVis <= 0) ? 0 : (int32_t)(playerVis * (numplayers > 1 ? 1.f : r_ambientlightrecip)); + g_visibility = (playerVis <= 0) ? 0 : (int32_t)(playerVis); CAMERA(sect) = pPlayer->cursectnum; From d80a32d37905e12e57d2c2e86097290dbf236114 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 21 Jun 2020 14:08:09 +1000 Subject: [PATCH 02/16] - fix render visibility calculation following changes in 0bd460d9e3bbaf239f4a33f9ce589dff58660bea. * Output from PrintVis() in 9dfd3ddd02631f9362e2d61211d92ef5b26c3a69 showed resulting global visibility as 0.078125. * Following 0bd460d9e3bbaf239f4a33f9ce589dff58660bea, resulting global visibility shown as 0.041667. * Scaling g_visibility by (8.f / 15.f) (0.533333) restores resulting global visibility to 0.078125. --- source/build/src/polymost.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 549882ffb..a308de6e0 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -266,7 +266,7 @@ static void polymost_updaterotmat(void) }; multiplyMatrix4f(matrix, tiltmatrix); renderSetViewMatrix(matrix); - renderSetVisibility(((float)(g_visibility) / r_ambientlight) * fviewingrange * (4.f / (65536.f * 65536.f))); + renderSetVisibility(((float)(g_visibility) / (8.f / 15.f) / r_ambientlight) * fviewingrange * (4.f / (65536.f * 65536.f))); } static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, int32_t method, const vec2_16_t& tilesiz); From 91cc97ced0d7205b33e214115590c8189148588d Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 24 Mar 2020 07:11:48 +1100 Subject: [PATCH 03/16] Change Next/Previous Weapon button handling for Shadow Warrior. - Makes consistent with Duke 3D, RR and Blood. --- source/sw/src/game.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 2c15a42bc..ded2a330c 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -3190,7 +3190,7 @@ getinput(SW_PACKET *loc, SWBOOL tied) } } - if (buttonMap.ButtonDown(gamefunc_Next_Weapon)) + if (buttonMap.ButtonPressed(gamefunc_Next_Weapon)) { USERp u = User[pp->PlayerSprite]; short next_weapon = u->WeaponNum + 1; @@ -3230,7 +3230,7 @@ getinput(SW_PACKET *loc, SWBOOL tied) } - if (buttonMap.ButtonDown(gamefunc_Previous_Weapon)) + if (buttonMap.ButtonPressed(gamefunc_Previous_Weapon)) { USERp u = User[pp->PlayerSprite]; short prev_weapon = u->WeaponNum - 1; From e1e05eeaa77993e3f3e1c6525878ba33d2957018 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 23 Jun 2020 07:55:05 +1000 Subject: [PATCH 04/16] - change cl_defaultconfiguration default from '2' (leftbinds) to '0' (defbinds). --- source/common/console/c_bind.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/console/c_bind.cpp b/source/common/console/c_bind.cpp index c5a540645..1aad2d255 100644 --- a/source/common/console/c_bind.cpp +++ b/source/common/console/c_bind.cpp @@ -739,7 +739,7 @@ void C_SetDefaultKeys(const char* baseconfig) // // //============================================================================= -CVAR(Int, cl_defaultconfiguration, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Int, cl_defaultconfiguration, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) void C_BindDefaults() From c05eb6dbb6a9d7709c4c6946ed5d818702e8f232 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Fri, 29 May 2020 11:28:41 +1000 Subject: [PATCH 05/16] Blood: Fix issues with weapon not switching properly if cycling the weapons too quickly. - This means that while weapons can't be changed mid-animation, they switch consistently. I feel they animate quick enough, anyway. --- source/blood/src/controls.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index 64fd25ae0..f86948cc6 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -170,16 +170,19 @@ void ctrlGetInput(void) cl_crosshair = !cl_crosshair; } - if (buttonMap.ButtonPressed(gamefunc_Next_Weapon)) + if (gPlayer[myconnectindex].nextWeapon == 0) { - buttonMap.ClearButton(gamefunc_Next_Weapon); - gInput.keyFlags.nextWeapon = 1; - } + if (buttonMap.ButtonPressed(gamefunc_Next_Weapon)) + { + buttonMap.ClearButton(gamefunc_Next_Weapon); + gInput.keyFlags.nextWeapon = 1; + } - if (buttonMap.ButtonPressed(gamefunc_Previous_Weapon)) - { - buttonMap.ClearButton(gamefunc_Previous_Weapon); - gInput.keyFlags.prevWeapon = 1; + if (buttonMap.ButtonPressed(gamefunc_Previous_Weapon)) + { + buttonMap.ClearButton(gamefunc_Previous_Weapon); + gInput.keyFlags.prevWeapon = 1; + } } if (buttonMap.ButtonDown(gamefunc_Show_Opponents_Weapon)) From 291475eeb573893e9f11f867b6a3559fb9565572 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 23 Jun 2020 20:53:53 +1000 Subject: [PATCH 06/16] - simplify visibility calculation from changes performed in d80a32d37905e12e57d2c2e86097290dbf236114. * Achieves the exact same result in a cleaner fashion. --- source/build/src/polymost.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index a308de6e0..ac5638519 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -266,7 +266,7 @@ static void polymost_updaterotmat(void) }; multiplyMatrix4f(matrix, tiltmatrix); renderSetViewMatrix(matrix); - renderSetVisibility(((float)(g_visibility) / (8.f / 15.f) / r_ambientlight) * fviewingrange * (4.f / (65536.f * 65536.f))); + renderSetVisibility(((float)(g_visibility) / r_ambientlight) * fviewingrange * (7.5f / (65536.f * 65536.f))); } static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, int32_t method, const vec2_16_t& tilesiz); From 8c723f52d16c0b8890b0077a2dcb3692ee1a1332 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 24 Jun 2020 23:11:42 +1000 Subject: [PATCH 07/16] - make controller input identical across all games. * Convert axes in ControlInfo struct from int32_t to float as what's received from the backend. * Remove all the scale up/down math since we don't need that with floats and replace with float constants that match old behaviour. * Store q16mlook scaling as a constant for use with mouse and upcoming controller code. * Add required controller code to Blood as the only game not to have working controllers. * Fix typos in (gInput.forward > input.forward) for `ctrlGetInput()` in Blood. * Remove use of `scaleAdjustmentToInterval()` on Exhumed and Shadow Warrior as they only process forward/side velocities within the game's ticrate. * Repair angvel/aimvel scaling mistakes from d79a5d256d7593a3633759f302ebc33cc7710ecb. * Scale dyaw and dpitch by 25% for Shadow Warrior as the game runs 25% faster than the other games, leading to faster input. --- source/blood/src/controls.cpp | 33 +++++++++++++++++++++----------- source/core/inputstate.cpp | 8 ++++---- source/core/inputstate.h | 15 ++++++--------- source/duke3d/src/player.cpp | 11 +++++------ source/exhumed/src/player.cpp | 11 +++++------ source/rr/src/player.cpp | 36 ++++++++++++++++------------------- source/sw/src/game.cpp | 21 ++++++++++++-------- source/sw/src/player.cpp | 6 +++--- 8 files changed, 74 insertions(+), 67 deletions(-) diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index f86948cc6..8734507be 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -306,10 +306,10 @@ void ctrlGetInput(void) if (gInput.forward < keyMove && gInput.forward > -keyMove) { if (buttonMap.ButtonDown(gamefunc_Move_Forward)) - gInput.forward += keyMove; + input.forward += keyMove; if (buttonMap.ButtonDown(gamefunc_Move_Backward)) - gInput.forward -= keyMove; + input.forward -= keyMove; } if (gInput.strafe < keyMove && gInput.strafe > -keyMove) @@ -345,6 +345,10 @@ void ctrlGetInput(void) static int32_t lastInputClock; // MED int32_t const elapsedTics = (int32_t)totalclock - lastInputClock; + // Blood's q16mlook scaling is different from the other games, therefore use the below constant to attenuate + // the speed to match the other games. + float const mlookScale = 3.25f; + lastInputClock = (int32_t) totalclock; if (turnLeft || turnRight) @@ -361,25 +365,32 @@ void ctrlGetInput(void) input.q16turn <<= 1; if (buttonMap.ButtonDown(gamefunc_Strafe)) - input.strafe -= info.mousex; + { + static int strafeyaw; + + input.strafe = -(info.mousex + strafeyaw) >> 3; + strafeyaw = (info.mousex + strafeyaw) % 8; + + input.strafe -= scaleAdjustmentToInterval(info.dyaw * keyMove); + } else + { input.q16turn = fix16_sadd(input.q16turn, fix16_sdiv(fix16_from_int(info.mousex), fix16_from_int(32))); + input.q16turn = fix16_sadd(input.q16turn, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw))); + } - input.strafe -= -(info.dx<<5); + input.strafe -= scaleAdjustmentToInterval(info.dx * keyMove); + input.forward -= scaleAdjustmentToInterval(info.dz * keyMove); -#if 0 - if (info.dz < 0) - gInput.mlook = ClipRange((info.dz+127)>>7, -127, 127); - else - gInput.mlook = ClipRange(info.dz>>7, -127, 127); -#endif if (mouseaim) - input.q16mlook = fix16_sadd(input.q16mlook, fix16_sdiv(fix16_from_int(info.mousey), fix16_from_int(208))); + input.q16mlook = fix16_sadd(input.q16mlook, fix16_sdiv(fix16_from_int(info.mousey), fix16_from_float(mlookScale * 64.f))); else input.forward -= info.mousey; if (!in_mouseflip) input.q16mlook = -input.q16mlook; + input.q16mlook = fix16_ssub(input.q16mlook, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch / mlookScale))); + if (!gViewMap.bFollowMode && gViewMode == 4) { gViewMap.turn += input.q16turn<<2; diff --git a/source/core/inputstate.cpp b/source/core/inputstate.cpp index 7df21cad6..0bac2c696 100644 --- a/source/core/inputstate.cpp +++ b/source/core/inputstate.cpp @@ -195,9 +195,9 @@ void CONTROL_GetInput(ControlInfo* info) I_GetAxes(joyaxes); - info->dyaw += -joyaxes[JOYAXIS_Yaw] * joyaxesScale; - info->dx += -joyaxes[JOYAXIS_Side] * joyaxesScale; - info->dz += -joyaxes[JOYAXIS_Forward] * joyaxesScale; - info->dpitch += -joyaxes[JOYAXIS_Pitch] * joyaxesScale; + info->dyaw += -joyaxes[JOYAXIS_Yaw] * 45.f; + info->dx += -joyaxes[JOYAXIS_Side] * 0.75f; + info->dz += -joyaxes[JOYAXIS_Forward] * 0.75f; + info->dpitch += -joyaxes[JOYAXIS_Pitch] * 22.5f; } } diff --git a/source/core/inputstate.h b/source/core/inputstate.h index f61b75305..9d5bcd922 100644 --- a/source/core/inputstate.h +++ b/source/core/inputstate.h @@ -15,12 +15,12 @@ typedef uint16_t kb_scancode; struct ControlInfo { - int32_t dx; - int32_t dy; - int32_t dz; - int32_t dyaw; - int32_t dpitch; - int32_t droll; + float dx; + float dy; + float dz; + float dyaw; + float dpitch; + float droll; int32_t mousex; int32_t mousey; }; @@ -179,9 +179,6 @@ public: extern InputState inputState; -const int analogExtent = 32767; // used as a divisor for scaling joystick input. -const float joyaxesScale = (float)analogExtent * 0.75f; // used as a multiplier for scaling joystick input. - void CONTROL_GetInput(ControlInfo* info); int32_t handleevents(void); diff --git a/source/duke3d/src/player.cpp b/source/duke3d/src/player.cpp index a174c03d2..f3462d1ac 100644 --- a/source/duke3d/src/player.cpp +++ b/source/duke3d/src/player.cpp @@ -3084,7 +3084,6 @@ void P_GetInput(int const playerNum) // JBF: Run key behaviour is selectable int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN; - constexpr int analogTurnAmount = (NORMALTURN << 1); int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE; input_t input {}; @@ -3096,12 +3095,12 @@ void P_GetInput(int const playerNum) input.svel = -(info.mousex + strafeyaw) >> 3; strafeyaw = (info.mousex + strafeyaw) % 8; - input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove / analogExtent); + input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove); } else { input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32))); - input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw * analogTurnAmount / (analogExtent >> 1)))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw))); } if (mouseaim) @@ -3111,9 +3110,9 @@ void P_GetInput(int const playerNum) if (!in_mouseflip) input.q16horz = -input.q16horz; - input.q16horz = fix16_ssub(input.q16horz, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch * analogTurnAmount / analogExtent))); - input.svel -= scaleAdjustmentToInterval(info.dx * keyMove / analogExtent); - input.fvel -= scaleAdjustmentToInterval(info.dz * keyMove / analogExtent); + input.q16horz = fix16_ssub(input.q16horz, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch))); + input.svel -= scaleAdjustmentToInterval(info.dx * keyMove); + input.fvel -= scaleAdjustmentToInterval(info.dz * keyMove); if (buttonMap.ButtonDown(gamefunc_Strafe)) { diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index 53195a3c6..8c6cab0ba 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -188,7 +188,6 @@ void PlayerInterruptKeys() int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); int const turnAmount = playerRunning ? 12 : 8; int const keyMove = playerRunning ? 12 : 6; - int const analogTurnAmount = 12; if (buttonMap.ButtonDown(gamefunc_Strafe)) { @@ -197,12 +196,12 @@ void PlayerInterruptKeys() input.xVel = -(info.mousex + strafeyaw) >> 6; strafeyaw = (info.mousex + strafeyaw) % 64; - input.xVel -= scaleAdjustmentToInterval(info.dyaw * keyMove / analogExtent); + input.xVel -= info.dyaw * keyMove; } else { input.nAngle = fix16_sadd(input.nAngle, fix16_sdiv(fix16_from_int(info.mousex), fix16_from_int(32))); - input.nAngle = fix16_sadd(input.nAngle, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw * analogTurnAmount / (analogExtent >> 1)))); + input.nAngle = fix16_sadd(input.nAngle, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw))); } g_MyAimMode = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming); @@ -214,9 +213,9 @@ void PlayerInterruptKeys() if (!in_mouseflip) input.horizon = -input.horizon; - input.horizon = fix16_ssub(input.horizon, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch * analogTurnAmount / analogExtent))); - input.xVel -= scaleAdjustmentToInterval(info.dx * keyMove / analogExtent); - input.yVel -= scaleAdjustmentToInterval(info.dz * keyMove / analogExtent); + input.horizon = fix16_ssub(input.horizon, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch))); + input.xVel -= info.dx * keyMove; + input.yVel -= info.dz * keyMove; if (buttonMap.ButtonDown(gamefunc_Strafe)) { diff --git a/source/rr/src/player.cpp b/source/rr/src/player.cpp index 6a15e5529..768cab4ca 100644 --- a/source/rr/src/player.cpp +++ b/source/rr/src/player.cpp @@ -3254,7 +3254,6 @@ void P_GetInput(int const playerNum) int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN; - int const analogTurnAmount = (NORMALTURN << 1); int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE; input_t input {}; @@ -3266,12 +3265,12 @@ void P_GetInput(int const playerNum) input.svel = -(info.mousex + strafeyaw) >> 3; strafeyaw = (info.mousex + strafeyaw) % 8; - input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove / analogExtent); + input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove); } else { input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32))); - input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw * analogTurnAmount / (analogExtent >> 1)))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw))); } if (mouseaim) @@ -3281,9 +3280,9 @@ void P_GetInput(int const playerNum) if (!in_mouseflip) input.q16horz = -input.q16horz; - input.q16horz = fix16_ssub(input.q16horz, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch * analogTurnAmount / analogExtent))); - input.svel -= scaleAdjustmentToInterval(info.dx * keyMove / analogExtent); - input.fvel -= scaleAdjustmentToInterval(info.dz * keyMove / analogExtent); + input.q16horz = fix16_ssub(input.q16horz, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch))); + input.svel -= scaleAdjustmentToInterval(info.dx * keyMove); + input.fvel -= scaleAdjustmentToInterval(info.dz * keyMove); if (buttonMap.ButtonDown(gamefunc_Strafe)) { @@ -3668,16 +3667,15 @@ void P_GetInputMotorcycle(int playerNum) // JBF: Run key behaviour is selectable int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); - int const analogTurnAmount = (NORMALTURN << 1); int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE; input_t input {}; input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32))); - input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw * analogTurnAmount / (analogExtent >> 1)))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw))); - input.svel -= scaleAdjustmentToInterval(info.dx * keyMove / analogExtent); - input.fvel -= scaleAdjustmentToInterval(info.dz * keyMove / analogExtent); + input.svel -= scaleAdjustmentToInterval(info.dx * keyMove); + input.fvel -= scaleAdjustmentToInterval(info.dz * keyMove); pPlayer->crouch_toggle = 0; @@ -3918,16 +3916,15 @@ void P_GetInputBoat(int playerNum) // JBF: Run key behaviour is selectable int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); - int const analogTurnAmount = (NORMALTURN << 1); int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE; input_t input {}; input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32))); - input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw * analogTurnAmount / (analogExtent >> 1)))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw))); - input.svel -= scaleAdjustmentToInterval(info.dx * keyMove / analogExtent); - input.fvel -= scaleAdjustmentToInterval(info.dz * keyMove / analogExtent); + input.svel -= scaleAdjustmentToInterval(info.dx * keyMove); + input.fvel -= scaleAdjustmentToInterval(info.dz * keyMove); pPlayer->crouch_toggle = 0; @@ -4159,7 +4156,6 @@ void P_DHGetInput(int const playerNum) int const playerCrouch = sub_299D8(); int const playerJump = buttonMap.ButtonDown(gamefunc_Jump) && !(pPlayer->cursectnum >= 0 && sector[pPlayer->cursectnum].hitag == 2003); int const turnAmount = playerCrouch ? 2 : (playerRunning ? 16 : 8); - int const analogTurnAmount = 16; int const keyMove = playerCrouch ? 3 : (playerRunning ? 24 : 12); input_t input {}; @@ -4171,12 +4167,12 @@ void P_DHGetInput(int const playerNum) input.svel = -(info.mousex + strafeyaw) >> 3; strafeyaw = (info.mousex + strafeyaw) % 8; - input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove / analogExtent); + input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove); } else { input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32))); - input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw * analogTurnAmount / (analogExtent >> 1)))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw))); } if (mouseaim) @@ -4186,9 +4182,9 @@ void P_DHGetInput(int const playerNum) if (!in_mouseflip) input.q16horz = -input.q16horz; - input.q16horz = fix16_ssub(input.q16horz, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch * analogTurnAmount / analogExtent))); - input.svel -= scaleAdjustmentToInterval(info.dx * keyMove / analogExtent); - input.fvel -= scaleAdjustmentToInterval(info.dz * keyMove / analogExtent); + input.q16horz = fix16_ssub(input.q16horz, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch))); + input.svel -= scaleAdjustmentToInterval(info.dx * keyMove); + input.fvel -= scaleAdjustmentToInterval(info.dz * keyMove); auto scaleAdjustmentToInterval = [=](double x) { return x * REALGAMETICSPERSEC / (1000.0 / elapsedInputTicks); }; diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index ded2a330c..5a96d3031 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -2996,7 +2996,12 @@ getinput(SW_PACKET *loc, SWBOOL tied) // The function DoPlayerTurn() scales the player's q16angvel by 1.40625, so store as constant // and use to scale back player's aim and ang values for a consistent feel between games. - float const inputScale = 1.40625f; + float const angvelScale = 1.40625f; + float const aimvelScale = 1.203125f; + + // Shadow Warrior has a ticrate of 40, 25% more than the other games, so store below constant + // for dividing controller input to match speed input speed of other games. + float const ticrateScale = 0.75f; if (running) { @@ -3026,25 +3031,25 @@ getinput(SW_PACKET *loc, SWBOOL tied) if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop) { svel = -info.mousex; - svel -= scaleAdjustmentToInterval(info.dyaw * keymove / analogExtent); + svel -= info.dyaw * keymove; } else { - q16angvel = fix16_div(fix16_from_int(info.mousex), fix16_from_int(inputScale * 32)); - q16angvel += fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw * turnamount / (inputScale * (analogExtent >> 1)))); + q16angvel = fix16_div(fix16_from_int(info.mousex), fix16_from_float(angvelScale * 32.f)); + q16angvel += fix16_from_dbl(scaleAdjustmentToInterval((info.dyaw * ticrateScale) / angvelScale)); } if (mouseaim) - q16aimvel = -fix16_div(fix16_from_int(info.mousey), fix16_from_int((inputScale / 2) * 64)); + q16aimvel = -fix16_div(fix16_from_int(info.mousey), fix16_from_float(aimvelScale * 64.f)); else vel = -(info.mousey >> 6); if (in_mouseflip) q16aimvel = -q16aimvel; - q16aimvel -= fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch * turnamount / ((inputScale / 2) * analogExtent))); - svel -= scaleAdjustmentToInterval(info.dx * keymove / analogExtent); - vel -= scaleAdjustmentToInterval(info.dz * keymove / analogExtent); + q16aimvel -= fix16_from_dbl(scaleAdjustmentToInterval((info.dpitch * ticrateScale) / aimvelScale)); + svel -= info.dx * keymove; + vel -= info.dz * keymove; if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop) { diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index ff1e8f13d..c596bc024 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -2531,9 +2531,9 @@ MoveScrollMode2D(PLAYERp pp) } if (buttonMap.ButtonDown(gamefunc_Strafe)) - mfsvel -= scrl_input.dyaw>>2; - mfsvel -= scrl_input.dx>>2; - mfvel = -scrl_input.dz>>2; + mfsvel -= scrl_input.dyaw / 4; + mfsvel -= scrl_input.dx / 4; + mfvel = -scrl_input.dz /4; #if 0 int const running = !!BUTTON(gamefunc_Run) ^ !!TEST(pp->Flags, PF_LOCK_RUN); From 43f899f2ce9a3e01832149240a4038aded583eb6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 24 Jun 2020 22:02:23 +0200 Subject: [PATCH 08/16] - Do not start multiple instances of the same sound on the same source in Exhumed. From the looks of it the engine calls the sound function repeatedly while the sound plays to perform distance checks. With the OpenAL backend these checks are totally unnecessary and shouldn't do anything. --- source/exhumed/src/sound.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/exhumed/src/sound.cpp b/source/exhumed/src/sound.cpp index 86512fd38..1ff7e3c05 100644 --- a/source/exhumed/src/sound.cpp +++ b/source/exhumed/src/sound.cpp @@ -577,6 +577,7 @@ void PlayFX2(unsigned short nSound, short nSprite) if (nSprite >= 0) { + if (soundEngine->IsSourcePlayingSomething(SOURCE_Actor, &sprite[nSprite], CHAN_BODY, nSound + 1)) return; soundEngine->StartSound(SOURCE_Actor, &sprite[nSprite], nullptr, CHAN_BODY, CHANF_OVERLAP, nSound+1, nVolume / 255.f, ATTN_NORM, nullptr, (11025 + nPitch) / 11025.f); } else From 16db8195d5a4f3df82e553325ece49c7866fec96 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 Jun 2020 12:20:24 +0200 Subject: [PATCH 09/16] - fixed incomplete texts in inventory. This didn't properly discover bad lowercase entries in the font. --- source/core/2d/screentext.cpp | 39 ++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/source/core/2d/screentext.cpp b/source/core/2d/screentext.cpp index 4202ea1e0..f042bbc9b 100644 --- a/source/core/2d/screentext.cpp +++ b/source/core/2d/screentext.cpp @@ -83,6 +83,21 @@ char* G_GetSubString(const char *text, const char *end, const int32_t iter, cons #define USERQUOTE_RIGHTOFFSET 14 +static int GetStringTile(int font, const char* t, int f) +{ + int ret = gi->GetStringTile(font, t, f); + auto tex = tileGetTexture(ret); + if (!tex || !tex->isValid()) + { + if (*t >= 'a' && *t <= 'z') + { + char tt = *t - 32; + ret = gi->GetStringTile(font, &tt, f); + } + } + return ret; +} + // qstrdim vec2_t G_ScreenTextSize(const int32_t font, @@ -171,7 +186,7 @@ vec2_t G_ScreenTextSize(const int32_t font, } // translate the character to a tilenum - tile = gi->GetStringTile(font, &t, f); + tile = GetStringTile(font, &t, f); // reset this here because we haven't printed anything yet this loop extent.x = 0; @@ -192,7 +207,7 @@ vec2_t G_ScreenTextSize(const int32_t font, char space = '.'; // this is subject to change as an implementation detail if (f & TEXT_TILESPACE) space = '\x7F'; // tile after '~' - tile = gi->GetStringTile(font, &space, f); + tile = GetStringTile(font, &space, f); extent.x += (tilesiz[tile].x * z); } @@ -206,7 +221,7 @@ vec2_t G_ScreenTextSize(const int32_t font, char line = 'A'; // this is subject to change as an implementation detail if (f & TEXT_TILELINE) line = '\x7F'; // tile after '~' - tile = gi->GetStringTile(font, &line, f); + tile = GetStringTile(font, &line, f); tempyextent += tilesiz[tile].y * z; } @@ -239,7 +254,7 @@ vec2_t G_ScreenTextSize(const int32_t font, char line = 'A'; // this is subject to change as an implementation detail if (f & TEXT_TILELINE) line = '\x7F'; // tile after '~' - tile = gi->GetStringTile(font, &line, f); + tile = GetStringTile(font, &line, f); tempyextent += tilesiz[tile].y * z; } @@ -267,7 +282,7 @@ vec2_t G_ScreenTextSize(const int32_t font, if (NUMHACKACTIVE) { char numeral = '0'; // this is subject to change as an implementation detail - extent.x = (tilesiz[gi->GetStringTile(font, &numeral, f)].x-1) * z; + extent.x = (tilesiz[GetStringTile(font, &numeral, f)].x-1) * z; } // height @@ -328,7 +343,7 @@ vec2_t G_ScreenTextSize(const int32_t font, char line = 'A'; // this is subject to change as an implementation detail if (f & TEXT_TILELINE) line = '\x7F'; // tile after '~' - tile = gi->GetStringTile(font, &line, f); + tile = GetStringTile(font, &line, f); tempyextent += tilesiz[tile].y * z; } @@ -559,7 +574,7 @@ vec2_t G_ScreenText(const int32_t font, } // translate the character to a tilenum - tile = gi->GetStringTile(font, &t, f); + tile = GetStringTile(font, &t, f); switch (t) { @@ -601,7 +616,7 @@ vec2_t G_ScreenText(const int32_t font, char space = '.'; // this is subject to change as an implementation detail if (f & TEXT_TILESPACE) space = '\x7F'; // tile after '~' - tile = gi->GetStringTile(font, &space, f); + tile = GetStringTile(font, &space, f); extent.x += (tilesiz[tile].x * z); } @@ -615,7 +630,7 @@ vec2_t G_ScreenText(const int32_t font, char line = 'A'; // this is subject to change as an implementation detail if (f & TEXT_TILELINE) line = '\x7F'; // tile after '~' - tile = gi->GetStringTile(font, &line, f); + tile = GetStringTile(font, &line, f); tempyextent += tilesiz[tile].y * z; } @@ -643,7 +658,7 @@ vec2_t G_ScreenText(const int32_t font, char line = 'A'; // this is subject to change as an implementation detail if (f & TEXT_TILELINE) line = '\x7F'; // tile after '~' - tile = gi->GetStringTile(font, &line, f); + tile = GetStringTile(font, &line, f); tempyextent += tilesiz[tile].y * z; } @@ -694,7 +709,7 @@ vec2_t G_ScreenText(const int32_t font, if (NUMHACKACTIVE) { char numeral = '0'; // this is subject to change as an implementation detail - extent.x = (tilesiz[gi->GetStringTile(font, &numeral, f)].x-1) * z; + extent.x = (tilesiz[GetStringTile(font, &numeral, f)].x-1) * z; } // height @@ -752,7 +767,7 @@ vec2_t G_ScreenText(const int32_t font, char line = 'A'; // this is subject to change as an implementation detail if (f & TEXT_TILELINE) line = '\x7F'; // tile after '~' - tile = gi->GetStringTile(font, &line, f); + tile = GetStringTile(font, &line, f); tempyextent += tilesiz[tile].y * z; } From fc017f58681d5f00ce292177b19aeeca0180b78f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 Jun 2020 20:28:57 +0200 Subject: [PATCH 10/16] - removed unused editwall variable. --- source/build/include/build.h | 3 +-- source/build/src/engine.cpp | 17 ----------------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 37b93a408..00f5c8db1 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -577,6 +577,7 @@ typedef struct { int8_t tileofs[MAXPSKYTILES]; // for 0 <= j < (1<>3]; EXTERN char gotsector[(MAXSECTORS+7)>>3]; -EXTERN char editwall[(MAXWALLS+7)>>3]; - extern uint32_t drawlinepat; extern void faketimerhandler(void); diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 418fef914..05d3f78a5 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -3426,7 +3426,6 @@ static void enginePrepareLoadBoard(FileReader & fr, vec3_t *dapos, int16_t *daan show2dsector.Zero(); Bmemset(show2dsprite, 0, sizeof(show2dsprite)); Bmemset(show2dwall, 0, sizeof(show2dwall)); - Bmemset(editwall, 0, sizeof(editwall)); #ifdef USE_STRUCT_TRACKERS Bmemset(sectorchanged, 0, sizeof(sectorchanged)); Bmemset(spritechanged, 0, sizeof(spritechanged)); @@ -4830,22 +4829,6 @@ void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day, uint8_t flags) } } } - - if (editstatus) - { - int32_t w; - // TODO: extern a separate bitmap instead? - for (w=0; w>3] & pow2char[w&7]) - { - editwall[w>>3] |= 1<<(w&7); - if (flags&2) - { - int wn = lastwall(w); - editwall[wn>>3] |= 1<<(wn&7); - } - } - } } // From bbacc9e816c3cce64c204c7cbe4bf8943eed1961 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Fri, 3 Jul 2020 17:38:42 +1000 Subject: [PATCH 11/16] - factor in xdimenscale and viewingrangerecip when calculating renderSetVisibility(). * Changes performed in 0bd460d9e3bbaf239f4a33f9ce589dff58660bea didn't take into account xdimenscale and viewingrangerecip like the days of old and this wasn't picked up in d80a32d37905e12e57d2c2e86097290dbf236114 or d80a32d37905e12e57d2c2e86097290dbf236114, where the applied fixes only appeared to work because they worked for me at 2560x1440p. --- source/build/include/polymost.h | 1 + source/build/src/engine.cpp | 2 +- source/build/src/polymost.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/build/include/polymost.h b/source/build/include/polymost.h index b79345cd2..99db0cfd2 100644 --- a/source/build/include/polymost.h +++ b/source/build/include/polymost.h @@ -108,5 +108,6 @@ EDUKE32_STATIC_ASSERT(DAMETH_NARROW_MASKPROPS(DAMETH_MASKPROPS) == DAMETH_MASK); extern float fcosglobalang, fsinglobalang; extern float fxdim, fydim, fydimen, fviewingrange; +extern int32_t viewingrangerecip; #endif diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 05d3f78a5..618088285 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -1104,7 +1104,7 @@ static int32_t globaluclip, globaldclip; //char globparaceilclip, globparaflorclip; int32_t xyaspect; -static int32_t viewingrangerecip; +int32_t viewingrangerecip; static char globalxshift, globalyshift; static int32_t globalxpanning, globalypanning; diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index ac5638519..7ff3c180c 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -266,7 +266,7 @@ static void polymost_updaterotmat(void) }; multiplyMatrix4f(matrix, tiltmatrix); renderSetViewMatrix(matrix); - renderSetVisibility(((float)(g_visibility) / r_ambientlight) * fviewingrange * (7.5f / (65536.f * 65536.f))); + renderSetVisibility(mulscale16(g_visibility, mulscale16(xdimenscale, viewingrangerecip)) * fviewingrange * (1.f / (65536.f * 65536.f)) / r_ambientlight); } static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, int32_t method, const vec2_16_t& tilesiz); From 25c5b76f91c4ea16d18cba3823e33d78c3e7e583 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 5 Jul 2020 11:04:34 +1000 Subject: [PATCH 12/16] - make SDL mouse scaling match that of Windows for consistency. --- source/common/platform/posix/sdl/i_input.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/source/common/platform/posix/sdl/i_input.cpp b/source/common/platform/posix/sdl/i_input.cpp index 6b34e6d64..846796831 100644 --- a/source/common/platform/posix/sdl/i_input.cpp +++ b/source/common/platform/posix/sdl/i_input.cpp @@ -225,14 +225,10 @@ static void MouseRead () } SDL_GetRelativeMouseState (&x, &y); - if (!m_noprescale) - { - x *= 3; - y *= 2; - } + if (x | y) { - PostMouseMove (x, -y); + PostMouseMove (m_noprescale ? x : x << 2, -y); } } From bb57590d340e2ac7defb200c6f464ad26b9aa74a Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 5 Jul 2020 11:31:48 +1000 Subject: [PATCH 13/16] =?UTF-8?q?-=20add=20`gl=5Ftexture`=20CVAR=20to=20gl?= =?UTF-8?q?backend=20=C3=A0=20la=20GZDoom.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Will be useful for further debugging of the lighting to determine whether Build actually did/does do different visibility for floor/walls/ceilings, etc. * Idea inspired by Gez: https://forum.zdoom.org/viewtopic.php?f=341&t=68838&start=75#p1158294 --- source/glbackend/glbackend.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 9401b4786..c00689bb7 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -50,6 +50,8 @@ #include "hw_renderstate.h" #include "hw_cvars.h" +CVAR(Bool, gl_texture, true, 0) + F2DDrawer twodpsp; static int BufferLock = 0; @@ -167,7 +169,7 @@ void PolymostRenderState::Apply(FRenderState& state, GLState& oldState) } else { - state.EnableTexture(true); + state.EnableTexture(gl_texture); state.SetMaterial(mMaterial.mMaterial, mMaterial.mClampMode, mMaterial.mTranslation, mMaterial.mOverrideShader); } /* todo: bind indexed textures */ From c70cc474a01fb39b2d386cd37471cadeaffa86cb Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 5 Jul 2020 12:02:33 +1000 Subject: [PATCH 14/16] - change mouse input from int to float and adjust games accordingly. * Calculate game-side mousex/mousey divisions into the calculations performed in `InputState::GetMouseDelta()`. * Fix mouse speed when `in_mousesmoothing` is true (wasn't factoring in / 3.f division used in non-true vector. * Standard mouse forward/side movement speeds in Exhumed & SW with that of other games. * Remove `strafeyaw` code from Duke/Exhumed/RR as it's not necessary and was leading to situations where the player would continually keep moving sideways even without input. * Change mouse forward/side velocities to -= current value as is done with controller input and the player's angle/aim velocities. --- source/blood/src/controls.cpp | 12 ++++-------- source/core/inputstate.cpp | 18 ++++++++++-------- source/core/inputstate.h | 10 +++++----- source/duke3d/src/player.cpp | 12 ++++-------- source/exhumed/src/player.cpp | 12 ++++-------- source/rr/src/player.cpp | 28 ++++++++++------------------ source/sw/src/game.cpp | 10 +++++----- 7 files changed, 42 insertions(+), 60 deletions(-) diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index 8734507be..82ea3d440 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -366,16 +366,12 @@ void ctrlGetInput(void) if (buttonMap.ButtonDown(gamefunc_Strafe)) { - static int strafeyaw; - - input.strafe = -(info.mousex + strafeyaw) >> 3; - strafeyaw = (info.mousex + strafeyaw) % 8; - + input.strafe -= info.mousex * 32.f; input.strafe -= scaleAdjustmentToInterval(info.dyaw * keyMove); } else { - input.q16turn = fix16_sadd(input.q16turn, fix16_sdiv(fix16_from_int(info.mousex), fix16_from_int(32))); + input.q16turn = fix16_sadd(input.q16turn, fix16_from_float(info.mousex)); input.q16turn = fix16_sadd(input.q16turn, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw))); } @@ -383,9 +379,9 @@ void ctrlGetInput(void) input.forward -= scaleAdjustmentToInterval(info.dz * keyMove); if (mouseaim) - input.q16mlook = fix16_sadd(input.q16mlook, fix16_sdiv(fix16_from_int(info.mousey), fix16_from_float(mlookScale * 64.f))); + input.q16mlook = fix16_sadd(input.q16mlook, fix16_from_float(info.mousey / mlookScale)); else - input.forward -= info.mousey; + input.forward -= info.mousey * 64.f; if (!in_mouseflip) input.q16mlook = -input.q16mlook; diff --git a/source/core/inputstate.cpp b/source/core/inputstate.cpp index 0bac2c696..b62560eef 100644 --- a/source/core/inputstate.cpp +++ b/source/core/inputstate.cpp @@ -46,22 +46,24 @@ void InputState::GetMouseDelta(ControlInfo * info) { - vec2_t input; + vec2f_t input, finput; input = g_mousePos; g_mousePos = {}; - vec2f_t finput = { float(input.x) / 3.0f, float(input.y) }; - if (in_mousesmoothing) { - static vec2_t last; - finput = { float(input.x + last.x) * 0.5f, float(input.y + last.y) * 0.5f }; + static vec2f_t last; + finput = { (input.x + last.x) * 0.5f, (input.y + last.y) * 0.5f }; last = input; } + else + { + finput = { input.x, input.y }; + } - info->mousex = int(finput.x * (16.f) * in_mousesensitivity * in_mousescalex); - info->mousey = int(finput.y * (16.f) * in_mousesensitivity * in_mousescaley); + info->mousex = finput.x * (16.f / 32.f) * in_mousesensitivity * in_mousescalex / 3.f; + info->mousey = finput.y * (16.f / 64.f) * in_mousesensitivity * in_mousescaley; // todo: Use these when the mouse is used for moving instead of turning. //info->mousex = int(finput.x * (4.f) * in_mousesensitivity * in_mouseside); @@ -69,7 +71,7 @@ void InputState::GetMouseDelta(ControlInfo * info) if (in_mousebias) { - if (abs(info->mousex) > abs(info->mousey)) + if (fabs(info->mousex) > fabs(info->mousey)) info->mousey /= in_mousebias; else info->mousex /= in_mousebias; diff --git a/source/core/inputstate.h b/source/core/inputstate.h index 9d5bcd922..4e5b9eb71 100644 --- a/source/core/inputstate.h +++ b/source/core/inputstate.h @@ -21,8 +21,8 @@ struct ControlInfo float dyaw; float dpitch; float droll; - int32_t mousex; - int32_t mousey; + float mousex; + float mousey; }; @@ -42,7 +42,7 @@ class InputState uint8_t g_keyAsciiPos; uint8_t g_keyAsciiEnd; - vec2_t g_mousePos; + vec2f_t g_mousePos; void keySetState(int32_t key, int32_t state); @@ -140,11 +140,11 @@ public: void AddEvent(const event_t* ev); - void MouseSetPos(int x, int y) + void MouseSetPos(float x, float y) { g_mousePos = { x, y }; } - void MouseAddToPos(int x, int y) + void MouseAddToPos(float x, float y) { g_mousePos.x += x; g_mousePos.y += y; diff --git a/source/duke3d/src/player.cpp b/source/duke3d/src/player.cpp index f3462d1ac..555cc92ec 100644 --- a/source/duke3d/src/player.cpp +++ b/source/duke3d/src/player.cpp @@ -3090,23 +3090,19 @@ void P_GetInput(int const playerNum) if (buttonMap.ButtonDown(gamefunc_Strafe)) { - static int strafeyaw; - - input.svel = -(info.mousex + strafeyaw) >> 3; - strafeyaw = (info.mousex + strafeyaw) % 8; - + input.svel -= info.mousex * 4.f; input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove); } else { - input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_float(info.mousex)); input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw))); } if (mouseaim) - input.q16horz = fix16_sadd(input.q16horz, fix16_sdiv(fix16_from_int(info.mousey), F16(64))); + input.q16horz = fix16_sadd(input.q16horz, fix16_from_float(info.mousey)); else - input.fvel = -(info.mousey >> 3); + input.fvel -= info.mousey * 8.f; if (!in_mouseflip) input.q16horz = -input.q16horz; diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index 8c6cab0ba..ab2e60089 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -191,25 +191,21 @@ void PlayerInterruptKeys() if (buttonMap.ButtonDown(gamefunc_Strafe)) { - static int strafeyaw; - - input.xVel = -(info.mousex + strafeyaw) >> 6; - strafeyaw = (info.mousex + strafeyaw) % 64; - + input.xVel -= info.mousex * 4.f; input.xVel -= info.dyaw * keyMove; } else { - input.nAngle = fix16_sadd(input.nAngle, fix16_sdiv(fix16_from_int(info.mousex), fix16_from_int(32))); + input.nAngle = fix16_sadd(input.nAngle, fix16_from_float(info.mousex)); input.nAngle = fix16_sadd(input.nAngle, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw))); } g_MyAimMode = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming); if (g_MyAimMode) - input.horizon = fix16_sadd(input.horizon, fix16_sdiv(fix16_from_int(info.mousey), fix16_from_int(64))); + input.horizon = fix16_sadd(input.horizon, fix16_from_float(info.mousey)); else - input.yVel = -(info.mousey >> 6); + input.yVel -= info.mousey * 8.f; if (!in_mouseflip) input.horizon = -input.horizon; diff --git a/source/rr/src/player.cpp b/source/rr/src/player.cpp index 768cab4ca..18ba7f7dd 100644 --- a/source/rr/src/player.cpp +++ b/source/rr/src/player.cpp @@ -3260,23 +3260,19 @@ void P_GetInput(int const playerNum) if (buttonMap.ButtonDown(gamefunc_Strafe)) { - static int strafeyaw; - - input.svel = -(info.mousex + strafeyaw) >> 3; - strafeyaw = (info.mousex + strafeyaw) % 8; - + input.svel -= info.mousex * 4.f; input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove); } else { - input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_float(info.mousex)); input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw))); } if (mouseaim) - input.q16horz = fix16_sadd(input.q16horz, fix16_sdiv(fix16_from_int(info.mousey), F16(64))); + input.q16horz = fix16_sadd(input.q16horz, fix16_from_float(info.mousey)); else - input.fvel = -(info.mousey >> 3); + input.fvel -= info.mousey * 8.f; if (!in_mouseflip) input.q16horz = -input.q16horz; @@ -3671,7 +3667,7 @@ void P_GetInputMotorcycle(int playerNum) input_t input {}; - input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_float(info.mousex)); input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw))); input.svel -= scaleAdjustmentToInterval(info.dx * keyMove); @@ -3920,7 +3916,7 @@ void P_GetInputBoat(int playerNum) input_t input {}; - input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_float(info.mousex)); input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw))); input.svel -= scaleAdjustmentToInterval(info.dx * keyMove); @@ -4162,23 +4158,19 @@ void P_DHGetInput(int const playerNum) if (buttonMap.ButtonDown(gamefunc_Strafe)) { - static int strafeyaw; - - input.svel = -(info.mousex + strafeyaw) >> 3; - strafeyaw = (info.mousex + strafeyaw) % 8; - + input.svel -= info.mousex * 4.f; input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove); } else { - input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_float(info.mousex)); input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw))); } if (mouseaim) - input.q16horz = fix16_sadd(input.q16horz, fix16_sdiv(fix16_from_int(info.mousey), F16(64))); + input.q16horz = fix16_sadd(input.q16horz, fix16_from_float(info.mousey)); else - input.fvel = -(info.mousey >> 3); + input.fvel -= info.mousey * 8.f; if (!in_mouseflip) input.q16horz = -input.q16horz; diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 5a96d3031..874dae2fd 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -3030,19 +3030,19 @@ getinput(SW_PACKET *loc, SWBOOL tied) if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop) { - svel = -info.mousex; + svel -= (info.mousex * ticrateScale) * 4.f; svel -= info.dyaw * keymove; } else { - q16angvel = fix16_div(fix16_from_int(info.mousex), fix16_from_float(angvelScale * 32.f)); - q16angvel += fix16_from_dbl(scaleAdjustmentToInterval((info.dyaw * ticrateScale) / angvelScale)); + q16angvel = fix16_sadd(q16angvel, fix16_from_float(info.mousex / angvelScale)); + q16angvel = fix16_sadd(q16angvel, fix16_from_dbl(scaleAdjustmentToInterval((info.dyaw * ticrateScale) / angvelScale))); } if (mouseaim) - q16aimvel = -fix16_div(fix16_from_int(info.mousey), fix16_from_float(aimvelScale * 64.f)); + q16aimvel = fix16_ssub(q16aimvel, fix16_from_float(info.mousey / aimvelScale)); else - vel = -(info.mousey >> 6); + vel -= (info.mousey * ticrateScale) * 8.f; if (in_mouseflip) q16aimvel = -q16aimvel; From 30300bf3b2b0f36faa33607223c03a3c86d4a56d Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 5 Jul 2020 16:53:43 +1000 Subject: [PATCH 15/16] - allow shade in glbackend.h to accept negative values, but still at a max of numshades-1. * This fixes some issues with distance lighting issues in Duke3D as reported at https://forum.zdoom.org/viewtopic.php?f=341&t=68838&start=75#p1158417. --- source/glbackend/glbackend.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index c2073f874..9025d0c95 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -143,7 +143,7 @@ public: void SetShade(int32_t shade, int numshades) { - renderState.Shade = clamp(shade, 0, numshades-1); + renderState.Shade = std::max(shade, numshades-1); } void SetVisibility(float visibility) From dae15061826f5776d0671c5d7577a21299fff77e Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 5 Jul 2020 17:02:23 +1000 Subject: [PATCH 16/16] - change `std::max()` to `std::min()` in glbackend.h. Fixes issue in coelckers/Raze#83. --- source/glbackend/glbackend.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index 9025d0c95..e5bb33873 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -143,7 +143,7 @@ public: void SetShade(int32_t shade, int numshades) { - renderState.Shade = std::max(shade, numshades-1); + renderState.Shade = std::min(shade, numshades-1); } void SetVisibility(float visibility)