예제 #1
0
        /// <summary>
        /// Sends the new state of the trading window to other party
        /// </summary>
        /// <param name="otherParty">Whether this is sending the own info to the other party (or, if false, to oneself)</param>
        /// <param name="client">receiving party</param>
        /// <param name="money">new amount of money</param>
        /// <param name="items">new items</param>
        public static void SendTradeUpdate(IPacketReceiver client, bool otherParty, uint money, Item[] items)
        {
            using (var pkt = new RealmPacketOut(RealmServerOpCode.SMSG_TRADE_STATUS_EXTENDED, 30 + 18 * 4 * items.Length))
            {
                pkt.Write(otherParty);
                pkt.Write(0);                                                   // Trade id
                pkt.Write(items.Length);
                pkt.Write(items.Length);
                pkt.Write(money);
                pkt.Write(0);

                for (var i = 0; i < items.Length; i++)
                {
                    pkt.WriteByte(i);
                    var item = items[i];

                    if (item != null)
                    {
                        pkt.Write(item.EntryId);
                        pkt.Write(item.Template.DisplayId);
                        pkt.Write(item.Amount);
                        pkt.Write(0);

                        pkt.Write(item.GiftCreator);

                        var enchant = item.GetEnchantment(EnchantSlot.Permanent);
                        pkt.Write(enchant != null ? enchant.Entry.Id : 0);

                        pkt.Zero(4 * 3);

                        pkt.Write(item.Creator);
                        pkt.Write(item.SpellCharges);
                        pkt.Write(item.Template.RandomSuffixFactor);
                        pkt.Write(item.RandomPropertiesId);

                        var itemLock = item.Lock;
                        pkt.Write(itemLock != null ? itemLock.Id : 0);

                        pkt.Write(item.MaxDurability);
                        pkt.Write(item.Durability);
                    }
                    else
                    {
                        pkt.Zero(18 * 4);
                    }
                }

                client.Send(pkt, addEnd: false);
            }
        }
예제 #2
0
        /// <summary>
        /// Sends the new state of the trading window to other party
        /// </summary>
        /// <param name="otherParty">Whether this is sending the own info to the other party (or, if false, to oneself)</param>
        /// <param name="client">receiving party</param>
        /// <param name="money">new amount of money</param>
        /// <param name="items">new items</param>
        public static void SendTradeUpdate(IPacketReceiver client, bool otherParty, uint money, Item[] items)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_TRADE_STATUS_EXTENDED,
                                                              30 + 72 * items.Length))
            {
                packet.Write(otherParty);
                packet.Write(0);
                packet.Write(items.Length);
                packet.Write(items.Length);
                packet.Write(money);
                packet.Write(0);
                for (int val = 0; val < items.Length; ++val)
                {
                    packet.WriteByte(val);
                    Item obj = items[val];
                    if (obj != null)
                    {
                        packet.Write(obj.EntryId);
                        packet.Write(obj.Template.DisplayId);
                        packet.Write(obj.Amount);
                        packet.Write(0);
                        packet.Write(obj.GiftCreator);
                        ItemEnchantment enchantment = obj.GetEnchantment(EnchantSlot.Permanent);
                        packet.Write(enchantment != null ? enchantment.Entry.Id : 0U);
                        packet.Zero(12);
                        packet.Write(obj.Creator);
                        packet.Write(obj.SpellCharges);
                        packet.Write(obj.Template.RandomSuffixFactor);
                        packet.Write(obj.RandomPropertiesId);
                        LockEntry lockEntry = obj.Lock;
                        packet.Write(lockEntry != null ? lockEntry.Id : 0U);
                        packet.Write(obj.MaxDurability);
                        packet.Write(obj.Durability);
                    }
                    else
                    {
                        packet.Zero(72);
                    }
                }

                client.Send(packet, false);
            }
        }
예제 #3
0
		/// <summary>
		/// Sends the new state of the trading window to other party
		/// </summary>
		/// <param name="otherParty">Whether this is sending the own info to the other party (or, if false, to oneself)</param>
		/// <param name="client">receiving party</param>
		/// <param name="money">new amount of money</param>
		/// <param name="items">new items</param>
		public static void SendTradeUpdate(IPacketReceiver client, bool otherParty, uint money, Item[] items)
		{
			using (var pkt = new RealmPacketOut(RealmServerOpCode.SMSG_TRADE_STATUS_EXTENDED, 30 + 18 * 4 * items.Length))
			{
				pkt.Write(otherParty);
				pkt.Write(0);					// Trade id
				pkt.Write(items.Length);
				pkt.Write(items.Length);
				pkt.Write(money);
				pkt.Write(0);

				for (var i = 0; i < items.Length; i++)
				{
					pkt.WriteByte(i);
					var item = items[i];

					if (item != null)
					{
						pkt.Write(item.EntryId);
						pkt.Write(item.Template.DisplayId);
						pkt.Write(item.Amount);
						pkt.Write(0);

						pkt.Write(item.GiftCreator);

						var enchant = item.GetEnchantment(EnchantSlot.Permanent);
						pkt.Write(enchant != null ? enchant.Entry.Id : 0);

						pkt.Zero(4 * 3);

						pkt.Write(item.Creator);
						pkt.Write(item.SpellCharges);
						pkt.Write(item.Template.RandomSuffixFactor);
						pkt.Write(item.RandomPropertiesId);

						var itemLock = item.Lock;
						pkt.Write(itemLock != null ? itemLock.Id : 0);

						pkt.Write(item.MaxDurability);
						pkt.Write(item.Durability);
					}
					else
					{
						pkt.Zero(18 * 4);
					}
				}

				client.Send(pkt);
			}
		}
