using System; using System.Threading; using Hang.Core; using Hang.Storage; using Hang.Net; using System.Text; using Kernel; namespace Hang.HabboHotel.Misc { internal class LowPriorityWorker { private static int UserPeak; private static string FormatToBytes(int Num) { if (Num < 1024) return Num + "B/s"; else if (Num < 1048576) //KB/s { double Traffic = Num / 1024; return String.Format("{0:0.##}", Traffic) + "KB/s"; } else //MB/s { double Traffic = Num / 1048576; return String.Format("{0:0.##}", Traffic) + "MB/s"; } } private static string mColdTitle; internal static void ConsoleTitleWorker() { while (true) { try { Console.Title = mColdTitle; } catch (Exception Exception) { Logging.LogThreadException(Exception.ToString(), "ConsoleTitleWorker"); } Thread.Sleep(1000); } } internal static void Process() { mColdTitle = string.Empty; // allow 10 seconds for Uber to finish anything it may be doing, then enter regular loop //Thread.Sleep(10000); MY SERVER LOADS FASTER THAN 1 SECOND WHY THE FUCK SHOULD I LET IT SLEEP FOR OVER 10X THE LOADING TIME?! using (DatabaseClient MySQL = HangEnvironment.GetDatabase().GetClient()) { UserPeak = MySQL.query_rows("SELECT userpeak FROM server_status"); } while (true) { try { TimeSpan Uptime = DateTime.Now - HangEnvironment.ServerStarted; mColdTitle = "Hang - Glider v.3.0 | Uptime: " + Uptime.Minutes + " minutes, " + Uptime.Hours + " hours and " + Uptime.Days + " day | " + "Online users: " + HangEnvironment.GetGame().GetClientManager().ClientCount + " | "; #region Garbage Collection GC.Collect(); GC.WaitForPendingFinalizers(); #endregion #region Statistics int Status = 1; int UsersOnline = HangEnvironment.GetGame().GetClientManager().ClientCount; if (UsersOnline > UserPeak) UserPeak = UsersOnline; int RoomsLoaded = HangEnvironment.GetGame().GetRoomManager().LoadedRoomsCount; using (DatabaseClient MySQL = HangEnvironment.GetDatabase().GetClient()) { MySQL.query("UPDATE server_status SET stamp = '" + HangEnvironment.GetUnixTimestamp() + "', status = '" + Status + "', users_online = '" + UsersOnline + "', rooms_loaded = '" + RoomsLoaded + "', server_ver = '" + ConsoleLog.PrettyVersion + "', userpeak = '" + UserPeak + "' LIMIT 1;"); } #endregion #region Effects HangEnvironment.GetGame().GetClientManager().CheckEffects(); #endregion } catch (Exception e) { Logging.LogThreadException(e.ToString(), "Server status update task"); } Thread.Sleep(30000); } } //private static void UpdateMaxUserCount(int UserCount) //{ //} } }