cat and dat files - enenra/x4modding GitHub Wiki

Overview

Cat and Dat files are the primary Archive files for X4 and older X Titles.

Purpose and content

In their current iteration the .dat File contains the Data of all files concatenated together. The .cat has the file paths and names, the file size (in bytes), the edit date (in UNIX time; seconds since 1970-01-01 00:00:00), and a md5 checksum. All of them are seperated by Spaces (Note that the File name may contain Spaces, too, so just using it like a csv with space as seperator wont work.)

here the 10.cat as example

t/0001-L007.xml 2900301 1544183042 bc28da05640bfcc53abfe60557241d76
t/0001-L033.xml 2453352 1544104415 aabdb19ca1dc762cf3978d0933835e56
t/0001-L034.xml 2466378 1544104415 dbc0b74b5d580c6e9410d12ac4567b7c
t/0001-L039.xml 2479298 1544104415 9dba6305c669e817e14865391acf9e5c
t/0001-L044.xml 2328924 1544030715 d7daad3fe6824a232e07c29650ad3106
t/0001-L049.xml 2576875 1544183042 e045fc693e19506f44b1aa9ea7c8ce54
t/0001-L055.xml 2414806 1544104415 bbffe0ba9a0bb7fb1c4bee7721f16239
t/0001-L081.xml 2458031 1544183042 4e252589db4943aec3a1e7152746ae14
t/0001-L082.xml 2570391 1544183042 652590b3729035ac30f46de52fa2e827
t/0001-L086.xml 2273020 1544183042 5901b25626d155b9127d0b3636e68c0c
t/0001-L088.xml 2273022 1544183042 3232d8c35b46ce72b25fa7e56756d499

Loading order/Priority of cat/dat files

(TODO: check if the unix timestamp has any relevancy here) Cat/Dat files are loaded in a virtual file System for the Game, and when an already existing file is encountered it is overwritten. Load order is:

  • Plain files in Game Root
  • 01.cat/dat
  • 02.cat/dat
  • .....
  • 99.cat/dat
  • ( Plain files in Game Root if parameter -prefersinglefiles is set ) (TODO: needs verification, might even be after subst cat/dats)
  • => now the extensions are loaded following mod dependencies
  • subst_01.cat/dat (into the root directory, possibly overwriting core files)
  • subst_02.cat/dat
  • ......
  • subst_99.cat/dat
  • plain files in extension directory
  • ext_01.cat/dat (into the extension directory)
  • ext_02.cat/dat
  • ......
  • ext_99.cat/dat

Extraction of cat/dat files

Official Tools (Name suggests X Rebirth, but they also work for X4)

Full game extraction Script for these

When installing manually install the X Rebirth Tools next to the Game directory (not inside) in a Folder usually named "X Rebirth Tools" create a new "extract X4.bat" file there with the content:

RD /S /Q "..\X4 Foundations\X4_extracted"
mkdir "..\X4 Foundations\X4_extracted"
XRcatTool.exe -in "..\X4 Foundations\01.cat" "..\X4 Foundations\02.cat" "..\X4 Foundations\03.cat" "..\X4 Foundations\04.cat" "..\X4 Foundations\05.cat" "..\X4 Foundations\06.cat" "..\X4 Foundations\07.cat" "..\X4 Foundations\08.cat" "..\X4 Foundations\09.cat" "..\X4 Foundations\10.cat" -out "..\X4 Foundations\X4_extracted"

Third party Tools