예제 #1
0
        public static void DropItem(Client client, PacketIn packet)
        {
            int        IID   = (int)packet.ReadUInt32();
            PlayerItem pItem = PlayerItem.GetItem(IID);

            int quantity = (int)packet.ReadUInt32();

            //check if the item exists
            if (pItem == null)
            {
                Hackshield.AddOffense(client, OffenseSeverity.IncorrectPacketDetails);
                return;
            }

            //check if player owns the item
            if (pItem.PID != client.Character.Player.PID)
            {
                Hackshield.AddOffense(client, OffenseSeverity.IncorrectPacketDetails);
                return;
            }

            CodeHandler handler = CodeManager.GetHandler(pItem.Item.Code);

            handler.Drop(pItem, quantity, client.Character, client);
        }
예제 #2
0
        public static void DropItem(Client client, PacketIn packet)
        {
            int IID = (int)packet.ReadUInt32();
            PlayerItem pItem = PlayerItem.GetItem(IID);

            int quantity = (int)packet.ReadUInt32();

            //check if the item exists
            if (pItem == null)
            {
                Hackshield.AddOffense(client, OffenseSeverity.IncorrectPacketDetails);
                return;
            }

            //check if player owns the item
            if (pItem.PID != client.Character.Player.PID)
            {
                Hackshield.AddOffense(client, OffenseSeverity.IncorrectPacketDetails);
                return;
            }

            CodeHandler handler = CodeManager.GetHandler(pItem.Item.Code);

            handler.Drop(pItem, quantity, client.Character, client);
        }
        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);
                    }
                }
            }
        }
예제 #4
0
파일: PT_Item.cs 프로젝트: sgentens/KaLua
        public static void DropItem(Client client, PacketIn packet)
        {
            int        itemId   = (int)packet.ReadUInt32();
            PlayerItem item     = PlayerItem.Get(itemId);
            int        quantity = (int)packet.ReadUInt32();

            if (item == null)
            {
                ServerConsole.WriteLine(
                    "Player #{0} attempted to drop non-existant item #{1} !",
                    client.Character.Player.PlayerId,
                    itemId
                    );
                return;
            }

            if (item.PlayerId != client.Character.Player.PlayerId)
            {
                ServerConsole.WriteLine(
                    "Player #{0} attempted to drop item that belongs to #{1}!",
                    client.Character.Player.PlayerId,
                    item.PlayerId
                    );
                return;
            }

            uint worldId = World.NewId();

            Server.WorldDrops[worldId] = new Drop(item, client.Character, quantity, worldId);

            client.Send(new Packets.SpawnDrop(Server.WorldDrops[worldId]), "Spawn Drop");
            client.Send(new Packets.RemoveFromInventory(item.ItemId, quantity), "Update Inventory");
            client.Character.Player.Inventory.Items.Remove(item);
        }
예제 #5
0
파일: PT_Item.cs 프로젝트: KalOnline/KaLua
        public static void DropItem(Client client, PacketIn packet)
        {
            int itemId      = (int)packet.ReadUInt32();
            PlayerItem item = PlayerItem.Get(itemId);
            int quantity    = (int)packet.ReadUInt32();

            if(item == null) {
                ServerConsole.WriteLine(
                    "Player #{0} attempted to drop non-existant item #{1} !",
                    client.Character.Player.PlayerId,
                    itemId
                );
                return;
            }

            if(item.PlayerId != client.Character.Player.PlayerId) {
                ServerConsole.WriteLine(
                    "Player #{0} attempted to drop item that belongs to #{1}!",
                    client.Character.Player.PlayerId,
                    item.PlayerId
                );
                return;
            }

            uint worldId = World.NewId();
            Server.WorldDrops[worldId] = new Drop(item,client.Character,quantity,worldId);

            client.Send(new Packets.SpawnDrop(Server.WorldDrops[worldId]),"Spawn Drop");
            client.Send(new Packets.RemoveFromInventory(item.ItemId,quantity),"Update Inventory");
            client.Character.Player.Inventory.Items.Remove(item);
        }
예제 #6
0
 public void HandleAuthChallange(PacketIn packet)
 {
     packet.ReadUInt32();
     ServerSeed = packet.ReadUInt32();
     ClientSeed = (UInt32)0;
     DoAuthSession();
 }
        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 (Object obj in objectMgr.getObjectArray())
            {
                if (obj.Fields != null)
                {
                    if (obj.Fields[(int)UpdateFields.OBJECT_FIELD_ENTRY] == entry.entry)
                    {
                        obj.Name = entry.name;
                        objectMgr.updateObject(obj);
                    }
                }
            }
        }
