Esempio n. 1
0
        private void RetrieveRealmList()
        {
            Realm[] Realms;

            byte   op          = win.ReadByte();
            UInt16 Length      = win.ReadUInt16();
            UInt32 Request     = win.ReadUInt32();
            UInt16 NumOfRealms = win.ReadUInt16();

            Realms = new Realm[NumOfRealms];

            for (int i = 0; i < NumOfRealms; i++)
            {
                if ((i + 1) % 10 == 0)
                {
                    BoogieCore.Log(LogType.SystemDebug, "Retrieved realm {0} of {1}.", i + 1, NumOfRealms);
                }

                Realms[i].Type  = win.ReadByte();
                Realms[i].Color = win.ReadByte();
                win.ReadByte(); // unk
                Realms[i].Name       = win.ReadString();
                Realms[i].Address    = win.ReadString();
                Realms[i].Population = win.ReadFloat();
                Realms[i].NumChars   = win.ReadByte();
                Realms[i].Language   = win.ReadByte();
                Realms[i].Unk        = win.ReadByte();
            }

            byte Unk1 = win.ReadByte();
            byte Unk2 = win.ReadByte();

            BoogieCore.Log(LogType.SystemDebug, "Done.");

            String defaultRealm = BoogieCore.configFile.ReadString("Connection", "DefaultRealm");

            if (defaultRealm != "")
            {
                foreach (Realm r in Realms)
                {
                    if (r.Name.ToLower() == defaultRealm.ToLower())
                    {
                        BoogieCore.Log(LogType.System, "Defaulting to realm {0}", defaultRealm);

                        string[] address = r.Address.Split(':');
                        BoogieCore.Log(LogType.System, "Defaulting to realm {0} IP: {1} port: {2}", defaultRealm, address[0], address[1]);
                        IPAddress WSAddr = IPAddress.Parse(address[0]);//Dns.GetHostEntry(address[0]).AddressList[0];
                        BoogieCore.Log(LogType.System, "IP: {0}", WSAddr.ToString());
                        int WSPort = Int32.Parse(address[1]);
                        BoogieCore.ConnectToWorldServer(new IPEndPoint(WSAddr, WSPort));

                        return;
                    }
                }
            }

            BoogieCore.Event(new Event(EventType.EVENT_REALMLIST, Time.GetTime(), Realms));
        }