summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2026-08-19 10:32:55 +0800
committerErik Kundiman <erik@megapahit.org>2026-08-19 10:39:08 +0800
commit7845ea584611b5bd81ad9dea226933b1444865f3 (patch)
tree2f16fe4deef44b864c2ceb5277ad1a08abbd8788 /indra
parent71484d55400477c7b3b4bd8d9cdae52278b25dde (diff)
Basic @redirchat implementationHEADmain
We use a non member static associative array here cause it needs to be accessed in sendChatFromViewer that is static. A public function for modifying it is also just static. As per spec, "It does not apply to emotes, and will not trigger any animation", hence some extra efforts there.
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llfloaterimnearbychat.cpp22
-rw-r--r--indra/newview/llfloaterimnearbychat.h1
-rw-r--r--indra/newview/rlvdefines.h1
-rw-r--r--indra/newview/rlvhandler.cpp8
-rw-r--r--indra/newview/rlvhelper.cpp1
5 files changed, 32 insertions, 1 deletions
diff --git a/indra/newview/llfloaterimnearbychat.cpp b/indra/newview/llfloaterimnearbychat.cpp
index f0d696361a..6143d5b89e 100644
--- a/indra/newview/llfloaterimnearbychat.cpp
+++ b/indra/newview/llfloaterimnearbychat.cpp
@@ -69,6 +69,7 @@
#include "lltranslate.h"
#include "llautoreplace.h"
#include "lluiusage.h"
+#include "rlvactions.h"
S32 LLFloaterIMNearbyChat::sLastSpecialChatChannel = 0;
@@ -91,6 +92,8 @@ static LLChatTypeTrigger sChatTypeTriggers[] = {
{ "/shout" , CHAT_TYPE_SHOUT}
};
+static std::unordered_set<S32> sRedirChatChannels;
+
bool cb_do_nothing()
{
return false;
@@ -475,7 +478,7 @@ void LLFloaterIMNearbyChat::onChatBoxKeystroke()
auto length = raw_text.length();
- if( (length > 0) && (raw_text[0] != '/') ) // forward slash is used for escape (eg. emote) sequences
+ if( (length > 0) && (raw_text[0] != '/') && !(RlvActions::isRlvEnabled() && !sRedirChatChannels.empty()) ) // forward slash is used for escape (eg. emote) sequences
{
gAgent.startTyping();
}
@@ -699,6 +702,14 @@ void LLFloaterIMNearbyChat::displaySpeakingIndicator()
}
}
+void LLFloaterIMNearbyChat::addOrRemoveRedirChatChannel(S32 channel, bool add)
+{
+ if (add)
+ sRedirChatChannels.insert(channel);
+ else
+ sRedirChatChannels.erase(channel);
+}
+
void LLFloaterIMNearbyChat::sendChatFromViewer(const std::string &utf8text, EChatType type, bool animate)
{
sendChatFromViewer(utf8str_to_wstring(utf8text), type, animate);
@@ -718,6 +729,15 @@ void LLFloaterIMNearbyChat::sendChatFromViewer(const LLWString &wtext, EChatType
utf8_text = utf8str_truncate(utf8_text, MAX_STRING - 1);
}
+ auto prefix = utf8_out_text.substr(0, 4);
+ if (RlvActions::isRlvEnabled() && channel == 0 && !sRedirChatChannels.empty() && prefix != "/me " && prefix != "/me'")
+ {
+ std::for_each(sRedirChatChannels.begin(), sRedirChatChannels.end(), [utf8_out_text,type](S32 channel){
+ send_chat_from_viewer(utf8_out_text, type, channel);
+ });
+ return;
+ }
+
// Don't animate for chats people can't hear (chat to scripts)
if (animate && (channel == 0))
{
diff --git a/indra/newview/llfloaterimnearbychat.h b/indra/newview/llfloaterimnearbychat.h
index abcaa13442..e2382690da 100644
--- a/indra/newview/llfloaterimnearbychat.h
+++ b/indra/newview/llfloaterimnearbychat.h
@@ -77,6 +77,7 @@ public:
static void startChat(const char* line);
static void stopChat();
+ static void addOrRemoveRedirChatChannel(S32 channel, bool add);
static void sendChatFromViewer(const std::string &utf8text, EChatType type, bool animate);
static void sendChatFromViewer(const LLWString &wtext, EChatType type, bool animate);
diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h
index 4437adcf1b..a3015d004a 100644
--- a/indra/newview/rlvdefines.h
+++ b/indra/newview/rlvdefines.h
@@ -93,6 +93,7 @@ namespace Rlv
Version = 0,
VersionNew,
VersionNum,
+ RedirChat,
GetSitID,
Sit,
SitGround,
diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp
index c11f6af5b2..53df717af7 100644
--- a/indra/newview/rlvhandler.cpp
+++ b/indra/newview/rlvhandler.cpp
@@ -29,6 +29,7 @@
#include "llagent.h"
#include "llstartup.h"
#include "llappearancemgr.h"
+#include "llfloaterimnearbychat.h"
#include "llinventoryfunctions.h"
#include "llinventorymodel.h"
#include "llmoveview.h"
@@ -415,6 +416,13 @@ ECmdRet CommandHandlerBaseImpl<EParamType::AddRem>::processCommand(const RlvComm
}
template<> template<>
+ECmdRet BehaviourToggleHandler<EBehaviour::RedirChat>::onCommand(const RlvCommand& rlvCmd, bool& toggle)
+{
+ LLFloaterIMNearbyChat::addOrRemoveRedirChatChannel(std::stoi(rlvCmd.getOption()), toggle);
+ return ECmdRet::Succeeded;
+}
+
+template<> template<>
ECmdRet BehaviourToggleHandler<EBehaviour::Sit>::onCommand(const RlvCommand& rlvCmd, bool& toggle)
{
gAgent.setAllowedToSit(toggle);
diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp
index 2c14434194..4d2a40da67 100644
--- a/indra/newview/rlvhelper.cpp
+++ b/indra/newview/rlvhelper.cpp
@@ -66,6 +66,7 @@ BehaviourDictionary::BehaviourDictionary()
addEntry(new ForceProcessor<EBehaviour::Detach>("detach"));
// AddRem
+ addEntry(new BehaviourProcessor<EBehaviour::RedirChat>("redirchat"));
addEntry(new BehaviourProcessor<EBehaviour::Sit>("sit"));
addEntry(new BehaviourProcessor<EBehaviour::Unsit>("unsit"));
addEntry(new BehaviourProcessor<EBehaviour::Detach>("detach"));