예제 #4
0
        /// <summary>
        /// Sends the character list to the client.
        /// </summary>
        /// <param name="client">the client to send to</param>
        /// <remarks>They probably meant 'enumeration,' but 'list' would have made so much more sense. :)</remarks>
        public static void SendCharEnum(IRealmClient client)
        {
            CharacterRecord curRecord = null;
            try
            {
                using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_ENUM))
                {
                    var chrs = client.Account.Characters;

                    packet.WriteByte(chrs.Count);

                    foreach (var record in chrs)
                    {
                        curRecord = record;

                        packet.Write(EntityId.GetPlayerId(record.EntityLowId)); // 8
                        packet.WriteCString(record.Name); // 9 + namelength
                        packet.Write((byte)record.Race); // 10 + namelength
                        packet.Write((byte)record.Class); // 11 + namelength
                        packet.Write((byte)record.Gender); // 12 + namelength
                        packet.Write(record.Skin); // 13 + namelength
                        packet.Write(record.Face); // 14 + namelength
                        packet.Write(record.HairStyle); // 15 + namelength
                        packet.Write(record.HairColor); // 16 + namelength
                        packet.Write(record.FacialHair); // 17 + namelength
                        packet.Write((byte)record.Level); // 18 + namelength
                        packet.Write((int)record.Zone); // 22 + namelength
                        packet.Write((int)record.MapId); // 26 + namelength

                        packet.Write(record.PositionX); // 30 + namelength
                        packet.Write(record.PositionY); // 34 + namelength
                        packet.Write(record.PositionZ); // 38 + namelength

                        packet.WriteUInt(record.GuildId); // guild id							// 42 + namelength
                        packet.Write((int)record.CharacterFlags); // 46 + namelength

                        packet.Write(0); // TOOD: Customization flags

                        packet.Write((byte)1); // NEW 3.2.0 - first login y/n - set to 1 for now

                        // Deprecated: Rest State
                        // var restState = record.RestXp > 0 ? RestState.Resting : RestState.Normal;
                        // packet.WriteByte((byte)restState); // 47 + namelength

                        // pet info (51 - 63)
                        var petEntry = record.PetEntry;
                        if (petEntry != null)
                        {
                            packet.Write(petEntry.DisplayIds[0]);
                            packet.Write(record.Level);				// liars!
                            packet.Write((int)petEntry.FamilyId);
                        }
                        else
                        {
                            packet.Write(0); // 51 + namelength
                            packet.Write(0); // 55 + namelength
                            packet.Write(0); // 59 + namelength
                        }

                        var itemOffset = packet.Position;
                        //packet.TotalLength += CharEnumItemCount * CharEnumItemBytes; // 239 + namelength
                        packet.Zero(CharEnumItemCount * CharEnumItemBytes);
                        packet.Position = itemOffset;

                        if (record.JustCreated)
                        {
                            var archetype = ArchetypeMgr.GetArchetype(record.Race, record.Class);
                            if (archetype != null)
                            {
                                var items = archetype.GetInitialItems(record.Gender);
                                foreach (var item in items)
                                {
                                    var template = item.Template;
                                    if (template.EquipmentSlots != null)
                                    {
                                        packet.Position = itemOffset + ((int)template.EquipmentSlots[0] * CharEnumItemBytes);

                                        packet.Write(template.DisplayId);
                                        packet.Write((byte)template.InventorySlotType);
                                        packet.Write(0);
                                    }
                                }
                            }
                            else
                            {
                                log.Warn("Invalid Race/Class combination " +
                                         "({0} {1}) in CharacterRecord {2}.",
                                         record.Race, record.Class, record);
                            }
                        }
                        else
                        {
                            foreach (var item in record.GetOrLoadItems())
                            {
                                if (!item.IsOwned)
                                {
                                    continue;
                                }

                                var template = item.Template;
                                if (item.ContainerSlot == BaseInventory.INVALID_SLOT && item.Slot <= (int)EquipmentSlot.Bag4)
                                {
                                    packet.Position = itemOffset + (item.Slot * CharEnumItemBytes);
                                    if (template != null)
                                    {
                                        var enchant = item.GetEnchant(EnchantSlot.Permanent);

                                        packet.Write(template.DisplayId);
                                        packet.Write((byte)template.InventorySlotType);
                                        packet.Write(enchant != null ? enchant.Visual : 0);
                                    }
                                    else
                                    {
                                        packet.Write(0);
                                        packet.Write((byte)0);
                                        packet.Write(0);
                                    }
                                }
                            }
                        }

                        packet.Position = itemOffset + (CharEnumItemCount * CharEnumItemBytes);
                    }

                    client.Send(packet);
                }
            }
            catch (Exception e)
            {
                if (curRecord == null)
                {
                    throw e;
                }

                LogUtil.ErrorException(e,
                                       "Could not create Char-Enum " +
                                       "for Character \"{0}\" (Race: {1}, Class: {2}, Level: {3}, Map: {4}{5}).",
                                       curRecord, curRecord.Race, curRecord.Class, curRecord.Level, curRecord.MapId,
                                       curRecord.IsNew ? ", [New]" : "");
            }
        }
