Skip to content

Commit

Permalink
gracefully handle when infoString does not include all expected data
Browse files Browse the repository at this point in the history
  • Loading branch information
RaidMax committed Jul 9, 2022
1 parent 1fc418c commit f5f5084
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions Application/IW4MServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -689,23 +689,50 @@ await Manager.GetPenaltyService().RemoveActivePenalties(E.Target.AliasLinkId, E.

else
{
Gametype = dict["gametype"];
Hostname = dict["hostname"];
if (dict.ContainsKey("gametype"))
{
Gametype = dict["gametype"];
}

if (dict.ContainsKey("hostname"))
{
Hostname = dict["hostname"];
}

string mapname = dict["mapname"] ?? CurrentMap.Name;
UpdateMap(mapname);
var newMapName = dict.ContainsKey("mapname")
? dict["mapname"] ?? CurrentMap.Name
: CurrentMap.Name;
UpdateMap(newMapName);
}
}

else
{
var dict = (Dictionary<string, string>) E.Extra;
Gametype = dict["g_gametype"];
Hostname = dict["sv_hostname"];
MaxClients = int.Parse(dict["sv_maxclients"]);
var dict = (Dictionary<string, string>)E.Extra;
if (dict.ContainsKey("g_gametype"))
{
Gametype = dict["g_gametype"];
}

if (dict.ContainsKey("sv_hostname"))
{
Hostname = dict["sv_hostname"];
}

string mapname = dict["mapname"];
UpdateMap(mapname);
if (dict.ContainsKey("sv_maxclients"))
{
MaxClients = int.Parse(dict["sv_maxclients"]);
}

else if (dict.ContainsKey("com_maxclients"))
{
MaxClients = int.Parse(dict["com_maxclients"]);
}

if (dict.ContainsKey("mapname"))
{
UpdateMap(dict["mapname"]);
}
}

if (E.GameTime.HasValue)
Expand Down

0 comments on commit f5f5084

Please sign in to comment.