From 42c7a2b030a1080b6679e8caccd08b162c9a8a29 Mon Sep 17 00:00:00 2001 From: White Date: Sun, 19 Mar 2017 10:06:45 +1030 Subject: [PATCH] Resolved a bug in CommandLineParser, which caused servers started with a single argumentless flag to not parse the flag. Closes #1411 --- TShockAPI/CLI/CommandLineParser.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/TShockAPI/CLI/CommandLineParser.cs b/TShockAPI/CLI/CommandLineParser.cs index 84c34b94..7106abbe 100644 --- a/TShockAPI/CLI/CommandLineParser.cs +++ b/TShockAPI/CLI/CommandLineParser.cs @@ -165,10 +165,14 @@ namespace TShockAPI.CLI { _source = source; - for (int i = 0; i < source.Length - 1; i++) + for (int i = 0; i < (source.Length - 1 == 0 ? 1 : source.Length - 1); i++) { string flag = source[i].ToLowerInvariant(); - string argument = source[i + 1]; + string argument = null; + if (i + 1 < source.Length) + { + argument = source[i + 1]; + } FlagSet flags = _flags.FirstOrDefault(f => f.Contains(flag)); if (flags == null)