Database Package File (DBPF) format
A reference written by Fogity
This page documents the Database Package File (DBPF) format.
The format is a key-value store used to store all the game resources using resource keys. The file consists of a header followed by each resource and finally the resource index (technically, the index could be stored anywhere after the header). The resources can be compressed using one of the supported compression types.
Format Specification
Section titled “Format Specification”- Binary- Little Endian
- Least Significant Bit First
== FILE ==HEADER file metadata... resource data, possibly compressedINDEX resource index with resource metadata
== HEADER ==byte[4] = "DBPF" file identifieruint32 = 2 major format versionuint32 = 1 minor format versionuint32 major file version (unused by Maxis and modders)uint32 minor file version (unused by Maxis and modders)uint32 unknown/unuseduint32 creation time (unused by Maxis and modders)uint32 update time (unused by Maxis and modders)uint32 unknown/unuseduint32 index countuint32 index offset, short (absolute) [1]uint32 index sizebyte[12] unknown/unuseduint32 = 3 unknown/unuseduint64 index offset, long (absolute) [1]byte[24] unknown/padding
== INDEX ==INDEX HEADER index options and constant valuesENTRY[index count] index entry for each resource
== INDEX HEADER ==uint32 index flags [2] 0x1 constant type 0x2 constant group 0x4 constant instance extensionIF 'constant type' set uint32 resource key typeIF 'constant group' set uint32 resource key groupIF 'constant instance extension' set uint32 resource key instance upper 32 bits
== ENTRY ==IF 'constant type' not set uint32 resource key typeIF 'constant group' not set uint32 resource key groupIF 'constant instance extension' not set uint32 resource key instance upper 32 bitsuint32 resource key instance lower 32 bitsuint32 resource offset (absolute)uint31 compressed sizebit extended entry (always set by Maxis and modders)uint32 uncompressed sizeIF 'extended entry' set uint16 compression type 0x0000 uncompressed 0x5a42 zlib 0xFFE0 deleted 0xFFFE streamable 0xFFFF internal uint16 = 1 committed (does not have any effect in the game)
- If the short index offset is set to 0, then the long index offset is used instead. Maxis always sets the short index offset to 0.
- If the type, group, or extended instance is the same for all keys in the index, then these values can be included in the index header instead of in each index entry.
Compression Types
Section titled “Compression Types”uncompressed: The resource is not compressed at all. Usually avoided.
zib: The zlib compression format. Most common compression type.
deleted: Not a compression type, used to mark that a resource should be unloaded from the game. Appears in delta packages, uncommon in mods or modding tools.
streamable: Unknown format. Not used.
internal: Custom compression format, used by Maxis for string tables.
Originally written by Fogity on GitLab.