Exemplo n.º 1
0
        public void HandleMonsterMove(PacketIn packet)
        {
            byte mask = packet.ReadByte();

            WoWGuid guid = new WoWGuid(mask, packet.ReadBytes(WoWGuid.BitCount8(mask)));

            Object obj = objectMgr.getObject(guid);
            if (obj != null)
            {
                    obj.Position = new Coordinate(packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat());
            }
        }
Exemplo n.º 2
0
        public void Handle_NameQuery(PacketIn packet)
        {
            WoWGuid guid = new WoWGuid(packet.ReadUInt64());
                string name = packet.ReadString();
                packet.ReadByte();
                Race Race = (Race)packet.ReadUInt32();
                Gender Gender = (Gender)packet.ReadUInt32();
                Classname Class = (Classname)packet.ReadUInt32();

                if (objectMgr.objectExists(guid))    // Update existing Object
                {
                    Object obj = objectMgr.getObject(guid);
                    obj.Name = name;
                    objectMgr.updateObject(obj);
                }
                else                // Create new Object        -- FIXME: Add to new 'names only' list?
                {
                    Object obj = new Object(guid);
                    obj.Name = name;
                    objectMgr.addObject(obj);

                    /* 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())
                        {
                            Log.WriteLine(LogType.Chat, "[{1}] {0}", message.Message, name);
                            ChatQueued.Remove(message);
                        }
                    }

                }
        }
Exemplo n.º 3
0
        public void HandleUpdateObjectFieldBlock(PacketIn packet, Object newObject)
        {
            uint lenght = packet.ReadByte();

            UpdateMask UpdateMask = new UpdateMask();
            UpdateMask.SetCount((ushort)(lenght));
            UpdateMask.SetMask(packet.ReadBytes((int)lenght * 4), (ushort)lenght);
            UInt32[] Fields = new UInt32[UpdateMask.GetCount()];

            for (int i = 0; i < UpdateMask.GetCount(); i++)
            {
                if (!UpdateMask.GetBit((ushort)i))
                {
                    UInt32 val = packet.ReadUInt32();
                    newObject.SetField(i, val);
                    Log.WriteLine(LogType.Normal, "Update Field: {0} = {1}", (UpdateFields)i, val);
                }
            }
        }
Exemplo n.º 4
0
        public void HandleLogonProof(PacketIn packetIn)
        {
            if (packetIn.ReadByte() == 0x00)
            {
                Log.WriteLine(LogType.Success, "Authenitcation successed. Requesting RealmList");

                //Retail server sends a loooooot of informations there!
                RequestRealmlist();
                pLoop.Stop();
            }
        }
Exemplo n.º 5
0
        public void HandleRealmlist(PacketIn packetIn)
        {
            //packetIn.ReadByte();
            UInt16 Length = packetIn.ReadUInt16();
            UInt32 Request = packetIn.ReadUInt32();
            int realmscount = packetIn.ReadInt16();

            //Console.Write(packetIn.ToHex());

            Log.WriteLine(LogType.Success, "Got information about {0} realms.", realmscount);
            Realm[] realms = new Realm[realmscount];
            try
            {
                for (int i = 0; i < realmscount; i++)
                {
                    realms[i].Type = packetIn.ReadByte();
                    realms[i].Color = packetIn.ReadByte();
                    packetIn.ReadByte(); // unk
                    realms[i].Name = packetIn.ReadString();
                    realms[i].Address = packetIn.ReadString();
                    realms[i].Population = packetIn.ReadFloat();
                    realms[i].NumChars = packetIn.ReadByte();
                    realms[i].Language = packetIn.ReadByte();
                    packetIn.ReadByte();
               }

                Realmlist = realms;
                mCore.Event(new Event(EventType.EVENT_REALMLIST, "", new object[] { Realmlist }));

            }
            catch (Exception ex)
            {
                Log.WriteLine(LogType.Error, "Exception Occured");
                Log.WriteLine(LogType.Error, "Message: {0}", ex.Message);
                Log.WriteLine(LogType.Error, "Stacktrace: {0}", ex.StackTrace);
                Disconnect();
            }
        }
Exemplo n.º 6
0
        public void AuthChallangeRequest(PacketIn packetIn)
        {
            packetIn.ReadByte();
            byte error = packetIn.ReadByte();
            if (error != 0x00)
            {
                Log.WriteLine(LogType.Error, "Authentication error: {0}", (AccountStatus)error);
                Disconnect();
                return;
            }

            B = new BigInteger(packetIn.ReadBytes(32));               // Varies
            byte glen = packetIn.ReadByte();                          // Length = 1
            g = packetIn.ReadBytes(glen);                             // g = 7
            byte Nlen = packetIn.ReadByte();                          // Length = 32
            N = packetIn.ReadBytes(Nlen);                             // N = B79B3E2A87823CAB8F5EBFBF8EB10108535006298B5BADBD5B53E1895E644B89
            Salt = new BigInteger(packetIn.ReadBytes(32));            // Salt = 3516482AC96291B3C84B4FC204E65B623EFC2563C8B4E42AA454D93FCD1B56BA
            crcsalt = packetIn.ReadBytes(16);                         // Varies

            BigInteger S;
            srp = new Srp6(new BigInteger(N), new BigInteger(g));

            do
            {
                a = BigInteger.Random(19 * 8);
                A = srp.GetA(a);

                I = Srp6.GetLogonHash(mUsername, mPassword);

                BigInteger x = Srp6.Getx(Salt, I);
                BigInteger u = Srp6.Getu(A, B);
                S = srp.ClientGetS(a, B, x, u);
            }
            while (S < 0);

            mKey = Srp6.ShaInterleave(S);
            M = srp.GetM(mUsername, Salt, A, B, new BigInteger(mKey));

            packetIn.ReadByte();

            Sha1Hash sha;
            byte[] files_crc;

            // Generate CRC/hashes of the Game Files
            if (Config.Retail)
                files_crc = GenerateCrc(crcsalt);
            else
                files_crc = new byte[20];

            // get crc_hash from files_crc
            sha = new Sha1Hash();
            sha.Update(A);
            sha.Update(files_crc);
            byte[] crc_hash = sha.Final();

            PacketOut packet = new PacketOut(LogonServerOpCode.AUTH_LOGON_PROOF);
            packet.Write(A); // 32 bytes
            packet.Write(M); // 20 bytes
            packet.Write(crc_hash); // 20 bytes
            packet.Write((byte)0); // number of keys
            packet.Write((byte)0); // unk (1.11.x)
            Send(packet);
        }
Exemplo n.º 7
0
        public void HandleCharEnum(PacketIn packet)
        {
            byte count = packet.ReadByte();

            Character[] characterList = new Character[count];
            for (int i = 0; i < count; i++)
            {

                characterList[i].GUID = packet.ReadUInt64();
                characterList[i].Name = packet.ReadString();
                characterList[i].Race = packet.ReadByte();
                characterList[i].Class = packet.ReadByte();
                packet.ReadByte();
                packet.ReadUInt32();
                packet.ReadByte();
                packet.ReadByte();
                packet.ReadUInt32();
                characterList[i].MapID = packet.ReadUInt32();
                packet.ReadFloat();
                packet.ReadFloat();
                packet.ReadFloat();
                packet.ReadUInt32();
                packet.ReadUInt32();
                packet.ReadByte();

                packet.ReadUInt32();
                packet.ReadUInt32();
                packet.ReadUInt32();
                packet.ReadBytes(9 * 20);
            }

            Log.WriteLine(LogType.Success, "Received info about {0} characters", count);

            Charlist = characterList;
            mCore.Event(new Event(EventType.EVENT_CHARLIST, "", new object[] { Charlist }));
            PingLoop();
        }
Exemplo n.º 8
0
        public void HandleAuthResponse(PacketIn packet)
        {
            LoginErrorCode error = (LoginErrorCode)packet.ReadByte();
            if (error == LoginErrorCode.AUTH_OK)
            {

                PacketOut outpacket = new PacketOut(WorldServerOpCode.CMSG_CHAR_ENUM);
                Send(outpacket);

            }
            else
            {
                Log.WriteLine(LogType.Error, "M values doesn't match, please try again.");
                Disconnect();
            }
        }
Exemplo n.º 9
0
        public void HandleChat(PacketIn packet)
        {
            try
            {

                string channel = null;
                UInt64 guid = 0;
                WoWGuid fguid = null, fguid2 = null;
                string username = null;

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

                guid = packet.ReadUInt64();
                fguid = new WoWGuid(guid);
                packet.ReadInt32();

                if ((ChatMsg)Type == ChatMsg.Channel)
                {
                    channel = packet.ReadString();
                }

                if (Type == 47)
                    return;
                fguid2 = new WoWGuid(packet.ReadUInt64());

                UInt32 Length = packet.ReadUInt32();
                string Message = Encoding.Default.GetString(packet.ReadBytes((int)Length));

                //Message = Regex.Replace(Message, @"\|H[a-zA-z0-9:].|h", ""); // Why do i should need spells and quest linked? ;>
                Message = Regex.Replace(Message, @"\|[rc]{1}[a-zA-z0-9]{0,8}", ""); // Colorfull chat message also isn't the most important thing.

                byte afk = 0;

                if (fguid.GetOldGuid() == 0)
                {
                    username = "******";
                }
                else
                {
                    if (objectMgr.objectExists(fguid))
                        username = objectMgr.getObject(fguid).Name;
                }

                if (username == null)
                {

                    ChatQueue que = new ChatQueue();
                    que.GUID = fguid;
                    que.Type = Type;
                    que.Language = Language;
                    if ((ChatMsg)Type == ChatMsg.Channel)
                        que.Channel = channel;
                    que.Length = Length;
                    que.Message = Message;
                    que.AFK = afk;
                    ChatQueued.Add(que);
                    QueryName(guid);
                    return;
                }

                object[] param = new object[] { (ChatMsg)Type, channel, username, Message };
                mCore.Event(new Event(EventType.EVENT_CHAT_MSG, "0", param));
                //Log.WriteLine(LogType.Chat, "[{1}] {0}", Message, username);
            }
            catch (Exception ex)
            {
                Log.WriteLine(LogType.Error, "Exception Occured");
                Log.WriteLine(LogType.Error, "Message: {0}", ex.Message);
                Log.WriteLine(LogType.Error, "Stacktrace: {0}", ex.StackTrace);
            }
        }
Exemplo n.º 10
0
 public void HandleChannelNotify(PacketIn packet)
 {
     Log.WriteLine(LogType.Success, "Dostalem takie gowno: {0}", packet.ReadByte());
 }