xoreos
0.0.5
|
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>
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 GFF3Struct & | getTopLevel () 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< GFF3Struct > | StructArray |
typedef std::vector< GFF3List > | ListArray |
Private Member Functions | |
void | load (uint32 id) |
void | loadHeader (uint32 id) |
void | loadStructs () |
void | loadLists () |
Common::SeekableReadStream & | getStream (uint32 offset) const |
Return the GFF3 stream. More... | |
Common::SeekableReadStream & | getFieldData () const |
Return the GFF3 stream seeked to the start of the field data. More... | |
const GFF3Struct & | getStruct (uint32 i) const |
Return a struct within the GFF3. More... | |
const GFF3List & | getList (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... | |
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.
|
private |
Definition at line 122 of file gff3file.h.
|
private |
Definition at line 121 of file gff3file.h.
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().
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.
|
virtual |
Definition at line 84 of file gff3file.cpp.
|
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().
Return a list within the GFF3.
Definition at line 260 of file gff3file.cpp.
References _listOffsetToIndex, and _lists.
Referenced by Aurora::GFF3Struct::getList().
|
private |
Return the GFF3 stream.
Definition at line 275 of file gff3file.cpp.
References _stream.
Referenced by getFieldData(), and Aurora::GFF3Struct::load().
|
private |
Return a struct within the GFF3.
Definition at line 253 of file gff3file.cpp.
References _structs.
Referenced by Aurora::GFF3Struct::getStruct(), and getTopLevel().
const GFF3Struct & Aurora::GFF3File::getTopLevel | ( | ) | const |
Returns the top-level struct.
Definition at line 91 of file gff3file.cpp.
References getStruct().
Referenced by Engines::NWN::CharGenChoices::applyChoices(), Engines::Witcher::Area::Area(), Engines::NWN2::Area::Area(), Aurora::DLGFile::DLGFile(), Engines::KotOR::SavedGame::fillFromModuleIFO(), Engines::KotOR::SavedGame::fillFromNFO(), Engines::Witcher::Campaign::getDescription(), Engines::NWN2::Module::getDescription(), Engines::Witcher::Module::getDescription(), Engines::Witcher::Campaign::getName(), Engines::NWN2::Module::getName(), Engines::Witcher::Module::getName(), Engines::Witcher::Area::getName(), Engines::KotOR2::Module::getName(), Engines::NWN2::Area::getName(), Engines::NWN::Area::getName(), Engines::KotOR::Module::getName(), Engines::Witcher::Creature::load(), Engines::Jade::Area::load(), Engines::KotOR2::Area::load(), Engines::NWN::Area::load(), Engines::KotOR::Area::load(), Engines::Witcher::Campaign::loadCampaignFile(), and Aurora::NFOFile::NFOFile().
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().
|
private |
Definition at line 97 of file gff3file.cpp.
References Common::StackException::add(), loadHeader(), loadLists(), and loadStructs().
Referenced by GFF3File().
|
private |
Definition at line 110 of file gff3file.cpp.
References _header, Aurora::AuroraFile::_id, _offsetCorrection, _repairNWNPremium, _stream, Aurora::AuroraFile::_version, Common::debugTag(), Aurora::GFF3File::Header::fieldDataOffset, Aurora::GFF3File::Header::fieldIndicesOffset, Aurora::GFF3File::Header::fieldOffset, kVersion32, kVersion33, Aurora::GFF3File::Header::labelOffset, Aurora::GFF3File::Header::listIndicesOffset, Aurora::GFF3File::Header::read(), Aurora::AuroraFile::readHeader(), and Aurora::GFF3File::Header::structOffset.
Referenced by load().
|
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().
|
private |
Definition at line 183 of file gff3file.cpp.
References _header, _structs, Aurora::GFF3File::Header::structCount, and Aurora::GFF3File::Header::structOffset.
Referenced by load().
|
friend |
Definition at line 160 of file gff3file.h.
|
private |
The GFF3's header.
Definition at line 127 of file gff3file.h.
Referenced by getFieldData(), loadHeader(), loadLists(), loadStructs(), Aurora::GFF3Struct::readField(), Aurora::GFF3Struct::readFields(), and Aurora::GFF3Struct::readLabel().
|
private |
To convert list offsets found in GFF3 to real indices.
Definition at line 138 of file gff3file.h.
Referenced by getList(), and loadLists().
|
private |
|
private |
The correctional value for offsets to repair Neverwinter Nights premium modules.
Definition at line 132 of file gff3file.h.
Referenced by loadHeader().
|
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().
|
private |
Definition at line 125 of file gff3file.h.
Referenced by getStream(), GFF3File(), loadHeader(), and loadLists().
|
private |
Our structs.
Definition at line 134 of file gff3file.h.
Referenced by getStruct(), loadLists(), and loadStructs().