Exemple #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));
        }
        public void PartChannel(string channel)
        {
            WoWWriter wr = new WoWWriter(OpCode.CMSG_LEAVE_CHANNEL);

            wr.Write((UInt32)0);
            wr.Write(channel);
            Send(wr.ToArray());

            ChannelList.Remove(channel);

            BoogieCore.Event(new Event(EventType.EVENT_CHANNEL_LEFT, Time.GetTime(), channel));
        }
Exemple #3
0
        //  Updates the UI
        public void updatePlayerLocationUI()
        {
            Object mObj = getPlayerObject();

            // Update the UI on our location
            Event e1 = new Event(EventType.EVENT_SELF_MOVED, Time.GetTime(), mObj.coord);

            BoogieCore.Event(e1);


            //Event e2 = new Event(EventType.EVENT_LOCATION_UPDATE, Time.GetTime(), location);
            //BoogieCore.Event(e2);
        }
        public void JoinChannel(string channel, string password)
        {
            WoWWriter wr = new WoWWriter(OpCode.CMSG_JOIN_CHANNEL);

            wr.Write((UInt32)0); // dbc id??
            wr.Write((UInt16)0); // crap as ascent put it

            wr.Write(channel);
            wr.Write((byte)0);
            Send(wr.ToArray());

            ChannelList.Add(channel);

            BoogieCore.Event(new Event(EventType.EVENT_CHANNEL_JOINED, Time.GetTime(), channel));
        }
        private void Handle_NameQuery(WoWReader wr)
        {
            WoWGuid guid   = new WoWGuid(wr.ReadUInt64());
            string  name   = wr.ReadString();
            UInt16  unk    = wr.ReadByte();
            UInt32  Race   = wr.ReadUInt32();
            UInt32  Gender = wr.ReadUInt32();
            UInt32  Level  = wr.ReadUInt32();

            BoogieCore.Log(LogType.NeworkComms, "Got NameQuery Response - GUID: {4} Name: {0} - Race: {1} - Gender: {2} - Level: {3}", name, Race, Gender, Level, BitConverter.ToUInt64(guid.GetNewGuid(), 0));

            Object obj = BoogieCore.world.getObject(guid);

            if (obj != null)    // Update existing object
            {
                obj.Name   = name;
                obj.Race   = Race;
                obj.Gender = Gender;
                obj.Level  = Level;
                BoogieCore.world.updateObject(obj);
            }
            else                // Create new Object        -- FIXME: Add to new 'names only' list?
            {
                obj        = new Object();
                obj.GUID   = guid;
                obj.Name   = name;
                obj.Race   = Race;
                obj.Gender = Gender;
                obj.Level  = Level;
                BoogieCore.world.newObject(obj, true);
            }

            /* Process chat message if we looked them up now */
            for (int i = 0; i < ChatQueued.Count; i++)
            {
                ChatQueue message = (ChatQueue)ChatQueued[i];
                if (message.GUID.GetOldGuid() == guid.GetOldGuid())
                {
                    BoogieCore.Event(new Event(EventType.EVENT_CHAT, Time.GetTime(), message, name));
                    ChatQueued.Remove(message);
                }
            }

            // WoWChat uses this to retrive names on friends and ignore list.
            BoogieCore.Event(new Event(EventType.EVENT_NAMEQUERY_RESPONSE, Time.GetTime(), guid, name));
        }
        private void Handle_MessageChat(WoWReader wr)
        {
            string  channel = null;
            UInt64  guid = 0;
            WoWGuid fguid = null, fguid2 = null;


            byte   Type     = wr.ReadByte();
            UInt32 Language = wr.ReadUInt32();

            fguid = new WoWGuid(wr.ReadUInt64());
            wr.ReadUInt32(); // rank?

            if ((ChatMsg)Type == ChatMsg.CHAT_MSG_CHANNEL)
            {
                channel = wr.ReadString();
                //pvp_rank = wr.ReadUInt32();
            }

            //if (Type == 0 || Type == 1 || Type == 5 || Type == 0x53)
            //{
            fguid2 = new WoWGuid(wr.ReadUInt64());

            //}

            UInt32 Length  = wr.ReadUInt32();
            string Message = wr.ReadString();
            byte   afk     = wr.ReadByte();


            string username = null;


            ChatQueue que = new ChatQueue();

            que.GUID     = fguid;
            que.Type     = Type;
            que.Language = Language;
            if ((ChatMsg)Type == ChatMsg.CHAT_MSG_CHANNEL)
            {
                que.Channel = channel;
            }
            que.Length  = Length;
            que.Message = Message;
            que.AFK     = afk;

            if (fguid.GetOldGuid() == 0)
            {
                username = "******";
            }
            else
            {
                username = BoogieCore.world.getObjectName(fguid);
            }

            if (username == null)
            {
                ChatQueued.Add(que);
                QueryName(guid);
                return;
            }
            ParseCommands(que, username);

            BoogieCore.Event(new Event(EventType.EVENT_CHAT, Time.GetTime(), que, username));
        }
        private void Handle_CharEnum(WoWReader wr)
        {
            BoogieCore.Log(LogType.NeworkComms, "WS: Recieved Character List..");
            byte count = wr.ReadByte();

            characterList = new Character[count];

            for (int i = 0; i < count; i++)
            {
                characterList[i].GUID        = wr.ReadUInt64();
                characterList[i].Name        = wr.ReadString();
                characterList[i].Race        = wr.ReadByte();
                characterList[i].Class       = wr.ReadByte();
                characterList[i].Gender      = wr.ReadByte();
                characterList[i].Skin        = wr.ReadByte();
                characterList[i].Face        = wr.ReadByte();
                characterList[i].HairStyle   = wr.ReadByte();
                characterList[i].HairColor   = wr.ReadByte();
                characterList[i].FacialHair  = wr.ReadByte();
                characterList[i].Level       = wr.ReadByte();
                characterList[i].ZoneID      = wr.ReadUInt32();
                characterList[i].MapID       = wr.ReadUInt32();
                characterList[i].X           = wr.ReadFloat();
                characterList[i].Y           = wr.ReadFloat();
                characterList[i].Z           = wr.ReadFloat();
                characterList[i].Guild       = wr.ReadUInt32();
                characterList[i].Unk         = wr.ReadUInt32();
                characterList[i].RestState   = wr.ReadByte();
                characterList[i].PetInfoID   = wr.ReadUInt32();
                characterList[i].PetLevel    = wr.ReadUInt32();
                characterList[i].PetFamilyID = wr.ReadUInt32();

                CharEquipment[] equip = new CharEquipment[20];

                for (int x = 0; x < 20; x++)
                {
                    equip[x].EntryID = wr.ReadUInt32();
                    equip[x].Type    = wr.ReadByte();
                    wr.ReadUInt32(); // enchant (2.4 patch)
                }

                characterList[i].Equipment = equip;
            }

            BoogieCore.Log(LogType.NeworkComms, "{0} characters in total.", characterList.Length);

            String defaultChar = BoogieCore.configFile.ReadString("Connection", "DefaultChar");

            if (defaultChar != "")
            {
                foreach (Character c in characterList)
                {
                    if (c.Name.ToLower() == defaultChar.ToLower())
                    {
                        BoogieCore.Log(LogType.System, "Defaulting to Character {0}", defaultChar);
                        BoogieCore.WorldServerClient.LoginChar(c.GUID);
                        return;
                    }
                }
            }

            if (count < 1)
            {
                string name = RandomString(6, false);
                BoogieCore.Log(LogType.System, "Auto-Generating Human Character with the name {0}", name);

                WoWWriter ww = new WoWWriter(OpCode.CMSG_CHAR_CREATE);
                ww.Write(name);
                ww.Write((byte)1); // race - human
                ww.Write((byte)1); // class - warrior
                ww.Write((byte)0); // gender - male
                ww.Write((byte)1); // skin
                ww.Write((byte)1); // face
                ww.Write((byte)1); // hair style
                ww.Write((byte)1); // hair color
                ww.Write((byte)1); // facial hair
                ww.Write((byte)1); // outfit id
                Send(ww.ToArray());
                ww = new WoWWriter(OpCode.CMSG_CHAR_ENUM);
                Send(ww.ToArray());
                return;
            }

            if (count == 1)
            {
                BoogieCore.Log(LogType.System, "Defaulting to Character {0}", characterList[0].Name);
                BoogieCore.WorldServerClient.LoginChar(characterList[0].GUID);
                return;
            }

            BoogieCore.Event(new Event(EventType.EVENT_CHAR_LIST, Time.GetTime(), characterList));
        }