- SW: Call DoPlayerMoveTurret() in processMovement() in lieu of DoPlayerTurnTurret() and don't interpolate sector object's sprite while !cl_syncinput.

* Makes operating the tank silky smooth while unsynchronised.
This commit is contained in:
Mitchell Richters 2020-09-08 19:42:22 +10:00
parent c00217163b
commit 73d0772e87
4 changed files with 32 additions and 35 deletions

View file

@ -1060,7 +1060,7 @@ enum
PF2_INPUT_CAN_TURN_BOAT = (BIT(3)), // Allow calling DoPlayerTurnBoat() from processMovement()
PF2_INPUT_CAN_TURN_TANK = (BIT(4)), // Allow calling DoPlayerTurnTank() from processMovement()
PF2_INPUT_CAN_TURN_TANKRECT = (BIT(5)), // Allow calling DoPlayerTurnTankRect() from processMovement()
PF2_INPUT_CAN_TURN_TURRET = (BIT(6)), // Allow calling DoPlayerTurnTurret() from processMovement()
PF2_INPUT_CAN_MOVE_TURRET = (BIT(6)), // Allow calling DoPlayerMoveTurret() from processMovement()
};
///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -38,7 +38,7 @@ void DoPlayerHorizon(PLAYERp pp, fixed_t const q16horz, double const scaleAdjust
void DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust);
void DoPlayerTurnBoat(PLAYERp pp, fixed_t q16avel);
void DoPlayerTurnTank(PLAYERp pp, fixed_t q16avel, int z, int floor_dist);
void DoPlayerTurnTurret(PLAYERp pp, fixed_t q16avel);
void DoPlayerMoveTurret(PLAYERp pp, fixed_t q16avel, fixed_t q16horz, double const scaleAdjust);
static InputPacket loc;
static int32_t turnheldtime;
@ -295,8 +295,8 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_TANK))
DoPlayerTurnTank(pp, q16avel, pp->posz + Z(10), labs(pp->posz + Z(10) - pp->sop->floor_loz));
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_TURRET))
DoPlayerTurnTurret(pp, q16avel);
if (TEST(pp->Flags2, PF2_INPUT_CAN_MOVE_TURRET))
DoPlayerMoveTurret(pp, q16avel, q16horz, scaleAdjust);
if (pp->angAdjust)
pp->q16ang = (pp->q16ang + FloatToFixed(scaleAdjust * pp->angAdjust)) & 0x7FFFFFF;

View file

@ -202,7 +202,8 @@ void so_updateinterpolations(void) // Stick at beginning of domovethings
for (sop = SectorObject, interp = so_interpdata;
sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++)
{
if (SO_EMPTY(sop))
bool skip = !cl_syncinput && (sop->track == SO_TURRET);
if (SO_EMPTY(sop) || skip)
continue;
if (interp->tic < interp->lasttic)
interp->tic += synctics;
@ -240,7 +241,8 @@ void so_dointerpolations(int32_t smoothratio) // Stick at b
for (sop = SectorObject, interp = so_interpdata;
sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++)
{
if (SO_EMPTY(sop))
bool skip = !cl_syncinput && (sop->track == SO_TURRET);
if (SO_EMPTY(sop) || skip)
continue;
for (i = 0; i < interp->numinterpolations; i++)
@ -266,7 +268,8 @@ void so_dointerpolations(int32_t smoothratio) // Stick at b
for (sop = SectorObject, interp = so_interpdata;
sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++)
{
if (SO_EMPTY(sop))
bool skip = !cl_syncinput && (sop->track == SO_TURRET);
if (SO_EMPTY(sop) || skip)
continue;
// Check if interpolation has been explicitly disabled
@ -326,7 +329,8 @@ void so_restoreinterpolations(void) // Stick at end of drawscree
for (sop = SectorObject, interp = so_interpdata;
sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++)
{
if (SO_EMPTY(sop))
bool skip = !cl_syncinput && (sop->track == SO_TURRET);
if (SO_EMPTY(sop) || skip)
continue;
for (i = 0, data = interp->data; i < interp->numinterpolations; i++, data++)

View file

@ -3159,24 +3159,9 @@ DoPlayerMoveTank(PLAYERp pp)
}
void
DoPlayerMoveTurret(PLAYERp pp)
DoPlayerMoveTurret(PLAYERp pp, fixed_t q16avel, fixed_t q16horz, double const scaleAdjust)
{
if (!Prediction)
{
if (pp->input.q16avel && !pp->lastinput.q16avel)
PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND);
else if (!pp->input.q16avel && pp->lastinput.q16avel)
PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND);
}
if (!cl_syncinput)
{
SET(pp->Flags2, PF2_INPUT_CAN_TURN_TURRET);
}
else
{
DoPlayerTurnTurret(pp, pp->input.q16avel);
}
DoPlayerTurnTurret(pp, q16avel);
if (PLAYER_MOVING(pp) == 0)
RESET(pp->Flags, PF_PLAYER_MOVED);
@ -3185,14 +3170,7 @@ DoPlayerMoveTurret(PLAYERp pp)
OperateSectorObject(pp->sop, FixedToInt(pp->q16ang), pp->sop->xmid, pp->sop->ymid);
if (!cl_syncinput)
{
SET(pp->Flags2, PF2_INPUT_CAN_AIM);
}
else
{
DoPlayerHorizon(pp, pp->input.q16horz, 1);
}
DoPlayerHorizon(pp, q16horz, scaleAdjust);
}
void
@ -5774,7 +5752,22 @@ DoPlayerOperateTurret(PLAYERp pp)
if (pp->sop_remote)
RemoteToPlayer(pp);
DoPlayerMoveTurret(pp);
if (!Prediction)
{
if (pp->input.q16avel && !pp->lastinput.q16avel)
PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND);
else if (!pp->input.q16avel && pp->lastinput.q16avel)
PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND);
}
if (!cl_syncinput)
{
SET(pp->Flags2, PF2_INPUT_CAN_MOVE_TURRET);
}
else
{
DoPlayerMoveTurret(pp, pp->input.q16avel, pp->input.q16horz, 1);
}
if (pp->sop_remote)
{
@ -7434,7 +7427,7 @@ domovethings(void)
ChopsCheck(pp);
// Reset flags used while tying input to framerate
RESET(pp->Flags2, PF2_INPUT_CAN_AIM|PF2_INPUT_CAN_TURN_GENERAL|PF2_INPUT_CAN_TURN_BOAT|PF2_INPUT_CAN_TURN_TANK|PF2_INPUT_CAN_TURN_TANKRECT|PF2_INPUT_CAN_TURN_TURRET);
RESET(pp->Flags2, PF2_INPUT_CAN_AIM|PF2_INPUT_CAN_TURN_GENERAL|PF2_INPUT_CAN_TURN_BOAT|PF2_INPUT_CAN_TURN_TANK|PF2_INPUT_CAN_TURN_TANKRECT|PF2_INPUT_CAN_MOVE_TURRET);
resetinputhelpers(pp);
if (pp->DoPlayerAction) pp->DoPlayerAction(pp);