xoreos  0.0.5
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
Aurora::GFF3File Class Reference

A GFF (generic file format) V3.2/V3.3 file, found in all Aurora games except Sonic Chronicles: The Dark Brotherhood. More...

#include <gff3file.h>

Inheritance diagram for Aurora::GFF3File:
Inheritance graph
[legend]
Collaboration diagram for Aurora::GFF3File:
Collaboration graph
[legend]

Classes

struct  Header
 A GFF3 header. More...
 

Public Member Functions

 GFF3File (Common::SeekableReadStream *gff3, uint32 id=0xFFFFFFFF, bool repairNWNPremium=false)
 Take over this stream and read a GFF3 file out of it. More...
 
 GFF3File (const Common::UString &gff3, FileType type, uint32 id=0xFFFFFFFF, bool repairNWNPremium=false)
 Request this resource from the ResourceManager and read a GFF3 file out of it. More...
 
virtual ~GFF3File ()
 
uint32 getType () const
 Return the GFF3's specific type. More...
 
const GFF3StructgetTopLevel () const
 Returns the top-level struct. More...
 
- Public Member Functions inherited from Aurora::AuroraFile
 AuroraFile ()
 
void clear ()
 
uint32 getID () const
 Return the file's ID. More...
 
uint32 getVersion () const
 Return the file's version. More...
 
bool isUTF16LE () const
 Were the ID and version encoded in little-endian UTF-16 in the file? More...
 

Private Types

typedef Common::PtrVector< GFF3StructStructArray
 
typedef std::vector< GFF3ListListArray
 

Private Member Functions

void load (uint32 id)
 
void loadHeader (uint32 id)
 
void loadStructs ()
 
void loadLists ()
 
Common::SeekableReadStreamgetStream (uint32 offset) const
 Return the GFF3 stream. More...
 
Common::SeekableReadStreamgetFieldData () const
 Return the GFF3 stream seeked to the start of the field data. More...
 
const GFF3StructgetStruct (uint32 i) const
 Return a struct within the GFF3. More...
 
const GFF3ListgetList (uint32 i) const
 Return a list within the GFF3. More...
 

Private Attributes

Common::ScopedPtr< Common::SeekableReadStream_stream
 
Header _header
 The GFF3's header. More...
 
bool _repairNWNPremium
 Should we try to read GFF3 files found in Neverwinter Nights premium modules? More...
 
uint32 _offsetCorrection
 The correctional value for offsets to repair Neverwinter Nights premium modules. More...
 
StructArray _structs
 Our structs. More...
 
ListArray _lists
 Our lists. More...
 
std::vector< uint32_listOffsetToIndex
 To convert list offsets found in GFF3 to real indices. More...
 

Friends

class GFF3Struct
 

Additional Inherited Members

- Static Public Member Functions inherited from Aurora::AuroraFile
static void readHeader (Common::ReadStream &stream, uint32 &id, uint32 &version, bool &utf16le)
 Read the header out of a stream. More...
 
static void readHeader (Common::ReadStream &stream, uint32 &id, uint32 &version)
 Read the ID and version out of a stream. More...
 
static uint32 readHeaderID (Common::ReadStream &stream)
 Read the ID out of a stream. More...
 
- Protected Member Functions inherited from Aurora::AuroraFile
void readHeader (Common::ReadStream &stream)
 
- Static Protected Member Functions inherited from Aurora::AuroraFile
static uint32 convertUTF16LE (uint32 x1, uint32 x2)
 
- Protected Attributes inherited from Aurora::AuroraFile
uint32 _id
 The file's ID. More...
 
uint32 _version
 The file's version. More...
 
bool _utf16le
 The file's ID and version are in little-endian UTF-16. More...
 

Detailed Description

A GFF (generic file format) V3.2/V3.3 file, found in all Aurora games except Sonic Chronicles: The Dark Brotherhood.

Even games that have V4.0/V4.1 GFFs additionally use V3.2/V3.3 files as well.

GFF files store hierarchical data, similar in concept to XML. They are used whenever such data is useful: to, for example, hold area and object descriptions, module and campaign specifications or conversations. They consist of a top-level struct, with a collection of fields of various types, indexed by a human-readable string name. A field can then be another struct (which itself will be a collection of fields) or a list of structs, leading to a recursive, hierarchical structure.

GFF V3.2/V3.3 files come in a multitude of types (ARE, DLG, ...), each with its own 4-byte type ID ('ARE ', 'DLG ', ...). When specified in the GFF3File constructor, the loader will enforce that it matches, and throw an exception should it not. Conversely, an ID of 0xFFFFFFFF means that no such type ID enforcement should be done. In both cases, the type ID read from the file can get access through getType().

The GFF V3.2/V3.3 files found in the encrypted premium module archives of Neverwinter Nights are deliberately broken in various way. When the constructor parameter repairNWNPremium is set to true, GFF3File will detect such broken files and automatically repair them. When this parameter is set to false, no detection will take place, and these broken files will lead the loader to throw an exception.

There is no functional difference between GFF V3.2 and V3.3 files. GFF V3.3 files exclusively appear in The Witcher (and every GFF file there is of version V3.3), simply to denote that the language table used for LocStrings is different. Since xoreos has more flexible handling of language IDs anyway, this doesn't concern us.

See also: GFF4File in gff4file.h for the later V4.0/V4.1 versions of the GFF format.

Definition at line 85 of file gff3file.h.

Member Typedef Documentation

◆ ListArray

typedef std::vector<GFF3List> Aurora::GFF3File::ListArray
private

Definition at line 122 of file gff3file.h.

◆ StructArray

Definition at line 121 of file gff3file.h.

Constructor & Destructor Documentation

◆ GFF3File() [1/2]

Aurora::GFF3File::GFF3File ( Common::SeekableReadStream gff3,
uint32  id = 0xFFFFFFFF,
bool  repairNWNPremium = false 
)

Take over this stream and read a GFF3 file out of it.

Definition at line 66 of file gff3file.cpp.

References _stream, and load().

Here is the call graph for this function:

◆ GFF3File() [2/2]

Aurora::GFF3File::GFF3File ( const Common::UString gff3,
FileType  type,
uint32  id = 0xFFFFFFFF,
bool  repairNWNPremium = false 
)

Request this resource from the ResourceManager and read a GFF3 file out of it.

Definition at line 74 of file gff3file.cpp.

References _stream, load(), Common::ScopedPtrBase< T, Deallocator >::reset(), ResMan, and TypeMan.

Here is the call graph for this function:

◆ ~GFF3File()

Aurora::GFF3File::~GFF3File ( )
virtual

Definition at line 84 of file gff3file.cpp.

Member Function Documentation

◆ getFieldData()

Common::SeekableReadStream & Aurora::GFF3File::getFieldData ( ) const
private

Return the GFF3 stream seeked to the start of the field data.

Definition at line 281 of file gff3file.cpp.

References _header, Aurora::GFF3File::Header::fieldDataOffset, and getStream().

Referenced by Aurora::GFF3Struct::getData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getList()

const GFF3List & Aurora::GFF3File::getList ( uint32  i) const
private

Return a list within the GFF3.

Definition at line 260 of file gff3file.cpp.

References _listOffsetToIndex, and _lists.

Referenced by Aurora::GFF3Struct::getList().

Here is the caller graph for this function:

◆ getStream()

Common::SeekableReadStream & Aurora::GFF3File::getStream ( uint32  offset) const
private

Return the GFF3 stream.

Definition at line 275 of file gff3file.cpp.

References _stream.

Referenced by getFieldData(), and Aurora::GFF3Struct::load().

Here is the caller graph for this function:

◆ getStruct()

const GFF3Struct & Aurora::GFF3File::getStruct ( uint32  i) const
private

Return a struct within the GFF3.

Definition at line 253 of file gff3file.cpp.

References _structs.

Referenced by Aurora::GFF3Struct::getStruct(), and getTopLevel().

Here is the caller graph for this function:

◆ getTopLevel()

const GFF3Struct & Aurora::GFF3File::getTopLevel ( ) const

◆ getType()

uint32 Aurora::GFF3File::getType ( ) const

Return the GFF3's specific type.

Definition at line 87 of file gff3file.cpp.

References Aurora::AuroraFile::_id.

Referenced by Aurora::SACFile::SACFile().

Here is the caller graph for this function:

◆ load()

void Aurora::GFF3File::load ( uint32  id)
private

Definition at line 97 of file gff3file.cpp.

References Common::StackException::add(), loadHeader(), loadLists(), and loadStructs().

Referenced by GFF3File().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadHeader()

void Aurora::GFF3File::loadHeader ( uint32  id)
private

◆ loadLists()

void Aurora::GFF3File::loadLists ( )
private

Definition at line 191 of file gff3file.cpp.

References _header, _listOffsetToIndex, _lists, _stream, _structs, Aurora::GFF3File::Header::listIndicesCount, and Aurora::GFF3File::Header::listIndicesOffset.

Referenced by load().

Here is the caller graph for this function:

◆ loadStructs()

void Aurora::GFF3File::loadStructs ( )
private

Definition at line 183 of file gff3file.cpp.

References _header, _structs, Aurora::GFF3File::Header::structCount, and Aurora::GFF3File::Header::structOffset.

Referenced by load().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ GFF3Struct

friend class GFF3Struct
friend

Definition at line 160 of file gff3file.h.

Member Data Documentation

◆ _header

Header Aurora::GFF3File::_header
private

◆ _listOffsetToIndex

std::vector<uint32> Aurora::GFF3File::_listOffsetToIndex
private

To convert list offsets found in GFF3 to real indices.

Definition at line 138 of file gff3file.h.

Referenced by getList(), and loadLists().

◆ _lists

ListArray Aurora::GFF3File::_lists
private

Our lists.

Definition at line 135 of file gff3file.h.

Referenced by getList(), and loadLists().

◆ _offsetCorrection

uint32 Aurora::GFF3File::_offsetCorrection
private

The correctional value for offsets to repair Neverwinter Nights premium modules.

Definition at line 132 of file gff3file.h.

Referenced by loadHeader().

◆ _repairNWNPremium

bool Aurora::GFF3File::_repairNWNPremium
private

Should we try to read GFF3 files found in Neverwinter Nights premium modules?

Definition at line 130 of file gff3file.h.

Referenced by loadHeader().

◆ _stream

Common::ScopedPtr<Common::SeekableReadStream> Aurora::GFF3File::_stream
private

Definition at line 125 of file gff3file.h.

Referenced by getStream(), GFF3File(), loadHeader(), and loadLists().

◆ _structs

StructArray Aurora::GFF3File::_structs
private

Our structs.

Definition at line 134 of file gff3file.h.

Referenced by getStruct(), loadLists(), and loadStructs().


The documentation for this class was generated from the following files: