From 2c1af5a8b352f8fe97cfbb5be3c0b5c301c6318d Mon Sep 17 00:00:00 2001
From: Kitty Barnett <develop@catznip.com>
Date: Sun, 10 Apr 2022 15:58:09 +0200
Subject: [PATCH] CATZ-633: Separate the 'blocked_tplurerequest_remote' into
 one for tplure and one for tprequest (with reasonable fallback for existing
 customizations)

---
 indra/newview/llimprocessing.cpp              |  7 ++--
 indra/newview/rlvcommon.cpp                   | 19 ++++++++-
 indra/newview/rlvcommon.h                     |  1 +
 indra/newview/rlvdefines.h                    | 40 ++++++++++---------
 .../skins/default/xui/en/rlva_strings.xml     | 17 ++++++--
 5 files changed, 58 insertions(+), 26 deletions(-)

diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp
index 3cbdb2e9921..34eaafc0b8a 100644
--- a/indra/newview/llimprocessing.cpp
+++ b/indra/newview/llimprocessing.cpp
@@ -1334,10 +1334,11 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,
 // [RLVa:KB] - Checked: RLVa-1.4.9
 				if (rlv_handler_t::isEnabled())
 				{
-					if ( ((IM_LURE_USER == dialog) && (!RlvActions::canAcceptTpOffer(from_id))) ||
-					     ((IM_TELEPORT_REQUEST == dialog) && (!RlvActions::canAcceptTpRequest(from_id))) )
+                    bool fBlockTpLure = (IM_LURE_USER == dialog) && (!RlvActions::canAcceptTpOffer(from_id));
+                    bool fBlockTpRequest = (IM_TELEPORT_REQUEST == dialog) && (!RlvActions::canAcceptTpRequest(from_id));
+					if ( fBlockTpLure || fBlockTpRequest )
 					{
-						RlvUtil::sendBusyMessage(from_id, RlvStrings::getString(RlvStringKeys::Blocked::TpLureRequestRemote));
+						RlvUtil::sendBusyMessage(from_id, RlvStrings::getString(fBlockTpLure ? RlvStringKeys::Blocked::TpLureRemote : RlvStringKeys::Blocked::TpRequestRemote));
 						if (is_do_not_disturb)
 							send_do_not_disturb_message(gMessageSystem, from_id);
 						return;
diff --git a/indra/newview/rlvcommon.cpp b/indra/newview/rlvcommon.cpp
index 0c930496239..581002e631e 100644
--- a/indra/newview/rlvcommon.cpp
+++ b/indra/newview/rlvcommon.cpp
@@ -279,6 +279,23 @@ void RlvStrings::initClass()
 	}
 }
 
