Exemple #1
0
 public void On_CMSG_AUTOSTORE_LOOT_ITEM(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     if (checked (packet.Data.Length - 1) < 6)
     {
         return;
     }
     try
     {
         packet.GetInt16();
         byte slot = packet.GetInt8();
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_AUTOSTORE_LOOT_ITEM [slot={2}]", client.IP, client.Port, slot);
         if (LootTable.ContainsKey(client.Character.lootGUID))
         {
             LootTable[client.Character.lootGUID].GetLoot(ref client, slot);
             return;
         }
         Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE);
         response.AddInt8(49);
         response.AddUInt64(0uL);
         response.AddUInt64(0uL);
         response.AddInt8(0);
         client.Send(ref response);
         response.Dispose();
     }
     catch (Exception ex)
     {
         ProjectData.SetProjectError(ex);
         Exception e = ex;
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "Error looting item.{0}", Environment.NewLine + e);
         ProjectData.ClearProjectError();
     }
 }
Exemple #2
0
        private void SendTaxiStatus(ref WS_PlayerData.CharacterObject objCharacter, ulong cGuid)
        {
            if (!WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(cGuid))
            {
                return;
            }
            int currentTaxi = WorldServiceLocator._WS_DBCDatabase.GetNearestTaxi(WorldServiceLocator._WorldServer.WORLD_CREATUREs[cGuid].positionX, WorldServiceLocator._WorldServer.WORLD_CREATUREs[cGuid].positionY, checked ((int)WorldServiceLocator._WorldServer.WORLD_CREATUREs[cGuid].MapID));

            Packets.PacketClass SMSG_TAXINODE_STATUS = new Packets.PacketClass(Opcodes.SMSG_TAXINODE_STATUS);
            try
            {
                SMSG_TAXINODE_STATUS.AddUInt64(cGuid);
                if (!objCharacter.TaxiZones[currentTaxi])
                {
                    SMSG_TAXINODE_STATUS.AddInt8(0);
                }
                else
                {
                    SMSG_TAXINODE_STATUS.AddInt8(1);
                }
                objCharacter.client.Send(ref SMSG_TAXINODE_STATUS);
            }
            finally
            {
                SMSG_TAXINODE_STATUS.Dispose();
            }
        }
Exemple #3
0
 public void SendPetitionActivate(ref WS_PlayerData.CharacterObject objCharacter, ulong cGUID)
 {
     if (WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(cGUID))
     {
         byte Count = 3;
         if (((uint)WorldServiceLocator._WorldServer.WORLD_CREATUREs[cGUID].CreatureInfo.cNpcFlags & 4u) != 0)
         {
             Count = 1;
         }
         Packets.PacketClass packet = new Packets.PacketClass(Opcodes.SMSG_PETITION_SHOWLIST);
         packet.AddUInt64(cGUID);
         packet.AddInt8(1);
         if (Count == 1)
         {
             packet.AddInt32(1);
             packet.AddInt32(WorldServiceLocator._Global_Constants.PETITION_GUILD);
             packet.AddInt32(16161);
             packet.AddInt32(WorldServiceLocator._Global_Constants.PETITION_GUILD_PRICE);
             packet.AddInt32(0);
             packet.AddInt32(9);
         }
         objCharacter.client.Send(ref packet);
         packet.Dispose();
     }
 }
Exemple #4
0
 public void SendRelease(ref WS_Network.ClientClass client)
 {
     Packets.PacketClass responseRelease = new Packets.PacketClass(Opcodes.SMSG_LOOT_RELEASE_RESPONSE);
     responseRelease.AddUInt64(GUID);
     responseRelease.AddInt8(1);
     client.Send(ref responseRelease);
     responseRelease.Dispose();
 }
 public void EndRoll(object state)
 {
     foreach (WS_PlayerData.CharacterObject objCharacter in Rolls)
     {
         if (!Looters.ContainsKey(objCharacter))
         {
             Looters[objCharacter] = 0;
             Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_LOOT_ROLL);
             response.AddUInt64(LootObject.GUID);
             response.AddInt32(LootSlot);
             response.AddUInt64(objCharacter.GUID);
             response.AddInt32(Item.ItemID);
             response.AddInt32(0);
             response.AddInt32(0);
             response.AddInt8(249);
             response.AddInt8(0);
             Broadcast(ref response);
         }
     }
     RollTimeoutTimer.Dispose();
     RollTimeoutTimer = null;
     Check();
 }
Exemple #6
0
 public void Destroy()
 {
     Packets.PacketClass packet = new Packets.PacketClass(Opcodes.SMSG_DESTROY_OBJECT);
     try
     {
         packet.AddUInt64(GUID);
         SendToNearPlayers(ref packet);
     }
     finally
     {
         packet.Dispose();
     }
     Dispose();
 }
Exemple #7
0
        public void SendTaxiMenu(ref WS_PlayerData.CharacterObject objCharacter, ulong cGuid)
        {
            if (!WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(cGuid))
            {
                return;
            }
            int currentTaxi = WorldServiceLocator._WS_DBCDatabase.GetNearestTaxi(WorldServiceLocator._WorldServer.WORLD_CREATUREs[cGuid].positionX, WorldServiceLocator._WorldServer.WORLD_CREATUREs[cGuid].positionY, checked ((int)WorldServiceLocator._WorldServer.WORLD_CREATUREs[cGuid].MapID));

            if (!objCharacter.TaxiZones[currentTaxi])
            {
                objCharacter.TaxiZones.Set(currentTaxi, value: true);
                Packets.PacketClass SMSG_NEW_TAXI_PATH = new Packets.PacketClass(Opcodes.SMSG_NEW_TAXI_PATH);
                try
                {
                    objCharacter.client.Send(ref SMSG_NEW_TAXI_PATH);
                }
                finally
                {
                    SMSG_NEW_TAXI_PATH.Dispose();
                }
                Packets.PacketClass SMSG_TAXINODE_STATUS = new Packets.PacketClass(Opcodes.SMSG_TAXINODE_STATUS);
                try
                {
                    SMSG_TAXINODE_STATUS.AddUInt64(cGuid);
                    SMSG_TAXINODE_STATUS.AddInt8(1);
                    objCharacter.client.Send(ref SMSG_TAXINODE_STATUS);
                }
                finally
                {
                    SMSG_TAXINODE_STATUS.Dispose();
                }
            }
            else
            {
                Packets.PacketClass SMSG_SHOWTAXINODES = new Packets.PacketClass(Opcodes.SMSG_SHOWTAXINODES);
                try
                {
                    SMSG_SHOWTAXINODES.AddInt32(1);
                    SMSG_SHOWTAXINODES.AddUInt64(cGuid);
                    SMSG_SHOWTAXINODES.AddInt32(currentTaxi);
                    SMSG_SHOWTAXINODES.AddBitArray(objCharacter.TaxiZones, 32);
                    objCharacter.client.Send(ref SMSG_SHOWTAXINODES);
                }
                finally
                {
                    SMSG_SHOWTAXINODES.Dispose();
                }
            }
        }
