예제 #1
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.Title           = "Leatty " + ServerConstants.Version;

            ServerConstants.LoadFromFile();

            InitializeDatabase();
            LoadDataBuffers();
            CustomNpcs = DataProvider.LoadCustomNpcs();
            StartCashShop();
            StartLogin();
            StartChannels();
            PingTimer.Elapsed += (sender, e) => PingClients();


            StartDataApi();

            GC.Collect();
            string line = string.Empty;

            while (!(line = Console.ReadLine().ToLower()).Contains("stop") && !line.Contains("exit"))
            {
                string[] split = line.Split(' ');
                if (split.Length > 0)
                {
                    switch (split[0])
                    {
                    case "login":
                        if (ServerConstants.LocalHost && Program.Clients.Any())
                        {
                            MapleClient  c   = Program.Clients.First().Value;
                            MapleAccount acc = MapleAccount.GetAccountFromDatabase("Nuclear");
                            c.SendPacket(LoginAccountHandler.LoginAccountSuccess(acc));
                        }
                        break;

                    case "mapleshark":
                    case "maplesharkconfig":
                        MapleSharkConfigCreator.GenerateConfigFile();
                        break;

                    case "dumpskills":
                        Functions.DumpSkillConstants();
                        break;

                    case "dumpitems":
                        Functions.DumpItems();
                        break;

                    case "send":
                        if (split.Length > 4)
                        {
                            MapleCharacter chr = GetCharacterByName(split[1]);
                            if (chr == null)
                            {
                                ServerConsole.Info("Player " + split[1] + "not found");
                            }
                            else
                            {
                                PacketWriter pw = new PacketWriter();
                                pw.WriteHexString(split.Fuse(2));
                                chr.Client.SendPacket(pw);
                            }
                        }
                        break;

                    case "notice":
                        if (split.Length > 1)
                        {
                            string message = "[Notice] " + split.Fuse(1);
                            BroadCastWorldPacket(MapleCharacter.ServerNotice(message, 6));
                        }
                        break;

                    default:
                        ServerConsole.Info("Unknown command: " + line);
                        break;
                    }
                }
            }
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Shutting down...");
            Quit();
        }