Files
WT-Offline/mod-dev-docs/en/02-client-packs-and-blk.md
T

54 lines
2.7 KiB
Markdown

# 02 · Client Packs & BLK Incremental Patching
## 1. Supported `.vromfs.bin` Packs
Place overlays under `client/packs/<pack-path>/`:
- **Always rebuilt from stock**: `char.vromfs.bin`, `aces.vromfs.bin`, `gui.vromfs.bin`
- **On-demand backup & restore**: `lang.vromfs.bin`, `mis.vromfs.bin`, `game.vromfs.bin`, `ui/atlases.vromfs.bin`, `ui/images.vromfs.bin`
Because the local server extracts static datasets directly from the overlaid packs on startup, vehicles added or edited in `shop.blk` and `wpcost.blk` automatically flow into research trees, prices, modifications, AI pools, and offline store bundle GUIDs.
---
## 2. File Handling Rules
1. **`<target>.patch.jsonc`** — Type-preserving structured BLK patch applied to `<target>` inside the pack.
2. **`<target>.patch.csv`** — Semicolon-separated localization CSV merger keyed by column 0.
3. **Any other file** — Added or replaced directly. Plain text `.blk` files are compiled to binary BLK automatically before packing.
---
## 3. BLK Patch Operations (`*.blk.patch.jsonc`)
Every patch file has `{ "ops": [...] }`. Path segments support indexed sibling selectors such as `"range[2]"` (zero-based).
- **`setParam`**: `{ "op": "setParam", "path": [...], "name": "...", "value": ..., "createBlocks": false }`
- **`addParam`**: appends a repeated parameter without removing existing entries (ideal for `slaveUnit`, `folder`, `aircraftGift`).
- **`removeParam`**: removes all matching params by `name` (or only those matching optional `value`).
- **`upsertBlock`**: finds or creates a block along `path` and merges `block.params` and `block.blocks`.
- **`addBlock`**: inserts a new child block (`before` / `after` sibling anchor optional).
- **`removeBlock`**: deletes the block at `path`.
- **`cloneBlock`**: deep-clones an existing block (`from`) into `toParent` under `newName`, optionally applying nested `ops` rooted at the cloned block (fastest way to derive a modded vehicle in `wpcost.blk`).
### Explicit BLK Types
Use `{ "type": "<blkType>", "value": <val> }` whenever an exact Dagor BLK type is needed:
`string`, `int`, `real`, `bool`, `int64`, `point2`, `point3`, `point4`, `ipoint2`, `ipoint3`, `ipoint4`, `color` (`[r,g,b,a]` or packed `0xAARRGGBB`), `matrix` (12 reals).
---
## 4. Localization CSV Patches (`*.csv.patch.csv`)
```csv
"<ID|readonly|noverify>";"<English>";"<Chinese>";"<HChinese>"
"my_custom_tank_shop";"M1A2 Mod";"M1A2 魔改型";"M1A2 魔改型"
```
Existing keys update only the supplied non-empty language columns; new keys are appended cleanly.
---
## 5. Root `config.blk` Patches (`client/config-blk.patch.jsonc`)
Uses the exact same BLK patch format against `<copy>/config.blk`. The launcher backs up the stock `config.blk` automatically and restores it when no enabled mod patches it.