Exemple #8
0
        public void On_CMSG_BATTLEMASTER_HELLO(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
        {
            if (checked (packet.Data.Length - 1) < 13)
            {
                return;
            }
            packet.GetInt16();
            ulong GUID = packet.GetUInt64();

            WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_BATTLEMASTER_HELLO [{2:X}]", client.IP, client.Port, GUID);
            if (!WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(GUID) || (WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].CreatureInfo.cNpcFlags & 0x800) == 0 || !WorldServiceLocator._WS_DBCDatabase.Battlemasters.ContainsKey(WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].ID))
            {
                return;
            }
            byte BGType = WorldServiceLocator._WS_DBCDatabase.Battlemasters[WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].ID];

            if (!WorldServiceLocator._WS_DBCDatabase.Battlegrounds.ContainsKey(BGType))
            {
                return;
            }
            if (WorldServiceLocator._WS_DBCDatabase.Battlegrounds[BGType].MinLevel > (uint)client.Character.Level || WorldServiceLocator._WS_DBCDatabase.Battlegrounds[BGType].MaxLevel < (uint)client.Character.Level)
            {
                WorldServiceLocator._Functions.SendMessageNotification(ref client, "You don't meet Battleground level requirements");
                return;
            }
            Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_BATTLEFIELD_LIST);
            try
            {
                response.AddUInt64(client.Character.GUID);
                response.AddInt32(BGType);
                List <int> Battlegrounds = WorldServiceLocator._WorldServer.ClsWorldServer.Cluster.BattlefieldList(BGType);
                response.AddInt8(0);
                response.AddInt32(Battlegrounds.Count);
                foreach (int Instance in Battlegrounds)
                {
                    response.AddInt32(Instance);
                }
                client.Send(ref response);
            }
            finally
            {
                response.Dispose();
            }
        }
Exemple #9
0
 public void On_CMSG_EMOTE(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     if (checked (packet.Data.Length - 1) >= 9)
     {
         packet.GetInt16();
         int emoteID = packet.GetInt32();
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_EMOTE [{2}]", client.IP, client.Port, emoteID);
         Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_EMOTE);
         try
         {
             response.AddInt32(emoteID);
             response.AddUInt64(client.Character.GUID);
             client.Character.SendToNearPlayers(ref response);
         }
         finally
         {
             response.Dispose();
         }
     }
 }
