private uint GetFieldDataOrOffset(GffField f) { if (GffComponent.IsSimple(f.Type)) { var lB = f.Bytes; if (lB.Length < 4) { Array.Resize(ref lB, 4); } return(BitConverter.ToUInt32(lB, 0)); } var br = new LatinBinaryWriter(_gb.FieldDataBlock); var pos = _gb.FieldDataBlock.Position; switch (f.Type) { case GffType.ResRef: br.Write((byte)f.Bytes.Length); break; case GffType.CExoString: case GffType.CExoLocString: case GffType.Void: br.Write((uint)f.Bytes.Length); break; } br.Write(f.Bytes); return((uint)pos); }
private uint GetListDataOrOffset(ICollection <GffComponent> lst) { var br = new LatinBinaryWriter(_gb.ListIndicesArray); var pos = _gb.ListIndicesArray.Position; br.Write((uint)lst.Count); foreach (var cpnt in lst) { if (cpnt is GffInListStruct) { br.Write(_gb.StructArray.IndexOf(DsaS[cpnt as GffInListStruct])); } else { throw new CompositeException(ErrorLabels.AddWrongStructureClassToList); } } return((uint)pos); }
private uint GetStructDataOrOffset(IList <GffComponent> vs) { switch (vs.Count) { case 0: return(uint.MaxValue); case 1: return((uint)_gb.FieldArray.IndexOf(DfaF[vs[0]])); default: { var br = new LatinBinaryWriter(_gb.FieldIndicesArray); var pos = _gb.FieldIndicesArray.Position; foreach (var cpnt in vs) { br.Write(_gb.FieldArray.IndexOf(DfaF[cpnt])); } return((uint)pos); } } }
private void WriteListIndices() { _gb.Header.ListIndicesOffset = (uint)_bw.BaseStream.Position; _gb.Header.ListIndicesCount = (uint)_gb.ListIndicesArray.Length; _bw.Write(_gb.ListIndicesArray.ToArray()); }