[Discord]: Make sure partyId is at least 2 chars (#871)

This commit is contained in:
Edo 2023-03-23 12:02:43 +00:00 committed by GitHub
parent 58bf01196e
commit b4500226dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,6 +62,8 @@ namespace Components
return; return;
} }
char hostNameBuffer[256]{};
const auto* map = Game::UI_GetMapDisplayName((*Game::ui_mapname)->current.string); const auto* map = Game::UI_GetMapDisplayName((*Game::ui_mapname)->current.string);
const Game::StringTable* table; const Game::StringTable* table;
@ -86,7 +88,6 @@ namespace Components
} }
else else
{ {
char hostNameBuffer[256]{};
TextRenderer::StripColors(Party::GetHostName().data(), hostNameBuffer, sizeof(hostNameBuffer)); TextRenderer::StripColors(Party::GetHostName().data(), hostNameBuffer, sizeof(hostNameBuffer));
TextRenderer::StripAllTextIcons(hostNameBuffer, hostNameBuffer, sizeof(hostNameBuffer)); TextRenderer::StripAllTextIcons(hostNameBuffer, hostNameBuffer, sizeof(hostNameBuffer));
@ -97,7 +98,7 @@ namespace Components
std::hash<Network::Address> hashFn; std::hash<Network::Address> hashFn;
const auto address = Party::Target(); const auto address = Party::Target();
DiscordPresence.partyId = Utils::String::VA("%zu", hashFn(address) ^ GetDiscordNonce()); DiscordPresence.partyId = Utils::String::VA("%s - %zu", hostNameBuffer, hashFn(address) ^ GetDiscordNonce());
DiscordPresence.joinSecret = address.getCString(); DiscordPresence.joinSecret = address.getCString();
DiscordPresence.partySize = Game::cgArray[0].snap ? Game::cgArray[0].snap->numClients : 1; DiscordPresence.partySize = Game::cgArray[0].snap ? Game::cgArray[0].snap->numClients : 1;
DiscordPresence.partyMax = Party::GetMaxClients(); DiscordPresence.partyMax = Party::GetMaxClients();