static void Main() { ApplicationSignal.SetConsoleCtrlHandler(AbortHandler, true); ApplicationSignal.RemoveConsoleQuickEditMode(); if (!ConfigMgr.Load(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".conf")) { ExitNow(); } testing(); // Initialize the database connection if (!StartDB()) { ExitNow(); } string bindIp = ConfigMgr.GetDefaultValue("BindIP", "0.0.0.0"); var restSocketServer = new SocketManager <RestSession>(); int restPort = ConfigMgr.GetDefaultValue("LoginREST.Port", 8081); if (restPort < 0 || restPort > 0xFFFF) { Log.outError(LogFilter.Network, "Specified login service port ({0}) out of allowed range (1-65535), defaulting to 8081", restPort); restPort = 8081; } if (!restSocketServer.StartNetwork(bindIp, restPort)) { Log.outError(LogFilter.Server, "Failed to initialize Rest Socket Server"); ExitNow(); } // Get the list of realms for the server Global.RealmMgr.Initialize(ConfigMgr.GetDefaultValue("RealmsStateUpdateDelay", 10)); Global.SessionMgr.Initialize(); var sessionSocketServer = new SocketManager <Session>(); // Start the listening port (acceptor) for auth connections int bnPort = ConfigMgr.GetDefaultValue("BattlenetPort", 1119); if (bnPort < 0 || bnPort > 0xFFFF) { Log.outError(LogFilter.Server, "Specified battle.net port ({0}) out of allowed range (1-65535)", bnPort); ExitNow(); } if (!sessionSocketServer.StartNetwork(bindIp, bnPort)) { Log.outError(LogFilter.Network, "Failed to start BnetServer Network"); ExitNow(); } uint _banExpiryCheckInterval = ConfigMgr.GetDefaultValue("BanExpiryCheckInterval", 60u); _banExpiryCheckTimer = new Timer(_banExpiryCheckInterval); _banExpiryCheckTimer.Elapsed += _banExpiryCheckTimer_Elapsed; while (true) { ; } }
static void Main() { ApplicationSignal.SetConsoleCtrlHandler(AbortHandler, true); ApplicationSignal.RemoveConsoleQuickEditMode(); if (!ConfigMgr.Load(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".conf")) { ExitNow(); } var WorldSocketMgr = new WorldSocketManager(); //AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; // Watch for any unhandled exceptions. if (!StartDB()) { ExitNow(); } Testing(); // set server offline (not connectable) DB.Login.Execute("UPDATE realmlist SET flag = (flag & ~{0}) | {1} WHERE id = '{2}'", (uint)RealmFlags.VersionMismatch, (uint)RealmFlags.Offline, Global.WorldMgr.GetRealm().Id.Realm); Global.RealmMgr.Initialize(ConfigMgr.GetDefaultValue("RealmsStateUpdateDelay", 10)); Global.WorldMgr.SetInitialWorldSettings(); // Launch the worldserver listener socket int worldPort = WorldConfig.GetIntValue(WorldCfg.PortWorld); string worldListener = ConfigMgr.GetDefaultValue("BindIP", "0.0.0.0"); int networkThreads = ConfigMgr.GetDefaultValue("Network.Threads", 1); if (networkThreads <= 0) { Log.outError(LogFilter.Server, "Network.Threads must be greater than 0"); ExitNow(); return; } if (!WorldSocketMgr.StartNetwork(worldListener, worldPort, networkThreads)) { Log.outError(LogFilter.Network, "Failed to start Realm Network"); ExitNow(); } // set server online (allow connecting now) DB.Login.Execute("UPDATE realmlist SET flag = flag & ~{0}, population = 0 WHERE id = '{1}'", (uint)RealmFlags.Offline, Global.WorldMgr.GetRealm().Id.Realm); Global.WorldMgr.GetRealm().PopulationLevel = 0.0f; Global.WorldMgr.GetRealm().Flags = Global.WorldMgr.GetRealm().Flags & ~RealmFlags.VersionMismatch; //- Launch CliRunnable thread if (ConfigMgr.GetDefaultValue("Console.Enable", true)) { Thread commandThread = new Thread(CommandManager.InitConsole); commandThread.Start(); } WorldUpdateLoop(); try { // Shutdown starts here Global.WorldMgr.KickAll(); // save and kick all players Global.WorldMgr.UpdateSessions(1); // real players unload required UpdateSessions call // unload Battlegroundtemplates before different singletons destroyed Global.BattlegroundMgr.DeleteAllBattlegrounds(); WorldSocketMgr.StopNetwork(); Global.MapMgr.UnloadAll(); // unload all grids (including locked in memory) Global.ScriptMgr.Unload(); // set server offline DB.Login.Execute("UPDATE realmlist SET flag = flag | {0} WHERE id = '{1}'", (uint)RealmFlags.Offline, Global.WorldMgr.GetRealm().Id.Realm); Global.RealmMgr.Close(); ClearOnlineAccounts(); ExitNow(); } catch (Exception ex) { Log.outException(ex); } }