From 1bd4836e7c36f3c1ee4a821c39f78ca1397e3291 Mon Sep 17 00:00:00 2001
From: Erik Kundiman <erik@megapahit.org>
Date: Tue, 20 Aug 2024 21:33:20 +0800
Subject: Arrival, distance & leaving notifs in local chat

https://megapahit.com/show_bug.cgi?id=49

The LLVOAvatar class doesn't seem to have a display name getter.
---
 indra/newview/llvoavatar.cpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index d7382eaac6..62884ecb3c 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -70,6 +70,7 @@
 #include "llmeshrepository.h"
 #include "llmutelist.h"
 #include "llmoveview.h"
+#include "llnotificationmanager.h"
 #include "llnotificationsutil.h"
 #include "llphysicsshapebuilderutil.h"
 #include "llquantize.h"
@@ -811,6 +812,7 @@ void LLVOAvatar::debugAvatarRezTime(std::string notification_name, std::string c
 //------------------------------------------------------------------------
 LLVOAvatar::~LLVOAvatar()
 {
+    LLNotificationsUI::LLNotificationManager::instance().onChat(LLChat{llformat("%s left.", getFullname().c_str())}, LLSD{});
     if (!mFullyLoaded)
     {
         debugAvatarRezTime("AvatarRezLeftCloudNotification","left after ruth seconds as cloud");
@@ -2462,6 +2464,20 @@ U32 LLVOAvatar::processUpdateMessage(LLMessageSystem *mesgsys,
     {
         mDebugExistenceTimer.reset();
         debugAvatarRezTime("AvatarRezArrivedNotification","avatar arrived");
+        uuid_vec_t uuids;
+        std::vector<LLVector3d> positions;
+        LLWorld::getInstance()->getAvatars(&uuids, &positions, gAgent.getPositionGlobal(), gSavedSettings.getF32("MPVNearMeRange"));
+        auto pos_it = positions.begin();
+        auto id_it = uuids.begin();
+        for (;pos_it != positions.end() && id_it != uuids.end(); ++pos_it, ++id_it)
+        {
+            if (*id_it == getID() && !isSelf())
+            {
+                LLNotificationsUI::LLNotificationManager::instance()
+                    .onChat(LLChat{llformat("%s arrived (%.1f m).", getFullname().c_str(), dist_vec(*pos_it, gAgent.getPositionGlobal()))}, LLSD{});
+                break;
+            }
+        }
     }
 
     if(retval & LLViewerObject::INVALID_UPDATE)
-- 
cgit v1.2.3