Map Exchange String Format

Enhance your gameplay with these tools. This category is also the right place for tools useful for modders.
Mod databases, calculators, cheatsheets, multiplayer, scripts, libs and other useful stuff that is not strictly in-game mods.
Post Reply
Lexxy Fox
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sun Jan 01, 2017 3:32 am
Contact:

Map Exchange String Format

Post by Lexxy Fox »

I needed to know the format of the map exchange string for... reasons... and I couldn't find a reference anywhere (it probably already exists somewhere), so for future reference here's a description of the format. I'd love to add this to the wiki as soon as I can (or somebody else with permissions can if they'd like instead). EDIT: I've been accepted, yay! This information is now located at https://wiki.factorio.com/Map_Exchange_String_Format. I might make a fancy HTML5 encoder/decoder utility thingy for this too, or something... maybe.

First, strip those >>> and <<<. The data is base 64 encoded as defined by RFC 4648 (or 3548, 2535, 2045, 1421, et al.). All numerical values are stored in unsigned little-endian format. I'll 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.

Map Exchange String format
The version number of the Factorio that generated the string is stored as a series of four shorts - one for each part of the version number (and then a forth unknown). This method of serializing the version number is seen elsewhere in Factorio files. In the map exchange string, the version number is used to determine the formatting scheme. We'll use version 0.14.21 as example.
  • Short - Factorio's major version number. (e.g. 0)
  • Short - Factorio's minor version number. (e.g. 14)
  • Short - Factorio's patch version number. (e.g. 21)
  • Short - A forth unknown part of the version number. My Factorio sets this to 0, and doesn't seem to care what it is.
  • 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.
  • Bytes - 0.15 Map settings. See wiki page for details.
  • 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.)
Ore_def Ore Definitions
See the wiki about map generation for more info about frequency, size, and richness.
  • String - Ore name.
  • Byte - Ore frequency.
  • Byte - Ore size.
  • Byte - Ore richness.
Magnitudes (Frequencies / Sizes / Richness)
These are the values used for the frequencies, sizes, and richnesses of ores, water, and the starting area size. None is a valid value for all three options. Anything greater than 5 will crash the game!
  • 0 = None / None / None
  • 1 = Very Low / Small / Poor
  • 2 = Low / Small / Poor
  • 3 = Normal / Medium / Regular
  • 4 = High / Big / Good
  • 5 = Very High / Big / Good
Final Notes
Last edited by Lexxy Fox on Mon May 01, 2017 10:00 pm, edited 2 times in total.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Map Exchange String Format

Post by Rseding91 »

You probably won't like the 0.15 exchange string size :P

It's about 3 times larger with all the map settings saved in it.

Also I fixed the "crashes the game" part for 0.15 when things are invalid.
If you want to get ahold of me I'm almost always on Discord.

Lexxy Fox
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sun Jan 01, 2017 3:32 am
Contact:

Re: Map Exchange String Format

Post by Lexxy Fox »

Rseding91 wrote:You probably won't like the 0.15 exchange string size :P

It's about 3 times larger with all the map settings saved in it.

Also I fixed the "crashes the game" part for 0.15 when things are invalid.
I came back from derping around with Stardew Valley for a few months only to find a map exchange string this long? Worst game ever 0/10.

Haha just kidding, I love the new update, and Factorio is even more awesome than ever. Congrats to all the staff and devs for all the work on the update :)

I updated the wiki page for 0.15 stuff. Not going to bother to copy it here though. Link here: https://wiki.factorio.com/Map_Exchange_String_Format

Also, thanks for fixing that. I promise to continue to try to break your game the best I can.

peyo
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed May 17, 2017 4:33 pm
Contact:

Re: Map Exchange String Format

Post by peyo »

Hi there !

First of all, thanks Lexxy Fox for your work =)
I've a (maybe stupid) question for those who played around with the map exchange string format.

I'm writing a parser (with great success until the 0.15 specific part) and I get inconsistent value in the steering.default section for force_unit_fuzzy_goto_behavior (that is supposed to be a boolean) as I get 0x33 (51 in decimal).

After extracting a new Map exchange string, assuming every needed info is in there), the pollution (in the 0.15 specific map settings section) is at offset 0x135.
This particular byte seems to be a boolean (0x00 or 0x01, yay!).
After that, there should be 13x64bits values (13x8bytes so 104 bytes after the pollution boolean) and again a boolean.

In the Map exchange strings that I've extracted and parsed (latest alpha version, just updated today), I've got a consistent 0x33 value (so no boolean).
If I keep checking for a bool value (according to the wiki page) I still don't get a boolean 3x8bytes after. Padding issue in the documentation? pebkac on my side?
Am I doing something wrong there ?
Any idea ?

Thanks!

NB: I'm using those as ressources : viewtopic.php?f=69&t=39257 and Lexxy Fox MES wiki page ( https://wiki.factorio.com/Map_Exchange_String_Format )

Edit: exact version : {'major': 0, 'minor': 15, 'patch': 12, 'reserved': 0}

treverios
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sun Dec 17, 2017 8:33 pm
Contact:

Re: Map Exchange String Format

Post by treverios »

Were there changes in the map exchange string with 0.16 apart from the cliff? I don't get normal values anymore.

Post Reply

Return to “Tools”