예제 #8
0
 public SELECT_SERVER(PacketIn p, ref byte[] pAESKey)
 {
     result = p.ReadUInt16();
     encrypted_data_size = p.ReadInt32();
     encrypted_data      = new byte[encrypted_data_size];
     p.Read(encrypted_data, 0, encrypted_data_size);
     encrypted_data = XClientAuthEmulator.DecryptAES(pAESKey, encrypted_data);
     pending_time   = p.ReadUInt32();
     unknown        = p.ReadUInt32();
     unknown2       = p.ReadUInt32();
 }
예제 #9
0
파일: PT_Item.cs 프로젝트: KalOnline/KaLua
 public static void EquipItem(Client client, PacketIn packet)
 {
     int itemId = (int)packet.ReadUInt32();
     PlayerItem item = PlayerItem.Get(itemId);
     if(item == null) {
         ServerConsole.WriteLine(
             System.Drawing.Color.Red,
             "Player #{0} attempted to equip non-existant item!",
             client.Character.Player.PlayerId
         );
         return;
     }
     if(item.PlayerId != client.Character.Player.PlayerId) {
         ServerConsole.WriteLine(System.Drawing.Color.Red,
             "Player #{0} attempted to equip item that belongs to #{1}!",
             client.Character.Player.PlayerId,
             item.PlayerId
         );
         return;
     }
     if(!item.Wearable) {
         ServerConsole.WriteLine(
             System.Drawing.Color.Red,
             "Player #{0} attempted to equip non-equipable item #{1}!",
             item.PlayerId,item.ItemId
         );
         return;
     }
     PlayerItem.Equip(item);
     client.Send(new Packets.EquipItem(item),"Equip Item");
 }
예제 #10
0
파일: PT_Npc.cs 프로젝트: KalOnline/KaLua
        public static void BuyNpcItem(Client client, PacketIn packet)
        {
            int npcWorldId = (int)packet.ReadUInt32();
            byte v1     = packet.ReadByte();
            byte amount = packet.ReadByte();

            int totalPrice = 0;

            ushort[] items   = new ushort[amount];
            ushort[] amounts = new ushort[amount];
            for(int i=0;i<amount;i++)
            {
                items[i]   = packet.ReadUShort();
                amounts[i] = packet.ReadUShort();

                // TODO, calculate correct price
                totalPrice += 100 * amounts[i];
            }

            // TODO, add geon amount check
            for(int i=0;i<amount;i++)
            {
                // should be items, not player items
                PlayerItem item = PlayerItem.Get((int)items[i]);
                client.Character.Player.Inventory.Items.Add(item);
                // update AddToInventory with generic item-object
                client.Send(new Packets.AddToInventory((int)items[i],(int)amounts[i]),"Buy Item");
                // update amout of geons !
            }
        }
예제 #11
0
파일: PT_Item.cs 프로젝트: sgentens/KaLua
        public static void EquipItem(Client client, PacketIn packet)
        {
            int        itemId = (int)packet.ReadUInt32();
            PlayerItem item   = PlayerItem.Get(itemId);

            if (item == null)
            {
                ServerConsole.WriteLine(
                    System.Drawing.Color.Red,
                    "Player #{0} attempted to equip non-existant item!",
                    client.Character.Player.PlayerId
                    );
                return;
            }
            if (item.PlayerId != client.Character.Player.PlayerId)
            {
                ServerConsole.WriteLine(System.Drawing.Color.Red,
                                        "Player #{0} attempted to equip item that belongs to #{1}!",
                                        client.Character.Player.PlayerId,
                                        item.PlayerId
                                        );
                return;
            }
            if (!item.Wearable)
            {
                ServerConsole.WriteLine(
                    System.Drawing.Color.Red,
                    "Player #{0} attempted to equip non-equipable item #{1}!",
                    item.PlayerId, item.ItemId
                    );
                return;
            }
            PlayerItem.Equip(item);
            client.Send(new Packets.EquipItem(item), "Equip Item");
        }
