[File decoder] - StarMade-Decoder

    Joined
    Jun 29, 2013
    Messages
    146
    Reaction score
    65
    • Modder
    • Legacy Citizen 4
    • Purchased!
    Hi everyone,

    After more than 10 years since the original SMDecoder (PHP/Node.js, 2015), I've done a complete rewrite of the project as a modern TypeScript SDK.

    The new project is called StarMade-Decoder and supersedes this one entirely.

    What changed
    Old SMDecoder (PHP/Node.js)New StarMade-Decoder (TypeScript)
    PHP class + early Node.js portPure TypeScript, ESM, Node.js ≥ 20
    .smd2 format (pre-release era).smd3 + .smd2 retrocompat
    Partial: .smbpm brokenAll formats fully implemented
    No write supportFull read and write / round-trip
    No typed APIComplete typed domain objects
    No tests525 passing tests, 99% coverage
    Supported formats (new)
    FormatReadWrite
    .ent (Ship, Station, Player, Shop, Asteroid)✅✅
    .fac (Factions)✅✅
    .cat (Catalog)✅✅
    .tag (Trading, Chat, NPC)✅✅
    .sim (Simulation state)✅✅
    .smd3 (Block segments)✅✅
    .sment (Blueprint archive)✅
    .smtpl (Template)✅✅
    .smbpl (Logic/control links)✅✅
    .smbpm (Metadata)✅
    .smbmm (Mod mappings)✅
    .smbph (Blueprint header)✅✅
    BlockConfig.xml✅✅
    server.cfg✅✅
    blockBehaviorConfig.xml✅✅
    FactionConfig.xml✅✅
    Quick example
    JavaScript:
    import { registerAllFactories, Ship, FactionManager, Catalog, writeTo } from 'starmade-decoder';
    import fs from 'node:fs';
    
    registerAllFactories();
    
    // Read a ship
    const ship = Ship.fromBuffer(fs.readFileSync('ENTITY_SHIP_MyShip.ent'));
    console.log(ship.uniqueId, ship.realName, ship.sectorPosition.toString());
    
    // Rename it and write back
    const renamed = ship.withRealName('Explorer MkII');
    fs.writeFileSync('ENTITY_SHIP_MyShip.ent', writeTo(renamed.toTag()));
    
    // Read factions
    const factions = FactionManager.fromBuffer(fs.readFileSync('FACTIONS.fac'));
    for (const f of factions.playerFactions) {
    console.log(`[${f.id}] ${f.name} — ${f.memberCount} members`);
    }
    Links
    This project is the foundation I'm using for StarMade-DB (HSQLDB module) and future tooling around the StarMade ecosystem.

    Feedback and contributions welcome.
     
    Last edited:
    • Like
    Reactions: Calbiri
    Joined
    Jun 20, 2013
    Messages
    461
    Reaction score
    71
    • Legacy Citizen 3
    • Purchased!
    • Community Content - Bronze 1
    i see .smskin is not in the list? could you add that
    Je vois que .smskin n'est pas dans la liste tu peux l'ajouter un jour?
     
    Joined
    Jun 29, 2013
    Messages
    146
    Reaction score
    65
    • Modder
    • Legacy Citizen 4
    • Purchased!
    Yes, I can see for implementing *.smskin. Format .*sment are not yet implemented

    Oui, je peux voir pour implémenter le *.smskin. Le format *.sment n'est pas encore implémenté lui aussi.
     
    • Like
    Reactions: testkil
    Joined
    Jun 29, 2013
    Messages
    146
    Reaction score
    65
    • Modder
    • Legacy Citizen 4
    • Purchased!
    I've updated SMDecoder for Starmade 0.175

    Change-log:
    • Update to StarMade 0.175
    • Added support for .sment (not for docked parts)
    • Added support for .smskin
    • Improve formating code
     
    • Like
    Reactions: Megacrafter127
    Joined
    Jun 29, 2013
    Messages
    146
    Reaction score
    65
    • Modder
    • Legacy Citizen 4
    • Purchased!
    New update, SMDecode is also available for node.js!
    Put the file to your server folder and add
    Code:
    SMD = require('./SMDecoder.js')
    to load it.
    .sment reader is not yet implemented in SMDecoder.js
     
    Joined
    Jun 29, 2013
    Messages
    146
    Reaction score
    65
    • Modder
    • Legacy Citizen 4
    • Purchased!
    Hello evrybody! Somes news about this project :)

    I've completly rewrite the SMDecoder class for php, now you'll have two file, std.php with two class, Binary and StreamReader.
    The Binary class is a simplified version of my old binary decoder (13 functions to 5 functions).
    The StreamReader privide basic fonctions to open end read file byte by byte.
    This file can be used without SMD and for other project than StarMade.
    BTW SMDecoder was fully rewrite to use thoses class and actually seems to read every starmade files (but i need to do more test).
    At last i curently rewrite all the formating functions and i think that i'll switch to a xml format because it's seems to be more appropriate with the default decoded format.

    I think the update will come really soon.
     
    Joined
    Jun 29, 2013
    Messages
    146
    Reaction score
    65
    • Modder
    • Legacy Citizen 4
    • Purchased!
    I've updated SMDecoder for Starmade 0.19+

    Change-log:
    • Move binary decoder inside std.php
    • Move stream read functions inside std.php
    • Update decoder for dev build 0.19+
    • Need fix for *.smbpm format
    • Need fix for format functions