Пример #1
0
		public static void SendItemNameQueryResponse(IPacketReceiver client, ItemTemplate item)
		{
			using (var outPacket = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_NAME_QUERY_RESPONSE, 4 + item.DefaultName.Length))
			{
				outPacket.WriteInt(item.Id);
				outPacket.WriteCString(item.DefaultName);

				client.Send(outPacket);
			}
		}
Пример #2
0
        public static void SendItemNameQueryResponse(RealmClient client, ItemTemplate item)
        {
            using (RealmPacketOut outPacket = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_NAME_QUERY_RESPONSE, 4 + item.Name.Length))
            {
                outPacket.WriteInt(item.Id);
                outPacket.WriteCString(item.Name);

                client.Send(outPacket);
            }
        }
Пример #3
0
        public static void CreateAchievementData(RealmPacketOut packet, Character chr)
        {
            foreach (AchievementRecord achievementRecord in chr.Achievements.m_completedAchievements.Values)
            {
                packet.WriteUInt(achievementRecord.AchievementEntryId);
                packet.WriteDateTime(achievementRecord.CompleteDate);
            }

            packet.WriteInt(uint.MaxValue);
        }
Пример #4
0
        public static void SendItemNameQueryResponse(IPacketReceiver client, ItemTemplate item)
        {
            using (var outPacket = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_NAME_QUERY_RESPONSE, 4 + item.DefaultName.Length))
            {
                outPacket.WriteInt(item.Id);
                outPacket.WriteCString(item.DefaultName);

                client.Send(outPacket, addEnd: false);
            }
        }
Пример #5
0
 public static void SendTextEmote(WorldObject obj, TextEmote emote, INamed target)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_TEXT_EMOTE,
                                                       target == null ? 20 : target.Name.Length + 21))
     {
         packet.Write(obj.EntityId);
         packet.WriteUInt((uint)emote);
         packet.WriteInt(-1);
         packet.WriteUIntPascalString(target != null ? target.Name : "");
         obj.SendPacketToArea(packet, true, false, Locale.Any, new float?());
     }
 }
Пример #6
0
        // Client doesn't seem to be sending this
        //[ClientPacketHandler(RealmServerOpCode.CMSG_EMOTE)]
        //public static void HandleEmote(IRealmClient client, RealmPacketIn packet)
        //{
        //    var emote = (EmoteType)packet.ReadUInt32();

        //    if (emote != EmoteType.None)
        //    {
        //        var chr = client.ActiveCharacter;
        //        if (chr.CanMove && chr.CanInteract)
        //        {
        //            SendEmote(chr, emote);
        //        }
        //    }
        //}

        public static void SendTextEmote(WorldObject obj, TextEmote emote, INamed target)
        {
            var len = (target == null) ? 20 : target.Name.Length + 21;

            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_TEXT_EMOTE, len))
            {
                packet.Write(obj.EntityId);
                packet.WriteUInt((uint)emote);
                packet.WriteInt(-1);
                packet.WriteUIntPascalString(target != null ? target.Name : "");

                obj.SendPacketToArea(packet, true);
            }
        }
Пример #7
0
        // Client doesn't seem to be sending this
        //[ClientPacketHandler(RealmServerOpCode.CMSG_EMOTE)]
        //public static void HandleEmote(IRealmClient client, RealmPacketIn packet)
        //{
        //    var emote = (EmoteType)packet.ReadUInt32();

        //    if (emote != EmoteType.None)
        //    {
        //        var chr = client.ActiveCharacter;
        //        if (chr.CanMove && chr.CanInteract)
        //        {
        //            SendEmote(chr, emote);
        //        }
        //    }
        //}

        public static void SendTextEmote(WorldObject obj, TextEmote emote, INamed target)
        {
            var len = (target == null) ? 20 : target.Name.Length + 21;

            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_TEXT_EMOTE, len))
            {
                packet.Write(obj.EntityId);
                packet.WriteUInt((uint)emote);
                packet.WriteInt(-1);
                packet.WriteUIntPascalString(target != null ? target.Name : "");

                obj.SendPacketToArea(packet, true);
            }
        }
Пример #8
0
        public static void CreateAchievementData(RealmPacketOut packet, Character chr)
        {
            foreach (AchievementRecord completedAchievement in chr.Achievements.m_completedAchievements.Values)
            {
                packet.WriteUInt((uint)completedAchievement.AchievementEntryId);
                packet.WriteDateTime(completedAchievement.CompleteDate);
            }
            packet.WriteInt(0xFFFFFFFFu);

            foreach (AchievementProgressRecord achievementProgressRecord in chr.Achievements.m_progressRecords.Values)
            {
                packet.WriteUInt((uint)achievementProgressRecord.AchievementCriteriaId);
                packet.WritePackedUInt64(achievementProgressRecord.Counter);                                                    //	amount
                chr.EntityId.WritePacked(packet);
                packet.Write(0);
                packet.WriteDateTime(DateTime.Now);                                             // start time?
                packet.Write(0);                                                                // Duration
                packet.Write(0);
            }
            packet.Write(0xFFFFFFFFu);
        }
Пример #9
0
        public void TestParsedSegment()
        {
            PacketDefinition def = new PacketDefinition(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT, PacketSender.Client,
                new PacketSegmentStructure(SimpleType.UInt, "SpellAttributes", typeof(SpellAttributes)),
                new ListPacketSegmentStructure(SimpleType.Byte, "Members",
                    new PacketSegmentStructure(SimpleType.Guid, "MemberId"),
                    new PacketSegmentStructure(SimpleType.CString, "Name")
                ),

                new SwitchPacketSegmentStructure("Attribute Switch", "SpellAttributes",
                    new SwitchCase(ComparisonType.And, SpellAttributes.CannotBeCastInCombat,
                        new PacketSegmentStructure(SimpleType.CString, "NoCombatString")
                    ),
                    new SwitchCase(ComparisonType.And, SpellAttributes.CannotBeCastInCombat | SpellAttributes.CastableWhileMounted,
                        new PacketSegmentStructure(SimpleType.CString, "NoCombatNoDismountString")
                    )
                ),

                new SwitchPacketSegmentStructure("List Switch", "Members",
                    new SwitchCase(ComparisonType.Equal, (byte)0,
                        new PacketSegmentStructure(SimpleType.Byte, "Status", "CharacterStatus"),
                        new SwitchPacketSegmentStructure("Nested Switch", "Status",
                            new SwitchCase(ComparisonType.AndNot, CharacterStatus.OFFLINE,
                                new PacketSegmentStructure(SimpleType.UInt, "NumX")
                            )
                        )
                    ),
                    new SwitchCase(ComparisonType.GreaterThan, (byte)0,
                        new PacketSegmentStructure(SimpleType.CString, "Info")
                    )
                ),

                new StaticListPacketSegmentStructure(1, "StaticList1",
                    new PacketSegmentStructure(SimpleType.Int, "Number1")
                ),

                new StaticListPacketSegmentStructure(2, "StaticList2",
                    new PacketSegmentStructure(SimpleType.Int, "Number2")
                ),

                new PacketSegmentStructure(SimpleType.Byte, "ListLength"),

                new ListPacketSegmentStructure("SomeList3", "ListLength",
                    new PacketSegmentStructure(SimpleType.Int, "SomeListEle")
                )
            );

            def.Init();

            using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT))
            {
                packet.WriteUInt((uint)(SpellAttributes.CastableWhileMounted | SpellAttributes.CannotBeCastInCombat));
                packet.WriteByte(2);

                packet.Write(EntityId.Zero);
                packet.WriteCString("Member1Name");

                packet.Write(new EntityId(10));
                packet.WriteCString("Member2Name");

                packet.WriteCString("NoCombat");
                packet.WriteCString("NoCombatNoDismount");

                packet.WriteCString("lotsofinfo");

                // StaticList1
                packet.WriteInt(10);

                // StaticList2
                packet.WriteInt(20);
                packet.WriteInt(30);

                // SomeList3's length
                packet.WriteByte(2);
                // SomeList3
                packet.WriteInt(5);
                packet.WriteInt(7);

                var parsedPacket = PacketParser.Parse(packet, PacketSender.Client, def);

                Assert.AreEqual("NoCombat", parsedPacket["NoCombatString"].StringValue);
                Assert.AreEqual("NoCombatNoDismount", parsedPacket["NoCombatNoDismountString"].StringValue);

                var members = parsedPacket["Members"];
                Assert.AreEqual(EntityId.Zero, members[0]["MemberId"].EntityIdValue);
                Assert.AreEqual("Member1Name", members[0]["Name"].StringValue);
                Assert.AreEqual("Member2Name", members[1]["Name"].StringValue);
                Assert.AreEqual("lotsofinfo", parsedPacket["Info"].StringValue);
                CheckRemainder(parsedPacket);
            }

            using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT))
            {
                packet.WriteUInt((uint)SpellAttributes.None);
                packet.WriteByte(0);

                packet.Write((byte)CharacterStatus.ONLINE);
                packet.Write((uint)1234);

                packet.WriteInt(10);

                packet.WriteInt(20);
                packet.WriteInt(30);

                // SomeList3's length
                packet.WriteByte(2);
                // SomeList3
                packet.WriteInt(5);
                packet.WriteInt(7);

                var parsedPacket = PacketParser.Parse(packet, PacketSender.Client, def);

                Assert.IsNull(parsedPacket.GetByName("Info"));

                Assert.AreEqual(CharacterStatus.ONLINE, parsedPacket["Status"].Value);
                Assert.AreEqual((uint)1234, parsedPacket["NumX"].Value);

                CheckRemainder(parsedPacket);
            }
        }
Пример #10
0
		public static void CreateAchievementData(RealmPacketOut packet, Character chr)
		{
			foreach (AchievementRecord completedAchievement in chr.Achievements.m_completedAchievements.Values)
			{
				packet.WriteUInt((uint)completedAchievement.AchievementEntryId);
				packet.WriteDateTime(completedAchievement.CompleteDate);
			}
			packet.WriteInt(0xFFFFFFFFu);

			/*foreach (AchievementProgressRecord achievementProgressRecord in chr.Achievements.m_achivement_progress.Values)
			{

				packet.WriteUInt((uint)achievementProgressRecord.AchievementCriteriaId);
				packet.WritePackedUInt64(achievementProgressRecord.Counter);					//	amount
				chr.EntityId.WritePacked(packet);
				packet.Write(0);
				packet.WriteDateTime(DateTime.Now);				// start time?
				packet.Write(0);								// Duration
				packet.Write(0);

			}
			packet.Write(0xFFFFFFFFu);*/
		}
Пример #11
0
        public static void SendTimeSpeed(IPacketReceiver client, DateTime time, float timeSpeed)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOGIN_SETTIMESPEED, 8))
            {
                packet.WriteDateTime(time);
                packet.WriteFloat(timeSpeed);
                packet.WriteInt(0);				// new, unknown

                client.Send(packet);
            }
        }
Пример #12
0
        public static void SendItemQueryResponse(RealmClient client, ItemTemplate item)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_QUERY_SINGLE_RESPONSE, 630))
            {
                packet.Write(item.Id);
                packet.WriteInt((int)item.ItemClass);
                packet.WriteInt((int)item.ItemSubClass);
                packet.WriteInt(-1); // unknown

                packet.WriteCString(item.Name);
                packet.WriteByte(0);// name2
                packet.WriteByte(0);// name3
                packet.WriteByte(0);// name4

                packet.WriteInt(item.DisplayId);
                packet.WriteInt((int)item.Quality);
                packet.WriteInt((int)item.Flags);
                packet.WriteInt(item.BuyPrice);
                packet.WriteInt(item.SellPrice);
                packet.WriteInt((int)item.InventorySlot);
                packet.WriteInt((int)item.RequiredClassMask);
                packet.WriteInt((int)item.RequiredRaceMask);
                packet.WriteInt(item.Level);
                packet.WriteInt(item.RequiredLevel);
                packet.WriteInt(item.RequiredSkill != null ? (int)item.RequiredSkill.Id : 0);
                packet.WriteInt(item.RequiredSkillLevel);
                packet.WriteInt(item.RequiredProfession != null ? (int)item.RequiredProfession.Id : 0);
                packet.WriteInt(item.RequiredPvPRank);
                packet.WriteInt(item.UnknownRank);// city rank?
                packet.WriteInt(item.RequiredFaction != null ? (int)item.RequiredFaction.Id : 0);
                packet.WriteInt((int)item.RequiredFactionStanding);
                packet.WriteInt(item.UniqueCount);
                packet.WriteInt(item.MaxAmount);
                packet.WriteInt(item.ContainerSlots);
               foreach (var stat in item.Mods)
                {
					packet.WriteUInt((uint)stat.Type);
                    packet.WriteInt(stat.Value);
                }

                foreach (var dmg in item.Damages)
                {
					packet.WriteFloat(dmg.Minimum);
					packet.WriteFloat(dmg.Maximum);
					packet.WriteUInt((uint)dmg.DamageSchool);
                }

                foreach (var res in item.Resistances)
                {
                    packet.WriteUInt(res);
                }

                packet.WriteUInt(item.WeaponSpeed);
				packet.WriteUInt((uint)item.ProjectileType);
                packet.WriteFloat(item.RangeModifier);

                for (int i = 0; i < 5; i++)
                {
					packet.WriteUInt(item.Spells[i].Id);
					packet.WriteUInt((int)item.Spells[i].Trigger);
					packet.WriteUInt(item.Spells[i].Charges);
                    packet.WriteInt(item.Spells[i].Cooldown);
                    packet.WriteUInt(item.Spells[i].CategoryId);
                    packet.WriteInt(item.Spells[i].CategoryCooldown);
                }

				packet.WriteUInt((int)item.BondType);
                packet.WriteCString(item.Description);

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

				for (int i = 0; i < ItemTemplate.MaxSocketCount; i++)
                {
                    packet.WriteInt(item.Sockets[i].SocketColor);
                    packet.WriteInt(item.Sockets[i].Unknown);
                }
                packet.WriteInt(item.SocketBonusId);
                packet.WriteInt(item.GemProperties);
                packet.WriteInt(item.ExtendedCost);
                packet.WriteInt(item.RequiredArenaRanking);
                packet.WriteInt(item.RequiredDisenchantingLevel);
                packet.WriteFloat(item.ArmorModifier);

                client.Send(packet);
            }
        }
Пример #13
0
		private static RealmPacketOut CreateGuildRosterPacket(Guild guild, bool showOfficerNotes)
		{
			var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GUILD_ROSTER);

			packet.Write(guild.MemberCount);

			if (guild.MOTD != null)
			{
				packet.WriteCString(guild.MOTD);
			}
			else
			{
				packet.WriteByte(0);
			}

			if (guild.Info != null)
			{
				packet.WriteCString(guild.Info);
			}
			else
			{
				packet.WriteByte(0);
			}

			var guildRanks = guild.Ranks;

			packet.Write(guildRanks.Length);

			for (var i = 0; i < guildRanks.Length; i++)
			{
				var rank = guildRanks[i];

				packet.Write((uint)rank.Privileges);

				packet.Write(rank.DailyBankMoneyAllowance);

				for (var j = 0; j < GuildMgr.MAX_BANK_TABS; j++)
				{
					var tabPrivileges = rank.BankTabRights[j];
					packet.WriteInt((uint)tabPrivileges.Privileges);
					packet.WriteInt(tabPrivileges.WithdrawlAllowance);
				}
			}

			Character chr;
			foreach (var member in guild.Members.Values)
			{
				chr = member.Character;

				packet.Write(EntityId.GetPlayerId(member.Id));

				if (chr != null)
					packet.WriteByte((byte)chr.Status);
				else
					packet.WriteByte((byte)CharacterStatus.OFFLINE);

				packet.WriteCString(member.Name);
				packet.Write(member.Rank.RankIndex);

				packet.Write((byte)member.Level);
				packet.Write((byte)member.Class);
				packet.Write((byte)0);
				packet.Write(member.ZoneId);

				if (chr == null)
				{
					packet.Write((float)(DateTime.Now - member.LastLogin).TotalDays);
				}

				if (member.PublicNote != null)
					packet.WriteCString(member.PublicNote);
				else
					packet.Write((byte)0);

				if (showOfficerNotes && member.OfficerNote != null)
					packet.WriteCString(member.OfficerNote);
				else
					packet.Write((byte)0);
			}

			return packet;
		}
Пример #14
0
		/// <summary>
		/// Sends a guild information to a client
		/// </summary>
		/// <param name="client">the client to send to</param>
		/// <param name="guild">guild</param>
		public static void SendGuildInformation(IPacketReceiver client, Guild guild)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GUILD_INFO))
			{
				packet.WriteCString(guild.Name);
				packet.WriteInt((byte)guild.Created.Year);
				packet.WriteInt((byte)guild.Created.Month);
				packet.WriteInt((byte)guild.Created.Day);
				packet.WriteInt((byte)guild.MemberCount);
				packet.WriteInt((byte)guild.MemberCount); // number of accounts

				client.Send(packet);
			}
		}
Пример #15
0
        public static void SendItemQueryResponse(RealmClient client, ItemTemplate item)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_QUERY_SINGLE_RESPONSE, 630))
            {
                packet.Write(item.Id);
                packet.WriteInt((int)item.ItemClass);
                packet.WriteInt((int)item.ItemSubClass);
                packet.WriteInt(-1); // unknown

                packet.WriteCString(item.Name);
                packet.WriteByte(0); // name2
                packet.WriteByte(0); // name3
                packet.WriteByte(0); // name4

                packet.WriteInt(item.DisplayId);
                packet.WriteInt((int)item.Quality);
                packet.WriteInt((int)item.Flags);
                packet.WriteInt(item.BuyPrice);
                packet.WriteInt(item.SellPrice);
                packet.WriteInt((int)item.InventorySlot);
                packet.WriteInt((int)item.RequiredClassMask);
                packet.WriteInt((int)item.RequiredRaceMask);
                packet.WriteInt(item.Level);
                packet.WriteInt(item.RequiredLevel);
                packet.WriteInt(item.RequiredSkill != null ? (int)item.RequiredSkill.Id : 0);
                packet.WriteInt(item.RequiredSkillLevel);
                packet.WriteInt(item.RequiredProfession != null ? (int)item.RequiredProfession.Id : 0);
                packet.WriteInt(item.RequiredPvPRank);
                packet.WriteInt(item.UnknownRank);// city rank?
                packet.WriteInt(item.RequiredFaction != null ? (int)item.RequiredFaction.Id : 0);
                packet.WriteInt((int)item.RequiredFactionStanding);
                packet.WriteInt(item.UniqueCount);
                packet.WriteInt(item.MaxAmount);
                packet.WriteInt(item.ContainerSlots);
                foreach (var stat in item.Mods)
                {
                    packet.WriteUInt((uint)stat.Type);
                    packet.WriteInt(stat.Value);
                }

                foreach (var dmg in item.Damages)
                {
                    packet.WriteFloat(dmg.Minimum);
                    packet.WriteFloat(dmg.Maximum);
                    packet.WriteUInt((uint)dmg.DamageSchool);
                }

                foreach (var res in item.Resistances)
                {
                    packet.WriteUInt(res);
                }

                packet.WriteUInt(item.WeaponSpeed);
                packet.WriteUInt((uint)item.ProjectileType);
                packet.WriteFloat(item.RangeModifier);

                for (int i = 0; i < 5; i++)
                {
                    packet.WriteUInt(item.Spells[i].Id);
                    packet.WriteUInt((int)item.Spells[i].Trigger);
                    packet.WriteUInt(item.Spells[i].Charges);
                    packet.WriteInt(item.Spells[i].Cooldown);
                    packet.WriteUInt(item.Spells[i].CategoryId);
                    packet.WriteInt(item.Spells[i].CategoryCooldown);
                }

                packet.WriteUInt((int)item.BondType);
                packet.WriteCString(item.Description);

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

                for (int i = 0; i < ItemTemplate.MaxSocketCount; i++)
                {
                    packet.WriteInt(item.Sockets[i].SocketColor);
                    packet.WriteInt(item.Sockets[i].Unknown);
                }
                packet.WriteInt(item.SocketBonusId);
                packet.WriteInt(item.GemProperties);
                packet.WriteInt(item.ExtendedCost);
                packet.WriteInt(item.RequiredArenaRanking);
                packet.WriteInt(item.RequiredDisenchantingLevel);
                packet.WriteFloat(item.ArmorModifier);

                client.Send(packet);
            }
        }
Пример #16
0
 public override void WriteSpecialStats(RealmPacketOut packet)
 {
     packet.WriteInt(FlagCaptures);            // Flag caps
     packet.WriteInt(FlagReturns);             // Flag returns
 }
Пример #17
0
 public override void WriteSpecialStats(RealmPacketOut packet)
 {
     packet.WriteInt(BasesAssaulted);
     packet.WriteInt(BasesDefended);
 }
Пример #18
0
        public void TestParsedSegment()
        {
            PacketDefinition def = new PacketDefinition(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT, PacketSender.Client,
                                                        new PacketSegmentStructure(SimpleType.UInt, "SpellAttributes", typeof(SpellAttributes)),
                                                        new ListPacketSegmentStructure(SimpleType.Byte, "Members",
                                                                                       new PacketSegmentStructure(SimpleType.Guid, "MemberId"),
                                                                                       new PacketSegmentStructure(SimpleType.CString, "Name")
                                                                                       ),

                                                        new SwitchPacketSegmentStructure("Attribute Switch", "SpellAttributes",
                                                                                         new SwitchCase(ComparisonType.And, SpellAttributes.CannotBeCastInCombat,
                                                                                                        new PacketSegmentStructure(SimpleType.CString, "NoCombatString")
                                                                                                        ),
                                                                                         new SwitchCase(ComparisonType.And, SpellAttributes.CannotBeCastInCombat | SpellAttributes.CastableWhileMounted,
                                                                                                        new PacketSegmentStructure(SimpleType.CString, "NoCombatNoDismountString")
                                                                                                        )
                                                                                         ),

                                                        new SwitchPacketSegmentStructure("List Switch", "Members",
                                                                                         new SwitchCase(ComparisonType.Equal, (byte)0,
                                                                                                        new PacketSegmentStructure(SimpleType.Byte, "Status", "CharacterStatus"),
                                                                                                        new SwitchPacketSegmentStructure("Nested Switch", "Status",
                                                                                                                                         new SwitchCase(ComparisonType.AndNot, CharacterStatus.OFFLINE,
                                                                                                                                                        new PacketSegmentStructure(SimpleType.UInt, "NumX")
                                                                                                                                                        )
                                                                                                                                         )
                                                                                                        ),
                                                                                         new SwitchCase(ComparisonType.GreaterThan, (byte)0,
                                                                                                        new PacketSegmentStructure(SimpleType.CString, "Info")
                                                                                                        )
                                                                                         ),

                                                        new StaticListPacketSegmentStructure(1, "StaticList1",
                                                                                             new PacketSegmentStructure(SimpleType.Int, "Number1")
                                                                                             ),

                                                        new StaticListPacketSegmentStructure(2, "StaticList2",
                                                                                             new PacketSegmentStructure(SimpleType.Int, "Number2")
                                                                                             ),

                                                        new PacketSegmentStructure(SimpleType.Byte, "ListLength"),

                                                        new ListPacketSegmentStructure("SomeList3", "ListLength",
                                                                                       new PacketSegmentStructure(SimpleType.Int, "SomeListEle")
                                                                                       )
                                                        );

            def.Init();

            using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT))
            {
                packet.WriteUInt((uint)(SpellAttributes.CastableWhileMounted | SpellAttributes.CannotBeCastInCombat));
                packet.WriteByte(2);

                packet.Write(EntityId.Zero);
                packet.WriteCString("Member1Name");

                packet.Write(new EntityId(10));
                packet.WriteCString("Member2Name");

                packet.WriteCString("NoCombat");
                packet.WriteCString("NoCombatNoDismount");

                packet.WriteCString("lotsofinfo");

                // StaticList1
                packet.WriteInt(10);

                // StaticList2
                packet.WriteInt(20);
                packet.WriteInt(30);

                // SomeList3's length
                packet.WriteByte(2);
                // SomeList3
                packet.WriteInt(5);
                packet.WriteInt(7);


                var parsedPacket = PacketParser.Parse(packet, PacketSender.Client, def);

                Assert.AreEqual("NoCombat", parsedPacket["NoCombatString"].StringValue);
                Assert.AreEqual("NoCombatNoDismount", parsedPacket["NoCombatNoDismountString"].StringValue);

                var members = parsedPacket["Members"];
                Assert.AreEqual(EntityId.Zero, members[0]["MemberId"].EntityIdValue);
                Assert.AreEqual("Member1Name", members[0]["Name"].StringValue);
                Assert.AreEqual("Member2Name", members[1]["Name"].StringValue);
                Assert.AreEqual("lotsofinfo", parsedPacket["Info"].StringValue);
                CheckRemainder(parsedPacket);
            }

            using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT))
            {
                packet.WriteUInt((uint)SpellAttributes.None);
                packet.WriteByte(0);

                packet.Write((byte)CharacterStatus.ONLINE);
                packet.Write((uint)1234);

                packet.WriteInt(10);

                packet.WriteInt(20);
                packet.WriteInt(30);

                // SomeList3's length
                packet.WriteByte(2);
                // SomeList3
                packet.WriteInt(5);
                packet.WriteInt(7);


                var parsedPacket = PacketParser.Parse(packet, PacketSender.Client, def);

                Assert.IsNull(parsedPacket.GetByName("Info"));

                Assert.AreEqual(CharacterStatus.ONLINE, parsedPacket["Status"].Value);
                Assert.AreEqual((uint)1234, parsedPacket["NumX"].Value);

                CheckRemainder(parsedPacket);
            }
        }