public LobbyMainWin()
        {
            InitializeComponent();

            server = new SocketWrapper();
            server.OnAccept += new SocketWrapper.dlgAccept(server_OnAccept);
            server.OnClose += new SocketWrapper.dlgClose(server_OnClose);
            server.OnRead += new SocketWrapper.dlgRead(PacketProcessor);

            Logger l = new Logger(tLog);
            //listClients.ItemsSource = clients;

            MapDB.Load("Data\\MapList.bin");
            DigimonDB.Load("Data\\DigimonList.bin");

            Opt = Settings.Deserialize();

            Console.WriteLine("This server is configured to route players to the game server at {0}:{1}",
                Opt.GameServer.Host, Opt.GameServer.Port);
            if (Opt.LobbyServer.AutoStart)
            {
                server.Listen(new ServerInfo(Opt.LobbyServer.Port, Opt.LobbyServer.IP));
                sbInfo1.Content = "Starting Lobby Server...";
            }
        }
Example #2
0
        public Options()
        {
            InitializeComponent();

            mySettings = Settings.Deserialize("Settings.xml");

            tHost.Text = mySettings.AuthServer.Host;
            tPort.Text = mySettings.AuthServer.Port.ToString();
            chkStart.IsChecked = new bool?(mySettings.AuthServer.AutoStart);
        }
Example #3
0
 public static Settings Deserialize(string fileName)
 {
     Settings Settings = new Settings();
     if (File.Exists(fileName))
     {
         XmlSerializer xml = new XmlSerializer(typeof(Settings));
         using (Stream s = File.OpenRead(fileName))
         {
             Settings = (Settings)xml.Deserialize(s);
         }
         SqlDB.SetInfo(Settings.Database.Host, Settings.Database.Username, Settings.Database.Password, Settings.Database.Schema);
     }
     else
         Settings.Serialize("Settings.xml");
     return Settings;
 }
        public AuthMainWin()
        {
            InitializeComponent();

            server = new SocketWrapper();
            server.OnAccept += new SocketWrapper.dlgAccept(m_auth_OnAccept);
            server.OnRead += new SocketWrapper.dlgRead(m_auth_OnRead);
            server.OnClose += new SocketWrapper.dlgClose(server_OnClose);

            Logger _writer = new Logger(tLog);

            Opt = Settings.Deserialize();
            if (Opt.AuthServer.AutoStart)
            {
                ServerInfo info = new ServerInfo(Opt.AuthServer.Port, Opt.AuthServer.IP);
                server.Listen(info);
            }
        }
Example #5
0
        public Yggdrasil()
        {
            Opt = Settings.Deserialize();

            server = new SocketWrapper();
            server.OnAccept += new SocketWrapper.dlgAccept(server_OnAccept);
            server.OnClose += new SocketWrapper.dlgClose(server_OnClose);
            server.OnRead += new SocketWrapper.dlgRead(server_OnRead);

            //TODO: Load mob/map/item/etc databases
            EvolutionDB.Load("Data\\DigimonEvolve.bin");
            MapDB.Load("Data\\MapList.bin");
            PortalDB.Load("Data\\MapPortal.bin");
            DigimonDB.Load("Data\\DigimonList.bin");
            ItemDB.Load("Data\\ItemList.bin");
            MonsterDB.Load("Data\\MonsterList.bin");
            TacticsDB.Load("Data\\Tactics.bin");

            World();

            Initialize();
        }
