mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 22:51:50 +00:00
- Game input: Fix miscellaneous issues.
* Duke/RR: Fix `SB_CENTERVIEW` not clearing while `cl_syncinput 1`. * Duke/RR: Remove superfluous call to `apply_seasick()`. * RR: Change two calls from `playerSetAngle()` to `playerAddAngle()` Updated version of `playerSetAngle()` doesn't stop setting angle until target is reached, a bit too strict for this and compromised vehicle turning. * `applylook()`: Remove dead flag. Was only used with Duke, no other game called the function when dead anyway. Since the input helpers are processed outside of `applylook()` now this is not needed. * `applylook()`: Extend function with a bit of commentary.
This commit is contained in:
parent
f806cdcec6
commit
59e4fae064
8 changed files with 63 additions and 56 deletions
|
@ -138,7 +138,7 @@ static void processMovement(ControlInfo* const hidInput)
|
||||||
// Perform unsynchronised angle/horizon if not dead.
|
// Perform unsynchronised angle/horizon if not dead.
|
||||||
if (gView->pXSprite->health != 0)
|
if (gView->pXSprite->health != 0)
|
||||||
{
|
{
|
||||||
applylook(&pPlayer->q16ang, &pPlayer->q16look_ang, &pPlayer->q16rotscrnang, &pPlayer->spin, input.q16avel, &pPlayer->input.actions, scaleAdjust, gView->pXSprite->health == 0, pPlayer->posture != 0);
|
applylook(&pPlayer->q16ang, &pPlayer->q16look_ang, &pPlayer->q16rotscrnang, &pPlayer->spin, input.q16avel, &pPlayer->input.actions, scaleAdjust, pPlayer->posture != 0);
|
||||||
UpdatePlayerSpriteAngle(pPlayer);
|
UpdatePlayerSpriteAngle(pPlayer);
|
||||||
sethorizon(&pPlayer->q16horiz, input.q16horz, &pPlayer->input.actions, scaleAdjust);
|
sethorizon(&pPlayer->q16horiz, input.q16horz, &pPlayer->input.actions, scaleAdjust);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1445,7 +1445,7 @@ void ProcessInput(PLAYER *pPlayer)
|
||||||
|
|
||||||
if (cl_syncinput)
|
if (cl_syncinput)
|
||||||
{
|
{
|
||||||
applylook(&pPlayer->q16ang, &pPlayer->q16look_ang, &pPlayer->q16rotscrnang, &pPlayer->spin, pInput->q16avel, &pInput->actions, 1, gView->pXSprite->health == 0, pPlayer->posture != 0);
|
applylook(&pPlayer->q16ang, &pPlayer->q16look_ang, &pPlayer->q16rotscrnang, &pPlayer->spin, pInput->q16avel, &pInput->actions, 1, pPlayer->posture != 0);
|
||||||
UpdatePlayerSpriteAngle(pPlayer);
|
UpdatePlayerSpriteAngle(pPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1560,24 +1560,26 @@ void sethorizon(fixed_t* q16horiz, fixed_t const q16horz, ESyncBits* actions, do
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void applylook(fixed_t* q16ang, fixed_t* q16look_ang, fixed_t* q16rotscrnang, fixed_t* spin, fixed_t const q16avel, ESyncBits* actions, double const scaleAdjust, bool const dead, bool const crouching)
|
void applylook(fixed_t* q16ang, fixed_t* q16look_ang, fixed_t* q16rotscrnang, fixed_t* spin, fixed_t const q16avel, ESyncBits* actions, double const scaleAdjust, bool const crouching)
|
||||||
{
|
|
||||||
if (!dead)
|
|
||||||
{
|
{
|
||||||
|
// return q16rotscrnang to 0 and set to 0 if less than a quarter of a FRACUNIT (16384)
|
||||||
*q16rotscrnang -= xs_CRoundToInt(scaleAdjust * (*q16rotscrnang * (15. / GameTicRate)));
|
*q16rotscrnang -= xs_CRoundToInt(scaleAdjust * (*q16rotscrnang * (15. / GameTicRate)));
|
||||||
if (abs(*q16rotscrnang) < (FRACUNIT >> 2)) *q16rotscrnang = 0;
|
if (abs(*q16rotscrnang) < (FRACUNIT >> 2)) *q16rotscrnang = 0;
|
||||||
|
|
||||||
|
// return q16look_ang to 0 and set to 0 if less than a quarter of a FRACUNIT (16384)
|
||||||
*q16look_ang -= xs_CRoundToInt(scaleAdjust * (*q16look_ang * (7.5 / GameTicRate)));
|
*q16look_ang -= xs_CRoundToInt(scaleAdjust * (*q16look_ang * (7.5 / GameTicRate)));
|
||||||
if (abs(*q16look_ang) < (FRACUNIT >> 2)) *q16look_ang = 0;
|
if (abs(*q16look_ang) < (FRACUNIT >> 2)) *q16look_ang = 0;
|
||||||
|
|
||||||
if (*actions & SB_LOOK_LEFT)
|
if (*actions & SB_LOOK_LEFT)
|
||||||
{
|
{
|
||||||
|
// start looking left
|
||||||
*q16look_ang -= FloatToFixed(scaleAdjust * (4560. / GameTicRate));
|
*q16look_ang -= FloatToFixed(scaleAdjust * (4560. / GameTicRate));
|
||||||
*q16rotscrnang += FloatToFixed(scaleAdjust * (720. / GameTicRate));
|
*q16rotscrnang += FloatToFixed(scaleAdjust * (720. / GameTicRate));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*actions & SB_LOOK_RIGHT)
|
if (*actions & SB_LOOK_RIGHT)
|
||||||
{
|
{
|
||||||
|
// start looking right
|
||||||
*q16look_ang += FloatToFixed(scaleAdjust * (4560. / GameTicRate));
|
*q16look_ang += FloatToFixed(scaleAdjust * (4560. / GameTicRate));
|
||||||
*q16rotscrnang -= FloatToFixed(scaleAdjust * (720. / GameTicRate));
|
*q16rotscrnang -= FloatToFixed(scaleAdjust * (720. / GameTicRate));
|
||||||
}
|
}
|
||||||
|
@ -1586,6 +1588,7 @@ void applylook(fixed_t* q16ang, fixed_t* q16look_ang, fixed_t* q16rotscrnang, fi
|
||||||
{
|
{
|
||||||
if (*spin == 0)
|
if (*spin == 0)
|
||||||
{
|
{
|
||||||
|
// currently not spinning, so start a spin
|
||||||
*spin = IntToFixed(-1024);
|
*spin = IntToFixed(-1024);
|
||||||
}
|
}
|
||||||
*actions &= ~SB_TURNAROUND;
|
*actions &= ~SB_TURNAROUND;
|
||||||
|
@ -1593,6 +1596,7 @@ void applylook(fixed_t* q16ang, fixed_t* q16look_ang, fixed_t* q16rotscrnang, fi
|
||||||
|
|
||||||
if (*spin < 0)
|
if (*spin < 0)
|
||||||
{
|
{
|
||||||
|
// return spin to 0
|
||||||
fixed_t add = FloatToFixed(scaleAdjust * ((!crouching ? 3840. : 1920.) / GameTicRate));
|
fixed_t add = FloatToFixed(scaleAdjust * ((!crouching ? 3840. : 1920.) / GameTicRate));
|
||||||
*spin += add;
|
*spin += add;
|
||||||
if (*spin > 0)
|
if (*spin > 0)
|
||||||
|
@ -1606,10 +1610,10 @@ void applylook(fixed_t* q16ang, fixed_t* q16look_ang, fixed_t* q16rotscrnang, fi
|
||||||
|
|
||||||
if (q16avel)
|
if (q16avel)
|
||||||
{
|
{
|
||||||
|
// add player's input
|
||||||
*q16ang = (*q16ang + q16avel) & 0x7FFFFFF;
|
*q16ang = (*q16ang + q16avel) & 0x7FFFFFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -1634,7 +1638,7 @@ void playerSetAngle(fixed_t* q16ang, fixed_t* helper, double adjustment)
|
||||||
if (!cl_syncinput)
|
if (!cl_syncinput)
|
||||||
{
|
{
|
||||||
// Add slight offset if adjustment is coming in as absolute 0.
|
// Add slight offset if adjustment is coming in as absolute 0.
|
||||||
if (adjustment == 0) adjustment += (1. / FRACUNIT);
|
if (adjustment == 0) adjustment += (1. / (FRACUNIT >> 1));
|
||||||
|
|
||||||
*helper = *q16ang + getincangleq16(*q16ang, FloatToFixed(adjustment));
|
*helper = *q16ang + getincangleq16(*q16ang, FloatToFixed(adjustment));
|
||||||
}
|
}
|
||||||
|
@ -1661,7 +1665,7 @@ void playerSetHoriz(fixed_t* q16horiz, fixed_t* helper, double adjustment)
|
||||||
if (!cl_syncinput)
|
if (!cl_syncinput)
|
||||||
{
|
{
|
||||||
// Add slight offset if adjustment is coming in as absolute 0.
|
// Add slight offset if adjustment is coming in as absolute 0.
|
||||||
if (adjustment == 0) adjustment += (1. / FRACUNIT);
|
if (adjustment == 0) adjustment += (1. / (FRACUNIT >> 1));
|
||||||
|
|
||||||
*helper = FloatToFixed(adjustment);
|
*helper = FloatToFixed(adjustment);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ int getincangle(int c, int n);
|
||||||
fixed_t getincangleq16(fixed_t c, fixed_t n);
|
fixed_t getincangleq16(fixed_t c, fixed_t n);
|
||||||
|
|
||||||
void sethorizon(fixed_t* q16horiz, fixed_t const q16horz, ESyncBits* actions, double const scaleAdjust);
|
void sethorizon(fixed_t* q16horiz, fixed_t const q16horz, ESyncBits* actions, double const scaleAdjust);
|
||||||
void applylook(fixed_t* q16ang, fixed_t* q16look_ang, fixed_t* q16rotscrnang, fixed_t* spin, fixed_t const q16avel, ESyncBits* actions, double const scaleAdjust, bool const dead, bool const crouching);
|
void applylook(fixed_t* q16ang, fixed_t* q16look_ang, fixed_t* q16rotscrnang, fixed_t* spin, fixed_t const q16avel, ESyncBits* actions, double const scaleAdjust, bool const crouching);
|
||||||
void playerAddAngle(fixed_t* q16ang, double* helper, double adjustment);
|
void playerAddAngle(fixed_t* q16ang, double* helper, double adjustment);
|
||||||
void playerSetAngle(fixed_t* q16ang, fixed_t* helper, double adjustment);
|
void playerSetAngle(fixed_t* q16ang, fixed_t* helper, double adjustment);
|
||||||
void playerAddHoriz(fixed_t* q16horiz, double* helper, double adjustment);
|
void playerAddHoriz(fixed_t* q16horiz, double* helper, double adjustment);
|
||||||
|
|
|
@ -1019,13 +1019,16 @@ static void GetInputInternal(InputPacket &locInput, ControlInfo* const hidInput)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cl_syncinput)
|
if (!cl_syncinput)
|
||||||
|
{
|
||||||
|
if (p->dead_flag == 0)
|
||||||
{
|
{
|
||||||
// Do these in the same order as the old code.
|
// Do these in the same order as the old code.
|
||||||
calcviewpitch(p, scaleAdjust);
|
calcviewpitch(p, scaleAdjust);
|
||||||
processq16avel(p, &input.q16avel);
|
processq16avel(p, &input.q16avel);
|
||||||
applylook(&p->q16ang, &p->q16look_ang, &p->q16rotscrnang, &p->one_eighty_count, input.q16avel, &sync[myconnectindex].actions, scaleAdjust, p->dead_flag != 0, p->crouch_toggle || sync[myconnectindex].actions & SB_CROUCH);
|
applylook(&p->q16ang, &p->q16look_ang, &p->q16rotscrnang, &p->one_eighty_count, input.q16avel, &sync[myconnectindex].actions, scaleAdjust, p->crouch_toggle || sync[myconnectindex].actions & SB_CROUCH);
|
||||||
apply_seasick(p, scaleAdjust);
|
|
||||||
sethorizon(&p->q16horiz, input.q16horz, &sync[myconnectindex].actions, scaleAdjust);
|
sethorizon(&p->q16horiz, input.q16horz, &sync[myconnectindex].actions, scaleAdjust);
|
||||||
|
}
|
||||||
|
|
||||||
playerProcessHelpers(&p->q16ang, &p->angAdjust, &p->angTarget, &p->q16horiz, &p->horizAdjust, &p->horizTarget, scaleAdjust);
|
playerProcessHelpers(&p->q16ang, &p->angAdjust, &p->angTarget, &p->q16horiz, &p->horizAdjust, &p->horizTarget, scaleAdjust);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2847,7 +2847,7 @@ void processinput_d(int snum)
|
||||||
// may still be needed later for demo recording
|
// may still be needed later for demo recording
|
||||||
|
|
||||||
processq16avel(p, &sb_avel);
|
processq16avel(p, &sb_avel);
|
||||||
applylook(&p->q16ang, &p->q16look_ang, &p->q16rotscrnang, &p->one_eighty_count, sb_avel, &actions, 1, p->dead_flag != 0, p->crouch_toggle || actions & SB_CROUCH);
|
applylook(&p->q16ang, &p->q16look_ang, &p->q16rotscrnang, &p->one_eighty_count, sb_avel, &sync[snum].actions, 1, p->crouch_toggle || actions & SB_CROUCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->spritebridge == 0)
|
if (p->spritebridge == 0)
|
||||||
|
@ -3079,7 +3079,7 @@ HORIZONLY:
|
||||||
|
|
||||||
if (cl_syncinput)
|
if (cl_syncinput)
|
||||||
{
|
{
|
||||||
sethorizon(&p->q16horiz, PlayerHorizon(snum), &actions, 1);
|
sethorizon(&p->q16horiz, PlayerHorizon(snum), &sync[snum].actions, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkhardlanding(p);
|
checkhardlanding(p);
|
||||||
|
|
|
@ -1812,7 +1812,7 @@ static void onMotorcycle(int snum, ESyncBits &actions)
|
||||||
ang = var98 >> 7;
|
ang = var98 >> 7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
playerSetAngle(&p->q16ang, &p->angTarget, (var90 - ang) & 2047);
|
playerAddAngle(&p->q16ang, &p->angAdjust, FixedToFloat(getincangleq16(p->q16ang, IntToFixed(var90 - ang))));
|
||||||
}
|
}
|
||||||
else if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->moto_on_mud || p->moto_on_oil))
|
else if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->moto_on_mud || p->moto_on_oil))
|
||||||
{
|
{
|
||||||
|
@ -2111,7 +2111,7 @@ static void onBoat(int snum, ESyncBits &actions)
|
||||||
p->posyv += (vard4 >> 7) * (sintable[(vardc * -51 + vard8) & 2047] << 4);
|
p->posyv += (vard4 >> 7) * (sintable[(vardc * -51 + vard8) & 2047] << 4);
|
||||||
ang = vare0 >> 6;
|
ang = vare0 >> 6;
|
||||||
}
|
}
|
||||||
playerSetAngle(&p->q16ang, &p->angTarget, (vard8 - ang) & 2047);
|
playerAddAngle(&p->q16ang, &p->angAdjust, FixedToFloat(getincangleq16(p->q16ang, IntToFixed(vard8 - ang))));
|
||||||
}
|
}
|
||||||
if (p->NotOnWater)
|
if (p->NotOnWater)
|
||||||
if (p->MotoSpeed > 50)
|
if (p->MotoSpeed > 50)
|
||||||
|
@ -3737,7 +3737,7 @@ void processinput_r(int snum)
|
||||||
// may still be needed later for demo recording
|
// may still be needed later for demo recording
|
||||||
|
|
||||||
processq16avel(p, &sb_avel);
|
processq16avel(p, &sb_avel);
|
||||||
applylook(&p->q16ang, &p->q16look_ang, &p->q16rotscrnang, &p->one_eighty_count, sb_avel, &actions, 1, p->dead_flag != 0, p->crouch_toggle || actions & SB_CROUCH);
|
applylook(&p->q16ang, &p->q16look_ang, &p->q16rotscrnang, &p->one_eighty_count, sb_avel, &sync[snum].actions, 1, p->crouch_toggle || actions & SB_CROUCH);
|
||||||
apply_seasick(p, 1);
|
apply_seasick(p, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4093,7 +4093,7 @@ HORIZONLY:
|
||||||
|
|
||||||
if (cl_syncinput)
|
if (cl_syncinput)
|
||||||
{
|
{
|
||||||
sethorizon(&p->q16horiz, PlayerHorizon(snum), &actions, 1);
|
sethorizon(&p->q16horiz, PlayerHorizon(snum), &sync[snum].actions, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkhardlanding(p);
|
checkhardlanding(p);
|
||||||
|
|
|
@ -1525,7 +1525,7 @@ UpdatePlayerSpriteAngle(PLAYERp pp)
|
||||||
void
|
void
|
||||||
DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust)
|
DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust)
|
||||||
{
|
{
|
||||||
applylook(&pp->q16ang, &pp->q16look_ang, &pp->q16rotscrnang, &pp->turn180_target, q16avel, &pp->input.actions, scaleAdjust, TEST(pp->Flags, PF_DEAD), pp->input.actions & (SB_CROUCH|SB_CROUCH_LOCK));
|
applylook(&pp->q16ang, &pp->q16look_ang, &pp->q16rotscrnang, &pp->turn180_target, q16avel, &pp->input.actions, scaleAdjust, pp->input.actions & (SB_CROUCH|SB_CROUCH_LOCK));
|
||||||
UpdatePlayerSpriteAngle(pp);
|
UpdatePlayerSpriteAngle(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue