Exemple #1
0
        /// <summary>
        /// 全局数据终止任务。
        /// </summary>
        /// <returns>
        /// 异步任务运行状态。
        /// </returns>
        public static async Task Terminate()
        {
            await ThreadMgr.Terminate();

            await FormMgr.Terminate();

            Buffer.Clear();
        }
Exemple #2
0
        public static void StartTheServer()
        {
            try
            {
                Console.ForegroundColor = ConsoleColor.Green;
                zoneServer.Monsters     = new List <NonPlayerCharacterClass>();
                zoneServer.Vendors      = new List <VendingMachine>();
                zoneServer.Doors        = new List <Doors>();

                using (SqlWrapper sqltester = new SqlWrapper())
                {
                    if (sqltester.SQLCheck() != SqlWrapper.DBCheckCodes.DBC_ok)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Database setup not correct");
                        Console.WriteLine("Error: #" + sqltester.lasterrorcode + " - " + sqltester.lasterrormessage);
                        Console.WriteLine("Please press Enter to exit.");
                        Console.ReadLine();
                        Process.GetCurrentProcess().Kill();
                    }
                    sqltester.CheckDBs();
                }

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Loaded {0} items", ItemHandler.CacheAllItems());
                Console.WriteLine("Loaded {0} nanos", NanoHandler.CacheAllNanos());
                Console.WriteLine("Loaded {0} spawns", NonPlayerCharacterHandler.CacheAllFromDB());
                Console.WriteLine("Loaded {0} vendors", VendorHandler.CacheAllFromDB());
                Console.WriteLine("Loaded {0} teleports", DoorHandler.CacheAllFromDB());
                Console.WriteLine("Loaded {0} statels", Statels.CacheAllStatels());

                LootHandler.CacheAllFromDB();
                Tradeskill.CacheItemNames();

                csc.AddScriptMembers();
                csc.CallMethod("Init", null);

                ThreadMgr.Start();
                zoneServer.Start();
                Console.ResetColor();
            }
            catch (MySqlException e)
            {
                Console.WriteLine("MySql Error. Server Cannot Start");
                Console.WriteLine("Exception: " + e.Message);
                string       current = DateTime.Now.ToString("HH:mm:ss");
                StreamWriter logfile = File.AppendText("ZoneEngineLog.txt");
                logfile.WriteLine(current + " " + e.Source + " MySql Error. Server Cannot Start");
                logfile.WriteLine(current + " " + e.Source + " Exception: " + e.Message);
                logfile.Close();
                zoneServer.Stop();
                ThreadMgr.Stop();
                Process.GetCurrentProcess().Kill();
            }
        }
Exemple #3
0
    /// <summary>
    /// 线程下载
    /// </summary>
    void BeginDownload(string url, string file)
    {     //线程下载
        object[] param = new object[2] {
            url, file
        };
        ThreadEvent ev = new ThreadEvent();

        ev.mKey = NotiConst.UPDATE_DOWNLOAD;
        ev.mParams.AddRange(param);
        ThreadMgr.AddEvent(ev, OnThreadCompleted);   //线程下载
    }
        public void WaitForCommands()
        {
            string input = null;

            this.Start();
            ServerGlobals.Init();
            while (!IsConsoleShuttingDown)
            {
                Console.ForegroundColor = ConsoleColor.Magenta;
                Console.Write("\n(Router Server) ");
                Console.ResetColor();
                input = Console.ReadLine();
                string[] args = input.Split(' ');



                switch (args[0].ToLower())
                {
                case "start":
                {
                    this.Start();
                }
                break;

                case "ip":
                {
                    IPAddress add = Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork);
                    Console.WriteLine(add);
                }
                break;

                case "stop":
                    ThreadMgr.Stop();
                    srv.Stop();
                    break;

                case "exit":
                    this.Stop();
                    break;

                default:
                    Console.WriteLine("No Such Command: " + input + "\r\n");
                    break;
                }
            }
        }
        public void Start()
        {
            IPAddress address = Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork);
            //if (address != null)
            //{
            IPAddress any = IPAddress.Parse("0.0.0.0");

            srv.TcpIP     = any;//IPAddress.Any;
            srv.TcpPort   = 7002;
            srv.EnableTCP = true;

            ThreadMgr.Start();
            srv.Start();
            //Console.WriteLine("IpAddress = null {0}", address == null);
            //}
            //Console.WriteLine("Unable to parse Ip");
        }
Exemple #6
0
 public void Start()
 {
     // if (cmd.Length == 3)
     // {
     srv.TcpIP     = IPAddress.Any;
     srv.TcpPort   = 8001;
     srv.EnableTCP = true;
     ServerGlobals.Init();
     ThreadMgr.Start();
     srv.Start();
     // Turn on and test our mysql
     try
     {
         bool mysql = MySqlManager.TestConnection;
         Console.WriteLine("MySql Initialize {0}", mysql ? "Successful" : "Unsuccessful");
     }
     catch (Exception ex)
     {
         Console.WriteLine("Unable to continue, error is {0}\nPress any key to close!", ex.Message);
         Console.Read();
         this.IsConsoleShuttingDown = true;
     }
 }
Exemple #7
0
        private static void ReceiveAsyncComplete(object sender, SocketAsyncEventArgs args)
        {
            ClientBase client = args.UserToken as ClientBase;

            try
            {
                int bytesTransferred = args.BytesTransferred;

                if (bytesTransferred == 0)
                {
                    client.m_server.DisconnectClient(client, true);
                }
                else
                {
                    unchecked
                    {
                        client.m_bytesReceived += bytesTransferred;
                        s_totalBytesReceived   += (uint)bytesTransferred;
                    }

                    client.m_processDataObj.BytesReceived = bytesTransferred;

                    ThreadMgr.QueueExecObj(client.m_processDataObj);
                }
            }
            catch (ObjectDisposedException e)
            {
                client.m_server.Warning(client, e);
                client.m_server.DisconnectClient(client, true);
            }
            catch (Exception e)
            {
                client.m_server.Warning(client, e);
                client.m_server.DisconnectClient(client, true);
            }
        }
