internal static void WriteLoginRequest(IPacketWriter Writer, string username, string password) { if (username.Contains('\t') || password.Contains('\t')) throw new ArgumentException("Username or password contains invalid character"); string textdata = string.Format("{0}\t{1}", username, password); byte[] data = Encoding.ASCII.GetBytes(textdata); using (var buffer = new FeenPacketBuffer(PacketID.LoginRequest, data)) { if (Writer != null) Writer.Write(buffer); } }
internal static void WriteAudioData(IPacketWriter Writer, Guid userID, Audio.Codecs.CodecID Codec, byte[] AudioData, int AudioDataLen) { using (var buffer = FeenPacketBuffer.Acquire()) { buffer.Write(PacketID.Audio); buffer.WriteLength(AudioDataLen + (userID == Guid.Empty ? 1 : 17) + 1); if (userID == Guid.Empty) buffer.Write(false); else { buffer.Write(true); buffer.Write(userID.ToByteArray()); } buffer.Write(Codec); buffer.Write(AudioData, AudioDataLen); if (Writer != null) Writer.Write(buffer); } }
internal static void WriteChat(IPacketWriter Writer, IUser user, string text) { byte[] dataText = Encoding.ASCII.GetBytes(text); using (var buffer = FeenPacketBuffer.Acquire()) { byte[] dataUser = UserData(user); var len = dataUser.Length + dataText.Length; buffer.Write(PacketID.Chat); buffer.WriteLength(len); buffer.Write(dataUser); buffer.Write(dataText); if (Writer != null) Writer.Write(buffer); } }
public void Write(IPacketWriter writer) { writer.WriteVarInt(Position.X); writer.WriteVarInt(Position.Z); const int last18Bits = 0b0000_0000_0000_0011_1111_1111_1111_1111; int skylightZeroMask = CalculateZeroMask(Chunk.Skylight.Span, Chunk) & last18Bits; int blocklightZeroMask = CalculateZeroMask(Chunk.Blocklight.Span, Chunk) & last18Bits; // note, we always send all light values. In theory, it is allowed to only update specific sections using this mask // meaning the zero mask is not necessarily the inverse of the main mask var skylightWriteMask = ~skylightZeroMask & last18Bits; writer.WriteVarInt(skylightWriteMask); var blocklightWriteMask = ~blocklightZeroMask & last18Bits; writer.WriteVarInt(blocklightWriteMask); writer.WriteVarInt(skylightZeroMask); writer.WriteVarInt(blocklightZeroMask); WriteSections(Chunk.Skylight.Span, skylightWriteMask, writer); WriteSections(Chunk.Blocklight.Span, blocklightWriteMask, writer); }
public static Task <Packet> GetDrillResultAsync(this IPacketWriter writer) { return(writer.SendCommandAsync("62007", "3", "101")); }
public PacketClientNotificationHandler(IFeenPhonePacketNetState state) { this.State = state; this.Writer = state.Writer; }
public override void WriteData(IPacketWriter writer) { writer.WriteString(Text); }
public void WriteLoginStream(IPacketWriter writer) { Debug.LogWarning("TODO investigate loginstream for shiftableAppearance"); }
/// <summary> /// Hạ cấp hàng loạt. /// </summary> /// <param name="equipmentId">ID của trang bị.</param> public static async Task <Packet> DegradeEquipmentAllAsync(this IPacketWriter writer, int equipmentId) { return(await writer.SendCommandAsync(39402, equipmentId.ToString())); }
internal static void WritePingReq(IPacketWriter Writer) { var timestamp = (int)Timekeeper.Elapsed.TotalMilliseconds; using (var buffer = new FeenPacketBuffer(PacketID.PingReq, new byte[] { (byte)(timestamp >> 8), (byte)(timestamp) })) { if (Writer != null) Writer.Write(buffer); } }
public static async Task <Packet> RefreshCollectAsync(this IPacketWriter writer) { return(await writer.SendCommandAsync("30100")); }
internal static void WriteUserLogout(IPacketWriter Writer, IUser user) { using (var buffer = new FeenPacketBuffer(PacketID.UserLogout, UserData(user))) { if (Writer != null) Writer.Write(buffer); } }
internal static void WriteUserList(IPacketWriter Writer, IEnumerable<IUser> users) { if (users.Count() > byte.MaxValue) throw new ArgumentException("Too many users, max is " + byte.MaxValue); List<byte[]> usersDatas = new List<byte[]>(); foreach (var user in users) usersDatas.Add(UserData(user)); using (var buffer = FeenPacketBuffer.Acquire()) { buffer.Write(PacketID.UserList); buffer.WriteLength(usersDatas.Sum(m => m.Length) + 1); buffer.Write((byte)usersDatas.Count()); buffer.Write(usersDatas.SelectMany(m => m).ToArray()); if (Writer != null) Writer.Write(buffer); } }
internal static void WritePingResp(IPacketWriter Writer, ushort timestamp) { using (var buffer = new FeenPacketBuffer(PacketID.PingResp, new byte[] { (byte)(timestamp >> 8), (byte)(timestamp) })) { if (Writer != null) Writer.Write(buffer); } }
public static Task <Packet> DrillAsync(this IPacketWriter writer) { return(writer.SendCommandAsync("62006", "3", "101", "0", "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); } }
internal static void WriteLoginStatus(IPacketWriter Writer, bool isLoggedIn, string message = null) { byte[] dataText = message == null || message.Length == 0 ? null : Encoding.ASCII.GetBytes(message); int dataTextLen = dataText == null ? 0 : dataText.Length; using (var buffer = FeenPacketBuffer.Acquire()) { buffer.Write(PacketID.LoginStatus); buffer.WriteLength(3 + dataTextLen); buffer.Write(isLoggedIn); buffer.Write((ushort)FeenPhone.Accounting.AccountHandler.Instance.Version); if (dataText != null) buffer.Write(dataText); if (Writer != null) Writer.Write(buffer); } }
/// <summary> /// Collect. /// </summary> public static async Task <Packet> Collect(this IPacketWriter writer, int value) { return(await writer.SendCommandAsync("30401", value + "")); }
public abstract void WriteAddStream(IPacketWriter writer);
/// <summary> /// Hạ cấp trang bị (ma lực không ảnh hưởng). /// </summary> /// <param name="writer"></param> /// <param name="equipmentId">ID của trang bị.</param> public static async Task <Packet> DegradeEquipmentAsync(this IPacketWriter writer, int equipmentId) { return(await writer.DegradeEquipmentAsync(equipmentId, 0)); }
public void WriteToPacket(IPacketWriter writer) { writer.WriteByte((byte)_history.Count); _history.ForEach(o => writer.Write(o)); }
public virtual void WriteAddStream(IPacketWriter writer) { throw new NotImplementedException(); //only playerAppearance should implement this }
protected override void WriteData(IPacketWriter writer) { writer.WriteBool(_stat); }
public void WriteAddStream(IPacketWriter writer) { writer.WriteInt32(mShiftedNPCTypeID); }
public static async Task <Packet> SetDefaultFormationAsync(this IPacketWriter writer, int formationId) { return(await writer.SendCommandAsync("42104", formationId.ToString())); }
public static async Task <Packet> SendCommandAsync(this IPacketWriter writer, string commandId, params string[] parameters) { return(await writer.SendCommandAsync(Int32.Parse(commandId), parameters)); }
public static async Task <Packet> RemoveAllHeroesFromFormationAsync(this IPacketWriter writer, int formationId) { return(await writer.SendCommandAsync("42107", formationId.ToString())); }
public void Send(IPacketWriter packet) { Socket.SendData(packet, packet.Name); }
public void WriteLoginStream(IPacketWriter writer) { writer.WriteInt32(GetRelevanceID()); writer.WriteFloat(Time.realtimeSinceStartup); writer.WriteByte((byte)mNetState); }
public static Task <Packet> RefreshOutsideAsync(this IPacketWriter writer, long playerId) { return(writer.SendCommandAsync("62002", playerId.ToString())); }
public override void WriteAddStream(IPacketWriter writer) { writer.WriteInt32(GetRelevanceID()); writer.WriteInt32(((Rotator)transform.rotation).Yaw); }
public override void WriteAddStream(IPacketWriter writer) { throw new NotImplementedException(); }
public abstract void Encode(IPacketWriter packetWriter);
public void SetPacketWriter(IPacketWriter writer) { packetWriter = writer; }
/// <summary> /// Giữ cải tiến. /// </summary> /// <param name="heroId">ID của tướng</param> public static async Task <Packet> KeepStatsAsync(this IPacketWriter writer, int heroId) { return(await writer.SendCommandAsync(41303, heroId.ToString(), "0")); }
/// <summary> /// Chuyen bang chu. /// </summary> /// public static async Task <Packet> Swap(this IPacketWriter writer, long slot1Id) { return(await writer.SendCommandAsync("32108", slot1Id + "")); }
/// <summary> /// Cải tiến. /// </summary> /// <param name="heroId">ID của tướng.</param> public static async Task <Packet> ImproveHeroAsync(this IPacketWriter writer, int heroId) { return(await writer.SendCommandAsync(41301, heroId.ToString(), "0")); }
/// <summary> /// Tìm bang chu. /// </summary> public static async Task <Packet> RefreshLegionAsync(this IPacketWriter writer) { return(await writer.SendCommandAsync("32101", "0", "12", " ")); }
/// <summary> /// Hạ cấp trang bị. /// </summary> /// <param name="equipmentId">ID của trang bị.</param> /// <param name="magic">Ma lực hiện tại</param> public static async Task <Packet> DegradeEquipmentAsync(this IPacketWriter writer, int equipmentId, int magic) { return(await writer.SendCommandAsync(39103, equipmentId.ToString(), "0", magic.ToString())); }