![]() |
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
3. File Format Physical Layout This section describes what the actual bytes are in a GFF file, where they are, and what they do. The file format descriptions in this section use the following terminology:
Note that GFF byte order is little endian, which is the format used by Intel processors. If an integer value is more than 1 byte long, then the least significant byte is the first one, and the most significant byte is the last one. For example, the number 258 (0x0102 in hex) expressed as a 4-byte integer would be stored as the following sequence of bytes within the file: 0x02, 0x01, 0x00, 0x00. 3.1. Overall File LayoutA GFF file contains 7 distinct sections--1 fixed-size header, 5 arrays of fixed-size elements, and 1 block of raw data. The offset to each section is stored in the header, as is the number of elements in each array. Figure 3.1: GFF File Structure
3.2. HeaderThe GFF header contains a number of values, all of them DWORDs (32-bit unsigned integers). The header contains offset information for all the other sections in the GFF file. Values in the header are as follows, and arranged in the order listed: Table 3.2: Header Format
The FileVersion should always be "V3.2" for all GFF files that use the Generic File Format as described in this document. If the FileVersion is different, then the application should abort reading the GFF file. The FileType is a programmer-defined 4-byte character string that identifies the content-type of the GFF file. By convention, it is a 3-letter file extension in all-caps, followed by a space. For example, "DLG ", "ITP ", etc. When opening a GFF file, the application should check the FileType to make sure that the file being opened is of the expected type. 3.3. StructsIn a GFF file, Struct Fields are stored differently from other fields. Whereas most Fields are stored in the Field array, Structs are stored in the Struct Array. The very first element in the Struct Array is the Top-Level Struct for the GFF file, and it "contains" all the other Fields, Structs, and Lists. In this sense, the word "contain" refers to conceptual containment (as in Section 2.1) rather than physical containment (as in Section 3). In other words, it does not imply that all the other Fields are physically located inside the Top-Level Struct on disk (in fact, all Structs have the same physical size on disk). Since the Top-Level Struct is always present, every GFF file contains at least one element in the Struct Array. The Struct Array looks like this
Physically, a GFF Struct contains the values listed in the table below. All of them are DWORDs. Table 3.3: Struct Format
The above table shows that the Fields that a Struct conceptually contains are referenced indirectly via the DataOrDataOffset value. Struct 0, which is the Top-Level Struct, always has a Type (aka Struct ID) of 0xFFFFFFFF. 3.4. FieldsThe Field Array contains all the Fields in the GFF file except for the Top-Level Struct. Figure 3.4: Field Array
Each Field contains the values listed in the table below. All of the values are DWORDs. Table 3.4a: Field Format
The Field Type specifies what data type the Field stores (recall the data types from Section 2.2). The following table lists the values for each Field type. A datatype is considered complex if it would not fit within a DWORD (4 bytes). Table 3.4b: Field Types
Non-complex Field data is contained directly within the Field itself, in the DataOrDataOffset member. If the data type is smaller than a DWORD, then the first bytes of the DataOrDataOffset DWORD, up to the size of the data type itself, contain the data value. If the Field data is complex, then the DataOrDataOffset value is equal to a byte offset from the beginning of the Field Data Block, pointing to the raw bytes that represent the complex data. The exact method of fetching the complex data depends on the actual Field Type, and is described in Section 4. *As a special case, if the Field Type is a Struct, then DataOrDataOffset is an index into the Struct Array instead of a byte offset into the Field Data Block. **As another special case, if the Field Type is a List, then DataOrDataOffset is a byte offset from the beginning of the List Indices Array, where there is a DWORD for the size of the array followed by an array of DWORDs. The elements of the array are offsets into the Struct Array. See Section 4.9 for details. 3.5. LabelsA Label is a 16-CHAR array. Unused characters are nulls, but the label itself is non-null-terminated, so a 16-character label would use up all 16 CHARs with no null at the end. The Label Array is a list of all the Labels used in a GFF file. Note that a single Label may be referenced by more than one Field. When multiple Fields have Labels with the exact same text, they share the same Label element instead of each having their own copy. This sharing occurs regardless of what Struct the Field belongs to. All Labels in the Label Array should be unique. Also, the Fields belonging to a Struct must all use different Labels. It is permissible, however, for Fields in two different Structs to use the same Label, regardless of whether one of those Structs is conceptually contained inside the other Struct. Figure 3.5: Label Array
3.6. Field Data BlockThe Field Data block contains raw data for any Fields that have a complex Field Type, as described in Section 3.4. The two exceptions to this rule are Struct and List Fields, which are not stored in the Field Data Block. The FieldDataCount in the GFF header specifies the number of BYTEs contained in the Field Data block. The data in the Field Data Block is laid out according to the type of Field that owns each byte of data. See Section 4 for details. 3.7. Field IndicesA Field Index is a DWORD containing the index of the associated Field within the Field array. The Field Indices Array is an array of such DWORDs. 3.8. List IndicesThe List Indices Array contains a sequence of List elements packed end-to-end. A List is an array of Structs, and being array, its length is variable. The format of a List is as shown below: Figure 3.8: List Format
The first DWORD is the Size of the List, and it specifies how many Struct elements the List contains. There are Size DWORDS after that, each one an index into the Struct Array. Go to Page (Previous Page - Index, 2, 3, 4 - Next Page)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||
|
Multiplayer Games at Neverwinter Connections
|
||
|
Buy Premium Modules
|
||
|
4,826,326 BioWare Users:
|
||