Exemple #8
0
        private static void Main(string[] args)
        {
            #region Console Texts...
            Console.Title = "CellAO " + AssemblyInfoclass.Title + " Console. Version: " + AssemblyInfoclass.Description
                            + " " + AssemblyInfoclass.AssemblyVersion + " " + AssemblyInfoclass.Trademark;

            ConsoleText ct = new ConsoleText();
            ct.TextRead("main.txt");
            Console.WriteLine("Loading " + AssemblyInfoclass.Title + "...");

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("[OK]");
            Console.ResetColor();
            #endregion

            //Sying helped figure all this code out, about 5 yearts ago! :P
            bool processedargs = false;
            loginLoginServer           = new LoginServer();
            loginLoginServer.EnableTCP = true;
            loginLoginServer.EnableUDP = false;
            try
            {
                loginLoginServer.TcpIP = IPAddress.Parse(Config.Instance.CurrentConfig.ListenIP);
            }
            catch
            {
                ct.TextRead("ip_config_parse_error.txt");
                Console.ReadKey();
                return;
            }
            loginLoginServer.TcpPort = Convert.ToInt32(Config.Instance.CurrentConfig.LoginPort);

            #region NLog
            LoggingConfiguration config        = new LoggingConfiguration();
            ColoredConsoleTarget consoleTarget = new ColoredConsoleTarget();
            consoleTarget.Layout = "${date:format=HH\\:MM\\:ss} ${logger} ${message}";
            FileTarget fileTarget = new FileTarget();
            config.AddTarget("file", fileTarget);
            fileTarget.FileName = "${basedir}/LoginEngineLog.txt";
            fileTarget.Layout   = "${date:format=HH\\:MM\\:ss} ${logger} ${message}";
            LoggingRule rule1 = new LoggingRule("*", LogLevel.Trace, consoleTarget);
            config.LoggingRules.Add(rule1);
            LoggingRule rule2 = new LoggingRule("*", LogLevel.Trace, fileTarget);
            config.LoggingRules.Add(rule2);
            LogManager.Configuration = config;
            #endregion

            #region NBug
            SettingsOverride.LoadCustomSettings("NBug.LoginEngine.Config");
            NBug.Settings.WriteLogToDisk = true;
            AppDomain.CurrentDomain.UnhandledException += Handler.UnhandledException;
            TaskScheduler.UnobservedTaskException      += Handler.UnobservedTaskException;
            //TODO: ADD More Handlers.
            #endregion

            loginLoginServer.MaximumPendingConnections = 100;

            #region Console Commands
            //Andyzweb: Added checks for start and stop
            //also added a running command to return status of the server
            //and added Console.Write("\nServer Command >>"); to login server
            string consoleCommand;
            ct.TextRead("login_consolecommands.txt");
            while (true)
            {
                if (!processedargs)
                {
                    if (args.Length == 1)
                    {
                        if (args[0].ToLower() == "/autostart")
                        {
                            ct.TextRead("autostart.txt");
                            ThreadMgr.Start();
                            loginLoginServer.Start();
                        }
                    }
                    processedargs = true;
                }
                Console.Write("\nServer Command >>");

                consoleCommand = Console.ReadLine();
                string temp = "";
                while (temp != consoleCommand)
                {
                    temp           = consoleCommand;
                    consoleCommand = consoleCommand.Replace("  ", " ");
                }
                consoleCommand = consoleCommand.Trim();
                switch (consoleCommand.ToLower())
                {
                case "start":
                    if (loginLoginServer.Running)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        ct.TextRead("loginisrunning.txt");
                        Console.ResetColor();
                        break;
                    }
                    ThreadMgr.Start();
                    loginLoginServer.Start();
                    break;

                case "stop":
                    if (!loginLoginServer.Running)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        ct.TextRead("loginisnotrunning.txt");
                        Console.ResetColor();
                        break;
                    }
                    ThreadMgr.Stop();
                    loginLoginServer.Stop();
                    break;

                case "exit":
                    Process.GetCurrentProcess().Kill();
                    break;

                case "running":
                    if (loginLoginServer.Running)
                    {
                        //Console.WriteLine("Login Server is running");
                        ct.TextRead("loginisrunning.txt");
                        break;
                    }
                    //Console.WriteLine("Login Server not running");
                    ct.TextRead("loginisnotrunning.txt");
                    break;

                    #region Help Commands....
                case "help":
                    ct.TextRead("logincmdhelp.txt");
                    break;

                case "help start":
                    ct.TextRead("helpstart.txt");
                    break;

                case "help exit":
                    ct.TextRead("helpstop.txt");
                    break;

                case "help running":
                    ct.TextRead("loginhelpcmdrunning.txt");
                    break;

                case "help Adduser":
                    ct.TextRead("logincmdadduserhelp.txt");
                    break;

                case "help setpass":
                    ct.TextRead("logincmdhelpsetpass.txt");
                    break;
                    #endregion

                default:

                    #region Adduser
                    //This section handles the command for adding a user to the database
                    if (consoleCommand.ToLower().StartsWith("adduser"))
                    {
                        string[] parts = consoleCommand.Split(' ');
                        if (parts.Length < 9)
                        {
                            Console.WriteLine(
                                "Invalid command syntax.\nPlease use:\nAdduser <username> <password> <number of characters> <expansion> <gm level> <email> <FirstName> <LastName>");
                            break;
                        }
                        string username = parts[1];
                        string password = parts[2];
                        int    numChars = 0;
                        try
                        {
                            numChars = int.Parse(parts[3]);
                        }
                        catch
                        {
                            Console.WriteLine("Error: <number of characters> must be a number (duh!)");
                            break;
                        }
                        int expansions = 0;
                        try
                        {
                            expansions = int.Parse(parts[4]);
                        }
                        catch
                        {
                            Console.WriteLine("Error: <expansions> must be a number between 0 and 2047!");
                            break;
                        }
                        if (expansions < 0 || expansions > 2047)
                        {
                            Console.WriteLine("Error: <expansions> must be a number between 0 and 2047!");
                            break;
                        }

                        int gm = 0;
                        try
                        {
                            gm = int.Parse(parts[5]);
                        }
                        catch
                        {
                            Console.WriteLine("Error: <GM Level> must be number (duh!)");
                            break;
                        }

                        string email = parts[6];
                        if (email == null)
                        {
                            email = String.Empty;
                        }
                        if (!TestEmailRegex(email))
                        {
                            Console.WriteLine("Error: <Email> You must supply an email address for this account");
                            break;
                        }
                        string firstname = parts[7];
                        try
                        {
                            if (firstname == null)
                            {
                                throw new ArgumentNullException();
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Error: <FirstName> You must supply a first name for this accout");
                            break;
                        }
                        string lastname = parts[8];
                        try
                        {
                            if (lastname == null)
                            {
                                throw new ArgumentNullException();
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Error: <LastName> You must supply a last name for this account");
                            break;
                        }

                        const string FormatString =
                            "INSERT INTO `login` (`CreationDate`, `Flags`,`AccountFlags`,`Username`,`Password`,`Allowed_Characters`,`Expansions`, `GM`, `Email`, `FirstName`, `LastName`) VALUES "
                            + "(NOW(), '0', '0', '{0}', '{1}', {2}, {3}, {4}, '{5}', '{6}', '{7}');";

                        LoginEncryption le = new LoginEncryption();

                        string hashedPassword = le.GeneratePasswordHash(password);

                        string sql = String.Format(
                            FormatString,
                            username,
                            hashedPassword,
                            numChars,
                            expansions,
                            gm,
                            email,
                            firstname,
                            lastname);
                        SqlWrapper sqlWrapper = new SqlWrapper();
                        try
                        {
                            sqlWrapper.SqlInsert(sql);
                        }
                        catch (MySqlException ex)
                        {
                            switch (ex.Number)
                            {
                            case 1062:         //duplicate entry for key
                                Console.WriteLine("A user account with this username already exists.");
                                break;

                            default:
                                Console.WriteLine(
                                    "An error occured while trying to add a new user account:\n{0}", ex.Message);
                                break;
                            }
                            break;
                        }
                        Console.WriteLine("User added successfully.");
                        break;
                    }
                    #endregion

                    #region Hashpass
                    //This function just hashes the string you enter using the loginencryption method
                    if (consoleCommand.ToLower().StartsWith("hash"))
                    {
                        string Syntax =
                            "The Syntax for this command is \"hash <String to hash>\" alphanumeric no spaces";
                        string[] parts = consoleCommand.Split(' ');
                        if (parts.Length != 2)
                        {
                            Console.WriteLine(Syntax);
                            break;
                        }
                        string          pass   = parts[1];
                        LoginEncryption le     = new LoginEncryption();
                        string          hashed = le.GeneratePasswordHash(pass);
                        Console.WriteLine(hashed);
                        break;
                    }
                    #endregion

                    #region setpass
                    //sets the password for the given username
                    //Added by Andyzweb
                    //Still TODO add exception and error handling
                    if (consoleCommand.ToLower().StartsWith("setpass"))
                    {
                        string Syntax =
                            "The syntax for this command is \"setpass <account username> <newpass>\" where newpass is alpha numeric no spaces";
                        string[] parts = consoleCommand.Split(' ');
                        if (parts.Length != 3)
                        {
                            Console.WriteLine(Syntax);
                            break;
                        }
                        string          username = parts[1];
                        string          newpass  = parts[2];
                        LoginEncryption le       = new LoginEncryption();
                        string          hashed   = le.GeneratePasswordHash(newpass);
                        string          formatString;
                        formatString = "UPDATE `login` SET Password = '******' WHERE login.Username = '******'";

                        string sql = String.Format(formatString, hashed, username);

                        SqlWrapper updt = new SqlWrapper();
                        try
                        {
                            updt.SqlUpdate(sql);
                        }
                        //yeah this part here, some kind of exception handling for mysql errors
                        catch
                        {
                        }
                    }
                    #endregion

                    ct.TextRead("login_consolecmdsdefault.txt");
                    break;
                }
            }
            #endregion
        }
