diff options
author | Erik Kundiman <erik@megapahit.org> | 2025-07-30 17:06:44 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2025-07-30 17:06:44 +0800 |
commit | 7ddb99117ecdaa1d27719908aca6283a0f90d74e (patch) | |
tree | 20e34778d0e920133138c6cf707e2ccdd137e63d /indra | |
parent | 275bc9d0e373c8018167c8f4b0ac79e8b782d0ec (diff) |
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`.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llappviewer.cpp | 26 | ||||
-rw-r--r-- | indra/newview/llappviewer.h | 2 | ||||
-rw-r--r-- | indra/newview/llpanelpeople.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llspeakers.cpp | 3 |
4 files changed, 26 insertions, 8 deletions
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 <discordpp.h> static std::shared_ptr<discordpp::Client> 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<discordpp::Client>(); 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<F32> 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<LLVector3d> 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<avatar_ids.size(); i++) { setSpeaker(avatar_ids[i]); |