Esempio n. 1
0
        public new void SendVicinityChat(string message)
        {
            List <Dynel> Clients = Misc.FindClient.GetClientsInRadius(this, 100.0f);

            int[] recvers = new int[Clients.Count];
            int   index   = 0;

            foreach (Character child in Clients)
            {
                recvers[index] = child.ID;
                index++;
            }

            ChatCom.SendVicinity(recvers, message);
        }
Esempio n. 2
0
        /// <summary>
        /// Dynel send to Vicinity
        /// </summary>
        /// <param name="message">Message string</param>
        public void SendVicinityChat(string message)
        {
            // Default vicinity radius is 10 -- Midian
            List <Dynel> clients = FindClient.GetClientsInRadius(this, 10.0f);

            UInt32[] recvers = new UInt32[clients.Count];
            int      index   = 0;

            foreach (Character child in clients)
            {
                recvers[index] = (UInt32)child.Id;
                index++;
            }

            ChatCom.SendVicinity((UInt32)this.Id, 0, recvers, message);
        }
Esempio n. 3
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;
                }
            }
        }