Hint: Simple Edit of existing Mod with .cat/.dat files without additional Tools

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
Kekser
Posts: 1
Joined: Tue, 24. Aug 10, 00:42
x4

Hint: Simple Edit of existing Mod with .cat/.dat files without additional Tools

Post by Kekser » Fri, 28. Jan 22, 21:15

Hello,

I found it a bit frustrating editing existing mods, which uses .cat / .dat files.
Why? My changes inside the .dat file never seemed to work. And I didn't want to install additional tools for my little Adjustments.

So I tried to do the needed steps manually - With success.

In this Thread I show you, how you can edit an existing Mod / Extension, which uses .cat and .dat files without installing any additional software.

My example: Editing the Priceranges of "Soaring Crystal Prices".

===========================================

Steps:
  • (Subscribed Steam Workshop Mods only) Copy the Extension Folder
  • (Subscribed Steam Workshop Mods only) Modify the content.xml
  • Edit the values in the dat files
  • Update the catalogue entries (Size + Hash)
  • Finish
===========================================

1. Copy the Extension Folder (Subscribed Steam Workshop Mods only)

Because Steam would try to update / repair subscribed mods you have to either "unsubscribe" or copy the existing folder, and rename it to something of your liking. It should be after the "original" mod in alphabetical order. (So it would be loaded later)

===========================================

2. Modify the content.xml (Subscribed Steam Workshop Mods only)


To prevent conflicts with the existing mod, you have to change the "id" in the content.xml. Example:

Original:

Code: Select all

<content ... id="ws_2528264659">
Copy:

Code: Select all

<content ... id="keksers_crystal_edit">

===========================================

3. Edit the values in the .dat file(s)

Now change the value(s) in the dat files with a Text Editor to your liking.

Example:
I changed the priceranges for some crystals.

Code: Select all

[...]
<replace sel="/wares/ware[@id='inv_crystal_02']/price">
	<price min="12000" average="22000" max="35000" />
</replace>
[...]
===========================================

4. Update the catalogue entries (Size + Hash)

While the game loads the extensions, it checks / loads the corresponding catalogue information (.cat File). Here two information have to be adjusted: The size in Bytes and the MD5 Hash of the File.

Example: Original ext_01.cat

libraries/wares.xml 677 1624716752 3ae5da638f859a9dfea80f99cae62b85

The "677" is the filesize in bytes of the ext_01.dat. You just have to change the size to the current one. (E.g. via file properties)
The "3ae5da638f859a9dfea80f99cae62b85" is the MD5 Hash of the file ext_01.dat. You can calculate the new hash via commandline Tools.

In Windows for example you can use a PowerShell Command:

Code: Select all

CertUtil -hashfile C:\X4\extensions\testextension\ext_01.dat MD5
You just have overwrite the existing Hash-Value with the new one.

In my case my changes were:
677 -> 679
3ae5da638f859a9dfea80f99cae62b85 -> 1a74414b26c80e8d83b6cfebe28085e0


===========================================

5. Finished!


Now your edited mod should work as expected.


Have fun!

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: Hint: Simple Edit of existing Mod with .cat/.dat files without additional Tools

Post by SirNukes » Sat, 29. Jan 22, 19:43

Kekser wrote:
Fri, 28. Jan 22, 21:15
The "3ae5da638f859a9dfea80f99cae62b85" is the MD5 Hash of the file ext_01.dat. You can calculate the new hash via commandline Tools.
The hash is for the particular subfile in the dat, hence why every subfile entry has its own hash. The game just doesn't require the hash to match.

HammerHead91
Posts: 217
Joined: Thu, 8. Apr 04, 21:55
x2

Re: Hint: Simple Edit of existing Mod with .cat/.dat files without additional Tools

Post by HammerHead91 » Tue, 16. Aug 22, 05:38

This is so helpful!

Post Reply

Return to “X4: Foundations - Scripts and Modding”