예제 #12
0
파일: PT_Npc.cs 프로젝트: sgentens/KaLua
        public static void BuyNpcItem(Client client, PacketIn packet)
        {
            int  npcWorldId = (int)packet.ReadUInt32();
            byte v1         = packet.ReadByte();
            byte amount     = packet.ReadByte();

            int totalPrice = 0;

            ushort[] items   = new ushort[amount];
            ushort[] amounts = new ushort[amount];
            for (int i = 0; i < amount; i++)
            {
                items[i]   = packet.ReadUShort();
                amounts[i] = packet.ReadUShort();

                // TODO, calculate correct price
                totalPrice += 100 * amounts[i];
            }

            // TODO, add geon amount check
            for (int i = 0; i < amount; i++)
            {
                // should be items, not player items
                PlayerItem item = PlayerItem.Get((int)items[i]);
                client.Character.Player.Inventory.Items.Add(item);
                // update AddToInventory with generic item-object
                client.Send(new Packets.AddToInventory((int)items[i], (int)amounts[i]), "Buy Item");
                // update amout of geons !
            }
        }
예제 #13
0
        public static void DeletePlayer(Client client, PacketIn packet)
        {
            int pid = (int)packet.ReadUInt32();

            client.DeletePlayer(pid);
            client.SendPlayerList();
        }
예제 #14
0
        public static void RestorePlayer(Client client, PacketIn packet)
        {
            int pid = (int)packet.ReadUInt32();

            client.RestorePlayer(pid);
            client.Send(new Packets.DisconnectMessage(Packets.DISCONNECT_MESSAGE.RESTORING_CHARACTER_COMPLETED));
        }
예제 #15
0
        public static void SkillRequest(Client client, PacketIn packet)
        {
            byte skillId  = packet.ReadByte();
            uint playerId = packet.ReadUInt32();

            client.SkillHandler.Request(skillId, playerId);

            client.Send(new Packets.SkillExecute(client.Character, skillId, 1));
        }
예제 #16
0
파일: PT_Skill.cs 프로젝트: KalOnline/KaLua
        public static void SkillRequest(Client client,PacketIn packet)
        {
            byte skillId  = packet.ReadByte();
            uint playerId = packet.ReadUInt32();

            client.SkillHandler.Request(skillId,playerId);

            client.Send(new Packets.SkillExecute(client.Character,skillId,1));
        }
예제 #17
0
파일: PT_Npc.cs 프로젝트: KalOnline/KaLua
 public static void NpcTalk(Client client, PacketIn packet)
 {
     Npc npc = Server.WorldNPCs[packet.ReadUInt32()];
     if(npc != null)
     {
         if(npc.Talk != 0) {
             //ServerConsole.WriteLine("Talking with npc #{0} returning Talk #{1}",npc.NpcId,npc.Talk);
             client.Send(new Packets.OpenDialog(npc.Talk));
         }
     }
 }
예제 #18
0
파일: PT_Npc.cs 프로젝트: sgentens/KaLua
        public static void NpcTalk(Client client, PacketIn packet)
        {
            Npc npc = Server.WorldNPCs[packet.ReadUInt32()];

            if (npc != null)
            {
                if (npc.Talk != 0)
                {
                    //ServerConsole.WriteLine("Talking with npc #{0} returning Talk #{1}",npc.NpcId,npc.Talk);
                    client.Send(new Packets.OpenDialog(npc.Talk));
                }
            }
        }
예제 #19
0
        void HandlePong(PacketIn packet)
        {
            UInt32 Server_Seq = packet.ReadUInt32();

            if (Server_Seq == Ping_Seq)
            {
                Ping_Res_Time = MM_GetTime();
                Latency       = Ping_Res_Time - Ping_Req_Time;
                Ping_Seq     += 1;
                Log.WriteLine(LogType.Debug, "Got nice pong. We love server;)");
            }
            else
            {
                Log.WriteLine(LogType.Error, "Server pong'd bad sequence! Ours: {0} Theirs: {1}", Ping_Seq, Server_Seq);
            }
        }
예제 #20
0
        public static void PickupDrop(Client client, PacketIn packet)
        {
            UInt32 worldId = packet.ReadUInt32();
            Drop drop;

            //check if the drop exists
            if (ServerWorld.Entities.ContainsKey(worldId))
            {
                drop = ServerWorld.Entities[worldId] as Drop;
            }
            else
            {
                return;
            }

            CodeHandler handler = CodeManager.GetHandler(drop.PlayerItem.Item.Code);

            handler.Pickup(drop, client.Character, client);
        }
