示例#1
0
 private static int ConsoleCtrHandler(ConsoleStart.ConsoleEvent e)
 {
     ConsoleStart.SetConsoleCtrlHandler(ConsoleStart.handler, false);
     if (GameServer.Instance != null)
     {
         GameServer.Instance.Stop();
     }
     return(0);
 }
示例#2
0
        public void OnAction(System.Collections.Hashtable parameters)
        {
            System.Console.WriteLine("This server GunnyII, edit and build by MrPhuong!");
            System.Console.WriteLine("Starting GameServer ... please wait a moment!");
            CenterServer.CreateInstance(new CenterServerConfig());
            ConsoleStart.StartServer();
            ConsoleClient client = new ConsoleClient();
            bool          flag   = true;

            while (flag)
            {
                try
                {
                    System.Console.Write("> ");
                    string   text  = System.Console.ReadLine();
                    string[] array = text.Split(new char[]
                    {
                        '&'
                    });
                    string key;
                    switch (key = array[0].ToLower())
                    {
                    case "exit":
                        flag = false;
                        continue;

                    case "notice":
                        if (array.Length < 2)
                        {
                            System.Console.WriteLine("公告需要公告内容,用&隔开!");
                            continue;
                        }
                        CenterServer.Instance.SendSystemNotice(array[1]);
                        continue;

                    case "reload":
                        if (array.Length < 2)
                        {
                            System.Console.WriteLine("加载需要指定表,用&隔开!");
                            continue;
                        }
                        CenterServer.Instance.SendReload(array[1]);
                        continue;

                    case "shutdown":
                        CenterServer.Instance.SendShutdown();
                        continue;

                    case "help":
                        System.Console.WriteLine(this.HelpStr);
                        continue;

                    case "AAS":
                        if (array.Length < 2)
                        {
                            System.Console.WriteLine("加载需要指定状态true or false,用&隔开!");
                            continue;
                        }
                        CenterServer.Instance.SendAAS(bool.Parse(array[1]));
                        continue;
                    }
                    if (text.Length > 0)
                    {
                        if (text[0] == '/')
                        {
                            text = text.Remove(0, 1);
                            text = text.Insert(0, "&");
                        }
                        try
                        {
                            if (!CommandMgr.HandleCommandNoPlvl(client, text))
                            {
                                System.Console.WriteLine("Unknown command: " + text);
                            }
                        }
                        catch (System.Exception ex)
                        {
                            System.Console.WriteLine(ex.ToString());
                        }
                    }
                }
                catch (System.Exception ex2)
                {
                    System.Console.WriteLine("Error:" + ex2.ToString());
                }
            }
            if (CenterServer.Instance != null)
            {
                CenterServer.Instance.Stop();
            }
        }
