mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Get rid of the globals used when implementing the framerate based input polling
git-svn-id: https://svn.eduke32.com/eduke32@8555 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
e94ce88b27
commit
ae9b6915ce
2 changed files with 44 additions and 41 deletions
|
@ -2899,13 +2899,10 @@ static int P_CheckLockedMovement(int const playerNum)
|
||||||
&& pPlayer->kickback_pic < PWEAPON(playerNum, pPlayer->curr_weapon, FireDelay)));
|
&& pPlayer->kickback_pic < PWEAPON(playerNum, pPlayer->curr_weapon, FireDelay)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool g_horizRecenter;
|
|
||||||
static float g_horizAngleAdjust;
|
|
||||||
static fix16_t g_horizSkew;
|
|
||||||
|
|
||||||
void P_GetInput(int const playerNum)
|
void P_GetInput(int const playerNum)
|
||||||
{
|
{
|
||||||
auto const pPlayer = g_player[playerNum].ps;
|
auto &thisPlayer = g_player[playerNum];
|
||||||
|
auto const pPlayer = thisPlayer.ps;
|
||||||
ControlInfo info;
|
ControlInfo info;
|
||||||
|
|
||||||
if (g_cheatBufLen > 1 || (pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause)))
|
if (g_cheatBufLen > 1 || (pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause)))
|
||||||
|
@ -3151,23 +3148,22 @@ void P_GetInput(int const playerNum)
|
||||||
pPlayer->q16horiz = fix16_clamp(fix16_sadd(pPlayer->q16horiz, input.q16horz), F16(HORIZ_MIN), F16(HORIZ_MAX));
|
pPlayer->q16horiz = fix16_clamp(fix16_sadd(pPlayer->q16horiz, input.q16horz), F16(HORIZ_MIN), F16(HORIZ_MAX));
|
||||||
}
|
}
|
||||||
|
|
||||||
// A horiz diff of 128 equal 45 degrees,
|
// A horiz diff of 128 equal 45 degrees, so we convert horiz to 1024 angle units
|
||||||
// so we convert horiz to 1024 angle units
|
|
||||||
|
|
||||||
if (g_horizAngleAdjust)
|
if (thisPlayer.horizAngleAdjust)
|
||||||
{
|
{
|
||||||
float const horizAngle
|
float const horizAngle
|
||||||
= atan2f(pPlayer->q16horiz - F16(100), F16(128)) * (512.f / fPI) + scaleAdjustmentToInterval(g_horizAngleAdjust);
|
= atan2f(pPlayer->q16horiz - F16(100), F16(128)) * (512.f / fPI) + scaleAdjustmentToInterval(thisPlayer.horizAngleAdjust);
|
||||||
pPlayer->q16horiz = F16(100) + Blrintf(F16(128) * tanf(horizAngle * (fPI / 512.f)));
|
pPlayer->q16horiz = F16(100) + Blrintf(F16(128) * tanf(horizAngle * (fPI / 512.f)));
|
||||||
}
|
}
|
||||||
else if (pPlayer->return_to_center > 0 || g_horizRecenter)
|
else if (pPlayer->return_to_center > 0 || thisPlayer.horizRecenter)
|
||||||
{
|
{
|
||||||
pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float(F16(66.666) - fix16_sdiv(pPlayer->q16horiz, F16(1.5))))));
|
pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float(F16(66.666) - fix16_sdiv(pPlayer->q16horiz, F16(1.5))))));
|
||||||
|
|
||||||
if ((!pPlayer->return_to_center && g_horizRecenter) || (pPlayer->q16horiz >= F16(99.9) && pPlayer->q16horiz <= F16(100.1)))
|
if ((!pPlayer->return_to_center && thisPlayer.horizRecenter) || (pPlayer->q16horiz >= F16(99.9) && pPlayer->q16horiz <= F16(100.1)))
|
||||||
{
|
{
|
||||||
pPlayer->q16horiz = F16(100);
|
pPlayer->q16horiz = F16(100);
|
||||||
g_horizRecenter = false;
|
thisPlayer.horizRecenter = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pPlayer->q16horizoff >= F16(-0.1) && pPlayer->q16horizoff <= F16(0.1))
|
if (pPlayer->q16horizoff >= F16(-0.1) && pPlayer->q16horizoff <= F16(0.1))
|
||||||
|
@ -3203,8 +3199,8 @@ void P_GetInput(int const playerNum)
|
||||||
pPlayer->q16horizoff = fix16_min(pPlayer->q16horizoff, 0);
|
pPlayer->q16horizoff = fix16_min(pPlayer->q16horizoff, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_horizSkew)
|
if (thisPlayer.horizSkew)
|
||||||
pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float(g_horizSkew))));
|
pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float(thisPlayer.horizSkew))));
|
||||||
|
|
||||||
pPlayer->q16horiz = fix16_clamp(pPlayer->q16horiz, F16(HORIZ_MIN), F16(HORIZ_MAX));
|
pPlayer->q16horiz = fix16_clamp(pPlayer->q16horiz, F16(HORIZ_MIN), F16(HORIZ_MAX));
|
||||||
}
|
}
|
||||||
|
@ -4713,20 +4709,22 @@ static void P_ClampZ(DukePlayer_t* const pPlayer, int const sectorLotag, int32_t
|
||||||
|
|
||||||
void P_ProcessInput(int playerNum)
|
void P_ProcessInput(int playerNum)
|
||||||
{
|
{
|
||||||
g_horizAngleAdjust = 0;
|
auto &thisPlayer = g_player[playerNum];
|
||||||
g_horizSkew = 0;
|
|
||||||
|
|
||||||
if (g_player[playerNum].playerquitflag == 0)
|
thisPlayer.horizAngleAdjust = 0;
|
||||||
|
thisPlayer.horizSkew = 0;
|
||||||
|
|
||||||
|
if (thisPlayer.playerquitflag == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto const pPlayer = g_player[playerNum].ps;
|
auto const pPlayer = thisPlayer.ps;
|
||||||
auto const pSprite = &sprite[pPlayer->i];
|
auto const pSprite = &sprite[pPlayer->i];
|
||||||
|
|
||||||
++pPlayer->player_par;
|
++pPlayer->player_par;
|
||||||
|
|
||||||
VM_OnEvent(EVENT_PROCESSINPUT, pPlayer->i, playerNum);
|
VM_OnEvent(EVENT_PROCESSINPUT, pPlayer->i, playerNum);
|
||||||
|
|
||||||
uint32_t playerBits = g_player[playerNum].input->bits;
|
uint32_t playerBits = thisPlayer.input->bits;
|
||||||
|
|
||||||
if (pPlayer->cheat_phase > 0)
|
if (pPlayer->cheat_phase > 0)
|
||||||
playerBits = 0;
|
playerBits = 0;
|
||||||
|
@ -5248,7 +5246,7 @@ void P_ProcessInput(int playerNum)
|
||||||
pPlayer->vel.x = 0;
|
pPlayer->vel.x = 0;
|
||||||
pPlayer->vel.y = 0;
|
pPlayer->vel.y = 0;
|
||||||
}
|
}
|
||||||
else if (g_player[playerNum].input->q16avel)
|
else if (thisPlayer.input->q16avel)
|
||||||
pPlayer->crack_time = PCRACKTIME;
|
pPlayer->crack_time = PCRACKTIME;
|
||||||
|
|
||||||
if (pPlayer->spritebridge == 0)
|
if (pPlayer->spritebridge == 0)
|
||||||
|
@ -5286,18 +5284,18 @@ void P_ProcessInput(int playerNum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_player[playerNum].input->extbits & (1)) VM_OnEvent(EVENT_MOVEFORWARD, pPlayer->i, playerNum);
|
if (thisPlayer.input->extbits & (1)) VM_OnEvent(EVENT_MOVEFORWARD, pPlayer->i, playerNum);
|
||||||
if (g_player[playerNum].input->extbits & (1 << 1)) VM_OnEvent(EVENT_MOVEBACKWARD, pPlayer->i, playerNum);
|
if (thisPlayer.input->extbits & (1 << 1)) VM_OnEvent(EVENT_MOVEBACKWARD, pPlayer->i, playerNum);
|
||||||
if (g_player[playerNum].input->extbits & (1 << 2)) VM_OnEvent(EVENT_STRAFELEFT, pPlayer->i, playerNum);
|
if (thisPlayer.input->extbits & (1 << 2)) VM_OnEvent(EVENT_STRAFELEFT, pPlayer->i, playerNum);
|
||||||
if (g_player[playerNum].input->extbits & (1 << 3)) VM_OnEvent(EVENT_STRAFERIGHT, pPlayer->i, playerNum);
|
if (thisPlayer.input->extbits & (1 << 3)) VM_OnEvent(EVENT_STRAFERIGHT, pPlayer->i, playerNum);
|
||||||
|
|
||||||
if (g_player[playerNum].input->extbits & (1 << 4) || g_player[playerNum].input->q16avel < 0)
|
if (thisPlayer.input->extbits & (1 << 4) || thisPlayer.input->q16avel < 0)
|
||||||
VM_OnEvent(EVENT_TURNLEFT, pPlayer->i, playerNum);
|
VM_OnEvent(EVENT_TURNLEFT, pPlayer->i, playerNum);
|
||||||
|
|
||||||
if (g_player[playerNum].input->extbits & (1 << 5) || g_player[playerNum].input->q16avel > 0)
|
if (thisPlayer.input->extbits & (1 << 5) || thisPlayer.input->q16avel > 0)
|
||||||
VM_OnEvent(EVENT_TURNRIGHT, pPlayer->i, playerNum);
|
VM_OnEvent(EVENT_TURNRIGHT, pPlayer->i, playerNum);
|
||||||
|
|
||||||
if (pPlayer->vel.x || pPlayer->vel.y || g_player[playerNum].input->fvel || g_player[playerNum].input->svel)
|
if (pPlayer->vel.x || pPlayer->vel.y || thisPlayer.input->fvel || thisPlayer.input->svel)
|
||||||
{
|
{
|
||||||
pPlayer->crack_time = PCRACKTIME;
|
pPlayer->crack_time = PCRACKTIME;
|
||||||
|
|
||||||
|
@ -5351,8 +5349,8 @@ void P_ProcessInput(int playerNum)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pPlayer->vel.x += (((g_player[playerNum].input->fvel) * velocityModifier) << 6);
|
pPlayer->vel.x += (((thisPlayer.input->fvel) * velocityModifier) << 6);
|
||||||
pPlayer->vel.y += (((g_player[playerNum].input->svel) * velocityModifier) << 6);
|
pPlayer->vel.y += (((thisPlayer.input->svel) * velocityModifier) << 6);
|
||||||
|
|
||||||
int playerSpeedReduction = 0;
|
int playerSpeedReduction = 0;
|
||||||
|
|
||||||
|
@ -5528,8 +5526,8 @@ RECHECK:
|
||||||
if (VM_OnEvent(EVENT_LOOKUP,pPlayer->i,playerNum) == 0)
|
if (VM_OnEvent(EVENT_LOOKUP,pPlayer->i,playerNum) == 0)
|
||||||
{
|
{
|
||||||
pPlayer->return_to_center = 9;
|
pPlayer->return_to_center = 9;
|
||||||
g_horizRecenter = true;
|
thisPlayer.horizRecenter = true;
|
||||||
g_horizAngleAdjust = float(12<<(int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
thisPlayer.horizAngleAdjust = float(12<<(int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5538,8 +5536,8 @@ RECHECK:
|
||||||
if (VM_OnEvent(EVENT_LOOKDOWN,pPlayer->i,playerNum) == 0)
|
if (VM_OnEvent(EVENT_LOOKDOWN,pPlayer->i,playerNum) == 0)
|
||||||
{
|
{
|
||||||
pPlayer->return_to_center = 9;
|
pPlayer->return_to_center = 9;
|
||||||
g_horizRecenter = true;
|
thisPlayer.horizRecenter = true;
|
||||||
g_horizAngleAdjust = -float(12<<(int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
thisPlayer.horizAngleAdjust = -float(12<<(int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5547,8 +5545,8 @@ RECHECK:
|
||||||
{
|
{
|
||||||
if (VM_OnEvent(EVENT_AIMUP,pPlayer->i,playerNum) == 0)
|
if (VM_OnEvent(EVENT_AIMUP,pPlayer->i,playerNum) == 0)
|
||||||
{
|
{
|
||||||
g_horizAngleAdjust = float(6 << (int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
thisPlayer.horizAngleAdjust = float(6 << (int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
||||||
g_horizRecenter = false;
|
thisPlayer.horizRecenter = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5556,14 +5554,14 @@ RECHECK:
|
||||||
{
|
{
|
||||||
if (VM_OnEvent(EVENT_AIMDOWN,pPlayer->i,playerNum) == 0)
|
if (VM_OnEvent(EVENT_AIMDOWN,pPlayer->i,playerNum) == 0)
|
||||||
{
|
{
|
||||||
g_horizAngleAdjust = -float(6 << (int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
thisPlayer.horizAngleAdjust = -float(6 << (int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
||||||
g_horizRecenter = false;
|
thisPlayer.horizRecenter = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pPlayer->hard_landing > 0)
|
if (pPlayer->hard_landing > 0)
|
||||||
{
|
{
|
||||||
g_horizSkew = fix16_from_int(-(pPlayer->hard_landing << 4));
|
thisPlayer.horizSkew = fix16_from_int(-(pPlayer->hard_landing << 4));
|
||||||
pPlayer->hard_landing--;
|
pPlayer->hard_landing--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5592,8 +5590,8 @@ RECHECK:
|
||||||
#ifndef EDUKE32_STANDALONE
|
#ifndef EDUKE32_STANDALONE
|
||||||
if (!FURY && pPlayer->knee_incs > 0)
|
if (!FURY && pPlayer->knee_incs > 0)
|
||||||
{
|
{
|
||||||
g_horizSkew = F16(-48);
|
thisPlayer.horizSkew = F16(-48);
|
||||||
g_horizRecenter = true;
|
thisPlayer.horizRecenter = true;
|
||||||
pPlayer->return_to_center = 9;
|
pPlayer->return_to_center = 9;
|
||||||
|
|
||||||
if (++pPlayer->knee_incs > 15)
|
if (++pPlayer->knee_incs > 15)
|
||||||
|
|
|
@ -223,10 +223,15 @@ typedef struct {
|
||||||
} DukePlayer_t;
|
} DukePlayer_t;
|
||||||
|
|
||||||
// KEEPINSYNC lunatic/_defs_game.lua
|
// KEEPINSYNC lunatic/_defs_game.lua
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
DukePlayer_t *ps;
|
DukePlayer_t *ps;
|
||||||
input_t *input;
|
input_t *input;
|
||||||
|
|
||||||
|
bool horizRecenter;
|
||||||
|
float horizAngleAdjust;
|
||||||
|
fix16_t horizSkew;
|
||||||
|
|
||||||
int32_t netsynctime;
|
int32_t netsynctime;
|
||||||
int16_t ping, filler;
|
int16_t ping, filler;
|
||||||
int32_t pcolor, pteam;
|
int32_t pcolor, pteam;
|
||||||
|
|
Loading…
Reference in a new issue