Exemple #9
0
        /// <summary>
        /// The main.
        /// </summary>
        /// <param name="args">
        /// Program arguments
        /// </param>
        private static void Main(string[] args)
        {
            Console.Title = "CellAO " + AssemblyInfoclass.Title + " Console. Version: " + AssemblyInfoclass.Description
                            + " " + AssemblyInfoclass.AssemblyVersion + " " + AssemblyInfoclass.Trademark;

            ConsoleText ct = new ConsoleText();

            ct.TextRead("main.txt");
            Console.WriteLine("Loading " + AssemblyInfoclass.Title + "...");

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Using ISComm v1.0");
            Console.WriteLine("[OK]");
            Console.ResetColor();

            bool       processedArgs = false;
            ChatServer chatServer    = new ChatServer();

            Console.WriteLine("[ISComm] Waiting for link...");

            #region NLog
            LoggingConfiguration config        = new LoggingConfiguration();
            ColoredConsoleTarget consoleTarget = new ColoredConsoleTarget();
            consoleTarget.Layout = "${date:format=HH\\:MM\\:ss} ${logger} ${message}";
            FileTarget fileTarget = new FileTarget();
            config.AddTarget("file", fileTarget);
            fileTarget.FileName = "${basedir}/ChatEngineLog.txt";
            fileTarget.Layout   = "${date:format=HH\\:MM\\:ss} ${logger} ${message}";
            LoggingRule rule1 = new LoggingRule("*", LogLevel.Trace, consoleTarget);
            config.LoggingRules.Add(rule1);
            LoggingRule rule2 = new LoggingRule("*", LogLevel.Trace, fileTarget);
            config.LoggingRules.Add(rule2);
            LogManager.Configuration = config;
            #endregion

            #region NBug

            SettingsOverride.LoadCustomSettings("NBug.ChatEngine.Config");
            Settings.WriteLogToDisk = true;
            AppDomain.CurrentDomain.UnhandledException += Handler.UnhandledException;
            TaskScheduler.UnobservedTaskException      += Handler.UnobservedTaskException;

            // TODO: ADD More Handlers.
            #endregion

            IPAddress localISComm;

            try
            {
                // Local ISComm IP valid?
                localISComm = IPAddress.Parse(Config.Instance.CurrentConfig.ISCommLocalIP);
            }
            catch
            {
                // Fallback to ZoneIP
                localISComm = IPAddress.Parse(Config.Instance.CurrentConfig.ZoneIP);
            }

            if (!ZoneCom.Link(localISComm.ToString(), Config.Instance.CurrentConfig.CommPort, chatServer))
            {
                Console.WriteLine("[ISComm] Unable to link to ZoneEngine. :(");
                return;
            }

            Console.WriteLine("[ISComm] Linked with ZoneEngine! :D");

            chatServer.EnableTCP = true;
            chatServer.EnableUDP = false;

            try
            {
                chatServer.TcpIP = IPAddress.Parse(Config.Instance.CurrentConfig.ListenIP);
            }
            catch
            {
                ct.TextRead("ip_config_parse_error.txt");
                Console.ReadKey();
                return;
            }

            try
            {
                chatServer.UdpIP = IPAddress.Parse(Config.Instance.CurrentConfig.ListenIP);
            }
            catch
            {
                ct.TextRead("ip_config_parse_error.txt");
                Console.ReadKey();
                return;
            }

            chatServer.TcpPort = Convert.ToInt32(Config.Instance.CurrentConfig.ChatPort);
            chatServer.MaximumPendingConnections = 100;

            AppDomain.CurrentDomain.UnhandledException += Handler.UnhandledException;
            TaskScheduler.UnobservedTaskException      += Handler.UnobservedTaskException;

            // TODO: ADD More Handlers.

            // Andyzweb: I added checks for if the server is running or not
            // also a command called running that returns the status of the server
            // and added the Console.Write("\nServer Command >>"); to chatserver
            string consoleCommand;
            ct.TextRead("chat_consolecommands.txt");
            while (true)
            {
                if (!processedArgs)
                {
                    if (args.Length == 1)
                    {
                        if (args[0].ToLower() == "/autostart")
                        {
                            ct.TextRead("autostart.txt");
                            ThreadMgr.Start();
                            chatServer.Start();
                        }
                    }

                    processedArgs = true;
                }

                Console.Write("\nServer Command >>");
                consoleCommand = Console.ReadLine();
                switch (consoleCommand.ToLower())
                {
                case "start":
                    if (chatServer.Running)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Chat Server is already running");
                        Console.ResetColor();
                        break;
                    }

                    ThreadMgr.Start();
                    chatServer.Start();
                    break;

                case "stop":
                    if (!chatServer.Running)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Chat Server is not running");
                        Console.ResetColor();
                        break;
                    }

                    ThreadMgr.Stop();
                    chatServer.Stop();
                    break;

                case "exit":
                    Process.GetCurrentProcess().Kill();
                    break;

                case "running":
                    if (chatServer.Running)
                    {
                        Console.WriteLine("Chat Server is Running");
                        break;
                    }

                    Console.WriteLine("Chat Server not Running");
                    break;

                default:
                    ct.TextRead("chat_consolecmdsdefault.txt");
                    break;
                }
            }
        }
