From c820bb2929a37fb222ce0d7368d699e81f5edc00 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sat, 31 Aug 2024 01:33:27 +0200 Subject: Minimal code needed to add RLVa with an on/off toggle --- indra/newview/CMakeLists.txt | 7 ++++ indra/newview/app_settings/settings.xml | 11 ++++++ indra/newview/llappviewer.cpp | 8 ++++ indra/newview/llstartup.cpp | 3 ++ indra/newview/rlvactions.cpp | 15 ++++++++ indra/newview/rlvactions.h | 19 ++++++++++ indra/newview/rlvcommon.cpp | 40 ++++++++++++++++++++ indra/newview/rlvcommon.h | 16 ++++++++ indra/newview/rlvdefines.h | 51 ++++++++++++++++++++++++++ indra/newview/rlvhandler.cpp | 40 ++++++++++++++++++++ indra/newview/rlvhandler.h | 25 +++++++++++++ indra/newview/skins/default/xui/en/strings.xml | 1 + 12 files changed, 236 insertions(+) create mode 100644 indra/newview/rlvactions.cpp create mode 100644 indra/newview/rlvactions.h create mode 100644 indra/newview/rlvcommon.cpp create mode 100644 indra/newview/rlvcommon.h create mode 100644 indra/newview/rlvdefines.h create mode 100644 indra/newview/rlvhandler.cpp create mode 100644 indra/newview/rlvhandler.h (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 7a9f3a46b5..70a9f09e1f 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -726,6 +726,9 @@ set(viewer_SOURCE_FILES llxmlrpctransaction.cpp noise.cpp pipeline.cpp + rlvactions.cpp + rlvcommon.cpp + rlvhandler.cpp ) set(VIEWER_BINARY_NAME "secondlife-bin" CACHE STRING @@ -1386,6 +1389,10 @@ set(viewer_HEADER_FILES llxmlrpctransaction.h noise.h pipeline.h + rlvdefines.h + rlvactions.h + rlvcommon.h + rlvhandler.h roles_constants.h VertexCache.h VorbisFramework.h diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index ec06582d90..48e0878383 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9843,6 +9843,17 @@ Value https://feedback.secondlife.com/ + RestrainedLove + + Comment + Toggles RLVa features (requires restart) + Persist + 1 + Type + Boolean + Value + 1 + RevokePermsOnStopAnimation Comment diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index afa701c5f2..6a2498c57a 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -250,6 +250,10 @@ using namespace LL; #include "llcoproceduremanager.h" #include "llviewereventrecorder.h" +#include "rlvactions.h" +#include "rlvcommon.h" +#include "rlvhandler.h" + // *FIX: These extern globals should be cleaned up. // The globals either represent state/config/resource-storage of either // this app, or another 'component' of the viewer. App globals should be @@ -1710,6 +1714,9 @@ bool LLAppViewer::cleanup() //ditch LLVOAvatarSelf instance gAgentAvatarp = NULL; + // Sanity check to catch cases where someone forgot to do an RlvActions::isRlvEnabled() check + LL_ERRS_IF(!RlvHandler::isEnabled() && RlvHandler::instanceExists()) << "RLV handler instance exists even though RLVa is disabled" << LL_ENDL; + LLNotifications::instance().clear(); // workaround for DEV-35406 crash on shutdown @@ -3333,6 +3340,7 @@ LLSD LLAppViewer::getViewerInfo() const } #endif + info["RLV_VERSION"] = RlvActions::isRlvEnabled() ? RlvStrings::getVersionAbout() : "(disabled)"; info["OPENGL_VERSION"] = ll_safe_string((const char*)(glGetString(GL_VERSION))); // Settings diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index b32b80331a..3b027df460 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -205,6 +205,7 @@ #include "threadpool.h" #include "llperfstats.h" +#include "rlvhandler.h" #if LL_WINDOWS #include "lldxhardware.h" @@ -876,6 +877,8 @@ bool idle_startup() return false; } + RlvHandler::setEnabled(gSavedSettings.get(Rlv::Settings::Main)); + // reset the values that could have come in from a slurl // DEV-42215: Make sure they're not empty -- gUserCredential // might already have been set from gSavedSettings, and it's too bad diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp new file mode 100644 index 0000000000..1988c99ecf --- /dev/null +++ b/indra/newview/rlvactions.cpp @@ -0,0 +1,15 @@ +#include "llviewerprecompiledheaders.h" + +#include "rlvactions.h" +#include "rlvhandler.h" + +// ============================================================================ +// Helper functions +// + +bool RlvActions::isRlvEnabled() +{ + return RlvHandler::isEnabled(); +} + +// ============================================================================ diff --git a/indra/newview/rlvactions.h b/indra/newview/rlvactions.h new file mode 100644 index 0000000000..ac4fc73339 --- /dev/null +++ b/indra/newview/rlvactions.h @@ -0,0 +1,19 @@ +#pragma once + +// ============================================================================ +// RlvActions - developer-friendly non-RLVa code facing class, use in lieu of RlvHandler whenever possible +// + +class RlvActions +{ + // ================ + // Helper functions + // ================ +public: + /* + * Convenience function to check if RLVa is enabled without having to include rlvhandler.h + */ + static bool isRlvEnabled(); +}; + +// ============================================================================ diff --git a/indra/newview/rlvcommon.cpp b/indra/newview/rlvcommon.cpp new file mode 100644 index 0000000000..f641d56a85 --- /dev/null +++ b/indra/newview/rlvcommon.cpp @@ -0,0 +1,40 @@ +#include "llviewerprecompiledheaders.h" +#include "llversioninfo.h" + +#include "rlvdefines.h" +#include "rlvcommon.h" + +using namespace Rlv; + +// ============================================================================ +// RlvStrings +// + +std::string RlvStrings::getVersion(bool wants_legacy) +{ + return llformat("%s viewer v%d.%d.%d (RLVa %d.%d.%d)", + !wants_legacy ? "RestrainedLove" : "RestrainedLife", + SpecVersion::Major, SpecVersion::Minor, SpecVersion::Patch, + ImplVersion::Major, ImplVersion::Minor, ImplVersion::Patch); +} + +std::string RlvStrings::getVersionAbout() +{ + return llformat("RLV v%d.%d.%d / RLVa v%d.%d.%d.%d", + SpecVersion::Major, SpecVersion::Minor, SpecVersion::Patch, + ImplVersion::Major, ImplVersion::Minor, ImplVersion::Patch, LLVersionInfo::instance().getBuild()); +} + +std::string RlvStrings::getVersionNum() +{ + return llformat("%d%02d%02d%02d", + SpecVersion::Major, SpecVersion::Minor, SpecVersion::Patch, SpecVersion::Build); +} + +std::string RlvStrings::getVersionImplNum() +{ + return llformat("%d%02d%02d%02d", + ImplVersion::Major, ImplVersion::Minor, ImplVersion::Patch, ImplVersion::ImplId); +} + +// ============================================================================ diff --git a/indra/newview/rlvcommon.h b/indra/newview/rlvcommon.h new file mode 100644 index 0000000000..288d48e373 --- /dev/null +++ b/indra/newview/rlvcommon.h @@ -0,0 +1,16 @@ +#pragma once + +// ============================================================================ +// RlvStrings +// + +class RlvStrings +{ +public: + static std::string getVersion(bool wants_legacy); + static std::string getVersionAbout(); + static std::string getVersionImplNum(); + static std::string getVersionNum(); +}; + +// ============================================================================ diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h new file mode 100644 index 0000000000..dc1e58f47c --- /dev/null +++ b/indra/newview/rlvdefines.h @@ -0,0 +1,51 @@ +#pragma once + +// ============================================================================ +// Defines +// + +namespace Rlv +{ + // Version of the specification we report + struct SpecVersion { + static constexpr S32 Major = 4; + static constexpr S32 Minor = 0; + static constexpr S32 Patch = 0; + static constexpr S32 Build = 0; + }; + + // RLVa implementation version + struct ImplVersion { + static constexpr S32 Major = 3; + static constexpr S32 Minor = 0; + static constexpr S32 Patch = 0; + static constexpr S32 ImplId = 2; /* Official viewer */ + }; +} + +// Defining these makes it easier if we ever need to change our tag +#define RLV_WARNS LL_WARNS("RLV") +#define RLV_INFOS LL_INFOS("RLV") +#define RLV_DEBUGS LL_DEBUGS("RLV") +#define RLV_ENDL LL_ENDL + +// ============================================================================ +// Settings +// + +namespace Rlv +{ + namespace Settings + { + constexpr char Main[] = "RestrainedLove"; + constexpr char Debug[] = "RestrainedLoveDebug"; + + constexpr char DebugHideUnsetDup[] = "RLVaDebugHideUnsetDuplicate"; + constexpr char EnableIMQuery[] = "RLVaEnableIMQuery"; + constexpr char EnableTempAttach[] = "RLVaEnableTemporaryAttachments"; + constexpr char TopLevelMenu[] = "RLVaTopLevelMenu"; + }; + +}; + +// ============================================================================ diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp new file mode 100644 index 0000000000..3315ed1999 --- /dev/null +++ b/indra/newview/rlvhandler.cpp @@ -0,0 +1,40 @@ +#include "llviewerprecompiledheaders.h" +#include "llappviewer.h" +#include "llstartup.h" + +#include "rlvdefines.h" +#include "rlvcommon.h" +#include "rlvhandler.h" + +using namespace Rlv; + +// ============================================================================ +// Static variable initialization +// + +bool RlvHandler::mIsEnabled = false; + +// ============================================================================ +// Initialization helper functions +// + +bool RlvHandler::canEnable() +{ + return LLStartUp::getStartupState() <= STATE_LOGIN_CLEANUP; +} + +bool RlvHandler::setEnabled(bool enable) +{ + if (mIsEnabled == enable) + return enable; + + if (enable && canEnable()) + { + RLV_INFOS << "Enabling Restrained Love API support - " << RlvStrings::getVersionAbout() << RLV_ENDL; + mIsEnabled = true; + } + + return mIsEnabled; +} + +// ============================================================================ diff --git a/indra/newview/rlvhandler.h b/indra/newview/rlvhandler.h new file mode 100644 index 0000000000..0d4cbe98fb --- /dev/null +++ b/indra/newview/rlvhandler.h @@ -0,0 +1,25 @@ +#pragma once + +#include "llsingleton.h" + +#include "rlvdefines.h" + +// ============================================================================ +// RlvHandler class +// + +class RlvHandler : public LLSingleton +{ + LLSINGLETON_EMPTY_CTOR(RlvHandler); + +public: + // Initialization (deliberately static so they can safely be called in tight loops) + static bool canEnable(); + static bool isEnabled() { return mIsEnabled; } + static bool setEnabled(bool enable); + +private: + static bool mIsEnabled; +}; + +// ============================================================================ diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 2d04b3e0fe..a270bc473d 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -60,6 +60,7 @@ Disk cache: [DISK_CACHE_INFO] HiDPI display mode: [HIDPI] +RestrainedLove API: [RLV_VERSION] J2C Decoder Version: [J2C_VERSION] Audio Driver Version: [AUDIO_DRIVER_VERSION] [LIBCEF_VERSION] -- cgit v1.2.3 From b82e9b73d35e41ed51063905dd31ccced9e97266 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 1 Sep 2024 01:21:00 +0200 Subject: Add owner say chat hook --- indra/newview/CMakeLists.txt | 2 + indra/newview/app_settings/settings.xml | 44 ++++++++ indra/newview/llviewermessage.cpp | 28 ++++- indra/newview/rlvdefines.h | 62 +++++++++++ indra/newview/rlvhandler.cpp | 44 +++++++- indra/newview/rlvhandler.h | 11 ++ indra/newview/rlvhelper.cpp | 136 +++++++++++++++++++++++++ indra/newview/rlvhelper.h | 24 +++++ indra/newview/skins/default/xui/en/strings.xml | 22 ++++ 9 files changed, 368 insertions(+), 5 deletions(-) create mode 100644 indra/newview/rlvhelper.cpp create mode 100644 indra/newview/rlvhelper.h (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 70a9f09e1f..a7bbadfd86 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -728,6 +728,7 @@ set(viewer_SOURCE_FILES pipeline.cpp rlvactions.cpp rlvcommon.cpp + rlvhelper.cpp rlvhandler.cpp ) @@ -1392,6 +1393,7 @@ set(viewer_HEADER_FILES rlvdefines.h rlvactions.h rlvcommon.h + rlvhelper.h rlvhandler.h roles_constants.h VertexCache.h diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 48e0878383..be88ad6e2f 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9852,6 +9852,50 @@ Type Boolean Value + 0 + + RestrainedLoveDebug + + Comment + Toggles RLVa debug mode (displays the commands when in debug mode) + Persist + 1 + Type + Boolean + Value + 0 + + RLVaBlockedExperiences + + Comment + List of experiences blocked from interacting with RLVa + Persist + 1 + Type + String + Value + bfe25fb4-222c-11e5-85a2-fa4c4ccaa202 + + RLVaDebugHideUnsetDuplicate + + Comment + Suppresses reporting "unset" or "duplicate" command restrictions when RestrainedLoveDebug is TRUE + Persist + 1 + Type + Boolean + Value + 0 + + RLVaEnableTemporaryAttachments + + Comment + Allows temporary attachments (regardless of origin) to issue RLV commands + Persist + 1 + Type + Boolean + Value 1 RevokePermsOnStopAnimation diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 872a9a1581..4ed16c19a6 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -118,6 +118,8 @@ #include "llpanelplaceprofile.h" #include "llviewerregion.h" #include "llfloaterregionrestarting.h" +#include "rlvactions.h" +#include "rlvhandler.h" #include "llnotificationmanager.h" // #include "llexperiencecache.h" @@ -2382,15 +2384,16 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) } bool is_audible = (CHAT_AUDIBLE_FULLY == chat.mAudible); + bool show_script_chat_particles = chat.mSourceType == CHAT_SOURCE_OBJECT + && chat.mChatType != CHAT_TYPE_DEBUG_MSG + && gSavedSettings.getBOOL("EffectScriptChatParticles"); chatter = gObjectList.findObject(from_id); if (chatter) { chat.mPosAgent = chatter->getPositionAgent(); // Make swirly things only for talking objects. (not script debug messages, though) - if (chat.mSourceType == CHAT_SOURCE_OBJECT - && chat.mChatType != CHAT_TYPE_DEBUG_MSG - && gSavedSettings.getBOOL("EffectScriptChatParticles") ) + if (show_script_chat_particles && (!RlvActions::isRlvEnabled() || CHAT_TYPE_OWNER != chat.mChatType) ) { LLPointer psc = new LLViewerPartSourceChat(chatter->getPositionAgent()); psc->setSourceObject(chatter); @@ -2470,8 +2473,25 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) case CHAT_TYPE_WHISPER: chat.mText = LLTrans::getString("whisper") + " "; break; - case CHAT_TYPE_DEBUG_MSG: case CHAT_TYPE_OWNER: + if (RlvActions::isRlvEnabled()) + { + if (RlvHandler::instance().handleSimulatorChat(mesg, chat, chatter)) + { + break; + } + else if (show_script_chat_particles) + { + LLPointer psc = new LLViewerPartSourceChat(chatter->getPositionAgent()); + psc->setSourceObject(chatter); + psc->setColor(color); + //We set the particles to be owned by the object's owner, + //just in case they should be muted by the mute list + psc->setOwnerUUID(owner_id); + LLViewerPartSim::getInstance()->addPartSource(psc); + } + } + case CHAT_TYPE_DEBUG_MSG: case CHAT_TYPE_NORMAL: case CHAT_TYPE_DIRECT: break; diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h index dc1e58f47c..6ba2afbc69 100644 --- a/indra/newview/rlvdefines.h +++ b/indra/newview/rlvdefines.h @@ -29,6 +29,68 @@ namespace Rlv #define RLV_DEBUGS LL_DEBUGS("RLV") #define RLV_ENDL LL_ENDL +#define RLV_RELEASE +#if LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG + // Make sure we halt execution on errors + #define RLV_ERRS LL_ERRS("RLV") + // Keep our asserts separate from LL's + #define RLV_ASSERT(f) if (!(f)) { RLV_ERRS << "ASSERT (" << #f << ")" << RLV_ENDL; } + #define RLV_ASSERT_DBG(f) RLV_ASSERT(f) +#else + // We don't want to check assertions in release builds + #ifndef RLV_RELEASE + #define RLV_ASSERT(f) RLV_VERIFY(f) + #define RLV_ASSERT_DBG(f) + #else + #define RLV_ASSERT(f) + #define RLV_ASSERT_DBG(f) + #endif // RLV_RELEASE +#endif // LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG + +namespace Rlv +{ + namespace Constants + { + constexpr char CmdPrefix = '@'; + } +} + +// ============================================================================ +// Enumeration declarations +// + +namespace Rlv +{ + enum class ECmdRet{ + Unknown = 0x0000, // Unknown error (should only be used internally) + Retained, // Command was retained + Success = 0x0100, // Command executed successfully + SuccessUnset, // Command executed successfully (RLV_TYPE_REMOVE for an unrestricted behaviour) + SuccessDuplicate, // Command executed successfully (RLV_TYPE_ADD for an already restricted behaviour) + SuccessDeprecated, // Command executed successfully but has been marked as deprecated + SuccessDelayed, // Command parsed valid but will execute at a later time + Failed = 0x0200, // Command failed (general failure) + FailedSyntax, // Command failed (syntax error) + FailedOption, // Command failed (invalid option) + FailedParam, // Command failed (invalid param) + FailedLock, // Command failed (command is locked by another object) + FailedDisabled, // Command failed (command disabled by user) + FailedUnknown, // Command failed (unknown command) + FailedNoSharedRoot, // Command failed (missing #RLV) + FailedDeprecated, // Command failed (deprecated and no longer supported) + FailedNoBehaviour, // Command failed (force modifier on an object with no active restrictions) + FailedUnheldBehaviour, // Command failed (local modifier on an object that doesn't hold the base behaviour) + FailedBlocked, // Command failed (object is blocked) + FailedThrottled, // Command failed (throttled) + FailedNoProcessor // Command doesn't have a template processor define (legacy code) + }; + + constexpr bool isReturnCodeSuccess(ECmdRet eRet) + { + return (static_cast(eRet) & static_cast(ECmdRet::Success)) == static_cast(ECmdRet::Success); + } +} + // ============================================================================ // Settings // diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index 3315ed1999..bf78a0a38a 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -1,10 +1,12 @@ #include "llviewerprecompiledheaders.h" #include "llappviewer.h" #include "llstartup.h" +#include "llviewercontrol.h" +#include "llviewerobject.h" -#include "rlvdefines.h" #include "rlvcommon.h" #include "rlvhandler.h" +#include "rlvhelper.h" using namespace Rlv; @@ -14,6 +16,46 @@ using namespace Rlv; bool RlvHandler::mIsEnabled = false; +// ============================================================================ +// Command processing functions +// + +bool RlvHandler::handleSimulatorChat(std::string& message, const LLChat& chat, const LLViewerObject* chatObj) +{ + static LLCachedControl enable_temp_attach(gSavedSettings, Settings::EnableTempAttach); + static LLCachedControl show_debug_output(gSavedSettings, Settings::Debug); + static LLCachedControl hide_unset_dupes(gSavedSettings, Settings::DebugHideUnsetDup); + + if ( message.length() <= 3 || Rlv::Constants::CmdPrefix != message[0] || CHAT_TYPE_OWNER != chat.mChatType || + (chatObj && chatObj->isTempAttachment() && !enable_temp_attach()) ) + { + return false; + } + + message.erase(0, 1); + LLStringUtil::toLower(message); + CommandDbgOut cmdDbgOut(message); + + boost_tokenizer tokens(message, boost::char_separator(",", "", boost::drop_empty_tokens)); + for (const std::string& strCmd : tokens) + { + ECmdRet eRet = (ECmdRet)processCommand(chat.mFromID, strCmd, true); + if ( show_debug_output() && + (!hide_unset_dupes() || (ECmdRet::SuccessUnset != eRet && ECmdRet::SuccessDuplicate != eRet)) ) + { + cmdDbgOut.add(strCmd, eRet); + } + } + + message = cmdDbgOut.get(); + return true; +} + +ECmdRet RlvHandler::processCommand(const LLUUID& idObj, const std::string& strCmd, bool fromObj) +{ + return ECmdRet::FailedNoProcessor; +} + // ============================================================================ // Initialization helper functions // diff --git a/indra/newview/rlvhandler.h b/indra/newview/rlvhandler.h index 0d4cbe98fb..8cf054e98e 100644 --- a/indra/newview/rlvhandler.h +++ b/indra/newview/rlvhandler.h @@ -1,9 +1,12 @@ #pragma once +#include "llchat.h" #include "llsingleton.h" #include "rlvdefines.h" +class LLViewerObject; + // ============================================================================ // RlvHandler class // @@ -13,6 +16,14 @@ class RlvHandler : public LLSingleton LLSINGLETON_EMPTY_CTOR(RlvHandler); public: + /* + * Helper functions + */ +public: + // Command processing helper functions + bool handleSimulatorChat(std::string& message, const LLChat& chat, const LLViewerObject* chatObj); + Rlv::ECmdRet processCommand(const LLUUID& idObj, const std::string& stCmd, bool fromObj); + // Initialization (deliberately static so they can safely be called in tight loops) static bool canEnable(); static bool isEnabled() { return mIsEnabled; } diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp new file mode 100644 index 0000000000..ade2b83dd7 --- /dev/null +++ b/indra/newview/rlvhelper.cpp @@ -0,0 +1,136 @@ +#include "llviewerprecompiledheaders.h" + +#include "lltrans.h" + +#include "rlvhelper.h" + +using namespace Rlv; + +// ========================================================================= +// Various helper classes/timers/functors +// + +namespace Rlv +{ + // =========================================================================== + // CommandDbgOut + // + + void CommandDbgOut::add(std::string strCmd, ECmdRet eRet) + { + ECmdRet resultBucket; + + // Successful and retained commands are added as-is + if (isReturnCodeSuccess(eRet)) + resultBucket = ECmdRet::Success; + else if (ECmdRet::Retained == eRet) + resultBucket = ECmdRet::Retained; + else + { + // Failed commands get the failure reason appended to help troubleshooting + resultBucket = ECmdRet::Failed; + strCmd.append(llformat(" (%s)", getReturnCodeString(eRet).c_str())); + } + + std::string& strResult = mCommandResults[resultBucket]; + if (!strResult.empty()) + strResult.append(", "); + strResult.append(strCmd); + } + + std::string CommandDbgOut::get() const { + std::ostringstream result; + + if (1 == mCommandResults.size()) + { + auto it = mCommandResults.begin(); + result << " " << getDebugVerbFromReturnCode(it->first) << ": @" << it->second;; + } + else if (mCommandResults.size() > 1) + { + auto appendResult = [&](ECmdRet eRet, const std::string& name) + { + auto it = mCommandResults.find(eRet); + if (it == mCommandResults.end()) return; + result << "\n - " << LLTrans::getString(name) << ": @" << it->second; + }; + result << ": @" << mOrigCmd; + appendResult(ECmdRet::Success, "RlvDebugExecuted"); + appendResult(ECmdRet::Failed, "RlvDebugFailed"); + appendResult(ECmdRet::Retained, "RlvDebugRetained"); + } + + return result.str(); + } + + std::string CommandDbgOut::getDebugVerbFromReturnCode(ECmdRet eRet) + { + switch (eRet) + { + case ECmdRet::Success: + return LLTrans::getString("RlvDebugExecuted"); + case ECmdRet::Failed: + return LLTrans::getString("RlvDebugFailed"); + case ECmdRet::Retained: + return LLTrans::getString("RlvDebugRetained"); + default: + RLV_ASSERT(false); + return LLStringUtil::null; + } + } + + std::string CommandDbgOut::getReturnCodeString(ECmdRet eRet) + { + switch (eRet) + { + case ECmdRet::SuccessUnset: + return LLTrans::getString("RlvReturnCodeUnset"); + case ECmdRet::SuccessDuplicate: + return LLTrans::getString("RlvReturnCodeDuplicate"); + case ECmdRet::SuccessDelayed: + return LLTrans::getString("RlvReturnCodeDelayed"); + case ECmdRet::SuccessDeprecated: + return LLTrans::getString("RlvReturnCodeDeprecated"); + case ECmdRet::FailedSyntax: + return LLTrans::getString("RlvReturnCodeSyntax"); + case ECmdRet::FailedOption: + return LLTrans::getString("RlvReturnCodeOption"); + case ECmdRet::FailedParam: + return LLTrans::getString("RlvReturnCodeParam"); + case ECmdRet::FailedLock: + return LLTrans::getString("RlvReturnCodeLock"); + case ECmdRet::FailedDisabled: + return LLTrans::getString("RlvReturnCodeDisabled"); + case ECmdRet::FailedUnknown: + return LLTrans::getString("RlvReturnCodeUnknown"); + case ECmdRet::FailedNoSharedRoot: + return LLTrans::getString("RlvReturnCodeNoSharedRoot"); + case ECmdRet::FailedDeprecated: + return LLTrans::getString("RlvReturnCodeDeprecatedAndDisabled"); + case ECmdRet::FailedNoBehaviour: + return LLTrans::getString("RlvReturnCodeNoBehaviour"); + case ECmdRet::FailedUnheldBehaviour: + return LLTrans::getString("RlvReturnCodeUnheldBehaviour"); + case ECmdRet::FailedBlocked: + return LLTrans::getString("RlvReturnCodeBlocked"); + case ECmdRet::FailedThrottled: + return LLTrans::getString("RlvReturnCodeThrottled"); + case ECmdRet::FailedNoProcessor: + return LLTrans::getString("RlvReturnCodeNoProcessor"); + // The following are identified by the chat verb + case ECmdRet::Retained: + case ECmdRet::Success: + case ECmdRet::Failed: + return LLStringUtil::null; + // The following shouldn't occur + case ECmdRet::Unknown: + default: + RLV_ASSERT(false); + return LLStringUtil::null; + } + } + + // =========================================================================== +} + +// ============================================================================ diff --git a/indra/newview/rlvhelper.h b/indra/newview/rlvhelper.h new file mode 100644 index 0000000000..89bdc709d5 --- /dev/null +++ b/indra/newview/rlvhelper.h @@ -0,0 +1,24 @@ +#pragma once + +#include "rlvdefines.h" + +// ============================================================================ +// Various helper classes/timers/functors +// + +namespace Rlv +{ + struct CommandDbgOut + { + CommandDbgOut(const std::string& orig_cmd) : mOrigCmd(orig_cmd) {} + void add(std::string strCmd, ECmdRet eRet); + std::string get() const; + static std::string getDebugVerbFromReturnCode(ECmdRet eRet); + static std::string getReturnCodeString(ECmdRet eRet); + private: + std::string mOrigCmd; + std::map mCommandResults; + }; +} + +// ============================================================================ diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index a270bc473d..39a663298a 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -4376,4 +4376,26 @@ and report the problem. [https://community.secondlife.com/knowledgebase/english/error-messages-r520/#Section__3 Knowledge Base] + + executed + failed + retained + unset + duplicate + delayed + deprecated + thingy error + invalid option + invalid param + locked command + disabled command + unknown command + missing #RLV + deprecated and disabled + no active behaviours + base behaviour not held + blocked object + throttled + no command processor found + -- cgit v1.2.3 From 7402fe6412e98e4b295ee3e04874f379c752f7a0 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 2 Sep 2024 01:39:17 +0200 Subject: Add basic scaffolding to support reply commands and handle @versionXXX as an illustration --- indra/newview/app_settings/settings.xml | 11 ++ indra/newview/llappviewer.cpp | 2 +- indra/newview/rlvcommon.cpp | 37 ++++- indra/newview/rlvcommon.h | 49 ++++-- indra/newview/rlvdefines.h | 142 +++++++++++------ indra/newview/rlvhandler.cpp | 93 ++++++++++- indra/newview/rlvhandler.h | 8 +- indra/newview/rlvhelper.cpp | 231 ++++++++++++++++++++++++++++ indra/newview/rlvhelper.h | 265 ++++++++++++++++++++++++++++++-- 9 files changed, 757 insertions(+), 81 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index be88ad6e2f..ab577200f5 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9897,6 +9897,17 @@ Boolean Value 1 + + RLVaExperimentalCommands + + Comment + Enables the experimental command set + Persist + 1 + Type + Boolean + Value + 1 RevokePermsOnStopAnimation diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 6a2498c57a..6a2f24a103 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -3340,7 +3340,7 @@ LLSD LLAppViewer::getViewerInfo() const } #endif - info["RLV_VERSION"] = RlvActions::isRlvEnabled() ? RlvStrings::getVersionAbout() : "(disabled)"; + info["RLV_VERSION"] = RlvActions::isRlvEnabled() ? Rlv::Strings::getVersionAbout() : "(disabled)"; info["OPENGL_VERSION"] = ll_safe_string((const char*)(glGetString(GL_VERSION))); // Settings diff --git a/indra/newview/rlvcommon.cpp b/indra/newview/rlvcommon.cpp index f641d56a85..898df3af42 100644 --- a/indra/newview/rlvcommon.cpp +++ b/indra/newview/rlvcommon.cpp @@ -1,5 +1,10 @@ #include "llviewerprecompiledheaders.h" +#include "llagent.h" +#include "llchat.h" +#include "lldbstrings.h" #include "llversioninfo.h" +#include "llviewerstats.h" +#include "message.h" #include "rlvdefines.h" #include "rlvcommon.h" @@ -10,7 +15,7 @@ using namespace Rlv; // RlvStrings // -std::string RlvStrings::getVersion(bool wants_legacy) +std::string Strings::getVersion(bool wants_legacy) { return llformat("%s viewer v%d.%d.%d (RLVa %d.%d.%d)", !wants_legacy ? "RestrainedLove" : "RestrainedLife", @@ -18,23 +23,47 @@ std::string RlvStrings::getVersion(bool wants_legacy) ImplVersion::Major, ImplVersion::Minor, ImplVersion::Patch); } -std::string RlvStrings::getVersionAbout() +std::string Strings::getVersionAbout() { return llformat("RLV v%d.%d.%d / RLVa v%d.%d.%d.%d", SpecVersion::Major, SpecVersion::Minor, SpecVersion::Patch, ImplVersion::Major, ImplVersion::Minor, ImplVersion::Patch, LLVersionInfo::instance().getBuild()); } -std::string RlvStrings::getVersionNum() +std::string Strings::getVersionNum() { return llformat("%d%02d%02d%02d", SpecVersion::Major, SpecVersion::Minor, SpecVersion::Patch, SpecVersion::Build); } -std::string RlvStrings::getVersionImplNum() +std::string Strings::getVersionImplNum() { return llformat("%d%02d%02d%02d", ImplVersion::Major, ImplVersion::Minor, ImplVersion::Patch, ImplVersion::ImplId); } // ============================================================================ +// RlvUtil +// + +bool Util::sendChatReply(S32 nChannel, const std::string& strUTF8Text) +{ + if (!isValidReplyChannel(nChannel)) + return false; + + // Copy/paste from send_chat_from_viewer() + gMessageSystem->newMessageFast(_PREHASH_ChatFromViewer); + gMessageSystem->nextBlockFast(_PREHASH_AgentData); + gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + gMessageSystem->nextBlockFast(_PREHASH_ChatData); + gMessageSystem->addStringFast(_PREHASH_Message, utf8str_truncate(strUTF8Text, MAX_MSG_STR_LEN)); + gMessageSystem->addU8Fast(_PREHASH_Type, CHAT_TYPE_SHOUT); + gMessageSystem->addS32("Channel", nChannel); + gAgent.sendReliableMessage(); + add(LLStatViewer::CHAT_COUNT, 1); + + return true; +} + +// ============================================================================ diff --git a/indra/newview/rlvcommon.h b/indra/newview/rlvcommon.h index 288d48e373..79ac6e1704 100644 --- a/indra/newview/rlvcommon.h +++ b/indra/newview/rlvcommon.h @@ -1,16 +1,41 @@ #pragma once -// ============================================================================ -// RlvStrings -// - -class RlvStrings +namespace Rlv { -public: - static std::string getVersion(bool wants_legacy); - static std::string getVersionAbout(); - static std::string getVersionImplNum(); - static std::string getVersionNum(); -}; + // ============================================================================ + // RlvStrings + // + + class Strings + { + public: + static std::string getVersion(bool wants_legacy); + static std::string getVersionAbout(); + static std::string getVersionImplNum(); + static std::string getVersionNum(); + }; + + // ============================================================================ + // RlvUtil + // + + namespace Util + { + bool isValidReplyChannel(S32 nChannel, bool isLoopback = false); + bool sendChatReply(S32 nChannel, const std::string& strUTF8Text); + bool sendChatReply(const std::string& strChannel, const std::string& strUTF8Text); + }; + + inline bool Util::isValidReplyChannel(S32 nChannel, bool isLoopback) + { + return (nChannel > (!isLoopback ? 0 : -1)) && (CHAT_CHANNEL_DEBUG != nChannel); + } + + inline bool Util::sendChatReply(const std::string& strChannel, const std::string& strUTF8Text) + { + S32 nChannel; + return LLStringUtil::convertToS32(strChannel, nChannel) ? sendChatReply(nChannel, strUTF8Text) : false; + } -// ============================================================================ + // ============================================================================ +} diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h index 6ba2afbc69..0459b59483 100644 --- a/indra/newview/rlvdefines.h +++ b/indra/newview/rlvdefines.h @@ -4,32 +4,14 @@ // Defines // -namespace Rlv -{ - // Version of the specification we report - struct SpecVersion { - static constexpr S32 Major = 4; - static constexpr S32 Minor = 0; - static constexpr S32 Patch = 0; - static constexpr S32 Build = 0; - }; - - // RLVa implementation version - struct ImplVersion { - static constexpr S32 Major = 3; - static constexpr S32 Minor = 0; - static constexpr S32 Patch = 0; - static constexpr S32 ImplId = 2; /* Official viewer */ - }; -} - // Defining these makes it easier if we ever need to change our tag #define RLV_WARNS LL_WARNS("RLV") #define RLV_INFOS LL_INFOS("RLV") #define RLV_DEBUGS LL_DEBUGS("RLV") #define RLV_ENDL LL_ENDL +#define RLV_VERIFY(f) (f) -#define RLV_RELEASE +#define RLV_DEBUG #if LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG // Make sure we halt execution on errors #define RLV_ERRS LL_ERRS("RLV") @@ -37,18 +19,36 @@ namespace Rlv #define RLV_ASSERT(f) if (!(f)) { RLV_ERRS << "ASSERT (" << #f << ")" << RLV_ENDL; } #define RLV_ASSERT_DBG(f) RLV_ASSERT(f) #else + // Don't halt execution on errors in release + #define RLV_ERRS LL_WARNS("RLV") // We don't want to check assertions in release builds - #ifndef RLV_RELEASE + #ifdef RLV_DEBUG #define RLV_ASSERT(f) RLV_VERIFY(f) #define RLV_ASSERT_DBG(f) #else #define RLV_ASSERT(f) #define RLV_ASSERT_DBG(f) - #endif // RLV_RELEASE + #endif // RLV_DEBUG #endif // LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG namespace Rlv { + // Version of the specification we report + namespace SpecVersion { + constexpr S32 Major = 4; + constexpr S32 Minor = 0; + constexpr S32 Patch = 0; + constexpr S32 Build = 0; + }; + + // RLVa implementation version + namespace ImplVersion { + constexpr S32 Major = 3; + constexpr S32 Minor = 0; + constexpr S32 Patch = 0; + constexpr S32 ImplId = 13; + }; + namespace Constants { constexpr char CmdPrefix = '@'; @@ -61,33 +61,84 @@ namespace Rlv namespace Rlv { - enum class ECmdRet{ - Unknown = 0x0000, // Unknown error (should only be used internally) - Retained, // Command was retained - Success = 0x0100, // Command executed successfully - SuccessUnset, // Command executed successfully (RLV_TYPE_REMOVE for an unrestricted behaviour) - SuccessDuplicate, // Command executed successfully (RLV_TYPE_ADD for an already restricted behaviour) - SuccessDeprecated, // Command executed successfully but has been marked as deprecated - SuccessDelayed, // Command parsed valid but will execute at a later time - Failed = 0x0200, // Command failed (general failure) - FailedSyntax, // Command failed (syntax error) - FailedOption, // Command failed (invalid option) - FailedParam, // Command failed (invalid param) - FailedLock, // Command failed (command is locked by another object) - FailedDisabled, // Command failed (command disabled by user) - FailedUnknown, // Command failed (unknown command) - FailedNoSharedRoot, // Command failed (missing #RLV) - FailedDeprecated, // Command failed (deprecated and no longer supported) - FailedNoBehaviour, // Command failed (force modifier on an object with no active restrictions) - FailedUnheldBehaviour, // Command failed (local modifier on an object that doesn't hold the base behaviour) - FailedBlocked, // Command failed (object is blocked) - FailedThrottled, // Command failed (throttled) - FailedNoProcessor // Command doesn't have a template processor define (legacy code) + enum class EBehaviour { + Version = 0, + VersionNew, + VersionNum, + + Count, + Unknown, }; + enum class EBehaviourOptionType + { + None, // Behaviour takes no parameters + Exception, // Behaviour requires an exception as a parameter + NoneOrException, // Behaviour takes either no parameters or an exception + }; + + enum class EParamType { + Unknown = 0x00, + Add = 0x01, // == "n"|"add" + Remove = 0x02, // == "y"|"rem" + Force = 0x04, // == "force" + Reply = 0x08, // == + Clear = 0x10, + AddRem = Add | Remove + }; + + enum class ECmdRet { + Unknown = 0x0000, // Unknown error (should only be used internally) + Retained, // Command was retained + Success = 0x0100, // Command executed successfully + SuccessUnset, // Command executed successfully (RLV_TYPE_REMOVE for an unrestricted behaviour) + SuccessDuplicate, // Command executed successfully (RLV_TYPE_ADD for an already restricted behaviour) + SuccessDeprecated, // Command executed successfully but has been marked as deprecated + SuccessDelayed, // Command parsed valid but will execute at a later time + Failed = 0x0200, // Command failed (general failure) + FailedSyntax, // Command failed (syntax error) + FailedOption, // Command failed (invalid option) + FailedParam, // Command failed (invalid param) + FailedLock, // Command failed (command is locked by another object) + FailedDisabled, // Command failed (command disabled by user) + FailedUnknown, // Command failed (unknown command) + FailedNoSharedRoot, // Command failed (missing #RLV) + FailedDeprecated, // Command failed (deprecated and no longer supported) + FailedNoBehaviour, // Command failed (force modifier on an object with no active restrictions) + FailedUnheldBehaviour, // Command failed (local modifier on an object that doesn't hold the base behaviour) + FailedBlocked, // Command failed (object is blocked) + FailedThrottled, // Command failed (throttled) + FailedNoProcessor // Command doesn't have a template processor define (legacy code) + }; + + enum class EExceptionCheck + { + Permissive, // Exception can be set by any object + Strict, // Exception must be set by all objects holding the restriction + Default, // Permissive or strict will be determined by currently enforced restrictions + }; + + // Replace&remove in c++23 + template + constexpr std::enable_if_t && !std::is_convertible_v, std::underlying_type_t> to_underlying(E e) noexcept + { + return static_cast>(e); + } + + template + constexpr std::enable_if_t && !std::is_convertible_v, bool> has_flag(E value, E flag) noexcept + { + return (to_underlying(value) & to_underlying(flag)) != 0; + } + constexpr bool isReturnCodeSuccess(ECmdRet eRet) { - return (static_cast(eRet) & static_cast(ECmdRet::Success)) == static_cast(ECmdRet::Success); + return (to_underlying(eRet) & to_underlying(ECmdRet::Success)) == to_underlying(ECmdRet::Success); + } + + constexpr bool isReturnCodeFailed(ECmdRet eRet) + { + return (to_underlying(eRet) & to_underlying(ECmdRet::Failed)) == to_underlying(ECmdRet::Failed); } } @@ -103,6 +154,7 @@ namespace Rlv constexpr char Debug[] = "RestrainedLoveDebug"; constexpr char DebugHideUnsetDup[] = "RLVaDebugHideUnsetDuplicate"; + constexpr char EnableExperimentalCommands[] = "RLVaExperimentalCommands"; constexpr char EnableIMQuery[] = "RLVaEnableIMQuery"; constexpr char EnableTempAttach[] = "RLVaEnableTemporaryAttachments"; constexpr char TopLevelMenu[] = "RLVaTopLevelMenu"; diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index bf78a0a38a..3d7f73937f 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -1,4 +1,5 @@ #include "llviewerprecompiledheaders.h" +#include "llagent.h" #include "llappviewer.h" #include "llstartup.h" #include "llviewercontrol.h" @@ -22,11 +23,12 @@ bool RlvHandler::mIsEnabled = false; bool RlvHandler::handleSimulatorChat(std::string& message, const LLChat& chat, const LLViewerObject* chatObj) { + // *TODO: There's an edge case for temporary attachments when going from enabled -> disabled with restrictions already in place static LLCachedControl enable_temp_attach(gSavedSettings, Settings::EnableTempAttach); static LLCachedControl show_debug_output(gSavedSettings, Settings::Debug); static LLCachedControl hide_unset_dupes(gSavedSettings, Settings::DebugHideUnsetDup); - if ( message.length() <= 3 || Rlv::Constants::CmdPrefix != message[0] || CHAT_TYPE_OWNER != chat.mChatType || + if ( message.length() <= 3 || Constants::CmdPrefix != message[0] || CHAT_TYPE_OWNER != chat.mChatType || (chatObj && chatObj->isTempAttachment() && !enable_temp_attach()) ) { return false; @@ -39,7 +41,7 @@ bool RlvHandler::handleSimulatorChat(std::string& message, const LLChat& chat, c boost_tokenizer tokens(message, boost::char_separator(",", "", boost::drop_empty_tokens)); for (const std::string& strCmd : tokens) { - ECmdRet eRet = (ECmdRet)processCommand(chat.mFromID, strCmd, true); + ECmdRet eRet = processCommand(chat.mFromID, strCmd, true); if ( show_debug_output() && (!hide_unset_dupes() || (ECmdRet::SuccessUnset != eRet && ECmdRet::SuccessDuplicate != eRet)) ) { @@ -53,7 +55,44 @@ bool RlvHandler::handleSimulatorChat(std::string& message, const LLChat& chat, c ECmdRet RlvHandler::processCommand(const LLUUID& idObj, const std::string& strCmd, bool fromObj) { - return ECmdRet::FailedNoProcessor; + const RlvCommand rlvCmd(idObj, strCmd); + return processCommand(std::ref(rlvCmd), fromObj); +} + +ECmdRet RlvHandler::processCommand(std::reference_wrapper rlvCmd, bool fromObj) +{ + { + const RlvCommand& rlvCmdTmp = rlvCmd; // Reference to the temporary with limited variable scope since we don't want it to leak below + + RLV_DEBUGS << "[" << rlvCmdTmp.getObjectID() << "]: " << rlvCmdTmp.asString() << RLV_ENDL; + if (!rlvCmdTmp.isValid()) + { + RLV_DEBUGS << "\t-> invalid syntax" << RLV_ENDL; + return ECmdRet::FailedSyntax; + } + if (rlvCmdTmp.isBlocked()) + { + RLV_DEBUGS << "\t-> blocked command" << RLV_ENDL; + return ECmdRet::FailedDisabled; + } + } + + ECmdRet eRet = ECmdRet::Unknown; + switch (rlvCmd.get().getParamType()) + { + case EParamType::Reply: + eRet = rlvCmd.get().processCommand(); + break; + case EParamType::Unknown: + default: + eRet = ECmdRet::FailedParam; + break; + } + RLV_ASSERT(ECmdRet::Unknown != eRet); + + RLV_DEBUGS << "\t--> command " << (isReturnCodeSuccess(eRet) ? "succeeded" : "failed") << RLV_ENDL; + + return eRet; } // ============================================================================ @@ -72,7 +111,7 @@ bool RlvHandler::setEnabled(bool enable) if (enable && canEnable()) { - RLV_INFOS << "Enabling Restrained Love API support - " << RlvStrings::getVersionAbout() << RLV_ENDL; + RLV_INFOS << "Enabling Restrained Love API support - " << Strings::getVersionAbout() << RLV_ENDL; mIsEnabled = true; } @@ -80,3 +119,49 @@ bool RlvHandler::setEnabled(bool enable) } // ============================================================================ +// Command handlers (RLV_TYPE_REPLY) +// + +ECmdRet CommandHandlerBaseImpl::processCommand(const RlvCommand& rlvCmd, ReplyHandlerFunc* pHandler) +{ + // Sanity check - should specify a - valid - reply channel + S32 nChannel; + if (!LLStringUtil::convertToS32(rlvCmd.getParam(), nChannel) || !Util::isValidReplyChannel(nChannel, rlvCmd.getObjectID() == gAgent.getID())) + return ECmdRet::FailedParam; + + std::string strReply; + ECmdRet eRet = (*pHandler)(rlvCmd, strReply); + + // If we made it this far then: + // - the command was handled successfully so we send off the response + // - the command failed but we still send off an - empty - response to keep the issuing script from blocking + if (nChannel != 0) + { + Util::sendChatReply(nChannel, strReply); + } + + return eRet; +} + +// Handles: @version= and @versionnew= +template<> template<> +ECmdRet VersionReplyHandler::onCommand(const RlvCommand& rlvCmd, std::string& strReply) +{ + strReply = Strings::getVersion(EBehaviour::Version == rlvCmd.getBehaviourType()); + return ECmdRet::Success; +} + +// Handles: @versionnum[:impl]= +template<> template<> +ECmdRet ReplyHandler::onCommand(const RlvCommand& rlvCmd, std::string& strReply) +{ + if (!rlvCmd.hasOption()) + strReply = Strings::getVersionNum(); + else if ("impl" == rlvCmd.getOption()) + strReply = Strings::getVersionImplNum(); + else + return ECmdRet::FailedOption; + return ECmdRet::Success; +} + +// ============================================================================ diff --git a/indra/newview/rlvhandler.h b/indra/newview/rlvhandler.h index 8cf054e98e..a5e91548ef 100644 --- a/indra/newview/rlvhandler.h +++ b/indra/newview/rlvhandler.h @@ -3,7 +3,7 @@ #include "llchat.h" #include "llsingleton.h" -#include "rlvdefines.h" +#include "rlvhelper.h" class LLViewerObject; @@ -15,15 +15,17 @@ class RlvHandler : public LLSingleton { LLSINGLETON_EMPTY_CTOR(RlvHandler); -public: /* - * Helper functions + * Command processing */ public: // Command processing helper functions bool handleSimulatorChat(std::string& message, const LLChat& chat, const LLViewerObject* chatObj); Rlv::ECmdRet processCommand(const LLUUID& idObj, const std::string& stCmd, bool fromObj); +protected: + Rlv::ECmdRet processCommand(std::reference_wrapper rlvCmdRef, bool fromObj); +public: // Initialization (deliberately static so they can safely be called in tight loops) static bool canEnable(); static bool isEnabled() { return mIsEnabled; } diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index ade2b83dd7..c3f9e6f756 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -1,11 +1,242 @@ #include "llviewerprecompiledheaders.h" #include "lltrans.h" +#include "llviewercontrol.h" #include "rlvhelper.h" +#include + using namespace Rlv; +// ============================================================================ +// BehaviourDictionary +// + +BehaviourDictionary::BehaviourDictionary() +{ + // + // Restrictions + // + + // + // Reply-only + // + addEntry(new ReplyProcessor("version")); + addEntry(new ReplyProcessor("versionnew")); + addEntry(new ReplyProcessor("versionnum")); + + // Populate mString2InfoMap (the tuple should be unique) + for (const BehaviourInfo* bhvr_info_p : mBhvrInfoList) + { + RLV_VERIFY(mString2InfoMap.insert(std::make_pair(std::make_pair(bhvr_info_p->getBehaviour(), static_cast(bhvr_info_p->getParamTypeMask())), bhvr_info_p)).second); + } + + // Populate m_Bhvr2InfoMap (there can be multiple entries per ERlvBehaviour) + for (const BehaviourInfo* bhvr_info_p : mBhvrInfoList) + { + if ((bhvr_info_p->getParamTypeMask() & to_underlying(EParamType::AddRem)) && !bhvr_info_p->isSynonym()) + { +#ifdef RLV_DEBUG + for (const auto& itBhvr : boost::make_iterator_range(mBhvr2InfoMap.lower_bound(bhvr_info_p->getBehaviourType()), mBhvr2InfoMap.upper_bound(bhvr_info_p->getBehaviourType()))) + { + RLV_ASSERT((itBhvr.first != bhvr_info_p->getBehaviourType()) || (itBhvr.second->getBehaviourFlags() != bhvr_info_p->getBehaviourFlags())); + } +#endif // RLV_DEBUG + mBhvr2InfoMap.insert(std::pair(bhvr_info_p->getBehaviourType(), bhvr_info_p)); + } + } +} + +BehaviourDictionary::~BehaviourDictionary() +{ + for (const BehaviourInfo* bhvr_info_p : mBhvrInfoList) + { + delete bhvr_info_p; + } + mBhvrInfoList.clear(); +} + +void BehaviourDictionary::addEntry(const BehaviourInfo* entry_p) +{ + // Filter experimental commands (if disabled) + static LLCachedControl sEnableExperimental(gSavedSettings, Settings::EnableExperimentalCommands); + if (!entry_p || (!sEnableExperimental && entry_p->isExperimental())) + { + return; + } + + // Sanity check for duplicate entries +#ifndef LL_RELEASE_FOR_DOWNLOAD + std::for_each(mBhvrInfoList.begin(), mBhvrInfoList.end(), + [&entry_p](const BehaviourInfo* bhvr_info_p) { + RLV_ASSERT_DBG((bhvr_info_p->getBehaviour() != entry_p->getBehaviour()) || ((bhvr_info_p->getParamTypeMask() & entry_p->getParamTypeMask()) == 0)); + }); +#endif // LL_RELEASE_FOR_DOWNLOAD + + mBhvrInfoList.push_back(entry_p); +} + +const BehaviourInfo* BehaviourDictionary::getBehaviourInfo(EBehaviour eBhvr, EParamType eParamType) const +{ + const BehaviourInfo* bhvr_info_p = nullptr; + for (auto itBhvrLower = mBhvr2InfoMap.lower_bound(eBhvr), itBhvrUpper = mBhvr2InfoMap.upper_bound(eBhvr); + std::find_if(itBhvrLower, itBhvrUpper, [eParamType](const auto& bhvrEntry) { return bhvrEntry.second->getParamTypeMask() == to_underlying(eParamType); }) != itBhvrUpper; + ++itBhvrLower) + { + if (bhvr_info_p) + return nullptr; + bhvr_info_p = itBhvrLower->second; + } + return bhvr_info_p; +} + +const BehaviourInfo* BehaviourDictionary::getBehaviourInfo(const std::string& strBhvr, EParamType eParamType, bool* is_strict_p) const +{ + size_t idxBhvrLastPart = strBhvr.find_last_of('_'); + std::string strBhvrLastPart((std::string::npos != idxBhvrLastPart) && (idxBhvrLastPart < strBhvr.size()) ? strBhvr.substr(idxBhvrLastPart + 1) : LLStringUtil::null); + + bool isStrict = (strBhvrLastPart.compare("sec") == 0); + if (is_strict_p) + *is_strict_p = isStrict; + + auto itBhvr = mString2InfoMap.find(std::make_pair((!isStrict) ? strBhvr : strBhvr.substr(0, strBhvr.size() - 4), (has_flag(eParamType, EParamType::AddRem)) ? EParamType::AddRem : eParamType)); + if ((mString2InfoMap.end() == itBhvr) && (!isStrict) && (!strBhvrLastPart.empty()) && (EParamType::Force == eParamType)) + { + // No match found but it could still be a local scope modifier + auto itBhvrMod = mString2InfoMap.find(std::make_pair(strBhvr.substr(0, idxBhvrLastPart), EParamType::AddRem)); + } + + return ((itBhvr != mString2InfoMap.end()) && ((!isStrict) || (itBhvr->second->hasStrict()))) ? itBhvr->second : nullptr; +} + +EBehaviour BehaviourDictionary::getBehaviourFromString(const std::string& strBhvr, EParamType eParamType, bool* pisStrict) const +{ + const BehaviourInfo* bhvr_info_p = getBehaviourInfo(strBhvr, eParamType, pisStrict); + // Filter out locally scoped modifier commands since they don't actually have a unique behaviour value of their own + return bhvr_info_p->getBehaviourType(); +} + +bool BehaviourDictionary::getCommands(const std::string& strMatch, EParamType eParamType, std::list& cmdList) const +{ + cmdList.clear(); + for (const BehaviourInfo* bhvr_info_p : mBhvrInfoList) + { + if ((bhvr_info_p->getParamTypeMask() & to_underlying(eParamType)) || (EParamType::Unknown == eParamType)) + { + std::string strCmd = bhvr_info_p->getBehaviour(); + if ((std::string::npos != strCmd.find(strMatch)) || (strMatch.empty())) + cmdList.push_back(strCmd); + if ((bhvr_info_p->hasStrict()) && ((std::string::npos != strCmd.append("_sec").find(strMatch)) || (strMatch.empty()))) + cmdList.push_back(strCmd); + } + } + return !cmdList.empty(); +} + +bool BehaviourDictionary::getHasStrict(EBehaviour eBhvr) const +{ + for (const auto& itBhvr : boost::make_iterator_range(mBhvr2InfoMap.lower_bound(eBhvr), mBhvr2InfoMap.upper_bound(eBhvr))) + { + // Only restrictions can be strict + if (to_underlying(EParamType::AddRem) != itBhvr.second->getParamTypeMask()) + continue; + return itBhvr.second->hasStrict(); + } + RLV_ASSERT(false); + return false; +} + +void BehaviourDictionary::toggleBehaviourFlag(const std::string& strBhvr, EParamType eParamType, BehaviourInfo::EBehaviourFlags eBhvrFlag, bool fEnable) +{ + auto itBhvr = mString2InfoMap.find(std::make_pair(strBhvr, (has_flag(eParamType, EParamType::AddRem)) ? EParamType::AddRem : eParamType)); + if (mString2InfoMap.end() != itBhvr) + { + const_cast(itBhvr->second)->toggleBehaviourFlag(eBhvrFlag, fEnable); + } +} + +// ============================================================================ +// RlvCommmand +// + +RlvCommand::RlvCommand(const LLUUID& idObj, const std::string& strCmd) + : mObjId(idObj) +{ + if (parseCommand(strCmd, mBehaviour, mOption, mParam)) + { + if ("n" == mParam || "add" == mParam) + mParamType = EParamType::Add; + else if ("y" == mParam || "rem" == mParam) + mParamType = EParamType::Remove; + else if ("clear" == mBehaviour) // clear is the odd one out so just make it its own type + mParamType = EParamType::Clear; + else if ("force" == mParam) + mParamType = EParamType::Force; + else if (S32 nTemp; LLStringUtil::convertToS32(mParam, nTemp)) // Assume it's a reply command if we can convert to an S32 + mParamType = EParamType::Reply; + } + + mIsValid = mParamType != EParamType::Unknown; + if (!mIsValid) + { + mOption.clear(); + mParam.clear(); + return; + } + + mBhvrInfo = BehaviourDictionary::instance().getBehaviourInfo(mBehaviour, mParamType, &mIsStrict); +} + +RlvCommand::RlvCommand(const RlvCommand& rlvCmd, EParamType eParamType) + : mIsValid(rlvCmd.mIsValid), mObjId(rlvCmd.mObjId), mBehaviour(rlvCmd.mBehaviour), mBhvrInfo(rlvCmd.mBhvrInfo) + , mParamType( (EParamType::Unknown == eParamType) ? rlvCmd.mParamType : eParamType) + , mIsStrict(rlvCmd.mIsStrict), mOption(rlvCmd.mOption), mParam(rlvCmd.mParam), mIsRefCounted(rlvCmd.mIsRefCounted) +{ +} + +bool RlvCommand::parseCommand(const std::string& strCmd, std::string& strBhvr, std::string& strOption, std::string& strParam) +{ + // Format: [: + RLVaTopLevelMenu + + Comment + Show the RLVa specific menu as a top level menu + Persist + 1 + Type + Boolean + Value + 1 RevokePermsOnStopAnimation diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index c1bf31ff9a..b9d80fff8e 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -76,6 +76,7 @@ #include "llslurl.h" #include "llstartup.h" #include "llperfstats.h" +#include "rlvcommon.h" // Third party library includes #include @@ -933,6 +934,8 @@ void settings_setup_listeners() setting_setup_signal_listener(gSavedSettings, "TerrainPaintBitDepth", handleSetShaderChanged); setting_setup_signal_listener(gSavedPerAccountSettings, "AvatarHoverOffsetZ", handleAvatarHoverOffsetChanged); + + setting_setup_signal_listener(gSavedSettings, Rlv::Settings::TopLevelMenu, Rlv::Util::menuToggleVisible); } #if TEST_CACHED_CONTROL diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 97d5781566..b8a4cc89fd 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -147,6 +147,7 @@ #include "llviewershadermgr.h" #include "gltfscenemanager.h" #include "gltf/asset.h" +#include "rlvcommon.h" using namespace LLAvatarAppearanceDefines; @@ -6375,6 +6376,8 @@ void show_debug_menus() gMenuBarView->setItemVisible("Advanced", debug); // gMenuBarView->setItemEnabled("Advanced", debug); // Don't disable Advanced keyboard shortcuts when hidden + Rlv::Util::menuToggleVisible(); + gMenuBarView->setItemVisible("Debug", qamode); gMenuBarView->setItemEnabled("Debug", qamode); diff --git a/indra/newview/rlvcommon.cpp b/indra/newview/rlvcommon.cpp index eda2cdedc8..abb54b5b39 100644 --- a/indra/newview/rlvcommon.cpp +++ b/indra/newview/rlvcommon.cpp @@ -1,15 +1,18 @@ #include "llviewerprecompiledheaders.h" + #include "llagent.h" #include "llchat.h" #include "lldbstrings.h" #include "llversioninfo.h" +#include "llviewermenu.h" #include "llviewerstats.h" #include "message.h" +#include -#include "rlvdefines.h" #include "rlvcommon.h" -#include +#include "llviewercontrol.h" +#include "rlvhandler.h" using namespace Rlv; @@ -48,6 +51,32 @@ std::string Strings::getVersionImplNum() // RlvUtil // +void Util::menuToggleVisible() +{ + bool isTopLevel = gSavedSettings.getBOOL(Settings::TopLevelMenu); + bool isRlvEnabled = RlvHandler::isEnabled(); + + LLMenuGL* menuRLVaMain = gMenuBarView->findChildMenuByName("RLVa Main", false); + LLMenuGL* menuAdvanced = gMenuBarView->findChildMenuByName("Advanced", false); + LLMenuGL* menuRLVaEmbed= menuAdvanced->findChildMenuByName("RLVa Embedded", false); + + gMenuBarView->setItemVisible("RLVa Main", isRlvEnabled && isTopLevel); + menuAdvanced->setItemVisible("RLVa Embedded", isRlvEnabled && !isTopLevel); + + if ( isRlvEnabled && menuRLVaMain && menuRLVaEmbed && + ( (isTopLevel && 1 == menuRLVaMain->getItemCount()) || (!isTopLevel && 1 == menuRLVaEmbed->getItemCount())) ) + { + LLMenuGL* menuFrom = isTopLevel ? menuRLVaEmbed : menuRLVaMain; + LLMenuGL* menuTo = isTopLevel ? menuRLVaMain : menuRLVaEmbed; + while (LLMenuItemGL* pItem = menuFrom->getItem(1)) + { + menuFrom->removeChild(pItem); + menuTo->addChild(pItem); + pItem->updateBranchParent(menuTo); + } + } +} + bool Util::parseStringList(const std::string& strInput, std::vector& optionList, std::string_view strSeparator) { if (!strInput.empty()) diff --git a/indra/newview/rlvcommon.h b/indra/newview/rlvcommon.h index bec3e23e11..d18abcf1ac 100644 --- a/indra/newview/rlvcommon.h +++ b/indra/newview/rlvcommon.h @@ -24,6 +24,7 @@ namespace Rlv namespace Util { bool isValidReplyChannel(S32 nChannel, bool isLoopback = false); + void menuToggleVisible(); bool parseStringList(const std::string& strInput, std::vector& optionList, std::string_view strSeparator = Constants::OptionSeparator); bool sendChatReply(S32 nChannel, const std::string& strUTF8Text); bool sendChatReply(const std::string& strChannel, const std::string& strUTF8Text); diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 40f3e51fca..d04bf87676 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -1818,6 +1818,71 @@ function="World.EnvPreset" parameter="sl_about" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From 3c49c33f1333be9508966bcb8e79adfbaec79e46 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 16 Sep 2024 15:41:09 +0200 Subject: Don't compose emojis on the RLVa console input --- indra/newview/skins/default/xui/en/floater_rlv_console.xml | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview') diff --git a/indra/newview/skins/default/xui/en/floater_rlv_console.xml b/indra/newview/skins/default/xui/en/floater_rlv_console.xml index 928d50cb41..708055d1b6 100644 --- a/indra/newview/skins/default/xui/en/floater_rlv_console.xml +++ b/indra/newview/skins/default/xui/en/floater_rlv_console.xml @@ -66,6 +66,7 @@ left="1" top="1" right="-1" + show_emoji_helper="false" wrap="true" /> -- cgit v1.2.3 From 6f4d7c2d6d363aee60d2f3d1fe4ed4a251aaa11b Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Tue, 17 Sep 2024 19:12:55 +0200 Subject: Add proper file headers --- indra/newview/rlvactions.cpp | 27 +++++++++++++++++++++++++++ indra/newview/rlvactions.h | 27 +++++++++++++++++++++++++++ indra/newview/rlvcommon.cpp | 27 +++++++++++++++++++++++++++ indra/newview/rlvcommon.h | 27 +++++++++++++++++++++++++++ indra/newview/rlvdefines.h | 27 +++++++++++++++++++++++++++ indra/newview/rlvfloaters.cpp | 27 +++++++++++++++++++++++++++ indra/newview/rlvfloaters.h | 27 +++++++++++++++++++++++++++ indra/newview/rlvhandler.cpp | 27 +++++++++++++++++++++++++++ indra/newview/rlvhandler.h | 27 +++++++++++++++++++++++++++ indra/newview/rlvhelper.cpp | 27 +++++++++++++++++++++++++++ indra/newview/rlvhelper.h | 27 +++++++++++++++++++++++++++ 11 files changed, 297 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp index 1988c99ecf..110beeafc0 100644 --- a/indra/newview/rlvactions.cpp +++ b/indra/newview/rlvactions.cpp @@ -1,3 +1,30 @@ +/** + * @file rlvactions.cpp + * @author Kitty Barnett + * @brief RLVa public facing helper class to easily make RLV checks + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + #include "llviewerprecompiledheaders.h" #include "rlvactions.h" diff --git a/indra/newview/rlvactions.h b/indra/newview/rlvactions.h index ac4fc73339..cb0df95e37 100644 --- a/indra/newview/rlvactions.h +++ b/indra/newview/rlvactions.h @@ -1,3 +1,30 @@ +/** + * @file rlvactions.h + * @author Kitty Barnett + * @brief RLVa public facing helper class to easily make RLV checks + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + #pragma once // ============================================================================ diff --git a/indra/newview/rlvcommon.cpp b/indra/newview/rlvcommon.cpp index abb54b5b39..4140659715 100644 --- a/indra/newview/rlvcommon.cpp +++ b/indra/newview/rlvcommon.cpp @@ -1,3 +1,30 @@ +/** + * @file rlvcommon.h + * @author Kitty Barnett + * @brief RLVa helper functions and constants used throughout the viewer + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + #include "llviewerprecompiledheaders.h" #include "llagent.h" diff --git a/indra/newview/rlvcommon.h b/indra/newview/rlvcommon.h index d18abcf1ac..6f1bbbbdc6 100644 --- a/indra/newview/rlvcommon.h +++ b/indra/newview/rlvcommon.h @@ -1,3 +1,30 @@ +/** + * @file rlvcommon.h + * @author Kitty Barnett + * @brief RLVa helper functions and constants used throughout the viewer + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + #pragma once #include "rlvdefines.h" diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h index 88dffa1127..15baf1ba49 100644 --- a/indra/newview/rlvdefines.h +++ b/indra/newview/rlvdefines.h @@ -1,3 +1,30 @@ +/** + * @file rlvdefines.h + * @author Kitty Barnett + * @brief RLVa common defines, constants and enums + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + #pragma once // ============================================================================ diff --git a/indra/newview/rlvfloaters.cpp b/indra/newview/rlvfloaters.cpp index 8d107b2540..8a074fd14d 100644 --- a/indra/newview/rlvfloaters.cpp +++ b/indra/newview/rlvfloaters.cpp @@ -1,3 +1,30 @@ +/** + * @file rlvfloaters.cpp + * @author Kitty Barnett + * @brief RLVa floaters class implementations + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + #include "llviewerprecompiledheaders.h" #include "llagentdata.h" diff --git a/indra/newview/rlvfloaters.h b/indra/newview/rlvfloaters.h index a599bb051a..1d560f32d4 100644 --- a/indra/newview/rlvfloaters.h +++ b/indra/newview/rlvfloaters.h @@ -1,3 +1,30 @@ +/** + * @file rlvfloaters.h + * @author Kitty Barnett + * @brief RLVa floaters class implementations + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + #pragma once #include "llfloater.h" diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index 0a0da0e25d..bf086c1b4b 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -1,3 +1,30 @@ +/** + * @file rlvhandler.cpp + * @author Kitty Barnett + * @brief RLVa helper classes for internal use only + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + #include "llviewerprecompiledheaders.h" #include "llagent.h" #include "llstartup.h" diff --git a/indra/newview/rlvhandler.h b/indra/newview/rlvhandler.h index 7fa4da767a..38612485b1 100644 --- a/indra/newview/rlvhandler.h +++ b/indra/newview/rlvhandler.h @@ -1,3 +1,30 @@ +/** + * @file rlvhandler.h + * @author Kitty Barnett + * @brief Primary command process and orchestration class + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + #pragma once #include "llchat.h" diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index ecb76a1db3..a82de4b9b8 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -1,3 +1,30 @@ +/** + * @file rlvhelper.cpp + * @author Kitty Barnett + * @brief RLVa helper classes for internal use only + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + #include "llviewerprecompiledheaders.h" #include "lltrans.h" diff --git a/indra/newview/rlvhelper.h b/indra/newview/rlvhelper.h index 644cd0ee22..7f0435f791 100644 --- a/indra/newview/rlvhelper.h +++ b/indra/newview/rlvhelper.h @@ -1,3 +1,30 @@ +/** + * @file rlvhelper.h + * @author Kitty Barnett + * @brief RLVa helper classes for internal use only + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + #pragma once #include "rlvdefines.h" -- cgit v1.2.3 From fca4227e59d3375e824e0265a08d6b7ed7715632 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Tue, 17 Sep 2024 23:07:29 +0200 Subject: Fix tab vs whitespace line --- indra/newview/llviewermenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index dbd3478637..bbf2dfad13 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -6248,7 +6248,7 @@ void show_debug_menus() gMenuBarView->setItemVisible("Advanced", debug); // gMenuBarView->setItemEnabled("Advanced", debug); // Don't disable Advanced keyboard shortcuts when hidden - Rlv::Util::menuToggleVisible(); + Rlv::Util::menuToggleVisible(); gMenuBarView->setItemVisible("Debug", qamode); gMenuBarView->setItemEnabled("Debug", qamode); -- cgit v1.2.3 From e03ad4913fd9dc12d9efcdd3854885a1622277ef Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Tue, 17 Sep 2024 23:44:22 +0200 Subject: Mac build fixes: Reapply the template fix in rlvhelper.h + point to LLFloaterReg in the global namespace --- indra/newview/rlvfloaters.h | 3 ++- indra/newview/rlvhelper.h | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/rlvfloaters.h b/indra/newview/rlvfloaters.h index 1d560f32d4..8acfa43f28 100644 --- a/indra/newview/rlvfloaters.h +++ b/indra/newview/rlvfloaters.h @@ -32,6 +32,7 @@ #include "rlvdefines.h" class LLChatEntry; +class LLFloaterReg; class LLLayoutPanel; class LLTextEditor; class RlvCommand; @@ -45,7 +46,7 @@ namespace Rlv class FloaterConsole : public LLFloater { - friend class LLFloaterReg; + friend class ::LLFloaterReg; FloaterConsole(const LLSD& sdKey) : LLFloater(sdKey) {} public: diff --git a/indra/newview/rlvhelper.h b/indra/newview/rlvhelper.h index 7f0435f791..f241332594 100644 --- a/indra/newview/rlvhelper.h +++ b/indra/newview/rlvhelper.h @@ -152,14 +152,20 @@ namespace Rlv // // CommandHandler - The actual command handler (Note that a handler is more general than a processor; a handler can - for instance - be used by multiple processors) // + #if LL_WINDOWS + #define RLV_TEMPL_FIX(x) template + #else + #define RLV_TEMPL_FIX(x) template + #endif // LL_WINDOWS + template struct CommandHandler { - template::type> static ECmdRet onCommand(const RlvCommand&, bool&); - template::type> static void onCommandToggle(EBehaviour, bool); - template::type> static ECmdRet onCommand(const RlvCommand&); - template::type> static ECmdRet onCommand(const RlvCommand&, std::string&); + RLV_TEMPL_FIX(typename = typename std::enable_if::type) static ECmdRet onCommand(const RlvCommand&, bool&); + RLV_TEMPL_FIX(typename = typename std::enable_if::type) static void onCommandToggle(EBehaviour, bool); + RLV_TEMPL_FIX(typename = typename std::enable_if::type) static ECmdRet onCommand(const RlvCommand&); + RLV_TEMPL_FIX(typename = typename std::enable_if::type) static ECmdRet onCommand(const RlvCommand&, std::string&); }; // Aliases to improve readability in definitions @@ -179,11 +185,11 @@ namespace Rlv { public: // Default constructor used by behaviour specializations - template::type> + RLV_TEMPL_FIX(typename = typename std::enable_if::type) CommandProcessor(const std::string& strBhvr, U32 nBhvrFlags = 0) : BehaviourInfo(strBhvr, templBhvr, templParamType, nBhvrFlags) {} // Constructor used when we don't want to specialize on behaviour (see BehaviourGenericProcessor) - template::type> + RLV_TEMPL_FIX(typename = typename std::enable_if::type) CommandProcessor(const std::string& strBhvr, EBehaviour eBhvr, U32 nBhvrFlags = 0) : BehaviourInfo(strBhvr, eBhvr, templParamType, nBhvrFlags) {} ECmdRet processCommand(const RlvCommand& rlvCmd) const override { return baseImpl::processCommand(rlvCmd, &handlerImpl::onCommand); } -- cgit v1.2.3 From dc64ac19fd74694a6e9ecf0cb68e3f83257c93b9 Mon Sep 17 00:00:00 2001 From: Nicky Date: Sat, 28 Sep 2024 00:36:12 +0200 Subject: Replace None and Success. Those are X11 defines and thus lead to compile errors when compiling a Linux viewer. --- indra/newview/rlvdefines.h | 6 +++--- indra/newview/rlvhandler.cpp | 6 +++--- indra/newview/rlvhelper.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h index 15baf1ba49..e3472ed4a8 100644 --- a/indra/newview/rlvdefines.h +++ b/indra/newview/rlvdefines.h @@ -102,7 +102,7 @@ namespace Rlv enum class EBehaviourOptionType { - None, // Behaviour takes no parameters + EmptyOrException, // Behaviour takes no parameters Exception, // Behaviour requires an exception as a parameter NoneOrException, // Behaviour takes either no parameters or an exception }; @@ -120,7 +120,7 @@ namespace Rlv enum class ECmdRet { Unknown = 0x0000, // Unknown error (should only be used internally) Retained, // Command was retained - Success = 0x0100, // Command executed successfully + Succeeded = 0x0100, // Command executed successfully SuccessUnset, // Command executed successfully (RLV_TYPE_REMOVE for an unrestricted behaviour) SuccessDuplicate, // Command executed successfully (RLV_TYPE_ADD for an already restricted behaviour) SuccessDeprecated, // Command executed successfully but has been marked as deprecated @@ -163,7 +163,7 @@ namespace Rlv constexpr bool isReturnCodeSuccess(ECmdRet eRet) { - return (to_underlying(eRet) & to_underlying(ECmdRet::Success)) == to_underlying(ECmdRet::Success); + return (to_underlying(eRet) & to_underlying(ECmdRet::Succeeded)) == to_underlying(ECmdRet::Succeeded); } constexpr bool isReturnCodeFailed(ECmdRet eRet) diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index bf086c1b4b..6c4b439105 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -198,7 +198,7 @@ ECmdRet ReplyHandler::onCommand(const RlvCommand& rlvCmd std::list cmdList; if (BehaviourDictionary::instance().getCommands(!optionList.empty() ? optionList[0] : LLStringUtil::null, eType, cmdList)) strReply = boost::algorithm::join(cmdList, optionList.size() >= 3 ? optionList[2] : Constants::OptionSeparator); - return ECmdRet::Success; + return ECmdRet::Succeeded; } // Handles: @version= and @versionnew= @@ -206,7 +206,7 @@ template<> template<> ECmdRet VersionReplyHandler::onCommand(const RlvCommand& rlvCmd, std::string& strReply) { strReply = Strings::getVersion(EBehaviour::Version == rlvCmd.getBehaviourType()); - return ECmdRet::Success; + return ECmdRet::Succeeded; } // Handles: @versionnum[:impl]= @@ -219,7 +219,7 @@ ECmdRet ReplyHandler::onCommand(const RlvCommand& rlvCmd strReply = Strings::getVersionImplNum(); else return ECmdRet::FailedOption; - return ECmdRet::Success; + return ECmdRet::Succeeded; } // ============================================================================ diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index a82de4b9b8..988fc9ca8b 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -283,7 +283,7 @@ namespace Rlv else if (mForConsole) return; // Only show console feedback on successful commands when there's an informational notice - std::string& strResult = mCommandResults[isReturnCodeSuccess(eRet) ? ECmdRet::Success : (ECmdRet::Retained == eRet ? ECmdRet::Retained : ECmdRet::Failed)]; + std::string& strResult = mCommandResults[isReturnCodeSuccess(eRet) ? ECmdRet::Succeeded : (ECmdRet::Retained == eRet ? ECmdRet::Retained : ECmdRet::Failed)]; if (!strResult.empty()) strResult.append(", "); strResult.append(strCmd); @@ -308,7 +308,7 @@ namespace Rlv }; if (!mForConsole) result << ": @" << mOrigCmd; - appendResult(ECmdRet::Success, !mForConsole ? "RlvDebugExecuted" : "RlvConsoleExecuted"); + appendResult(ECmdRet::Succeeded, !mForConsole ? "RlvDebugExecuted" : "RlvConsoleExecuted"); appendResult(ECmdRet::Failed, !mForConsole ? "RlvDebugFailed" : "RlvConsoleFailed"); appendResult(ECmdRet::Retained, !mForConsole ? "RlvDebugRetained" : "RlvConsoleRetained"); } @@ -320,7 +320,7 @@ namespace Rlv { switch (eRet) { - case ECmdRet::Success: + case ECmdRet::Succeeded: return LLTrans::getString("RlvDebugExecuted"); case ECmdRet::Failed: return LLTrans::getString("RlvDebugFailed"); @@ -372,7 +372,7 @@ namespace Rlv return LLTrans::getString("RlvReturnCodeNoProcessor"); // The following are identified by the chat verb case ECmdRet::Retained: - case ECmdRet::Success: + case ECmdRet::Succeeded: case ECmdRet::Failed: return LLStringUtil::null; // The following shouldn't occur -- cgit v1.2.3 From 689f723a5f314ffa0f54c0e50a51cbe464b36ccf Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Wed, 2 Oct 2024 00:34:09 +0200 Subject: Remove unneeded RLV_VERIFY + undefine accidental RLV_DEBUG define (should fix Linux build) --- indra/newview/rlvdefines.h | 1 - indra/newview/rlvhelper.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h index e3472ed4a8..e39328fdd6 100644 --- a/indra/newview/rlvdefines.h +++ b/indra/newview/rlvdefines.h @@ -38,7 +38,6 @@ #define RLV_ENDL LL_ENDL #define RLV_VERIFY(f) (f) -#define RLV_DEBUG #if LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG // Make sure we halt execution on errors #define RLV_ERRS LL_ERRS("RLV") diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index 988fc9ca8b..7cb1473c8c 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -57,7 +57,7 @@ BehaviourDictionary::BehaviourDictionary() // Populate mString2InfoMap (the tuple should be unique) for (const BehaviourInfo* bhvr_info_p : mBhvrInfoList) { - RLV_VERIFY(mString2InfoMap.insert(std::make_pair(std::make_pair(bhvr_info_p->getBehaviour(), static_cast(bhvr_info_p->getParamTypeMask())), bhvr_info_p)).second); + mString2InfoMap.insert(std::make_pair(std::make_pair(bhvr_info_p->getBehaviour(), static_cast(bhvr_info_p->getParamTypeMask())), bhvr_info_p)); } // Populate m_Bhvr2InfoMap (there can be multiple entries per ERlvBehaviour) -- cgit v1.2.3