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 with its
byte layout, 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, so opening and saving it in that editor produces a different map.
What the editor does with it#
The editor keeps every section in the order it found it, repeats included, and reproduces the game's reading when it decodes them. 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
that has to be added, because the map had none and an edit created one, goes in among the
others at the place StarEdit would put it rather than at the end. Bytes after the last
section are kept as well, unless the Save dialog is told to drop them.
Two consequences are worth knowing:
- A file another editor wrote with a section this one does not model keeps that section. Nothing is lost by opening a map here, whatever made it.
- Repeated sections stay repeated. If you want a protected map flattened into one clean copy of each section, that is a deliberate choice: the Save dialog's Merge repeated sections into one tick does it using the same rules the game uses, and the Repair plugin explains each finding before it changes anything.
Every piece of text in the map lives in one string table, STR
(or STRx on a Remastered map), and the other sections point into
it by number. Because raw sections keep pointing at the numbers they were written with,
the editor never renumbers the table on save; a string that stops being used is blanked,
not removed.
Neither table says how its bytes spell characters; the STR page says what StarEdit
wrote and how each version of the game reads it. The editor follows the game's reading:
a table that is valid UTF-8 is UTF-8; otherwise every legacy encoding that decodes the
bytes without error is scored by how much of the non-ASCII text falls in its own script,
and the best guess is shown in Scenario ▸ Map Revision for the user to correct. Korean and Chinese bytes are
often valid in each other's encoding, so a tie goes to Korean. The table is written back
in the encoding chosen, ? standing in for a character it cannot hold, which Check Map
and the Save dialog report first. stat_txt.tbl and the other game tables are read the
same way, so a localized install names its units in its own language.