mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-16 08:52:15 +00:00
- Duke: Rework input blocking setup.
* Takes the duplicated conditions out of the input handler and makes the ticker responsible by forcing synchronised input.
This commit is contained in:
parent
bd3e9b305e
commit
4355a44721
10 changed files with 43 additions and 41 deletions
|
@ -1512,6 +1512,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Raze, GetBuildTime, I_GetBuildTime)
|
|||
ACTION_RETURN_INT(I_GetBuildTime());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_Raze, forceSyncInput, setForcedSyncInput)
|
||||
{
|
||||
setForcedSyncInput();
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Raze, PickTexture)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
|
|
|
@ -551,7 +551,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
|
|||
break;
|
||||
|
||||
case PLAYER_NEWOWNER:
|
||||
if (bSet) ps[iPlayer].newOwner = vValue.safeActor();
|
||||
if (bSet && (ps[iPlayer].newOwner = vValue.safeActor())) setForcedSyncInput();
|
||||
else SetGameVarID(lVar2, ps[iPlayer].newOwner, sActor, sPlayer);
|
||||
break;
|
||||
|
||||
|
@ -621,7 +621,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
|
|||
break;
|
||||
|
||||
case PLAYER_ON_CRANE:
|
||||
if (bSet) ps[iPlayer].on_crane = vValue.safeActor();
|
||||
if (bSet && (ps[iPlayer].on_crane = vValue.safeActor())) setForcedSyncInput();
|
||||
else SetGameVarID(lVar2, (ps[iPlayer].on_crane), sActor, sPlayer);
|
||||
break;
|
||||
|
||||
|
|
|
@ -741,41 +741,6 @@ static void processVehicleInput(player_struct *p, HIDInput* const hidInput, Inpu
|
|||
inputBuffer->avel += currInput->avel;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// finalizes the input and passes it to the global input buffer
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void FinalizeInput(player_struct *p, InputPacket& input)
|
||||
{
|
||||
if (gamestate != GS_LEVEL || movementBlocked(p) || p->GetActor()->spr.extra <= 0)
|
||||
{
|
||||
// neutralize all movement when not in a game, blocked or in automap follow mode
|
||||
loc.fvel = loc.svel = 0;
|
||||
loc.avel = loc.horz = 0;
|
||||
input.avel = input.horz = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p->on_crane != nullptr)
|
||||
{
|
||||
loc.fvel = input.fvel = 0;
|
||||
loc.svel = input.svel = 0;
|
||||
}
|
||||
|
||||
if (p->newOwner != nullptr || p->on_crane != nullptr)
|
||||
{
|
||||
loc.avel = input.avel = 0;
|
||||
}
|
||||
|
||||
if (p->newOwner != nullptr || (p->sync.actions & SB_CENTERVIEW && abs(p->GetActor()->spr.Angles.Pitch.Degrees()) > 2.2370))
|
||||
{
|
||||
loc.horz = input.horz = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -808,8 +773,6 @@ void GameInterface::GetInput(const double scaleAdjust, InputPacket* packet)
|
|||
processMovement(&hidInput, &loc, &input, scaleAdjust, p->drink_amt);
|
||||
}
|
||||
|
||||
FinalizeInput(p, input);
|
||||
|
||||
if (!SyncInput() && p->GetActor()->spr.extra > 0)
|
||||
{
|
||||
p->Angles.CameraAngles.Yaw += p->adjustavel(input.avel);
|
||||
|
|
|
@ -545,6 +545,9 @@ void playerisdead(int snum, int psectlotag, double floorz, double ceilingz)
|
|||
auto p = &ps[snum];
|
||||
auto actor = p->GetActor();
|
||||
|
||||
// lock input when dead.
|
||||
setForcedSyncInput();
|
||||
|
||||
if (p->dead_flag == 0)
|
||||
{
|
||||
if (actor->spr.pal != 1)
|
||||
|
@ -958,6 +961,8 @@ bool movementBlocked(player_struct *p)
|
|||
p->hard_landing ||
|
||||
p->access_incs > 0 ||
|
||||
p->knee_incs > 0 ||
|
||||
p->GetActor()->spr.extra <= 0 ||
|
||||
(p->dead_flag && !ud.god) ||
|
||||
(blockingweapon() && p->kickback_pic > 1 && p->kickback_pic < weapondelay()));
|
||||
}
|
||||
|
||||
|
|
|
@ -2713,6 +2713,7 @@ void processinput_d(int snum)
|
|||
|
||||
if (p->newOwner != nullptr)
|
||||
{
|
||||
setForcedSyncInput();
|
||||
p->vel.X = p->vel.Y = 0;
|
||||
pact->vel.X = 0;
|
||||
|
||||
|
@ -2730,7 +2731,10 @@ void processinput_d(int snum)
|
|||
auto oldpos = p->GetActor()->opos;
|
||||
|
||||
if (p->on_crane != nullptr)
|
||||
{
|
||||
setForcedSyncInput();
|
||||
goto HORIZONLY;
|
||||
}
|
||||
|
||||
p->playerweaponsway(pact->vel.X);
|
||||
|
||||
|
@ -2765,6 +2769,7 @@ void processinput_d(int snum)
|
|||
doubvel = 0;
|
||||
p->vel.X = 0;
|
||||
p->vel.Y = 0;
|
||||
setForcedSyncInput();
|
||||
}
|
||||
else if (SyncInput())
|
||||
{
|
||||
|
@ -2985,7 +2990,12 @@ HORIZONLY:
|
|||
playerAimDown(snum, actions);
|
||||
}
|
||||
|
||||
if (SyncInput())
|
||||
if (p->centeringView())
|
||||
{
|
||||
p->sync.horz = 0;
|
||||
setForcedSyncInput();
|
||||
}
|
||||
else if (SyncInput())
|
||||
{
|
||||
p->GetActor()->spr.Angles.Pitch += GetPlayerHorizon(snum);
|
||||
}
|
||||
|
|
|
@ -3382,6 +3382,7 @@ void processinput_r(int snum)
|
|||
|
||||
if (p->newOwner != nullptr)
|
||||
{
|
||||
setForcedSyncInput();
|
||||
p->vel.X = p->vel.Y = 0;
|
||||
pact->vel.X = 0;
|
||||
|
||||
|
@ -3399,7 +3400,10 @@ void processinput_r(int snum)
|
|||
auto oldpos = p->GetActor()->opos;
|
||||
|
||||
if (p->on_crane != nullptr)
|
||||
{
|
||||
setForcedSyncInput();
|
||||
goto HORIZONLY;
|
||||
}
|
||||
|
||||
p->playerweaponsway(pact->vel.X);
|
||||
|
||||
|
@ -3448,6 +3452,7 @@ void processinput_r(int snum)
|
|||
doubvel = 0;
|
||||
p->vel.X = 0;
|
||||
p->vel.Y = 0;
|
||||
setForcedSyncInput();
|
||||
}
|
||||
else if (SyncInput())
|
||||
{
|
||||
|
@ -3796,7 +3801,12 @@ HORIZONLY:
|
|||
p->GetActor()->spr.Angles.Pitch += maphoriz(d);
|
||||
}
|
||||
|
||||
if (SyncInput())
|
||||
if (p->centeringView())
|
||||
{
|
||||
p->sync.horz = 0;
|
||||
setForcedSyncInput();
|
||||
}
|
||||
else if (SyncInput())
|
||||
{
|
||||
p->GetActor()->spr.Angles.Pitch += GetPlayerHorizon(snum);
|
||||
}
|
||||
|
|
|
@ -345,6 +345,11 @@ struct player_struct
|
|||
{
|
||||
bobpos = GetActor()->spr.pos.XY();
|
||||
}
|
||||
|
||||
bool centeringView()
|
||||
{
|
||||
return (sync.actions & SB_CENTERVIEW) && abs(GetActor()->spr.Angles.Pitch.Degrees()) > 2.2370;
|
||||
}
|
||||
};
|
||||
|
||||
struct Cycler
|
||||
|
|
|
@ -151,6 +151,7 @@ class DukeCrane : DukeActor
|
|||
plr.on_crane = self;
|
||||
plr.actor.PlayActorSound("CRANEGRAB");
|
||||
plr.settargetangle(self.angle + 180);
|
||||
Raze.forceSyncInput();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -47,6 +47,7 @@ class DukeViewscreen : DukeActor
|
|||
camsprite = self;
|
||||
|
||||
user.newOwner = acti;
|
||||
Raze.forceSyncInput();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,6 +171,7 @@ struct Raze
|
|||
static double bobval(double angle) { return sin(angle * (360. / 2048)); }
|
||||
native static TextureID PickTexture(TextureID texid);
|
||||
native static int GetBuildTime();
|
||||
native static void forceSyncInput();
|
||||
native static Font PickBigFont(String cmptext = "");
|
||||
native static Font PickSmallFont(String cmptext = "");
|
||||
native static int SoundEnabled();
|
||||
|
|
Loading…
Reference in a new issue