From d73ea118df554107a2395cb4e5313edd35a8bfd8 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 6 Sep 2020 19:11:12 +1000 Subject: [PATCH 1/2] - SW: Get `cl_syncinput 0` (default) working properly. * Joystick input probably not appropriately scaled. Refactor is coming but lets just get the game workable for now. * Fixes #328. --- source/sw/src/game.cpp | 1 - source/sw/src/input.cpp | 36 ++++++++++++------------------------ source/sw/src/network.cpp | 2 -- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 8677365af..537d612a1 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -87,7 +87,6 @@ BEGIN_SW_NS void Logo(const CompletionFunc& completion); void StatScreen(int FinishAnim, CompletionFunc completion); -void getinput(InputPacket*, SWBOOL); void pClearSpriteList(PLAYERp pp); diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index 9584b8032..64adcb94b 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -67,8 +67,7 @@ void GameInterface::ResetFollowPos(bool) Follow_posy = pp->posy; } -void -getinput(InputPacket *loc, SWBOOL tied) +static void getinput(InputPacket *loc) { int i; PLAYERp pp = Player + myconnectindex; @@ -111,7 +110,7 @@ getinput(InputPacket *loc, SWBOOL tied) // If in 2D follow mode, scroll around using glob vars // Tried calling this in domovethings, but key response it too poor, skips key presses // Note: this get called only during follow mode - if (!tied && automapFollow && automapMode != am_off && pp == Player + myconnectindex && !Prediction) + if (automapFollow && automapMode != am_off && pp == Player + myconnectindex && !Prediction) MoveScrollMode2D(Player + myconnectindex); // !JIM! Added M_Active() so that you don't move at all while using menus @@ -175,9 +174,6 @@ getinput(InputPacket *loc, SWBOOL tied) keymove = NORMALKEYMOVE; } - if (tied) - keymove = 0; - int32_t svel = 0, vel = 0; fixed_t q16horz = 0, q16angvel = 0; @@ -279,23 +275,8 @@ getinput(InputPacket *loc, SWBOOL tied) pp->oq16horiz += pp->camq16horiz - prevcamq16horiz; } - loc->fvel += vel; - loc->svel += svel; - - if (!tied) - { - vel = clamp(loc->fvel, -MAXVEL, MAXVEL); - svel = clamp(loc->svel, -MAXSVEL, MAXSVEL); - - momx = mulscale9(vel, sintable[NORM_ANGLE(FixedToInt(newpp->q16ang) + 512)]); - momy = mulscale9(vel, sintable[NORM_ANGLE(FixedToInt(newpp->q16ang))]); - - momx += mulscale9(svel, sintable[NORM_ANGLE(FixedToInt(newpp->q16ang))]); - momy += mulscale9(svel, sintable[NORM_ANGLE(FixedToInt(newpp->q16ang) + 1536)]); - - loc->fvel = momx; - loc->svel = momy; - } + loc->fvel = clamp(loc->fvel + vel, -MAXVEL, MAXVEL); + loc->svel = clamp(loc->svel + svel, -MAXSVEL, MAXSVEL); loc->q16avel += q16angvel; loc->q16horz += q16horz; @@ -380,10 +361,17 @@ getinput(InputPacket *loc, SWBOOL tied) void GameInterface::GetInput(InputPacket *packet) { - getinput(&loc, FALSE); + getinput(&loc); if (packet) { PLAYERp pp = &Player[myconnectindex]; + + auto fvel = loc.fvel; + auto svel = loc.svel; + auto ang = FixedToInt(pp->camq16ang); + + loc.fvel = mulscale9(fvel, sintable[NORM_ANGLE(ang + 512)]) + mulscale9(svel, sintable[NORM_ANGLE(ang)]); + loc.svel = mulscale9(fvel, sintable[NORM_ANGLE(ang)]) + mulscale9(svel, sintable[NORM_ANGLE(ang + 1536)]); loc.q16ang = pp->camq16ang; loc.q16horiz = pp->camq16horiz; *packet = loc; diff --git a/source/sw/src/network.cpp b/source/sw/src/network.cpp index 4c8d62e4d..6e39d2570 100644 --- a/source/sw/src/network.cpp +++ b/source/sw/src/network.cpp @@ -42,8 +42,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS -void getinput(InputPacket *, SWBOOL); - static uint8_t tempbuf[576], packbuf[576]; int PlayClock; From 677efb20badbfba9b56f151dc91c54700aade96d Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 6 Sep 2020 19:16:24 +1000 Subject: [PATCH 2/2] - SW: Don't check `SB_RUN` as player action in `ChopsCheck()`. Fixes #312. --- source/sw/src/player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index def7e1207..2869decdc 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -7378,7 +7378,7 @@ void ChopsCheck(PLAYERp pp) { if (!M_Active() && !TEST(pp->Flags, PF_DEAD) && !pp->sop_riding && numplayers <= 1) { - if (pp->input.actions || pp->input.fvel || pp->input.svel || pp->input.q16avel || pp->input.q16horz || + if (pp->input.actions & ~SB_RUN || pp->input.fvel || pp->input.svel || pp->input.q16avel || pp->input.q16horz || TEST(pp->Flags, PF_CLIMBING | PF_FALLING | PF_DIVING)) { // Hit a input key or other reason to stop chops