Fixed server failing to assign jobs to all clients on some modded servers: if the max amount of players per job had been reached on all the jobs the client has in their preferences, the client would not get a job at all (causing crashes later on when trying to access the client's job). Now the server assigns a random job if none of the preferred jobs are available.

+ Fix for exceptions in Client constructor if there are less than 3 job prefabs.
This commit is contained in:
Joonas Rikkonen
2017-08-01 19:46:24 +03:00
parent 7553d63a99
commit 1e11d5ab28
2 changed files with 47 additions and 26 deletions
@@ -111,7 +111,7 @@ namespace Barotrauma.Networking
votes = new object[Enum.GetNames(typeof(VoteType)).Length];
jobPreferences = new List<JobPrefab>(JobPrefab.List.GetRange(0, 3));
jobPreferences = new List<JobPrefab>(JobPrefab.List.GetRange(0, Math.Min(JobPrefab.List.Count, 3)));
entityEventLastSent = new Dictionary<UInt16, float>();
}
@@ -135,7 +135,7 @@ namespace Barotrauma.Networking
name = name.Substring(0, 20);
}
string rName = "";
for (int i=0;i<name.Length;i++)
for (int i = 0; i < name.Length; i++)
{
if (name[i] < 32)
{