Exemple #10
0
 public void GetLoot(ref WS_Network.ClientClass client, byte Slot)
 {
     try
     {
         if (Items[Slot] == null)
         {
             Packets.PacketClass response4 = new Packets.PacketClass(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE);
             response4.AddInt8(49);
             response4.AddUInt64(0uL);
             response4.AddUInt64(0uL);
             response4.AddInt8(0);
             client.Send(ref response4);
             response4.Dispose();
             return;
         }
         if (GroupLootInfo.ContainsKey(Slot))
         {
             Packets.PacketClass response3 = new Packets.PacketClass(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE);
             response3.AddInt8(58);
             response3.AddUInt64(0uL);
             response3.AddUInt64(0uL);
             response3.AddInt8(0);
             client.Send(ref response3);
             response3.Dispose();
             return;
         }
         ItemObject itemObject = new ItemObject(Items[Slot].ItemID, client.Character.GUID)
         {
             StackCount = Items[Slot].ItemCount
         };
         ItemObject tmpItem = itemObject;
         if (client.Character.ItemADD(ref tmpItem))
         {
             if (tmpItem.ItemInfo.Bonding == 1)
             {
                 ItemObject             itemObject2 = tmpItem;
                 WS_Network.ClientClass client2     = null;
                 itemObject2.SoulbindItem(client2);
             }
             Packets.PacketClass response2 = new Packets.PacketClass(Opcodes.SMSG_LOOT_REMOVED);
             response2.AddInt8(Slot);
             client.Send(ref response2);
             response2.Dispose();
             client.Character.LogLootItem(tmpItem, Items[Slot].ItemCount, Recieved: false, Created: false);
             Items[Slot].Dispose();
             Items[Slot] = null;
             if (LootType == LootType.LOOTTYPE_FISHING && IsEmpty)
             {
                 SendRelease(ref client);
                 Dispose();
             }
         }
         else
         {
             tmpItem.Delete();
             Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE);
             response.AddInt8(50);
             response.AddUInt64(0uL);
             response.AddUInt64(0uL);
             response.AddInt8(0);
             client.Send(ref response);
             response.Dispose();
         }
     }
     catch (Exception ex)
     {
         ProjectData.SetProjectError(ex);
         Exception e = ex;
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "Error getting loot.{0}", Environment.NewLine + e);
         ProjectData.ClearProjectError();
     }
 }
            private void DoTrade()
            {
                byte TargetReqItems = 0;
                byte TraderReqItems = 0;
                byte i = 0;

                do
                {
                    checked
                    {
                        if (TraderSlots[i] > 0)
                        {
                            TargetReqItems = (byte)(TargetReqItems + 1);
                        }
                        if (TargetSlots[i] > 0)
                        {
                            TraderReqItems = (byte)(TraderReqItems + 1);
                        }
                        i = (byte)unchecked ((uint)(i + 1));
                    }
                }while (i <= 5u);
                try
                {
                    if (Target.ItemFREESLOTS() < TargetReqItems)
                    {
                        Packets.PacketClass responseUnAccept2 = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS);
                        try
                        {
                            responseUnAccept2.AddInt32(7);
                            Target.client.SendMultiplyPackets(ref responseUnAccept2);
                            TraderAccept = false;
                            Trader.client.SendMultiplyPackets(ref responseUnAccept2);
                            TraderAccept = false;
                        }
                        finally
                        {
                            responseUnAccept2.Dispose();
                        }
                        Packets.PacketClass responseNoSlot2 = new Packets.PacketClass(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE);
                        try
                        {
                            responseNoSlot2.AddInt8(50);
                            responseNoSlot2.AddUInt64(0uL);
                            responseNoSlot2.AddUInt64(0uL);
                            responseNoSlot2.AddInt8(0);
                            Target.client.Send(ref responseNoSlot2);
                        }
                        finally
                        {
                            responseNoSlot2.Dispose();
                        }
                        return;
                    }
                    if (Trader.ItemFREESLOTS() < TraderReqItems)
                    {
                        Packets.PacketClass responseUnAccept = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS);
                        try
                        {
                            responseUnAccept.AddInt32(7);
                            Target.client.SendMultiplyPackets(ref responseUnAccept);
                            TraderAccept = false;
                            Trader.client.SendMultiplyPackets(ref responseUnAccept);
                            TargetAccept = false;
                        }
                        finally
                        {
                            responseUnAccept.Dispose();
                        }
                        Packets.PacketClass responseNoSlot = new Packets.PacketClass(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE);
                        try
                        {
                            responseNoSlot.AddInt8(50);
                            responseNoSlot.AddUInt64(0uL);
                            responseNoSlot.AddUInt64(0uL);
                            responseNoSlot.AddInt8(0);
                            Trader.client.Send(ref responseNoSlot);
                        }
                        finally
                        {
                            responseNoSlot.Dispose();
                        }
                        return;
                    }
                    if ((TargetGold > 0L) | (TraderGold > 0L))
                    {
                        checked
                        {
                            Trader.Copper = Trader.Copper - TraderGold + TargetGold;
                            Target.Copper = Target.Copper + TraderGold - TargetGold;
                            Trader.SetUpdateFlag(1176, Trader.Copper);
                            Target.SetUpdateFlag(1176, Target.Copper);
                        }
                    }
                    if (TargetReqItems > 0 || TraderReqItems > 0)
                    {
                        byte j = 0;
                        do
                        {
                            checked
                            {
                                if (TraderSlots[j] > 0)
                                {
                                    byte       mySlot2 = (byte)(TraderSlots[j] & 0xFF);
                                    byte       myBag2  = (byte)(TraderSlots[j] >> 8);
                                    ItemObject myItem2 = null;
                                    myItem2 = ((myBag2 != 0) ? Trader.Items[myBag2].Items[mySlot2] : Trader.Items[mySlot2]);
                                    if (myItem2.ItemInfo.ObjectClass != ITEM_CLASS.ITEM_CLASS_QUEST)
                                    {
                                        myItem2.OwnerGUID = Target.GUID;
                                        if (Target.ItemADD(ref myItem2))
                                        {
                                            Trader.ItemREMOVE(myBag2, mySlot2, Destroy: false, Update: false);
                                        }
                                    }
                                }
                                if (TargetSlots[j] > 0)
                                {
                                    byte       mySlot = (byte)(TargetSlots[j] & 0xFF);
                                    byte       myBag  = (byte)(TargetSlots[j] >> 8);
                                    ItemObject myItem = null;
                                    myItem = ((myBag != 0) ? Target.Items[myBag].Items[mySlot] : Target.Items[mySlot]);
                                    if (myItem.ItemInfo.ObjectClass != ITEM_CLASS.ITEM_CLASS_QUEST)
                                    {
                                        myItem.OwnerGUID = Trader.GUID;
                                        if (Trader.ItemADD(ref myItem))
                                        {
                                            Target.ItemREMOVE(myBag, mySlot, Destroy: false, Update: false);
                                        }
                                    }
                                }
                                j = (byte)unchecked ((uint)(j + 1));
                            }
                        }while (j <= 5u);
                    }
                    Trader.SendCharacterUpdate();
                    Target.SendCharacterUpdate();
                    Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS);
                    try
                    {
                        response.AddInt32(8);
                        Target.client.SendMultiplyPackets(ref response);
                        Trader.client.SendMultiplyPackets(ref response);
                    }
                    finally
                    {
                        response.Dispose();
                        Dispose();
                    }
                }
                catch (Exception ex)
                {
                    ProjectData.SetProjectError(ex);
                    Exception e = ex;
                    WorldServiceLocator._WorldServer.Log.WriteLine(LogType.FAILED, "Error doing trade: {0}{1}", Environment.NewLine, e.ToString());
                    ProjectData.ClearProjectError();
                }
            }
 public void SendTradeUpdateToTarget()
 {
     if (Target == null)
     {
         return;
     }
     Packets.PacketClass packet = new Packets.PacketClass(Opcodes.SMSG_TRADE_STATUS_EXTENDED);
     checked
     {
         try
         {
             packet.AddInt8(1);
             packet.AddInt32(7);
             packet.AddInt32(7);
             packet.AddUInt32(TraderGold);
             packet.AddInt32(0);
             int i = 0;
             do
             {
                 packet.AddInt8((byte)i);
                 if (TraderSlots[i] > 0)
                 {
                     byte       mySlot = (byte)(TraderSlots[i] & 0xFF);
                     byte       myBag  = (byte)(TraderSlots[i] >> 8);
                     ItemObject myItem = null;
                     myItem = ((myBag != 0) ? Trader.Items[myBag].Items[mySlot] : Trader.Items[mySlot]);
                     packet.AddInt32(myItem.ItemEntry);
                     packet.AddInt32(myItem.ItemInfo.Model);
                     packet.AddInt32(myItem.StackCount);
                     packet.AddInt32(0);
                     packet.AddUInt64(myItem.GiftCreatorGUID);
                     if (myItem.Enchantments.ContainsKey(0))
                     {
                         packet.AddInt32(myItem.Enchantments[0].ID);
                     }
                     else
                     {
                         packet.AddInt32(0);
                     }
                     packet.AddUInt64(myItem.CreatorGUID);
                     packet.AddInt32(myItem.ChargesLeft);
                     packet.AddInt32(0);
                     packet.AddInt32(myItem.RandomProperties);
                     packet.AddInt32(myItem.ItemInfo.Flags);
                     packet.AddInt32(myItem.ItemInfo.Durability);
                     packet.AddInt32(myItem.Durability);
                 }
                 else
                 {
                     int j = 0;
                     do
                     {
                         packet.AddInt32(0);
                         j++;
                     }while (j <= 14);
                 }
                 i++;
             }while (i <= 6);
             Target.client.Send(ref packet);
         }
         finally
         {
             packet.Dispose();
         }
     }
 }
