What you get
- Your app answers "Is it compatible?" before the player starts the game.
- Your app merges most clashes. The player does not pick one mod.
- After a game update, your app finds each mod that hides Valve edits, and it can repair that mod.
- Your app shows the player what each mod changes.
- Mods with no companion load as they do today.
The cost is a decompile step, a patch step, and a compile step. Your app runs the compile step only for a clash or a repair.
What a companion is
A companion is one .patch file that ships next to a mod VPK. The VPK holds the full mod and loads as it is. The companion holds a plain diff for each game file that the VPK replaces.
# spec: diffmod/v1
# decompiler: source2viewer-cli/20.1
# title: Compact HUD
--- a/panorama/layout/hud.xml
+++ b/panorama/layout/hud.xml
@@ -2,6 +2,7 @@
<styles>
<include src="s2r://panorama/styles/hud.vcss_c" />
<include src="s2r://panorama/styles/hud_common.vcss_c" />
+ <include src="s2r://panorama/styles/compact_hud/main.vcss_c" />
</styles>
The file name makes the pair. The companion of pak50_dir.vpk is pak50_dir.vpk.patch in the same folder. Each VPK has at most one companion. All header keys are optional.
What to build
- Find each pair. A file whose name ends in
.vpk.patchis a companion. Remove.patchfrom the name to get its VPK, in the same folder. If that VPK is absent, skip the companion and warn. - Keep each pair. If your app renames a VPK, rename its companion to match.
- Check each pair. Do this on install and after each game update. See Check a pair.
- Find clashes. A mod VPK changes each game file that it replaces. Two mods clash on a file if both change it.
- Rebuild each clashed file. See Rebuild a file.
- Find stale files. Do this after each game update. See Repair after a game update.
- Do nothing else. With no clash and no stale file, load each VPK as it is.
Check a pair
- Decompile each file in the mod VPK that the companion covers.
- Reverse apply the companion to those files.
- If the reverse apply fails, warn. Treat the VPK as a VPK with no companion.
- If the reverse apply succeeds, keep the result. It is the game file that the mod maker used.
(cd vpk-copy && git apply -R -p1 --check ../pak50_dir.vpk.patch)
Rebuild a file
- Decompile the game copy of the file. This is the base.
- Apply each companion that covers the file, in the mod order of the player.
- If a companion does not apply, leave it out of that file. Warn, and name the mod and the file.
- Compile the result with the CSDK resourcecompiler.
- Pack all rebuilt files into one VPK. That VPK must take priority over each mod VPK.
New files, such as the style sheet in the example above, still load from the mod VPKs.
If a VPK with no companion replaces the file, use its decompiled copy as the base. See spec rule 18.
Repair after a game update
- Check each pair again. The check gives the game file that the mod maker used.
- Compare that file with the game copy of today.
- If they differ, the VPK copy is stale. It hides Valve edits.
- Offer a rebuild of that file, and let the player decide.
A game update makes a VPK copy stale only if Valve edited that same file.
Tools
- Decompile with Source2Viewer-CLI. Compile with the CSDK resourcecompiler. The Deadlock profile gives the paths and the commands.
- Version 1 covers
.xml,.cssand.jsfiles. For other files, the last load wins, as it does today. - After each build, show the game build id, the decompiler version and the spec version. Let the player copy them into a bug report.
- If the
decompilerkey of a companion differs from your decompiler, warn and proceed.
Reference and questions
- The strict rules for companions are spec rules 12 to 19.
- Modbox is the reference tool for the decompile, patch and compile steps. It does not read companions yet. Its mods folder holds several example mods as plain DiffMods, with no VPK.
- Questions and ideas go to Discussions. Defects in the rules go to the issue tracker.
- If your app reads companions, tell us. The player guide lists such apps.