mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-28 20:40:47 +00:00
- Blood: Bring in SW's input helpers and hook up within input code.
This commit is contained in:
parent
1900cf1fcc
commit
85e81c94c7
3 changed files with 133 additions and 0 deletions
|
@ -152,8 +152,42 @@ static void processMovement(ControlInfo* const hidInput, bool const mouseaim)
|
|||
if (!cl_syncinput && gamestate == GS_LEVEL)
|
||||
{
|
||||
PLAYER* pPlayer = &gPlayer[myconnectindex];
|
||||
|
||||
applylook(pPlayer, input.q16avel, scaleAdjust);
|
||||
|
||||
if (pPlayer->angTarget)
|
||||
{
|
||||
fixed_t angDelta = getincangleq16(pPlayer->q16ang, pPlayer->angTarget);
|
||||
pPlayer->q16ang = (pPlayer->q16ang + xs_CRoundToInt(scaleAdjust * angDelta));
|
||||
|
||||
if (abs(pPlayer->q16ang - pPlayer->angTarget) < FRACUNIT)
|
||||
{
|
||||
pPlayer->q16ang = pPlayer->angTarget;
|
||||
pPlayer->angTarget = 0;
|
||||
}
|
||||
}
|
||||
else if (pPlayer->angAdjust)
|
||||
{
|
||||
pPlayer->q16ang = (pPlayer->q16ang + FloatToFixed(scaleAdjust * pPlayer->angAdjust)) & 0x7FFFFFF;
|
||||
}
|
||||
|
||||
sethorizon(pPlayer, input.q16horz, scaleAdjust);
|
||||
|
||||
if (pPlayer->horizTarget)
|
||||
{
|
||||
fixed_t horizDelta = pPlayer->horizTarget - pPlayer->q16horiz;
|
||||
pPlayer->q16horiz += xs_CRoundToInt(scaleAdjust * horizDelta);
|
||||
|
||||
if (abs(pPlayer->q16horiz - pPlayer->horizTarget) < FRACUNIT)
|
||||
{
|
||||
pPlayer->q16horiz = pPlayer->horizTarget;
|
||||
pPlayer->horizTarget = 0;
|
||||
}
|
||||
}
|
||||
else if (pPlayer->horizAdjust)
|
||||
{
|
||||
pPlayer->q16horiz += FloatToFixed(scaleAdjust * pPlayer->horizAdjust);
|
||||
}
|
||||
}
|
||||
|
||||
gInput.fvel = clamp(gInput.fvel + input.fvel, -MAXFVEL, MAXFVEL);
|
||||
|
|
|
@ -1304,6 +1304,12 @@ int ActionScan(PLAYER *pPlayer, int *a2, int *a3)
|
|||
return -1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Player's angle function, called in processInput() or from gi->GetInput() as required.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void applylook(PLAYER *pPlayer, fixed_t const q16avel, double const scaleAdjust)
|
||||
{
|
||||
spritetype *pSprite = pPlayer->pSprite;
|
||||
|
@ -1339,6 +1345,12 @@ void applylook(PLAYER *pPlayer, fixed_t const q16avel, double const scaleAdjust)
|
|||
pPlayer->angold = pSprite->ang = FixedToInt(pPlayer->q16ang);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Player's horizon function, called in processInput() or from gi->GetInput() as required.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void sethorizon(PLAYER *pPlayer, fixed_t const q16horz, double const scaleAdjust)
|
||||
{
|
||||
InputPacket *pInput = &pPlayer->input;
|
||||
|
@ -1379,6 +1391,85 @@ void sethorizon(PLAYER *pPlayer, fixed_t const q16horz, double const scaleAdjust
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Unsynchronised input helpers.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void resetinputhelpers(PLAYER* pPlayer)
|
||||
{
|
||||
pPlayer->horizAdjust = 0;
|
||||
pPlayer->angAdjust = 0;
|
||||
pPlayer->pitchAdjust = 0;
|
||||
}
|
||||
|
||||
void playerAddAngle(PLAYER* pPlayer, double ang)
|
||||
{
|
||||
if (!cl_syncinput)
|
||||
{
|
||||
pPlayer->angAdjust += ang;
|
||||
}
|
||||
else
|
||||
{
|
||||
pPlayer->addang(ang);
|
||||
}
|
||||
}
|
||||
|
||||
void playerSetAngle(PLAYER* pPlayer, double ang)
|
||||
{
|
||||
if (!cl_syncinput)
|
||||
{
|
||||
// Cancel out any angle adjustments as we're setting angle now.
|
||||
pPlayer->angAdjust = 0;
|
||||
|
||||
// Add slight offset if input angle is coming in as absolute 0.
|
||||
if (ang == 0)
|
||||
{
|
||||
ang += 0.1;
|
||||
}
|
||||
|
||||
pPlayer->angTarget = pPlayer->q16ang + getincangleq16(pPlayer->q16ang, FloatToFixed(ang));
|
||||
}
|
||||
else
|
||||
{
|
||||
pPlayer->setang(ang);
|
||||
}
|
||||
}
|
||||
|
||||
void playerAddHoriz(PLAYER* pPlayer, double horiz)
|
||||
{
|
||||
if (!cl_syncinput)
|
||||
{
|
||||
pPlayer->horizAdjust += horiz;
|
||||
}
|
||||
else
|
||||
{
|
||||
pPlayer->addhoriz(horiz);
|
||||
}
|
||||
}
|
||||
|
||||
void playerSetHoriz(PLAYER* pPlayer, double horiz)
|
||||
{
|
||||
if (!cl_syncinput)
|
||||
{
|
||||
// Cancel out any horizon adjustments as we're setting horizon now.
|
||||
pPlayer->horizAdjust = 0;
|
||||
|
||||
// Add slight offset if input horizon is coming in as absolute 0.
|
||||
if (horiz == 0)
|
||||
{
|
||||
horiz += 0.1;
|
||||
}
|
||||
|
||||
pPlayer->horizTarget = FloatToFixed(horiz);
|
||||
}
|
||||
else
|
||||
{
|
||||
pPlayer->sethoriz(horiz);
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessInput(PLAYER *pPlayer)
|
||||
{
|
||||
enum
|
||||
|
|
|
@ -185,6 +185,14 @@ struct PLAYER
|
|||
int player_par;
|
||||
int nWaterPal;
|
||||
POSTURE pPosture[kModeMax][kPostureMax];
|
||||
|
||||
// Input helper variables and setters.
|
||||
double horizAdjust, angAdjust, pitchAdjust;
|
||||
fixed_t horizTarget, angTarget;
|
||||
void addang(int v) { q16ang = (q16ang + IntToFixed(v)) & 0x7FFFFFF; }
|
||||
void setang(int v) { q16ang = IntToFixed(v); }
|
||||
void addhoriz(int v) { q16horiz += (IntToFixed(v)); }
|
||||
void sethoriz(int v) { q16horiz = IntToFixed(v); }
|
||||
};
|
||||
|
||||
struct PROFILE
|
||||
|
|
Loading…
Reference in a new issue