Mapdev:SMF format: Difference between revisions

From Spring
Jump to navigationJump to search
m added more info
m to match source code
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= SMF Reference =
= SMF(Spring Map File) Reference =
SMF(Spring Map Format)
SMF is a binary format
* [https://github.com/spring/spring/blob/2e5bc43dc464ec27d6b880d105f0c618e07c4ff8/rts/Map/SMF/mapfile.h mapfile.h]
* [https://github.com/spring/spring/blob/2e5bc43dc464ec27d6b880d105f0c618e07c4ff8/rts/Map/SMF/SmfMapFile.cpp SmfMapFile.cpp]


= File Location =
== File location ==
./maps/mymapname.smf
maparchive.sd7/maps/mymapname.smf


= Binary Format =
== Data Map ==
{| class="wikitable" width="100%"
* smu = spring map unit, the size you see when in the lobby. roughly between 2 and 64.
|+ align="left" | SMF File
|
{| class="wikitable" width="100%"
{| class="wikitable" width="100%"
|+ align="left" | Header
|+ align="left" | Header
!Magic !! Version !! MapID !! Xsize !! Ysize
! style="width: 20%" | Bytes
! style="width: 20%" | Type !! Description
|-
| 16 || <code>char[]</code> || Magic number; "spring map file\0"
|-
| 4 || <code>int</code> || Version number; "1"
|-
| 4 || <code>unsigned int</code> || ID, should be as unique as possible.
|-
| 4 || <code>int</code> || Width; smu * 64
|-
| 4 || <code>int</code> || Length; smu * 64
|-
| 4 || <code>int</code> || Square size; 8
|-
| 4 || <code>int</code> || Texels per square size; 8
|-
| 4 || <code>int</code> || Tile size; 32
|-
| 4 || <code>float</code> || Depth/min height; 512 = 1*smu
|-
| 4 || <code>float</code> || Height/max height; 512 = 1*smu
|-
| 4 || <code>int</code> || Byte offset to start of height map
|-
|-
|(c_str)`spring map file' || (int)1 || 32bit uInt  || Int || int
| 4 || <code>int</code> || Byte offset to start of type map
|-
|-
! Square Size !! texel/square !! tile size !! minHeight !! maxheight !! ExtraHdrs
| 4 || <code>int</code> || Byte offset to start of tile index
|-
|-
| (int)8 || (int)8 || (int)32 || float || float || (int)1
| 4 || <code>int</code> || Byte offset to start of mini map
|-
|-
! heightPtr !! typePtr !! miniPtr !! tilesPtr !! metalPtr !! featurePtr
| 4 || <code>int</code> || Byte offset to start of metal map
|-
|-
| int || int || int || int || int || int
| 4 || <code>int</code> || Byte offset to start of features map
|-
|-
| colspan=7 |
| 4 || <code>int</code> || No of extra headers
|}


{| class="wikitable" width="100%"
{| class="wikitable" width="100%"
|+ align="left" | Extra Header(s)
|+ align="left" | + Extra Headers
! Extra Header Size !! Extra Header Type !! vegitationPtr
! style="width: 20%" | Bytes
! style="width: 20%" | Type !! Description
|-
| 4 || <code>int</code> || Size of the header
|-
| 4 || <code>int</code> || Type of header
|-
|-
| (int)12 || (~int)MEH_Vegetation || (int)
| * || * || Data of header
|}
 
|}
|}
 
*
*
*
{| class="wikitable" width="100%"
{| class="wikitable" width="100%"
|+ align="left" | +HeightMap
|+ align="left" | + Height Map
| Array of [xsize+1]*[ysize+1] unsigned short
! style="width: 20%" | Bytes
! style="width: 20%" | Type !! Description
|-
| (width+1)*(length+1) || <code>unsigned short[]</code> || Data for height map.
|}
|}


{| class="wikitable" width="100%"
{| class="wikitable" width="100%"
|+ align="left" | +TypeMap
|+ align="left" | + Type Map
| Array of [xsize/2]*[ysize/2] char(0-255)
! style="width: 20%" | Bytes
! style="width: 20%" | Type !! Description
|-
| (width/2)*(length/2) || <code>char[]</code> || Data for type map.
|}
|}


{| class="wikitable" width="100%"
{| class="wikitable" width="100%"
|+ align="left" | +MiniMap
|+ align="left" | + Mini Map
| 1024x1024 raw DXT1 image data (NO metadata)
! style="width: 20%" | Bytes
! style="width: 20%" | Type !! Description
|-
| 699048 || <code>char[]</code> || raw DXT1 compressed 1024x1024 image.
|}
|}


{| class="wikitable" width="100%"
{| class="wikitable" width="100%"
|+ align="left" | +TileHeader
|+ align="left" | + Tile Index Header
|  
! style="width: 20%" | Bytes
! style="width: 20%" | Type !! Description
|-
| 4 || <code>int</code> || Number of tile files
|-
| 4 || <code>int</code> || Total number of tiles in all files.
|}


{| class="wikitable" width="100%"
{| class="wikitable" width="100%"
|+ align="left" | MapTileHeader
|+ align="left" | + SMT File Infos
! #Files !! #Tiles
! style="width: 20%" | Bytes
! style="width: 20%" | Type !! Description
|-
|-
| Int || Int
| 4 || <code>int</code> || Number of tiles in this file
|-
| size of filename || <code>char[]</code> || The filename of the smt.
|}
|}
|
*
*
*
{| class="wikitable" width="100%"
{| class="wikitable" width="100%"
|+ align="left" | For each external Tile File:
|+ align="left" | + Tile Index
! #Tiles in file !! #Tile Filename
! style="width: 20%" | Bytes
|-
! style="width: 20%" | Type !! Description
| Int || c_str
|}
|-
! #Internal Tiles !! New Tile Filename
|-
| Int || c_str
|-
|-
| colspan=2 |
| (width / 4) * (length / 4) || <code>int[]</code> || Index numbers of tiles in SMT's
{| class="wikitable" width="100%"
|+ align="left" | TileMap
| Array of [Ysize/4]*[Xsize/4] int containing tile # used
|}
|}
|}


{| class="wikitable" width="100%"
{| class="wikitable" width="100%"
|+ align="left" | +MetalMap
|+ align="left" | + Metal Map
| Array of [Ysize/2]*[Xsize/2] char (0-255) containing metal density
! style="width: 20%" | Bytes
! style="width: 20%" | Type !! Description
|-
| (width / 2) * (length / 2) || <code>char[]</code> || Metal Density
|}
|}


{| class="wikitable" width="100%"
{| class="wikitable" width="100%"
|+ align="left" | +VegitationMap
|+ align="left" | + Features Header
| Array of [Ysize/4]*[Xsize/4] char (0-255) used as boolean
! style="width: 20%" | Bytes
! style="width: 20%" | Type !! Description
|-
| 4 || <code>int</code> || Number of features
|-
| 4 || <code>int</code> || Number of feature types
|-
| * || <code>char[]</code> || List of feature names delimited by null
|}
|}


{| class="wikitable" width="100%"
{| class="wikitable" width="100%"
|+ align="left" | +FeatureMap
|+ align="left" | + Features
|
! style="width: 20%" | Bytes
{| class="wikitable" width="100%"
! style="width: 20%" | Type !! Description
|+ align="left" | MapFeatureHeader
|-
! # Features !! # FeatureTypes
| 4 || <code>int</code> || Type of feature, corresponds with feature name list.
|-
|-
| int || int
| 4 || <code>float</code> || X Position (along the width of the map)
|}
|
{| class="wikitable" width="100%"
|+ align="left" | For each TreeType a c_str:
| 'TreeType' + int + null
|}
aka: {TreeType0,TreeType1,TreeTypeX, TreeTypeN}
|-
|-
! Geovents
| 4 || <code>float</code> || Y Position (Up into the sky)
| rowspan=2 |
{| class="wikitable" width="100%"
|+ align="left" | For each additional feature type"
! Feature Name
|-
|-
| C_str
| 4 || <code>float</code> || Z Position (along the length of the map)
|} (ie. from fs.txt)
|-
|-
|(c_str)'Geovent'
| 4 || <code>float</code> || rotation, not sure of scale
|-
|-
| colspan=2 |
| 4 || <code>float</code> || relative size (not implemented); 1
|}
*
*
*
 
== Optional Extra Headers & data ==
{| class="wikitable" width="100%"
{| class="wikitable" width="100%"
|+ align="left" | MapFeatureStruct:(1 for each feature on map)
|+ align="left" | + Grass Extra header
! featureType !! xPos !! yPos !! zPos !! Rotation !! relativeSize
! style="width: 20%" | Bytes
! style="width: 20%" | Type !! Description
|-
| 4 || <code>int</code> || Size of the header; 12
|-
|-
| Int || Float || Float || Float || Float || (float)1
| 4 || <code>int</code> || Type of header; 1
|}
|-
| 4 || <code>int</code> || Byte offset to beginning of grass map
|}
|}
{| class="wikitable" width="100%"
|+ align="left" | + Grass Data
| style="width: 20%" | (width / 4) * (length / 4)
| style="width: 20%" | <code>unsigned char</code>
| Map defining the grass on the map. not sure what 256 available values mean.
|}
|}
Notes:
*Sometimes I've given the 'effective' format, not what the game actually uses.
*When I say something like 'c_str' I mean an array of char with terminating null.
*Never include `'"{}s. 
*Pointers are all offsets (in 8bit char's) from the beginning of the file.
*MapID is just gibberish that is[or should] only used to identify two almost identical maps as different.
----
The SMT description will hopefully appear in the future.
Double check this information, no guarantees.
--[[User:Mother|Mother]] 23:29, 21 Dec 2005 (W. Europe Standard Time)
== Additional Info ==
* [https://github.com/spring/spring/blob/2e5bc43dc464ec27d6b880d105f0c618e07c4ff8/rts/Map/SMF/mapfile.h mapfile.h]
* [https://github.com/spring/spring/blob/2e5bc43dc464ec27d6b880d105f0c618e07c4ff8/rts/Map/SMF/SmfMapFile.cpp SmfMapFile.cpp]
* [http://springrts.com/phpbb/viewtopic.php?f=13&t=20337 Forum Thread with more info]




[[Category:Mapdev]]
[[Category:Map Dev]]
[[Category:Development]]

Latest revision as of 07:53, 3 October 2014

SMF(Spring Map File) Reference

SMF is a binary format

File location

maparchive.sd7/maps/mymapname.smf

Data Map

  • smu = spring map unit, the size you see when in the lobby. roughly between 2 and 64.
Header
Bytes Type Description
16 char[] Magic number; "spring map file\0"
4 int Version number; "1"
4 unsigned int ID, should be as unique as possible.
4 int Width; smu * 64
4 int Length; smu * 64
4 int Square size; 8
4 int Texels per square size; 8
4 int Tile size; 32
4 float Depth/min height; 512 = 1*smu
4 float Height/max height; 512 = 1*smu
4 int Byte offset to start of height map
4 int Byte offset to start of type map
4 int Byte offset to start of tile index
4 int Byte offset to start of mini map
4 int Byte offset to start of metal map
4 int Byte offset to start of features map
4 int No of extra headers
+ Extra Headers
Bytes Type Description
4 int Size of the header
4 int Type of header
* * Data of header
+ Height Map
Bytes Type Description
(width+1)*(length+1) unsigned short[] Data for height map.
+ Type Map
Bytes Type Description
(width/2)*(length/2) char[] Data for type map.
+ Mini Map
Bytes Type Description
699048 char[] raw DXT1 compressed 1024x1024 image.
+ Tile Index Header
Bytes Type Description
4 int Number of tile files
4 int Total number of tiles in all files.
+ SMT File Infos
Bytes Type Description
4 int Number of tiles in this file
size of filename char[] The filename of the smt.
+ Tile Index
Bytes Type Description
(width / 4) * (length / 4) int[] Index numbers of tiles in SMT's
+ Metal Map
Bytes Type Description
(width / 2) * (length / 2) char[] Metal Density
+ Features Header
Bytes Type Description
4 int Number of features
4 int Number of feature types
* char[] List of feature names delimited by null
+ Features
Bytes Type Description
4 int Type of feature, corresponds with feature name list.
4 float X Position (along the width of the map)
4 float Y Position (Up into the sky)
4 float Z Position (along the length of the map)
4 float rotation, not sure of scale
4 float relative size (not implemented); 1

Optional Extra Headers & data

+ Grass Extra header
Bytes Type Description
4 int Size of the header; 12
4 int Type of header; 1
4 int Byte offset to beginning of grass map
+ Grass Data
(width / 4) * (length / 4) unsigned char Map defining the grass on the map. not sure what 256 available values mean.