Move all startup arguments to TShock from API

This commit is contained in:
George 2015-07-17 22:14:54 +01:00
parent 07d4b397e2
commit 8cf78be440
2 changed files with 163 additions and 31 deletions

View file

@ -533,6 +533,7 @@ namespace TShockAPI
switch (parms[i].ToLower()) switch (parms[i].ToLower())
{ {
case "-configpath": case "-configpath":
{
path = parms[++i]; path = parms[++i];
if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1) if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1)
{ {
@ -540,8 +541,9 @@ namespace TShockAPI
ServerApi.LogWriter.PluginWriteLine(this, "Config path has been set to " + path, TraceLevel.Info); ServerApi.LogWriter.PluginWriteLine(this, "Config path has been set to " + path, TraceLevel.Info);
} }
break; break;
}
case "-worldpath": case "-worldpath":
{
path = parms[++i]; path = parms[++i];
if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1) if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1)
{ {
@ -549,8 +551,9 @@ namespace TShockAPI
ServerApi.LogWriter.PluginWriteLine(this, "World path has been set to " + path, TraceLevel.Info); ServerApi.LogWriter.PluginWriteLine(this, "World path has been set to " + path, TraceLevel.Info);
} }
break; break;
}
case "-logpath": case "-logpath":
{
path = parms[++i]; path = parms[++i];
if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1) if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1)
{ {
@ -558,16 +561,19 @@ namespace TShockAPI
ServerApi.LogWriter.PluginWriteLine(this, "Log path has been set to " + path, TraceLevel.Info); ServerApi.LogWriter.PluginWriteLine(this, "Log path has been set to " + path, TraceLevel.Info);
} }
break; break;
}
case "-logformat": case "-logformat":
{
LogFormat = parms[++i]; LogFormat = parms[++i];
break; break;
}
case "-logclear": case "-logclear":
{
bool.TryParse(parms[++i], out LogClear); bool.TryParse(parms[++i], out LogClear);
break; break;
}
case "-dump": case "-dump":
{
ConfigFile.DumpDescriptions(); ConfigFile.DumpDescriptions();
Permissions.DumpDescriptions(); Permissions.DumpDescriptions();
ServerSideConfig.DumpDescriptions(); ServerSideConfig.DumpDescriptions();
@ -575,6 +581,132 @@ namespace TShockAPI
Environment.Exit(1); Environment.Exit(1);
break; break;
} }
case "-config":
{
string filePath = parms[++i];
ServerApi.LogWriter.PluginWriteLine(this, string.Format("Loading dedicated config file: {0}", filePath), TraceLevel.Verbose);
Main.instance.LoadDedConfig(filePath);
break;
}
case "-port":
{
int serverPort;
if (int.TryParse(parms[++i], out serverPort))
{
Netplay.ListenPort = serverPort;
ServerApi.LogWriter.PluginWriteLine(this, string.Format("Listening on port {0}.", serverPort), TraceLevel.Verbose);
}
else
{
// The server should not start up if this argument is invalid.
throw new InvalidOperationException("Invalid value given for command line argument \"-ip\".");
}
break;
}
case "-world":
{
string worldPath = parms[++i];
Main.instance.SetWorld(worldPath);;
ServerApi.LogWriter.PluginWriteLine(this, string.Format("World set for auto loading: {0}", worldPath), TraceLevel.Verbose);
break;
}
case "-worldname":
{
string worldName = parms[++i];
Main.instance.SetWorldName(worldName);
ServerApi.LogWriter.PluginWriteLine(this, string.Format("World name will be overridden by: {0}", worldName), TraceLevel.Verbose);
break;
}
case "-autoshutdown":
{
Main.instance.autoShut();
break;
}
case "-autocreate":
{
string newOpt = parms[++i];
Main.instance.autoCreate(newOpt);
break;
}
case "-ip":
{
IPAddress ip;
if (IPAddress.TryParse(parms[++i], out ip))
{
Netplay.ServerIP = ip;
ServerApi.LogWriter.PluginWriteLine(this, string.Format("Listening on IP {0}.", ip), TraceLevel.Verbose);
}
else
{
// The server should not start up if this argument is invalid.
throw new InvalidOperationException("Invalid value given for command line argument \"-ip\".");
}
break;
}
case "-connperip":
{
int limit;
if (int.TryParse(parms[++i], out limit))
{
Netplay.MaxConnections = limit;
ServerApi.LogWriter.PluginWriteLine(this, string.Format(
"Connections per IP have been limited to {0} connections.", limit), TraceLevel.Verbose);
}
else
ServerApi.LogWriter.PluginWriteLine(this, "Invalid value given for command line argument \"-connperip\".", TraceLevel.Warning);
break;
}
case "-killinactivesocket":
{
// Netplay.killInactive = true;
ServerApi.LogWriter.PluginWriteLine(this, "The argument -killinactivesocket is no longer present in Terraria.", TraceLevel.Warning);
break;
}
case "-lang":
{
int langIndex;
if (int.TryParse(parms[++i], out langIndex))
{
Lang.lang = langIndex;
ServerApi.LogWriter.PluginWriteLine(this, string.Format("Language index set to {0}.", langIndex), TraceLevel.Verbose);
}
else
ServerApi.LogWriter.PluginWriteLine(this, "Invalid value given for command line argument \"-lang\".", TraceLevel.Warning);
break;
}
case "-ignoreversion":
{
ServerApi.IgnoreVersion = true;
ServerApi.LogWriter.PluginWriteLine(this,
"Plugin versions are no longer being regarded, you are on your own! If problems arise, TShock developers will not help you with issues regarding this.",
TraceLevel.Warning);
break;
}
case "-forceupdate":
{
ServerApi.ForceUpdate = true;
ServerApi.LogWriter.PluginWriteLine(this,
"Forcing game updates regardless of players! This is experimental, and will cause constant CPU usage, you are on your own.",
TraceLevel.Warning);
break;
}
case "-asyncmono":
{
ServerApi.UseAsyncSocketsInMono = true;
ServerApi.LogWriter.PluginWriteLine(this,
"Forcing Mono to use asynchronous sockets. This is highly experimental and may not work on all versions of Mono.",
TraceLevel.Warning);
break;
}
}
} }
} }

@ -1 +1 @@
Subproject commit e00a8175feef23bb2cc53d1e0dd00c42b62d3e65 Subproject commit 0672f953608a6627923b34cff164641ac55d68ba