示例#3
0
        public void OnAction(Hashtable parameters)
        {
            Console.WriteLine("This server GunnyII, edit and build by SkelletonX!");
            Console.WriteLine("Starting GameServer ... please wait a moment!");
            GameServer.CreateInstance(new GameServerConfig());
            GameServer.Instance.Start();
            GameServer.KeepRunning = true;
            Console.WriteLine("Server started!");
            ConsoleClient client = new ConsoleClient();

            while (GameServer.KeepRunning)
            {
                try
                {
                    ConsoleStart.handler = new ConsoleStart.ConsoleCtrlDelegate(ConsoleStart.ConsoleCtrHandler);
                    ConsoleStart.SetConsoleCtrlHandler(ConsoleStart.handler, true);
                    Console.Write("> ");
                    string   text  = Console.ReadLine();
                    string[] array = text.Split(new char[]
                    {
                        ' '
                    });
                    string key;
                    switch (key = array[0])
                    {
                    case "exit":
                        GameServer.KeepRunning = false;
                        continue;

                    //dragonares
                    case "lock":
                        Console.Clear();
                        Console.WriteLine("Ten tai khoan: ");
                        string bnickname = Console.ReadLine();
                        Console.WriteLine("Ly do band: ");
                        string   breason = Console.ReadLine();
                        DateTime dt2     = new DateTime(2014, 07, 02); //Tempo de banimento
                        using (ManageBussiness mg = new ManageBussiness())
                        {
                            mg.ForbidPlayerByNickName(bnickname, dt2, false);
                        }
                        Console.WriteLine("Nguoi dung " + bnickname + " da bi khoa.");

                        break;

                    case "unlock":
                        Console.Clear();
                        Console.WriteLine("Ten tai khoan: ");
                        string   bnickname2 = Console.ReadLine();
                        DateTime dt22       = new DateTime(2014, 07, 02); //Tempo de banimento
                        using (ManageBussiness mg = new ManageBussiness())
                        {
                            mg.ForbidPlayerByNickName(bnickname2, dt22, true);
                        }
                        Console.WriteLine("Nguoi dung " + bnickname2 + " da mo khoa.");

                        break;

                    case "thongbao":
                    {
                        Console.WriteLine("Thong bao: ");
                        string value = Console.ReadLine();
                        Console.WriteLine(string.Format(value));
                        Console.WriteLine("Thong bao thanh cong .");
                        continue;
                    }

                    case "cp":
                    {
                        GameClient[]    allClients   = GameServer.Instance.GetAllClients();
                        int             num2         = (allClients == null) ? 0 : allClients.Length;
                        GamePlayer[]    allPlayers   = WorldMgr.GetAllPlayers();
                        int             num3         = (allPlayers == null) ? 0 : allPlayers.Length;
                        List <BaseRoom> allUsingRoom = RoomMgr.GetAllUsingRoom();
                        int             num4         = 0;
                        int             num5         = 0;
                        foreach (BaseRoom current in allUsingRoom)
                        {
                            if (!current.IsEmpty)
                            {
                                num4++;
                                if (current.IsPlaying)
                                {
                                    num5++;
                                }
                            }
                        }
                        double num6 = (double)GC.GetTotalMemory(false);
                        Console.WriteLine(string.Format("Total Clients/Players:{0}/{1}", num2, num3));
                        Console.WriteLine(string.Format("Total Rooms/Games:{0}/{1}", num4, num5));
                        Console.WriteLine(string.Format("Total Momey Used:{0} MB", num6 / 1024.0 / 1024.0));
                        continue;
                    }

                    case "shutdown":
                        ConsoleStart._count = 6;
                        ConsoleStart._timer = new Timer(new TimerCallback(ConsoleStart.ShutDownCallBack), null, 0, 60000);
                        continue;

                    case "savemap":
                        continue;

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

                    case "ball&reload":
                        if (BallMgr.ReLoad())
                        {
                            Console.WriteLine("Ball info is Reload!");
                            continue;
                        }
                        Console.WriteLine("Ball info is Error!");
                        continue;

                    case "map&reload":
                        if (MapMgr.ReLoadMap())
                        {
                            Console.WriteLine("Map info is Reload!");
                            continue;
                        }
                        Console.WriteLine("Map info is Error!");
                        continue;

                    case "mapserver&reload":
                        if (MapMgr.ReLoadMapServer())
                        {
                            Console.WriteLine("mapserver info is Reload!");
                            continue;
                        }
                        Console.WriteLine("mapserver info is Error!");
                        continue;

                    case "prop&reload":
                        if (PropItemMgr.Reload())
                        {
                            Console.WriteLine("prop info is Reload!");
                            continue;
                        }
                        Console.WriteLine("prop info is Error!");
                        continue;

                    case "item&reload":
                        if (ItemMgr.ReLoad())
                        {
                            Console.WriteLine("item info is Reload!");
                            continue;
                        }
                        Console.WriteLine("item info is Error!");
                        continue;

                    case "shop&reload":
                        if (ShopMgr.ReLoad())
                        {
                            Console.WriteLine("shop info is Reload!");
                            continue;
                        }
                        Console.WriteLine("shop info is Error!");
                        continue;

                    case "quest&reload":
                        if (QuestMgr.ReLoad())
                        {
                            Console.WriteLine("quest info is Reload!");
                            continue;
                        }
                        Console.WriteLine("quest info is Error!");
                        continue;

                    case "fusion&reload":
                        if (FusionMgr.ReLoad())
                        {
                            Console.WriteLine("fusion info is Reload!");
                            continue;
                        }
                        Console.WriteLine("fusion info is Error!");
                        continue;

                    case "consortia&reload":
                        if (ConsortiaMgr.ReLoad())
                        {
                            Console.WriteLine("consortiaMgr info is Reload!");
                            continue;
                        }
                        Console.WriteLine("consortiaMgr info is Error!");
                        continue;

                    case "rate&reload":
                        if (RateMgr.ReLoad())
                        {
                            Console.WriteLine("Rate Rate is Reload!");
                            continue;
                        }
                        Console.WriteLine("Rate Rate is Error!");
                        continue;

                    case "fight&reload":
                        if (FightRateMgr.ReLoad())
                        {
                            Console.WriteLine("FightRateMgr is Reload!");
                            continue;
                        }
                        Console.WriteLine("FightRateMgr is Error!");
                        continue;

                    case "dailyaward&reload":
                        if (AwardMgr.ReLoad())
                        {
                            Console.WriteLine("dailyaward is Reload!");
                            continue;
                        }
                        Console.WriteLine("dailyaward is Error!");
                        continue;

                    case "language&reload":
                        if (LanguageMgr.Reload(""))
                        {
                            Console.WriteLine("language is Reload!");
                            continue;
                        }
                        Console.WriteLine("language is Error!");
                        continue;

                    case "nickname":
                    {
                        Console.WriteLine("Please enter the nickname");
                        string nickName = Console.ReadLine();
                        string playerStringByPlayerNickName = WorldMgr.GetPlayerStringByPlayerNickName(nickName);
                        Console.WriteLine(playerStringByPlayerNickName);
                        continue;
                    }
                    }
                    if (text.Length > 0)
                    {
                        if (text[0] == '/')
                        {
                            text = text.Remove(0, 1);
                            text = text.Insert(0, "&");
                        }
                        try
                        {
                            if (!CommandMgr.HandleCommandNoPlvl(client, text))
                            {
                                Console.WriteLine("Unknown command: " + text);
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                        }
                    }
                }
                catch (Exception value)
                {
                    Console.WriteLine(value);
                }
            }
            if (GameServer.Instance != null)
            {
                GameServer.Instance.Stop();
            }
            LogManager.Shutdown();
        }