mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-28 12:30:46 +00:00
- make sure that the static time counters in the input code do not accumulate while not in use.
The one for holding the turn key needs to be reset any time there is no turning and everything needs to be cleared when the input state is cleared. And all need to check for the case where the static state is not set yet.
This commit is contained in:
parent
e70115ff5c
commit
36d61fc662
2 changed files with 57 additions and 25 deletions
|
@ -42,6 +42,12 @@ BEGIN_DUKE_NS
|
|||
static int WeaponToSend;
|
||||
static ESyncBits BitsToSend;
|
||||
|
||||
// State timer counters.
|
||||
static int nonsharedtimer;
|
||||
static int turnheldtime;
|
||||
static int lastcontroltime;
|
||||
static double lastCheck;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// handles UI side input not handled via CCMDs or CVARs.
|
||||
|
@ -51,8 +57,6 @@ static ESyncBits BitsToSend;
|
|||
|
||||
void nonsharedkeys(void)
|
||||
{
|
||||
static int nonsharedtimer;
|
||||
|
||||
if (ud.recstat == 2)
|
||||
{
|
||||
ControlInfo noshareinfo;
|
||||
|
@ -187,8 +191,17 @@ void nonsharedkeys(void)
|
|||
|
||||
if (ud.overhead_on != 0)
|
||||
{
|
||||
int j = (int)totalclock - nonsharedtimer;
|
||||
nonsharedtimer += j;
|
||||
int j;
|
||||
if (nonsharedtimer > 0 || totalclock < nonsharedtimer)
|
||||
{
|
||||
j = (int)totalclock - nonsharedtimer;
|
||||
nonsharedtimer += j;
|
||||
}
|
||||
else
|
||||
{
|
||||
j = 0;
|
||||
nonsharedtimer = (int)totalclock;
|
||||
}
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen))
|
||||
ps[myconnectindex].zoom += mulscale6(j, max(ps[myconnectindex].zoom, 256));
|
||||
|
@ -818,6 +831,19 @@ static void checkCrouchToggle(player_struct* p)
|
|||
p->crouch_toggle = 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
int getticssincelastupdate()
|
||||
{
|
||||
int tics = lastcontroltime == 0 || (int)totalclock < lastcontroltime ? 0 : (int)totalclock - lastcontroltime;
|
||||
lastcontroltime = (int)totalclock;
|
||||
return tics;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// handles movement
|
||||
|
@ -862,10 +888,7 @@ static void processMovement(player_struct *p, input_t &input, ControlInfo &info,
|
|||
}
|
||||
else
|
||||
{
|
||||
static int turnheldtime;
|
||||
static int lastcontroltime; // MED
|
||||
int tics = (int)totalclock - lastcontroltime;
|
||||
lastcontroltime = (int)totalclock;
|
||||
int tics = getticssincelastupdate();
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
|
||||
{
|
||||
|
@ -878,7 +901,11 @@ static void processMovement(player_struct *p, input_t &input, ControlInfo &info,
|
|||
input.q16avel += fix16_from_dbl(2 * scaleFactor * (turnheldtime >= TURBOTURNTIME) ? turnamount : PREAMBLETURN);
|
||||
}
|
||||
else
|
||||
{
|
||||
turnheldtime = 0;
|
||||
lastcontroltime = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (loc.svel < abs(keymove))
|
||||
|
@ -931,14 +958,10 @@ static void processMovement(player_struct *p, input_t &input, ControlInfo &info,
|
|||
|
||||
static int motoApplyTurn(player_struct* p, int turnl, int turnr, int bike_turn, bool goback, double factor)
|
||||
{
|
||||
static int turnheldtime;
|
||||
static int lastcontroltime;
|
||||
|
||||
int tics = totalclock - lastcontroltime;
|
||||
lastcontroltime = totalclock;
|
||||
|
||||
if (p->MotoSpeed == 0 || !p->on_ground)
|
||||
{
|
||||
turnheldtime = 0;
|
||||
lastcontroltime = 0;
|
||||
if (turnl)
|
||||
{
|
||||
p->TiltStatus -= (float)factor;
|
||||
|
@ -954,6 +977,7 @@ static int motoApplyTurn(player_struct* p, int turnl, int turnr, int bike_turn,
|
|||
}
|
||||
else
|
||||
{
|
||||
int tics = getticssincelastupdate();
|
||||
if (turnl || p->moto_drink < 0)
|
||||
{
|
||||
turnheldtime += tics;
|
||||
|
@ -991,6 +1015,7 @@ static int motoApplyTurn(player_struct* p, int turnl, int turnr, int bike_turn,
|
|||
else
|
||||
{
|
||||
turnheldtime = 0;
|
||||
lastcontroltime = 0;
|
||||
|
||||
if (p->TiltStatus > 0)
|
||||
p->TiltStatus -= (float)factor;
|
||||
|
@ -1013,11 +1038,7 @@ static int motoApplyTurn(player_struct* p, int turnl, int turnr, int bike_turn,
|
|||
|
||||
static int boatApplyTurn(player_struct *p, int turnl, int turnr, int bike_turn, double factor)
|
||||
{
|
||||
static int turnheldtime;
|
||||
static int lastcontroltime;
|
||||
|
||||
int tics = totalclock - lastcontroltime;
|
||||
lastcontroltime = totalclock;
|
||||
int tics = getticssincelastupdate();
|
||||
|
||||
if (p->MotoSpeed)
|
||||
{
|
||||
|
@ -1064,6 +1085,7 @@ static int boatApplyTurn(player_struct *p, int turnl, int turnr, int bike_turn,
|
|||
else if (!p->NotOnWater)
|
||||
{
|
||||
turnheldtime = 0;
|
||||
lastcontroltime = 0;
|
||||
|
||||
if (p->TiltStatus > 0)
|
||||
p->TiltStatus -= (float)factor;
|
||||
|
@ -1074,6 +1096,11 @@ static int boatApplyTurn(player_struct *p, int turnl, int turnr, int bike_turn,
|
|||
p->TiltStatus = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
turnheldtime = 0;
|
||||
lastcontroltime = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1199,7 +1226,6 @@ static void FinalizeInput(int playerNum, input_t& input, bool vehicle)
|
|||
|
||||
void GetInput()
|
||||
{
|
||||
static double lastCheck;
|
||||
double elapsedInputTicks;
|
||||
auto const p = &ps[myconnectindex];
|
||||
updatePauseStatus();
|
||||
|
@ -1305,11 +1331,16 @@ void registerinputcommands()
|
|||
C_RegisterFunction("invuse", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_INVENTORY; return CCMD_OK; });
|
||||
}
|
||||
|
||||
// This is called from ImputState::ClearAllInput
|
||||
// This is called from ImputState::ClearAllInput and resets all static state being used here.
|
||||
void GameInterface::clearlocalinputstate()
|
||||
{
|
||||
WeaponToSend = 0;
|
||||
BitsToSend = 0;
|
||||
nonsharedtimer = 0;
|
||||
turnheldtime = 0;
|
||||
lastcontroltime = 0;
|
||||
lastCheck = 0;
|
||||
|
||||
}
|
||||
|
||||
END_DUKE_NS
|
||||
|
|
|
@ -35,6 +35,8 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
|||
// PRIMITIVE
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
static bool sound445done; // what is this supposed to do? Looks broken.
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -2616,11 +2618,10 @@ void checksectors_r(int snum)
|
|||
if (!isRRRA()) return;
|
||||
if (numplayers == 1)
|
||||
{
|
||||
static bool alreadydone; // what is this supposed to do? Looks broken.
|
||||
// This is from RedneckGDX - the version in RR Reconstruction looked like broken nonsense.
|
||||
if (S_CheckSoundPlaying(neartagsprite, 445) || alreadydone != 0)
|
||||
if (S_CheckSoundPlaying(neartagsprite, 445) || sound445done != 0)
|
||||
{
|
||||
if (!S_CheckSoundPlaying(neartagsprite, 445) && !S_CheckSoundPlaying(neartagsprite, 446) && !S_CheckSoundPlaying(neartagsprite, 447) && alreadydone != 0)
|
||||
if (!S_CheckSoundPlaying(neartagsprite, 445) && !S_CheckSoundPlaying(neartagsprite, 446) && !S_CheckSoundPlaying(neartagsprite, 447) && sound445done != 0)
|
||||
{
|
||||
if ((krand() % 2) == 1)
|
||||
spritesound(446, neartagsprite);
|
||||
|
@ -2631,7 +2632,7 @@ void checksectors_r(int snum)
|
|||
else
|
||||
{
|
||||
spritesound(445, neartagsprite);
|
||||
alreadydone = 1;
|
||||
sound445done = 1;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue