Difference between revisions of "Sims 3:DBPF"

From SimsWiki
Jump to: navigation, search
 
m (The Index: Explicitly refer (non-link) to the Index Type subsection)
 
(30 intermediate revisions by 6 users not shown)
Line 1: Line 1:
Package Header - 96 bytes: "standard" DBPF 2.0 format; DBBF not seen.
+
{{TS3AdvancedModdingHeader}}
  
Code:
+
==DBPF Packages==
DWORD    magic ;; "DBPF"
+
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:
DWORD    major ;; 2
+
{| class="wikitable" border="1"
DWORD    minor ;; 0
+
|-
BYTE[24] unknown1
+
|*.package
DWORD    ;; number of index entries - if zero, size and position also zero
+
|General collection of resources
BYTE[4]  unknown2
+
|-
DWORD    ;; size of index on disk in bytes
+
|*.world
BYTE[12] unknown3
+
|Resources comprising a "world"
DWORD    ;; is always 0x00000003 ?
+
|-
DWORD    ;; position of index (absolute)
+
|*.dbc
BYTE[28] unknown4
+
|Collection of DBPF archives in a single archive
There are a number of different index formats. The Spore ones are newer than the Sims3 ones, we think, as they use an extra type bit - and the DBBF files!
+
|}
  
If position is not zero, at that position:
+
== Package Header ==
DWORD ;; Index type
+
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
  
The count of set bits in the index type is the number of additional DWORD entries in index header:
+
== The Index ==
DWORD[(for each bit in Index type)]
+
If ''position'' is not zero, at that position:
  
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.
+
DWORD ;; Index Type, see subsection below
 +
<Index Header>
 +
<Index Entry>[number of index entries]
  
;; For each index entry on disk:
+
''Note: The [number of index entries] value in the [[#Package Header|Package Header]] '''excludes''' the Index Header.''
DWORD[(8 - number of bits in Index type)]
+
  
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):
+
Each Index Entry (and the Index Header) contains a variable number of '''DWORD''' fields in the following order:
0 - ResourceType
+
1 - ResourceGroup
+
2 - InstanceHi
+
3 - InstanceLo
+
4 - Chunkoffset ;; Absolute location in package
+
5 - Filesize ;; Length of data in package
+
6 - Memsize ;; Length of uncompressed data
+
7 - Compressed(lo WORD) | Unknown2(hi WORD) ;; 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..!)
+
{|class="wikitable"
 +
|-
 +
![[#Index Type|Bitfield]]
 +
!colspan=2|Field
 +
|-
 +
|style="text-align: center;"|0
 +
|'''ResourceType'''
 +
|
 +
|-
 +
|style="text-align: center;"|1
 +
|'''ResourceGroup'''
 +
|Top byte is a set of flags
 +
|-
 +
|style="text-align: center;"|2
 +
|'''InstanceHi'''
 +
|
 +
|-
 +
|style="text-align: center;"|3
 +
|'''InstanceLo'''
 +
|
 +
|-
 +
|style="text-align: center;"|4
 +
|'''Chunkoffset'''
 +
|Absolute location in package
 +
|-
 +
|style="text-align: center;"|5
 +
|'''Filesize''' (lo 31bits), '''Unknown1''' (hi bit)
 +
|Length of data in package
 +
|-
 +
|style="text-align: center;"|6
 +
|'''Memsize'''
 +
|Length of uncompressed data
 +
|-
 +
|style="text-align: center;"|7
 +
|'''Compressed''' (lo WORD), '''Unknown2''' (hi WORD)
 +
|Compressed is '''0x0000''' or '''0xFFFF'''
 +
|}
  
By Peter Jones
+
=== 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]]
 +
 
 +
 
 +
{{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