BioWare Atari
BioWare Info BioWare Games Support Forums Visit the BioWare Store
Neverwinter Nights Home
Neverwinter Nights Home

Tutorial: A GFF to TXT File Conversion Program

Intended Audience: For Developers
By Don Moar

NOTICE: This tutorial is to give software developers an example of how to use the Generic File Format (GFF). The source code provided is unsupported; compile and run at your own risk. Please refer to the For Developers FAQ and the NWN End User License Agreement (EULA) for more information.

Purpose

I would like to keep my individual module resources checked into a source code control system but I would prefer to store them as text files instead of binary files since that allows me to do comparisons between versions much easier. Since most of the game's resources are stored using the GFF, I need a way to convert a file from it to text.

The text output should follow the XML-like format outlined below, with appropriate values inserted between each tag. Each <STRUCT> element would mirror a GFF Struct, containing <FIELD> elements for each GFF Field that the Struct contains.

<STRUCT>
<TYPE>
</TYPE>
<FIELD>
<FIELD TYPE>
</FIELD_TYPE>
<FIELD_LABEL>
</FIELD_LABEL>
<FIELD_VALUE>
</FIELD_VALUE>
</FIELD>
</STRUCT>

Command-Line

The program's command line should look like this:

gff2txt [gff filename] [txt filename]

Parameter Required Description
gff filename Yes The name of the file to parse. This can have any extension, such as .dlg, .ifo, .utc, etc.
txt filename Yes The name of the file to create.

Program Architecture

Once again, I am only creating a quick and dirty utility, so I'm not going to spend time creating a fully fleshed out GFF class. However, I will create a few helper functions to reduce code duplication.

Class Definitions

None.

C Source Code

To view or download the C Source Code you need to be logged into your BioWare Community Account. If you don't have an account you can sign up for a free BioWare Community Account.

Extra Credit

1. Complete the Program

There are a few things left to do to complete this program:

  • add support for the remaining complex data types (DOUBLE, DWORD64, ExoLocString, INT64, List, Void)
  • restructure the program by creating an interface to the standard set of methods required for GFF access and a set of objects that implements the interface
  • make the program more robust
  • change the text output so that it indents tags that are embedded within other tags, making it easier to read

2. Remove the Extraneous Parameter

Since we always want the name of the output text file to resemble the name of the GFF resource, always having to supply its name is a bit of a waste (and error prone). Modify the program so that the name of the output text file is based on the name of the given GFF file.

3. Combine ERF / GFF Techniques

Using the information from this tutorial and Tutorial 1, write a single program that parses a given module, converting gff resource types to text files that are stored in the given directory. This will make it much more convenient to extract the data for the purposes of checking them into source control.

 

 

BioWare Store
Neverwinter Nights 2 Forums
Hide/Show

English
Deutsch
Français
Español
Italiano

Hide/Show

View Latest Screenshots 

View Latest Screenshots
Hide/Show

Multiplayer Games at Neverwinter Connections

Today
Schedule a Game...



Current time is: (set time)
Sun, 08 November 2009 03:48AM

Hide/Show

Buy Premium Modules

Top NWN: HotU Modules:
1. Good vs Evil III
2. More...

Top NWN: SoU Modules:
1. Good vs Evil III
2. More...

Top CEP Modules:
1. The Lord of Terror The Diablo Campa...
2. More...

Top Modules - NWVault:
1. Hall of Fame
2. More...

Total Modules: 4423

Hide/Show

4,828,578 BioWare Users:
  164 Logged In
  10 Hidden
  1175 Guests

1271 Playing Online
  100% NWN
  100% NWN: SoU
  99% NWN: HotU

446 Registered Guilds

8,715,400 posts in forums

Newest Forum Topics:
1. Strength Cheat? (Dragon Age: Origins General Discussion)

2. I found Kreia! (Dragon Age: Origins General Discussion)

3. Lost in Dreams (Dragon Age: Origins Story and Plot (Spoilers) Forum)

4. 4Aces/KMA - Needs Texture Defs +... (Dragon Age Toolset Forum)

5. How do I make a key ring? (NWN2: Builders - NWN2 Scripting)