1

Topic: Extracting layer data out of .map file

Hi Community,
I'm currenty developing a small tool for TW that collects map data out of the .map files.
I'm not sure what features it is going to have later yet, at first I want to make the extracting work.

I read a lot in the source code and found out the in version four the rawdata is stored compressed with the deflate algo from zlib.
Now my problem:
I want to write my tool in C# and I tried a lot of C# zlib implementations but noone gives me the result expected.
The uncompressed size never matches the one written in the terminal by TW (Editor).
The first thing that helped me was to replace all bytes containing an 32 (interger) by an byte containing a 0.

This gives me the correct image names, but the quadlayer data still doesn't work.

The zlib inflate return an "incorrect data check" error and going into the code shows me that zlib starts checking too early, e.g. for standart ctf5, group 1, first (and only) quadlayer only 63 bytes were read but it should be 79.

Do I have to replace something else that inflate dosn't start checking too early or is there a proplem with the encoding or something else?
I would be great if someone could help me,
Thanks
Teebeutel

2 (edited by Sushi Tee 2012-01-21 21:12:02)

Re: Extracting layer data out of .map file

The item are not compressed. Only the data is.

u have the following items:

  • version

  • info

  • images

  • envelops

  • groups

  • layers

  • envpoints

in the data part the following is stored:

  • image names

  • tiles

  • quads

  • embedded images

where to find what is defined after the map header in the item types and offsets.
U just pick out the data from the map file and put the correct datatypes over it (see mapitems.h).

A little information about the mapfile u can find here

uptee - a simple web interface for hosting and maintaining teeworlds servers
teerace - a website gathering results of trusted Race-mod servers providing global ranking and statistics
*gV* rox ^^

3 (edited by Teebeutel 2012-01-23 22:44:33)

Re: Extracting layer data out of .map file

Thanks for the link to the information,
but I think my problem is not misunderstanding the map format or finding the wrong data in the file.

I can locate the data and extract it. Items as well as Data only the decompression fails.
I know it isn't an TW mistake but i hope someone had some kind of problem in the past and can give me some tips.

So thank you for for your fast reply but it didn't help me wink

EDIT:
It looks like i solved the problem smile
I change the infalte of zlib that it never starts checking an abort the decompression when an exception is thrown...bad solution and very slow i think....

Now a new question:
I got about 17,000 tiles in one layer. I have the related image index but how do I know which position in the image a tile is representing? Thay only have an index, flag, skip and reserved param.
Thanks so far,
Teebeutel

4

Re: Extracting layer data out of .map file

A tilemap image is split into a grid with 256 entries. 16x16.The index in the tile is the index into the tilemap.

5

Re: Extracting layer data out of .map file

Ok this seems to easy wink
Thanks for your help so far,
Teebeutel