Пример #1
0
 public void DestroyObject(PacketIn packet)
 {
     //Log.WriteLine(netLogic.Shared.LogType.Network, "SMSG_DESTROY_OBJECT {0}", packet.PacketId.RawId);
     GameGuid guid = new GameGuid(packet.ReadUInt64());
     //Destroy(GameObject.Find(guid.ToString()));
     GetInstance().ObjMgr().Remove(guid);
 }
Пример #2
0
 public void HandleCompressedObjectUpdate(PacketIn packet)
 {
     try
     {
         Int32 size = packet.ReadInt32();
         byte[] decomped = netLogic.Shared.Compression.Decompress(size, packet.ReadRemaining());
         packet = new PacketIn(decomped, 1);
         HandleObjectUpdate(packet);
     }
     catch(Exception ex)
     {
         Log.WriteLine(netLogic.Shared.LogType.Error, "{1} \n {0}", ex.StackTrace, ex.Message);
     }
 }
Пример #3
0
        public void HandlePacket(PacketIn packet)
        {
            PacketHandle handle = Handles.Find(s => PacketId.isEqual(s.packetId,packet.PacketId));
            if (handle != null)
            {

                System.Object[] obj = new System.Object[1];
                obj[0] = packet;

                try
                {
                    if (packet.PacketId.Service == ServiceType.Logon)
                    {
                        Log.WriteLine(LogType.Network, "Handling packet: {0}", handle.packetId);
                        handle.MethodInfo.Invoke(tClient, obj);
                    }
                    else if (packet.PacketId.Service == ServiceType.World)
                    {
                        Log.WriteLine(LogType.Network, "Handling packet: {0}", handle.packetId);
                        if (handle.packetId.RawId == 170)
                        {
                            Log.WriteLine(LogType.Network, "Handling packet: {0}", handle.packetId);
                        }
                        handle.MethodInfo.Invoke(wClient, obj);

                    }
                    //Log.WriteLine(LogType.Packet, packet.ToHex());
                }
                catch
                {
                }

            }
            else
            {
                 //Log.WriteLine(LogType.Normal, "Unhandled packet: {0}", packet.PacketId.ToString());
            }
        }
Пример #4
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(netLogic.Shared.LogType.Error, "M values doesn't match, please try again.");
                Disconnect();
            }
        }
Пример #5
0
 public void HandleAuthChallange(PacketIn packet)
 {
     packet.ReadUInt32();
     ServerSeed = packet.ReadUInt32();
     ClientSeed = (UInt32)random.Next();
     DoAuthSession();
 }
Пример #6
0
 public void GotWarden(PacketIn packet)
 {
     //Console.WriteLine(packet.ToHex());
 }
Пример #7
0
        public void GotMOTD(PacketIn packet)
        {
            var vari = packet.ReadUInt32();
            var str = packet.ReadCString();
            //Console.WriteLine(packet.ToHex());
            var guid = Global.GetInstance().GetWSession().GetMyGuid().GetOldGuid();
            QueryName(guid);
            PacketOut outpacket = new PacketOut(WorldServerOpCode.CMSG_SET_ACTIVE_MOVER);
            outpacket.Write(guid);
            Send(outpacket);

              //  LevelManager.Load("DEMO_WORLD");
        }
Пример #8
0
        public void RequestRealmlist()
        {
            PacketOut packet = new PacketOut(LogonServerOpCode.REALM_LIST);
            packet.Write(0x00);
            Send(packet);

            // Most tricky code ever. It's so because retail server sends a lot of data in this packet...
            byte[] temp = pLoop.OnReceive(3);
            PacketIn p1 = new PacketIn(temp, true);
            byte[] temp2 = pLoop.OnReceive(p1.ReadUInt16());
            byte[] temp3 = new byte[temp.Length + temp2.Length];
            temp.CopyTo(temp3, 0);
            temp2.CopyTo(temp3, temp.Length);

            p1 = new PacketIn(temp3, false);
            HandlePacket(p1);
        }
Пример #9
0
        public void Handle_NameQuery(PacketIn packet)
        {
            byte mask = packet.ReadByte();
            GameGuid guid = new GameGuid(mask, packet.ReadBytes(GameGuid.BitCount8(mask)));

            packet.ReadByte();
            string name = packet.ReadString();
            packet.ReadByte();

            //Races Race = (Races)packet.ReadByte();
            //Gender Gender = (Gender)packet.ReadByte();
            //Classes Class = (Classes)packet.ReadByte();

              /*  if (netLogicCore.ObjectMgr.GetObject(guid) != null)    // Update existing Object
            {
                obj = netLogicCore.ObjectMgr.GetObject(guid);
                obj.Name = name;

               // netLogicCore.ObjectMgr.updateObject(obj);
            }*/
             /*    else                // Create new Object        -- FIXME: Add to new 'names only' list?
             {
                 obj = new MMOObject(guid);
                 obj.Name = name;
                 netLogicCore.ObjectMgr.newObject(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 == guid)
                     {
                         Log.WriteLine(netLogic.Shared.LogType.Chat, "[{1}] {0}", message.Message, name);
                         ChatQueued.Remove(message);
                     }
                 }

             }*/
        }
Пример #10
0
        public void HandleChat(PacketIn packet)
        {
            try
            {

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

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

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

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

                if (Type == 47)
                    return;
                fguid2 = new GameGuid(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 (netLogicCore.ObjectMgr.objectExists(fguid))
                        //username = netLogicCore.ObjectMgr.GetObject(fguid).Name;
                }

                if (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;
                    ChatQueued.Add(que);
                    QueryName(guid);
                    return;
                }

                object[] param = new object[] { (ChatMsg)Type, channel, username, Message };
                netInstance.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);
            }
        }
Пример #11
0
        public void HandleLogonProof(PacketIn packetIn)
        {
            if (packetIn.ReadByte() == 0x00)
            {
                Log.WriteLine(LogType.Success, "Authenitcation successed. Requesting RealmList");
                netInstance.Event(new Event(EventType.EVENT_OK, "0", new object[] { "Succesfally connected" }));

                //Retail server sends a loooooot of informations there!
                RequestRealmlist();

                pLoop.Stop();

            }
            else {
                //Log.WriteLine(LogType.Error, "Authenitcation filed. Wrong information");
                netInstance.Event(new Event(EventType.EVENT_AUTH_FALSE, "0", new object[] { "Authenitcation filed. Wrong information" }));
                Global.GetInstance().Disconnect();
            }
        }
Пример #12
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);
        }
Пример #13
0
        public void HandleObjectUpdate(PacketIn packet)
        {
            /*   lock (packet)
            {
                StartCoroutine_Auto(ObjectUpdates(packet));
            }*/

            Global.GetInstance().myScheduler.ForceToMainThread = true;
            StartCoroutine(ParseValueAsync(packet));

            UInt32 UpdateBlocks = packet.ReadUInt32();

            for (int allBlocks = 0; allBlocks < UpdateBlocks; allBlocks++)
            {
                UpdateTypes type = (UpdateTypes)packet.ReadByte();

                switch (type)
                {
                    case UpdateTypes.UPDATETYPE_VALUES:
                        ParseValues(packet);
                        //StartCoroutine(ParseValueAsync(packet));
                        break;
                    case UpdateTypes.UPDATETYPE_MOVEMENT:
                        ParseMovement(packet);
                        //StartCoroutine(ParseMovementAsync(packet));
                        break;
                    case UpdateTypes.UPDATETYPE_CREATE_OBJECT:
                    case UpdateTypes.UPDATETYPE_CREATE_OBJECT2:

                        ParseCreateObjects(packet);
                        //StartCoroutine(CreateObjectAsync(packet));
                        break;
                    case UpdateTypes.UPDATETYPE_OUT_OF_RANGE_OBJECTS:
                        //ParseOutOfRangeObjects(packet);
                        break;
                    case UpdateTypes.UPDATETYPE_NEAR_OBJECTS:
                        //ParseNearObjects(packet);
                        break;
                    default:
                        Console.WriteLine("Unknown updatetype {0}", type);
                        break;
                }
            }
        }
Пример #14
0
        public void HandleCharEnum(PacketIn packet)
        {
            byte count = packet.ReadByte();

            PlayerEnum[] chr = new PlayerEnum[10];
            for (int i = 0; i < count; i++)
            {

                chr[i].GUID = new GameGuid(packet.ReadUInt64());
                chr[i].Name = packet.ReadString();
                chr[i].Race = packet.ReadByte();
                chr[i].Class = packet.ReadByte();
                chr[i].Gender = packet.ReadByte();
                chr[i].Skin = packet.ReadByte();
                chr[i].Face = packet.ReadByte();
                chr[i].HairStyle = packet.ReadByte();
                chr[i].HairColor = packet.ReadByte();
                chr[i].FacialHair = packet.ReadByte();
                chr[i].Level = packet.ReadByte();
                chr[i].ZoneID = packet.ReadUInt32();
                chr[i].MapID = packet.ReadUInt32();
                chr[i].X = packet.ReadFloat();
                chr[i].Y = packet.ReadFloat();
                chr[i].Z = packet.ReadFloat();

                chr[i].Guild = packet.ReadUInt32();
                chr[i].CharacterFlags = packet.ReadUInt32();
                chr[i].CustomizationFlags = packet.ReadUInt32();
                chr[i].FirstLogin = packet.ReadByte();
                chr[i].PetInfoID = packet.ReadUInt32();
                chr[i].PetLevel = packet.ReadUInt32();
                chr[i].PetFamilyID = packet.ReadUInt32();
                chr[i]._items = new PlayerEnumItem[23];
                for (int x = 0; x <= 22; x++)
                {
                    chr[i]._items[x].displayId = packet.ReadUInt32();
                    chr[i]._items[x].inventorytype = packet.ReadByte();
                    chr[i]._items[x].enchant = packet.ReadUInt32(); // enchant (2.4 patch)
                }

               /* packet.ReadByte();
                packet.ReadByte();
                packet.ReadByte();
                packet.ReadByte();*/

                CharacterListExt cx;
                cx.p = chr[i];
                cx.class_ = "classname";
                cx.race = "racename";
                cx.zone = "zonename";
                cx.map_ = "mapname";

                Global.GetInstance().GetWSession().GetCharList().Add(cx);

            }

            #region Default Char Create
            if (count == 0)
            {
                PacketOut outpacket = new PacketOut(WorldServerOpCode.CMSG_CHAR_CREATE);

                outpacket.Write("qweqwe");
                outpacket.Write((byte)1); // race - human
                outpacket.Write((byte)1); // class - warrior
                outpacket.Write((byte)0); // gender - male
                outpacket.Write((byte)1); // skin
                outpacket.Write((byte)1); // face
                outpacket.Write((byte)1); // hair style
                outpacket.Write((byte)1); // hair color
                outpacket.Write((byte)1); // facial hair
                outpacket.Write((byte)1); // outfit id
                Send(outpacket);
                outpacket = new PacketOut(WorldServerOpCode.CMSG_CHAR_ENUM);
                Send(outpacket);
                // return;
            }
            else {

            }
            #endregion

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

            PingLoop();
            LevelManager.Load("CharactersList");
        }
Пример #15
0
 public void HandlePacket(PacketIn packet)
 {
     //Log.WriteLine(LogType.Packet, "{0}", packet.ToHex());
     pHandler.HandlePacket(packet);
 }
Пример #16
0
 public void HandleChannelNotify(PacketIn packet)
 {
     Log.WriteLine(LogType.Success, "Dostalem takie gowno: {0}", packet.ReadByte());
 }
Пример #17
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;

                LevelManager.Load("RealmServers");
                //netInstance.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();
            }
        }
Пример #18
0
        public void _ItemQuerySingleResponse(PacketIn packet)
        {
            UInt32 ItemID;
              //  UInt32 unk;
               // uint unk8;
              //  string s;

            ItemID = packet.ReadUInt32();

            if (!(ItemID == 0x80000000)) // invalid item flag?
            {
                ItemProto proto = new ItemProto();
                proto.Id = ItemID;
                proto.Class = packet.ReadUInt32();
                proto.SubClass = packet.ReadUInt32();
                packet.ReadUInt32();
                proto.Name = packet.ReadString();
                packet.ReadByte();
                packet.ReadByte();
                packet.ReadByte();
                proto.DisplayInfoID = packet.ReadUInt32();
                proto.Quality = packet.ReadUInt32();
                proto.Flags = packet.ReadUInt32();
                proto.Faction = packet.ReadUInt32();
                proto.BuyPrice = packet.ReadUInt32();
                proto.SellPrice = packet.ReadUInt32();
                proto.InventoryType = packet.ReadUInt32();
                proto.AllowableClass = packet.ReadUInt32();
                proto.AllowableRace = packet.ReadUInt32();
                proto.ItemLevel = packet.ReadUInt32();
                proto.RequiredLevel = packet.ReadUInt32();
                proto.RequiredSkill = packet.ReadUInt32();
                proto.RequiredSkillRank = packet.ReadUInt32();
                proto.RequiredSpell = packet.ReadUInt32();
                proto.RequiredHonorRank = packet.ReadUInt32();
                proto.RequiredCityRank = packet.ReadUInt32();
                proto.RequiredReputationFaction = packet.ReadUInt32();
                proto.RequiredReputationRank = packet.ReadUInt32();
                proto.MaxCount = packet.ReadUInt32();
                proto.Stackable = packet.ReadUInt32();
                proto.ContainerSlots = packet.ReadUInt32();
                proto.StatsCount = packet.ReadUInt32();
                for (UInt32 i = 0; i<proto.StatsCount; i++)
                {
                    proto.ItemStat = new _ItemStat[10];
                    proto.ItemStat[i].ItemStatType = packet.ReadUInt32();
                    proto.ItemStat[i].ItemStatValue = packet.ReadUInt32();
                }
                proto.ScalingStatDistribution = packet.ReadUInt32();
                proto.ScalingStatValue = packet.ReadUInt32();
                for (int i = 0; i < 2; i++)
                {
                    proto.Damage = new _ItemDamage[2];
                    proto.Damage[i].DamageMin = packet.ReadFloat();
                    proto.Damage[i].DamageMax = packet.ReadFloat();
                    proto.Damage[i].DamageType = packet.ReadUInt32();
                }
                proto.Armor = packet.ReadUInt32();
                proto.HolyRes = packet.ReadUInt32();
                proto.FireRes = packet.ReadUInt32();
                proto.NatureRes = packet.ReadUInt32();
                proto.FrostRes = packet.ReadUInt32();
                proto.ShadowRes = packet.ReadUInt32();
                proto.ArcaneRes = packet.ReadUInt32();
                proto.Delay = packet.ReadUInt32();
                proto.Ammo_type = packet.ReadUInt32();
                proto.RangedModRange = packet.ReadFloat();
                for (int i = 0; i < 5; i++)
                {
                    proto.Spells = new _ItemSpell[5];
                    proto.Spells[i].SpellId = packet.ReadUInt32();
                    proto.Spells[i].SpellTrigger = packet.ReadUInt32();
                    proto.Spells[i].SpellCharges = packet.ReadUInt32();
                    proto.Spells[i].SpellCooldown = packet.ReadUInt32();
                    proto.Spells[i].SpellCategory = packet.ReadUInt32();
                    proto.Spells[i].SpellCategoryCooldown = packet.ReadUInt32();
                }
                proto.Bonding = packet.ReadUInt32();
                proto.Description = packet.ReadString();
                proto.PageText = packet.ReadUInt32();
                proto.LanguageID = packet.ReadUInt32();
                proto.PageMaterial = packet.ReadUInt32();
                proto.StartQuest = packet.ReadUInt32();
                proto.LockID = packet.ReadUInt32();
                proto.Material = packet.ReadUInt32();
                proto.Sheath = packet.ReadUInt32();
                proto.RandomProperty = packet.ReadUInt32();
                proto.RandomSuffix = packet.ReadUInt32();
                proto.Block = packet.ReadUInt32();
                proto.ItemSet = packet.ReadUInt32();
                proto.MaxDurability = packet.ReadUInt32();
                proto.Area = packet.ReadUInt32();
                proto.Map = packet.ReadUInt32();
                proto.BagFamily = packet.ReadUInt32();
                proto.TotemCategory = packet.ReadUInt32();
                for (UInt32 i = 0; i < 3; i++)
                {
                    proto.Socket = new _ItemSocket[3];
                    proto.Socket[i].Color = packet.ReadUInt32();
                    proto.Socket[i].Content = packet.ReadUInt32();
                }
                proto.socketBonus = packet.ReadUInt32();
                proto.GemProperties = packet.ReadUInt32();
                proto.RequiredDisenchantSkill = packet.ReadUInt32();
                proto.ArmorDamageModifier = packet.ReadFloat();
                proto.Duration = packet.ReadInt32();
                proto.ItemLimitCategory = packet.ReadUInt32();
                proto.HolidayId = packet.ReadUInt32();

                //TODO
               /* objmgr.Add(proto);
                objmgr.AssignNameToObj(proto->Id, TYPEID_ITEM, proto->Name);
                objmgr.AssignNameToObj(proto->Id, TYPEID_CONTAINER, proto->Name);*/

            }
        }
Пример #19
0
        public void Handle_CreatureQuery(PacketIn packet)
        {
            Entry entry = new Entry();
            entry.entry = packet.ReadUInt32();
            entry.name = packet.ReadString();
            entry.blarg = packet.ReadBytes(3);
            entry.subname = packet.ReadString();
            entry.flags = packet.ReadUInt32();
            entry.subtype = packet.ReadUInt32();
            entry.family = packet.ReadUInt32();
            entry.rank = packet.ReadUInt32();

            /*    foreach (MMOObject obj in netLogicCore.ObjectMgr.WorldObjects)
            {
                if (obj.Fields != null)
                {
                    if (obj.Fields[(int)UpdateFieldsLoader.GetUpdateField(ObjectTypes.TYPEID_UNIT,"OBJECT_FIELD_ENTRY").Value] == entry.entry)
                    {
                        obj.Name = entry.name;
                        obj.Rank = entry.rank;
                        obj.Family = entry.family;
                        obj.SubType = entry.subtype;
                        //netLogicCore.ObjectMgr.updateObject(obj);
                    }
                }
            }*/
        }