Exemple #13
0
        public Packets.PacketClass BuildPartyMemberStats(ref WS_PlayerData.CharacterObject objCharacter, uint flag)
        {
            Opcodes opCode = Opcodes.SMSG_PARTY_MEMBER_STATS;

            if (flag == 1015 || flag == 524279)
            {
                opCode = Opcodes.SMSG_PARTY_MEMBER_STATS_FULL;
                if (objCharacter.ManaType != 0)
                {
                    flag |= 8u;
                }
            }
            Packets.PacketClass packet = new Packets.PacketClass(opCode);
            packet.AddPackGUID(objCharacter.GUID);
            packet.AddUInt32(flag);
            if ((flag & (true ? 1u : 0u)) != 0)
            {
                byte memberFlags = 1;
                if (objCharacter.isPvP)
                {
                    memberFlags = (byte)(memberFlags | 2);
                }
                if (objCharacter.DEAD)
                {
                    memberFlags = (byte)(memberFlags | 0x10);
                }
                packet.AddInt8(memberFlags);
            }
            checked
            {
                if ((flag & 2u) != 0)
                {
                    packet.AddUInt16((ushort)objCharacter.Life.Current);
                }
                if ((flag & 4u) != 0)
                {
                    packet.AddUInt16((ushort)objCharacter.Life.Maximum);
                }
                if ((flag & 8u) != 0)
                {
                    packet.AddInt8((byte)objCharacter.ManaType);
                }
                if ((flag & 0x10u) != 0)
                {
                    if (objCharacter.ManaType == ManaTypes.TYPE_RAGE)
                    {
                        packet.AddUInt16((ushort)objCharacter.Rage.Current);
                    }
                    else if (objCharacter.ManaType == ManaTypes.TYPE_ENERGY)
                    {
                        packet.AddUInt16((ushort)objCharacter.Energy.Current);
                    }
                    else
                    {
                        packet.AddUInt16((ushort)objCharacter.Mana.Current);
                    }
                }
                if ((flag & 0x20u) != 0)
                {
                    if (objCharacter.ManaType == ManaTypes.TYPE_RAGE)
                    {
                        packet.AddUInt16((ushort)objCharacter.Rage.Maximum);
                    }
                    else if (objCharacter.ManaType == ManaTypes.TYPE_ENERGY)
                    {
                        packet.AddUInt16((ushort)objCharacter.Energy.Maximum);
                    }
                    else
                    {
                        packet.AddUInt16((ushort)objCharacter.Mana.Maximum);
                    }
                }
                if ((flag & 0x40u) != 0)
                {
                    packet.AddUInt16(objCharacter.Level);
                }
                if ((flag & 0x80u) != 0)
                {
                    packet.AddUInt16((ushort)objCharacter.ZoneID);
                }
                if ((flag & 0x100u) != 0)
                {
                    packet.AddInt16((short)objCharacter.positionX);
                    packet.AddInt16((short)objCharacter.positionY);
                }
                if ((flag & 0x200u) != 0)
                {
                    ulong auraMask2 = 0uL;
                    int   auraPos2  = packet.Data.Length;
                    packet.AddUInt64(0uL);
                    int num = WorldServiceLocator._Global_Constants.MAX_AURA_EFFECTs_VISIBLE - 1;
                    for (int j = 0; j <= num; j++)
                    {
                        if (objCharacter.ActiveSpells[j] != null)
                        {
                            unchecked
                            {
                                auraMask2 |= (ulong)(1L << checked ((int)(ulong)j));
                            }
                            packet.AddUInt16((ushort)objCharacter.ActiveSpells[j].SpellID);
                            packet.AddInt8(1);
                        }
                    }
                    packet.AddUInt64(auraMask2, auraPos2);
                }
                if ((flag & 0x400u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddUInt64(objCharacter.Pet.GUID);
                    }
                    else
                    {
                        packet.AddInt64(0L);
                    }
                }
                if ((flag & 0x800u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddString(objCharacter.Pet.PetName);
                    }
                    else
                    {
                        packet.AddString("");
                    }
                }
                if ((flag & 0x1000u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddUInt16((ushort)objCharacter.Pet.Model);
                    }
                    else
                    {
                        packet.AddInt16(0);
                    }
                }
                if ((flag & 0x2000u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddUInt16((ushort)objCharacter.Pet.Life.Current);
                    }
                    else
                    {
                        packet.AddInt16(0);
                    }
                }
                if ((flag & 0x4000u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddUInt16((ushort)objCharacter.Pet.Life.Maximum);
                    }
                    else
                    {
                        packet.AddInt16(0);
                    }
                }
                if ((flag & 0x8000u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddInt8(2);
                    }
                    else
                    {
                        packet.AddInt8(0);
                    }
                }
                if ((flag & 0x10000u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddUInt16((ushort)objCharacter.Pet.Mana.Current);
                    }
                    else
                    {
                        packet.AddInt16(0);
                    }
                }
                if ((flag & 0x20000u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        packet.AddUInt16((ushort)objCharacter.Pet.Mana.Maximum);
                    }
                    else
                    {
                        packet.AddInt16(0);
                    }
                }
                if ((flag & 0x40000u) != 0)
                {
                    if (objCharacter.Pet != null)
                    {
                        ulong auraMask = 0uL;
                        int   auraPos  = packet.Data.Length;
                        packet.AddUInt64(0uL);
                        int num2 = WorldServiceLocator._Global_Constants.MAX_AURA_EFFECTs_VISIBLE - 1;
                        for (int i = 0; i <= num2; i++)
                        {
                            if (objCharacter.Pet.ActiveSpells[i] != null)
                            {
                                unchecked
                                {
                                    auraMask |= (ulong)(1L << checked ((int)(ulong)i));
                                }
                                packet.AddUInt16((ushort)objCharacter.Pet.ActiveSpells[i].SpellID);
                                packet.AddInt8(1);
                            }
                        }
                        packet.AddUInt64(auraMask, auraPos);
                    }
                    else
                    {
                        packet.AddInt64(0L);
                    }
                }
                return(packet);
            }
        }
