Skip to content

Save Game File Formats

shartte edited this page May 1, 2015 · 7 revisions

This page lists the file formats related to save games in ToEE.

Archive Files

Once the savegame is written, it gets archived into two files: *.tfai and *.tfaf. tfai is in an index file while tfaf contains the actual data files.

TFAI format

To read or write an index file, continuously read 32-bit integers which specify the type of the entry. The following types are supported:

Type Description
0 File
1 Directory
2 End of Directory This entry has no body.
3 End of Index. This entry has no body.

File Entries

A file entry (type 0) consist of:

struct FileEntry {
  int length_of_name;
  char name[length_of_name]; // not null-terminated
  int size; // in bytes
}

Directory entry

A directory entry (type 1) consists of:

struct FileEntry {
  int length_of_name;
  char name[length_of_name]; // not null-terminated
}

All following entries in the index file are within that directory, until an entry of type 2 is encountered to denote the end of the directory.

TFAF Format

The tfaf file just contains all data for FileEntries found in the TFAI file (in order). So in order to extract the files, one has to read the archive index in order and whenever a file entry is encountered, the number of bytes specified in the size field has to be read from the data file.

GSI Format

The gsi filename contains the user specified name of the save game. It seems to be a short index file that describes the save game and is used by the load game and save game UIs to displays the list of save slots without having to open the actual save archive.

The format can be described by this 010 Editor template:

int version; // Always 0
int moduleNameLen;
char moduleName[moduleNameLen];
int leaderNameLen;
char leaderName[leaderNameLen];
int mapNumber;
int gameTimeDays;
int gameTimeMilliseconds;
int leaderPortraitId;
int leaderLevel;
int leaderTileLocX;
int leaderTileLocY;
int storyState;
int displayNameLen;
char displayName[displayNameLen];