mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 20:20:40 +00:00
- Duke: Only read keyboard input for movement when called for the actual tic.
Since the added values are not scaled, doing this per frame has the potential risk of achieving too high total velocity when combined with other means of input. The change here was kept as simple as possible.
This commit is contained in:
parent
c5648be2bd
commit
1f4594b450
1 changed files with 54 additions and 49 deletions
|
@ -586,7 +586,7 @@ int getticssincelastupdate()
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void processMovement(player_struct *p, InputPacket &input, ControlInfo* const hidInput, double scaleFactor)
|
||||
static void processMovement(player_struct *p, InputPacket &input, ControlInfo* const hidInput, double scaleFactor, bool allowkeys)
|
||||
{
|
||||
bool mouseaim = !(loc.actions & SB_AIMMODE);
|
||||
|
||||
|
@ -608,21 +608,10 @@ static void processMovement(player_struct *p, InputPacket &input, ControlInfo* c
|
|||
if (!in_mouseflip) input.q16horz = -input.q16horz;
|
||||
|
||||
input.q16horz -= FloatToFixed(scaleFactor * (hidInput->dpitch));
|
||||
input.svel -= scaleFactor * (hidInput->dx * keymove);
|
||||
input.fvel -= scaleFactor * (hidInput->dz * keymove);
|
||||
input.svel -= xs_CRoundToInt(scaleFactor * hidInput->dx * keymove);
|
||||
input.fvel -= xs_CRoundToInt(scaleFactor * hidInput->dz * keymove);
|
||||
|
||||
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
|
||||
if (!buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
{
|
||||
int tics = getticssincelastupdate();
|
||||
|
||||
|
@ -644,44 +633,59 @@ static void processMovement(player_struct *p, InputPacket &input, ControlInfo* c
|
|||
|
||||
}
|
||||
|
||||
if (abs(loc.svel) < keymove)
|
||||
if (allowkeys)
|
||||
{
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe_Left))
|
||||
input.svel += keymove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe_Right))
|
||||
input.svel += -keymove;
|
||||
}
|
||||
|
||||
if (abs(loc.fvel) < keymove)
|
||||
{
|
||||
if (isRR() && p->drink_amt >= 66 && p->drink_amt <= 87)
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
{
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Forward))
|
||||
if (abs(loc.svel) < keymove)
|
||||
{
|
||||
input.fvel += keymove;
|
||||
if (p->drink_amt & 1)
|
||||
input.svel += keymove;
|
||||
else
|
||||
input.svel -= keymove;
|
||||
}
|
||||
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
|
||||
input.svel = keymove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
|
||||
{
|
||||
input.fvel += -keymove;
|
||||
if (p->drink_amt & 1)
|
||||
input.svel -= keymove;
|
||||
else
|
||||
input.svel += keymove;
|
||||
if (buttonMap.ButtonDown(gamefunc_Turn_Right))
|
||||
input.svel = -keymove;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Forward))
|
||||
input.fvel += keymove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
|
||||
input.fvel += -keymove;
|
||||
if (abs(loc.svel) < keymove)
|
||||
{
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe_Left))
|
||||
input.svel = keymove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe_Right))
|
||||
input.svel = -keymove;
|
||||
}
|
||||
|
||||
if (abs(loc.fvel) < keymove)
|
||||
{
|
||||
if (isRR() && p->drink_amt >= 66 && p->drink_amt <= 87)
|
||||
{
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Forward))
|
||||
{
|
||||
input.fvel += keymove;
|
||||
if (p->drink_amt & 1)
|
||||
input.svel += keymove;
|
||||
else
|
||||
input.svel -= keymove;
|
||||
}
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
|
||||
{
|
||||
input.fvel += -keymove;
|
||||
if (p->drink_amt & 1)
|
||||
input.svel -= keymove;
|
||||
else
|
||||
input.svel += keymove;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Forward))
|
||||
input.fvel += keymove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
|
||||
input.fvel -= keymove;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -982,7 +986,7 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void GetInputInternal(InputPacket &locInput, ControlInfo* const hidInput)
|
||||
static void GetInputInternal(InputPacket &locInput, ControlInfo* const hidInput, bool allowkeys)
|
||||
{
|
||||
auto const p = &ps[myconnectindex];
|
||||
|
||||
|
@ -992,6 +996,7 @@ static void GetInputInternal(InputPacket &locInput, ControlInfo* const hidInput)
|
|||
return;
|
||||
}
|
||||
|
||||
// Todo: Handle this through SERVERINFO CVARs.
|
||||
if (numplayers == 1)
|
||||
{
|
||||
setlocalplayerinput(p);
|
||||
|
@ -1015,7 +1020,7 @@ static void GetInputInternal(InputPacket &locInput, ControlInfo* const hidInput)
|
|||
else
|
||||
{
|
||||
processInputBits(p, hidInput);
|
||||
processMovement(p, input, hidInput, scaleAdjust);
|
||||
processMovement(p, input, hidInput, scaleAdjust, allowkeys);
|
||||
checkCrouchToggle(p);
|
||||
FinalizeInput(myconnectindex, input, false);
|
||||
}
|
||||
|
@ -1037,7 +1042,7 @@ static void GetInputInternal(InputPacket &locInput, ControlInfo* const hidInput)
|
|||
|
||||
void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
|
||||
{
|
||||
GetInputInternal(loc, hidInput);
|
||||
GetInputInternal(loc, hidInput, packet != nullptr);
|
||||
if (packet)
|
||||
{
|
||||
auto const pPlayer = &ps[myconnectindex];
|
||||
|
|
Loading…
Reference in a new issue