/// <summary> /// Override to deserialize the object from the GFF file's binary data. /// </summary> /// <param name="rawField">The raw field from the GFF</param> /// <param name="rawData">The GFF's raw file data</param> void IGffFieldSerialize.Deserialize(RawGffData.RawGffField rawField, RawGffData rawData) { // Save the structure type. RawGffData.RawGffStruct rawStruct = rawData.GetStruct(rawField.DataOrDataOffset); structureType = rawStruct.Type; // Fill in the field dictionary and assign it to our value. Value = GetFieldStruct(rawStruct, rawData); }
/// <summary> /// Loads the GFF file from the specified stream. /// </summary> /// <param name="stream">The stream to load the GFF file from.s</param> private void LoadStream(Stream stream) { // Read the header. NWNLogger.Log(0, "Gff.LoadStream loading header"); GffHeader header = new GffHeader(stream); NWNLogger.Log(1, "Gff.LoadStream version {0}", header.VersionText); if ("V3.2" != header.VersionText) throw new NWNException("Version {0} GFF files are unsupported", header.VersionText); NWNLogger.Log(0, "Gff.LoadStream reading raw GFF data"); RawGffData rawData = new RawGffData(stream, header); topLevel = GffStructField.GetFieldStruct(rawData.GetStruct(0), rawData); }
/// <summary> /// Override to deserialize the object from the GFF file's binary data. /// </summary> /// <param name="rawField">The raw field from the GFF</param> /// <param name="rawData">The GFF's raw file data</param> void IGffFieldSerialize.Deserialize(RawGffData.RawGffField rawField, RawGffData rawData) { // Get the list of structure indeces for the items in the list uint[] indeces = rawData.GetListIndeces(rawField.DataOrDataOffset); // Create a field collection for the structures, and loop through // the index array. GffFieldCollection fields = new GffFieldCollection(); for (int i = 0; i < indeces.Length; i++) { // Get the raw structure data for this structure. RawGffData.RawGffStruct rawStruct = rawData.GetStruct(indeces[i]); // Create a GffStructField object for the structure and set it's // structure type. GffStructField field = (GffStructField) GffFieldFactory.CreateField(GffFieldType.Struct); field.StructureType = rawStruct.Type; // Create a dummy field object so we can deserialize the structure, // set it's DataOrDataOffset to the structure index. RawGffData.RawGffField dummyField = new RawGffData.RawGffField(GffFieldType.Struct); dummyField.LabelIndex = 0; dummyField.DataOrDataOffset = indeces[i]; // Deserialize the structure. ((IGffFieldSerialize) field).Deserialize(dummyField, rawData); // Add the structure to the collection. fields.Add(field); } Value = fields; }