From 7ddb99117ecdaa1d27719908aca6283a0f90d74e Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Wed, 30 Jul 2025 17:06:44 +0800 Subject: Use getAvatars already called for Discord Party numbers so we don't have to make any extra getAvatars calls just for this, as it's pricy in crowds, and we'll just be piggybacking `updateSpeakerList` and `updateNearbyList`. --- indra/newview/llappviewer.cpp | 26 ++++++++++++++++++-------- indra/newview/llappviewer.h | 2 ++ indra/newview/llpanelpeople.cpp | 3 +++ indra/newview/llspeakers.cpp | 3 +++ 4 files changed, 26 insertions(+), 8 deletions(-) (limited to 'indra') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index f65b6f309b..ec03377ccb 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -283,6 +283,8 @@ using namespace LL; #include static std::shared_ptr gDiscordClient; static uint64_t gDiscordTimestampsStart; +static int32_t gDiscordPartyCurrentSize; +static int32_t gDiscordPartyMaxSize; #endif static LLAppViewerListener sAppViewerListener(LLAppViewer::instance); @@ -5926,6 +5928,8 @@ void LLAppViewer::metricsSend(bool enable_reporting) void LLAppViewer::initDiscordSocial() { + gDiscordPartyCurrentSize = 1; + gDiscordPartyMaxSize = 0; gDiscordTimestampsStart = time(nullptr); gDiscordClient = std::make_shared(); gDiscordClient->SetStatusChangedCallback([](discordpp::Client::Status status, discordpp::Client::Error, int32_t) { @@ -6071,20 +6075,26 @@ void LLAppViewer::updateDiscordActivity() auto location = llformat("%s (%d, %d, %d)", gAgent.getRegion()->getName().c_str(), pos_x, pos_y, pos_z); activity.SetState(location); - auto world = LLWorld::getInstance(); - uuid_vec_t chat_radius_uuids, near_me_uuids; - auto position = gAgent.getPositionGlobal(); - world->getAvatars(&chat_radius_uuids, NULL, position, CHAT_NORMAL_RADIUS); - static LLCachedControl range(gSavedSettings, "MPVNearMeRange", 4096.0f); - world->getAvatars(&near_me_uuids, NULL, position, range); discordpp::ActivityParty party; party.SetId(location); - party.SetCurrentSize(chat_radius_uuids.size()); - party.SetMaxSize(near_me_uuids.size()); + party.SetCurrentSize(gDiscordPartyCurrentSize); + party.SetMaxSize(gDiscordPartyMaxSize); activity.SetParty(party); } gDiscordClient->UpdateRichPresence(activity, [](discordpp::ClientResult) {}); } +void LLAppViewer::updateDiscordPartyCurrentSize(int32_t size) +{ + gDiscordPartyCurrentSize = size; + updateDiscordActivity(); +} + +void LLAppViewer::updateDiscordPartyMaxSize(int32_t size) +{ + gDiscordPartyMaxSize = size; + updateDiscordActivity(); +} + #endif diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 283975833e..b60f7ae084 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -254,6 +254,8 @@ public: static void initDiscordSocial(); static void handleDiscordSocial(const LLSD& value); static void updateDiscordActivity(); + static void updateDiscordPartyCurrentSize(int32_t size); + static void updateDiscordPartyMaxSize(int32_t size); #endif protected: diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index 72fa553023..da7f524146 100644 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -843,6 +843,9 @@ void LLPanelPeople::updateNearbyList() LLWorld::getInstance()->getAvatars(&mNearbyList->getIDs(), &positions, gAgent.getPositionGlobal(), gSavedSettings.getF32("MPVNearMeRange")); mNearbyList->setDirty(); +#ifdef LL_DISCORD + LLAppViewer::updateDiscordPartyMaxSize(mNearbyList->getIDs().size()); +#endif DISTANCE_COMPARATOR.updateAvatarsPositions(positions, mNearbyList->getIDs()); LLActiveSpeakerMgr::instance().update(true); diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp index 4956c188fb..46a88ba512 100644 --- a/indra/newview/llspeakers.cpp +++ b/indra/newview/llspeakers.cpp @@ -1026,6 +1026,9 @@ void LLLocalSpeakerMgr::updateSpeakerList() uuid_vec_t avatar_ids; std::vector positions; LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, gAgent.getPositionGlobal(), CHAT_NORMAL_RADIUS); +#ifdef LL_DISCORD + LLAppViewer::updateDiscordPartyCurrentSize(avatar_ids.size()); +#endif for(U32 i=0; i