From 672037d1f26e9093d4c33dfd68e7ace6f9a0b2f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liru=20F=C3=A6rs?= Date: Sun, 5 Jan 2020 23:25:22 -0500 Subject: [PATCH] Sync LLChatBar with alchemy's LLChatBar and LLChatUtilities Stops typing anim on chatbar focus loss Makes a couple classes final Adds checkChatVolume and canSendChannel to RlvActions Updates other bits of Rlv, but adds no functionality --- .../newview/app_settings/settings_ascent.xml | 11 ++ indra/newview/llchatbar.cpp | 180 +++++++++--------- indra/newview/llchatbar.h | 22 ++- indra/newview/rlvactions.cpp | 32 +++- indra/newview/rlvactions.h | 17 +- indra/newview/rlvhelper.cpp | 14 +- 6 files changed, 163 insertions(+), 113 deletions(-) diff --git a/indra/newview/app_settings/settings_ascent.xml b/indra/newview/app_settings/settings_ascent.xml index b0b90b0b4..759e674a9 100644 --- a/indra/newview/app_settings/settings_ascent.xml +++ b/indra/newview/app_settings/settings_ascent.xml @@ -212,6 +212,17 @@ Value 1 + AlchemyNearbyChatChannel + + Comment + Chat channel used for sending nearby chat from the viewer + Persist + 0 + Type + S32 + Value + 0 + AlchemyRainbowEffects Comment diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp index 32323b8f5..2d8917b2e 100644 --- a/indra/newview/llchatbar.cpp +++ b/indra/newview/llchatbar.cpp @@ -72,6 +72,8 @@ #include "chatbar_as_cmdline.h" // [RLVa:KB] +#include "rlvcommon.h" +#include "rlvactions.h" #include "rlvhandler.h" // [/RLVa:KB] @@ -100,25 +102,24 @@ class LLChatBarGestureObserver : public LLGestureManagerObserver { public: LLChatBarGestureObserver(LLChatBar* chat_barp) : mChatBar(chat_barp){} - virtual ~LLChatBarGestureObserver() {} - virtual void changed() { mChatBar->refreshGestures(); } + virtual ~LLChatBarGestureObserver() = default; + void changed() override { mChatBar->refreshGestures(); } private: LLChatBar* mChatBar; }; - // // Functions // LLChatBar::LLChatBar() : LLPanel(), - mInputEditor(NULL), + mInputEditor(nullptr), mGestureLabelTimer(), mLastSpecialChatChannel(0), mIsBuilt(FALSE), - mGestureCombo(NULL), - mObserver(NULL) + mGestureCombo(nullptr), + mObserver(nullptr) { setIsChrome(TRUE); @@ -132,10 +133,14 @@ LLChatBar::~LLChatBar() { LLGestureMgr::instance().removeObserver(mObserver); delete mObserver; - mObserver = NULL; + mObserver = nullptr; // LLView destructor cleans up children } +//----------------------------------------------------------------------- +// Overrides +//----------------------------------------------------------------------- + BOOL LLChatBar::postBuild() { if (LLUICtrl* history_ctrl = findChild("History")) @@ -189,7 +194,7 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) else if (mask == MASK_SHIFT) { // whisper - sendChat( CHAT_TYPE_WHISPER ); + sendChat(CHAT_TYPE_WHISPER); handled = TRUE; } else if (mask == MASK_NONE) @@ -210,6 +215,11 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) return handled; } +void LLChatBar::onFocusLost() +{ + stopChat(); +} + void LLChatBar::refresh() { // HACK: Leave the name of the gesture in place for a few seconds. @@ -242,17 +252,16 @@ void LLChatBar::refreshGestures() //store current selection so we can maintain it std::string cur_gesture = mGestureCombo->getValue().asString(); mGestureCombo->selectFirstItem(); - std::string label = mGestureCombo->getValue().asString();; + // clear mGestureCombo->clearRows(); // collect list of unique gestures std::map unique; - LLGestureMgr::item_map_t::const_iterator it; const LLGestureMgr::item_map_t& active_gestures = LLGestureMgr::instance().getActiveGestures(); - for (it = active_gestures.begin(); it != active_gestures.end(); ++it) + for (const auto& active_gesture : active_gestures) { - LLMultiGesture* gesture = (*it).second; + LLMultiGesture* gesture = active_gesture.second; if (gesture) { if (!gesture->mTrigger.empty()) @@ -262,11 +271,9 @@ void LLChatBar::refreshGestures() } } - // add unique gestures - std::map ::iterator it2; - for (it2 = unique.begin(); it2 != unique.end(); ++it2) + for (auto& it2 : unique) { - mGestureCombo->addSimpleElement((*it2).first); + mGestureCombo->addSimpleElement(it2.first); } mGestureCombo->sortByName(); @@ -316,12 +323,12 @@ void LLChatBar::setIgnoreArrowKeys(BOOL b) } } -BOOL LLChatBar::inputEditorHasFocus() +BOOL LLChatBar::inputEditorHasFocus() const { return mInputEditor && mInputEditor->hasFocus(); } -std::string LLChatBar::getCurrentChat() +std::string LLChatBar::getCurrentChat() const { return mInputEditor ? mInputEditor->getText() : LLStringUtil::null; } @@ -390,7 +397,7 @@ LLWString LLChatBar::stripChannelNumber(const LLWString &mesg, S32* channel) pos++; } - mLastSpecialChatChannel = strtol(wstring_to_utf8str(channel_string).c_str(), NULL, 10); + mLastSpecialChatChannel = strtol(wstring_to_utf8str(channel_string).c_str(), nullptr, 10); // if(mesg[1] == '-') mLastSpecialChatChannel = -mLastSpecialChatChannel; @@ -570,9 +577,12 @@ void LLChatBar::onInputEditorKeystroke() S32 length = raw_text.length(); - //if( (length > 0) && (raw_text[0] != '/') ) // forward slash is used for escape (eg. emote) sequences -// [RLVa:KB] - Checked: 2009-07-07 (RLVa-1.0.0d) - if ( (length > 0) && (raw_text[0] != '/') && (!gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT)) ) +// if( (length > 0) +// && (raw_text[0] != '/') // forward slash is used for escape (eg. emote) sequences +// && (raw_text[0] != ':') // colon is used in for MUD poses +// ) +// [RLVa:KB] - Checked: 2010-03-26 (RLVa-1.2.0b) | Modified: RLVa-1.0.0d + if ( (length > 0) && (raw_text[0] != '/') && (raw_text[0] != ':') && (!RlvActions::hasBehaviour(RLV_BHVR_REDIRCHAT)) ) // [/RLVa:KB] { gAgent.startTyping(); @@ -582,21 +592,6 @@ void LLChatBar::onInputEditorKeystroke() gAgent.stopTyping(); } - /* Doesn't work -- can't tell the difference between a backspace - that killed the selection vs. backspace at the end of line. - if (length > 1 - && text[0] == '/' - && key == KEY_BACKSPACE) - { - // the selection will already be deleted, but we need to trim - // off the character before - std::string new_text = raw_text.substr(0, length-1); - mInputEditor->setText( new_text ); - mInputEditor->setCursorToEnd(); - length = length - 1; - } - */ - KEY key = gKeyboard->currentKey(); // Ignore "special" keys, like backspace, arrows, etc. @@ -622,11 +617,6 @@ void LLChatBar::onInputEditorKeystroke() mInputEditor->setSelection(length, outlength); } } - - //LL_INFOS() << "GESTUREDEBUG " << trigger - // << " len " << length - // << " outlen " << out_str.getLength() - // << LL_ENDL; } } @@ -668,11 +658,11 @@ void LLChatBar::sendChatFromViewer(const std::string &utf8text, EChatType type, void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate) { // Look for "/20 foo" channel chats. - S32 channel = 0; + S32 channel = gSavedSettings.getS32("AlchemyNearbyChatChannel"); LLWString out_text = stripChannelNumber(wtext, &channel); std::string utf8_out_text = wstring_to_utf8str(out_text); - std::string utf8_text = wstring_to_utf8str(wtext); + utf8_text = utf8str_trim(utf8_text); if (!utf8_text.empty()) { @@ -680,17 +670,12 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL } // [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0b - if ( (0 == channel) && (rlv_handler_t::isEnabled()) ) + // RELEASE-RLVa: [SL-2.0.0] This entire class appears to be dead/non-functional? + if ( (0 == channel) && (RlvActions::isRlvEnabled()) ) { // Adjust the (public) chat "volume" on chat and gestures (also takes care of playing the proper animation) - if ( ((CHAT_TYPE_SHOUT == type) || (CHAT_TYPE_NORMAL == type)) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATNORMAL)) ) - type = CHAT_TYPE_WHISPER; - else if ( (CHAT_TYPE_SHOUT == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATSHOUT)) ) - type = CHAT_TYPE_NORMAL; - else if ( (CHAT_TYPE_WHISPER == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATWHISPER)) ) - type = CHAT_TYPE_NORMAL; - - animate &= !gRlvHandler.hasBehaviour( (!RlvUtil::isEmote(utf8_text)) ? RLV_BHVR_REDIRCHAT : RLV_BHVR_REDIREMOTE ); + type = RlvActions::checkChatVolume(type); + animate &= !RlvActions::hasBehaviour( (!RlvUtil::isEmote(utf8_text)) ? RLV_BHVR_REDIRCHAT : RLV_BHVR_REDIREMOTE ); } // [/RLVa:KB] @@ -731,23 +716,19 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL send_chat_from_viewer(utf8_out_text, type, channel); } -// [RLVa:KB] - Checked: 2009-07-07 (RLVa-1.0.0d) | Modified: RLVa-0.2.2a +//void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel) +// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0b) | Modified: RLVa-0.2.2a void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channel) // [/RLVa:KB] { // [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0a // Only process chat messages (ie not CHAT_TYPE_START, CHAT_TYPE_STOP, etc) - if ( (rlv_handler_t::isEnabled()) && ( (CHAT_TYPE_WHISPER == type) || (CHAT_TYPE_NORMAL == type) || (CHAT_TYPE_SHOUT == type) ) ) + if ( (RlvActions::isRlvEnabled()) && ( (CHAT_TYPE_WHISPER == type) || (CHAT_TYPE_NORMAL == type) || (CHAT_TYPE_SHOUT == type) ) ) { if (0 == channel) { - // (We already did this before, but LLChatHandler::handle() calls this directly) - if ( ((CHAT_TYPE_SHOUT == type) || (CHAT_TYPE_NORMAL == type)) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATNORMAL)) ) - type = CHAT_TYPE_WHISPER; - else if ( (CHAT_TYPE_SHOUT == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATSHOUT)) ) - type = CHAT_TYPE_NORMAL; - else if ( (CHAT_TYPE_WHISPER == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATWHISPER)) ) - type = CHAT_TYPE_NORMAL; + // Clamp the volume of the chat if needed + type = RlvActions::checkChatVolume(type); // Redirect chat if needed if ( ( (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT) || (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE)) ) && @@ -763,7 +744,7 @@ void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channe else { // Don't allow chat on a non-public channel if sendchannel restricted (unless the channel is an exception) - if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHANNEL)) && (!gRlvHandler.isException(RLV_BHVR_SENDCHANNEL, channel)) ) + if (!RlvActions::canSendChannel(channel)) return; // Don't allow chat on debug channel if @sendchat, @redirchat or @rediremote restricted (shows as public chat on viewers) @@ -836,33 +817,29 @@ void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channe void really_send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel) { LLMessageSystem* msg = gMessageSystem; - // - if(channel >= 0) + if (channel >= 0) { - // - msg->newMessageFast(_PREHASH_ChatFromViewer); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->nextBlockFast(_PREHASH_ChatData); - msg->addStringFast(_PREHASH_Message, utf8_out_text); - msg->addU8Fast(_PREHASH_Type, type); - msg->addS32("Channel", channel); - // + msg->newMessageFast(_PREHASH_ChatFromViewer); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + msg->nextBlockFast(_PREHASH_ChatData); + msg->addStringFast(_PREHASH_Message, utf8_out_text); + msg->addU8Fast(_PREHASH_Type, type); + msg->addS32("Channel", channel); } else { - msg->newMessage("ScriptDialogReply"); - msg->nextBlock("AgentData"); - msg->addUUID("AgentID", gAgent.getID()); - msg->addUUID("SessionID", gAgent.getSessionID()); - msg->nextBlock("Data"); - msg->addUUID("ObjectID", gAgent.getID()); + msg->newMessageFast(_PREHASH_ScriptDialogReply); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + msg->nextBlockFast(_PREHASH_Data); + msg->addUUIDFast(_PREHASH_ObjectID, gAgent.getID()); msg->addS32("ChatChannel", channel); - msg->addS32("ButtonIndex", 0); - msg->addString("ButtonLabel", utf8_out_text); + msg->addS32Fast(_PREHASH_ButtonIndex, 0); + msg->addStringFast(_PREHASH_ButtonLabel, utf8_out_text); } - // gAgent.sendReliableMessage(); LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT); @@ -895,7 +872,7 @@ void LLChatBar::onCommitGesture(LLUICtrl* ctrl) } } mGestureLabelTimer.start(); - if (mGestureCombo != NULL) + if (mGestureCombo != nullptr) { // free focus back to chat bar mGestureCombo->setFocus(FALSE); @@ -907,24 +884,39 @@ void toggleChatHistory() LLFloaterChat::toggleInstance(LLSD()); } +// +// LLChatCommandHandler +// -class LLChatHandler : public LLCommandHandler +class LLChatCommandHandler final : public LLCommandHandler { public: // not allowed from outside the app - LLChatHandler() : LLCommandHandler("chat", UNTRUSTED_BLOCK) { } + LLChatCommandHandler() : LLCommandHandler("chat", UNTRUSTED_BLOCK) { } // Your code here bool handle(const LLSD& tokens, const LLSD& query_map, - LLMediaCtrl* web) + LLMediaCtrl* web) override { - if (tokens.size() < 2) return false; - S32 channel = tokens[0].asInteger(); - std::string mesg = tokens[1].asString(); - send_chat_from_viewer(mesg, CHAT_TYPE_NORMAL, channel); - return true; + bool retval = false; + // Need at least 2 tokens to have a valid message. + if (tokens.size() < 2) + { + retval = false; + } + else + { + S32 channel = tokens[0].asInteger(); + { + retval = true; + // Send unescaped message, see EXT-6353. + std::string unescaped_mesg (LLURI::unescape(tokens[1].asString())); + send_chat_from_viewer(unescaped_mesg, CHAT_TYPE_NORMAL, channel); + } + } + return retval; } }; // Creating the object registers with the dispatcher. -LLChatHandler gChatHandler; +LLChatCommandHandler gChatHandler; diff --git a/indra/newview/llchatbar.h b/indra/newview/llchatbar.h index 71440d8bb..656da5132 100644 --- a/indra/newview/llchatbar.h +++ b/indra/newview/llchatbar.h @@ -33,10 +33,9 @@ #ifndef LL_LLCHATBAR_H #define LL_LLCHATBAR_H -#include "llpanel.h" #include "llframetimer.h" #include "llchat.h" -#include "lllayoutstack.h" +#include "llpanel.h" class LLLineEditor; class LLMessageSystem; @@ -46,17 +45,19 @@ class LLFrameTimer; class LLChatBarGestureObserver; class LLComboBox; -class LLChatBar : public LLPanel + +class LLChatBar final +: public LLPanel { public: // constructor for inline chat-bars (e.g. hosted in chat history window) LLChatBar(); - ~LLChatBar(); - virtual BOOL postBuild(); - virtual BOOL handleKeyHere(KEY key, MASK mask); + BOOL postBuild() override; + BOOL handleKeyHere(KEY key, MASK mask) override; + void onFocusLost() override; - void refresh(); + void refresh() override; void refreshGestures(); // Move cursor into chat input field. @@ -65,8 +66,8 @@ public: // Ignore arrow keys for chat bar void setIgnoreArrowKeys(BOOL b); - BOOL inputEditorHasFocus(); - std::string getCurrentChat(); + BOOL inputEditorHasFocus() const; + std::string getCurrentChat() const; // since chat bar logic is reused for chat history // gesture combo box might not be a direct child @@ -94,10 +95,11 @@ public: static void stopChat(); protected: + ~LLChatBar(); + void sendChat(EChatType type); void updateChat(); -protected: LLLineEditor* mInputEditor; LLFrameTimer mGestureLabelTimer; diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp index b746cda4a..6dd15cf49 100644 --- a/indra/newview/rlvactions.cpp +++ b/indra/newview/rlvactions.cpp @@ -1,6 +1,6 @@ /** * - * Copyright (c) 2009-2013, Kitty Barnett + * Copyright (c) 2009-2016, Kitty Barnett * * The source code in this file is provided to you under the terms of the * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; @@ -38,6 +38,13 @@ bool RlvActions::canReceiveIM(const LLUUID& idSender) ( (!gRlvHandler.hasBehaviour(RLV_BHVR_RECVIMFROM)) || (!gRlvHandler.isException(RLV_BHVR_RECVIMFROM, idSender)) ) ); } +bool RlvActions::canSendChannel(int nChannel) +{ + return + ( (!gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHANNEL)) || (gRlvHandler.isException(RLV_BHVR_SENDCHANNEL, nChannel)) ) /*&& + ( (!gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHANNELEXCEPT)) || (!gRlvHandler.isException(RLV_BHVR_SENDCHANNELEXCEPT, nChannel)) )*/; +} + // Checked: 2010-11-30 (RLVa-1.3.0) bool RlvActions::canSendIM(const LLUUID& idRecipient) { @@ -62,29 +69,44 @@ bool RlvActions::canStartIM(const LLUUID& idRecipient) ( (!gRlvHandler.hasBehaviour(RLV_BHVR_STARTIMTO)) || (!gRlvHandler.isException(RLV_BHVR_STARTIMTO, idRecipient)) ) ); } +// Handles: @chatwhisper, @chatnormal and @chatshout +EChatType RlvActions::checkChatVolume(EChatType chatType) +{ + // In vs Bhvr | whisper | normal | shout | n+w | n+s | s+w | s+n+w | + // --------------------------------------------------------------------------------- + // whisper | normal | - | - | normal | - | normal | normal | + // normal | - | whisper | - | whisper | whisper | - | whisper | + // shout | - | whisper | normal | whisper | whisper | normal | whisper | + + RlvHandler& rlvHandler = gRlvHandler; + if ( ((CHAT_TYPE_SHOUT == chatType) || (CHAT_TYPE_NORMAL == chatType)) && (rlvHandler.hasBehaviour(RLV_BHVR_CHATNORMAL)) ) + chatType = CHAT_TYPE_WHISPER; + else if ( (CHAT_TYPE_SHOUT == chatType) && (rlvHandler.hasBehaviour(RLV_BHVR_CHATSHOUT)) ) + chatType = CHAT_TYPE_NORMAL; + else if ( (CHAT_TYPE_WHISPER == chatType) && (rlvHandler.hasBehaviour(RLV_BHVR_CHATWHISPER)) ) + chatType = CHAT_TYPE_NORMAL; + return chatType; +} + // ============================================================================ // Movement // -// Checked: 2010-12-11 (RLVa-1.2.2) bool RlvActions::canAcceptTpOffer(const LLUUID& idSender) { return ((!gRlvHandler.hasBehaviour(RLV_BHVR_TPLURE)) || (gRlvHandler.isException(RLV_BHVR_TPLURE, idSender))) && (canStand()); } -// Checked: 2013-11-08 (RLVa-1.4.9) bool RlvActions::autoAcceptTeleportOffer(const LLUUID& idSender) { return ((idSender.notNull()) && (gRlvHandler.isException(RLV_BHVR_ACCEPTTP, idSender))) || (gRlvHandler.hasBehaviour(RLV_BHVR_ACCEPTTP)); } -// Checked: 2013-11-08 (RLVa-1.4.9) bool RlvActions::canAcceptTpRequest(const LLUUID& idSender) { return (!gRlvHandler.hasBehaviour(RLV_BHVR_TPREQUEST)) || (gRlvHandler.isException(RLV_BHVR_TPREQUEST, idSender)); } -// Checked: 2013-11-08 (RLVa-1.4.9) bool RlvActions::autoAcceptTeleportRequest(const LLUUID& idRequester) { return ((idRequester.notNull()) && (gRlvHandler.isException(RLV_BHVR_ACCEPTTPREQUEST, idRequester))) || (gRlvHandler.hasBehaviour(RLV_BHVR_ACCEPTTPREQUEST)); diff --git a/indra/newview/rlvactions.h b/indra/newview/rlvactions.h index fbc8ab12b..062758594 100644 --- a/indra/newview/rlvactions.h +++ b/indra/newview/rlvactions.h @@ -1,6 +1,6 @@ /** * - * Copyright (c) 2009-2013, Kitty Barnett + * Copyright (c) 2009-2016, Kitty Barnett * * The source code in this file is provided to you under the terms of the * GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY; @@ -17,6 +17,7 @@ #ifndef RLV_ACTIONS_H #define RLV_ACTIONS_H +#include "llchat.h" #include "rlvdefines.h" // ============================================================================ @@ -34,6 +35,13 @@ public: */ static bool canReceiveIM(const LLUUID& idSender); + /* + + /* + * Returns true if the user is allowed to chat on the specified channel + */ + static bool canSendChannel(int nChannel); + /* * Returns true if the user is allowed to send IMs to the specified recipient (can be an avatar or a group) */ @@ -53,6 +61,11 @@ public: static bool canShowName(EShowNamesContext eContext) { return (eContext < SNC_COUNT) ? !s_BlockNamesContexts[eContext] : false; } static void setShowName(EShowNamesContext eContext, bool fShowName) { if ( (eContext < SNC_COUNT) && (isRlvEnabled()) ) { s_BlockNamesContexts[eContext] = !fShowName; } } + /* + * Checks if the user is allowed to use the specified volume in (main) chat and returns the appropriate chat volume type + */ + static EChatType checkChatVolume(EChatType chatType); + protected: // Backwards logic so that we can initialize to 0 and it won't block when we forget to/don't check if RLVa is disabled static bool s_BlockNamesContexts[SNC_COUNT]; @@ -108,7 +121,7 @@ public: static bool hasBehaviour(ERlvBehaviour eBhvr); /* - * Returns true if a - P2P or group - IM session is open with the specified UUID. + * Returns true if a - P2P or group - IM session is open with the specified UUID */ static bool hasOpenP2PSession(const LLUUID& idAgent); static bool hasOpenGroupSession(const LLUUID& idGroup); diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index fcffd476a..629d3a14e 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -434,9 +434,19 @@ bool RlvObject::hasBehaviour(ERlvBehaviour eBehaviour, bool fStrictOnly) const bool RlvObject::hasBehaviour(ERlvBehaviour eBehaviour, const std::string& strOption, bool fStrictOnly) const { - for (rlv_command_list_t::const_iterator itCmd = m_Commands.begin(); itCmd != m_Commands.end(); ++itCmd) - if ( (itCmd->getBehaviourType() == eBehaviour) && (itCmd->getOption() == strOption) && ((!fStrictOnly) || (itCmd->isStrict())) ) + for (const RlvCommand& rlvCmd : m_Commands) + { + // The specified behaviour is contained within the current object if: + // - the (parsed) behaviour matches + // - the option matches (or we're checking for an empty option and the command was reference counted) + // - we're not matching on strict (or it is a strict command) + if ( (rlvCmd.getBehaviourType() == eBehaviour) && + ( (rlvCmd.getOption() == strOption) /*|| ((strOption.empty()) && (rlvCmd.isRefCounted()))*/ ) && + ( (!fStrictOnly) ||(rlvCmd.isStrict()) ) ) + { return true; + } + } return false; }