From fddd851a4faffd9121d6006c4b3c53921d54489f Mon Sep 17 00:00:00 2001
From: Testicular Slingshot <automatic@null.net>
Date: Sun, 23 Feb 2020 18:08:20 -0400
Subject: [PATCH] Some fixes and changes thanks to @Liru

---
 indra/newview/llimprocessing.cpp                | 14 +++++++-------
 indra/newview/llimprocessing.h                  |  3 +++
 indra/newview/llviewermessage.cpp               | 17 +++--------------
 indra/newview/llviewerregion.cpp                |  1 -
 .../skins/default/xui/en/notifications.xml      |  8 ++++++++
 5 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp
index 0570480325..2ee2b3d418 100644
--- a/indra/newview/llimprocessing.cpp
+++ b/indra/newview/llimprocessing.cpp
@@ -70,7 +70,7 @@
 #include <boost/lexical_cast.hpp>
 #include <boost/tokenizer.hpp>
 
-std::string replace_wildcard(std::string input, const LLUUID& id, const std::string& name)
+std::string replace_wildcards(std::string input, const LLUUID& id, const std::string& name)
 {
 	boost::algorithm::replace_all(input, "#n", name);
 // disable boost::lexical_cast warning
@@ -171,11 +171,11 @@ void translate_if_needed(std::string& message)
     }
 }
 
-class LLPostponedIMSystemTipNotification : public LLPostponedNotification
+class LLPostponedIMSystemTipNotification final : public LLPostponedNotification
 {
 protected:
     /* virtual */
-    void modifyNotificationParams()
+    void modifyNotificationParams() override
     {
         LLSD payload = mParams.payload;
         payload["SESSION_NAME"] = mName;
@@ -183,11 +183,11 @@ protected:
     }
 };
 
-class LLPostponedOfferNotification : public LLPostponedNotification
+class LLPostponedOfferNotification final : public LLPostponedNotification
 {
 protected:
     /* virtual */
-    void modifyNotificationParams()
+    void modifyNotificationParams() override
     {
         LLSD substitutions = mParams.substitutions;
         substitutions["NAME"] = mName;
@@ -632,7 +632,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,
 				std::string response = gSavedPerAccountSettings.getString(sAutorespondNonFriend && !is_friend
 					? "AlchemyAutoresponseNotFriend"
 					: "AlchemyAutoresponse");
-				response = replace_wildcard(response, from_id, name);
+				response = replace_wildcards(response, from_id, name);
 				pack_instant_message(
 					gMessageSystem,
 					gAgent.getID(),
@@ -754,7 +754,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,
 					std::string response = gSavedPerAccountSettings.getString(sAutorespondNonFriend && !is_friend
 						? "AlchemyAutoresponseNotFriend"
 						: "AlchemyAutoresponse");
-					response = replace_wildcard(response, from_id, name);
+					response = replace_wildcards(response, from_id, name);
 					pack_instant_message(gMessageSystem,
 						gAgent.getID(),
 						FALSE,
diff --git a/indra/newview/llimprocessing.h b/indra/newview/llimprocessing.h
index 4d20b963a4..e221e98681 100644
--- a/indra/newview/llimprocessing.h
+++ b/indra/newview/llimprocessing.h
@@ -59,5 +59,8 @@ private:
     static void requestOfflineMessagesLegacy();
 };
 
+// Replace wild cards in message strings
+std::string replace_wildcards(std::string input, const LLUUID& id, const std::string& name);
+
 
 #endif  // LL_LLLLIMPROCESSING_H
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index b2f2624d4d..fa975940a7 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -520,20 +520,6 @@ void process_layer_data(LLMessageSystem* mesgsys, void** user_data)
 	}
 }
 
-// Replace wild cards in message strings
-std::string replace_wildcards(std::string input, const LLUUID& id, const std::string& name)
-{
-	boost::algorithm::replace_all(input, "#n", name);
-
-	LLSLURL slurl;
-	LLAgentUI::buildSLURL(slurl);
-	boost::algorithm::replace_all(input, "#r", slurl.getSLURLString());
-
-	LLAvatarName av_name;
-	boost::algorithm::replace_all(input, "#d", LLAvatarNameCache::get(id, &av_name) ? av_name.getDisplayName() : name);
-	return input;
-}
-
 void process_derez_ack(LLMessageSystem*, void**)
 {
 	if (gViewerWindow) gViewerWindow->getWindow()->decBusyCount();
@@ -730,6 +716,9 @@ bool join_group_response(const LLSD& notification, const LLSD& response)
 			notification_adjusted = sSavedGroupInvite[id];
 			response_adjusted = sSavedResponse[id];
 		}
+		// Potential memory leak fix
+		sSavedGroupInvite.erase(id);
+		sSavedResponse.erase(id);
 	}
 
 	S32 option = LLNotificationsUtil::getSelectedOption(notification_adjusted, response_adjusted);
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index ff46487ecf..946438a926 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -3047,7 +3047,6 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames)
 	capabilityNames.append(CAP_NAME_OBJECT_MEDIA);
 	capabilityNames.append("ObjectMediaNavigate");
 	capabilityNames.append("ObjectNavMeshProperties");
-	capabilityNames.append("OpenSimExtras");
 	capabilityNames.append("ParcelPropertiesUpdate");
 	capabilityNames.append("ParcelVoiceInfoRequest");
 	capabilityNames.append("ProductInfoRequest");
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index ffd2c4cb09..868e8b2096 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -7563,6 +7563,10 @@ Offer a teleport?
        index="1"
        name="Decline"
        text="Decline"/>
+      <button
+       index="2"
+       name="IM"
+       text="IM"/>
     </form>
   </notification>
 
@@ -7594,6 +7598,10 @@ Offer a teleport?
        index="1"
        name="Decline"
        text="Decline"/>
+      <button
+       index="2"
+       name="IM"
+       text="IM"/>
     </form>
   </notification>
 
-- 
GitLab