From fd16d8cc79d65636b097d247a00dbbf2b1263292 Mon Sep 17 00:00:00 2001 From: William Miller Date: Fri, 13 Sep 2024 06:47:00 -0300 Subject: Fix Discord presence crashing on Campaign (#881) Add MP/SP check to prevent running logic that would script error on SP. Also gives more accurate playercount now. --- .../mod/scripts/vscripts/presence/cl_presence.nut | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'Northstar.Client/mod/scripts') diff --git a/Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut b/Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut index 142c94ba..191ef144 100644 --- a/Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut +++ b/Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut @@ -22,14 +22,21 @@ GameStateStruct function DiscordRPC_GenerateGameState( GameStateStruct gs ) gs.mapDisplayname = Localize(GetMapDisplayName(GetMapName())) gs.playlist = GetCurrentPlaylistName() - gs.playlistDisplayname = Localize(GetCurrentPlaylistVarString("name", GetCurrentPlaylistName())) + gs.playlistDisplayname = Localize( GetCurrentPlaylistVarString( "name", GetCurrentPlaylistName() ) ) - gs.currentPlayers = GetPlayerArray().len() - gs.maxPlayers = GetCurrentPlaylistVarInt( "maxPlayers", -1 ) + int reservedCount = GetTotalPendingPlayersReserved() + int connectingCount = GetTotalPendingPlayersConnecting() + int loadingCount = GetTotalPendingPlayersLoading() + int connectedCount = GetPlayerArray().len() + int allKnownPlayersCount = reservedCount + connectingCount + loadingCount + connectedCount + + gs.currentPlayers = allKnownPlayersCount + gs.maxPlayers = GetCurrentPlaylistVarInt( "max_players", 16 ) if ( IsValid( GetLocalClientPlayer() ) ) gs.ownScore = GameRules_GetTeamScore( GetLocalClientPlayer().GetTeam() ) + #if MP if ( GameRules_GetGameMode() == FD ) { gs.playlist = "fd" // So it returns only one thing to the plugin side instead of the 5 separate difficulties FD have @@ -41,6 +48,9 @@ GameStateStruct function DiscordRPC_GenerateGameState( GameStateStruct gs ) else gs.fd_waveNumber = -1 // Tells plugin it's on Wave Break } + #else + gs.fd_waveNumber = -1 // Unecessary for campaign so return -1 + #endif gs.serverGameState = GetGameState() == -1 ? 0 : GetGameState() gs.otherHighestScore = gs.ownScore == highestScore ? secondHighest : highestScore -- cgit v1.2.3