diff options
author | William Miller <william-millennium@hotmail.com> | 2024-09-13 06:47:00 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-13 11:47:00 +0200 |
commit | fd16d8cc79d65636b097d247a00dbbf2b1263292 (patch) | |
tree | 9488d58f9cc30f5f692ea417fc6ab6d1a0ca930f /Northstar.Client/mod/scripts | |
parent | 6437c5eef53e921613946f309f51ac441e08bdf0 (diff) | |
download | NorthstarMods-1.28.2-rc1.tar.gz NorthstarMods-1.28.2-rc1.zip |
Fix Discord presence crashing on Campaign (#881)v1.28.2-rc1
Add MP/SP check to prevent running logic that would script error on SP.
Also gives more accurate playercount now.
Diffstat (limited to 'Northstar.Client/mod/scripts')
-rw-r--r-- | Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut | 16 |
1 files changed, 13 insertions, 3 deletions
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 |