scmJS docs

STR

The string table. Every piece of text in the map is here, and other sections refer to it by number: the scenario name and description, force names, location names, custom unit names, switch names, sound file names, and the text and sounds of trigger actions.

The section starts with the number of strings, then one offset per string, counted from the start of the section, and then the text. Each string ends with a 0 byte. String numbers count from 1: the first offset is string 1. Several strings may share the same offset, and a string may start partway into another, sharing its end. Because the offsets are 16-bit, every string has to start within the first 64 KB of the section; only the last one may run on past it. A table too big for that needs fewer or shorter strings, or STRx in a Remastered file. When an edited table does not fit, scmJS points each string that is the end of another into it and puts the longest string last, and will not save a table that still does not fit. A table that has not been edited is saved as it was read.

Every read of the map reads STR again, and a map without one is shown in the map list as Invalid Scenario, not under its file name. StarCraft 1.16.1 shows the first 31 bytes of the scenario's name and the first 255 of its description. Remastered's map list shows the whole description, and as much of the name as fits on two lines, with an ellipsis after it. Its lobby and game keep only the first 31 bytes of the name, counted after the name is turned into UTF-8 whatever the file holds: ten Korean syllables, where a CP949 file holds them in 20 bytes. A long name in Latin letters is cut shorter still, to the room the lobby has. Both games show the first 29 bytes of a force's name. (Remastered's limits found playing it.)

The table does not say how its bytes spell characters. StarEdit wrote the code page of the Windows it ran on: EUC-KR (CP949) for Korean, Shift_JIS for Japanese, GBK or Big5 for Chinese, Windows-1251 for Russian, Windows-1252 for the rest. 1.16.1 reads a file in the code page of the machine it runs on. Remastered decides string by string: UTF-8 when the bytes are valid UTF-8, Korean (CP949) when they pass its Korean test, and Windows-1252 for anything else. So a Japanese, Chinese or Russian map that is not UTF-8 shows garbled text in Remastered whatever the player's Windows.

The Korean test only asks that every byte above 127 be followed by a byte from 0x41 to 0xFE. Western text in Windows-1252 can pass it: a capital À to Æ, or a curly quote or dash, followed by a letter, or two accented letters in a row. Remastered then turns each part of the string between colour codes into Korean where every such pair is a Korean character, and leaves the other parts as Windows-1252. On an English copy of Remastered, a map whose text was stored in Windows-1252 showed "Ärger Don’t" as "훣ger Don뭪" and "Größe" as "Gr秤e", in the map list, the lobby and the game, while "Défense España" and "café" stayed as written: an accented small letter followed by a plain letter is not a Korean character, and one followed by a space or the end of the text fails the test. (Read in Remastered's code and found playing it.) Writing the table as UTF-8 avoids it.

scmJS reads the table as UTF-8 when it is valid UTF-8. Otherwise it tries each legacy code page above, keeps those that decode the bytes without error, and scores each by how much of the non-ASCII text falls in that code page's own script. Korean and Chinese bytes are often valid in each other's code page, so a tie goes to Korean; when nothing scores, the guess is Windows-1252, which decodes anything. The guess is shown in Scenario ▸ Map Revision, where it can be corrected, and the table is written back in the encoding chosen, with ? for a character it cannot hold.

Name STR␠ (53 54 52 20)
Size Whatever the text needs.
Read by The game, every time it reads the map: for the map list, at the start of every game, and for the briefing.
Required Yes. Without it the map list shows the map as Invalid Scenario, and it cannot be played.
The game accepts Any length.
More than one copy The last copy replaces the others, whatever its length: a copy of 1 byte replaces the real table, and the map loses its text. Remastered passes over a copy shorter than 2 bytes, and in a VER 64 or 206 file a STRx of 4 bytes or more replaces it.
In scmJS Read, and written again when you change what it holds.

Layout:

Offset Type Holds
0 u16 How many strings there are
2 u16 × that many Where each string starts, counted from the start of the section
after the offsets text The strings, each ending in a 0 byte

A string runs from its offset to the next 0 byte, and nothing else marks where it ends. So two strings can share their bytes, one string can be the end of another, and an offset can point anywhere in the section, the offset table included. 1.16.1 checks neither the count nor the offsets against the section's length: an offset at or past the end reads whatever lies after the table in memory, so an editor has to read it as no string. A string number past the count is an empty string. Remastered checks both, and shows <MISSING> for a string that falls outside the table: a map whose last STR copy holds no strings is listed with <MISSING> as its name and description (found playing Remastered).

StarEdit writes a table of 1024 strings, and points every unused one at a single 0 byte straight after the offsets: an empty string. Blizzard's maps are laid out this way.

Example#

A table of three strings, the first and the third the same text. The third shares the first one's bytes, and the lone 0 after the offsets is where an unused string would point:

   0  03 00                    3 strings
   2  09 00                    string 1 starts at 9
   4  0F 00                    string 2 starts at 15
   6  09 00                    string 3 starts at 9
   8  00                       a lone 0: an empty string
   9  48 69 6C 6C 73 00        "Hills" and its 0
  15  46 6F 72 63 65 20 31 00  "Force 1" and its 0

Control codes#

Bytes 0x01 to 0x1F in a string are not characters. Most set the colour of the text after them, and a few align it, hide it or cut it short. Editors write them as <XX>, the byte in hexadecimal, and the game draws the text from the byte where the code stands. In 1.16.1 each new line of a string starts in the default colour again; in Remastered a colour carries on to the next line of the same string. In both games <01> goes back to the colour before the last change, one step only, and once the text is grey (<05>) every later colour code in the string is ignored, <01> included.

Byte Written What it does
0x01 <01> Previous colour (the one before the last change)
0x02 <02> Colour: Cyan (#b8b8e8)
0x03 <03> Colour: Yellow (#dcdc3c)
0x04 <04> Colour: White (#ffffff)
0x05 <05> Colour: Grey (#847474)
0x06 <06> Colour: Red (#c81818)
0x07 <07> Colour: Green (#10fc18)
0x08 <08> Colour: Red — player 1 (#f40404)
0x09 <09> Tab
0x0A <0A> Newline
0x0B <0B> Invisible
0x0C <0C> Remove beyond (newline in the small font)
0x0D <0D> Carriage return
0x0E <0E> Colour: Blue — player 2 (#0c48cc)
0x0F <0F> Colour: Teal — player 3 (#2cb494)
0x10 <10> Colour: Purple — player 4 (#88409c)
0x11 <11> Colour: Orange — player 5 (#f88c14)
0x12 <12> Right align
0x13 <13> Centre align
0x14 <14> Invisible
0x15 <15> Colour: Brown — player 6 (#703014)
0x16 <16> Colour: White — player 7 (#cce0d0)
0x17 <17> Colour: Yellow — player 8 (#fcfc38)
0x18 <18> Colour: Green — player 9 (#088008)
0x19 <19> Colour: Brighter yellow — player 10 (#fcfc7c)
0x1A <1A> Nothing
0x1B <1B> Colour: Pinkish — player 11 (#ecc4b0)
0x1C <1C> Colour: Dark cyan — player 12 (#4068d4)
0x1D <1D> Colour: Grey-green (#74a47c)
0x1E <1E> Colour: Blue-grey (#9090b8)
0x1F <1F> Colour: Turquoise (#00e4fc)

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.