Fixed EndGame not working properly + Fixed exception when clients disconnected during a round

This commit is contained in:
juanjp600
2017-06-22 15:20:11 -03:00
parent c1780fa7b7
commit 72d5cb227b
5 changed files with 47 additions and 14 deletions
+37 -1
View File
@@ -33,10 +33,46 @@ namespace Barotrauma
public static List<ColoredText> Messages = new List<ColoredText>();
private static string[] SplitCommand(string command)
{
command = command.Trim();
List<string> commands = new List<string>();
int escape = 0;
bool inQuotes = false;
string piece = "";
for (int i=0;i<command.Length;i++)
{
if (command[i] == '\\')
{
if (escape == 0) escape = 2;
else piece += '\\';
}
else if (command[i] == '"')
{
if (escape == 0) inQuotes = !inQuotes;
else piece += '"';
}
else if (command[i] == ' ' && !inQuotes)
{
if (!string.IsNullOrWhiteSpace(piece)) commands.Add(piece);
piece = "";
}
else if (escape == 0) piece += command[i];
if (escape > 0) escape--;
}
if (!string.IsNullOrWhiteSpace(piece)) commands.Add(piece); //add final piece
return commands.ToArray();
}
public static void ExecuteCommand(string command, GameMain game)
{
if (string.IsNullOrWhiteSpace(command)) return;
string[] commands = command.Split(' ');
string[] commands = SplitCommand(command);
if (!commands[0].ToLowerInvariant().Equals("admin"))
{