This is for any potential scripters who want to integrate with the new format... and this is not fun, but here we go:
There are two types of integers you'll need to pull out of it, single bytes and shorts. And wonky endianness
Byte:
AB = A + B * 16
Short:
ABCD = (A + B * 16) * 256 + (C + D * 16)
There are no more separators for easily managing data anymore. No '|'s or '^'s or ','s or '!'s
EDIT: I FORGOT ABOUT THE FIRST FOUR BYTES YOU NEED TO READ FOUR BYTES OFF THE TOP OF THE DATA FOR SOME REASON
Data starts off similarly as 1.4, the first portion is tile data.
713 tiles, each represented by a byte in hex format. So 1426 characters of tile data total [EDIT: AFTER THE FIRST EIGHT].
Now comes the fun part... objects.
The codes for objects are:
0: player
1: mine
2: gold
3: exit
4: regular door
5: locked door
6: trap door
7: launchpad
8: oneway
9: chaingun
10: laser
11: zap
12: chaser
13: floorguard
14: bounceblock
15: rocket
16: gauss
17: thwump
The objects are stored in this order, and you need to go through each of them for possible stored data.
Right after the tile data ends, we need to loop through every 18 of the possible objects starting with the player at 0.
Read a short (four characters). This is how many objects of that type of objects are coming up.
The tricky part now is that there are a different number of bytes of data based on what the objects is, and here is that information:
2 bytes: player, bounceblock, mine, rocket, turret
3 bytes: regular door, launchpad, oneway, thwump
4 bytes: chaingun, laser, zap, chaser, exit
5 bytes: locked door, trap door
Read that many bytes for whatever object type you're currently on, then repeat from grabbing the short.
Let's run through an example:
"0010e3e20020a3232423002024a2a3a2000000000000000000000000000000000000000000000000000000000000"
Start our type at 0, the player
Read a short,
0010 (1). That's how many players we have
A player has two bytes, so read two bytes,
e3, e2 (62, 46)
No more players, so up our type to 1, mines, and read a short for how many mines we have,
0020 (2). Two mines, read two for the first mine
a3, 23 (58, 50)
Read two for the second
24, 23 (66, 50)
No more mines, we're at type 2, for gold, so read a short for gold
0020 (2), read two golds
24, a2 (66, 42)
a3, a2 (58, 42)
You'll notice the rest of the data is 00, so that means we have no more objects. But you will use this logic for other objects if present.
Actually using this data? Have fun with that. As far as I know, the first two bytes of information are positions. The extra bytes for the other objects are other information, some of it is other objects as well. The last two bytes for exits, locked doors, and trap doors are the switch/key positions. Third bytes are probably position in the tile. I haven't actually gone any further than just figuring out how the data is stored.
Hopefully this helps further scripters to write tools for the new format, but I'm really hoping they will redo the format to be friendly for third partiers.
Also if you want to get your map data from the server, get your level id and go to http://bucket.thewayoftheninja.org/[level_id].txt
The data's just base64 encoded and zlib compressed, so undecode and decompress it for your map data from the server.
I made a crappy notation to describe the data format
Code: Select all
<bytes:variable>, [number of elements:element]
Code: Select all
map data = <4:who knows>[713:<1:tile>][18:<2:object count>[object count:[2-5:<1:data>]]]
Code: Select all
server response = <2:title length><title length:title>%map data%