- Allow ticker to lock input to player's angle and horizon without having to force use of synchronised input.

This commit is contained in:
Mitchell Richters 2021-07-18 19:25:41 +10:00
parent 58ed7f8745
commit ca65c4c9da
2 changed files with 43 additions and 3 deletions

View File

@ -246,8 +246,8 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn
void PlayerHorizon::applyinput(float const horz, ESyncBits* actions, double const scaleAdjust)
{
// Process only if no targeted horizon set.
if (!targetset())
// Process only if movewment isn't locked.
if (!movementlocked())
{
// Store current horizon as true pitch.
double pitch = horiz.aspitch();
@ -342,7 +342,7 @@ void PlayerAngle::applyinput(float const avel, ESyncBits* actions, double const
rotscrnang += buildfang(scaleAdjust * -(720. / GameTicRate));
}
if (!targetset())
if (!movementlocked())
{
if (*actions & SB_TURNAROUND)
{
@ -450,6 +450,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngle& w, Pl
("lookang", w.look_ang)
("rotscrnang", w.rotscrnang)
("spin", w.spin)
("inputdisabled", w.inputdisabled)
.EndObject();
if (arc.isReading())
@ -457,6 +458,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngle& w, Pl
w.oang = w.ang;
w.olook_ang = w.look_ang;
w.orotscrnang = w.rotscrnang;
w.inputdisabled = w.inputdisabled;
w.resetadjustment();
}
}
@ -469,12 +471,14 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w,
{
arc("horiz", w.horiz)
("horizoff", w.horizoff)
("inputdisabled", w.inputdisabled)
.EndObject();
if (arc.isReading())
{
w.ohoriz = w.horiz;
w.ohorizoff = w.horizoff;
w.inputdisabled = w.inputdisabled;
w.resetadjustment();
}
}

View File

@ -13,6 +13,8 @@ struct PlayerHorizon
{
fixedhoriz horiz, ohoriz, horizoff, ohorizoff;
friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w, PlayerHorizon* def);
void backup()
{
ohoriz = horiz;
@ -50,11 +52,26 @@ struct PlayerHorizon
__settarget(value, backup);
}
void lockinput()
{
inputdisabled = true;
}
void unlockinput()
{
inputdisabled = false;
}
bool targetset()
{
return target.asq16();
}
bool movementlocked()
{
return target.asq16() || inputdisabled;
}
void processhelpers(double const scaleAdjust)
{
if (targetset())
@ -103,6 +120,7 @@ struct PlayerHorizon
private:
fixedhoriz target;
double adjustment;
bool inputdisabled;
void __addadjustment(fixedhoriz value)
{
@ -138,6 +156,8 @@ struct PlayerAngle
binangle ang, oang, look_ang, olook_ang, rotscrnang, orotscrnang;
double spin;
friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngle& w, PlayerAngle* def);
void backup()
{
oang = ang;
@ -177,11 +197,26 @@ struct PlayerAngle
__settarget(value, backup);
}
void lockinput()
{
inputdisabled = true;
}
void unlockinput()
{
inputdisabled = false;
}
bool targetset()
{
return target.asbam();
}
bool movementlocked()
{
return target.asq16() || inputdisabled;
}
void processhelpers(double const scaleAdjust)
{
if (targetset())
@ -244,6 +279,7 @@ struct PlayerAngle
private:
binangle target;
double adjustment;
bool inputdisabled;
void __addadjustment(binangle value)
{