summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2025-07-28 20:36:54 +0800
committerErik Kundiman <erik@megapahit.org>2025-07-28 20:36:54 +0800
commitb7d33485406150bf466f61477cfd33d9bdacb705 (patch)
treef366e6cb5ebdc5ddd8224ca6a085eb51ab5278f7
parentc1adf320af2ca2afd9ed05cccc9031b99fc7ee60 (diff)
Discord time elapsed not reset on region change
Time elapses right after viewer launch even before login. Plus parameter name change in header to make it the same as in implementation.
-rw-r--r--indra/newview/llappviewer.cpp14
-rw-r--r--indra/newview/llappviewer.h2
2 files changed, 12 insertions, 4 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 2ea8b65ee1..b5175fbf71 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -282,6 +282,7 @@ using namespace LL;
#define DISCORDPP_IMPLEMENTATION
#include <discordpp.h>
static std::shared_ptr<discordpp::Client> gDiscordClient;
+static uint64_t gDiscordTimestampsStart;
#endif
static LLAppViewerListener sAppViewerListener(LLAppViewer::instance);
@@ -5922,6 +5923,7 @@ void LLAppViewer::metricsSend(bool enable_reporting)
void LLAppViewer::initDiscordSocial()
{
+ gDiscordTimestampsStart = time(nullptr);
gDiscordClient = std::make_shared<discordpp::Client>();
gDiscordClient->SetStatusChangedCallback([](discordpp::Client::Status status, discordpp::Client::Error, int32_t) {
if (status == discordpp::Client::Status::Ready)
@@ -5980,11 +5982,17 @@ void LLAppViewer::handleDiscordSocial(const LLSD& value)
void LLAppViewer::updateDiscordActivity()
{
- if (gAgent.getID() == LLUUID::null)
- return;
-
discordpp::Activity activity;
activity.SetType(discordpp::ActivityTypes::Playing);
+ discordpp::ActivityTimestamps timestamps;
+ timestamps.SetStart(gDiscordTimestampsStart);
+ activity.SetTimestamps(timestamps);
+
+ if (gAgent.getID() == LLUUID::null)
+ {
+ gDiscordClient->UpdateRichPresence(activity, [](discordpp::ClientResult) {});
+ return;
+ }
if (gSavedSettings.getBOOL("ShowDiscordActivityDetails"))
{
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index 2185295b30..283975833e 100644
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -252,7 +252,7 @@ public:
#ifdef LL_DISCORD
static void initDiscordSocial();
- static void handleDiscordSocial(const LLSD& newvalue);
+ static void handleDiscordSocial(const LLSD& value);
static void updateDiscordActivity();
#endif