From 233f7d417b1447459fbecff5222ef6094476f44b Mon Sep 17 00:00:00 2001 From: Shank Date: Wed, 8 Jun 2011 15:59:17 -0600 Subject: [PATCH] Version tick 2.0.0.7 --- TShockAPI/TShock.cs | 2 +- TShockAPI/UpdateManager.cs | 160 ++++++++++++++++++------------------- 2 files changed, 81 insertions(+), 81 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 85d6278b..08b07b3d 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -21,7 +21,7 @@ namespace TShockAPI public static Version VersionNum = new Version(2, 0, 0, 6); - public static string VersionCodename = "UnrealIRCd ftw (irc.shankshock.com #terraria)"; + public static string VersionCodename = "RSaC (Red Sucks at Coding)"; private static bool[] BlacklistTiles; diff --git a/TShockAPI/UpdateManager.cs b/TShockAPI/UpdateManager.cs index 6dcdc154..5c8dab3e 100644 --- a/TShockAPI/UpdateManager.cs +++ b/TShockAPI/UpdateManager.cs @@ -1,91 +1,91 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; using System.Text; using System.Threading; using System.Threading.Tasks; using Terraria; -namespace TShockAPI -{ - class UpdateManager - { - static string updateUrl = "http://shankshock.com/tshock-update.txt"; - public static bool updateCmd; - public static DateTime lastcheck = DateTime.MinValue; +namespace TShockAPI +{ + class UpdateManager + { + static string updateUrl = "http://shankshock.com/tshock-update.txt"; + public static bool updateCmd; + public static DateTime lastcheck = DateTime.MinValue; public static string[] globalChanges = {}; /// /// Check once every X minutes. /// - static readonly int CheckXMinutes = 30; - /// - /// Checks to see if the server is out of date. - /// - /// - public static bool ServerIsOutOfDate() - { - WebClient client = new WebClient(); - client.Headers.Add("user-agent", - "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705;)"); - try - { - string updateString = client.DownloadString(updateUrl); - string[] changes = updateString.Split(','); - Version updateVersion = new Version(Convert.ToInt32(changes[0]), Convert.ToInt32(changes[1]), - Convert.ToInt32(changes[2]), Convert.ToInt32(changes[3])); - if (TShock.VersionNum.CompareTo(updateVersion) < 0) - { - globalChanges = changes; - return true; - } - } - catch (Exception e) - { - FileTools.WriteError(e.Message); - } - return false; - } - - public static void EnableUpdateCommand() - { - Commands.commands.Add(new Commands.Command("updatenow", "maintenance", Commands.UpdateNow)); - updateCmd = true; - } - - public static void NotifyAdministrators(string[] changes) - { - for (int i = 0; i < Main.maxPlayers; i++) - { - if (Main.player[i].active) - { - if (!TShock.players[i].group.HasPermission("maintenance")) - return; - Tools.SendMessage(i, "The server is out of date. To update, type /updatenow."); - for (int j = 4; j < changes.Length; j++) - { - Tools.SendMessage(i, changes[j], 255, 0, 0); - } - } - } - } - - public static void UpdateProcedureCheck() + static readonly int CheckXMinutes = 30; + /// + /// Checks to see if the server is out of date. + /// + /// + public static bool ServerIsOutOfDate() { - if ((DateTime.Now - lastcheck).TotalMinutes >= CheckXMinutes) - { + WebClient client = new WebClient(); + client.Headers.Add("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705;)"); + try + { + string updateString = client.DownloadString(updateUrl); + string[] changes = updateString.Split(','); + Version updateVersion = new Version(Convert.ToInt32(changes[0]), Convert.ToInt32(changes[1]), + Convert.ToInt32(changes[2]), Convert.ToInt32(changes[3])); + if (TShock.VersionNum.CompareTo(updateVersion) < 0) + { + globalChanges = changes; + return true; + } + } + catch (Exception e) + { + FileTools.WriteError(e.Message); + } + return false; + } + + public static void EnableUpdateCommand() + { + Commands.commands.Add(new Commands.Command("updatenow", "maintenance", Commands.UpdateNow)); + updateCmd = true; + } + + public static void NotifyAdministrators(string[] changes) + { + for (int i = 0; i < Main.maxPlayers; i++) + { + if (Main.player[i].active) + { + if (!TShock.players[i].group.HasPermission("maintenance")) + return; + Tools.SendMessage(i, "The server is out of date. To update, type /updatenow."); + for (int j = 4; j < changes.Length; j++) + { + Tools.SendMessage(i, changes[j], 255, 0, 0); + } + } + } + } + + public static void UpdateProcedureCheck() + { + if ((DateTime.Now - lastcheck).TotalMinutes >= CheckXMinutes) + { ThreadPool.QueueUserWorkItem(CheckUpdate); - lastcheck = DateTime.Now; - } - } - - public static void CheckUpdate(object o) - { - if (ServerIsOutOfDate()) - { - EnableUpdateCommand(); - NotifyAdministrators(globalChanges); - } - } - } -} + lastcheck = DateTime.Now; + } + } + + public static void CheckUpdate(object o) + { + if (ServerIsOutOfDate()) + { + EnableUpdateCommand(); + NotifyAdministrators(globalChanges); + } + } + } +}