protected override Stream UnParse() { var s = new MemoryStream(); var bw = new BinaryWriter(s); bw.Write(this.version); if (this.commonA == null) { this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged); } this.commonA.UnParse(s); cstlRefsSize = 25; // default version 0x0E if (this.version == 0x0D) // has smaller array { cstlRefsSize = 21; } if (cstlRefs == null) // making new resource { cstlRefs = new TGIBlock[cstlRefsSize]; } if (cstlRefs.Length < cstlRefsSize) // may have changed the version and need larger array { TGIBlock[] newcstlRefs = new TGIBlock[cstlRefsSize]; for (int i = 0; i < cstlRefs.Length; i++) { newcstlRefs[i] = cstlRefs[i]; } cstlRefs = newcstlRefs; } for (int i = 0; i < cstlRefsSize; i++) // don't write out more than we need even if we have more { if (cstlRefs[i] == null) { cstlRefs[i] = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG); } cstlRefs[i].UnParse(s); } if (this.unkList1 == null) { this.unkList1 = new UnkCSTLUintList(this.OnResourceChanged); } this.unkList1.UnParse(s); bw.Write(this.unk01); bw.Write(this.unk02); bw.Write(this.unk03); bw.Write(this.unk04); bw.Write(this.unk05); bw.Write(this.unkIID01); return(s); }
void Parse(Stream s) { var br = new BinaryReader(s); this.version = br.ReadUInt32(); this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged, s); if (this.version == 0x0D) { cstlRefsSize = 21; } cstlRefs = new TGIBlock[cstlRefsSize]; for (int i = 0; i < cstlRefs.Length; i++) { cstlRefs[i] = new TGIBlock(requestedApiVersion, OnResourceChanged, TGIBlock.Order.ITG, s); } this.unkList1 = new UnkCSTLUintList(OnResourceChanged, s); this.unk01 = br.ReadUInt32(); this.unk02 = br.ReadUInt32(); this.unk03 = br.ReadUInt32(); this.unk04 = br.ReadUInt32(); this.unk05 = br.ReadByte(); this.unkIID01 = br.ReadUInt64(); }