예제 #21
0
        public static void PickupDrop(Client client, PacketIn packet)
        {
            UInt32 worldId = packet.ReadUInt32();
            Drop   drop;

            //check if the drop exists
            if (ServerWorld.Entities.ContainsKey(worldId))
            {
                drop = ServerWorld.Entities[worldId] as Drop;
            }
            else
            {
                return;
            }

            CodeHandler handler = CodeManager.GetHandler(drop.PlayerItem.Item.Code);

            handler.Pickup(drop, client.Character, client);
        }
예제 #22
0
        /// <summary>
        /// Checks if the client's proof matches our proof.
        /// </summary>
        /// <param name="packet">the packet to read from</param>
        /// <returns>true if the client proof matches; false otherwise</returns>
        public bool IsClientProofValid(PacketIn packet)
        {
            m_srp.PublicEphemeralValueA = packet.ReadBigInteger(32);

            BigInteger proof = packet.ReadBigInteger(20);

            // SHA1 of PublicEphemeralValueA and the 16 random bytes sent in
            // AUTH_LOGON_CHALLENGE from the server
            byte[] arr = packet.ReadBytes(20);

            byte keyCount = packet.ReadByte();

            for (int i = 0; i < keyCount; i++)
            {
                ushort keyUnk1     = packet.ReadUInt16();
                uint   keyUnk2     = packet.ReadUInt32();
                byte[] keyUnkArray = packet.ReadBytes(4);
                // sha of the SRP's PublicEphemeralValueA, PublicEphemeralValueB,
                // and 20 unknown bytes
                byte[] keyUnkSha = packet.ReadBytes(20);
            }

            byte securityFlags = packet.ReadByte();

            if ((securityFlags & 1) != 0)
            {
                // PIN
                byte[] pinRandom = packet.ReadBytes(16);
                byte[] pinSha    = packet.ReadBytes(20);
            }
            if ((securityFlags & 2) != 0)
            {
                byte[] security2Buf = packet.ReadBytes(20);
            }
            if ((securityFlags & 4) != 0)
            {
                byte   arrLen       = packet.ReadByte();
                byte[] security4Buf = packet.ReadBytes(arrLen);
            }

            return(m_srp.IsClientProofValid(proof));
        }
예제 #23
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);
                }
            }
        }
예제 #24
0
파일: PT_Item.cs 프로젝트: sgentens/KaLua
        public static void PickupDrop(Client client, PacketIn packet)
        {
            Drop drop;

            try {
                drop = Server.WorldDrops[packet.ReadUInt32()];
            } catch (Exception) {
                return;
            }

            PlayerItem item = PlayerItem.Get(drop.PlayerItem.ItemId);

            client.Character.Player.Inventory.Items.Add(item);

            client.Send(new Packets.PickupDrop(item), "Pickup Drop");
            client.Send(new Packets.AddToInventory(drop.ItemId, drop.Quantity), "Update Inventory");
            client.Send(new Packets.UnspawnDrop(drop), "Unspawn Drop");

            Server.WorldDrops.Remove((uint)drop.WorldId);
            World.FreeId((uint)drop.WorldId);
        }
예제 #25
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();
        }
예제 #26
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();
            }
        }
예제 #27
0
        public static void RestoreCharacter(Client client, PacketIn packet)
        {
            int playerId = (int)packet.ReadUInt32();

            using (ISession session = Server.Factory.OpenSession())
            {
                Player player = (Player)session.Get(typeof(Player), playerId);
                if (player == null)
                {
                    ServerConsole.WriteLine(
                        System.Drawing.Color.Red,
                        "Tried to restore unexisting character with PlayerId ({0)",
                        playerId
                        );
                    return;
                }

                using (ITransaction transaction = session.BeginTransaction())
                {
                    IQuery q = session.CreateQuery("FROM DeletedPlayer WHERE PlayerId = :playerId");
                    q.SetParameter("playerId", playerId);
                    DeletedPlayer dPlayer = q.UniqueResult <DeletedPlayer>();

                    session.Delete(dPlayer);
                    transaction.Commit();
                }

                using (ITransaction transaction = session.BeginTransaction())
                {
                    player.Status = 1;
                    session.Update(player);
                    transaction.Commit();
                }
            }

            client.SendPlayerList();
        }
