Difference between revisions of "Sims 3:DBPF"

From SimsWiki
Jump to: navigation, search
m (The Index)
m (The Index: Explicitly refer (non-link) to the Index Type subsection)
 
(26 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{TS3AdvancedModdingHeader}}
 +
 +
==DBPF Packages==
 +
Sims 3 stores [[Sims 3:PackedFileTypes|multiple resource types]] in an archive format known by it's [http://en.wikipedia.org/wiki/Magic_number_%28programming%29 magic number] of "DBPF".  On disk, these archives have one of a number of extensions:
 +
{| class="wikitable" border="1"
 +
|-
 +
|*.package
 +
|General collection of resources
 +
|-
 +
|*.world
 +
|Resources comprising a "world"
 +
|-
 +
|*.dbc
 +
|Collection of DBPF archives in a single archive
 +
|}
 +
 
== Package Header ==
 
== Package Header ==
96 bytes: "standard" DBPF 2.0 format; DBBF not seen; DPPF is encrypted.
+
96 bytes: "standard" DBPF 2.0 format; DBBF not seen; DBPP is encrypted.
<pre>
+
DWORD    magic ;; "DBPF"
DWORD    magic ;; "DBPF"
+
DWORD    major ;; 2
DWORD    major ;; 2
+
DWORD    minor ;; 0
DWORD    minor ;; 0
+
BYTE[24] unknown1
BYTE[24] unknown1
+
DWORD    ;; number of index entries - if zero, size and position also zero
DWORD    ;; number of index entries - if zero, size and position also zero
+
BYTE[4]  unknown2
BYTE[4]  unknown2
+
DWORD    ;; size of index on disk in bytes
DWORD    ;; size of index on disk in bytes
+
BYTE[12] unknown3
BYTE[12] unknown3
+
DWORD    index_version ;; always 3
DWORD    index_version ;; always 3
+
DWORD    ;; ''position'' of index (absolute)
DWORD    ;; ''position'' of index (absolute)
+
BYTE[28] unknown4
BYTE[28] unknown4
+
 
</pre>
+
 
== The Index ==
 
== The Index ==
 
If ''position'' is not zero, at that position:
 
If ''position'' is not zero, at that position:
<pre>DWORD ;; Index type</pre>
 
  
The count of set bits in the index type is the number of additional DWORD entries in index header:
+
DWORD ;; Index Type, see subsection below
<pre>DWORD[(for each bit in Index type)]</pre>
+
<Index Header>
 +
<Index Entry>[number of index entries]
  
