Skip to content

Commit

Permalink
Merge pull request Pryaxis#187 from Pryaxis/difficulty
Browse files Browse the repository at this point in the history
Add -difficulty cli flag
  • Loading branch information
QuiCM committed May 13, 2021
2 parents 96c1bc9 + f561535 commit e82ea40
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions TerrariaServerAPI/TerrariaApi.Server/ServerApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ internal static void HandleCommandLine(string[] parms)
{
Dictionary<string, string> args = Utils.ParseArguements(parms);

bool isAutoCreating = false;

foreach (KeyValuePair<string, string> arg in args)
{
switch (arg.Key.ToLower())
Expand Down Expand Up @@ -225,6 +227,30 @@ internal static void HandleCommandLine(string[] parms)
case "-autocreate":
{
game.autoCreate(arg.Value);
isAutoCreating = true;

break;
}
case "-difficulty":
{
if (!isAutoCreating)
{
LogWriter.ServerWriteLine("Ignoring difficulty command line flag because server is starting in interactive mode without autocreate", TraceLevel.Warning);
continue;
}

// If the arg isn't an integer, or its an incorrect value, we want to ignore it
if (int.TryParse(arg.Value, out int dif))
{
if (dif >= 0 && dif <= 3)
{
Main.GameMode = dif;
}
}
else
{
LogWriter.ServerWriteLine("Unexpected difficulty value. Expected values are 0-3.", TraceLevel.Warning);
}

break;
}
Expand Down

0 comments on commit e82ea40

Please sign in to comment.