Neverwinter Nights:Key File Format
A Key file is an index of all the resources contained within a set of BIF files. The key file contains information as to which BIFs it indexes for and what resources are contained in those BIFs.
(size 64 bytes)
|0||FileType||CHAR ||"KEY "|
|4||FileVersion||CHAR ||"V1 "|
|8||BIFCount||INT32||Number of BIF files that this KEY file controls|
|12||KeyCount||INT32||Number of Resources in all BIF files linked to this keyfile|
|16||OffsetToFileTable||INT32||Byte offset of File Table from beginning of this file|
|20||OffsetToKeyTable||INT32||Byte offset of Key Entry Table from beginning of this file|
|24||Build Year||INT32||Number of years since 1900|
|28||Build Day||INT32||Number of days since January 1|
|32||Reserved||BYTE ||Reserved for future use|
(size 12 bytes * BIFCount)
The File Table is a list of all the BIF files that are associated with the key file.
The number of elements in the File Table is equal to the BIFCount specified in the Header.
Each element in the File Table is a File Entry, and describes a single BIF file.
|0||FileSize||INT32||File size of the BIF|
|4||FilenameOffset||INT32||Byte position of the BIF file's filename in this file. Points to a location in the Filename Table|
|8||FilenameSize||INT16||Number of characters in the BIF's filename|
|10||Drives||INT16||A number that represents which drives the BIF file is located in. Currently each bit represents a drive letter, e.g., bit 0 = HD0, which is the directory where the application was installed|
(size varies * BIFCount)
The Filename Table lists the filenames of all the BIF files associated with the key file.
Each File Entry in the File Table has a FilenameOffset that indexes into a Filename Entry in the Filename Table.
|0||Filename||variable||Filename of the BIF as a non-terminated character string.
This filename is relative to the "drive" where the BIF is located (as specified in the Drives portion of the BIF File Entry). Each Filename must be unique. e.g., "data\2da.bif"
(size 22 bytes * KeyCount)
The Key Table is a list of all the resources in all the BIFs associated with this key file.
The number of elements in the Key Table is equal to the KeyCount specified in the the Header.
Each element in the Key Table is a Key Entry, and describes a single resource. A resource may be a Variable Resource, or it may be a Fixed Resource (at this time, all resources are Variable).
|0||ResRef||CHAR ||The filename of the resource item without it's extension. The game uses this name to access the resource. Each ResRef must be unique.|
|16||ResourceType||INT16||Resource Type of the Resource|
|18||ResID||INT32||A unique ID number. It is generated as follows:
x = [index into File Table to specify a BIF]
Note: This ID must match the ID in the BIF.