public static void WriteAddonInfo(this IAuthHandler authHandler, IPacketReader inPacket, IPacketWriter outPacket, int size) { int count = 0x100; // arbitrary number if (Authenticator.ClientBuild >= 9464) { count = inPacket.ReadInt32(); // addon count } int i = 0; while (inPacket.Position < size && i < count) { string addonName = inPacket.ReadString(); bool enabled = inPacket.ReadBool(); uint filecrc = inPacket.ReadUInt32(); uint urlcrc = inPacket.ReadUInt32(); bool requireskey = filecrc != 0x1C776D01u && filecrc != 0x4C1C776Du; // offical crcs outPacket.WriteUInt8(2); // blizzard outPacket.WriteBool(true); // enabled outPacket.WriteBool(requireskey); if (requireskey) { outPacket.Write(AddonPublicKey); } outPacket.WriteUInt32(0); // use addon url file outPacket.WriteUInt8(0); // addon url filename, cstring i++; } outPacket.WriteUInt32(0); // banned addon count }
public override void WriteData(IPacketWriter writer) { if (Speaker.Flags.HasFlag(ConversationSpeakerFlags.NPCReplacedByNPC)) { writer.WriteInt(Speaker.TemplateID); } writer.WriteString(Text); writer.WriteBool(IsPrevEnabled); writer.WriteBool(IsNextEnabled); }
private void WriteTargetedMessages(OutgoingMessageRequest request) { var desconstructedMessage = request.Message.Split(' '); if (desconstructedMessage.Length < 3) { throw new InvalidCommandException(); } _packetWriter.WriteString(ReconstructMessage(desconstructedMessage)); _packetWriter.WriteBool(true); _packetWriter.WriteString(desconstructedMessage[1]); _packetWriter.WriteBool(request.Message.StartsWith("/m")); }
public static void WriteMobStats(this IPacketWriter writer, IMobStats mobStats) { var stats = mobStats.ToDictionary(); var now = DateTime.UtcNow; writer.WriteMobStatsFlag(mobStats); MobStatsOrder.WriteOrder.ForEach(t => { if (!stats.ContainsKey(t)) { return; } var stat = stats[t]; var remaining = stat.DateExpire.HasValue ? (stat.DateExpire.Value - now).TotalMilliseconds : short.MaxValue; writer.WriteShort((short)stat.Value); writer.WriteInt(stat.Reason); writer.WriteShort((short)remaining); }); if (stats.ContainsKey(MobStatType.Burned)) { writer.WriteInt(0); // Count writer.WriteInt(0); // CharacterID writer.WriteInt(0); // SkillID writer.WriteInt(0); // Damage writer.WriteInt(0); // Interval writer.WriteInt(0); // End writer.WriteInt(0); // DotCount } if (stats.ContainsKey(MobStatType.PCounter)) { writer.WriteInt(0); // ModValue? } if (stats.ContainsKey(MobStatType.MCounter)) { writer.WriteInt(0); // ModValue? } if (stats.ContainsKey(MobStatType.PCounter) || stats.ContainsKey(MobStatType.MCounter)) { writer.WriteInt(100); // CounterProb } if (stats.ContainsKey(MobStatType.Disable)) { writer.WriteBool(true); // Invincible writer.WriteBool(false); // Disable } }
private byte[] ConvertRequestToByteArray(OutgoingMessageRequest request) { var reponseRequest = new IncomingMessageRequest(request.Nickname, request.Message, request.Destination, request.PrivateMessage); _packetWriter.WriteByte(reponseRequest.PacketId); _packetWriter.WriteString(reponseRequest.Nickname); _packetWriter.WriteString(reponseRequest.Message); _packetWriter.WriteBool(reponseRequest.Destination != null); if (reponseRequest.Destination != null) { _packetWriter.WriteString(reponseRequest.Destination); _packetWriter.WriteBool(reponseRequest.PrivateMessage); } return(_packetWriter.GetBytes()); }
private byte[] ConvertRequestToByteArray(RegisterResultRequest request) { _packetWriter.WriteByte(request.PacketId); _packetWriter.WriteString(request.Nickname); _packetWriter.WriteBool(request.Registered); return(_packetWriter.GetBytes()); }
private static void WriteItemBase(this IPacketWriter p, AbstractItemSlot i) { p.WriteInt(i.TemplateID); p.WriteBool(i.CashItemSN.HasValue); if (i.CashItemSN.HasValue) { p.WriteLong(i.CashItemSN.Value); } p.WriteDateTime(i.DateExpire ?? GameConstants.Permanent); // TODO: constants }
public void WriteData(IPacketWriter writer) { writer.WriteInt(Info.ID); writer.WritePoint2D(Position); writer.WriteByte((byte)Action); writer.WriteShort((short)(Foothold?.ID ?? 0)); writer.WriteShort((short)RX0); writer.WriteShort((short)RX1); writer.WriteBool(true); // enabled }
public static void WriteCharacterLook(this IPacketWriter p, Character c) { p.WriteByte(c.Gender); p.WriteByte(c.Skin); p.WriteInt(c.Face); p.WriteBool(false); p.WriteInt(c.Hair); var inventory = c.Inventories[ItemInventoryType.Equip]; var equipped = inventory.Items .Where(kv => kv.Key < 0) .ToDictionary(); var stickers = equipped .Select(kv => equipped.ContainsKey((short)(kv.Key - 100)) ? new KeyValuePair<short, AbstractItemSlot>(kv.Key, equipped[(short)(kv.Key - 100)]) : kv) .ToDictionary(); var unseen = equipped .Except(stickers) .ToDictionary( kv => kv.Key <= -100 ? kv.Key - 100 : kv.Key, kv => kv.Value ); stickers.ForEach(kv => { p.WriteByte((byte)Math.Abs(kv.Key)); p.WriteInt(kv.Value.TemplateID); }); p.WriteByte(0xFF); unseen.ForEach(kv => { p.WriteByte((byte)Math.Abs(kv.Key)); p.WriteInt(kv.Value.TemplateID); }); p.WriteByte(0xFF); p.WriteInt(inventory.Items.ContainsKey(-111) ? inventory.Items[-111].TemplateID : 0); for (var i = 0; i < 3; i++) p.WriteInt(0); }
public static void WriteCharacterData(this IPacketWriter p, Character c, CharacterDataFlags flags = CharacterDataFlags.All) { p.WriteLong((long)flags); p.WriteByte(0); p.WriteByte(0); if (flags.HasFlag(CharacterDataFlags.Character)) { p.WriteCharacterStats(c); p.WriteByte(250); // nFriendMax p.WriteBool(false); } if (flags.HasFlag(CharacterDataFlags.Money)) p.WriteInt(c.Money); if (flags.HasFlag(CharacterDataFlags.InventorySize)) { if (flags.HasFlag(CharacterDataFlags.ItemSlotEquip)) p.WriteByte((byte)c.Inventories[ItemInventoryType.Equip].SlotMax); if (flags.HasFlag(CharacterDataFlags.ItemSlotConsume)) p.WriteByte((byte)c.Inventories[ItemInventoryType.Consume].SlotMax); if (flags.HasFlag(CharacterDataFlags.ItemSlotInstall)) p.WriteByte((byte)c.Inventories[ItemInventoryType.Install].SlotMax); if (flags.HasFlag(CharacterDataFlags.ItemSlotEtc)) p.WriteByte((byte)c.Inventories[ItemInventoryType.Etc].SlotMax); if (flags.HasFlag(CharacterDataFlags.ItemSlotCash)) p.WriteByte((byte)c.Inventories[ItemInventoryType.Cash].SlotMax); } if (flags.HasFlag(CharacterDataFlags.AdminShopCount)) { p.WriteInt(0); p.WriteInt(0); } if (flags.HasFlag(CharacterDataFlags.ItemSlotEquip)) { var inventory = c.Inventories[ItemInventoryType.Equip].Items; var equip = inventory.Where(kv => kv.Key >= 0); var equipped = inventory.Where(kv => kv.Key >= -100 && kv.Key < 0); var equipped2 = inventory.Where(kv => kv.Key >= -1000 && kv.Key < -100); var dragonEquipped = inventory.Where(kv => kv.Key >= -1100 && kv.Key < -1000); var mechanicEquipped = inventory.Where(kv => kv.Key >= -1200 && kv.Key < -1100); new List<IEnumerable<KeyValuePair<short, AbstractItemSlot>>> { equipped, equipped2, equip, dragonEquipped, mechanicEquipped } .ForEach(e => { e.ForEach(kv => { p.WriteShort((short)(Math.Abs(kv.Key) % 100)); p.WriteItemData(kv.Value); }); p.WriteShort(0); }); } new List<(CharacterDataFlags, ItemInventoryType)> { (CharacterDataFlags.ItemSlotConsume, ItemInventoryType.Consume), (CharacterDataFlags.ItemSlotInstall, ItemInventoryType.Install), (CharacterDataFlags.ItemSlotEtc, ItemInventoryType.Etc), (CharacterDataFlags.ItemSlotCash, ItemInventoryType.Cash) } .Where(t => flags.HasFlag(t.Item1)) .ForEach(t => { var inventory = c.Inventories[t.Item2].Items; inventory.ForEach(kv => { p.WriteByte((byte)kv.Key); p.WriteItemData(kv.Value); }); p.WriteByte(0); }); if (flags.HasFlag(CharacterDataFlags.SkillRecord)) { p.WriteShort((short)c.SkillRecord.Count); c.SkillRecord.ForEach(kv => { p.WriteInt(kv.Key); p.WriteInt(kv.Value.Level); p.WriteDateTime(kv.Value.DateExpire ?? GameConstants.Permanent); if (GameConstants.IsSkillNeedMasterLevel(kv.Key)) p.WriteInt(kv.Value.MasterLevel ?? 0); }); } if (flags.HasFlag(CharacterDataFlags.SkillCooltime)) { p.WriteShort(0); } if (flags.HasFlag(CharacterDataFlags.QuestRecord)) { p.WriteShort(0); } if (flags.HasFlag(CharacterDataFlags.QuestComplete)) { p.WriteShort(0); } if (flags.HasFlag(CharacterDataFlags.MinigameRecord)) { p.WriteShort(0); } if (flags.HasFlag(CharacterDataFlags.CoupleRecord)) { p.WriteShort(0); // Couple p.WriteShort(0); // Friend p.WriteShort(0); // Marriage } if (flags.HasFlag(CharacterDataFlags.MapTransfer)) { for (var i = 0; i < 5; i++) p.WriteInt(0); for (var i = 0; i < 10; i++) p.WriteInt(0); } if (flags.HasFlag(CharacterDataFlags.NewYearCard)) { p.WriteShort(0); } if (flags.HasFlag(CharacterDataFlags.QuestRecordEx)) { p.WriteShort(0); } if (flags.HasFlag(CharacterDataFlags.WildHunterInfo)) { if (c.Job / 100 == 33) { p.WriteByte(0); for (var i = 0; i < 5; i++) p.WriteInt(0); } } if (flags.HasFlag(CharacterDataFlags.QuestCompleteOld)) { p.WriteShort(0); } if (flags.HasFlag(CharacterDataFlags.VisitorLog)) { p.WriteShort(0); } }
protected override void WriteData(IPacketWriter writer) { writer.WriteBool(_stat); }