diff --git a/src/component/discord.cpp b/src/component/discord.cpp index db770c37..9a8ea371 100644 --- a/src/component/discord.cpp +++ b/src/component/discord.cpp @@ -1,8 +1,11 @@ #include #include "loader/component_loader.hpp" -#include "scheduler.hpp" + #include "game/game.hpp" +#include "scheduler.hpp" +#include "command.hpp" + #include #include @@ -12,6 +15,7 @@ namespace discord namespace { DiscordRichPresence discord_presence; + std::string state; void update_discord() { @@ -32,7 +36,7 @@ namespace discord const auto mapname = game::UI_SafeTranslateString(utils::string::va("PRESENCE_SP_%s", map)); discord_presence.details = mapname; - discord_presence.state = ""; + discord_presence.state = state.data(); if (!discord_presence.startTimestamp) { @@ -64,6 +68,17 @@ namespace discord scheduler::loop(update_discord, scheduler::pipeline::async, 5s); initialized_ = true; + + command::add("setdiscordstate", [](const command::params& params) + { + const std::string _state = params.join(1); + + scheduler::once([_state]() + { + state = _state; + update_discord(); + }, scheduler::pipeline::async); + }); } private: @@ -74,6 +89,7 @@ namespace discord ZeroMemory(&discord_presence, sizeof(discord_presence)); discord_presence.instance = 1; + discord_presence.state = ""; Discord_UpdatePresence(&discord_presence); } diff --git a/src/game/scripting/lua/context.cpp b/src/game/scripting/lua/context.cpp index e08da0e7..fe4a4a82 100644 --- a/src/game/scripting/lua/context.cpp +++ b/src/game/scripting/lua/context.cpp @@ -170,6 +170,11 @@ namespace scripting::lua command::execute(command, false); }; + game_type["setdiscordstate"] = [](const game&, const std::string& state) + { + command::execute(utils::string::va("setdiscordstate %s", state.data()), false); + }; + game_type["say"] = [](const game&, const std::string& msg) { chat::print(msg); diff --git a/src/game/symbols.hpp b/src/game/symbols.hpp index 8953fc60..bf862fbb 100644 --- a/src/game/symbols.hpp +++ b/src/game/symbols.hpp @@ -76,7 +76,7 @@ namespace game WEAK symbol g_assetNames{0xBEF280}; - WEAK symbol g_entities{0x52DDEC0}; + WEAK symbol g_entities{0x52DDDA0}; WEAK symbol keyCatchers{0x203F3C0};