All Rust maps (apart from ones that are made by Facepunch and saved as an Unity scene), are stored in a .map file. When first joining a server that is running a procedural map, Rust will generate the map from the following information:
|
Size |
Seed |
Map Type |
|
1000-6000 |
0-2147483647 |
Procedural Map |
The map is then saved into a .map file, and can be found in the Rust install directory inside the maps folder. The map filename will be named MapType.Size.Seed.map
Custom maps are essentially a pre-generated map, which is downloaded from an URL rather than being generated based on certain values.
Data Format
Map files are stored in the format below, and compressed using a "legacy" LZ4Stream. They first contain the World Serialization number, currently 10 (4 bytes), then a timestamp (8 bytes) and then the WorldData. To decompress the map, see the following snipped below. Note: this is done using K4os.Compression.LZ4.Legacy.
Decompress the map:
public static byte[] DecompressRustMap(Stream stream) {
stream.Seek(4 + 8, SeekOrigin.Begin);
using var lz4 = LZ4Legacy.Decode(stream);
using var ms = new MemoryStream();
lz4.CopyTo(ms);
return ms.ToArray();
}
The WorldData is stored in the following format:
public class WorldData
{
[ProtoMember(1)] public uint size = 4500;
[ProtoMember(2)] public List<MapData> maps = new List<MapData>();
[ProtoMember(3)] public List<PrefabData> prefabs = new List<PrefabData>();
[ProtoMember(4)] public List<PathData> paths = new List<PathData>();
}
The MapData contains a layer (Ground, Biome, Heightmap etc) and the corresponding ByteMap. It is stored in the following format:
public class MapData
{
[ProtoMember(1)] public string name;
[ProtoMember(2)] public byte[] data;
}
The PrefabData contains info on the ID of the prefab, and it’s world space values. It is stored in the following format:
public class PrefabData
{
[ProtoMember(1)] public string category;
[ProtoMember(2)] public uint id;
[ProtoMember(3)] public VectorData position;
[ProtoMember(4)] public VectorData rotation;
[ProtoMember(5)] public VectorData scale;
}
The PathData contains info on the Rivers and Roads of the map. It is stored in the following format:
public class PathData
{
[ProtoMember(1)] public string name;
[ProtoMember(2)] public bool spline;
[ProtoMember(3)] public bool start;
[ProtoMember(4)] public bool end;
[ProtoMember(5)] public float width;
[ProtoMember(6)] public float innerPadding;
[ProtoMember(7)] public float outerPadding;
[ProtoMember(8)] public float innerFade;
[ProtoMember(9)] public float outerFade;
[ProtoMember(10)] public float randomScale;
[ProtoMember(11)] public float meshOffset;
[ProtoMember(12)] public float terrainOffset;
[ProtoMember(13)] public int splat;
[ProtoMember(14)] public int topology;
[ProtoMember(15)] public VectorData[] nodes;
}
Information gathered provided by the Rust Map Making community.