예제 #5
0
		public static void SendItemQueryResponse(IRealmClient client, ItemTemplate item)
		{
			var locale = client.Info.Locale;
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_QUERY_SINGLE_RESPONSE, 630))
			{
				packet.Write(item.Id);
				packet.Write((uint)item.Class);
				packet.Write((uint)item.SubClass);
				packet.Write(-1); // unknown

				packet.WriteCString(item.Names.Localize(locale));
				packet.Write((byte)0);// name2
				packet.Write((byte)0);// name3
				packet.Write((byte)0);// name4

				packet.Write(item.DisplayId);
				packet.Write((uint)item.Quality);
				packet.Write((uint)item.Flags);
                packet.Write((uint)item.Faction);		// new 3.2.0
				packet.Write(item.BuyPrice);
				packet.Write(item.SellPrice);
				packet.Write((int)item.InventorySlotType);
				packet.Write((uint)item.RequiredClassMask);
				packet.Write((uint)item.RequiredRaceMask);
				packet.Write(item.Level);
				packet.Write(item.RequiredLevel);
				packet.Write(item.RequiredSkill != null ? (int)item.RequiredSkill.Id : 0);
				packet.Write(item.RequiredSkillValue);
				packet.Write(item.RequiredProfession != null ? item.RequiredProfession.Id : 0);
				packet.Write(item.RequiredPvPRank);
				packet.Write(item.UnknownRank);// PVP Medal
				packet.Write(item.RequiredFaction != null ? (int)item.RequiredFaction.Id : 0);
				packet.Write((int)item.RequiredFactionStanding);
				packet.Write(item.UniqueCount);
				packet.Write(item.MaxAmount);
				packet.Write(item.ContainerSlots);

				packet.Write(item.Mods.Length);
				for (var m = 0; m < item.Mods.Length; m++)
				{
					packet.Write((int) item.Mods[m].Type);
					packet.Write(item.Mods[m].Value);
				}

				packet.Write(0);// NEW 3.0.2 ScalingStatDistribution.dbc
				packet.Write(0);// NEW 3.0.2 ScalingStatFlags


				// In 3.1 there are only 2 damages instead of 5
				for (var i = 0; i < item.Damages.Length && i < 2; i++)
				{
					var dmg = item.Damages[i];

					packet.Write(dmg.Minimum);
					packet.Write(dmg.Maximum);
					packet.Write((uint)dmg.School);
				}

				for (var i = 0; i < ItemConstants.MaxResCount; i++)
				{
					var res = item.Resistances[i];
					packet.Write(res);
				}

				packet.Write(item.AttackTime);
				packet.Write((uint)item.ProjectileType);
				packet.Write(item.RangeModifier);

				var s = 0;
				for (; s < item.Spells.Length; s++)
				{
					var spell = item.Spells[s];
					if (spell != null)
					{
						packet.Write((uint)spell.Id);
						packet.Write((uint)spell.Trigger);
						packet.Write(spell.Charges);
						packet.Write(spell.Cooldown);
						packet.Write(spell.CategoryId);
						packet.Write(spell.CategoryCooldown);
					}
					else
					{
						// 6 * 4 = 24
						packet.Zero(24);
					}
				}

				for (; s < ItemConstants.MaxSpellCount; s++)
				{
					// 6 * 4 = 24
					packet.Zero(24);
				}

				packet.Write((uint)item.BondType);
				packet.WriteCString(item.Descriptions.Localize(locale));

				packet.Write(item.PageTextId);
				packet.Write(item.PageCount);
				packet.Write((uint)item.PageMaterial);
				packet.Write(item.QuestId);
				packet.Write(item.LockId);
				packet.Write((int)item.Material);
				packet.Write((int)item.SheathType);
				packet.Write(item.RandomPropertiesId);
				packet.Write(item.RandomSuffixId);
				packet.Write(item.BlockValue);
				packet.Write((uint)item.SetId);
				packet.Write(item.MaxDurability);
				packet.Write((uint)item.ZoneId);
				packet.Write((uint)item.MapId);
				packet.Write((uint)item.BagFamily);
				packet.Write((uint)item.TotemCategory);

				for (var i = 0; i < ItemConstants.MaxSocketCount; i++)
				{
					packet.Write((uint)item.Sockets[i].Color);
					packet.Write(item.Sockets[i].Content);
				}

				packet.Write(item.SocketBonusEnchantId);
				packet.Write(item.GemPropertiesId);
				packet.Write(item.RequiredDisenchantingLevel);
				packet.Write(item.ArmorModifier);

				packet.Write(0);// Exisiting duration in seconds
				packet.Write(0);// NEW 3.0.2 ItemLimitCategory.dbc

				packet.Write(0); // NEW 3.1.0 Holidays.dbc

				client.Send(packet);
			}
		}