/// <summary> /// </summary> /// <param name="ZoneServer"> /// </param> /// <returns> /// </returns> public Client Create(ZoneServer ZoneServer) { return new Client(ZoneServer, this.messageSerializer, this.bus); }
/// <summary> /// </summary> /// <param name="args"> /// </param> private static void Main(string[] args) { bool processedargs = false; LogUtil.SetupConsoleLogging(LogLevel.Debug); LogUtil.SetupFileLogging("${basedir}/ZoneEngineLog.txt", LogLevel.Trace); SettingsOverride.LoadCustomSettings("NBug.ZoneEngine.Config"); Settings.WriteLogToDisk = true; AppDomain.CurrentDomain.UnhandledException += Handler.UnhandledException; TaskScheduler.UnobservedTaskException += Handler.UnobservedTaskException; csc = new ScriptCompiler(); // TODO: ADD More Handlers. Console.Title = "CellAO " + AssemblyInfoclass.Title + " Console. Version: " + AssemblyInfoclass.Description + " " + AssemblyInfoclass.AssemblyVersion + " " + AssemblyInfoclass.Trademark; ConsoleText ct = new ConsoleText(); ct.TextRead("main.txt"); Console.Write("Loading "); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write(AssemblyInfoclass.Title + " "); Console.ForegroundColor = ConsoleColor.White; Console.Write(AssemblyInfoclass.Description); Console.ResetColor(); Console.WriteLine("..."); zoneServer = Container.GetInstance<ZoneServer>(); int Port = Convert.ToInt32(Config.Instance.CurrentConfig.ZonePort); try { if (Config.Instance.CurrentConfig.ListenIP == "0.0.0.0") { zoneServer.TcpEndPoint = new IPEndPoint(IPAddress.Any, Port); } else { zoneServer.TcpIP = IPAddress.Parse(Config.Instance.CurrentConfig.ListenIP); } } catch { ct.TextRead("ip_config_parse_error.txt"); Console.ReadKey(); return; } string consoleCommand; ct.TextRead("zone_consolecommands.txt"); // removed CheckDBs here, added commands check and updatedb (updatedb will change to a versioning while (true) { if (!processedargs) { if (args.Length == 1) { if (args[0].ToLower() == "/autostart") { ct.TextRead("autostart.txt"); csc.Compile(false); StartTheServer(); } } processedargs = true; } Console.Write("\nServer Command >>"); consoleCommand = Console.ReadLine(); switch (consoleCommand.ToLower()) { case "start": if (zoneServer.Running) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Zone Server is already running"); Console.ResetColor(); break; } // TODO: Add Sql Check. csc.Compile(false); StartTheServer(); break; case "startm": // Multiple dll compile if (zoneServer.Running) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Zone Server is already running"); Console.ResetColor(); break; } // TODO: Add Sql Check. csc.Compile(true); StartTheServer(); break; case "stop": if (!zoneServer.Running) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Zone Server is not running"); Console.ResetColor(); break; } zoneServer.Stop(); break; case "check": case "updatedb": using (SqlWrapper sqltester = new SqlWrapper()) { sqltester.CheckDBs(); Console.ResetColor(); } break; case "exit": case "quit": if (zoneServer.Running) { zoneServer.Stop(); } Process.GetCurrentProcess().Kill(); break; case "ls": // list all available scripts, dont remove it since it does what it should Console.WriteLine("Available scripts"); /* Old Lua way string[] files = Directory.GetFiles("Scripts");*/ try { string[] files = Directory.GetFiles("Scripts", "*.cs", SearchOption.AllDirectories); if (files.Length == 0) { Console.WriteLine("No scripts were found."); break; } Console.ForegroundColor = ConsoleColor.Green; foreach (string s in files) { Console.WriteLine(s); } } catch (Exception) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Scripts folder not found."); } Console.ResetColor(); break; case "ping": // ChatCom.Server.Ping(); Console.WriteLine("Ping is disabled till we can fix it"); break; case "running": if (zoneServer.Running) { Console.WriteLine("Zone Server is Running"); break; } Console.WriteLine("Zone Server not Running"); break; case "online": if (zoneServer.Running) { Console.ForegroundColor = ConsoleColor.White; lock (zoneServer.Clients) { foreach (Client c in zoneServer.Clients) { Console.WriteLine("Character " + c.Character.Name + " online"); } } Console.ResetColor(); } break; default: ct.TextRead("zone_consolecmdsdefault.txt"); break; } } }