In the source
For developers. Everything above is implemented under src/formats/chk/ and
src/formats/mpq/, with the file-level policy in src/editor/:
| File | Does |
|---|---|
src/formats/mpq/scm.ts |
Opens and writes the archive over mopaq: finds staredit\scenario.chk, accepts a bare .chk, reports how the member was stored, keeps the other members. |
src/formats/chk/reader.ts |
Parses the chunk stream into a ChkFile: every occurrence in order, truncation and negative lengths recorded, trailing bytes kept. layer() reproduces the game's overwrite semantics. |
src/formats/chk/sections/registry.ts |
One entry per known section: combine mode, fixed size (some depend on the map's dimensions), record stride, and the editorOnly flag the Save dialog's strip groups are built from. |
src/formats/chk/scenario.ts |
The Scenario model, parseScenario and serializeScenario, the dirty set that decides what is re-encoded, the revision table, revisionSections for the settings pairs, and the insertion order for a section the file did not have. |
src/formats/chk/sections/*.ts |
The codecs: terrain, objects (units, sprites, doodads, locations), players, strings, settings, triggers, cuwp, sounds, and the vcod table. |
src/formats/chk/create.ts |
File ▸ New, and requiredSections(version), which Check Map tests a file against. |
src/editor/save.ts |
The save plan: strip groups, merging repeats with the registry's mode, the sector size per compression, and the warnings the dialog shows. |
src/editor/mapBuild.ts, src/services/mapBuild.ts |
Built maps: packing the step's output with the source beside it, restoring the source on open, and running the steps without letting one cost a save. |
src/editor/sections.ts |
Section-level reads and writes for the Section Explorer plugin and api.document.sections. |
src/editor/validate.ts |
Check Map. |
src/data/triggerDefs.ts, src/formats/triggers/text.ts |
Which field of a trigger record holds which argument, and the text format. |
The rules that matter when changing any of it:
- Any code that mutates the scenario has to mark every section it touched dirty, or the change never reaches the file.
- To model a new section: add a codec under
sections/, decode it inparseScenario, add a case toencodeSection, add it toMODELLED_SECTIONS, and add a round trip totests/chk.test.ts. - Optional sections are
nullin the model when the file had none, and the encoder omits them then. Do not write a zeroed one. - The tests re-encode Blizzard's own maps byte for byte:
tests/chk.test.ts,tests/save.test.ts,tests/settings.test.ts,tests/data-settings.test.ts,tests/trigger.test.ts,tests/briefing.test.tsandtests/cuwp.test.tsrun againstfixtures/maps/*.scx, which is gitignored (Blizzard data) and skipped when absent. A green run on a clone without the fixtures has not exercised them.