The StarMade Template file format (smtpl)

    Joined
    Jan 22, 2014
    Messages
    1,047
    Reaction score
    299
    Since I needed a convenient way to edit around 120 template files (see recent dev versions), I took it upon myself to reverse engineer the corresponding file format. Here's what I got from 7 different template files.

    Each file consists of a Header, the blocks, and master/slave information. Origin for indeces seems to be the bottom/right/aft corner. All indeces are positive.

    I'll be using the following notation: (x, n), whereas x is the offset relative to the start of the section, and n is the number of bytes used (the length).
    Also, let a the number of blocks, let b the number of connections. Let i a value between 0 and a, let j a value between 0 and b.

    Header (0, 25):
    • 0, 1: Version information, currently always 0x01.
    • 1, 4: Unknown Int, values 0x06 and 0x08 were observed.
    • 5, 4: Unknown Int, the only value observed was 0x08.
    • 9, 4: Unknown Int, values 0x04, 0x06, 0x07 were observed.
    • 13, 4: Unknown Int, values 0x09, 0x0A, 0x0B were observed.
    • 17, 4: Unknown Int, values 0x09 and 0x0A were observed.
    • 21, 4: Unknown Int, the only value observed was 0x08.
    Blocks (25, 4 + 15a):
    • 0, 4: Number of blocks to follow (a).
    • 4 + 15i, 15: Block entry:
      • 0, 4: X coordinate.
      • 4, 4: Y coordinate.
      • 8, 4: Z coordinate.
      • 12, 3: The actual block, the same as in every other StarMade related file format.
    Connections (26 + 15a, 4 + 20b):
    • 0, 4: Number of connections to follow (b).
    • 4 + 20j, 20: Connection entry:
      • 0, 2: Unknown Int16, the only value observed was 0x0. Probably a filler.
      • 2, 2: Z coordinate of the master block.
      • 4, 2: Y coordinate of the master block.
      • 6, 2: X coordinate of the master block.
      • 8, 4: Unknown Int, the only value observed was 0x01.
      • 12, 2: Unknown Int16, the only value observed as 0x0. Probably a filler.
      • 14, 2: Z coordinate of the slave block.
      • 16, 2: Y coordinate of the slave block.
      • 18, 2: X coordinate of the slave block.

    This information is sufficient to parse template files, and to do simple block substitutions.

    Other observations: Blocks are not stored in any particular order. I've observed (X, Y, Z), as well as (-X, ?, -Z). Empty spaces are not stored, only blocks that are actually present make it into the file.
     

    NeonSturm

    StormMaker
    Joined
    Dec 31, 2013
    Messages
    5,110
    Reaction score
    617
    • Wired for Logic
    • Thinking Positive
    • Legacy Citizen 5
    • 8, 4: Unknown Int, the only value observed was 0x01.
    • 12, 2: Unknown Int16, the only value observed as 0x0. Probably a filler.
    How do you know it's 4+2 and not 2+4?

    Why are above coordinates 4 byte and not 2 like below?
    2 byte represent a value of a ship >16km in both directions from the core.​

    Thus you may think 0xXXXX as position X while it is actually 0xUUXX (U=unknown, X=position X)

    Makes some sense in code like X = readInt(); X2 = X >> 16; place 2 blocks.
     
    Joined
    Aug 23, 2013
    Messages
    29
    Reaction score
    23
    • Purchased!
    • Community Content - Bronze 1
    • Legacy Citizen 6
    How can I transfer old templates to the new versions?
    The old templates were .sment datatype, the new are .smtpl datatype
    Is there any chance to converte the old templaytes?
     

    therimmer96

    The Cake Network Staff Senior button unpusher
    Joined
    Jun 21, 2013
    Messages
    3,603
    Reaction score
    1,053
    • Legacy Citizen 10
    • Top Forum Contributor
    You're confusing blueprints with templates

    .sment contains the files needed to spawn a copy of a ship that has been saved

    .smtpl contains data used to paste copied parts that you've saved before. they can be placed on any entity as long as the build mode size is big enough.

    You can't convert between the 2.
     
    Joined
    Aug 23, 2016
    Messages
    758
    Reaction score
    129
    Last edited: