From ca65c4c9dad54c6bf6153790d0ef47b6b7cb1192 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 18 Jul 2021 19:25:41 +1000 Subject: [PATCH] - Allow ticker to lock input to player's angle and horizon without having to force use of synchronised input. --- source/core/gameinput.cpp | 10 +++++++--- source/core/gameinput.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 236e50082..ab48ef726 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -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(); } } diff --git a/source/core/gameinput.h b/source/core/gameinput.h index 4939d826b..d84f10305 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -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) {