예제 #28
0
        /// <summary>Checks if the client's proof matches our proof.</summary>
        /// <param name="packet">the packet to read from</param>
        /// <returns>true if the client proof matches; false otherwise</returns>
        public bool IsClientProofValid(PacketIn packet)
        {
            this.m_srp.PublicEphemeralValueA = packet.ReadBigInteger(32);
            BigInteger client_proof = packet.ReadBigInteger(20);

            packet.ReadBytes(20);
            byte num1 = packet.ReadByte();

            for (int index = 0; index < (int)num1; ++index)
            {
                packet.ReadUInt16();
                packet.ReadUInt32();
                packet.ReadBytes(4);
                packet.ReadBytes(20);
            }

            byte num2 = packet.ReadByte();

            if (((int)num2 & 1) != 0)
            {
                packet.ReadBytes(16);
                packet.ReadBytes(20);
            }

            if (((int)num2 & 2) != 0)
            {
                packet.ReadBytes(20);
            }
            if (((int)num2 & 4) != 0)
            {
                byte num3 = packet.ReadByte();
                packet.ReadBytes((int)num3);
            }

            return(this.m_srp.IsClientProofValid(client_proof));
        }
예제 #29
0
 public static void DeletePlayer(Client client, PacketIn packet)
 {
     int pid = (int)packet.ReadUInt32();
     client.DeletePlayer(pid);
     client.SendPlayerList();
 }
예제 #30
0
 public static void PlayerSelect(Client client, PacketIn packet)
 {
     client.PlayerSelect((int)packet.ReadUInt32());
 }
예제 #31
0
 public static void RestorePlayer(Client client, PacketIn packet)
 {
     int pid = (int)packet.ReadUInt32();
     client.RestorePlayer(pid);
     client.Send(new Packets.DisconnectMessage(Packets.DISCONNECT_MESSAGE.RESTORING_CHARACTER_COMPLETED));
 }
예제 #32
0
 public static void PlayerSelect(Client client, PacketIn packet)
 {
     client.PlayerSelect((int)packet.ReadUInt32());
 }
