SW - Hopefully a better way to decide if getinput should call

DoPlayerTurn/DoPlayerHorizon while input is tied to the frame rate:
Introduce the new player flags PF2_INPUT_CAN_TURN and PF2_INPUT_CAN_AIM.
Set PF2_INPUT_CAN_TURN if DoPlayerTurn can be called outside
of getinput. Similarly set PF2_INPUT_CAN_AIM if DoPlayerHorizon
can be called in this manner.
getinput will only call DoPlayerTurn/DoPlayerHorizon
if PF2_INPUT_CAN_TURN/PF2_INPUT_CAN_AIM is set. These flags are reset
right before the call to the player's current DoPlayerAction function.

For one example in which this assists, it's not always the
case that DoPlayerDeathFollowKiller may call DoPlayerTurn,
even if we assume that pp->input.q16angvel is never zero.
This commit is contained in:
NY00123 2020-04-18 00:10:55 +03:00 committed by Christoph Oelckers
parent e3197d206d
commit 6aecd46dbc
3 changed files with 13 additions and 3 deletions

View file

@ -3283,11 +3283,12 @@ getinput(SW_PACKET *loc, SWBOOL tied)
q16angvel = fix16_floor(q16angvel);
q16aimvel = fix16_floor(q16aimvel);
}
else if (!TEST(pp->Flags, PF_DEAD) && (pp->DoPlayerAction != DoPlayerTeleportPause))
else
{
if (!TEST(pp->Flags, PF_CLIMBING) && !pp->sop_control)
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN))
DoPlayerTurn(pp, &pp->camq16ang, q16angvel);
DoPlayerHorizon(pp, &pp->camq16horiz, q16aimvel);
if (TEST(pp->Flags2, PF2_INPUT_CAN_AIM))
DoPlayerHorizon(pp, &pp->camq16horiz, q16aimvel);
}
loc->vel += vel;

View file

@ -1357,6 +1357,8 @@ extern PLAYER Player[MAX_SW_PLAYERS_REG+1];
#define PF_WEAPON_DOWN (BIT(31))
#define PF2_TELEPORTED (BIT(0))
#define PF2_INPUT_CAN_TURN (BIT(1)) // Allow calling DoPlayerTurn from getinput
#define PF2_INPUT_CAN_AIM (BIT(2)) // Allow calling DoPlayerHorizon from getinput
///////////////////////////////////////////////////////////////////////////////////////////
//

View file

@ -1545,6 +1545,7 @@ DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16angvel)
if (!PedanticMode && (pq16ang == &pp->q16ang))
{
SET(pp->Flags2, PF2_INPUT_CAN_TURN);
pp->q16ang = pp->oq16ang = pp->input.q16ang;
sprite[pp->PlayerSprite].ang = fix16_to_int(*pq16ang);
if (!Prediction)
@ -1914,6 +1915,7 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16aimvel)
if (!PedanticMode && (pq16horiz == &pp->q16horiz))
{
SET(pp->Flags2, PF2_INPUT_CAN_AIM);
pp->q16horiz = pp->oq16horiz = pp->input.q16horiz;
return;
}
@ -6779,6 +6781,9 @@ void DoPlayerDeathFollowKiller(PLAYERp pp)
//DoPlayerDeathTilt(pp, pp->tilt_dest, 4 * synctics);
// allow turning
if (TEST(pp->Flags, PF_DEAD_HEAD|PF_HEAD_CONTROL))
SET(pp->Flags2, PF2_INPUT_CAN_TURN);
if ((TEST(pp->Flags, PF_DEAD_HEAD) && pp->input.q16angvel != 0) || TEST(pp->Flags, PF_HEAD_CONTROL))
{
DoPlayerTurn(pp, &pp->q16ang, pp->input.q16angvel);
@ -8021,6 +8026,8 @@ domovethings(void)
DoPlayerSectorUpdatePreMove(pp);
ChopsCheck(pp);
// Reset flags used while tying input to framerate
RESET(pp->Flags2, PF2_INPUT_CAN_TURN|PF2_INPUT_CAN_AIM);
// extern SWBOOL ScrollMode2D;
//if (!ScrollMode2D)
if (pp->DoPlayerAction) pp->DoPlayerAction(pp);