- SW: Hook up all vehicle turn code in processMovement() except for DoPlayerTurnTankRect(), which still needs considerations.

* Issue in `DoPlayerTurnTurret()` with `PlaySOsound()` calls occurring too frequently, still requires investigation on how to best handle this.
This commit is contained in:
Mitchell Richters 2020-09-08 06:22:47 +10:00
parent 0619281a34
commit 5145bf907a
3 changed files with 92 additions and 56 deletions

View file

@ -1055,8 +1055,12 @@ enum
PF_MOUSE_AIMING_ON = (BIT(30)), PF_MOUSE_AIMING_ON = (BIT(30)),
PF_WEAPON_DOWN = (BIT(31)), PF_WEAPON_DOWN = (BIT(31)),
PF2_TELEPORTED = (BIT(0)), PF2_TELEPORTED = (BIT(0)),
PF2_INPUT_CAN_TURN = (BIT(1)), // Allow calling DoPlayerTurn from getinput PF2_INPUT_CAN_AIM = (BIT(1)), // Allow calling DoPlayerHorizon from getinput
PF2_INPUT_CAN_AIM = (BIT(2)), // Allow calling DoPlayerHorizon from getinput PF2_INPUT_CAN_TURN_GENERAL = (BIT(2)), // Allow calling DoPlayerTurn from getinput
PF2_INPUT_CAN_TURN_BOAT = (BIT(3)), // Allow calling DoPlayerTurnBoat from getinput
PF2_INPUT_CAN_TURN_TANK = (BIT(4)), // Allow calling DoPlayerTurnTank from getinput
PF2_INPUT_CAN_TURN_TANKRECT = (BIT(5)), // Allow calling DoPlayerTurnTankRect from getinput
PF2_INPUT_CAN_TURN_TURRET = (BIT(6)), // Allow calling DoPlayerTurnTurret from getinput
}; };
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -34,8 +34,11 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
BEGIN_SW_NS BEGIN_SW_NS
void DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust);
void DoPlayerHorizon(PLAYERp pp, fixed_t const q16horz, double const scaleAdjust); 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);
static InputPacket loc; static InputPacket loc;
static int32_t turnheldtime; static int32_t turnheldtime;
@ -277,10 +280,20 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool
if (!cl_syncinput) if (!cl_syncinput)
{ {
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN))
DoPlayerTurn(pp, q16avel, scaleAdjust);
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 (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_GENERAL))
DoPlayerTurn(pp, q16avel, scaleAdjust);
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_BOAT))
DoPlayerTurnBoat(pp, q16avel);
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);
} }
loc.fvel = clamp(loc.fvel + fvel, -MAXFVEL, MAXFVEL); loc.fvel = clamp(loc.fvel + fvel, -MAXFVEL, MAXFVEL);

View file