+// Used to provide fallback behaviour whenever we rename/split/join customizable string values
+LLSD& RlvStrings::cleanStringValues(LLSD& sdStringValues)
+{
+	LLSD sdValues(sdStringValues);
+	for (LLSD::map_const_iterator itString = sdValues.beginMap(); itString != sdValues.endMap(); ++itString)
+	{
+		if (itString->first == "blocked_tplurerequest_remote")
+		{
+			sdStringValues.erase("blocked_tplurerequest_remote");
+			sdStringValues[RlvStringKeys::Blocked::TpLureRemote] = itString->second;
+			sdStringValues[RlvStringKeys::Blocked::TpRequestRemote] = itString->second;
+		}
+	}
+
+	return sdStringValues;
+}
+
 // Checked: 2011-11-08 (RLVa-1.5.0)
 void RlvStrings::loadFromFile(const std::string& strFilePath, bool fUserOverride)
 {
@@ -289,7 +306,7 @@ void RlvStrings::loadFromFile(const std::string& strFilePath, bool fUserOverride
 
 	if (sdFileData.has("strings"))
 	{
-		const LLSD& sdStrings = sdFileData["strings"];
+		const LLSD sdStrings = (!fUserOverride) ? sdFileData["strings"] : cleanStringValues(sdFileData["strings"]);
 		for (LLSD::map_const_iterator itString = sdStrings.beginMap(); itString != sdStrings.endMap(); ++itString)
 		{
 			if ( (!itString->second.has("value")) || ((fUserOverride) && (!hasString(itString->first))) )
diff --git a/indra/newview/rlvcommon.h b/indra/newview/rlvcommon.h
index 008e4d6fa45..666d036e4de 100644
--- a/indra/newview/rlvcommon.h
+++ b/indra/newview/rlvcommon.h
@@ -148,6 +148,7 @@ class RlvStrings
 {
 public:
 	static void initClass();
+	static LLSD& cleanStringValues(LLSD& sdValues);
 	static void loadFromFile(const std::string& strFilePath, bool fDefault);
 	static void saveToFile(const std::string& strFilePath);
 
diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h
index dff03ef5361..c199f379393 100644
--- a/indra/newview/rlvdefines.h
+++ b/indra/newview/rlvdefines.h
@@ -469,28 +469,30 @@ namespace RlvStringKeys
 		/*inline*/ constexpr boost::string_view StartIm = make_string_view("blocked_startim");
 		/*inline*/ constexpr boost::string_view Teleport = make_string_view("blocked_teleport");
 		/*inline*/ constexpr boost::string_view TeleportOffer = make_string_view("blocked_teleport_offer");
-		/*inline*/ constexpr boost::string_view TpLureRequestRemote = make_string_view("blocked_tplurerequest_remote");
+		/*inline*/ constexpr boost::string_view TpLureRemote = make_string_view("blocked_tplure_remote");
+		/*inline*/ constexpr boost::string_view TpRequestRemote = make_string_view("blocked_tprequest_remote");
 		/*inline*/ constexpr boost::string_view ViewXxx = make_string_view("blocked_viewxxx");
 		/*inline*/ constexpr boost::string_view Wireframe = make_string_view("blocked_wireframe");
 #else
-		constexpr const char AutoPilot[] = "blocked_autopilot";
-		constexpr const char Generic[] = "blocked_generic";
-		constexpr const char GroupChange[] = "blocked_groupchange";
-		constexpr const char InvFolder[] = "blocked_invfolder";
-		constexpr const char PermissionAttach[] = "blocked_permattach";
-		constexpr const char PermissionTeleport[] = "blocked_permteleport";
-		constexpr const char RecvIm[] = "blocked_recvim";
-		constexpr const char RecvImRemote[] = "blocked_recvim_remote";
-		constexpr const char SendIm[] = "blocked_sendim";
-		constexpr const char Share[] = "blocked_share";
-		constexpr const char ShareGeneric[] = "blocked_share_generic";
-		constexpr const char StartConference[] = "blocked_startconf";
-		constexpr const char StartIm[] = "blocked_startim";
-		constexpr const char Teleport[] = "blocked_teleport";
-		constexpr const char TeleportOffer[] = "blocked_teleport_offer";
-		constexpr const char TpLureRequestRemote[] = "blocked_tplurerequest_remote";
-		constexpr const char ViewXxx[] = "blocked_viewxxx";
-		constexpr const char Wireframe[] = "blocked_wireframe";
+		static constexpr const char AutoPilot[] = "blocked_autopilot";
+		static constexpr const char Generic[] = "blocked_generic";
+		static constexpr const char GroupChange[] = "blocked_groupchange";
+		static constexpr const char InvFolder[] = "blocked_invfolder";
+		static constexpr const char PermissionAttach[] = "blocked_permattach";
+		static constexpr const char PermissionTeleport[] = "blocked_permteleport";
+		static constexpr const char RecvIm[] = "blocked_recvim";
+		static constexpr const char RecvImRemote[] = "blocked_recvim_remote";
+		static constexpr const char SendIm[] = "blocked_sendim";
+		static constexpr const char Share[] = "blocked_share";
+		static constexpr const char ShareGeneric[] = "blocked_share_generic";
+		static constexpr const char StartConference[] = "blocked_startconf";
+		static constexpr const char StartIm[] = "blocked_startim";
+		static constexpr const char Teleport[] = "blocked_teleport";
+		static constexpr const char TeleportOffer[] = "blocked_teleport_offer";
+		static constexpr const char TpLureRemote[] = "blocked_tplure_remote";
+		static constexpr const char TpRequestRemote[] = "blocked_tprequest_remote";
+		static constexpr const char ViewXxx[] = "blocked_viewxxx";
+		static constexpr const char Wireframe[] = "blocked_wireframe";
 #endif // CATZNIP_STRINGVIEW
 	}
 
diff --git a/indra/newview/skins/default/xui/en/rlva_strings.xml b/indra/newview/skins/default/xui/en/rlva_strings.xml
index 3ffb3d90094..95321f7ac68 100644
--- a/indra/newview/skins/default/xui/en/rlva_strings.xml
+++ b/indra/newview/skins/default/xui/en/rlva_strings.xml
@@ -194,14 +194,25 @@
 			<key>customizable</key>
 			<boolean>1</boolean>
 		</map>
-		<key>blocked_tplurerequest_remote</key>
+		<key>blocked_tplure_remote</key>
 		<map>
 			<key>value</key>
 			<string>The Resident is currently prevented from accepting. Please try again later.</string>
 			<key>description</key>
-			<string>Sent to the remote party when their teleport offer or request was blocked</string>
+			<string>Sent to the remote party when their teleport offer was blocked</string>
 			<key>label</key>
-			<string>Blocked teleport offer/request (remote)</string>
+			<string>Blocked teleport offer (remote)</string>
+			<key>customizable</key>
+			<boolean>1</boolean>
+		</map>
+		<key>blocked_tprequest_remote</key>
+		<map>
+			<key>value</key>
+			<string>The Resident is currently prevented from accepting. Please try again later.</string>
+			<key>description</key>
+			<string>Sent to the remote party when their teleport request was blocked</string>
+			<key>label</key>
+			<string>Blocked teleport request (remote)</string>
 			<key>customizable</key>
 			<boolean>1</boolean>
 		</map>
-- 
GitLab