- SW: Simplify unsynchronised input setup.

* Had complicated flagging and setup for SO vehicles that never worked and doubt I'd ever get to work.
* Setup now lends itself well to a potential more generic input setup.
This commit is contained in:
Mitchell Richters 2023-03-18 11:40:42 +11:00
parent 292030b59e
commit a4f0a75a58
4 changed files with 33 additions and 108 deletions

View file

@ -567,8 +567,6 @@ enum
PF_TANK = (BIT(29)), // Doin the tank thang PF_TANK = (BIT(29)), // Doin the tank thang
PF_WEAPON_DOWN = (BIT(31)), PF_WEAPON_DOWN = (BIT(31)),
PF2_TELEPORTED = (BIT(0)), PF2_TELEPORTED = (BIT(0)),
PF2_INPUT_CAN_AIM = (BIT(1)), // Allow calling DoPlayerHorizon() from processMovement()
PF2_INPUT_CAN_TURN_GENERAL = (BIT(2)), // Allow calling DoPlayerTurn() from processMovement()
PF2_INPUT_CAN_TURN_VEHICLE = (BIT(3)), // Allow calling DoPlayerTurnVehicle() from processMovement() PF2_INPUT_CAN_TURN_VEHICLE = (BIT(3)), // Allow calling DoPlayerTurnVehicle() from processMovement()
PF2_INPUT_CAN_TURN_TURRET = (BIT(4)), // Allow calling DoPlayerTurnTurret() from processMovement() PF2_INPUT_CAN_TURN_TURRET = (BIT(4)), // Allow calling DoPlayerTurnTurret() from processMovement()
}; };

View file

@ -34,9 +34,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
BEGIN_SW_NS BEGIN_SW_NS
void DoPlayerTurnVehicle(PLAYER* pp, DAngle& plyaw, float avel, double z, double floor_dist);
void DoPlayerTurnTurret(PLAYER* pp, DAngle& plyaw, float avel);
static InputPacket loc; static InputPacket loc;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -180,26 +177,9 @@ void GameInterface::GetInput(const double scaleAdjust, InputPacket *packet)
processWeapon(pp); processWeapon(pp);
if (!SyncInput()) if (!SyncInput())
{
if ((pp->Flags2 & PF2_INPUT_CAN_AIM))
{
pp->Angles.CameraAngles.Pitch += DAngle::fromDeg(input.horz);
}
if ((pp->Flags2 & PF2_INPUT_CAN_TURN_GENERAL))
{ {
pp->Angles.CameraAngles.Yaw += DAngle::fromDeg(input.avel); pp->Angles.CameraAngles.Yaw += DAngle::fromDeg(input.avel);
} pp->Angles.CameraAngles.Pitch += DAngle::fromDeg(input.horz);
if ((pp->Flags2 & PF2_INPUT_CAN_TURN_VEHICLE))
{
DoPlayerTurnVehicle(pp, pp->Angles.CameraAngles.Yaw, input.avel, pp->actor->getOffsetZ() + 10, abs(pp->actor->getOffsetZ() + 10 - pp->sop->floor_loz));
}
if ((pp->Flags2 & PF2_INPUT_CAN_TURN_TURRET))
{
DoPlayerTurnTurret(pp, pp->Angles.CameraAngles.Yaw, input.avel);
}
} }
if (packet) if (packet)

View file

@ -385,11 +385,9 @@ void so_updateinterpolations(void) // Stick at beginning of domovethings
for (sop = SectorObject, interp = so_interpdata; for (sop = SectorObject, interp = so_interpdata;
sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++) sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++)
{ {
bool skip = !SyncInput() && (sop->track == SO_TURRET); if (SO_EMPTY(sop))
if (SO_EMPTY(sop) || skip)
continue; continue;
if (interp->tic < interp->lasttic) if (interp->tic < interp->lasttic)
interp->tic += synctics; interp->tic += synctics;
for (i = 0, data = interp->data; i < interp->numinterpolations; i++, data++) for (i = 0, data = interp->data; i < interp->numinterpolations; i++, data++)
@ -436,11 +434,9 @@ void so_dointerpolations(double interpfrac) // Stick at beg
for (sop = SectorObject, interp = so_interpdata; for (sop = SectorObject, interp = so_interpdata;
sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++) sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++)
{ {
bool skip = !SyncInput() && (sop->track == SO_TURRET); if (SO_EMPTY(sop))
if (SO_EMPTY(sop) || skip)
continue; continue;
for (i = 0; i < interp->numinterpolations; i++) for (i = 0; i < interp->numinterpolations; i++)
{ {
auto actorofang = interp->data[i].actorofang; auto actorofang = interp->data[i].actorofang;
@ -472,8 +468,7 @@ void so_dointerpolations(double interpfrac) // Stick at beg
for (sop = SectorObject, interp = so_interpdata; for (sop = SectorObject, interp = so_interpdata;
sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++) sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++)
{ {
bool skip = !SyncInput() && (sop->track == SO_TURRET); if (SO_EMPTY(sop))
if (SO_EMPTY(sop) || skip)
continue; continue;
// Check if interpolation has been explicitly disabled // Check if interpolation has been explicitly disabled
@ -542,8 +537,7 @@ void so_restoreinterpolations(void) // Stick at end of drawscree
for (sop = SectorObject, interp = so_interpdata; for (sop = SectorObject, interp = so_interpdata;
sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++) sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++)
{ {
bool skip = !SyncInput() && (sop->track == SO_TURRET); if (SO_EMPTY(sop))
if (SO_EMPTY(sop) || skip)
continue; continue;
for (i = 0, data = interp->data; i < interp->numinterpolations; i++, data++) for (i = 0, data = interp->data; i < interp->numinterpolations; i++, data++)

View file

@ -146,7 +146,6 @@ void DoPlayerFly(PLAYER* pp);
void DoPlayerBeginClimb(PLAYER* pp); void DoPlayerBeginClimb(PLAYER* pp);
void DoPlayerClimb(PLAYER* pp); void DoPlayerClimb(PLAYER* pp);
void DoPlayerBeginDie(PLAYER* pp); void DoPlayerBeginDie(PLAYER* pp);
void DoPlayerDie(PLAYER* pp);
// void DoPlayerBeginOperateBoat(PLAYER* pp); // void DoPlayerBeginOperateBoat(PLAYER* pp);
void DoPlayerBeginOperateVehicle(PLAYER* pp); void DoPlayerBeginOperateVehicle(PLAYER* pp);
void DoPlayerBeginOperate(PLAYER* pp); void DoPlayerBeginOperate(PLAYER* pp);
@ -1529,28 +1528,28 @@ void UpdatePlayerSpriteAngle(PLAYER* pp)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void DoPlayerTurnVehicle(PLAYER* pp, DAngle& plyaw, float avel, double zz, double floordist) void DoPlayerTurnVehicle(PLAYER* pp, double zz, double floordist)
{ {
SECTOR_OBJECT* sop = pp->sop; SECTOR_OBJECT* sop = pp->sop;
if (sop->drive_angspeed) if (sop->drive_angspeed)
{ {
float drive_oavel = pp->drive_avel; float drive_oavel = pp->drive_avel;
pp->drive_avel = float((avel * sop->drive_angspeed + (drive_oavel * (sop->drive_angslide - 1))) / sop->drive_angslide); pp->drive_avel = float((pp->input.avel * sop->drive_angspeed + (drive_oavel * (sop->drive_angslide - 1))) / sop->drive_angslide);
avel = pp->drive_avel; pp->input.avel = pp->drive_avel;
} }
else else
{ {
avel *= synctics * 0.125f; pp->input.avel *= synctics * 0.125f;
} }
if (avel != 0) if (pp->input.avel != 0)
{ {
auto sum = plyaw + DAngle::fromDeg(avel); auto sum = pp->actor->spr.Angles.Yaw + DAngle::fromDeg(pp->input.avel);
if (MultiClipTurn(pp, sum, zz, floordist)) if (MultiClipTurn(pp, sum, zz, floordist))
{ {
plyaw = sum; pp->actor->spr.Angles.Yaw = sum;
} }
} }
} }
@ -1594,7 +1593,7 @@ void DoPlayerTurnVehicleRect(PLAYER* pp, DVector2* pos, DVector2* opos)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void DoPlayerTurnTurret(PLAYER* pp, DAngle& plyaw, float avel) void DoPlayerTurnTurret(PLAYER* pp)
{ {
DAngle new_ang, diff; DAngle new_ang, diff;
SECTOR_OBJECT* sop = pp->sop; SECTOR_OBJECT* sop = pp->sop;
@ -1602,18 +1601,18 @@ void DoPlayerTurnTurret(PLAYER* pp, DAngle& plyaw, float avel)
if (sop->drive_angspeed) if (sop->drive_angspeed)
{ {
float drive_oavel = pp->drive_avel; float drive_oavel = pp->drive_avel;
pp->drive_avel = float((avel * sop->drive_angspeed + (drive_oavel * (sop->drive_angslide - 1))) / sop->drive_angslide); pp->drive_avel = float((pp->input.avel * sop->drive_angspeed + (drive_oavel * (sop->drive_angslide - 1))) / sop->drive_angslide);
avel = pp->drive_avel; pp->input.avel = pp->drive_avel;
} }
else else
{ {
avel = avel * synctics * 0.25f; pp->input.avel = pp->input.avel * synctics * 0.25f;
} }
if (fabs(avel) >= FLT_EPSILON) if (fabs(pp->input.avel) >= FLT_EPSILON)
{ {
new_ang = plyaw + DAngle::fromDeg(avel); new_ang = pp->actor->spr.Angles.Yaw + DAngle::fromDeg(pp->input.avel);
if (sop->limit_ang_center >= nullAngle) if (sop->limit_ang_center >= nullAngle)
{ {
@ -1628,10 +1627,10 @@ void DoPlayerTurnTurret(PLAYER* pp, DAngle& plyaw, float avel)
} }
} }
plyaw = new_ang; pp->actor->spr.Angles.Yaw = new_ang;
} }
OperateSectorObject(pp->sop, plyaw, pp->sop->pmid); OperateSectorObject(pp->sop, pp->actor->spr.Angles.Yaw, pp->sop->pmid);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -2026,11 +2025,7 @@ void DoPlayerMove(PLAYER* pp)
pp->Angles.doViewYaw(&pp->input); pp->Angles.doViewYaw(&pp->input);
if (!SyncInput()) if (SyncInput())
{
pp->Flags2 |= (PF2_INPUT_CAN_TURN_GENERAL);
}
else
{ {
pp->actor->spr.Angles.Yaw += DAngle::fromDeg(pp->input.avel); pp->actor->spr.Angles.Yaw += DAngle::fromDeg(pp->input.avel);
} }
@ -2154,11 +2149,7 @@ void DoPlayerMove(PLAYER* pp)
DoPlayerSetWadeDepth(pp); DoPlayerSetWadeDepth(pp);
if (!SyncInput()) if (SyncInput())
{
pp->Flags2 |= (PF2_INPUT_CAN_AIM);
}
else
{ {
pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz); pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz);
} }
@ -2581,9 +2572,6 @@ void DoPlayerMoveVehicle(PLAYER* pp)
PlaySOsound(pp->sop->mid_sector,SO_IDLE_SOUND); PlaySOsound(pp->sop->mid_sector,SO_IDLE_SOUND);
} }
// force synchronised input here for now.
setForcedSyncInput();
if (PLAYER_MOVING(pp) == 0) if (PLAYER_MOVING(pp) == 0)
pp->Flags &= ~(PF_PLAYER_MOVED); pp->Flags &= ~(PF_PLAYER_MOVED);
else else
@ -2695,14 +2683,8 @@ void DoPlayerMoveVehicle(PLAYER* pp)
} }
else else
{ {
if (!SyncInput()) setForcedSyncInput();
{ DoPlayerTurnVehicle(pp, zz, floordist);
pp->Flags2 |= (PF2_INPUT_CAN_TURN_VEHICLE);
}
else
{
DoPlayerTurnVehicle(pp, pp->actor->spr.Angles.Yaw, pp->input.avel, zz, floordist);
}
auto save_cstat = plActor->spr.cstat; auto save_cstat = plActor->spr.cstat;
plActor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK); plActor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK);
@ -2741,11 +2723,7 @@ void DoPlayerMoveVehicle(PLAYER* pp)
OperateSectorObject(pp->sop, pp->actor->spr.Angles.Yaw, pp->actor->spr.pos.XY()); OperateSectorObject(pp->sop, pp->actor->spr.Angles.Yaw, pp->actor->spr.pos.XY());
pp->cursector = save_sect; // for speed pp->cursector = save_sect; // for speed
if (!SyncInput()) if (SyncInput())
{
pp->Flags2 |= (PF2_INPUT_CAN_AIM);
}
else
{ {
pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz); pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz);
} }
@ -2773,25 +2751,15 @@ void DoPlayerMoveTurret(PLAYER* pp)
PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND);
} }
if (!SyncInput()) setForcedSyncInput();
{ DoPlayerTurnTurret(pp);
pp->Flags2 |= (PF2_INPUT_CAN_TURN_TURRET);
}
else
{
DoPlayerTurnTurret(pp, pp->actor->spr.Angles.Yaw, pp->input.avel);
}
if (PLAYER_MOVING(pp) == 0) if (PLAYER_MOVING(pp) == 0)
pp->Flags &= ~(PF_PLAYER_MOVED); pp->Flags &= ~(PF_PLAYER_MOVED);
else else
pp->Flags |= (PF_PLAYER_MOVED); pp->Flags |= (PF_PLAYER_MOVED);
if (!SyncInput()) if (SyncInput())
{
pp->Flags2 |= (PF2_INPUT_CAN_AIM);
}
else
{ {
pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz); pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz);
} }
@ -3389,11 +3357,7 @@ void DoPlayerClimb(PLAYER* pp)
// setsprite to players location // setsprite to players location
ChangeActorSect(pp->actor, pp->cursector); ChangeActorSect(pp->actor, pp->cursector);
if (!SyncInput()) if (SyncInput())
{
pp->Flags2 |= (PF2_INPUT_CAN_AIM);
}
else
{ {
pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz); pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz);
} }
@ -5904,6 +5868,7 @@ void DoPlayerBeginDie(PLAYER* pp)
pp->Flags |= (PF_DEAD); pp->Flags |= (PF_DEAD);
plActor->user.Flags &= ~(SPR_BOUNCE); plActor->user.Flags &= ~(SPR_BOUNCE);
pp->Flags &= ~(PF_HEAD_CONTROL); pp->Flags &= ~(PF_HEAD_CONTROL);
setForcedSyncInput();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -5995,15 +5960,8 @@ void DoPlayerDeathFollowKiller(PLAYER* pp)
// allow turning // allow turning
if (pp->Flags & (PF_DEAD_HEAD|PF_HEAD_CONTROL)) if (pp->Flags & (PF_DEAD_HEAD|PF_HEAD_CONTROL))
{
if (!SyncInput())
{
pp->Flags2 |= (PF2_INPUT_CAN_TURN_GENERAL);
}
else
{ {
pp->actor->spr.Angles.Yaw += DAngle::fromDeg(pp->input.avel); pp->actor->spr.Angles.Yaw += DAngle::fromDeg(pp->input.avel);
}
UpdatePlayerSpriteAngle(pp); UpdatePlayerSpriteAngle(pp);
} }
@ -6996,18 +6954,13 @@ void domovethings(void)
{ {
WeaponOperate(pp); WeaponOperate(pp);
PlayerOperateEnv(pp); PlayerOperateEnv(pp);
resetForcedSyncInput();
} }
// do for moving sectors // do for moving sectors
DoPlayerSectorUpdatePreMove(pp); DoPlayerSectorUpdatePreMove(pp);
ChopsCheck(pp); ChopsCheck(pp);
// Reset flags used while tying input to framerate
pp->Flags2 &= ~(PF2_INPUT_CAN_AIM|PF2_INPUT_CAN_TURN_GENERAL|PF2_INPUT_CAN_TURN_VEHICLE|PF2_INPUT_CAN_TURN_TURRET);
// disable synchronised input if set by game.
resetForcedSyncInput();
// convert fvel/svel into a vector before performing actions. // convert fvel/svel into a vector before performing actions.
const auto velvect = DVector2(pp->input.fvel, pp->input.svel).Rotated(pp->actor->spr.Angles.Yaw); const auto velvect = DVector2(pp->input.fvel, pp->input.svel).Rotated(pp->actor->spr.Angles.Yaw);
pp->input.fvel = (float)velvect.X; pp->input.fvel = (float)velvect.X;