Fixed oddities in traitor ratio/assignment logic. The TraitorUseRatio setting is used to determine the number of traitors, the minimum number of traitors is 1 instead of 2, the host is taken into account when determining the number of traitors. Closes #477

This commit is contained in:
Joonas Rikkonen
2018-07-16 11:05:10 +03:00
parent 015eacbcb0
commit ceae0bf94e
2 changed files with 7 additions and 7 deletions

View File

@@ -108,10 +108,9 @@ namespace Barotrauma
codeWords = ToolBox.GetRandomLine(wordsTxt) + ", " + ToolBox.GetRandomLine(wordsTxt);
codeResponse = ToolBox.GetRandomLine(wordsTxt) + ", " + ToolBox.GetRandomLine(wordsTxt);
while (traitorCount-- >= 0)
while (traitorCount-- > 0)
{
if (traitorCandidates.Count <= 0)
break;
if (traitorCandidates.Count <= 0) break;
int traitorIndex = Rand.Int(traitorCandidates.Count);
Character traitorCharacter = traitorCandidates[traitorIndex];

View File

@@ -1343,11 +1343,12 @@ namespace Barotrauma.Networking
List<Character> characters = new List<Character>();
foreach (Client client in ConnectedClients)
{
if (client.Character != null)
characters.Add(client.Character);
if (client.Character != null) characters.Add(client.Character);
}
var max = (int)Math.Round(characters.Count * 0.2f, 1);
var traitorCount = Math.Max(1, TraitorsEnabled == YesNoMaybe.Maybe ? Rand.Int(max) + 1 : max);
if (Character != null) characters.Add(Character);
int max = Math.Max(TraitorUseRatio ? (int)Math.Round(characters.Count * TraitorRatio, 1) : 1, 1);
int traitorCount = Rand.Int(max + 1);
TraitorManager = new TraitorManager(this, traitorCount);
if (TraitorManager.TraitorList.Count > 0)