The number of DWORDs in an actual index entry is 8.  The entry is stored in two parts - the index header and then the entry on disk.  The header provides the data that is constant to all entries, essentially a kind of compression.
+
''Note: The [number of index entries] value in the [[#Package Header|Package Header]] '''excludes''' the Index Header.''
  
* For each index entry on disk:
+
Each Index Entry (and the Index Header) contains a variable number of '''DWORD''' fields in the following order:
<pre>DWORD[(8 - number of bits in Index type)]</pre>
+
  
Each DWORD in an actual index entry can either come from the header or from the index entry on disk, depending on the bits set in the index type.  The order of the DWORDs in an index entry is (with matching bit number):
+
{|class="wikitable"
{| class="wikitable" border="1"
+
 
|-
 
|-
|0
+
![[#Index Type|Bitfield]]
|ResourceType
+
!colspan=2|Field
|
+
 
|-
 
|-
|1
+
|style="text-align: center;"|0
|ResourceGroup
+
|'''ResourceType'''
 
|
 
|
 
|-
 
|-
|2
+
|style="text-align: center;"|1
|InstanceHi
+
|'''ResourceGroup'''
 +
|Top byte is a set of flags
 +
|-
 +
|style="text-align: center;"|2
 +
|'''InstanceHi'''
 
|
 
|
 
|-
 
|-
|3
+
|style="text-align: center;"|3
|InstanceLo
+
|'''InstanceLo'''
 
|
 
|
 
|-
 
|-
|4
+
|style="text-align: center;"|4
|Chunkoffset
+
|'''Chunkoffset'''
 
|Absolute location in package
 
|Absolute location in package
 
|-
 
|-
|5
+
|style="text-align: center;"|5
|Filesize
+
|'''Filesize''' (lo 31bits), '''Unknown1''' (hi bit)
 
|Length of data in package
 
|Length of data in package
 
|-
 
|-
|6
+
|style="text-align: center;"|6
|Memsize
+
|'''Memsize'''
 
|Length of uncompressed data
 
|Length of uncompressed data
 
|-
 
|-
|7
+
|style="text-align: center;"|7
|Compressed(lo WORD) , Unknown2(hi WORD)
+
|'''Compressed''' (lo WORD), '''Unknown2''' (hi WORD)
|Compressed is 0x0000 or 0xFFFF
+
|Compressed is '''0x0000''' or '''0xFFFF'''
 
|}
 
|}
(That's a total of 32 bytes per entry.)
 
  
(Possibly confusingly, in my implementation, I actually store the index type along with the entries - keeps the data structure simpler..!)
+
=== Index Type ===
 +
 
 +
This is a ''bitfield'' that determines which DWORD fields exist in the Index Header and the Index Entries.
 +
 
 +
 
 +
=== Index Header ===
 +
 
 +
The header provides the data that is constant to all entries, essentially a kind of compression. However not all data is valid to be included in the index header for all entries.
 +
 
 +
DWORD[(for each SET bit in Index Type)]
 +
 
 +
 
 +
=== Index Entry ===
 +
 
 +
DWORD[(for each UNSET bits in Index Type)]
 +
 
 +
''Note: Because of the different treatment of the bitfield, fields that exist in the Index Header '''will NOT''' exist in all Index Entries, and vice versa.''
 +
 
 +
==Chunk Compression==
 +
See [[Sims 3:DBPF/Compression]].
 +
 
 +
 
 +
==Credits==
 +
Above documented by Peter Jones based on [[Spore:DBPF|Spore package format]]
 +
 
  
By Peter Jones
+
{{TS3AdvancedModdingHeader}}

Latest revision as of 18:00, 10 February 2015

Modding Reference by Category

Sims 3 :DBPF | File Types | RCOL(Scene) | Catalog Resource | String Table | Key Table | TS3 Programmer's Reference 

Contents

[edit] DBPF Packages

Sims 3 stores multiple resource types in an archive format known by it's magic number of "DBPF". On disk, these archives have one of a number of extensions:

*.package General collection of resources
*.world Resources comprising a "world"
*.dbc Collection of DBPF archives in a single archive

[edit] Package Header

96 bytes: "standard" DBPF 2.0 format; DBBF not seen; DBPP is encrypted.

DWORD    magic ;; "DBPF"
DWORD    major ;; 2
DWORD    minor ;; 0
BYTE[24] unknown1
DWORD    ;; number of index entries - if zero, size and position also zero
BYTE[4]  unknown2
DWORD    ;; size of index on disk in bytes
BYTE[12] unknown3
DWORD    index_version ;; always 3
DWORD    ;; position of index (absolute)
BYTE[28] unknown4

[edit] The Index

If position is not zero, at that position:

DWORD ;; Index Type, see subsection below
<Index Header>
<Index Entry>[number of index entries]

Note: The [number of index entries] value in the Package Header excludes the Index Header.

Each Index Entry (and the Index Header) contains a variable number of DWORD fields in the following order:

Bitfield Field
0 ResourceType
1 ResourceGroup Top byte is a set of flags
2 InstanceHi
3 InstanceLo
4 Chunkoffset Absolute location in package
5 Filesize (lo 31bits), Unknown1 (hi bit) Length of data in package
6 Memsize Length of uncompressed data
7 Compressed (lo WORD), Unknown2 (hi WORD) Compressed is 0x0000 or 0xFFFF

[edit] Index Type

This is a bitfield that determines which DWORD fields exist in the Index Header and the Index Entries.


[edit] Index Header

The header provides the data that is constant to all entries, essentially a kind of compression. However not all data is valid to be included in the index header for all entries.

DWORD[(for each SET bit in Index Type)]


[edit] Index Entry

DWORD[(for each UNSET bits in Index Type)]

Note: Because of the different treatment of the bitfield, fields that exist in the Index Header will NOT exist in all Index Entries, and vice versa.

[edit] Chunk Compression

See Sims 3:DBPF/Compression.


[edit] Credits

Above documented by Peter Jones based on Spore package format


Modding Reference by Category

Sims 3 :DBPF | File Types | RCOL(Scene) | Catalog Resource | String Table | Key Table | TS3 Programmer's Reference 

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox