Difference between revisions of "Sims 3:DBPF"
HugeLunatic (Talk | contribs) |
(→The Index: Nearly total rewrite. I got bitten and misled by the original description. Careful analysis of a lot of .package files (and testing using code) has been performed.) |
||
Line 31: | Line 31: | ||
== The Index == | == The Index == | ||
If ''position'' is not zero, at that position: | If ''position'' is not zero, at that position: | ||
− | |||
− | + | DWORD ;; Index Type | |
− | + | <Index Header> | |
+ | <Index Entry>[number of index entries] | ||
− | The number of | + | ''Note: The [number of index entries] value in the [[#Package Header|Package Header]] '''excludes''' the Index Header.'' |
− | + | Each Index Entry (and the Index Header) contains a variable number of '''DWORD''' fields in the following order: | |
− | + | ||
− | + | {|class="wikitable" | |
− | {| class="wikitable | + | |
|- | |- | ||
− | |0 | + | ![[#Index Type|Bitfield]] |
− | |ResourceType | + | !colspan=2|Field |
+ | |- | ||
+ | |style="text-align: center;"|0 | ||
+ | |'''ResourceType''' | ||
| | | | ||
|- | |- | ||
− | |1 | + | |style="text-align: center;"|1 |
− | |ResourceGroup | + | |'''ResourceGroup''' |
|Top byte is a set of flags | |Top byte is a set of flags | ||
|- | |- | ||
− | |2 | + | |style="text-align: center;"|2 |
− | |InstanceHi | + | |'''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 (lo 31bits) , Unknown1 (hi bit) | + | |'''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''' |
|} | |} | ||
− | |||
− | + | === 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== | ==Chunk Compression== |
Revision as of 17:55, 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 |
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 |
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
The Index
If position is not zero, at that position:
DWORD ;; Index Type <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 |
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
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 |