private static void Main(string[] args) { if (args.Length == 1 && args[0].ToLower() == "setup" || !File.Exists(Application.ExecutablePath + "WvsGame.ini")) { WvsGameSetup.Run(); } start: WvsGame.Clients = new GameClients(); Log.Entitle("WvsGame v.{0}.{1}", Application.MapleVersion, Application.PatchVersion); try { Settings.Initialize(Application.ExecutablePath + "WvsGame.ini"); Database.Test(); Database.Analyze(true); Shortcuts.Apply(); WvsGame.AutoRestartTime = Settings.GetInt("Server/AutoRestartTime"); Log.Inform("Automatic restart time set to {0} seconds.", WvsGame.AutoRestartTime); DataProvider.Initialize(); WvsGame.IsAlive = true; } catch (Exception ex) { Log.Error(ex); } if (WvsGame.IsAlive) { WvsGame.CenterConnectionDone.Reset(); new Thread(new ThreadStart(CenterServer.Main)).Start(); WvsGame.CenterConnectionDone.WaitOne(); #if DEBUG string linkPath = Path.Combine(Application.ExecutablePath, "LaunchClient.lnk"); if (File.Exists(linkPath) && WvsGame.WorldID == 0 && WvsGame.ChannelID == 0) //Only for the first WvsGame instance, and only if shortcut exists { System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = linkPath; proc.Start(); } #endif } else { Log.Inform("Could not start server because of errors."); } while (WvsGame.IsAlive) { WvsGame.AcceptDone.Reset(); WvsGame.Listener.BeginAcceptSocket(new AsyncCallback(WvsGame.OnAcceptSocket), null); WvsGame.AcceptDone.WaitOne(); } foreach (GameClient client in WvsGame.Clients) { client.Stop(); } WvsGame.Dispose(); Log.Warn("Server stopped."); if (WvsGame.AutoRestartTime > 0) { Log.Inform("Attempting auto-restart in {0} seconds.", WvsGame.AutoRestartTime); Thread.Sleep(WvsGame.AutoRestartTime * 1000); goto start; } else { Console.Read(); } }
private static void InitiateGameServerSetup() { Log.SkipLine(); Log.Inform("Initiating Destiny game server setup ..."); WvsGameSetup.Run(); }