From 2468ecab7e9c2d80b549fdf5cc83c2df0d32cac1 Mon Sep 17 00:00:00 2001 From: high Date: Tue, 28 Jun 2011 11:28:51 -0400 Subject: [PATCH] Moved HandleCommandLine to the start of Initialize. Made SavePath not used before HandleCommandLine so that -configpath would work. --- TShockAPI/FileTools.cs | 24 ++++++++++++------------ TShockAPI/TShock.cs | 17 ++++++++--------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/TShockAPI/FileTools.cs b/TShockAPI/FileTools.cs index d553af0c..26c9d5c3 100644 --- a/TShockAPI/FileTools.cs +++ b/TShockAPI/FileTools.cs @@ -23,17 +23,17 @@ namespace TShockAPI { internal class FileTools { - public static readonly string RulesPath = Path.Combine(TShock.SavePath, "rules.txt"); - public static readonly string MotdPath = Path.Combine(TShock.SavePath, "motd.txt"); - public static readonly string BansPath = Path.Combine(TShock.SavePath, "bans.txt"); - public static readonly string WhitelistPath = Path.Combine(TShock.SavePath, "whitelist.txt"); - public static readonly string GroupsPath = Path.Combine(TShock.SavePath, "groups.txt"); - public static readonly string UsersPath = Path.Combine(TShock.SavePath, "users.txt"); - public static readonly string ItemBansPath = Path.Combine(TShock.SavePath, "itembans.txt"); - public static readonly string RememberedPosPath = Path.Combine(TShock.SavePath, "oldpos.xml"); - public static readonly string ConfigPath = Path.Combine(TShock.SavePath, "config.json"); - public static readonly string RegionsPath = Path.Combine(TShock.SavePath, "regions.xml"); - public static readonly string WarpsPath = Path.Combine(TShock.SavePath, "warps.xml"); + public static string RulesPath { get { return Path.Combine(TShock.SavePath, "rules.txt"); } } + public static string MotdPath { get { return Path.Combine(TShock.SavePath, "motd.txt"); } } + public static string BansPath { get { return Path.Combine(TShock.SavePath, "bans.txt"); } } + public static string WhitelistPath { get { return Path.Combine(TShock.SavePath, "whitelist.txt"); } } + public static string GroupsPath { get { return Path.Combine(TShock.SavePath, "groups.txt"); } } + public static string UsersPath { get { return Path.Combine(TShock.SavePath, "users.txt"); } } + public static string ItemBansPath { get { return Path.Combine(TShock.SavePath, "itembans.txt"); } } + public static string RememberedPosPath { get { return Path.Combine(TShock.SavePath, "oldpos.xml"); } } + public static string ConfigPath { get { return Path.Combine(TShock.SavePath, "config.json"); } } + public static string RegionsPath { get { return Path.Combine(TShock.SavePath, "regions.xml"); } } + public static string WarpsPath { get { return Path.Combine(TShock.SavePath, "warps.xml"); } } public static void CreateFile(string file) { @@ -69,7 +69,7 @@ namespace TShockAPI //Copies if using old paths (Remove in future releases, after everyone is running this version +) if (File.Exists("regions.xml") && !File.Exists(RegionsPath)) { - File.Move("regions.xml", RegionsPath); + File.Move("regions.xml", RegionsPath); } else { diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 19e71a65..edbed599 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -40,8 +40,8 @@ namespace TShockAPI public static string SavePath = "tshock"; public static TSPlayer[] Players = new TSPlayer[Main.maxPlayers]; - public static BanManager Bans = new BanManager(Path.Combine(SavePath, "bans.txt")); - public static BackupManager Backups = new BackupManager(Path.Combine(SavePath, "backups")); + public static BanManager Bans; + public static BackupManager Backups; public override Version Version { @@ -70,14 +70,15 @@ namespace TShockAPI public override void Initialize() { + HandleCommandLine(Environment.GetCommandLineArgs()); + + Bans = new BanManager(FileTools.BansPath); + Backups = new BackupManager(Path.Combine(SavePath, "backups")); + FileTools.SetupConfig(); - string version = string.Format("TShock Version {0} ({1}) now running.", Version, VersionCodename); - Console.WriteLine(version); - Log.Initialize(Path.Combine(SavePath, "log.txt"), LogLevel.All, false); - - Log.Info(version); + Log.ConsoleInfo(string.Format("TShock Version {0} ({1}) now running.", Version, VersionCodename)); Log.Info("Starting..."); GameHooks.PostInitialize += OnPostInit; @@ -113,8 +114,6 @@ namespace TShockAPI Log.ConsoleInfo("AutoSave " + (ConfigurationManager.AutoSave ? "Enabled" : "Disabled")); Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled")); - - HandleCommandLine(Environment.GetCommandLineArgs()); } public override void DeInitialize()