Skip to content

Commit

Permalink
fixed issue where corrupted lobby server message can lead to null pla…
Browse files Browse the repository at this point in the history
…yer be tracked by infra and then failing in !ring etc. fix #2998
  • Loading branch information
Licho1 committed Jan 7, 2025
1 parent 9fd83d5 commit 504ebc4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Shared/LobbyClient/Spring.SpringBattleContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class SpringBattleContext

public BattlePlayerResult GetOrAddPlayer(string name)
{
if (string.IsNullOrEmpty(name)) return null; // we don't want to add null players

var ret = ActualPlayers.FirstOrDefault(y => y.Name == name);
if (ret == null)
{
Expand Down
2 changes: 1 addition & 1 deletion ZkLobbyServer/ServerBattle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public List<string> GetAllUserNames()
{
var ret = Users.Select(x => x.Key).ToList();
if (spring.IsRunning) ret.AddRange(spring.Context.ActualPlayers.Select(x => x.Name));
return ret.Distinct().ToList();
return ret.Distinct().Where(x=>x!=null).ToList();
}

public BattleCommand GetCommandByName(string name)
Expand Down
2 changes: 1 addition & 1 deletion ZkLobbyServer/autohost/Commands/CmdKick.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private bool NotifyAdminChannel(ServerBattle battle, Say e, bool isActualKick)
{
gtype = string.Format("game on map {0}", battle.MapName);
PlasmaShared.BattlePlayerResult res = battle.spring.Context.GetOrAddPlayer(target);
isspec = res.IsSpectator;
isspec = res?.IsSpectator == true;
}
else
{
Expand Down

0 comments on commit 504ebc4

Please sign in to comment.