Module dbpf
Source
Read and write Database Packed File (DBPF) archives.
See Also
- DBPF (SC4D Encyclopedia)
- List of File Formats (SC4D Encyclopedia)
License
MIT License
Members
-
isValidDbpfVersion
enum auto isValidDbpfVersion(float V);
Determines whether
V
is a valid DBPF version number.See Also
Version
Remarks
1.0
seen in SimCity 4, The Sims 21.1
seen in The Sims 22.0
seen in Spore, The Sims 33.0
seen in SimCity (2013)
-
Header
struct Header(float V = 1) if (isValidDbpfVersion!V);
Parameters
V
DBPF archive version. SeeVersion
.See Also
DBPF Header (SC4D Encyclopedia)
-
identifier
static const identifier;
Always
DBPF
. -
magic
ubyte[4] magic;
Always
DBPF
. -
version_
Version version_;
-
unknown1
uint unknown1;
Unused, possibly reserved.
-
unknown2
uint unknown2;
Unused, possibly reserved.
-
unknown3
const uint unknown3;
Should always be zero in DBPF v
2.0
. -
dateCreated
uint dateCreated;
Date created. Unix timestamp.
Remarks
Unused in DBPF1.1
. -
dateModified
uint dateModified;
Date modified. Unix timestamp.
Remarks
Unused in DBPF v1.1
. -
indexMajorVersion
uint indexMajorVersion;
Major version of the Index table.
Remarks
Always7
in The Sims 2 and SimCity 4. If this is a DBPF v2.0
archive, then it is0
for Spore.See Also
indexMinorVersion
-
indexEntryCount
uint indexEntryCount;
Number of entries in the Index Table.
-
indexOffset
uint indexOffset;
Offset to Index table, in bytes. Location of first index entry.
-
indexSize
uint indexSize;
Size of the Index table, in bytes.
-
holeEntryCount
uint holeEntryCount;
Number of Hole entries in the Hole Record.
-
holeOffset
uint holeOffset;
Location of the hole Record.
-
holeSize
uint holeSize;
Size of the hole Record, in bytes.
-
indexMinorVersion
uint indexMinorVersion;
Minor version of the Index table.
Remarks
In The Sims 2 for DBPF v
1.1+
.In DBPF >= v
2.0
, this is3
, otherwise:1
= v7.0
2
= v7.1
See Also
indexMajorVersion
-
indexOffset
uint indexOffset;
Offset to Index table, in bytes. Location of first index entry.
-
unknown4
uint unknown4;
-
reserved
ubyte[24] reserved;
Reserved for future use.
-
indexVersion
const @property Version indexVersion();
Computed, human-readable Index table version.
-
Version
struct Version;
Remarks
For DBPF version specifiers:1.0
seen in SimCity 4, The Sims 21.1
seen in The Sims 22.0
seen in Spore, The Sims 33.0
seen in SimCity(2013)
7.0
seen in SimCity 4, The Sims 27.1
seen in The Sims 2
-
simCity4
static const float simCity4;
static const float sc4; -
sims2
static const float sims2;
-
spore
static const float spore;
-
sims3
static const float sims3;
-
simCity
static const float simCity;
SimCity (2013)
-
simCity4Index
static const Version simCity4Index;
-
sc4Index
static const Version sc4Index;
-
major
uint major;
-
minor
uint minor;
-
isValidIndexVersion
enum auto isValidIndexVersion(float V);
Determines whether
V
is a valid DBPF Index table version number.See Also
Version
-
Entry
struct Entry;
struct ResourceEntry;Index Tables list the contents of a DBPF package.
Remarks
The index table is very similar to the directory file (DIR) within a DPBF package. The difference being that the Index Table lists every file in the package, whereas the directory file only lists the compressed files within the package. Reader presents a directory file that is a mashup of these two entities, listing every file in the package, as well as indicating whether or not that particular file is compressed.See Also
DBPF Index Table (SC4D Encyclopedia)
-
TableEntry
alias TableEntry = std.sumtype.SumType!(Entry, ResourceEntry).SumType;
-
Table
alias Table = SumType!(Entry, ResourceEntry)[];
-
EntryFilter
alias EntryFilter = bool function(SumType!(Entry, ResourceEntry) entry);
-
entryOf
bool entryOf(alias T)(TableEntry
entry
) if (is(typeof(T) == Tgi) || is(typeof(T.asOriginalType) == Tgi)); -
HoleTable
struct HoleTable;
A Hole Table contains the location and size of all holes in a DBPF file.
Remarks
Holes are created when the game deletes something from a DBPF. The holes themselves are simply junk data of the appropriate length to fill the hole. -
FileHeader
struct FileHeader;
Occurs before
File.contents
, if and only if theFile
is compressed.-
compressedSize
uint compressedSize;
Compressed size of the file, in bytes.
-
compressionId
const ushort compressionId;
Compression ID, i.e. (
0x10FB
). Always QFS Compression.See Also
DBPF Compression (SC4D Encyclopedia)
-
uncompressedSize
int24 uncompressedSize;
Uncompressed size of the file, in bytes.
-
File
struct File(Flag!"compressed" Compressed = false);
alias UncompressedFile = File!Flag.no.File;
alias CompressedFile = File!Flag.yes.File;Files fill the bulk of a DBPF archive.
A file header exists only if this file is compressed.
Remarks
Each file is either uncompressed or compressed. To check if a file is compressed you first need to read the DIR file, if it exists. If no DIR entry exists, then no files within the package are compressed.-
header
FileHeader header;
Exists only if this file is compressed.
-
contents
ubyte[] contents;
Contents of this file.
See List of File Formats for a list of the file types that may exist within a DBPF archive.
-
size
const @property uint size();
Uncompressed size of this file, in bytes.
-
ArchiveException
class ArchiveException: object.Exception;
Thrown when an
Archive
is invalid or corrupt. -
isValidVersion
enum auto isValidVersion(float DBPF, float V);
Determines whether
DBPF and
V` are valid DBPF and Index table versions.See Also
isValidDbpfVersion
isValidIndexVersion
Version
-
Archive
struct Archive(float DBPF) if (isValidDbpfVersion!DBPF);
-
path
const string path;
-
metadata
Head metadata;
-
entries
Table entries;
-
directory
const UncompressedFile* directory;
If no DIR entry exists, then no files within the package are compressed.
-
this
this(string
path
);Open a DBPF archive from the given file
.path
Throws
FileException
when the archive is not found, or there is some I/O error.Throws
ArchiveException
when the archive is invalid or corrupt. -
close
void close();
-
SimCity4Archive
alias SimCity4Archive = Archive!1.0F.Archive;
-
Sims2Archive
alias Sims2Archive = Archive!1.1F.Archive;
-
SporeArchive
alias SporeArchive = Archive!2.0F.Archive;
-
Sims3Archive
alias Sims3Archive = Archive!2.0F.Archive;
-
SimCity2013Archive
alias SimCity2013Archive = Archive!3.0F.Archive;