public override bool Serialize(ref PacketOutStream Data) { if (val is Dictionary <long, ISerializablePacket> ) { Dictionary <long, ISerializablePacket> Dic = val as Dictionary <long, ISerializablePacket>; int KeyType = (int)EPacketFieldType.Unsigned7BitEncoded; int ValueType = (int)EPacketFieldType.Packet; int Count = Dic.Count; if (Count <= 0) { return(false); } long DicData; PacketOutStream.Encode3Parameters(out DicData, KeyType, ValueType, Count); Data.WriteEncoded7Bit(DicData); foreach (KeyValuePair <long, ISerializablePacket> KP in Dic) { PacketProcessor.WriteField(ref Data, (EPacketFieldType)KeyType, KP.Key); PacketProcessor.WriteField(ref Data, (EPacketFieldType)ValueType, KP.Value); } return(true); } return(false); }
public override bool Serialize(ref PacketOutStream Data) { if (val is Dictionary<long, ISerializablePacket>) { Dictionary<long, ISerializablePacket> Dic = val as Dictionary<long, ISerializablePacket>; int KeyType = (int)EPacketFieldType.Unsigned7BitEncoded; int ValueType = (int)EPacketFieldType.Packet; int Count = Dic.Count; if (Count <= 0) return false; long DicData; PacketOutStream.Encode3Parameters(out DicData, KeyType, ValueType, Count); Data.WriteEncoded7Bit(DicData); foreach (KeyValuePair<long, ISerializablePacket> KP in Dic) { PacketProcessor.WriteField(ref Data, (EPacketFieldType)KeyType, KP.Key); PacketProcessor.WriteField(ref Data, (EPacketFieldType)ValueType, KP.Value); } return true; } return false; }
public override bool Serialize(ref PacketOutStream Data) { if (val is UInt32) { Data.WriteUInt32R((UInt32)val); } else if (val is Int32) { Data.WriteInt32R((Int32)val); } else if (val is float) { Data.WriteFloat((float)val); } else if (val is byte[]) { Data.Write((byte[])val); } else { return(false); } return(true); }
public static PacketOutStream WritePacket(ISerializablePacket Packet) { PacketOutStream Stream = new PacketOutStream(); WritePacket(ref Stream, Packet, true, true, true); return(Stream); }
public static bool WriteField(ref PacketOutStream Stream, ISerializableField Field) { if (Field == null) { return(false); } return(WriteField(ref Stream, Field, Field.Index, (int)Field.PacketType)); }
public void SendTCPWithSize(byte[] ToSend) { PacketOutStream St = new PacketOutStream(); St.WriteEncoded7Bit(ToSend.Length); St.Write(ToSend); SendTCP(St.ToArray()); }
public override void OnRead(RiftClient From) { if (CharacterMgr.Instance.GetCharactersCount(From.Acct.Id, From.Realm.RealmId) >= 6) { Log.Error("CharacterCreate", "Hack From : " + From.GetIp); From.Disconnect(); return; } LobbyCharacterCreateResponse Rp = new LobbyCharacterCreateResponse(); Character Exist = CharacterMgr.CharacterDB.SelectObject<Character>("Name='" + CharacterMgr.CharacterDB.Escape(Name) + "' AND RealmID=" + From.Realm.RealmId); if (Exist != null) { Rp.AddField(0, EPacketFieldType.Unsigned7BitEncoded, (long)6); } else { Rp.AddField(0, EPacketFieldType.Unsigned7BitEncoded, (long)0); PacketOutStream Stream = new PacketOutStream(); PacketProcessor.WritePacket(ref Stream, Custom, false, true, true); CustomData = Stream.ToArray(); string Data = UTF8ByteArrayToString(CustomData); Character Char = new Character(); Char.Name = Name; Char.AccountId = From.Acct.Id; Char.RealmId = From.Realm.RealmId; Char.Race = Field1; Char.Sex = Field2; Char.Class = Field13; Char.HairModelID = HairID; Char.Level = 1; Char.Data = Data; CharacterMgr.Instance.AddObject(Char); Character CharEntry = CharacterMgr.Instance.GetCharacter(CharacterMgr.CharacterDB.Escape(Name)); Character_StartItems[] StartItems = CharacterMgr.Instance.GetStartItems(Field1, Field2, Field13); foreach (Character_StartItems Item in StartItems) { Character_Item It = new Character_Item(); It.ItemID = Item.ItemID; It.Bag = 0; It.Equiped = 1; It.GUID = CharEntry.Id; CharacterMgr.Instance.AddObject(It); } } From.SendSerialized(Rp); }
public override bool Serialize(ref PacketOutStream Data) { if (val is byte[]) Data.Write((byte[])val); else if (val is long) Data.WriteInt64R((long)val); else if (val is UInt64) Data.WriteUInt64R((UInt64)val); else return false; return true; }
public static bool WriteField(ref PacketOutStream Stream, EPacketFieldType FieldType, object Value) { ISerializableField Field = GetFieldType(FieldType); Log.Success("WriteField", "Type=" + FieldType + ",Val=" + Value + ",Field=" + Field); if (Field != null) { Field.val = Value; Field.Serialize(ref Stream); return(true); } return(false); }
public void SendSerialized(ISerializablePacket Packet) { PacketOutStream Out = PacketProcessor.WritePacket(Packet); byte[] ToSend = Out.ToArray(); SendTCP(ToSend); List <Cache_Info> Entries = CacheMgr.Instance.GetBinCache(Packet.Opcode, false); foreach (Cache_Info Entry in Entries) { SendCache(Entry.Type, (uint)Entry.CacheId); } }
public override bool Serialize(ref PacketOutStream Data) { if (val is UInt32) Data.WriteUInt32R((UInt32)val); else if (val is Int32) Data.WriteInt32R((Int32)val); else if (val is float) Data.WriteFloat((float)val); else if (val is byte[]) Data.Write((byte[])val); else return false; return true; }
public static bool WriteField(ref PacketOutStream Stream, ISerializableField Field, int FieldIndex, int FieldType) { if (FieldType == (int)EPacketFieldType.Invalid) { return(false); } PacketOutStream NewStream = new PacketOutStream(); long FieldResult; PacketOutStream.Encode2Parameters(out FieldResult, FieldType, FieldIndex); NewStream.WriteEncoded7Bit(FieldResult); if (Field == null || Field.Serialize(ref NewStream)) { Stream.Write(NewStream.ToArray()); } return(true); }
public override bool Serialize(ref PacketOutStream Data) { if (val is byte[]) { Data.Write((byte[])val); } else if (val is long) { Data.WriteInt64R((long)val); } else if (val is UInt64) { Data.WriteUInt64R((UInt64)val); } else { return(false); } return(true); }
public override bool Serialize(ref PacketOutStream Data) { byte[] Result = new byte[0]; if (val is string) { Result = UTF8Encoding.UTF8.GetBytes((val as string)); } else if (val is byte[]) { Result = (val as byte[]); } if (Result == null || Result.Length <= 0) return false; Data.WriteEncoded7Bit(Result.Length); Data.Write(Result); return true; }
public override bool Serialize(ref PacketOutStream Data) { byte[] Result = new byte[0]; if (val is string) { Result = UTF8Encoding.UTF8.GetBytes((val as string)); } else if (val is byte[]) { Result = (val as byte[]); } if (Result == null || Result.Length <= 0) { return(false); } Data.WriteEncoded7Bit(Result.Length); Data.Write(Result); return(true); }
public static bool WritePacket(ref PacketOutStream Stream, ISerializablePacket Packet, bool WithSize = true, bool WithTerminator = true, bool WithOpcode = true) { if (Packet == null) { Log.Error("WritePacket", "Packet == null"); return(false); } Packet.ConvertToField(); PacketOutStream Data = new PacketOutStream(); if (WithOpcode) { Data.WriteEncoded7Bit(Packet.Opcode); } foreach (ISerializableField Field in Packet.GetFields().Values) { WriteField(ref Data, Field); } if (WithTerminator && Packet.Opcode != (int)Opcodes.ProtocolHandshakeCompression) { WriteField(ref Data, null, 0, (int)EPacketFieldType.Terminator); } if (WithSize) { Stream.WriteEncoded7Bit(Data.Length); } Stream.Write(Data.ToArray()); return(true); }
public override bool Serialize(ref PacketOutStream Data) { Data.WriteEncoded7Bit((long)val); return(true); }
public static bool WriteField(ref PacketOutStream Stream, EPacketFieldType FieldType, object Value) { ISerializableField Field = GetFieldType(FieldType); Log.Success("WriteField", "Type=" + FieldType + ",Val=" + Value + ",Field="+Field); if (Field != null) { Field.val = Value; Field.Serialize(ref Stream); return true; } return false; }
public static bool WritePacket(ref PacketOutStream Stream,ISerializablePacket Packet, bool WithSize = true , bool WithTerminator = true, bool WithOpcode = true) { if (Packet == null) { Log.Error("WritePacket", "Packet == null"); return false; } Packet.ConvertToField(); PacketOutStream Data = new PacketOutStream(); if (WithOpcode) Data.WriteEncoded7Bit(Packet.Opcode); foreach (ISerializableField Field in Packet.GetFields().Values) WriteField(ref Data, Field); if (WithTerminator && Packet.Opcode != (int)Opcodes.ProtocolHandshakeCompression) WriteField(ref Data, null, 0, (int)EPacketFieldType.Terminator); if (WithSize) Stream.WriteEncoded7Bit(Data.Length); Stream.Write(Data.ToArray()); return true; }
public static PacketOutStream WritePacket(ISerializablePacket Packet) { PacketOutStream Stream = new PacketOutStream(); WritePacket(ref Stream, Packet,true,true,true); return Stream; }
public abstract bool Serialize(ref PacketOutStream Data);
public abstract bool Serialize(ref PacketOutStream Data);
public override bool Serialize(ref PacketOutStream Data) { return(true); }
public override bool Serialize(ref PacketOutStream Data) { return true; }
public void SendTCPWithSize(byte[] ToSend) { PacketOutStream St = new PacketOutStream(); St.WriteEncoded7Bit(ToSend.Length); St.Write(ToSend); SendTCP(St.ToArray()); }
public override bool Serialize(ref PacketOutStream Data) { return(PacketProcessor.WritePacket(ref Data, (ISerializablePacket)val, false, true, true)); }
public static bool WriteField(ref PacketOutStream Stream, ISerializableField Field, int FieldIndex, int FieldType) { if (FieldType == (int)EPacketFieldType.Invalid) return false; PacketOutStream NewStream = new PacketOutStream(); long FieldResult; PacketOutStream.Encode2Parameters(out FieldResult, FieldType, FieldIndex); NewStream.WriteEncoded7Bit(FieldResult); if(Field == null || Field.Serialize(ref NewStream)) Stream.Write(NewStream.ToArray()); return true; }
public override bool Serialize(ref PacketOutStream Data) { Data.WriteEncoded7Bit((long)val); return true; }
public override bool Serialize(ref PacketOutStream Data) { return PacketProcessor.WritePacket(ref Data, (ISerializablePacket)val, false, true, true); }
public override bool Serialize(ref PacketOutStream Data) { Log.Success("WriteList", "Serialize : " + val); if (val is List<ISerializablePacket>) { List<ISerializablePacket> Packets = val as List<ISerializablePacket>; /*if (Packets.Count <= 0) return false;*/ long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)EPacketFieldType.Packet, Packets.Count); Data.WriteEncoded7Bit(ListData); foreach (ISerializablePacket Packet in Packets) PacketProcessor.WritePacket(ref Data, Packet, false, true, true); } else if (val is List<long>) { List<long> Values = val as List<long>; /*if (Values.Count <= 0) return false;*/ long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)EPacketFieldType.Unsigned7BitEncoded, Values.Count); Data.WriteEncoded7Bit(ListData); for (int i = 0; i < Values.Count; ++i) PacketProcessor.WriteField(ref Data, EPacketFieldType.Unsigned7BitEncoded, (long)Values[i]); } else if (val is List<uint>) { List<uint> Values = val as List<uint>; /*if (Values.Count <= 0) return false;*/ long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)EPacketFieldType.Raw4Bytes, Values.Count); Data.WriteEncoded7Bit(ListData); for (int i = 0; i < Values.Count; ++i) PacketProcessor.WriteField(ref Data, EPacketFieldType.Raw4Bytes, (uint)Values[i]); } else if (val is List<float>) { List<float> Values = val as List<float>; /*if (Values.Count <= 0) return false;*/ long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)EPacketFieldType.Raw4Bytes, Values.Count); Data.WriteEncoded7Bit(ListData); for (int i = 0; i < Values.Count; ++i) PacketProcessor.WriteField(ref Data, EPacketFieldType.Raw4Bytes, Values[i]); } else if (val is List<string>) { List<string> Strs = val as List<string>; /*if (Strs.Count <= 0) return false;*/ long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)EPacketFieldType.ByteArray, Strs.Count); Data.WriteEncoded7Bit(ListData); for (int i = 0; i < Strs.Count; ++i) PacketProcessor.WriteField(ref Data, EPacketFieldType.ByteArray, (string)Strs[i]); return true; } else if (val is List<ISerializableField>) { List<ISerializableField> Strs = val as List<ISerializableField>; if (Strs.Count <= 0) return false; ISerializableField Field = Strs[0]; long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)Field.PacketType, Strs.Count); Data.WriteEncoded7Bit(ListData); for (int i = 0; i < Strs.Count; ++i) PacketProcessor.WriteField(ref Data, Strs[i].PacketType, Strs[i].val); return true; } else return false; return true; }
public override bool Serialize(ref PacketOutStream Data) { Log.Success("WriteList", "Serialize : " + val); if (val is List <ISerializablePacket> ) { List <ISerializablePacket> Packets = val as List <ISerializablePacket>; /*if (Packets.Count <= 0) * return false;*/ long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)EPacketFieldType.Packet, Packets.Count); Data.WriteEncoded7Bit(ListData); foreach (ISerializablePacket Packet in Packets) { PacketProcessor.WritePacket(ref Data, Packet, false, true, true); } } else if (val is List <long> ) { List <long> Values = val as List <long>; /*if (Values.Count <= 0) * return false;*/ long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)EPacketFieldType.Unsigned7BitEncoded, Values.Count); Data.WriteEncoded7Bit(ListData); for (int i = 0; i < Values.Count; ++i) { PacketProcessor.WriteField(ref Data, EPacketFieldType.Unsigned7BitEncoded, (long)Values[i]); } } else if (val is List <uint> ) { List <uint> Values = val as List <uint>; /*if (Values.Count <= 0) * return false;*/ long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)EPacketFieldType.Raw4Bytes, Values.Count); Data.WriteEncoded7Bit(ListData); for (int i = 0; i < Values.Count; ++i) { PacketProcessor.WriteField(ref Data, EPacketFieldType.Raw4Bytes, (uint)Values[i]); } } else if (val is List <float> ) { List <float> Values = val as List <float>; /*if (Values.Count <= 0) * return false;*/ long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)EPacketFieldType.Raw4Bytes, Values.Count); Data.WriteEncoded7Bit(ListData); for (int i = 0; i < Values.Count; ++i) { PacketProcessor.WriteField(ref Data, EPacketFieldType.Raw4Bytes, Values[i]); } } else if (val is List <string> ) { List <string> Strs = val as List <string>; /*if (Strs.Count <= 0) * return false;*/ long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)EPacketFieldType.ByteArray, Strs.Count); Data.WriteEncoded7Bit(ListData); for (int i = 0; i < Strs.Count; ++i) { PacketProcessor.WriteField(ref Data, EPacketFieldType.ByteArray, (string)Strs[i]); } return(true); } else if (val is List <ISerializableField> ) { List <ISerializableField> Strs = val as List <ISerializableField>; if (Strs.Count <= 0) { return(false); } ISerializableField Field = Strs[0]; long ListData; PacketOutStream.Encode2Parameters(out ListData, (int)Field.PacketType, Strs.Count); Data.WriteEncoded7Bit(ListData); for (int i = 0; i < Strs.Count; ++i) { PacketProcessor.WriteField(ref Data, Strs[i].PacketType, Strs[i].val); } return(true); } else { return(false); } return(true); }
public static bool WriteField(ref PacketOutStream Stream, ISerializableField Field) { if (Field == null) return false; return WriteField(ref Stream, Field, Field.Index, (int)Field.PacketType); }