DLTX - Differential LTX Loading [updated 25th September 2021]
Modding STALKER has this annoying tendency to result in conflicts when two different mods overwrite the same file, but not the same variables and sections within that file. DLTX aims to mitigate this by allowing a mod author to only override the values that they actually wish to change in a separate file, which should greatly reduce the amount of needless mod conflicts and the need to manually merge mods.
How do I install it?
Back up the contents of your "bin" folder and replace it with the one supplied. The contents of "tools" and "example_mod" include optional resources to make mods for DLTX or to convert existing ones. If you are using Mod Organizer 2 do NOT use it to install DLTX (you can still use it for other mods), you need to paste the files into your real "bin" folder.
How do I use it as a player?
Nothing should change from how you normally install mods, except hopefully alot more of them should work without issues once people decide to use this format. However you could try to convert mods yourself if you're having alot of mod conflicts.
How do I use it as a modder?
In order to make a differential change to the LTX records, you have to follow these steps:
1. Find out which root LTX file is loading the variable you are trying to modify. You can either search the files manually and trace back the chain of #includes, or you can use LTXDiff for this purpose.
LTXDiff findroot [Base Folder] [Mod Folder] [Relative Path to File]
2. Once you have found the root file, create a new one in the same directory with the name "mod_[name of the root file]_[name of your choosing].ltx".
3. Make an entry for the section and variable that you want to modify. The section that you want to override has to be prefixed with "!", e.g. ![medkit]. You do not need to include the sections parents again (i.e. do ![medkit], NOT ![medkit]:booster_multi), since they already are in the base definition. Now simply list your variables that you want changed as you usually would.
You can add parents by declaring them like you normally would, or remove them by prefixing them with "!", e.g. "![vodka2]:!vodka, medkit" makes vodka2 behave like a medkit instead of its original parent.
If you want to delete a variable, simply add a line "!variable_name". You can delete sections too, by prefixing them with "!!", however they will only be deleted if all variables they own are deleted too, otherwise the flag won't come into effect.
You can only override sections that already have a base definition. Both loading an override without a base section, or loading multiple base sections will cause crashes. Multiple overrides can be applied to the same section. If multiple mods override the same value, the one that is loaded last will win the conflict over that particular variable. I haven't verified what actually affects the load order, but I'm going to guess it's probably based on the alphabetic order of the file names.
Converting already existing mods
LTXDiff is capable of automatically converting conventional mods into a DLTX-ready format.
LTXDiff dltxify [Base Folder] [Mod Folder] [Mod Suffix]
Mod suffix in this case is the name that gets appended to the mod files, like in step 2 of the previous section.
Building the modified executables yourself
If you want to build the binaries by yourself, or just take a look at the code, or are the Anomaly dev team and want to include this code in your next release, I've supplied a diff patch in "other_stuff". To apply it you need a git client and Anomaly's XRay Engine at version 1.5.1 . Run the following commands once you have git installed:
git clone https://bitbucket.org/anomalymod/xray-monolith.git
cd xray-monolith
git apply "/your/path/to/other_stuff/differential-ltx-loading.diff"
Once the patch is applied, add "mezz_stringbuffer.cpp" to the project "XrCore" in visual studio, now you should be able to compile Anomaly as you normally would.
Current known Issues:
- Attempting to override weathers is going to cause a crash. The game loads any loose files in environment/weathers/ as root files, which inadvertently loads any mod files as a rootfile, without any base definitions.
Credits:
Feel_Fried - FDDA animation bug fix, loose file particle loading
Changes
v7:
- Added loose file particle loading. Files in the "particles" folder with the extensions *.pg and *.pe will override their counter parts from particles.xr (contributed by Feel_Fried)
- Binaries for this release were compiled by Feel_Fried, so hopefully russian keyboard layouts should work again.
v6.1:
- Fixed a bug where inherited sections would be applied in reverse
v6:
- Fixed deletions not working correctly at all
- Incorporated FDDA animation bug fix
v5:
- The order in which sections are listed in a file is largely irrelevant now. Sections can inherit from other sections that appear later in the file, and overrides no longer need to come strictly after a base section, as long as one exists at all. Order still matters for override conflict resolution, i.e. if two overrides change the same value, the one that comes later in the file wins the conflict.
- Removed "mod__[...]" files, due to order independent loading making them purpose free.
- Fixed a bug where certain rootfiles would inadvertently apply the wrong mod file to themselves due to ambiguous naming. If a mod file name could be applied to multiple root files, only the one with the longest fitting name will be picked.
v4:
- Added the ability to properly modify section parents. Parents can be added, by declaring them normally on an override section header, and removed by prefixing an added parent with "!"
- Added another automatic include for files named "mod__[rootfilename]_[suffix].ltx" (two underscores after "mod"), that get loaded before the root file does, which can be used to define base sections that can then later be used to be injected as parents, since they get loaded before everything else.
v3:
- Fixed a crash related to stack allocated string buffers not being cleaned up properly and causing corruption when very long LTX entries would be loaded.
v2:
- Fixed a bug where the last line of a root file would sometimes be swallowed, which would make overriding cause the game to fail loading
- Overrides now apply retroactively, which means that any sections that have a parent with overrides, are now affected by those too
- Added the ability to delete variables and sections. Variables are deleted by prefixing them with "!", sections with "!!". Sections are only deleted if they are fully empty, otherwise the delete flag has no effect.
LTXDiff
Github.com
Old versions:
Drive.google.com