public void AddField(int Index, ISerializableField Field) { if (!Fields.ContainsKey(Index)) Fields.Add(Index, Field); else { //Log.Error("ISerializablePacket", "Duplicate Field Index : " + GetType().Name); Fields.Remove(Index); AddField(Index, Field); } }
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 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,false)) Stream.Write(NewStream.ToArray()); return true; }
public static EPacketFieldType GetFieldType(ISerializableField Field) { if (Field is BoolBitField) { if (Field.val.ToString() == "0") return EPacketFieldType.False; else return EPacketFieldType.True; } foreach (KeyValuePair<EPacketFieldType, ISerializableField> F in FieldsTypes) if (F.Value.GetType() == Field.GetType() ) return F.Key; Log.Error("PacketProcessor", "Unhandled Field : " + Field); return EPacketFieldType.Invalid; }