From 17982bd766791da2bbb1f02d739b6924954fb3b0 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Mon, 4 Dec 2017 21:49:56 -0700 Subject: [PATCH] Move SetConsoleTitle to utils --- TShockAPI/TShock.cs | 16 +++------------- TShockAPI/Utils.cs | 12 +++++++++++- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 4d0a8dbd..b3e91a02 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -822,7 +822,7 @@ namespace TShockAPI /// args - The EventArgs object. private void OnPostInit(EventArgs args) { - SetConsoleTitle(false); + Utils.SetConsoleTitle(false); //This is to prevent a bug where a CLI-defined password causes packets to be //sent in an unexpected order, resulting in clients being unable to connect @@ -1179,17 +1179,7 @@ namespace TShockAPI } } } - SetConsoleTitle(false); - } - - /// SetConsoleTitle - Updates the console title with some pertinent information. - /// empty - True/false if the server is empty; determines if we should use Utils.ActivePlayers() for player count or 0. - private void SetConsoleTitle(bool empty) - { - Console.Title = string.Format("{0}{1}/{2} on {3} @ {4}:{5} (TShock for Terraria v{6})", - !string.IsNullOrWhiteSpace(Config.ServerName) ? Config.ServerName + " - " : "", - empty ? 0 : Utils.ActivePlayers(), - Config.MaxSlots, Main.worldName, Netplay.ServerIP.ToString(), Netplay.ListenPort, Version); + Utils.SetConsoleTitle(false); } /// OnHardUpdate - Fired when a hardmode tile update event happens. @@ -1435,7 +1425,7 @@ namespace TShockAPI { if (Config.SaveWorldOnLastPlayerExit) SaveManager.Instance.SaveWorld(); - SetConsoleTitle(true); + Utils.SetConsoleTitle(true); } } diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index 3304acb4..eaa62dd3 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -1429,7 +1429,7 @@ namespace TShockAPI } /// FixChestStacks - Verifies that each stack in each chest is valid and not over the max stack count. - public void FixChestStacks() + internal void FixChestStacks() { if (TShock.Config.IgnoreChestStacksOnLoad) return; @@ -1446,5 +1446,15 @@ namespace TShockAPI } } } + + /// SetConsoleTitle - Updates the console title with some pertinent information. + /// empty - True/false if the server is empty; determines if we should use Utils.ActivePlayers() for player count or 0. + internal void SetConsoleTitle(bool empty) + { + Console.Title = string.Format("{0}{1}/{2} on {3} @ {4}:{5} (TShock for Terraria v{6})", + !string.IsNullOrWhiteSpace(TShock.Config.ServerName) ? TShock.Config.ServerName + " - " : "", + empty ? 0 : ActivePlayers(), + TShock.Config.MaxSlots, Main.worldName, Netplay.ServerIP.ToString(), Netplay.ListenPort, TShock.VersionNum); + } } }