Skip to content

Commit 504ebc4

Browse files
committed
fixed issue where corrupted lobby server message can lead to null player be tracked by infra and then failing in !ring etc. fix #2998
1 parent 9fd83d5 commit 504ebc4

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

Shared/LobbyClient/Spring.SpringBattleContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class SpringBattleContext
4747

4848
public BattlePlayerResult GetOrAddPlayer(string name)
4949
{
50+
if (string.IsNullOrEmpty(name)) return null; // we don't want to add null players
51+
5052
var ret = ActualPlayers.FirstOrDefault(y => y.Name == name);
5153
if (ret == null)
5254
{

ZkLobbyServer/ServerBattle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public List<string> GetAllUserNames()
181181
{
182182
var ret = Users.Select(x => x.Key).ToList();
183183
if (spring.IsRunning) ret.AddRange(spring.Context.ActualPlayers.Select(x => x.Name));
184-
return ret.Distinct().ToList();
184+
return ret.Distinct().Where(x=>x!=null).ToList();
185185
}
186186

187187
public BattleCommand GetCommandByName(string name)

ZkLobbyServer/autohost/Commands/CmdKick.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private bool NotifyAdminChannel(ServerBattle battle, Say e, bool isActualKick)
9090
{
9191
gtype = string.Format("game on map {0}", battle.MapName);
9292
PlasmaShared.BattlePlayerResult res = battle.spring.Context.GetOrAddPlayer(target);
93-
isspec = res.IsSpectator;
93+
isspec = res?.IsSpectator == true;
9494
}
9595
else
9696
{

0 commit comments

Comments
 (0)