scmJS docs

The scenario

The scenario is a flat sequence of sections, each a four-character name, a length and that many bytes of data: MTXM holds the terrain, UNIT the placed units, TRIG the triggers. The CHK format reference has a page for every section, and explains what the game does when a file repeats a section or gives one an odd length. Map protectors rely on those cases: a protected map is written so that the game reads it correctly and a naive editor reads it wrongly.

What the editor does with it#

The editor keeps every section in the order it found it, repeats included, and reads them the way the game does. Opening a protected map shows what the game would show.

On save, only the sections you changed are written from the editor's own model. Edit a trigger and TRIG is re-encoded; every other section, known or not, is written back from the bytes it came in with, in its original order and with its original repeats. A section an edit creates goes in where StarEdit would put it, not at the end. Bytes after the last section are kept too, unless the Save dialog is told to drop them. So:

Every piece of text in the map lives in one string table, STR (or STRx on a Remastered map), and other sections point into it by number. The editor reads STRx where the game does, in a VER 64 or 206 file, and there it wins over STR. A STRx in any other revision is kept in the file as it is, and the editor shows the STR text players see. The editor never renumbers the table on save, since sections it carries as bytes still point at the old numbers; a string that stops being used is blanked, not removed. STR counts its offsets in 16 bits, so its text must fit in 64 KB: Save refuses a map whose strings run past that, and Check Map says which. Shorter text, or a Remastered revision with STRx, fixes it. A table the map was opened with is written back as the file had it until some text in it changes, so only an edited one can be refused.

The table does not say which character encoding its text is in. The editor guesses as the game would read it and shows the guess in Scenario ▸ Map Revision, where you can change it. The text is written back in that encoding; a character it cannot hold becomes ?, which Check Map and the Save dialog report. The STR page says how the guess is made.

Known and unknown sections#

The CHK format reference lists every section the editor knows. It decodes all of them into its own model and re-encodes them when you change them, except VCOD, IVER and IVE2, which it only carries as bytes. Any other section is carried through untouched. Tools ▸ Check Map reports a section the game requires and the file lacks as an error.

Two sections are rewritten without an edit, because the game would refuse the file as it stands:

Sections a map may not have#

ISOM, MASK, WAV , CRGB, SWNM, the CUWP slots and every settings table may be missing from a map, and the editor does not add one to a file that had none: a map without MASK stays without it, rather than gaining an all-clear fog table. The one exception is a change of revision, below. The game is stricter. A melee game never reads MASK, the CUWP slots or the settings tables, but a Use Map Settings game needs them and stops at the start without them (see What a map needs). The editor shows a map with no MASK fully fogged, which is how a melee game starts. A map with no ISOM cannot use the isometric brush until the record is rebuilt.

scmJS 0.18.0 · Generated from the repository. The source is under the MIT license, which does not cover what ATTRIBUTION.md lists. StarCraft and Brood War are trademarks of Blizzard Entertainment; this project ships none of their data.