.cps/stm file format

  • Marte2007
    11th Oct 2011 Member 0 Permalink
    Can someone explain me the format of .cps and .stm files? Are they the same? I know that the C of CPS is for "compressed", but how? Thanks
  • mniip
    11th Oct 2011 Developer 0 Permalink
    STM: remove first 12 bytes (or so)
    then use bz2 to decode, that's pure content, test, test and test, get what number what means
  • Ximon
    11th Oct 2011 Administrator 0 Permalink
    CPS actually stands for "Crappy Poo Save"
  • THElagB3AST
    11th Oct 2011 Member 0 Permalink
    @Simon- (View Post)
    Really? Just Really?
  • boxmein
    11th Oct 2011 Former Staff 0 Permalink
    @Lord-Spectre (View Post)
    They're both the same, it's just that stamps have a variable width/height
    Format is:
    Magic number (3 Bytes):
    'PSv'
    Saved settings (1 Byte):
    Bit 0: Legacy mode
    Bit 1: Pause mode
    Bit 2-3: Gravity mode
    Bit 4-6: Air mode
    Bit 7: Newtonian gravity mode
    Game version (1 Byte)
    Cell size (1 Byte)
    Width, in cells (1 Bytes)
    Heigth, in cells (1 Bytes)
    Unzipped size of the save data (4 Bytes)
    Save data, zipped with bzip2:

    All walls (1 Byte each)
    For FANs: X speed (1 Byte each)
    For FANs: Y speed (1 Byte each)
    All particles, types (1 Byte each)
    Particles X speed (1 Byte each)
    Particles Y speed (1 Byte each)
    Particles life (2 Byte each)
    Particles tmp (2 Byte each)
    Particles deco alpha (1 Byte each)
    Particles deco red (1 Byte each)
    Particles deco green (1 Byte each)
    Particles deco blue (1 Byte each)
    Particles temperature (2 Byte each)
    Particles ctype, only for CLNE, PCLN, BCLN, SPRK, LAVA & PIPE (1 Byte each)
    Number of signs (1 Byte)
    Then for each sign:

    X position (2 Bytes)
    Y position (2 Bytes)
    Text align (1 Byte)
    Length of text (1 Byte)
    Text (IV Bytes)

    EOF(End of File)
    Thank you, JoJoBond.
  • JoJoBond
    11th Oct 2011 Member 0 Permalink
    @boxmein (View Post)
    There were some minor changes to this, in the recent versions. Each PBCN adds a additional byte for its tmp2-value right after the regular tmp-values. There are some additional elements that have their ctype saved. But the rest should still be good.
  • Marte2007
    11th Oct 2011 Member 0 Permalink
    I don't understand the data inside the bzipped part, the actual save...
  • boxmein
    11th Oct 2011 Former Staff 0 Permalink
    This is the saving function, http://pastebin.com/wCsHL7zK
    The compressing function is
    BZ2_bzBuffToBuffCompress((char *)(c+12), (unsigned *)&i, (char *)d, p, 9, 0, 0)
    To decompress it, just run
    BZ2_bzBuffToBuffDecompress(arguments);
  • Marte2007
    11th Oct 2011 Member 0 Permalink

    Lord-Spectre:

    I don't understand the data inside the bzipped part, the actual save...

    I already decompressed it, with Python's bz2.BZ2Decompressor, but I cannot understand the uncompressed data...
  • Videogamer555
    11th Oct 2011 Member 0 Permalink
    Where it says EOF does that mean that there is an End Of File symbol of some kind? If so, is this EOF symbol 1 byte in size? And what is the symbol?
Locked by Lockheedmartin: Necro