.cmap format documentation

You have suggestions or want to give feedback to the game or the forum? Post it here!
Post Reply
Annoyed Grunt

.cmap format documentation

Post by Annoyed Grunt » Fri Nov 03, 2017 12:57 pm

The built-in map editor is passable but very limited. For this reason, I'd like to play with the .cmap files myself, but obviously I have no idea how to read them. Lewa, do you think you could give me some info about it?

User avatar
Lewa
Site Admin
Posts: 157
Joined: Sun Nov 15, 2015 1:24 am

Re: .cmap format documentation

Post by Lewa » Sat Nov 04, 2017 12:06 am

Sure!

The game uses a custom binary format, thus data needs to be read in binary form.
In order to simplify how the structure looks like, i'll shorten the names of data types so that it's easiert to read.

Legend:
  • u8 - unsigned byte
  • u16 - unsigned short (2 bytes)
  • u32 - unsigned int (4 bytes)
  • s16 - signed short (2 bytes)
  • s32 - signed int (4 bytes)
  • f32 - float
  • f64 - double
I bielieve the engine uses little-endian order for the byte arangement (for datatypes like short, int, etc...)

So here is the format (sequentially stored in the .cmap file)

I'll use the method of writing the information down as
Datatype (number of times this datatype was sequentially written into the file)

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ CMAP format \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  1. u8 (11) > eleven unsigned bytes stored times (storing the identifier "celaria_map" as a string)
  2. u8 (1) > version number of the format
  3. u8 (1) > number of characters in the mapname
  4. u8 (namelength (previous byte) ) > name of the map as string
  5. u8 (2) > unused bytes (should be 0)
  6. u8 (1) > number of checkpoints
  7. u32 (checkpoint count) > platin times (for each checkpoint)
  8. u32 (checkpoint count) > gold times (for each checkpoint)
  9. u32 (checkpoint count) > silver times (for each checkpoint)
  10. u32 (checkpoint count) > bronze times (for each checkpoint)
  11. f32 (1) > sun rotation on the Z-axis
  12. f32 (1) > sun angle
  13. f64 (1) > camera preview x coordinate
  14. f64 (1) > camera preview y coordinate
  15. f64 (1) > camera preview z coordinate
  16. f64 (1) > camera preview lookat x coordinate
  17. f64 (1) > camera preview lookat y coordinate
  18. f64 (1) > camera preview lookat z coordinate
  19. u32 (1) > number of entities in the game (blocks, spawn markers, etc...)

    >> here you start reading data (in a for-loop as an example) as many times as entities exist. Depending on the following byte you can identify with what type of entity you are dealing with
    ================repeat as many times as entities exist ==================
    u8 (1) > entity ID

    if entityID = 0 >> block entity
    ---------------then read------------------
    u8 (1) > block type (red,green, white, yellow, etc...)
    u8 (1) > unused byte
    s32 (1) > x coordinate
    s32 (1) > y coordinate
    u32 (1) > z coordinate
    u32 (1) > x scale
    u32 (1) > y scale
    u32 (1) > z scale
    f32 (1) > z rotation

    if block type = 5 >> means that the block is a checkpoint
    then read the following byte
    u8 (1) > read checkpoint order number
    ---------------------------------


    if entityID = 1 >> sphere spawner
    ----------------then read-----------------
    s32 (1) > x coordinate
    s32 (1) > y coordinate
    s32 (1) > z coordinate
    ---------------------------------

    if entityID = 2 >> player startpoint
    -----------------then read----------------
    u8 (1) > unused byte
    s32 (1) > x coordinate
    s32 (1) > y coordinate
    s32 (1) > z coordinate
    f32 (1) > z rotation
    ---------------------------------

    if entityID = 128 >> dummy object (used for special, internal stuff like the text markers on the tutorial map)
    ---------------then read------------------
    u8 (1) > dummy ID
    s32 (1) > x coordinate
    s32 (1) > y coordinate
    u32 (1) > z coordinate
    u32 (1) > x scale
    u32 (1) > y scale
    u32 (1) > z scale
    f32 (1) > z rotation
    ---------------------------------
    =================================================================
Note that there are some (minor) differences between the .cmap and the .cemap format. (the above data was for the .cmap format.)

If something isn't clear enough i'll be more than happy to answer the given question. :)

Annoyed Grunt

Re: .cmap format documentation

Post by Annoyed Grunt » Fri Nov 17, 2017 8:22 pm

Thank you for answering. I'll play with this a bit.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest