Settlers V - Heritage Of Kings BBA

From XentaxWiki
Jump to: navigation, search

Choose archive extension:

BBA


Format Specifications

char {3}     - Header (BAF)
byte {1}     - Version (2)
uint32 {4}   - Archive Length [+8]

char {3}     - BAH Header (BAH)
byte {1}     - BAH Version (2)
uint32 {4}   - BAH Length (8)
uint32 {4}   - Unknown (3)
uint32 {4}   - Unknown (0) (Demo)/(1) (Full Version)

char {3}     - File Data Header (BAf)
byte {1}     - File Data Version (2)
uint32 {4}   - File Data Length

// File Data
{

// Uncompressed File
{
byte {X}     - File Data
}


// Compressed File
{
uint32 {4}   - Compression Header (0x0637f2bd)
uint32 {4}   - Data Length
{
uint32 {4}   - Compressed Size
uint32 {4}   - Decompressed Size
uint32 {4}   - Adler-32
byte {X}     - File Data
}
}

}


byte {3}     - Directory Header (BAd)
byte {1}     - Directory Version (2)
uint32 {4}   - Directory Length

// Directory
{

byte {3}     - File Entries Header (BAe)
byte {1}     - File Entries Version (2)
uint32 {4}   - File Entries Length


// File Entries Data
{
uint32 {4}   - Compression Header (0x0637f2bd)
uint32 {4}   - Data Length
{
uint32 {4}   - Compressed Size
uint32 {4}   - Decompressed Size
uint32 {4}   - Adler-32


// Directory (Encrypted with a modifiet TEA Algorithm and compressed using ZLib)
// When decompressed, the directory has the following structure
{
uint32 {4}   - Number Of Files


// for each file
{
uint32 {4}   - File Type Identifier (also compression identifier)


if (fileTypeID == 1)
{
// directory
uint64 {8}   - null
uint16 {2}   - Directory Name Length
uint16 {2}   - Number of characters from the start of the dirname that provide the parent directory
int32 {4}    - Offset of the first child
int32 {4}    - Offset of the next file or -1 if this is the last file
uint64 {8}   - null
char {X}     - Directory Name
byte {0-7}   - Padding to multiple of 4 bytes
}
else
{
// file
uint32 {4}   - Offset
uint32 {4}   - Decompressed File Size
uint16 {2}   - Filename Length
uint16 {2}   - Number of characters from the start of the filename that provide the directory
int32 {4}    - -1
int32 {4}    - Offset of the next file or -1 if this is the last file
uint64 {8}   - Timestamp
char {X}     - Filename
byte {0-7}   - Padding to multiple of 4 bytes
}
}
}
}
}


byte {3}     - BAh Header (BAh)
byte {1}     - BAh Version (2)
uint32 {4}   - BAh Length (depends on the Number of Files)
// BAh Data (hashtable)
{
uint32 {4}   - Hashtable size (Bah Length - 4) / 8
// A hashtable element has the following structure
{
uint32 {4}   - Filename hashvalue
uint32 {4}   - BAe offset
}
}
}

}

MultiEx BMS Script

Not written yet

Notes and Comments

  • ZLib Compression is used extensively in this archive
  • The Full Version uses a modifiet TEA Algorithm to encrypt the Directory.
  • File Type ID Numbers
    • 0 = Uncompressed File
    • 1 = Directory
    • 2 = Compressed File
      • Filetypes: fdb, fx, lua, txt, xml
  • The timestamp is the Windows FILETIME.
  • Initial value for Adler-32 checksums: 0x01BB7353 (29061971)
    • Note: This is the birthday of Dietmar Meschede, the Lead Programmer of the game :)
  • The BAe data is a directory Tree with "." as its root.
    • Every file entry has a Next File and First Child information.
    • If the file entry is a directory use the First Child to switch in this directory. First Child points on the first file there. First Child is always -1 (0xFFFFFFFF) if the file entry is a(n un-)compressed file.
    • Use Next File to get the offset of the next file or directory in the current directory. Next File is -1 (0xFFFFFFFF) there are no more files in the current directory.
  • The hashtable includes some empty elements. Each element has a size of 8 Bytes (hashvalue of a filename + offset of the file in the BAe data).
    • The first element always seems to be the offset to the root (".") of the directory tree.
    • The hashtable can be used for faster access to the file data. But there are some collisions of hashvalues in big archives. So you have to check the filename too.
    • A special algorithm is used to place the data at the right position.



Compatible Programs