Map exchange string format: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:


The outer layer of the map exchange string format includes three angle brackets on either side: ">>>" and "<<<", which must be present for Factorio to accept the string. Between those two tokens is the map exchange data, encoded using base 64 as defined by [https://tools.ietf.org/html/rfc4648#section-4 RFC 4648] (or [https://tools.ietf.org/html/rfc3548#section-3 3548], [https://tools.ietf.org/html/rfc2535#page-42 2535], [https://tools.ietf.org/html/rfc2045#section-6.8 2045], [https://tools.ietf.org/html/rfc1421#section-4.3.2.4 1421], et al.) All numerical values are stored in unsigned [https://en.wikipedia.org/wiki/Endianness#Little-endian little-endian] format. This document will use the terms "int" to refer to 4 byte numbers and "short" to refer to 2 byte numbers. Strings are [https://en.wikipedia.org/wiki/String_(computer_science)#Length-prefixed Pascal-style int length prefixed strings]. The format described below is valid at least for Factorio 0.14.x, other versions may use a different version scheme.
The outer layer of the map exchange string format includes three angle brackets on either side: ">>>" and "<<<", which must be present for Factorio to accept the string. Between those two tokens is the map exchange data, encoded using base 64 as defined by [https://tools.ietf.org/html/rfc4648#section-4 RFC 4648] (or [https://tools.ietf.org/html/rfc3548#section-3 3548], [https://tools.ietf.org/html/rfc2535#page-42 2535], [https://tools.ietf.org/html/rfc2045#section-6.8 2045], [https://tools.ietf.org/html/rfc1421#section-4.3.2.4 1421], et al.) All numerical values are stored in unsigned [https://en.wikipedia.org/wiki/Endianness#Little-endian little-endian] format. This document will use the terms "int" to refer to 4 byte numbers and "short" to refer to 2 byte numbers. Strings are [https://en.wikipedia.org/wiki/String_(computer_science)#Length-prefixed Pascal-style int length prefixed strings]. The format described below is valid at least for Factorio 0.14.x, other versions may use a different version scheme.
{| class="wikitable"
| short[4]
| The version of Factorio that generated this string, used to determine encoding format.
|-
| byte
| Water frequency.
|-
| byte
| Water size.
|-
| ore_def[int]
| An array of ore definitions (described later). The array length is stored as an integer prefix. Factorio doesn’t care what order these are in, but it always alphabetizes during export. Vanilla has six ores: coal, copper-ore, crude-oil, enemy-base, iron-ore, and stone. Unknown ores are ignored and missing ores are set to their defaults.
|-
| int
| Map seed.
|-
| int
| Map width.
|-
| int
| Map height.
|-
| byte
| Starting area size.
|-
| byte
| Peaceful mode. Enabled if set to 1, disabled otherwise.
|-
| int
| CRC32 checksum of all preceding data, as defined by ANSI X3.66 / FIPS 71 / ITU-T V.42 (the same one used by zlib, ethernet, etc.)
|}

Revision as of 03:24, 8 January 2017


This is a technical description of the map exchange string format, used to share map generating configurations with other users.

The outer layer of the map exchange string format includes three angle brackets on either side: ">>>" and "<<<", which must be present for Factorio to accept the string. Between those two tokens is the map exchange data, encoded using base 64 as defined by RFC 4648 (or 3548, 2535, 2045, 1421, et al.) All numerical values are stored in unsigned little-endian format. This document will use the terms "int" to refer to 4 byte numbers and "short" to refer to 2 byte numbers. Strings are Pascal-style int length prefixed strings. The format described below is valid at least for Factorio 0.14.x, other versions may use a different version scheme.

short[4] The version of Factorio that generated this string, used to determine encoding format.
byte Water frequency.
byte Water size.
ore_def[int] An array of ore definitions (described later). The array length is stored as an integer prefix. Factorio doesn’t care what order these are in, but it always alphabetizes during export. Vanilla has six ores: coal, copper-ore, crude-oil, enemy-base, iron-ore, and stone. Unknown ores are ignored and missing ores are set to their defaults.
int Map seed.
int Map width.
int Map height.
byte Starting area size.
byte Peaceful mode. Enabled if set to 1, disabled otherwise.
int CRC32 checksum of all preceding data, as defined by ANSI X3.66 / FIPS 71 / ITU-T V.42 (the same one used by zlib, ethernet, etc.)