From 9c986bef6704ac07112e18dc82b870acf1847e41 Mon Sep 17 00:00:00 2001 From: leviathan Date: Thu, 27 Jun 2024 00:18:42 -0700 Subject: put GameControl behind a feature flag --- indra/llwindow/llgamecontrol.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'indra/llwindow/llgamecontrol.cpp') diff --git a/indra/llwindow/llgamecontrol.cpp b/indra/llwindow/llgamecontrol.cpp index 23849aca66..0e3782a10e 100644 --- a/indra/llwindow/llgamecontrol.cpp +++ b/indra/llwindow/llgamecontrol.cpp @@ -443,6 +443,7 @@ namespace U64 g_lastSend = 0; U64 g_nextResendPeriod = FIRST_RESEND_PERIOD; + bool g_enabled = false; bool g_sendToServer = false; bool g_controlAgent = false; bool g_translateAgentActions = false; @@ -457,6 +458,7 @@ namespace std::function s_loadObject; std::function s_saveObject; + std::string SETTING_ENABLE("EnableGameControl"); std::string SETTING_SENDTOSERVER("GameControlToServer"); std::string SETTING_CONTROLAGENT("GameControlToAgent"); std::string SETTING_TRANSLATEACTIONS("AgentToGameControl"); @@ -1489,6 +1491,21 @@ void onControllerAxis(const SDL_Event& event) g_manager.onAxis(event.caxis.which, event.caxis.axis, event.caxis.value); } +// static +bool LLGameControl::isEnabled() +{ + return g_enabled; +} + +void LLGameControl::setEnabled(bool enable) +{ + if (enable != g_enabled) + { + g_enabled = enable; + s_saveBoolean(SETTING_ENABLE, g_enabled); + } +} + // static bool LLGameControl::isInitialized() { @@ -1593,7 +1610,7 @@ bool LLGameControl::computeFinalStateAndCheckForChanges() // g_lastSend has "expired" // either because g_nextResendPeriod has been zeroed // or the last send really has expired. - return g_sendToServer && (g_lastSend + g_nextResendPeriod < get_now_nsec()); + return g_enabled && g_sendToServer && (g_lastSend + g_nextResendPeriod < get_now_nsec()); } // static @@ -1762,7 +1779,7 @@ LLGameControl::ActionNameType LLGameControl::getActionNameType(const std::string // static bool LLGameControl::willControlAvatar() { - return g_controlAgent && g_agentControlMode == CONTROL_MODE_AVATAR; + return g_enabled && g_controlAgent && g_agentControlMode == CONTROL_MODE_AVATAR; } // static @@ -2040,6 +2057,7 @@ void LLGameControl::initByDefault() void LLGameControl::loadFromSettings() { // In case of absence of the required setting the default value is assigned + g_enabled = s_loadBoolean(SETTING_ENABLE); g_sendToServer = s_loadBoolean(SETTING_SENDTOSERVER); g_controlAgent = s_loadBoolean(SETTING_CONTROLAGENT); g_translateAgentActions = s_loadBoolean(SETTING_TRANSLATEACTIONS); @@ -2068,6 +2086,7 @@ void LLGameControl::loadFromSettings() // static void LLGameControl::saveToSettings() { + s_saveBoolean(SETTING_ENABLE, g_enabled); s_saveBoolean(SETTING_SENDTOSERVER, g_sendToServer); s_saveBoolean(SETTING_CONTROLAGENT, g_controlAgent); s_saveBoolean(SETTING_TRANSLATEACTIONS, g_translateAgentActions); -- cgit v1.2.3