Skip to content

Commit

Permalink
Modify state formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Lpsd committed Oct 12, 2023
1 parent 55d6b76 commit 061ef41
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 11 additions & 1 deletion Client/core/CSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3457,7 +3457,17 @@ void CSettings::SaveData()
auto discord = g_pCore->GetDiscord();

if (discord)
discord->SetPresenceState(CCore::GetSingleton().IsConnected() ? SString("In-game (%s)", g_pCore->GetLastConnectedServerName()) : "Main menu", false);
{
SString state = "Main menu";

if (CCore::GetSingleton().IsConnected())
{
SString serverName = g_pCore->GetLastConnectedServerName();
state = (serverName.length() > 0) ? SString("In-game (%s)", serverName) : "In-game";
}

discord->SetPresenceState(state, false);
}
}

// Grass
Expand Down
7 changes: 5 additions & 2 deletions Client/mods/deathmatch/logic/CPacketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,11 @@ void CPacketHandler::Packet_ServerJoined(NetBitStreamInterface& bitStream)
std::string serverName;
bitStream.ReadString(serverName);

g_pCore->SetLastConnectedServerName(serverName);
discord->SetPresenceState(SString("In-game (%s)", serverName), false);
if (serverName.length() > 0)
{
g_pCore->SetLastConnectedServerName(serverName);
discord->SetPresenceState(SString("In-game (%s)", serverName), false);
}
}
}

Expand Down

0 comments on commit 061ef41

Please sign in to comment.