Skip to content

Commit

Permalink
Merge pull request #286 from CitiesSkylinesMultiplayer/fix-null-mods
Browse files Browse the repository at this point in the history
Fix exception on empty mod list
  • Loading branch information
DominicMaas authored Sep 15, 2022
2 parents 51c638c + 52f1a8a commit 0970697
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/csm/Commands/Handler/Internal/ConnectionRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ public void HandleOnServer(ConnectionRequestCommand command, NetPeer peer)
}

List<string> mods = ModSupport.Instance.RequiredModsForSync;
if (!command.Mods.SequenceEqual(mods))
List<string> clientMods = command.Mods ?? new List<string>();
if (!clientMods.SequenceEqual(mods))
{
Log.Info($"Connection rejected: List of mods [{string.Join(", ", command.Mods.ToArray())}] (client) and [{string.Join(", ", mods.ToArray())}] (server) differ.");
Log.Info($"Connection rejected: List of mods [{string.Join(", ", clientMods.ToArray())}] (client) and [{string.Join(", ", mods.ToArray())}] (server) differ.");
CommandInternal.Instance.SendToClient(peer, new ConnectionResultCommand
{
Success = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected override void Handle(ConnectionResultCommand command)
else if (command.Reason.Contains("Mods"))
{
List<string> clientMods = ModSupport.Instance.RequiredModsForSync;
List<string> serverMods = command.Mods;
List<string> serverMods = command.Mods ?? new List<string>();

IEnumerable<string> clientNotServer = clientMods.Where(mod => !serverMods.Contains(mod));
IEnumerable<string> serverNotClient = serverMods.Where(mod => !clientMods.Contains(mod));
Expand Down

0 comments on commit 0970697

Please sign in to comment.