Exemple #14
0
            public void SendLoot(ref WS_Network.ClientClass client)
            {
                if (Items.Count == 0)
                {
                    WorldServiceLocator._WS_Loot.SendEmptyLoot(GUID, LootType, ref client);
                    return;
                }
                if (decimal.Compare(new decimal(LootOwner), 0m) != 0 && client.Character.GUID != LootOwner)
                {
                    Packets.PacketClass notMy = new Packets.PacketClass(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE);
                    notMy.AddInt8(58);
                    notMy.AddUInt64(0uL);
                    notMy.AddUInt64(0uL);
                    notMy.AddInt8(0);
                    client.Send(ref notMy);
                    notMy.Dispose();
                    return;
                }
                Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_LOOT_RESPONSE);
                response.AddUInt64(GUID);
                response.AddInt8((byte)LootType);
                response.AddInt32(Money);
                byte b2;
                byte i;

                checked
                {
                    response.AddInt8((byte)Items.Count);
                    byte b = (byte)(Items.Count - 1);
                    byte j = 0;
                    while (j <= (uint)b)
                    {
                        if (Items[j] == null)
                        {
                            response.AddInt8(j);
                            response.AddInt32(0);
                            response.AddInt32(0);
                            response.AddInt32(0);
                            response.AddUInt64(0uL);
                            response.AddInt8(0);
                        }
                        else
                        {
                            response.AddInt8(j);
                            response.AddInt32(Items[j].ItemID);
                            response.AddInt32(Items[j].ItemCount);
                            response.AddInt32(Items[j].ItemModel);
                            response.AddUInt64(0uL);
                            if (client.Character.IsInGroup && client.Character.Group.LootMethod == GroupLootMethod.LOOT_MASTER && client.Character.Group.LocalLootMaster != null && client.Character.Group.LocalLootMaster != client.Character)
                            {
                                response.AddInt8(2);
                            }
                            else
                            {
                                response.AddInt8(0);
                            }
                        }
                        j = (byte)unchecked ((uint)(j + 1));
                    }
                    client.Send(ref response);
                    response.Dispose();
                    client.Character.lootGUID = GUID;
                    if (!client.Character.IsInGroup || !((client.Character.Group.LootMethod == GroupLootMethod.LOOT_NEED_BEFORE_GREED) | (client.Character.Group.LootMethod == GroupLootMethod.LOOT_GROUP)))
                    {
                        return;
                    }
                    b2 = (byte)(Items.Count - 1);
                    i  = 0;
                }
                while (i <= (uint)b2)
                {
                    if (Items[i] != null && WorldServiceLocator._WorldServer.ITEMDatabase[Items[i].ItemID].Quality >= (int)client.Character.Group.LootThreshold)
                    {
                        GroupLootInfo[i] = new GroupLootInfo
                        {
                            LootObject = this,
                            LootSlot   = i,
                            Item       = Items[i]
                        };
                        WorldServiceLocator._WS_Loot.StartRoll(GUID, i, ref client.Character);
                        break;
                    }
                    checked
                    {
                        i = (byte)unchecked ((uint)(i + 1));
                    }
                }
            }
Exemple #15
0
 public void On_CMSG_NAME_QUERY(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     try
     {
         if (checked (packet.Data.Length - 1) < 13)
         {
             return;
         }
         packet.GetInt16();
         ulong GUID = packet.GetUInt64();
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_NAME_QUERY [GUID={2:X}]", client.IP, client.Port, GUID);
         Packets.PacketClass SMSG_NAME_QUERY_RESPONSE = new Packets.PacketClass(Opcodes.SMSG_NAME_QUERY_RESPONSE);
         if (GUID == int.MaxValue)
         {
             try
             {
                 SMSG_NAME_QUERY_RESPONSE.AddUInt64(GUID);
                 SMSG_NAME_QUERY_RESPONSE.AddString("System");
                 SMSG_NAME_QUERY_RESPONSE.AddInt32(1);
                 SMSG_NAME_QUERY_RESPONSE.AddInt32(1);
                 SMSG_NAME_QUERY_RESPONSE.AddInt32(1);
                 client.Send(ref SMSG_NAME_QUERY_RESPONSE);
             }
             finally
             {
                 SMSG_NAME_QUERY_RESPONSE.Dispose();
             }
         }
         else if (WorldServiceLocator._CommonGlobalFunctions.GuidIsPlayer(GUID))
         {
             if (WorldServiceLocator._WorldServer.CHARACTERs.ContainsKey(GUID))
             {
                 try
                 {
                     SMSG_NAME_QUERY_RESPONSE.AddUInt64(GUID);
                     SMSG_NAME_QUERY_RESPONSE.AddString(WorldServiceLocator._WorldServer.CHARACTERs[GUID].Name);
                     SMSG_NAME_QUERY_RESPONSE.AddInt32((int)WorldServiceLocator._WorldServer.CHARACTERs[GUID].Race);
                     SMSG_NAME_QUERY_RESPONSE.AddInt32((int)WorldServiceLocator._WorldServer.CHARACTERs[GUID].Gender);
                     SMSG_NAME_QUERY_RESPONSE.AddInt32((int)WorldServiceLocator._WorldServer.CHARACTERs[GUID].Classe);
                     client.Send(ref SMSG_NAME_QUERY_RESPONSE);
                 }
                 finally
                 {
                     SMSG_NAME_QUERY_RESPONSE.Dispose();
                 }
                 return;
             }
             DataTable MySQLQuery = new DataTable();
             WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT char_name, char_race, char_class, char_gender FROM characters WHERE char_guid = \"{GUID}\";", ref MySQLQuery);
             if (MySQLQuery.Rows.Count > 0)
             {
                 try
                 {
                     SMSG_NAME_QUERY_RESPONSE.AddUInt64(GUID);
                     SMSG_NAME_QUERY_RESPONSE.AddString(MySQLQuery.Rows[0].As <string>("char_name"));
                     SMSG_NAME_QUERY_RESPONSE.AddInt32(MySQLQuery.Rows[0].As <int>("char_race"));
                     SMSG_NAME_QUERY_RESPONSE.AddInt32(MySQLQuery.Rows[0].As <int>("char_gender"));
                     SMSG_NAME_QUERY_RESPONSE.AddInt32(MySQLQuery.Rows[0].As <int>("char_class"));
                     client.Send(ref SMSG_NAME_QUERY_RESPONSE);
                 }
                 finally
                 {
                     SMSG_NAME_QUERY_RESPONSE.Dispose();
                 }
             }
             else
             {
                 WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_NAME_QUERY_RESPONSE [Character GUID={2:X} not found]", client.IP, client.Port, GUID);
             }
             MySQLQuery.Dispose();
         }
         else
         {
             if (!WorldServiceLocator._CommonGlobalFunctions.GuidIsCreature(GUID))
             {
                 return;
             }
             if (WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(GUID))
             {
                 try
                 {
                     SMSG_NAME_QUERY_RESPONSE.AddUInt64(GUID);
                     SMSG_NAME_QUERY_RESPONSE.AddString(WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].Name);
                     SMSG_NAME_QUERY_RESPONSE.AddInt32(0);
                     SMSG_NAME_QUERY_RESPONSE.AddInt32(0);
                     SMSG_NAME_QUERY_RESPONSE.AddInt32(0);
                     client.Send(ref SMSG_NAME_QUERY_RESPONSE);
                 }
                 finally
                 {
                     SMSG_NAME_QUERY_RESPONSE.Dispose();
                 }
             }
             else
             {
                 WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_NAME_QUERY_RESPONSE [Creature GUID={2:X} not found]", client.IP, client.Port, GUID);
             }
         }
     }
     catch (Exception ex)
     {
         ProjectData.SetProjectError(ex);
         Exception e = ex;
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.CRITICAL, "Error at name query.{0}", Environment.NewLine + e);
         ProjectData.ClearProjectError();
     }
 }
