Remove format string in server name from Discord rich presence (#18159)

This commit is contained in:
Meehoi 2022-10-03 05:01:24 +07:00 committed by GitHub
parent ec12892dba
commit 5cb9b8be15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 2 deletions

View File

@ -8,7 +8,6 @@
*****************************************************************************/
#ifdef __ENABLE_DISCORD__
# include "DiscordService.h"
# include "../Context.h"
@ -16,6 +15,7 @@
# include "../OpenRCT2.h"
# include "../core/Console.hpp"
# include "../core/String.hpp"
# include "../localisation/Formatting.h"
# include "../localisation/Localisation.h"
# include "../world/Park.h"
# include "network.h"
@ -99,7 +99,23 @@ void DiscordService::RefreshPresence() const
}
else
{
state = String::ToStd(network_get_server_name());
OpenRCT2::FmtString fmtServerName(network_get_server_name());
std::string serverName;
for (const auto& token : fmtServerName)
{
if (token.IsLiteral())
{
serverName += token.text;
}
else if (token.IsCodepoint())
{
auto codepoint = token.GetCodepoint();
char buffer[8]{};
utf8_write_codepoint(buffer, codepoint);
serverName += buffer;
}
}
state = serverName;
// NOTE: the party size is displayed next to state
discordPresence.partyId = network_get_server_name();