Protected maps
StarCraft reads a map differently from how a simple editor does, and a map can be "protected" by building it so that the game reads it correctly while an editor misreads it or gives up. None of it is encryption. Each trick relies on a rule on this page that the game follows and a simple reader does not, so a reader that follows the rules reads the map as the game does. The archive around the scenario has tricks of its own, such as a missing file list or a renamed scenario; those are in Opening and saving maps.
The table says what 1.16.1 does. Protectors write for Remastered, which differs on short
STR copies and checks string offsets, so a trick that works there may refuse the map in
1.16.1 or lose its text.
In the container#
| What the file does | What the game does | What a reader has to do |
|---|---|---|
| Repeats a section | Combines the copies by the section's rule (Repeated sections) | Keep every copy in file order and combine them by the same rule. A reader that takes the first copy, or the last, sees a decoy wherever the rule is a different one. |
| Gives the terrain or the fog a copy shorter than the section's size | Writes it over the start of the space, leaving the rest as it was | Start from a space of the full size and write every copy over it in turn. |
| Gives a section more bytes than it needs | Refuses the map, except for MTXM (up to 131,072 bytes), MASK, STR, and sections it never reads |
Nothing: such a map does not load. |
| Ends a record section in part of a record | Refuses the map | Nothing: such a map does not load. |
| Declares a length that runs past the end of the file | Stops walking there. It refuses the map if it reads that section, and does not mind if it never does | Keep what is there, and stop. |
| Declares a negative length | Moves backwards by that much and reads on from there, so bytes are read a second time as different sections. Remastered stops if the jump lands before the start of the file | Follow the jump. A reader that stops there misses the sections found after it. |
| Includes sections whose names mean nothing, or are not text at all | Passes over them | Pass over them rather than rejecting the file. |
| Leaves bytes after the last section | Ignores fewer than 8; reads 8 or more as another header | Keep them or drop them; they are not part of the map. |
| Puts the sections in an unusual order | Reads them in its own order whatever the file's | Do not depend on StarEdit's order. |
In the sections#
| Section | What the file does | What it means |
|---|---|---|
ISOM, TILE, DD2 |
Leaves them out, or fills them with zeros | The game never reads them, so the map plays the same. An editor loses the isometric brush, the ground under each doodad, and the doodads as objects it can select. ISOM can be rebuilt from the tiles (exactly where the terrain was painted isometrically), and a new TILE copied from MTXM, which gives back the ground but keeps the doodads' tiles in it. |
IVER, IVE2, IOWN, UPUS, SWNM, WAV |
Leaves them out | Only editors read these either. The switch names and the list of sounds are gone; the sounds themselves stay in the archive, and the trigger actions that play them still name them. |
STRx |
Adds a STRx with different text to a VER 205 file |
No game reads it there, so players see the STR text. A reader that prefers STRx wherever it finds one shows the decoy. |
STR |
Adds a 1-byte copy after the real string table | Remastered passes over a copy too short to hold its string count and reads the real table. 1.16.1 takes it, and the map loses its text. A reader that takes the last copy finds no text, and a file saved with only that copy no longer loads: Remastered says the scenario is intended for an expansion set. |
MTXM, MASK |
Splits them into several copies, some of them short or full of junk | Only the combined result counts: each copy written over the one before, in file order. A copy of junk followed by a full copy of the real terrain draws the real terrain. |
UNIT, THG2, TRIG, MBRF |
Splits the records across several copies | The copies are joined into one list, in file order. A reader that keeps only one copy loses units or triggers. Start locations come from the last UNIT copy only. |
STR |
Makes strings overlap, share bytes, or start inside the offset table | A string is whatever lies between its offset and the next 0 byte. Read each one from its own offset and assume nothing about where it sits. An editor that writes the table back has to lay the strings out afresh. |
ERA |
Sets bits above the low three | Brood War uses the low three bits. The original StarCraft refuses a value above 4. |
| Any section the game never reads | Fills it with junk, makes it any length, or ends the file inside it | No effect on the game. |
Reading a protected map#
A reader that does these things reads a protected map as the game does:
- Read the headers one after another, and keep every section with its place in the file, repeats included.
- At a negative length, follow the jump, as the game does. Guard against a jump that returns to a header already read with the same bytes after it, which would loop for ever.
- At a length past the end of the file, take the bytes that are there and stop.
- Pass over any name you do not know.
- Combine the copies of each section by its rule, the More than one copy row of its page. For the terrain and the fog, start from the size the page gives.
- Read each string from its own offset.
A map the game accepts has no partial records and no sections of the wrong length, so a reader that meets one is reading a map the game would refuse, or one the game never reads that part of. Writing the result back as one copy of each section, in StarEdit's order, gives an ordinary file that holds the same map.