Exemple #16
0
 public void On_CMSG_TEXT_EMOTE(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     checked
     {
         if (packet.Data.Length - 1 < 21 && client.Character != null)
         {
             return;
         }
         packet.GetInt16();
         int   TextEmote = packet.GetInt32();
         int   Unk       = packet.GetInt32();
         ulong GUID      = packet.GetUInt64();
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_TEXT_EMOTE [TextEmote={2} Unk={3}]", client.IP, client.Port, TextEmote, Unk);
         if (WorldServiceLocator._CommonGlobalFunctions.GuidIsCreature(GUID) && WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(GUID))
         {
             WS_Quests aLLQUESTS = WorldServiceLocator._WorldServer.ALLQUESTS;
             ref WS_PlayerData.CharacterObject character = ref client.Character;
             Dictionary <ulong, WS_Creatures.CreatureObject> wORLD_CREATUREs;
             ulong key;
             WS_Creatures.CreatureObject creature = (wORLD_CREATUREs = WorldServiceLocator._WorldServer.WORLD_CREATUREs)[key = GUID];
             aLLQUESTS.OnQuestDoEmote(ref character, ref creature, TextEmote);
             wORLD_CREATUREs[key] = creature;
             if (WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].aiScript != null && WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].aiScript is WS_Creatures_AI.GuardAI)
             {
                 ((WS_Creatures_AI.GuardAI)WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].aiScript).OnEmote(TextEmote);
             }
         }
         if (WorldServiceLocator._WS_DBCDatabase.EmotesText.ContainsKey(TextEmote))
         {
             if (WorldServiceLocator._WS_DBCDatabase.EmotesState[WorldServiceLocator._WS_DBCDatabase.EmotesText[TextEmote]] == 0)
             {
                 client.Character.DoEmote(WorldServiceLocator._WS_DBCDatabase.EmotesText[TextEmote]);
             }
             else if (WorldServiceLocator._WS_DBCDatabase.EmotesState[WorldServiceLocator._WS_DBCDatabase.EmotesText[TextEmote]] == 2)
             {
                 client.Character.cEmoteState = WorldServiceLocator._WS_DBCDatabase.EmotesText[TextEmote];
                 client.Character.SetUpdateFlag(148, client.Character.cEmoteState);
                 client.Character.SendCharacterUpdate();
             }
         }
         string secondName = "";
         if (decimal.Compare(new decimal(GUID), 0m) > 0)
         {
             if (WorldServiceLocator._WorldServer.CHARACTERs.ContainsKey(GUID))
             {
                 secondName = WorldServiceLocator._WorldServer.CHARACTERs[GUID].Name;
             }
             else if (WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(GUID))
             {
                 secondName = WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].Name;
             }
         }
         Packets.PacketClass SMSG_TEXT_EMOTE = new Packets.PacketClass(Opcodes.SMSG_TEXT_EMOTE);
         try
         {
             SMSG_TEXT_EMOTE.AddUInt64(client.Character.GUID);
             SMSG_TEXT_EMOTE.AddInt32(TextEmote);
             SMSG_TEXT_EMOTE.AddInt32(255);
             SMSG_TEXT_EMOTE.AddInt32(secondName.Length + 1);
             SMSG_TEXT_EMOTE.AddString(secondName);
             client.Character.SendToNearPlayers(ref SMSG_TEXT_EMOTE);
         }
         finally
         {
             SMSG_TEXT_EMOTE.Dispose();
         }
     }
            public void Check()
            {
                if (Looters.Count != Rolls.Count)
                {
                    return;
                }
                byte maxRollType = 0;

                foreach (KeyValuePair <WS_PlayerData.CharacterObject, int> looter2 in Looters)
                {
                    if (looter2.Value == 1)
                    {
                        maxRollType = 1;
                    }
                    if (looter2.Value == 2 && maxRollType != 1)
                    {
                        maxRollType = 2;
                    }
                }
                if (maxRollType == 0)
                {
                    LootObject.GroupLootInfo.Remove(LootSlot);
                    Packets.PacketClass response2 = new Packets.PacketClass(Opcodes.SMSG_LOOT_ALL_PASSED);
                    response2.AddUInt64(LootObject.GUID);
                    response2.AddInt32(LootSlot);
                    response2.AddInt32(Item.ItemID);
                    response2.AddInt32(0);
                    response2.AddInt32(0);
                    Broadcast(ref response2);
                    response2.Dispose();
                    return;
                }
                int maxRoll = -1;

                WS_PlayerData.CharacterObject looterCharacter = null;
                checked
                {
                    foreach (KeyValuePair <WS_PlayerData.CharacterObject, int> looter in Looters)
                    {
                        if (looter.Value == maxRollType)
                        {
                            byte rollValue = (byte)WorldServiceLocator._WorldServer.Rnd.Next(0, 100);
                            if (rollValue > maxRoll)
                            {
                                maxRoll         = rollValue;
                                looterCharacter = looter.Key;
                            }
                            Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_LOOT_ROLL);
                            response.AddUInt64(LootObject.GUID);
                            response.AddInt32(LootSlot);
                            response.AddUInt64(looter.Key.GUID);
                            response.AddInt32(Item.ItemID);
                            response.AddInt32(0);
                            response.AddInt32(0);
                            response.AddInt8(rollValue);
                            response.AddInt8((byte)looter.Value);
                            Broadcast(ref response);
                            response.Dispose();
                        }
                    }
                    ItemObject itemObject = new ItemObject(Item.ItemID, looterCharacter.GUID)
                    {
                        StackCount = Item.ItemCount
                    };
                    ItemObject          tmpItem = itemObject;
                    Packets.PacketClass wonItem = new Packets.PacketClass(Opcodes.SMSG_LOOT_ROLL_WON);
                    wonItem.AddUInt64(LootObject.GUID);
                    wonItem.AddInt32(LootSlot);
                    wonItem.AddInt32(Item.ItemID);
                    wonItem.AddInt32(0);
                    wonItem.AddInt32(0);
                    wonItem.AddUInt64(looterCharacter.GUID);
                    wonItem.AddInt8((byte)maxRoll);
                    wonItem.AddInt8(maxRollType);
                    Broadcast(ref wonItem);
                    if (looterCharacter.ItemADD(ref tmpItem))
                    {
                        looterCharacter.LogLootItem(tmpItem, Item.ItemCount, Recieved: false, Created: false);
                        LootObject.GroupLootInfo.Remove(LootSlot);
                        LootObject.Items[LootSlot] = null;
                    }
                    else
                    {
                        tmpItem.Delete();
                        LootObject.GroupLootInfo.Remove(LootSlot);
                    }
                }
            }
