mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-31 12:30:40 +00:00
- Move syncinput mechanism into GameInput
object.
This commit is contained in:
parent
39df2714e9
commit
52b20e1f59
19 changed files with 51 additions and 53 deletions
|
@ -182,8 +182,6 @@ extern int hud_size_max;
|
|||
static bool sendPause;
|
||||
bool pausedWithKey;
|
||||
|
||||
static bool gamesetinput = false;
|
||||
|
||||
int PlayClock;
|
||||
extern int nextwipe;
|
||||
|
||||
|
@ -1529,26 +1527,11 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Raze, GetBuildTime, I_GetBuildTime)
|
|||
ACTION_RETURN_INT(I_GetBuildTime());
|
||||
}
|
||||
|
||||
bool SyncInput()
|
||||
{
|
||||
return gamesetinput || cl_syncinput || cl_capfps;
|
||||
}
|
||||
|
||||
void setForcedSyncInput(const int playeridx)
|
||||
{
|
||||
if (playeridx == myconnectindex) gamesetinput = true;
|
||||
}
|
||||
|
||||
void resetForcedSyncInput()
|
||||
{
|
||||
gamesetinput = false;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_Raze, forceSyncInput, setForcedSyncInput)
|
||||
DEFINE_ACTION_FUNCTION(_Raze, forceSyncInput)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_INT(playeridx);
|
||||
setForcedSyncInput(playeridx);
|
||||
gameInput.ForceInputSync(playeridx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,9 +46,6 @@ void ChangeLevel(MapRecord* map, int skill, bool bossexit = false);
|
|||
void CompleteLevel(MapRecord* map);
|
||||
bool CheckCheatmode(bool printmsg = true, bool sponly = false);
|
||||
void setVideoMode();
|
||||
bool SyncInput();
|
||||
void setForcedSyncInput(const int playeridx);
|
||||
void resetForcedSyncInput();
|
||||
|
||||
void TITLE_InformName(const char* newname);
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "gameinput.h"
|
||||
#include "coreplayer.h"
|
||||
#include "g_input.h"
|
||||
#include "d_net.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -399,7 +398,7 @@ void PlayerAngles::doPitchInput(InputPacket* const input)
|
|||
// Add player's mouse/device input.
|
||||
if (input->ang.Pitch.Degrees())
|
||||
{
|
||||
pActor->spr.Angles.Pitch += input->ang.Pitch * SyncInput();
|
||||
pActor->spr.Angles.Pitch += input->ang.Pitch * gameInput.SyncInput();
|
||||
input->actions &= ~SB_CENTERVIEW;
|
||||
}
|
||||
|
||||
|
@ -446,7 +445,7 @@ void PlayerAngles::doPitchInput(InputPacket* const input)
|
|||
void PlayerAngles::doYawInput(InputPacket* const input)
|
||||
{
|
||||
// Add player's mouse/device input.
|
||||
pActor->spr.Angles.Yaw += input->ang.Yaw * SyncInput();
|
||||
pActor->spr.Angles.Yaw += input->ang.Yaw * gameInput.SyncInput();
|
||||
|
||||
if (input->actions & SB_TURNAROUND)
|
||||
{
|
||||
|
@ -597,7 +596,7 @@ void PlayerAngles::doRollInput(InputPacket* const input, const DVector2& nVelVec
|
|||
else
|
||||
{
|
||||
// Add player's device input.
|
||||
pActor->spr.Angles.Roll += input->ang.Roll * SyncInput();
|
||||
pActor->spr.Angles.Roll += input->ang.Roll * gameInput.SyncInput();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "serializer.h"
|
||||
#include "gamefuncs.h"
|
||||
#include "d_net.h"
|
||||
|
||||
enum : unsigned
|
||||
{
|
||||
|
@ -43,6 +44,7 @@ class GameInput
|
|||
ESyncBits ActionsToSend;
|
||||
double turnheldtime;
|
||||
double scaleAdjust;
|
||||
bool syncinput;
|
||||
int WeaponToSend;
|
||||
int dpad_lock;
|
||||
int keymove;
|
||||
|
@ -91,6 +93,23 @@ public:
|
|||
scaleAdjust = !SyncInput() ? frac : 1;
|
||||
}
|
||||
|
||||
// Handling of whether to allow unsynchronised input.
|
||||
bool SyncInput()
|
||||
{
|
||||
return syncinput || cl_syncinput || cl_capfps;
|
||||
}
|
||||
void ForceInputSync(const int pnum)
|
||||
{
|
||||
if (pnum == myconnectindex)
|
||||
{
|
||||
syncinput = true;
|
||||
}
|
||||
}
|
||||
void ResetInputSync()
|
||||
{
|
||||
syncinput = false;
|
||||
}
|
||||
|
||||
// Prototypes for large member functions.
|
||||
void processMovement(const double turnscale = 1, const bool allowstrafe = true, const int drink_amt = 0);
|
||||
void processVehicle(const double baseVel, const double velScale, const unsigned flags);
|
||||
|
|
|
@ -617,7 +617,7 @@ void TryRunTics (void)
|
|||
gi->Predict(myconnectindex);
|
||||
#endif
|
||||
}
|
||||
if (!SyncInput())
|
||||
if (!gameInput.SyncInput())
|
||||
{
|
||||
gameInput.getInput();
|
||||
}
|
||||
|
|
|
@ -431,7 +431,7 @@ void GameInterface::Ticker()
|
|||
DBloodPlayer* pPlayer = getPlayer(myconnectindex);
|
||||
|
||||
// disable synchronised input if set by game.
|
||||
resetForcedSyncInput();
|
||||
gameInput.ResetInputSync();
|
||||
|
||||
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
||||
{
|
||||
|
|
|
@ -2188,7 +2188,7 @@ void trPlayerCtrlSetLookAngle(int value, DBloodPlayer* pPlayer)
|
|||
|
||||
if (const double adjustment = clamp(value * 0.125 * (value > 0 ? lookStepUp : lookStepDown), downAngle, upAngle))
|
||||
{
|
||||
setForcedSyncInput(pPlayer->pnum);
|
||||
gameInput.ForceInputSync(pPlayer->pnum);
|
||||
pPlayer->GetActor()->spr.Angles.Pitch = maphoriz(-100. * tan(adjustment * pi::pi() * (1. / 1024.)));
|
||||
}
|
||||
}
|
||||
|
@ -6060,12 +6060,12 @@ bool modernTypeOperateSprite(DBloodActor* actor, EVENT& event)
|
|||
if (actor->xspr.data4 != 0) break;
|
||||
else if (actor->spr.flags & kModernTypeFlag1)
|
||||
{
|
||||
setForcedSyncInput(pPlayer->pnum);
|
||||
gameInput.ForceInputSync(pPlayer->pnum);
|
||||
pPlayer->GetActor()->spr.Angles.Yaw = actor->spr.Angles.Yaw;
|
||||
}
|
||||
else if (valueIsBetween(actor->xspr.data2, -kAng360, kAng360))
|
||||
{
|
||||
setForcedSyncInput(pPlayer->pnum);
|
||||
gameInput.ForceInputSync(pPlayer->pnum);
|
||||
pPlayer->GetActor()->spr.Angles.Yaw = mapangle(actor->xspr.data2);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1531,7 +1531,7 @@ void ProcessInput(DBloodPlayer* pPlayer)
|
|||
if (actor->xspr.health == 0)
|
||||
{
|
||||
// force synchronised input upon death.
|
||||
setForcedSyncInput(pPlayer->pnum);
|
||||
gameInput.ForceInputSync(pPlayer->pnum);
|
||||
|
||||
bool bSeqStat = playerSeqPlaying(pPlayer, 16);
|
||||
DBloodActor* fragger = pPlayer->fragger;
|
||||
|
|
|
@ -251,7 +251,7 @@ void drawoverlays(double interpfrac)
|
|||
if (screenpeek == myconnectindex && numplayers > 1)
|
||||
{
|
||||
cposxy = interpolatedvalue(omypos, mypos, interpfrac).XY();
|
||||
cang = !SyncInput() ? myang : interpolatedvalue(omyang, myang, interpfrac);
|
||||
cang = interpolatedvalue(omyang, myang, interpfrac);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -540,7 +540,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
|
|||
break;
|
||||
|
||||
case PLAYER_NEWOWNER:
|
||||
if (bSet && (p->newOwner = vValue.safeActor())) setForcedSyncInput(iPlayer);
|
||||
if (bSet && (p->newOwner = vValue.safeActor())) gameInput.ForceInputSync(iPlayer);
|
||||
else SetGameVarID(lVar2, p->newOwner, sActor, sPlayer);
|
||||
break;
|
||||
|
||||
|
@ -610,7 +610,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
|
|||
break;
|
||||
|
||||
case PLAYER_ON_CRANE:
|
||||
if (bSet && (p->on_crane = vValue.safeActor())) setForcedSyncInput(iPlayer);
|
||||
if (bSet && (p->on_crane = vValue.safeActor())) gameInput.ForceInputSync(iPlayer);
|
||||
else SetGameVarID(lVar2, (p->on_crane), sActor, sPlayer);
|
||||
break;
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ void GameInterface::Ticker()
|
|||
}
|
||||
|
||||
// disable synchronised input if set by game.
|
||||
resetForcedSyncInput();
|
||||
gameInput.ResetInputSync();
|
||||
|
||||
DukeSpriteIterator it;
|
||||
while (auto ac = it.Next())
|
||||
|
|
|
@ -527,7 +527,7 @@ void playerisdead(DDukePlayer* const p, int psectlotag, double floorz, double ce
|
|||
auto actor = p->GetActor();
|
||||
|
||||
// lock input when dead.
|
||||
setForcedSyncInput(p->pnum);
|
||||
gameInput.ForceInputSync(p->pnum);
|
||||
|
||||
if (p->dead_flag == 0)
|
||||
{
|
||||
|
@ -857,7 +857,7 @@ void playerCenterView(DDukePlayer* const p)
|
|||
{
|
||||
p->cmd.ucmd.actions |= SB_CENTERVIEW;
|
||||
p->cmd.ucmd.ang.Pitch = nullAngle;
|
||||
setForcedSyncInput(p->pnum);
|
||||
gameInput.ForceInputSync(p->pnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1651,7 +1651,7 @@ void processinput_d(DDukePlayer* const p)
|
|||
|
||||
if (p->newOwner != nullptr)
|
||||
{
|
||||
setForcedSyncInput(p->pnum);
|
||||
gameInput.ForceInputSync(p->pnum);
|
||||
p->vel.X = p->vel.Y = 0;
|
||||
pact->vel.X = 0;
|
||||
|
||||
|
@ -1671,7 +1671,7 @@ void processinput_d(DDukePlayer* const p)
|
|||
|
||||
if (p->on_crane != nullptr)
|
||||
{
|
||||
setForcedSyncInput(p->pnum);
|
||||
gameInput.ForceInputSync(p->pnum);
|
||||
goto HORIZONLY;
|
||||
}
|
||||
|
||||
|
@ -1705,7 +1705,7 @@ void processinput_d(DDukePlayer* const p)
|
|||
p->vel.X = 0;
|
||||
p->vel.Y = 0;
|
||||
p->cmd.ucmd.ang.Yaw = nullAngle;
|
||||
setForcedSyncInput(p->pnum);
|
||||
gameInput.ForceInputSync(p->pnum);
|
||||
}
|
||||
|
||||
p->Angles.doYawInput(&p->cmd.ucmd);
|
||||
|
|
|
@ -2473,7 +2473,7 @@ void processinput_r(DDukePlayer* const p)
|
|||
|
||||
if (p->newOwner != nullptr)
|
||||
{
|
||||
setForcedSyncInput(p->pnum);
|
||||
gameInput.ForceInputSync(p->pnum);
|
||||
p->vel.X = p->vel.Y = 0;
|
||||
pact->vel.X = 0;
|
||||
|
||||
|
@ -2493,7 +2493,7 @@ void processinput_r(DDukePlayer* const p)
|
|||
|
||||
if (p->on_crane != nullptr)
|
||||
{
|
||||
setForcedSyncInput(p->pnum);
|
||||
gameInput.ForceInputSync(p->pnum);
|
||||
goto HORIZONLY;
|
||||
}
|
||||
|
||||
|
@ -2542,7 +2542,7 @@ void processinput_r(DDukePlayer* const p)
|
|||
p->vel.X = 0;
|
||||
p->vel.Y = 0;
|
||||
p->cmd.ucmd.ang.Yaw = nullAngle;
|
||||
setForcedSyncInput(p->pnum);
|
||||
gameInput.ForceInputSync(p->pnum);
|
||||
}
|
||||
|
||||
p->Angles.doYawInput(&p->cmd.ucmd);
|
||||
|
|
|
@ -386,7 +386,7 @@ public:
|
|||
|
||||
if ((centertest && returnlock) || !cmd.ucmd.ang.Pitch.Degrees())
|
||||
{
|
||||
setForcedSyncInput(pnum);
|
||||
gameInput.ForceInputSync(pnum);
|
||||
cmd.ucmd.ang.Pitch = nullAngle;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -327,7 +327,7 @@ void GameInterface::Ticker()
|
|||
else if (EndLevel == 0)
|
||||
{
|
||||
// disable synchronised input if set by game.
|
||||
resetForcedSyncInput();
|
||||
gameInput.ResetInputSync();
|
||||
|
||||
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
||||
{
|
||||
|
|
|
@ -109,7 +109,7 @@ void MoveThings()
|
|||
{
|
||||
if (nFreeze == 1 || nFreeze == 2)
|
||||
{
|
||||
setForcedSyncInput(nLocalPlayer);
|
||||
gameInput.ForceInputSync(nLocalPlayer);
|
||||
DoSpiritHead();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1506,7 +1506,7 @@ static void doPlayerUnderwater(DExhumedPlayer* const pPlayer, const bool oUnderw
|
|||
|
||||
static void doPlayerRamses(DExhumedPlayer* const pPlayer)
|
||||
{
|
||||
setForcedSyncInput(pPlayer->pnum);
|
||||
gameInput.ForceInputSync(pPlayer->pnum);
|
||||
|
||||
if (nTotalPlayers <= 1)
|
||||
{
|
||||
|
@ -2064,7 +2064,7 @@ void AIPlayer::Tick(RunListEvent* ev)
|
|||
}
|
||||
else
|
||||
{
|
||||
setForcedSyncInput(nPlayer);
|
||||
gameInput.ForceInputSync(nPlayer);
|
||||
doPlayerDeathPitch(pPlayer);
|
||||
|
||||
if (!doPlayerDeathRestart(pPlayer))
|
||||
|
|
|
@ -2455,7 +2455,7 @@ void DoPlayerMoveVehicle(DSWPlayer* pp)
|
|||
pp->setcursector(pp->sop->op_main_sector); // for speed
|
||||
|
||||
double floordist = abs(zz - pp->sop->floor_loz);
|
||||
setForcedSyncInput(pp->pnum);
|
||||
gameInput.ForceInputSync(pp->pnum);
|
||||
|
||||
DoPlayerVehicleInputScaling(pp, &DRotator::Yaw, 0.125f);
|
||||
DoPlayerVehicleInputScaling(pp, &DRotator::Pitch, 0.125f);
|
||||
|
@ -2590,7 +2590,7 @@ void DoPlayerMoveTurret(DSWPlayer* pp)
|
|||
PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND);
|
||||
}
|
||||
|
||||
setForcedSyncInput(pp->pnum);
|
||||
gameInput.ForceInputSync(pp->pnum);
|
||||
|
||||
DoPlayerVehicleInputScaling(pp, &DRotator::Yaw, 0.125f);
|
||||
DoPlayerVehicleInputScaling(pp, &DRotator::Pitch, 0.125f);
|
||||
|
@ -5678,7 +5678,7 @@ void DoPlayerBeginDie(DSWPlayer* pp)
|
|||
pp->Flags |= (PF_DEAD);
|
||||
plActor->user.Flags &= ~(SPR_BOUNCE);
|
||||
pp->Flags &= ~(PF_HEAD_CONTROL);
|
||||
setForcedSyncInput(pp->pnum);
|
||||
gameInput.ForceInputSync(pp->pnum);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -6775,7 +6775,7 @@ void domovethings(void)
|
|||
{
|
||||
WeaponOperate(pp);
|
||||
PlayerOperateEnv(pp);
|
||||
resetForcedSyncInput();
|
||||
gameInput.ResetInputSync();
|
||||
}
|
||||
|
||||
// do for moving sectors
|
||||
|
|
Loading…
Reference in a new issue