public static TdfDoubleList Create(string Label, byte subtype1, byte subtype2, object list1, object list2, int count) { TdfDoubleList res = new TdfDoubleList(); res.Set(Label, 5); res.SubType1 = subtype1; res.SubType2 = subtype2; res.List1 = list1; res.List2 = list2; res.Count = count; return(res); }
public static TdfDoubleList ReadTdfDoubleList(Tdf head, Stream s) { TdfDoubleList res = new TdfDoubleList(); res.Label = head.Label; res.Tag = head.Tag; res.Type = head.Type; res.SubType1 = (byte)s.ReadByte(); res.SubType2 = (byte)s.ReadByte(); res.Count = (int)DecompressInteger(s); for (int i = 0; i < res.Count; i++) { switch (res.SubType1) { case 0: if (res.List1 == null) { res.List1 = new List <long>(); } List <long> l1 = (List <long>)res.List1; l1.Add(DecompressInteger(s)); res.List1 = l1; break; case 1: if (res.List1 == null) { res.List1 = new List <string>(); } List <string> l2 = (List <string>)res.List1; l2.Add(ReadString(s)); res.List1 = l2; break; case 3: if (res.List1 == null) { res.List1 = new List <TdfStruct>(); } List <TdfStruct> l3 = (List <TdfStruct>)res.List1; Blaze.TdfStruct tmp = new TdfStruct(); tmp.startswith2 = false; tmp.Values = ReadStruct(s, out tmp.startswith2); l3.Add(tmp); res.List1 = l3; break; case 0xA: if (res.List1 == null) { res.List1 = new List <float>(); } List <float> lf3 = (List <float>)res.List1; lf3.Add(ReadFloat(s)); res.List1 = lf3; break; default: throw new Exception("Unknown Tdf Type in Double List: " + res.SubType1); } switch (res.SubType2) { case 0: if (res.List2 == null) { res.List2 = new List <long>(); } List <long> l1 = (List <long>)res.List2; l1.Add(DecompressInteger(s)); res.List2 = l1; break; case 1: if (res.List2 == null) { res.List2 = new List <string>(); } List <string> l2 = (List <string>)res.List2; l2.Add(ReadString(s)); res.List2 = l2; break; case 3: if (res.List2 == null) { res.List2 = new List <TdfStruct>(); } List <TdfStruct> l3 = (List <TdfStruct>)res.List2; Blaze.TdfStruct tmp = new TdfStruct(); tmp.startswith2 = false; tmp.Values = ReadStruct(s, out tmp.startswith2); l3.Add(tmp); res.List2 = l3; break; case 0xA: if (res.List2 == null) { res.List2 = new List <float>(); } List <float> lf3 = (List <float>)res.List2; lf3.Add(ReadFloat(s)); res.List2 = lf3; break; default: throw new Exception("Unknown Tdf Type in Double List: " + res.SubType2); } } return(res); }
public static void WriteTdfDoubleList(TdfDoubleList tdf, Stream s) { s.WriteByte(tdf.SubType1); s.WriteByte(tdf.SubType2); CompressInteger(tdf.Count, s); for (int i = 0; i < tdf.Count; i++) { switch (tdf.SubType1) { case 0: CompressInteger(((List <long>)(tdf.List1))[i], s); break; case 1: WriteString(((List <string>)(tdf.List1))[i], s); break; case 3: Blaze.TdfStruct str = ((List <Blaze.TdfStruct>)tdf.List1)[i]; if (str.startswith2) { s.WriteByte(2); } foreach (Tdf ttdf in str.Values) { WriteTdf(ttdf, s); } s.WriteByte(0); break; case 0xA: WriteFloat(s, ((List <float>)(tdf.List1))[i]); break; } switch (tdf.SubType2) { case 0: CompressInteger(((List <long>)(tdf.List2))[i], s); break; case 1: WriteString(((List <string>)(tdf.List2))[i], s); break; case 3: Blaze.TdfStruct str = ((List <Blaze.TdfStruct>)tdf.List2)[i]; if (str.startswith2) { s.WriteByte(2); } foreach (Tdf ttdf in str.Values) { WriteTdf(ttdf, s); } s.WriteByte(0); break; case 0xA: WriteFloat(s, ((List <float>)(tdf.List2))[i]); break; } } }