Exemple #18
0
 public void On_CMSG_GET_MAIL_LIST(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     checked
     {
         if (packet.Data.Length - 1 < 13)
         {
             return;
         }
         packet.GetInt16();
         ulong GameObjectGUID = packet.GetUInt64();
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GET_MAIL_LIST [GUID={2:X}]", client.IP, client.Port, GameObjectGUID);
         try
         {
             DataTable MySQLQuery = new DataTable();
             WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT mail_id FROM characters_mail WHERE mail_time < {WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now)};", ref MySQLQuery);
             if (MySQLQuery.Rows.Count > 0)
             {
                 byte b = (byte)(MySQLQuery.Rows.Count - 1);
                 byte j = 0;
                 while (j <= (uint)b)
                 {
                     WorldServiceLocator._WorldServer.CharacterDatabase.Update(string.Format("DELETE FROM characters_mail WHERE mail_id = {0};", RuntimeHelpers.GetObjectValue(MySQLQuery.Rows[j]["mail_id"])));
                     j = (byte)unchecked ((uint)(j + 1));
                 }
             }
             WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT * FROM characters_mail WHERE mail_receiver = {client.Character.GUID};", ref MySQLQuery);
             Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_MAIL_LIST_RESULT);
             response.AddInt8((byte)MySQLQuery.Rows.Count);
             if (MySQLQuery.Rows.Count > 0)
             {
                 byte b2 = (byte)(MySQLQuery.Rows.Count - 1);
                 byte i  = 0;
                 while (i <= (uint)b2)
                 {
                     response.AddInt32(MySQLQuery.Rows[i].As <int>("mail_id"));
                     response.AddInt8(MySQLQuery.Rows[i].As <byte>("mail_type"));
                     object left = MySQLQuery.Rows[i]["mail_type"];
                     if (Operators.ConditionalCompareObjectEqual(left, MailTypeInfo.NORMAL, TextCompare: false))
                     {
                         response.AddUInt64(MySQLQuery.Rows[i].As <ulong>("mail_sender"));
                     }
                     else if (Operators.ConditionalCompareObjectEqual(left, MailTypeInfo.AUCTION, TextCompare: false))
                     {
                         response.AddInt32(MySQLQuery.Rows[i].As <int>("mail_sender"));
                     }
                     response.AddString(MySQLQuery.Rows[i].As <string>("mail_subject"));
                     if (Operators.ConditionalCompareObjectNotEqual(MySQLQuery.Rows[i]["mail_body"], "", TextCompare: false))
                     {
                         response.AddInt32(MySQLQuery.Rows[i].As <int>("mail_id"));
                     }
                     else
                     {
                         response.AddInt32(0);
                     }
                     response.AddInt32(0);
                     response.AddInt32(MySQLQuery.Rows[i].As <int>("mail_stationary"));
                     if (decimal.Compare(new decimal(MySQLQuery.Rows[i].As <ulong>("item_guid")), 0m) > 0)
                     {
                         ItemObject tmpItem = WorldServiceLocator._WS_Items.LoadItemByGUID(MySQLQuery.Rows[i].As <ulong>("item_guid"));
                         response.AddInt32(tmpItem.ItemEntry);
                         if (tmpItem.Enchantments.ContainsKey(0))
                         {
                             packet.AddInt32(tmpItem.Enchantments[0].ID);
                         }
                         else
                         {
                             packet.AddInt32(0);
                         }
                         response.AddInt32(tmpItem.RandomProperties);
                         response.AddInt32(0);
                         response.AddInt8((byte)tmpItem.StackCount);
                         response.AddInt32(tmpItem.ChargesLeft);
                         response.AddInt32(tmpItem.ItemInfo.Durability);
                         response.AddInt32(tmpItem.Durability);
                     }
                     else
                     {
                         response.AddInt32(0);
                         response.AddInt32(0);
                         response.AddInt32(0);
                         response.AddInt32(0);
                         response.AddInt8(0);
                         response.AddInt32(0);
                         response.AddInt32(0);
                         response.AddInt32(0);
                     }
                     response.AddUInt32(MySQLQuery.Rows[i].As <uint>("mail_money"));
                     response.AddUInt32(MySQLQuery.Rows[i].As <uint>("mail_COD"));
                     response.AddInt32(MySQLQuery.Rows[i].As <int>("mail_read"));
                     response.AddSingle((float)((MySQLQuery.Rows[i].As <uint>("mail_time") - WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now)) / 86400.0));
                     response.AddInt32(0);
                     i = (byte)unchecked ((uint)(i + 1));
                 }
             }
             client.Send(ref response);
             response.Dispose();
         }
         catch (Exception ex)
         {
             ProjectData.SetProjectError(ex);
             Exception e = ex;
             WorldServiceLocator._WorldServer.Log.WriteLine(LogType.FAILED, "Error getting mail list: {0}{1}", Environment.NewLine, e.ToString());
             ProjectData.ClearProjectError();
         }
     }
 }
Exemple #19
0
 public void On_CMSG_PETITION_BUY(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     checked
     {
         if (packet.Data.Length - 1 < 26)
         {
             return;
         }
         packet.GetInt16();
         ulong GUID = packet.GetUInt64();
         packet.GetInt64();
         packet.GetInt32();
         string Name = packet.GetString();
         if (packet.Data.Length - 1 < 26 + Name.Length + 40 + 2 + 1 + 4 + 4)
         {
             return;
         }
         packet.GetInt64();
         packet.GetInt64();
         packet.GetInt64();
         packet.GetInt64();
         packet.GetInt64();
         packet.GetInt16();
         packet.GetInt8();
         int Index = packet.GetInt32();
         packet.GetInt32();
         if (!WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(GUID) || (WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].CreatureInfo.cNpcFlags & 0x200) == 0)
         {
             return;
         }
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_PETITION_BUY [GuildName={2}]", client.IP, client.Port, Name);
         if ((ulong)client.Character.GuildID != 0)
         {
             return;
         }
         int       CharterID    = WorldServiceLocator._Global_Constants.PETITION_GUILD;
         int       CharterPrice = WorldServiceLocator._Global_Constants.PETITION_GUILD_PRICE;
         DataTable q            = new DataTable();
         WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT guild_id FROM guilds WHERE guild_name = '{Name}'", ref q);
         if (q.Rows.Count > 0)
         {
             SendGuildResult(ref client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_NAME_EXISTS, Name);
         }
         q.Clear();
         if (!WorldServiceLocator._Functions.ValidateGuildName(Name))
         {
             SendGuildResult(ref client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_NAME_INVALID, Name);
         }
         if (!WorldServiceLocator._WorldServer.ITEMDatabase.ContainsKey(CharterID))
         {
             Packets.PacketClass response2 = new Packets.PacketClass(Opcodes.SMSG_BUY_FAILED);
             response2.AddUInt64(GUID);
             response2.AddInt32(CharterID);
             response2.AddInt8(0);
             client.Send(ref response2);
             response2.Dispose();
             return;
         }
         if (client.Character.Copper < CharterPrice)
         {
             Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_BUY_FAILED);
             response.AddUInt64(GUID);
             response.AddInt32(CharterID);
             response.AddInt8(2);
             client.Send(ref response);
             response.Dispose();
             return;
         }
         ref uint copper = ref client.Character.Copper;
         copper = (uint)(copper - CharterPrice);
         client.Character.SetUpdateFlag(1176, client.Character.Copper);
         client.Character.SendCharacterUpdate(toNear: false);
         ItemObject tmpItem = new ItemObject(CharterID, client.Character.GUID)
         {
             StackCount = 1
         };
         tmpItem.AddEnchantment((int)(tmpItem.GUID - WorldServiceLocator._Global_Constants.GUID_ITEM), 0);
         if (client.Character.ItemADD(ref tmpItem))
         {
             WorldServiceLocator._WorldServer.CharacterDatabase.Update(string.Format("INSERT INTO petitions (petition_id, petition_itemGuid, petition_owner, petition_name, petition_type, petition_signedMembers) VALUES ({0}, {0}, {1}, '{2}', {3}, 0);", tmpItem.GUID - WorldServiceLocator._Global_Constants.GUID_ITEM, client.Character.GUID - WorldServiceLocator._Global_Constants.GUID_PLAYER, Name, 9));
         }
         else
         {
             tmpItem.Delete();
         }
     }