mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-30 13:21:04 +00:00
- SW: Handle angAdjust
and horizAdjust
directly in processMovement()
instead of via DoPlayerTurn()
/DoPlayerHorizon()
.
* Eliminates issues with when to call when player is dead, etc. Handles cases like climbing a ladder which doesn't trigger `DoPlayerTurn()`.
This commit is contained in:
parent
92443806af
commit
083ed3e9b7
3 changed files with 115 additions and 135 deletions
|
@ -283,6 +283,9 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool
|
||||||
if (TEST(pp->Flags2, PF2_INPUT_CAN_AIM))
|
if (TEST(pp->Flags2, PF2_INPUT_CAN_AIM))
|
||||||
DoPlayerHorizon(pp, q16horz, scaleAdjust);
|
DoPlayerHorizon(pp, q16horz, scaleAdjust);
|
||||||
|
|
||||||
|
if (pp->horizAdjust)
|
||||||
|
pp->q16horiz += FloatToFixed(scaleAdjust * pp->horizAdjust);
|
||||||
|
|
||||||
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_GENERAL))
|
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_GENERAL))
|
||||||
DoPlayerTurn(pp, q16avel, scaleAdjust);
|
DoPlayerTurn(pp, q16avel, scaleAdjust);
|
||||||
|
|
||||||
|
@ -294,6 +297,9 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool
|
||||||
|
|
||||||
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_TURRET))
|
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_TURRET))
|
||||||
DoPlayerTurnTurret(pp, q16avel);
|
DoPlayerTurnTurret(pp, q16avel);
|
||||||
|
|
||||||
|
if (pp->angAdjust)
|
||||||
|
pp->q16ang = (pp->q16ang + FloatToFixed(scaleAdjust * pp->angAdjust)) & 0x7FFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
loc.fvel = clamp(loc.fvel + fvel, -MAXFVEL, MAXFVEL);
|
loc.fvel = clamp(loc.fvel + fvel, -MAXFVEL, MAXFVEL);
|
||||||
|
|
|
@ -1547,8 +1547,6 @@ DoPlayerCrawlHeight(PLAYERp pp)
|
||||||
|
|
||||||
void
|
void
|
||||||
DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust)
|
DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust)
|
||||||
{
|
|
||||||
if (!TEST(pp->Flags, PF_DEAD) || TEST(pp->Flags, PF_DEAD) && TEST(pp->Flags, PF_DEAD_HEAD|PF_HEAD_CONTROL))
|
|
||||||
{
|
{
|
||||||
if (!TEST(pp->Flags, PF_TURN_180))
|
if (!TEST(pp->Flags, PF_TURN_180))
|
||||||
{
|
{
|
||||||
|
@ -1607,13 +1605,6 @@ DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust)
|
||||||
if (q16avel != 0)
|
if (q16avel != 0)
|
||||||
{
|
{
|
||||||
pp->q16ang = (pp->q16ang + q16avel) & 0x7FFFFFF;
|
pp->q16ang = (pp->q16ang + q16avel) & 0x7FFFFFF;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cl_syncinput && pp->angAdjust)
|
|
||||||
{
|
|
||||||
pp->q16ang = (pp->q16ang + FloatToFixed(scaleAdjust * pp->angAdjust)) & 0x7FFFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
// update players sprite angle
|
// update players sprite angle
|
||||||
// NOTE: It's also updated in UpdatePlayerSprite, but needs to be
|
// NOTE: It's also updated in UpdatePlayerSprite, but needs to be
|
||||||
|
@ -1626,6 +1617,7 @@ DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust)
|
||||||
sprite[pp->PlayerUnderSprite].ang = FixedToInt(pp->q16ang);
|
sprite[pp->PlayerUnderSprite].ang = FixedToInt(pp->q16ang);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DoPlayerTurnBoat(PLAYERp pp, fixed_t q16avel)
|
DoPlayerTurnBoat(PLAYERp pp, fixed_t q16avel)
|
||||||
|
@ -1832,8 +1824,6 @@ PlayerAutoLook(PLAYERp pp, double const scaleAdjust)
|
||||||
|
|
||||||
void
|
void
|
||||||
DoPlayerHorizon(PLAYERp pp, fixed_t const q16horz, double const scaleAdjust)
|
DoPlayerHorizon(PLAYERp pp, fixed_t const q16horz, double const scaleAdjust)
|
||||||
{
|
|
||||||
if (!TEST(pp->Flags, PF_DEAD))
|
|
||||||
{
|
{
|
||||||
// Fixme: This should probably be made optional.
|
// Fixme: This should probably be made optional.
|
||||||
if (cl_slopetilting)
|
if (cl_slopetilting)
|
||||||
|
@ -1899,7 +1889,6 @@ DoPlayerHorizon(PLAYERp pp, fixed_t const q16horz, double const scaleAdjust)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bound the base
|
// bound the base
|
||||||
pp->q16horizbase = max(pp->q16horizbase, IntToFixed(PLAYER_HORIZ_MIN));
|
pp->q16horizbase = max(pp->q16horizbase, IntToFixed(PLAYER_HORIZ_MIN));
|
||||||
|
@ -1913,11 +1902,6 @@ DoPlayerHorizon(PLAYERp pp, fixed_t const q16horz, double const scaleAdjust)
|
||||||
|
|
||||||
// add base and offsets
|
// add base and offsets
|
||||||
pp->q16horiz = pp->q16horizbase + pp->q16horizoff;
|
pp->q16horiz = pp->q16horizbase + pp->q16horizoff;
|
||||||
|
|
||||||
if (!cl_syncinput)
|
|
||||||
{
|
|
||||||
pp->q16horiz += xs_CRoundToInt(scaleAdjust * pp->horizAdjust);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -4293,7 +4277,7 @@ PlayerOnLadder(PLAYERp pp)
|
||||||
pp->lx = lsp->x + nx * 5;
|
pp->lx = lsp->x + nx * 5;
|
||||||
pp->ly = lsp->y + ny * 5;
|
pp->ly = lsp->y + ny * 5;
|
||||||
|
|
||||||
playerSetAngle(pp, pp->LadderAngle);
|
playerAddAngle(pp, FixedToFloat(GetDeltaQ16Angle(IntToFixed(pp->LadderAngle), pp->q16ang)));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -6296,9 +6280,6 @@ DoPlayerDeathHoriz(PLAYERp pp, short target, short speed)
|
||||||
{
|
{
|
||||||
if (pp->q16horiz > IntToFixed(target))
|
if (pp->q16horiz > IntToFixed(target))
|
||||||
{
|
{
|
||||||
if (!cl_syncinput)
|
|
||||||
SET(pp->Flags2, PF2_INPUT_CAN_AIM);
|
|
||||||
|
|
||||||
playerAddHoriz(pp, -speed);
|
playerAddHoriz(pp, -speed);
|
||||||
|
|
||||||
if (pp->q16horiz <= IntToFixed(target))
|
if (pp->q16horiz <= IntToFixed(target))
|
||||||
|
@ -6307,9 +6288,6 @@ DoPlayerDeathHoriz(PLAYERp pp, short target, short speed)
|
||||||
|
|
||||||
if (pp->q16horiz < IntToFixed(target))
|
if (pp->q16horiz < IntToFixed(target))
|
||||||
{
|
{
|
||||||
if (!cl_syncinput)
|
|
||||||
SET(pp->Flags2, PF2_INPUT_CAN_AIM);
|
|
||||||
|
|
||||||
playerAddHoriz(pp, speed);
|
playerAddHoriz(pp, speed);
|
||||||
|
|
||||||
if (pp->q16horiz >= IntToFixed(target))
|
if (pp->q16horiz >= IntToFixed(target))
|
||||||
|
@ -6410,10 +6388,6 @@ void DoPlayerDeathFollowKiller(PLAYERp pp)
|
||||||
|
|
||||||
if (FAFcansee(kp->x, kp->y, SPRITEp_TOS(kp), kp->sectnum, pp->posx, pp->posy, pp->posz, pp->cursectnum))
|
if (FAFcansee(kp->x, kp->y, SPRITEp_TOS(kp), kp->sectnum, pp->posx, pp->posy, pp->posz, pp->cursectnum))
|
||||||
{
|
{
|
||||||
if (!cl_syncinput)
|
|
||||||
{
|
|
||||||
SET(pp->Flags2, PF2_INPUT_CAN_TURN_GENERAL);
|
|
||||||
}
|
|
||||||
playerAddAngle(pp, GetDeltaQ16Angle(gethiq16angle(kp->x - pp->posx, kp->y - pp->posy), pp->q16ang) / (double)(FRACUNIT << 4));
|
playerAddAngle(pp, GetDeltaQ16Angle(gethiq16angle(kp->x - pp->posx, kp->y - pp->posy), pp->q16ang) / (double)(FRACUNIT << 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7452,7 +7426,7 @@ domovethings(void)
|
||||||
// auto tracking mode for single player multi-game
|
// auto tracking mode for single player multi-game
|
||||||
if (numplayers <= 1 && PlayerTrackingMode && pnum == screenpeek && screenpeek != myconnectindex)
|
if (numplayers <= 1 && PlayerTrackingMode && pnum == screenpeek && screenpeek != myconnectindex)
|
||||||
{
|
{
|
||||||
playerSetAngle(&Player[screenpeek], gethiq16angle(Player[myconnectindex].posx - Player[screenpeek].posx, Player[myconnectindex].posy - Player[screenpeek].posy) / (double)(FRACUNIT));
|
playerSetAngle(&Player[screenpeek], FixedToFloat(gethiq16angle(Player[myconnectindex].posx - Player[screenpeek].posx, Player[myconnectindex].posy - Player[screenpeek].posy)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TEST(pp->Flags, PF_DEAD))
|
if (!TEST(pp->Flags, PF_DEAD))
|
||||||
|
|
|
@ -1675,7 +1675,7 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
|
||||||
|
|
||||||
// New angle is formed by taking last known angle and
|
// New angle is formed by taking last known angle and
|
||||||
// adjusting by the delta angle
|
// adjusting by the delta angle
|
||||||
playerSetAngle(pp, (pp->RevolveQ16Ang + IntToFixed(pp->RevolveDeltaAng)) / (double)(FRACUNIT));
|
playerSetAngle(pp, FixedToFloat(pp->RevolveQ16Ang + IntToFixed(pp->RevolveDeltaAng)));
|
||||||
|
|
||||||
UpdatePlayerSprite(pp);
|
UpdatePlayerSprite(pp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue