diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 9b370ed00..c034ff152 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -152,6 +152,8 @@ extern int hud_size_max; int paused; bool pausedWithKey; +bool gamesetinput = false; + CUSTOM_CVAR(Int, cl_gender, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { if (self < 0 || self > 3) self = 0; diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 1dee1e6e1..1dc5cecff 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -226,3 +226,20 @@ extern int chatmodeon; extern bool sendPause; extern int lastTic; + + +//--------------------------------------------------------------------------- +// +// Inline functions to help with edge cases where synchronised input is needed. +// +//--------------------------------------------------------------------------- + +extern bool gamesetinput; +inline void setForcedSyncInput() +{ + if (!cl_syncinput) gamesetinput = cl_syncinput = true; +} +inline void resetForcedSyncInput() +{ + if (gamesetinput) gamesetinput = cl_syncinput = false; +} diff --git a/source/exhumed/src/osdcmds.cpp b/source/exhumed/src/osdcmds.cpp index 4ee24d7f6..ac0bca1a5 100644 --- a/source/exhumed/src/osdcmds.cpp +++ b/source/exhumed/src/osdcmds.cpp @@ -34,8 +34,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -static bool gamesetinput = false; - void GameInterface::WarpToCoords(int x, int y, int z, int ang, int horz) { Player *nPlayer = &PlayerList[nLocalPlayer]; @@ -107,15 +105,15 @@ void GameInterface::ToggleThirdPerson() { bCamera = !bCamera; - if (bCamera && !cl_syncinput) + if (bCamera) { - gamesetinput = cl_syncinput = true; + setForcedSyncInput(); GrabPalette(); } } - if (gamesetinput && !bCamera) + if (!bCamera) { - gamesetinput = cl_syncinput = false; + resetForcedSyncInput(); } } diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 13edf285d..04c2514c9 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -133,9 +133,6 @@ PLAYER Player[MAX_SW_PLAYERS_REG + 1]; short NormalVisibility; -// bool for determining whether game has set cl_syncinput or not. -static bool gamesetinput = false; - int InitBloodSpray(int16_t SpriteNum, bool dogib, short velocity); SPRITEp FindNearSprite(SPRITEp sp, short stat); @@ -2815,10 +2812,7 @@ DoPlayerMoveVehicle(PLAYERp pp) } // force synchronised input here for now. - if (!cl_syncinput) - { - gamesetinput = cl_syncinput = true; - } + setForcedSyncInput(); if (PLAYER_MOVING(pp) == 0) RESET(pp->Flags, PF_PLAYER_MOVED); @@ -7236,10 +7230,7 @@ domovethings(void) pp->angle.resetadjustment(); // disable synchronised input if set by game. - if (gamesetinput) - { - gamesetinput = cl_syncinput = false; - } + resetForcedSyncInput(); if (pp->DoPlayerAction) pp->DoPlayerAction(pp);