Example #6
0
        public static void Process(Client client, byte[] buffer, Settings Opt)
        {
            PacketReader packet = new PacketReader(buffer);

            switch (packet.Type)
            {
                case -1:
                    {
                        Console.WriteLine("Accepted connection: {0}", client.m_socket.RemoteEndPoint);
                        client.Send(new Packets.PacketFFEF((short)(client.handshake ^ 0x7e41)));
                        break;
                    }
                case -3:
                    { break; }
                case 1706:
                    {
                        //request characters?
                        uint AcctId = BitConverter.ToUInt32(buffer, 8);
                        int UniId = BitConverter.ToInt32(buffer, 12);

                        packet.Skip(4);
                        uint tAcct = packet.ReadUInt();
                        int tUni = packet.ReadInt();

                        SqlDB.LoadUser(client, AcctId, UniId);
                        List<Character> listTamers = SqlDB.GetCharacters(client.AccountID);
                        client.Send(new Packets.Lobby.CharList(listTamers));
                        break;
                    }
                case 1703:
                    {
                        client.Send(packet.ToArray());
                        break;
                    }
                case 1302:
                    {
                        //Name Availability
                        string name = packet.ReadString();
                        if (SqlDB.NameAvail(name))
                            client.Send(new Packets.Lobby.NameCheck(1));
                        else
                            client.Send(new Packets.Lobby.NameCheck(0));
                        break;
                    }
                case 1303:
                    {
                        //Create Character
                        int position = packet.ReadByte();
                        int model = packet.ReadInt();
                        string name = packet.ReadZString();
                        packet.Seek(31);
                        int digiModel = packet.ReadInt();
                        string digiName = packet.ReadZString();

                        Console.WriteLine("CreateChar {0} {1}", (CharacterModel)model, name);

                        int charId = SqlDB.CreateCharacter(client.AccountID, position, model, name, digiModel);
                        int digiId = (int)SqlDB.CreateDigimon((uint)charId, digiName, digiModel);
                        SqlDB.SetPartner(charId, digiId);
                        SqlDB.SetTamer(charId, digiId);

                        client.Send(new Packets.Lobby.ConfirmCreate());
                        break;
                    }
                case 1304:
                    {
                        int slot = packet.ReadInt();
                        string code = packet.ReadString();
                        bool canDelete = SqlDB.VerifyCode(client.AccountID, code);
                        if (canDelete)
                        {
                            if (SqlDB.DeleteTamer(client.AccountID, slot))
                                client.Send(new Packets.Lobby.CharDelete(1));
                            else
                                client.Send(new Packets.Lobby.CharDelete(0));
                        }
                            else
                             client.Send(new Packets.Lobby.CharDelete(2));
                        break;
                    }
                case 1305:
                    {
                        //Request Map Server
                        int slot = packet.ReadInt();
                        Position pLoc = null;
                        try
                        {
                            SqlDB.SetLastChar(client.AccountID, slot);
                            pLoc = SqlDB.GetTamerPosition(client.AccountID, slot);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                        client.Send(new Packets.Lobby.ServerIP(Opt.GameServer.IP.ToString(), Opt.GameServer.Port,
                            pLoc.Map, pLoc.MapName));
                        break;
                    }
                default:
                    Console.WriteLine("Unknown Packet Type: {0}", packet.Type);
                    Console.WriteLine(packet.ToString());
                    break;
            }
        }
 private void mi_Options_Click(object sender, RoutedEventArgs e)
 {
     Options winOpt = new Options();
     if (winOpt.ShowDialog().Value)
         Opt = Settings.Deserialize();
 }
        private void btnSend_Click(object sender, RoutedEventArgs e)
        {
            string[] cmd = tConsole.Text.Split(' ');
            switch (cmd[0])
            {
                case "test":
                    {
                        TacticsDB.Load("Data\\Tactics.bin");
                        break;
                    }
                case "settings":
                    {
                        Settings s = new Settings();
                        s.Serialize("Settings.xml");
                        break;
                    }
                case "hatch":
                    {
                        Settings s = new Settings();
                        int[][] Rate = new int[5][] { new int[3], new int[3], new int[3], new int[3], new int[3] };
                        Random r = new Random();
                        for (int i = 0; i < 1000; i++ )
                        {
                            int Level = r.Next(0, 5);
                            int res = (int)s.GameServer.HatchRates.Hatch(Level);
                            Rate[Level][res]++;
                        }
                        Console.WriteLine("Level 1: {0} succeeded, {1} failed, {2} broke, {3} total",
                            Rate[0][0], Rate[0][1], Rate[0][2],
                            Rate[0][0] + Rate[0][1] + Rate[0][2]);
                        Console.WriteLine("Level 2: {0} succeeded, {1} failed, {2} broke, {3} total",
                            Rate[1][0], Rate[1][1], Rate[1][2],
                            Rate[1][0] + Rate[1][1] + Rate[1][2]);
                        Console.WriteLine("Level 3: {0} succeeded, {1} failed, {2} broke, {3} total",
                            Rate[2][0], Rate[2][1], Rate[2][2],
                            Rate[2][0] + Rate[2][1] + Rate[2][2]);
                        Console.WriteLine("Level 4: {0} succeeded, {1} failed, {2} broke, {3} total",
                            Rate[3][0], Rate[3][1], Rate[3][2],
                            Rate[3][0] + Rate[3][1] + Rate[3][2]);
                        Console.WriteLine("Level 5: {0} succeeded, {1} failed, {2} broke, {3} total",
                            Rate[4][0], Rate[4][1], Rate[4][2],
                            Rate[4][0] + Rate[4][1] + Rate[4][2]);
                        break;
                    }
                case "hatch2":
                    {
                        Settings s = new Settings();
                        int[] total = new int[6];
                        int eggs = 100;
                        if (cmd.Length >= 2)
                            int.TryParse(cmd[1], out eggs);
                        for (int i = 0; i < eggs; i++)
                        {
                            int level = 0;
                            while (level != 5)
                            {
                                int res = (int)s.GameServer.HatchRates.Hatch(level);
                                if (res == 0)
                                    level++;
                                else if (res == -1)
                                    continue;
                                else
                                    break;
                            }
                            total[level]++;

                        }
                        Console.WriteLine("No Inp. - {0} = {1}", total[0], total[0] / (float)eggs);
                        Console.WriteLine("Level 1 - {0} = {1}", total[1], total[1] / (float)eggs);
                        Console.WriteLine("Level 2 - {0} = {1}", total[2], total[2] / (float)eggs);
                        Console.WriteLine("Level 3 - {0} = {1}", total[3], total[3] / (float)eggs);
                        Console.WriteLine("Level 4 - {0} = {1}", total[4], total[4] / (float)eggs);
                        Console.WriteLine("Level 5 - {0} = {1}", total[5], total[5] / (float)eggs);
                        break;
                    }
                default:
                    break;
            }
        }