@ -1628,15 +1628,14 @@ DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust)
} }
void void
DoPlayerTurnBoat(PLAYERp pp) DoPlayerTurnBoat(PLAYERp pp, fixed_t q16avel)
{ {
fixed_t q16avel;
SECTOR_OBJECTp sop = pp->sop; SECTOR_OBJECTp sop = pp->sop;
if (sop->drive_angspeed) if (sop->drive_angspeed)
{ {
fixed_t drive_oq16avel = pp->drive_q16avel; fixed_t drive_oq16avel = pp->drive_q16avel;
pp->drive_q16avel = (mulscale16(pp->input.q16avel, sop->drive_angspeed) + (drive_oq16avel * (sop->drive_angslide - 1))) / sop->drive_angslide; pp->drive_q16avel = (mulscale16(q16avel, sop->drive_angspeed) + (drive_oq16avel * (sop->drive_angslide - 1))) / sop->drive_angslide;
q16avel = pp->drive_q16avel; q16avel = pp->drive_q16avel;
} }
@ -1653,21 +1652,20 @@ DoPlayerTurnBoat(PLAYERp pp)
} }
void void
DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist) DoPlayerTurnTank(PLAYERp pp, fixed_t q16avel, int z, int floor_dist)
{ {
fixed_t q16avel;
SECTOR_OBJECTp sop = pp->sop; SECTOR_OBJECTp sop = pp->sop;
if (sop->drive_angspeed) if (sop->drive_angspeed)
{ {
fixed_t drive_oq16avel = pp->drive_q16avel; fixed_t drive_oq16avel = pp->drive_q16avel;
pp->drive_q16avel = (mulscale16(pp->input.q16avel, sop->drive_angspeed) + (drive_oq16avel * (sop->drive_angslide - 1))) / sop->drive_angslide; pp->drive_q16avel = (mulscale16(q16avel, sop->drive_angspeed) + (drive_oq16avel * (sop->drive_angslide - 1))) / sop->drive_angslide;
q16avel = pp->drive_q16avel; q16avel = pp->drive_q16avel;
} }
else else
{ {
q16avel = DIV8(pp->input.q16avel * synctics); q16avel = DIV8(q16avel * synctics);
} }
if (q16avel != 0) if (q16avel != 0)
@ -1709,29 +1707,29 @@ DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy)
} }
void void
DoPlayerTurnTurret(PLAYERp pp) DoPlayerTurnTurret(PLAYERp pp, fixed_t q16avel)
{ {
fixed_t q16avel, new_ang, diff; fixed_t new_ang, diff;
SECTOR_OBJECTp sop = pp->sop; SECTOR_OBJECTp sop = pp->sop;
if (!Prediction) if (!Prediction)
{ {
if (pp->input.q16avel && !pp->lastinput.q16avel) if (q16avel && !pp->lastinput.q16avel)
PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND); PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND);
else if (!pp->input.q16avel && pp->lastinput.q16avel) else if (!q16avel && pp->lastinput.q16avel)
PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND);
} }
if (sop->drive_angspeed) if (sop->drive_angspeed)
{ {
fixed_t drive_oq16avel = pp->drive_q16avel; fixed_t drive_oq16avel = pp->drive_q16avel;
pp->drive_q16avel = (mulscale16(pp->input.q16avel, sop->drive_angspeed) + (drive_oq16avel * (sop->drive_angslide - 1))) / sop->drive_angslide; pp->drive_q16avel = (mulscale16(q16avel, sop->drive_angspeed) + (drive_oq16avel * (sop->drive_angslide - 1))) / sop->drive_angslide;
q16avel = pp->drive_q16avel; q16avel = pp->drive_q16avel;
} }
else else
{ {
q16avel = DIV4(pp->input.q16avel * synctics); q16avel = DIV4(q16avel * synctics);
} }
if (q16avel != 0) if (q16avel != 0)
@ -2344,7 +2342,7 @@ DoPlayerMove(PLAYERp pp)
if (!cl_syncinput) if (!cl_syncinput)
{ {
SET(pp->Flags2, PF2_INPUT_CAN_TURN); SET(pp->Flags2, PF2_INPUT_CAN_TURN_GENERAL);
} }
else else
{ {
@ -2630,7 +2628,14 @@ DoPlayerMoveBoat(PLAYERp pp)
PlaySOsound(pp->sop->mid_sector,SO_IDLE_SOUND); PlaySOsound(pp->sop->mid_sector,SO_IDLE_SOUND);
} }
DoPlayerTurnBoat(pp); if (!cl_syncinput)
{
SET(pp->Flags2, PF2_INPUT_CAN_TURN_BOAT);
}
else
{
DoPlayerTurnBoat(pp, pp->input.q16avel);
}
if (PLAYER_MOVING(pp) == 0) if (PLAYER_MOVING(pp) == 0)
RESET(pp->Flags, PF_PLAYER_MOVED); RESET(pp->Flags, PF_PLAYER_MOVED);
@ -3120,7 +3125,14 @@ DoPlayerMoveTank(PLAYERp pp)
} }
else else
{ {
DoPlayerTurnTank(pp, z, floor_dist); if (!cl_syncinput)
{
SET(pp->Flags2, PF2_INPUT_CAN_TURN_TANK);
}
else
{
DoPlayerTurnTank(pp, pp->input.q16avel, z, floor_dist);
}
save_cstat = pp->SpriteP->cstat; save_cstat = pp->SpriteP->cstat;
RESET(pp->SpriteP->cstat, CSTAT_SPRITE_BLOCK); RESET(pp->SpriteP->cstat, CSTAT_SPRITE_BLOCK);
@ -3173,7 +3185,14 @@ DoPlayerMoveTank(PLAYERp pp)
void void
DoPlayerMoveTurret(PLAYERp pp) DoPlayerMoveTurret(PLAYERp pp)
{ {
DoPlayerTurnTurret(pp); if (!cl_syncinput)
{
SET(pp->Flags2, PF2_INPUT_CAN_TURN_TURRET);
}
else
{
DoPlayerTurnTurret(pp, pp->input.q16avel);
}
if (PLAYER_MOVING(pp) == 0) if (PLAYER_MOVING(pp) == 0)
RESET(pp->Flags, PF_PLAYER_MOVED); RESET(pp->Flags, PF_PLAYER_MOVED);
@ -6376,7 +6395,7 @@ void DoPlayerDeathFollowKiller(PLAYERp pp)
{ {
if (!cl_syncinput) if (!cl_syncinput)
{ {
SET(pp->Flags2, PF2_INPUT_CAN_TURN); SET(pp->Flags2, PF2_INPUT_CAN_TURN_GENERAL);
} }
else else
{ {
@ -6393,7 +6412,7 @@ void DoPlayerDeathFollowKiller(PLAYERp pp)
{ {
if (!cl_syncinput) if (!cl_syncinput)
{ {
SET(pp->Flags2, PF2_INPUT_CAN_TURN); 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));
} }
@ -7447,7 +7466,7 @@ domovethings(void)
ChopsCheck(pp); ChopsCheck(pp);
// Reset flags used while tying input to framerate // Reset flags used while tying input to framerate
RESET(pp->Flags2, PF2_INPUT_CAN_TURN|PF2_INPUT_CAN_AIM); 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);
resetinputhelpers(pp); resetinputhelpers(pp);
if (pp->DoPlayerAction) pp->DoPlayerAction(pp); if (pp->DoPlayerAction) pp->DoPlayerAction(pp);