Exemple #10
0
        private static void Main(string[] args)
        {
            bool processedargs = false;

            // Please dont kill the commented out lines below for the moment -NV
            //Misc.Playfields.Instance.playfields[0].districts.Add(new ZoneEngine.Misc.DistrictInfo());
            //Misc.Playfields.Instance.playfields[0].districts[0].districtName = "some district";
            //Misc.Playfields.Instance.playfields[0].districts.Add(new ZoneEngine.Misc.DistrictInfo());
            //Misc.Playfields.Instance.playfields[0].districts[1].districtName = "some other district";
            //Misc.DistrictInfo.DumpXML(@"C:\list.xml", Misc.Playfields.Instance.playfields[0]);

            #region Console Text...
            Console.Title = "CellAO " + AssemblyInfoclass.Title + " Console. Version: " + AssemblyInfoclass.Description
                            + " " + AssemblyInfoclass.AssemblyVersion + " " + AssemblyInfoclass.Trademark;

            ConsoleText ct = new ConsoleText();
            ct.TextRead("main.txt");
            Console.WriteLine("Loading " + AssemblyInfoclass.Title + "...");

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Using ISComm v1.0");
            Console.WriteLine("[OK]");
            Console.ResetColor();
            #endregion

            #region Delete old SqlError.log, so it doesnt get too big
            if (File.Exists("sqlerror.log"))
            {
                File.Delete("sqlerror.log");
            }
            #endregion

            #region ISComm Code Area...
            Console.WriteLine("[ISComm] Waiting for Link...");
            ChatCom.StartLink(Config.Instance.CurrentConfig.CommPort);
            //System.Console.WriteLine("[ISComm] Linked Successfully! :D");
            #endregion

            zoneServer = new Server {
                EnableTCP = true, EnableUDP = false
            };

            #region Script Loading Code Area..
            csc = new ScriptCompiler();
            #endregion

            try
            {
                zoneServer.TcpIP = IPAddress.Parse(Config.Instance.CurrentConfig.ListenIP);
            }
            catch
            {
                ct.TextRead("ip_config_parse_error.txt");
                Console.ReadKey();
                return;
            }
            try
            {
                zoneServer.UdpIP = IPAddress.Parse(Config.Instance.CurrentConfig.ListenIP);
            }
            catch
            {
                ct.TextRead("ip_config_parse_error.txt");
                Console.ReadKey();
                return;
            }

            zoneServer.TcpPort = Convert.ToInt32(Config.Instance.CurrentConfig.ZonePort);

            #region NLog
            LoggingConfiguration config        = new LoggingConfiguration();
            ColoredConsoleTarget consoleTarget = new ColoredConsoleTarget();
            consoleTarget.Layout = "${date:format=HH\\:MM\\:ss} ${logger} ${message}";
            FileTarget fileTarget = new FileTarget();
            config.AddTarget("file", fileTarget);
            fileTarget.FileName = "${basedir}/ZoneEngineLog.txt";
            fileTarget.Layout   = "${date:format=HH\\:MM\\:ss} ${logger} ${message}";
            LoggingRule rule1 = new LoggingRule("*", LogLevel.Trace, consoleTarget);
            config.LoggingRules.Add(rule1);
            LoggingRule rule2 = new LoggingRule("*", LogLevel.Trace, fileTarget);
            config.LoggingRules.Add(rule2);
            LogManager.Configuration = config;
            #endregion

            #region NBug
            SettingsOverride.LoadCustomSettings("NBug.ZoneEngine.Config");
            NBug.Settings.WriteLogToDisk = true;
            AppDomain.CurrentDomain.UnhandledException += Handler.UnhandledException;
            TaskScheduler.UnobservedTaskException      += Handler.UnobservedTaskException;
            //TODO: ADD More Handlers.
            #endregion

            FunctionC.ReadFunctions();
            Console.WriteLine("Registered " + FunctionC.NumberofRegisteredFunctions().ToString() + " Functions");

            #region Console Commands...
            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();
                    ThreadMgr.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();
                        ThreadMgr.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");*/
                    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);

                        /* Old Lua way
                         * if (s.EndsWith(".lua"))
                         * {
                         *  Console.WriteLine(s.Split('\\')[1].Split('.')[0]);
                         * }*/
                    }
                    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;
                }
            }
        }
