Migrate from GitHub to SourceForge with this tool. Check out all of SourceForge's recent improvements.
Close

Home

Greg Janik
Attachments
HashCheck.zip (1987295 bytes)
MLFiles.zip (95378 bytes)

MCPK Format Specification

A lot of the content for CitiesXL is compressed into archives (CXLRA, for CitiesXL Resource Archives). Here is what is known about the format:

The following is a description of the file format/encoding used in the CitiesXL resource archives (.pak and .patch files, among others). I had a really hard time finding this information in English. I figured this would be as good a place as any to post an English version. Big thanks to the people at Xentax Forum for most of the initial work in reverse engineering the format, and to Arcadoli at Generation-City.com for sending me a pretty neat document describing the format in French.

  1. File Name
    File names should end in .pak, .patch, .sgbin, .land, .sav, or .ava
  2. File Format
    All ints are 4 bytes and little-endian
    1. Header, 0x30 bytes
      1. 0x4D43504B
        ASCII text, always "MCPK"
      2. version, int
        The version of the game this file is built for. Almost all files are version 3. However, there are about 5-10 that are actually version 2 and don't follow this format
      3. build, int
        The build number of the game this file is built for
      4. sha1Hash, 20 bytes
        SHA-1 hash of this file from 0x30 (inclusive) to the end of this file, including encrypted file table
      5. fileTableAddress, int
        The offset of the file table from the start of this file (see 2.3)
      6. fileCount, int
        The number of files contained in this archive
    2. File contents, from 0x30 (inclusive) to fileTableAddress (exclusive)
      Each compressed file (not all are necessarily compressed) is individually deflated using zlibdd>
    3. File table, encrypted by RC4 using the MD5 hash of "allocator" as the key
      1. Table Entries, each entry specifies a file in this CXLRA
        1. compressedSize, int
          The size of the archived file within this archive, in bytes
        2. size, int
          The size of the archived file after decompression with zlib
        3. address, int
          The offset of the archived file in this archive
        4. sha1Hash, 20 bytes
          SHA-1 hash of the decompressed file pointed to by this table entry
        5. compression, int
          If the archived file is compressed, this integer is equal to 0. Otherwise, it is 0x00000100. Some files, such a small text files and most PNG files, are actually larger when deflated for storage in a CXLRA. A few are even the same size. Always check these bits to determine if the file needs to be inflated with zlib.
        6. nameLength, int
          The size of the name of the archived file, including the null terminator
        7. name, variable size
          The null-terminated name of the archived file