예제 #33
0
        /*
         *      [PacketHandlerAtribute(WorldServerOpCode.SMSG_COMPRESSED_UPDATE_OBJECT)]
         *      public void HandleCompressedObjectUpdate(PacketIn packet)
         *      {
         *              try
         *              {
         *                      Int32 size = packet.ReadInt32();
         *                      byte[] decomped = mClient.Shared.Compression.Decompress(size, packet.ReadRemaining());
         *                      packet = new PacketIn(decomped, 1);
         *                      HandleObjectUpdate(packet);
         *              }
         *              catch(Exception ex)
         *              {
         *                      Log.WriteLine(LogType.Error, "{1} \n {0}", ex.StackTrace, ex.Message);
         *              }
         *      }
         *
         *      [PacketHandlerAtribute(WorldServerOpCode.SMSG_UPDATE_OBJECT)]
         *      public void HandleObjectUpdate(PacketIn packet)
         *      {
         *      UInt32 UpdateBlocks = packet.ReadUInt32();
         *
         *      for(int allBlocks = 0; allBlocks < UpdateBlocks; allBlocks++)
         *      {
         *          UpdateType type = (UpdateType)packet.ReadByte();
         *
         *          WoWGuid updateGuid;
         *          uint updateId;
         *          uint fCount;
         *
         *          switch(type)
         *          {
         *              case UpdateType.Values:
         *                  Object getObject;
         *                  updateGuid = new WoWGuid(packet.ReadUInt64());
         *                  if (objectMgr.objectExists(updateGuid))
         *                  {
         *                      getObject = objectMgr.getObject(updateGuid);
         *                  }
         *                  else
         *                  {
         *                      getObject = new Object(updateGuid);
         *                      objectMgr.addObject(getObject);
         *                  }
         *                  Log.WriteLine(LogType.Normal, "Handling Fields Update for object: {0}", getObject.Guid.ToString());
         *                  HandleUpdateObjectFieldBlock(packet, getObject);
         *                  objectMgr.updateObject(getObject);
         *                  break;
         *
         *              case UpdateType.Create:
         *              case UpdateType.CreateSelf:
         *                  updateGuid = new WoWGuid(packet.ReadUInt64());
         *                  updateId = packet.ReadByte();
         *                  fCount = GeUpdateFieldsCount(updateId);
         *
         *                  if (objectMgr.objectExists(updateGuid))
         *                      objectMgr.delObject(updateGuid);
         *
         *                  Object newObject = new Object(updateGuid);
         *                  newObject.Fields = new UInt32[2000];
         *                  objectMgr.addObject(newObject);
         *                  HandleUpdateMovementBlock(packet, newObject);
         *                  HandleUpdateObjectFieldBlock(packet, newObject);
         *                  objectMgr.updateObject(newObject);
         *                  Log.WriteLine(LogType.Normal, "Handling Creation of object: {0}", newObject.Guid.ToString());
         *                  break;
         *
         *              case UpdateType.OutOfRange:
         *                  fCount = packet.ReadByte();
         *                  for (int j = 0; j < fCount; j++)
         *                  {
         *                      WoWGuid guid = new WoWGuid(packet.ReadUInt64());
         *                      Log.WriteLine(LogType.Normal, "Handling delete for object: {0}", guid.ToString());
         *                      if (objectMgr.objectExists(guid))
         *                          objectMgr.delObject(guid);
         *                  }
         *                  break;
         *          }
         *      }
         *
         * }
         */

        public void HandleUpdateMovementBlock(PacketIn packet, Object newObject)
        {
            UInt16 flags = packet.ReadUInt16();


            if ((flags & 0x20) >= 1)
            {
                UInt32 flags2 = packet.ReadUInt32();
                UInt16 unk1   = packet.ReadUInt16();
                UInt32 unk2   = packet.ReadUInt32();
                newObject.Position = new Coordinate(packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat());

                if ((flags2 & 0x200) >= 1)
                {
                    packet.ReadBytes(21); //transporter
                }

                if (((flags2 & 0x2200000) >= 1) || ((unk1 & 0x20) >= 1))
                {
                    packet.ReadBytes(4); // pitch
                }

                packet.ReadBytes(4); //lastfalltime

                if ((flags2 & 0x1000) >= 1)
                {
                    packet.ReadBytes(16); // skip 4 floats
                }

                if ((flags2 & 0x4000000) >= 1)
                {
                    packet.ReadBytes(4); // skip 1 float
                }

                packet.ReadBytes(32);          // all of speeds

                if ((flags2 & 0x8000000) >= 1) //spline ;/
                {
                    UInt32 splineFlags = packet.ReadUInt32();

                    if ((splineFlags & 0x00020000) >= 1)
                    {
                        packet.ReadBytes(4); // skip 1 float
                    }
                    else
                    {
                        if ((splineFlags & 0x00010000) >= 1)
                        {
                            packet.ReadBytes(4); // skip 1 float
                        }
                        else if ((splineFlags & 0x00008000) >= 1)
                        {
                            packet.ReadBytes(12); // skip 3 float
                        }
                    }

                    packet.ReadBytes(28); // skip 8 float

                    UInt32 splineCount = packet.ReadUInt32();

                    for (UInt32 j = 0; j < splineCount; j++)
                    {
                        packet.ReadBytes(12); // skip 3 float
                    }

                    packet.ReadBytes(13);
                }
            }

            else if ((flags & 0x100) >= 1)
            {
                packet.ReadBytes(40);
            }
            else if ((flags & 0x40) >= 1)
            {
                newObject.Position = new Coordinate(packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat());
            }

            if ((flags & 0x8) >= 1)
            {
                packet.ReadBytes(4);
            }

            if ((flags & 0x10) >= 1)
            {
                packet.ReadBytes(4);
            }

            if ((flags & 0x04) >= 1)
            {
                packet.ReadBytes(8);
            }

            if ((flags & 0x2) >= 1)
            {
                packet.ReadBytes(4);
            }

            if ((flags & 0x80) >= 1)
            {
                packet.ReadBytes(8);
            }

            if ((flags & 0x200) >= 1)
            {
                packet.ReadBytes(8);
            }
        }
예제 #34
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);
            }
        }
예제 #35
0
파일: PT_Item.cs 프로젝트: KalOnline/KaLua
        public static void PickupDrop(Client client, PacketIn packet)
        {
            Drop drop;
            try {
                drop = Server.WorldDrops[packet.ReadUInt32()];
            } catch(Exception) {
                return;
            }

            PlayerItem item = PlayerItem.Get(drop.PlayerItem.ItemId);
            client.Character.Player.Inventory.Items.Add(item);

            client.Send(new Packets.PickupDrop(item),"Pickup Drop");
            client.Send(new Packets.AddToInventory(drop.ItemId,drop.Quantity),"Update Inventory");
            client.Send(new Packets.UnspawnDrop(drop),"Unspawn Drop");

            Server.WorldDrops.Remove((uint)drop.WorldId);
            World.FreeId((uint)drop.WorldId);
        }