Exemple #11
0
        public void WaitForCommands()
        {
            string input = null;

            this.Start();
            LoadScripts();
            InitGameData();
            while (!IsConsoleShuttingDown)
            {
                Console.ForegroundColor = ConsoleColor.Magenta;
                Console.Write("\n[{Realm World Server}] ");
                Console.ResetColor();
                input = Console.ReadLine();
                string[] args = input.Split(' ');



                switch (args[0].ToLower())
                {
                case "pass":
                {
                    // we gonna hash passwords here man !!
                    string password = string.Empty;

                    if (args.Length >= 2)
                    {
                        // get the pass
                        password = args[1];
                        string hash = RealmOffline.Accounts.PasswordHash.CreateHash(password);
                        bool   back = RealmOffline.Accounts.PasswordHash.ValidatePassword(password, hash);
                        Console.WriteLine("We got password ({0}) and hash ({1}), they {2} match.", password, hash,
                                          back ? "do":" do not");
                    }
                }
                break;

                case "/mob":
                {
                    if (args.Length >= 2)
                    {
                        short id = 0;
                        if (short.TryParse(args[1], out id))
                        {
                            MobileType type = MobileType.None;
                            string     name = BaseMobile.MobNameFromID(id, out type);
                            Console.WriteLine("We found {0} for MobID {1}, its type is {2}",
                                              name, id, type);
                        }
                    }
                }
                break;

                case "/sm":
                {
                    if (args.Length >= 3)
                    {
                        //1 = topic 2 on = message
                        string topic = input.Split('|').First();
                        string msg   = input.Split('|').Last();
                        Console.WriteLine("Topic ({0}) Message ({1})", topic, msg);
                    }
                }
                break;

                case "terd":
                {
                    BaseMobile.Init();
                    string[] m = BaseMobile.NonHumanoid.Select(x => x.Value).ToArray();
                    foreach (string c in m)
                    {
                        Console.WriteLine(c);
                    }
                }
                break;

                case "fight":
                {
                    // We want stats 2 stats 2 skills for attack
                    //1 = str 2 = dex 3 = CS 4 = wepskill
                    if (args.Length >= 5)
                    {
                        int str = 0;
                        int dex = 0;
                        int cs  = 0;
                        int wep = 0;
                        if (int.TryParse(args[1], out str) &&
                            int.TryParse(args[2], out dex) &&
                            int.TryParse(args[3], out cs) &&
                            int.TryParse(args[4], out wep))
                        {
                            Console.WriteLine("We got STR:({0}) DEX:({1}) CS:({2}) Wep:({3})",
                                              str, dex, cs, wep);

                            // Lets formulate a chance
                            int[] attacker = { str, dex, cs, wep };
                            int[] oppn     = { 12, 12, 5, 5 };

                            // int hitpoints = 3000; // both have 3k hp
                            int aper = attacker.Sum();
                            int oper = oppn.Sum();

                            Console.WriteLine("We start with {0}% for Attacker and {1}% for opponent.", aper, oper);
                        }
                    }
                }
                break;

                case "id":
                {
                    if (args.Length == 2)
                    {
                        short id = 0;
                        if (short.TryParse(args[1], out id))
                        {
                            bool vali = Mob.IsValidID(id);
                            Console.WriteLine("{0} {1} a valid id.", id, vali ? "is" : "is not");
                        }
                    }
                }
                break;

                case "ts":
                {
                    byte[] t = new byte[] { 0x21, 0xFF, 0x00, 0x9C };
                    Array.Reverse(t);
                    double   d  = (double)BitConverter.ToInt32(t, 0);
                    DateTime dt = MagicMail.UnixTimeStampToDateTime(d);
                    Console.WriteLine(dt);
                }
                break;

                    #region Account Creation and Deletion
                case "account":
                {
                    string useage = "[Create an Account]\naccount create username password emailaddress secretword 3 \n" +
                                    "Last value is User Priv's\n" +
                                    "5 = Player, 4 = EventHost 3 = Guide 2 = Moderator 1 = Admin 0 = Owner \n" +
                                    "\n" +
                                    "[Delete an Account]\n" +
                                    "account delete username";
                    string createUseage = "[Create an Account]\naccount create username password emailaddress secretword 3 \n" +
                                          "Last value is User Priv's\n" +
                                          "5 = Player, 4 = EventHost 3 = Guide 2 = Moderator 1 = Admin 0 = Owner \n";
                    string deleteUsage = "[Delete an Account]\n" +
                                         "account delete username";

                    // create or delete
                    if (args.Length > 2)
                    {
                        if (args[1].ToLower() == "create")
                        {
                            if (args[2].ToLower() == "help" || args[2] == string.Empty)
                            {
                                Console.WriteLine(createUseage);
                            }
                            else
                            {
                                string error = string.Empty;
                                if (!MySqlManager.ValidateAccount(args, out error))
                                {
                                    if (error.Trim() != string.Empty)
                                    {
                                        Console.ForegroundColor = ConsoleColor.Red;
                                        Console.WriteLine(error);
                                        Console.ResetColor();
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("Account {0} Created.", args[2]);
                                }
                            }
                        }
                        else if (args[1].ToLower() == "delete")
                        {
                            if (args.Length != 3)
                            {
                                Console.WriteLine(deleteUsage);
                            }
                            else
                            {
                                bool delete = MySqlManager.DeleteUserAccount(args[2].ToLower());
                                if (delete)
                                {
                                    Console.WriteLine("Removed Account {0}.", args[2].ToLower());
                                }
                                else
                                {
                                    Console.WriteLine("Account {0} not found.", args[2].ToLower());
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("create or delete are the only valid options.");
                        }
                    }
                    else
                    {
                        Console.WriteLine(useage);
                    }
                    // Ok this will be the command to create a new account

                    /*
                     * We need
                     * 2: Username
                     * 3: Password
                     * 4: email address
                     * 5: secret word
                     * 6: Priv Level
                     * string string string string int
                     */
                }
                    #endregion
                    break;

                case "spell":
                {
                    List <Account> accts = ServerGlobals.GetAccountsInRoom(1310);
                    Console.WriteLine("Total in room 1310 {0}", accts.Count);
                }
                break;

                case "online":
                {
                    int online = 0;
                    if (ServerGlobals.LoggedInAccounts != null)
                    {
                        online = ServerGlobals.LoggedInAccounts.Count;
                    }
                    Console.WriteLine("Currently {0} accounts online.", online);
                }
                break;

                case "clear":
                    Console.Clear();
                    break;

                case "mem":
                {
                    // Returns the current memory usage
                    Console.WriteLine(MemoryUseDisplay);
                }
                break;

                case "q":
                {
                    TestObject t       = new TestObject();
                    string     fileloc = Path.Combine(ServerGlobals.BaseDirectory, "TestSerialize.xml");

                    SerializedObject.Serialize(t, fileloc);

                    TestObject t1 = SerializedObject.Deserialize <TestObject>(fileloc);
                    Console.WriteLine(t1.ID);
                }
                break;

                case "touint16":
                {
                    if (args.Length == 2)
                    {
                        // should be 4 letters / numbers
                        string toParse = args[1].Trim();
                        // split string in half
                        if (toParse.Length == 4)
                        {
                            string      b1    = toParse.Substring(0, 2);
                            string      b2    = toParse.Substring(2);
                            List <byte> blist = new List <byte>();

                            try
                            {
                                byte a;
                                byte b;
                                a = Byte.Parse(b1, NumberStyles.HexNumber);
                                b = Byte.Parse(b2, NumberStyles.HexNumber);
                                blist.Add(a);
                                blist.Add(b);
                                byte[] f1     = blist.ToArray();
                                ushort result = BitConverter.ToUInt16(f1, 0);
                                Console.WriteLine("UInt16 result of bytes [{0}] [{1}] = {2}",
                                                  BitConverter.ToString(new byte[] { a }), BitConverter.ToString(new byte[] { b }), result);
                            }
                            catch { Console.WriteLine("Bad Parse"); }
                        }
                    }
                }
                break;

                case "toint32":
                {
                    if (args.Length == 2)
                    {
                        // should be 8 letters / numbers
                        string toParse = args[1].Trim();
                        // split string in half
                        if (toParse.Length == 8)
                        {
                            string      b1    = toParse.Substring(0, 2);
                            string      b2    = toParse.Substring(2, 2);
                            string      b3    = toParse.Substring(4, 2);
                            string      b4    = toParse.Substring(6);
                            List <byte> blist = new List <byte>();

                            try
                            {
                                byte a;
                                byte b;
                                byte c;
                                byte d;
                                a = Byte.Parse(b1, NumberStyles.HexNumber);
                                b = Byte.Parse(b2, NumberStyles.HexNumber);
                                c = Byte.Parse(b3, NumberStyles.HexNumber);
                                d = Byte.Parse(b4, NumberStyles.HexNumber);
                                blist.Add(a);
                                blist.Add(b);
                                blist.Add(c);
                                blist.Add(d);
                                byte[] f1 = blist.ToArray();
                                f1.Reverse();
                                Int32 result = BitConverter.ToInt32(f1, 0);
                                Console.WriteLine("Int32 result of bytes [{0}] [{1}] [{2}] [{3}]= {4}",
                                                  BitConverter.ToString(new byte[] { a }), BitConverter.ToString(new byte[] { b }),
                                                  BitConverter.ToString(new byte[] { c }), BitConverter.ToString(new byte[] { d }),
                                                  result);
                            }
                            catch { Console.WriteLine("Bad Parse"); }
                        }
                    }
                }
                break;

                case "touint32":
                {
                    if (args.Length == 2)
                    {
                        // should be 8 letters / numbers
                        string toParse = args[1].Trim();
                        // split string in half
                        if (toParse.Length == 8)
                        {
                            string      b1    = toParse.Substring(0, 2);
                            string      b2    = toParse.Substring(2, 2);
                            string      b3    = toParse.Substring(4, 2);
                            string      b4    = toParse.Substring(6);
                            List <byte> blist = new List <byte>();

                            try
                            {
                                byte a;
                                byte b;
                                byte c;
                                byte d;
                                a = Byte.Parse(b1, NumberStyles.HexNumber);
                                b = Byte.Parse(b2, NumberStyles.HexNumber);
                                c = Byte.Parse(b3, NumberStyles.HexNumber);
                                d = Byte.Parse(b4, NumberStyles.HexNumber);
                                blist.Add(a);
                                blist.Add(b);
                                blist.Add(c);
                                blist.Add(d);
                                byte[] f1 = blist.ToArray();
                                f1.Reverse();
                                UInt32 result = BitConverter.ToUInt32(f1, 0);
                                Console.WriteLine("Int32 result of bytes [{0}] [{1}] [{2}] [{3}]= {4}",
                                                  BitConverter.ToString(new byte[] { a }), BitConverter.ToString(new byte[] { b }),
                                                  BitConverter.ToString(new byte[] { c }), BitConverter.ToString(new byte[] { d }),
                                                  result);
                            }
                            catch { Console.WriteLine("Bad Parse"); }
                        }
                    }
                }
                break;

                case "tobytes32":
                {
                    // the next value is a number
                    if (args.Length == 2)
                    {
                        int value = 0;
                        if (int.TryParse(args[1], out value))
                        {
                            byte[] conv = BitConverter.GetBytes(value);
                            Console.WriteLine(BitConverter.ToString(conv));
                        }
                    }
                }
                break;

                case "m2ushort":
                {
                    // we have 2 bytes space 2 bytes 0 1 2 args or 3 total

                    if (args.Length == 3)
                    {
                        try
                        {
                            string firstushort  = args[1].Trim();
                            string secondushort = args[2].Trim();

                            string      b1    = firstushort.Substring(0, 2);
                            string      b2    = firstushort.Substring(2, 2);
                            string      b3    = secondushort.Substring(0, 2);
                            string      b4    = secondushort.Substring(2, 2);
                            List <byte> blist = new List <byte>();


                            byte a;
                            byte b;
                            byte c;
                            byte d;
                            a = Byte.Parse(b1, NumberStyles.HexNumber);
                            b = Byte.Parse(b2, NumberStyles.HexNumber);
                            c = Byte.Parse(b3, NumberStyles.HexNumber);
                            d = Byte.Parse(b4, NumberStyles.HexNumber);
                            byte[] fArg = { a, b };
                            byte[] sArg = { c, d };
                            ushort vone = BitConverter.ToUInt16(fArg, 0);
                            ushort vtwo = BitConverter.ToUInt16(sArg, 0);
                            Console.WriteLine("We got {0} and {1} for a difference of {2} or {3}",
                                              vone, vtwo, vone - vtwo, vtwo - vone);
                        }
                        catch { Console.WriteLine("Bad Parse"); }
                    }
                }
                break;

                case "bc":
                {
                    if (args.Length > 2)
                    {
                        // get the rest of this string
                        StringBuilder build = new StringBuilder();
                        foreach (string s in args)
                        {
                            build.Append(s + " ");
                        }
                        string   first  = build.ToString().Remove(0, 3);
                        string[] parse2 = first.Split(' ');
                        // whats the color ?
                        int color = -1;
                        if (int.TryParse(parse2[0], out color))
                        {
                            // Fix the last string again then
                            build.Clear();
                            foreach (string s in parse2)
                            {
                                build.Append(s + " ");
                            }
                            string message       = build.ToString().Remove(0, parse2[0].Length + 1);
                            byte[] messagePacket = RealmPacketIO.BuildGossipPacket(color, message, "SERVER");
                            ServerGlobals.SendToAllClients(messagePacket);
                            byte[] messagePacket2 = Packet.ChatPacket(color, 1, message, "SERVER");
                            ServerGlobals.SendToAllClients(messagePacket2);
                            //Console.WriteLine(message);
                        }
                        else
                        {
                            Console.WriteLine("Bad color argument of {0}", parse2[0]);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Usage: bc 10 I want to say hi !!");
                    }
                }
                break;

                case "sta":
                {
                    //string fileLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ServerPacket24Message.txt");
                    byte[] fake0 = RealmPacketIO.ServerMessageType1(
                        "A Topic Test", "A Very Nice Message, we couldnt have much nicer, so dont be a dick!");        //RealmPacketIO.GetByteArrayFromFile(fileLocation);

                    if (args.Length == 2)
                    {
                        if (args[1].ToLower() == "len")
                        {
                            Console.WriteLine("Message Packet Length {0}",
                                              BitConverter.ToString(BitConverter.GetBytes(fake0.Length - 8)));
                        }
                    }
                    else
                    {
                        //ServerPacket24Message.txt

                        ServerGlobals.SendToAllClients(fake0);
                    }
                }
                break;

                case "sta2":
                {
                    // ServerMessagePacket81.txt
                    string fileLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ServerMessagePacket81.txt");
                    byte[] fake0        = RealmPacketIO.ServerMessageType2(
                        "F**k you and da horse you roded in on foo!");        //RealmPacketIO.GetByteArrayFromFile(fileLocation);
                    if (args.Length == 2)
                    {
                        if (args[1].ToLower() == "len")
                        {
                            Console.WriteLine("Message Packet Length {0}",
                                              BitConverter.ToString(BitConverter.GetBytes(fake0.Length - 8)));
                        }
                    }
                    else
                    {
                        // ServerMessagePacket81.txt

                        ServerGlobals.SendToAllClients(fake0);
                    }
                }
                break;

                case "switch":
                {
                    if (ServerGlobals.LoadFromSql)
                    {
                        ServerGlobals.LoadFromSql = false; Console.WriteLine("Loading from CharData.txt File.");
                    }
                    else
                    {
                        ServerGlobals.LoadFromSql = true; Console.WriteLine("Loading from MySql.");
                    }
                }
                break;

                case "croom":
                {
                    // Sends a packet derived from a filename in our debug dir
                    // args[1] is the filename
                    string fileLocation = string.Empty;
                    if (args.Length != 2)
                    {
                        Console.WriteLine("Please supply a filename with extention.");
                    }
                    else
                    {
                        if (args[1].Trim() == "off")
                        {
                            RealmPacketIO.CustomRoomLoad = false;
                            RealmPacketIO.CustomRoomFile = string.Empty;
                        }
                        else
                        {
                            fileLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), args[1].Trim());
                            if (!File.Exists(fileLocation))
                            {
                                Console.WriteLine("Unable to find file {0}", fileLocation);
                            }
                            else
                            {
                                RealmPacketIO.CustomRoomLoad = true;
                                RealmPacketIO.CustomRoomFile = args[1].Trim();
                                Console.WriteLine("CustomFile Atrrib = {0} for file {1}",
                                                  RealmPacketIO.CustomRoomLoad, RealmPacketIO.CustomRoomFile);
                            }
                        }
                    }
                }
                break;

                case "to":
                {
                }
                break;

                case "itempacket":
                {
                    for (int f = 0; f < 2001; f++)
                    {
                        Item i = new Item();
                        i.GraphicID = 1444;
                        i.Color     = 0x69;
                        //uint id = 0;
                        // byte[] r = i.Ser();
                        //byte[] item = i.Serialize(out id);
                        Console.Write("\rItem:{0}.          ", f);
                    }
                }
                break;

                case "send":
                {
                    // Sends a packet derived from a filename in our debug dir
                    // args[1] is the filename
                    string fileLocation = string.Empty;
                    if (args.Length != 2)
                    {
                        Console.WriteLine("Please supply a filename with extention.");
                    }
                    else
                    {
                        fileLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), args[1].Trim());
                        if (!File.Exists(fileLocation))
                        {
                            Console.WriteLine("Unable to find file {0}", fileLocation);
                        }
                        else
                        {
                            byte[] fileToArray = null;
                            try { fileToArray = RealmPacketIO.GetByteArrayFromFile(fileLocation); }
                            catch (Exception ex) { Console.WriteLine(ex.Message); }

                            if (fileToArray != null)
                            {
                                ServerGlobals.SendToAllClients(fileToArray);
                                Console.WriteLine("Sent {0}", fileLocation);
                            }
                        }
                    }
                }
                break;

                case "a":
                {
                }
                break;

                case "x":
                {
                    //byte[] p = RealmPacketIO.Test;
                    // ServerGlobals.SendToAllClients(p);
                }
                break;

                case "w":
                {
                    /*
                     * string fileLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Lookat.txt");
                     * byte[] fake0 = RealmPacketIO.GetByteArrayFromFile(fileLocation);
                     * byte[] len = BitConverter.GetBytes(fake0.Length);
                     * Console.WriteLine(BitConverter.ToString(len));
                     */
                }
                break;

                case "t":
                {
                    // try to get this room
                    Room found = null;
                    if (ScriptResolver.ImportedRooms.TryGetRoom(213, out found))
                    {
                        Console.WriteLine("Found room {0}", 213);
                        Console.WriteLine(BitConverter.ToString(found.GetRoomPacket(3)));
                    }
                }
                break;

                case "tt":
                {
                    // messin wit commands
                    if (ScriptResolver.ImportedCommands.Count == 0)
                    {
                        Console.WriteLine("WTF ?");
                    }
                    else
                    {
                        Console.WriteLine("{0} commands found.", ScriptResolver.ImportedCommands.Count);
                        foreach (Command cmd in ScriptResolver.ImportedCommands)
                        {
                            Console.WriteLine("Command Name {0}", cmd.CommandName);

                            Command[] cmds = ScriptResolver.ImportedCommands.CommandsByPrefix('/');
                            Console.WriteLine("Commands by Prefix returned {0}", cmds.Length);
                        }
                    }
                }
                break;

                case "lmob":
                {
                    string fileLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "mobtest.txt");
                    byte[] fake0        = RealmPacketIO.GetByteArrayFromFile(fileLocation);
                    byte[] len          = BitConverter.GetBytes(fake0.Length);
                    Console.WriteLine(BitConverter.ToString(len));
                }
                break;

                case "mob":
                {
                    string fileLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "mobtest.txt");
                    byte[] fake0        = RealmPacketIO.GetByteArrayFromFile(fileLocation);
                    Console.WriteLine("We have a packet {0} in length.", fake0.Length);
                    ServerGlobals.SendToAllClients(fake0);
                }
                break;

                case "s":
                {
                    string        fileLocation = Path.Combine(ServerGlobals.BaseDirectory, "Test.log");
                    RLog          log          = new RLog(fileLocation);
                    StringBuilder b            = new StringBuilder();
                    for (int i = 2000; i != 0; i--)
                    {
                        b.AppendLine(i.ToString());
                    }
                    log.LogMessage(b.ToString(), MessageType.Warning);
                }
                break;

                case "start":
                {
                    this.Start();
                }
                break;

                case "stop":
                    ThreadMgr.Stop();
                    srv.Stop();
                    break;

                case "exit":
                    this.Stop();
                    break;

                default:
                    Console.WriteLine("No Such Command: " + input + "\r\n");
                    break;
                }
            }
        }