FIRE-14759: Override chat channel with channel selected in channel selection only if no channel is provided in the message itself

Ansariel 2014-10-09 12:54:40 +02:00
parent c6a20cd27a
commit 1bff13ce0c
4 changed files with 26 additions and 83 deletions

View File

@ -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 "/<number>" 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<LLSpinCtrl>("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 "/<number>" 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:Ansariel> [FS communication UI]
//channel = (S32)(LLFloaterNearbyChat::getInstance()->getChild<LLSpinCtrl>("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]
//<FS:TS> FIRE-11412: Allow saying /-channel for negative numbers
//&& LLStringOps::isDigit(mesg[1]))
&& (LLStringOps::isDigit(mesg[1])
|| (mesg[1] == '-'
&& mesg[2]
&& LLStringOps::isDigit(mesg[2]))))
//</FS:TS> FIRE-11412
{
// This a special "/20" speak on a channel
S32 pos = 0;
//<FS:TS> FIRE-11412: Allow saying /-channel for negative numbers
if (mesg[1] == '-')
pos++;
//</FS:TS> 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);
//<FS:TS> FIRE-11412: Allow saying /-channel for negative numbers
if (mesg[1] == '-')
sLastSpecialChatChannel = -sLastSpecialChatChannel;
//</FS:TS> 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)

View File

@ -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();

View File

@ -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 "/<number>" 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<LLSpinCtrl>("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)
//</FS:TS> FIRE-11412
{
// This a special "/20" speak on a channel
*is_set = true;
S32 pos = 0;
//<FS:TS> 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 "/<number>" 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<LLSpinCtrl>("ChatChannel")->get());
}

View File

@ -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);