Skip to content

Commit

Permalink
Improved discord RPC startTimestamp timing
Browse files Browse the repository at this point in the history
  • Loading branch information
JariKCoding committed Apr 12, 2022
1 parent d506418 commit 00efd17
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/client/components/discord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ namespace discord
int roundsPlayed;
int playerScore;
int enemyScore;
bool isIngame = false;

void update_discord()
{
Discord_RunCallbacks();

if (game::Com_IsRunningUILevel())
if (!isIngame)
{
discord_presence.details = game::Com_SessionMode_IsMode(game::eModes::MODE_CAMPAIGN) ? "Campaign" : game::Com_SessionMode_IsMode(game::eModes::MODE_MULTIPLAYER) ? "Multiplayer" : "Zombies";
discord_presence.state = "Lobby";
Expand Down Expand Up @@ -129,6 +130,7 @@ namespace discord

void start_hooks() override
{
isIngame = true;
std::string raw_lua =
"LUI.roots.UIRoot0:subscribeToGlobalModel(0, 'GameScore', 'roundsPlayed', function(model) "
"local roundsPlayed = Engine.GetModelValue(model); "
Expand All @@ -151,6 +153,11 @@ namespace discord
hks::execute_raw_lua(raw_lua, "DiscordScoreModels");
}

void destroy_hooks() override
{
isIngame = false;
}

private:
static inline bool initialized_ = false;

Expand Down

0 comments on commit 00efd17

Please sign in to comment.