diff --git a/indra/newview/fsfloaternearbychat.cpp b/indra/newview/fsfloaternearbychat.cpp index d700f9ed31..958fbe6d6f 100644 --- a/indra/newview/fsfloaternearbychat.cpp +++ b/indra/newview/fsfloaternearbychat.cpp @@ -36,6 +36,7 @@ #include "fscommon.h" #include "fsfloaterim.h" #include "fsfloaterimcontainer.h" +#include "fsnearbychathub.h" #include "llagent.h" // gAgent #include "llanimationstates.h" // ANIM_AGENT_WHISPER, ANIM_AGENT_TALK, ANIM_AGENT_SHOUT #include "llautoreplace.h" @@ -993,12 +994,13 @@ void FSFloaterNearbyChat::sendChat( EChatType type ) // Check if this is destined for another channel S32 channel = 0; - stripChannelNumber(text, &channel); + bool is_set = false; + FSNearbyChat::stripChannelNumber(text, &channel, &is_set); // If "/" is not specified, see if a channel has been set in // the spinner. - if (gSavedSettings.getBOOL("FSNearbyChatbar") && - gSavedSettings.getBOOL("FSShowChatChannel") && - (channel == 0)) + if (!is_set && + gSavedSettings.getBOOL("FSNearbyChatbar") && + gSavedSettings.getBOOL("FSShowChatChannel")) { channel = (S32)(FSFloaterNearbyChat::getInstance()->getChild("ChatChannel")->get()); } @@ -1086,12 +1088,13 @@ void FSFloaterNearbyChat::sendChatFromViewer(const std::string &utf8text, EChatT void FSFloaterNearbyChat::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate) { S32 channel = 0; - LLWString out_text = stripChannelNumber(wtext, &channel); + bool is_set = false; + LLWString out_text = FSNearbyChat::stripChannelNumber(wtext, &channel, &is_set); // If "/" is not specified, see if a channel has been set in // the spinner. - if (gSavedSettings.getBOOL("FSNearbyChatbar") && - gSavedSettings.getBOOL("FSShowChatChannel") && - (channel == 0)) + if (!is_set && + gSavedSettings.getBOOL("FSNearbyChatbar") && + gSavedSettings.getBOOL("FSShowChatChannel")) { // [FS communication UI] //channel = (S32)(LLFloaterNearbyChat::getInstance()->getChild("ChatChannel")->get()); @@ -1169,70 +1172,6 @@ void FSFloaterNearbyChat::stopChat() } } -// If input of the form "/20foo" or "/20 foo", returns "foo" and channel 20. -// Otherwise returns input and channel 0. -LLWString FSFloaterNearbyChat::stripChannelNumber(const LLWString &mesg, S32* channel) -{ - if (mesg[0] == '/' - && mesg[1] == '/') - { - // This is a "repeat channel send" - *channel = sLastSpecialChatChannel; - return mesg.substr(2, mesg.length() - 2); - } - else if (mesg[0] == '/' - && mesg[1] - // FIRE-11412: Allow saying /-channel for negative numbers - //&& LLStringOps::isDigit(mesg[1])) - && (LLStringOps::isDigit(mesg[1]) - || (mesg[1] == '-' - && mesg[2] - && LLStringOps::isDigit(mesg[2])))) - // FIRE-11412 - { - // This a special "/20" speak on a channel - S32 pos = 0; - // FIRE-11412: Allow saying /-channel for negative numbers - if (mesg[1] == '-') - pos++; - // FIRE-11412 - - // Copy the channel number into a string - LLWString channel_string; - llwchar c; - do - { - c = mesg[pos+1]; - channel_string.push_back(c); - pos++; - } - while(c && pos < 64 && LLStringOps::isDigit(c)); - - // Move the pointer forward to the first non-whitespace char - // Check isspace before looping, so we can handle "/33foo" - // as well as "/33 foo" - while(c && iswspace(c)) - { - c = mesg[pos+1]; - pos++; - } - - sLastSpecialChatChannel = strtol(wstring_to_utf8str(channel_string).c_str(), NULL, 10); - // FIRE-11412: Allow saying /-channel for negative numbers - if (mesg[1] == '-') - sLastSpecialChatChannel = -sLastSpecialChatChannel; - // FIRE-11412 - *channel = sLastSpecialChatChannel; - return mesg.substr(pos, mesg.length() - pos); - } - else - { - // This is normal chat. - *channel = 0; - return mesg; - } -} - //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_nearby_floater(std::string utf8_out_text, EChatType type, S32 channel) diff --git a/indra/newview/fsfloaternearbychat.h b/indra/newview/fsfloaternearbychat.h index 62582cb471..3174f2eb62 100644 --- a/indra/newview/fsfloaternearbychat.h +++ b/indra/newview/fsfloaternearbychat.h @@ -106,7 +106,6 @@ protected: void onChatBoxCommit(); void onChatTypeChanged(); - static LLWString stripChannelNumber(const LLWString &mesg, S32* channel); EChatType processChatTypeTriggers(EChatType type, std::string &str); void reshapeFloater(bool collapse); void reshapeChatLayoutPanel(); diff --git a/indra/newview/fsnearbychathub.cpp b/indra/newview/fsnearbychathub.cpp index ab9fd9e956..f107065e6b 100644 --- a/indra/newview/fsnearbychathub.cpp +++ b/indra/newview/fsnearbychathub.cpp @@ -262,12 +262,13 @@ void FSNearbyChat::sendChatFromViewer(const LLWString& wtext, EChatType type, BO { // Look for "/20 foo" channel chats. S32 channel = 0; - LLWString out_text = stripChannelNumber(wtext, &channel); + bool is_set = false; + LLWString out_text = stripChannelNumber(wtext, &channel, &is_set); // If "/" is not specified, see if a channel has been set in // the spinner. - if (gSavedSettings.getBOOL("FSNearbyChatbar") && - gSavedSettings.getBOOL("FSShowChatChannel") && - (channel == 0)) + if (!is_set && + gSavedSettings.getBOOL("FSNearbyChatbar") && + gSavedSettings.getBOOL("FSShowChatChannel")) { channel = (S32)(FSFloaterNearbyChat::getInstance()->getChild("ChatChannel")->get()); } @@ -370,8 +371,10 @@ EChatType FSNearbyChat::processChatTypeTriggers(EChatType type, std::string &str // If input of the form "/20foo" or "/20 foo", returns "foo" and channel 20. // Otherwise returns input and channel 0. -LLWString FSNearbyChat::stripChannelNumber(const LLWString &mesg, S32* channel) +LLWString FSNearbyChat::stripChannelNumber(const LLWString &mesg, S32* channel, bool* is_set) { + *is_set = false; + if (mesg[0] == '/' && mesg[1] == '/') { @@ -391,6 +394,7 @@ LLWString FSNearbyChat::stripChannelNumber(const LLWString &mesg, S32* channel) // FIRE-11412 { // This a special "/20" speak on a channel + *is_set = true; S32 pos = 0; // FIRE-11412: Allow saying /-channel for negative numbers // (this code was here; documenting for the future) @@ -454,12 +458,13 @@ void FSNearbyChat::sendChat(LLWString text, EChatType type) // Check if this is destined for another channel S32 channel = 0; - stripChannelNumber(text, &channel); + bool is_set = false; + stripChannelNumber(text, &channel, &is_set); // If "/" is not specified, see if a channel has been set in // the spinner. - if (gSavedSettings.getBOOL("FSNearbyChatbar") && - gSavedSettings.getBOOL("FSShowChatChannel") && - (channel == 0)) + if (!is_set && + gSavedSettings.getBOOL("FSNearbyChatbar") && + gSavedSettings.getBOOL("FSShowChatChannel")) { channel = (S32)(FSFloaterNearbyChat::getInstance()->getChild("ChatChannel")->get()); } diff --git a/indra/newview/fsnearbychathub.h b/indra/newview/fsnearbychathub.h index 571ee460c1..b17f5a2e7e 100644 --- a/indra/newview/fsnearbychathub.h +++ b/indra/newview/fsnearbychathub.h @@ -55,7 +55,7 @@ public: void showDefaultChatBar(BOOL visible,const char* text=0) const; void sendChat(LLWString text,EChatType type); - LLWString stripChannelNumber(const LLWString &mesg, S32* channel); + static LLWString stripChannelNumber(const LLWString &mesg, S32* channel, bool* is_set); EChatType processChatTypeTriggers(EChatType type, std::string &str); void sendChatFromViewer(const std::string& utf8text, EChatType type, BOOL animate); void sendChatFromViewer(const LLWString& wtext, EChatType type, BOOL animate);