Reverted key input changes from yesterday.

At least the SW version did not work right so let's take no chances here.
This commit is contained in:
Christoph Oelckers 2020-09-15 21:54:10 +02:00
parent d74d65bece
commit 867b8f006f
2 changed files with 75 additions and 88 deletions

View file

@ -586,7 +586,7 @@ int getticssincelastupdate()
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static void processMovement(player_struct *p, InputPacket &input, ControlInfo* const hidInput, double scaleFactor, bool allowkeys) static void processMovement(player_struct *p, InputPacket &input, ControlInfo* const hidInput, double scaleFactor)
{ {
bool mouseaim = !(loc.actions & SB_AIMMODE); bool mouseaim = !(loc.actions & SB_AIMMODE);
@ -608,10 +608,21 @@ static void processMovement(player_struct *p, InputPacket &input, ControlInfo* c
if (!in_mouseflip) input.q16horz = -input.q16horz; if (!in_mouseflip) input.q16horz = -input.q16horz;
input.q16horz -= FloatToFixed(scaleFactor * (hidInput->dpitch)); input.q16horz -= FloatToFixed(scaleFactor * (hidInput->dpitch));
input.svel -= xs_CRoundToInt(scaleFactor * hidInput->dx * keymove); input.svel -= scaleFactor * (hidInput->dx * keymove);
input.fvel -= xs_CRoundToInt(scaleFactor * hidInput->dz * keymove); input.fvel -= scaleFactor * (hidInput->dz * keymove);
if (!buttonMap.ButtonDown(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
{
if (!loc.svel)
{
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
input.svel = keymove;
if (buttonMap.ButtonDown(gamefunc_Turn_Right))
input.svel = -keymove;
}
}
else
{ {
int tics = getticssincelastupdate(); int tics = getticssincelastupdate();
@ -633,27 +644,13 @@ static void processMovement(player_struct *p, InputPacket &input, ControlInfo* c
} }
if (allowkeys)
{
if (buttonMap.ButtonDown(gamefunc_Strafe))
{
if (abs(loc.svel) < keymove)
{
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
input.svel = keymove;
if (buttonMap.ButtonDown(gamefunc_Turn_Right))
input.svel = -keymove;
}
}
if (abs(loc.svel) < keymove) if (abs(loc.svel) < keymove)
{ {
if (buttonMap.ButtonDown(gamefunc_Strafe_Left)) if (buttonMap.ButtonDown(gamefunc_Strafe_Left))
input.svel = keymove; input.svel += keymove;
if (buttonMap.ButtonDown(gamefunc_Strafe_Right)) if (buttonMap.ButtonDown(gamefunc_Strafe_Right))
input.svel = -keymove; input.svel += -keymove;
} }
if (abs(loc.fvel) < keymove) if (abs(loc.fvel) < keymove)
@ -684,8 +681,7 @@ static void processMovement(player_struct *p, InputPacket &input, ControlInfo* c
input.fvel += keymove; input.fvel += keymove;
if (buttonMap.ButtonDown(gamefunc_Move_Backward)) if (buttonMap.ButtonDown(gamefunc_Move_Backward))
input.fvel -= keymove; input.fvel += -keymove;
}
} }
} }
} }
@ -986,7 +982,7 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static void GetInputInternal(InputPacket &locInput, ControlInfo* const hidInput, bool allowkeys) static void GetInputInternal(InputPacket &locInput, ControlInfo* const hidInput)
{ {
auto const p = &ps[myconnectindex]; auto const p = &ps[myconnectindex];
@ -996,7 +992,6 @@ static void GetInputInternal(InputPacket &locInput, ControlInfo* const hidInput,
return; return;
} }
// Todo: Handle this through SERVERINFO CVARs.
if (numplayers == 1) if (numplayers == 1)
{ {
setlocalplayerinput(p); setlocalplayerinput(p);
@ -1020,7 +1015,7 @@ static void GetInputInternal(InputPacket &locInput, ControlInfo* const hidInput,
else else
{ {
processInputBits(p, hidInput); processInputBits(p, hidInput);
processMovement(p, input, hidInput, scaleAdjust, allowkeys); processMovement(p, input, hidInput, scaleAdjust);
checkCrouchToggle(p); checkCrouchToggle(p);
FinalizeInput(myconnectindex, input, false); FinalizeInput(myconnectindex, input, false);
} }
@ -1042,7 +1037,7 @@ static void GetInputInternal(InputPacket &locInput, ControlInfo* const hidInput,
void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
{ {
GetInputInternal(loc, hidInput, packet != nullptr); GetInputInternal(loc, hidInput);
if (packet) if (packet)
{ {
auto const pPlayer = &ps[myconnectindex]; auto const pPlayer = &ps[myconnectindex];

View file

@ -199,7 +199,7 @@ static void processWeapon(PLAYERp const pp)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool const mouseaim, bool allowkeys) static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool const mouseaim)
{ {
double const scaleAdjust = InputScale(); double const scaleAdjust = InputScale();
bool const strafeKey = buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop; bool const strafeKey = buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop;
@ -239,7 +239,17 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool
svel -= xs_CRoundToInt(scaleAdjust * (hidInput->dx * keymove)); svel -= xs_CRoundToInt(scaleAdjust * (hidInput->dx * keymove));
fvel -= xs_CRoundToInt(scaleAdjust * (hidInput->dz * keymove)); fvel -= xs_CRoundToInt(scaleAdjust * (hidInput->dz * keymove));
if (strafeKey || pp->sop) if (strafeKey)
{
if (abs(svel) < keymove)
{
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
svel += keymove;
if (buttonMap.ButtonDown(gamefunc_Turn_Right))
svel -= keymove;
}
}
else
{ {
if (buttonMap.ButtonDown(gamefunc_Turn_Left) || (buttonMap.ButtonDown(gamefunc_Strafe_Left) && pp->sop)) if (buttonMap.ButtonDown(gamefunc_Turn_Left) || (buttonMap.ButtonDown(gamefunc_Strafe_Left) && pp->sop))
{ {
@ -257,31 +267,14 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool
} }
} }
if (allowkeys)
{
if (!pp->sop)
{
if (strafeKey)
{
if (abs(svel) < keymove)
{
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
svel += keymove;
if (buttonMap.ButtonDown(gamefunc_Turn_Right))
svel -= keymove;
}
}
if (abs(loc.svel) < keymove) if (abs(loc.svel) < keymove)
{ {
if (buttonMap.ButtonDown(gamefunc_Strafe_Left)) if (buttonMap.ButtonDown(gamefunc_Strafe_Left) && !pp->sop)
svel += keymove; svel += keymove;
if (buttonMap.ButtonDown(gamefunc_Strafe_Right)) if (buttonMap.ButtonDown(gamefunc_Strafe_Right) && !pp->sop)
svel -= keymove; svel -= keymove;
} }
}
if (abs(loc.fvel) < keymove) if (abs(loc.fvel) < keymove)
{ {
if (buttonMap.ButtonDown(gamefunc_Move_Forward)) if (buttonMap.ButtonDown(gamefunc_Move_Forward))
@ -290,7 +283,6 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool
if (buttonMap.ButtonDown(gamefunc_Move_Backward)) if (buttonMap.ButtonDown(gamefunc_Move_Backward))
fvel -= keymove; fvel -= keymove;
} }
}
if (!cl_syncinput) if (!cl_syncinput)
{ {
@ -366,7 +358,7 @@ void GameInterface::GetInput(InputPacket *packet, ControlInfo* const hidInput)
bool mouseaim; bool mouseaim;
processInputBits(pp, hidInput, &mouseaim); processInputBits(pp, hidInput, &mouseaim);
processMovement(pp, hidInput, mouseaim, packet != nullptr); processMovement(pp, hidInput, mouseaim);
processWeapon(pp); processWeapon(pp);
if (packet) if (packet)