1 (edited by toilette 2009-07-12 21:46:26)

Topic: [HELP] I need help with the map structure

Hello and good evening from Germany,
well I'm trying to create a little php file that reads out the images stored in a teeworld map file. Well I'm knowing that it will be very hard, but I think I can do that (not perfect but who is perfect?)
The beginning was easy, I've written a little Scripts, that reads out the complete header structure stored in this file, For those eho were interested in, here the code :

<?php
    function array2string($array) {
        for($i=0;$i<count($array);$i++) {
            if (is_int($array[$i])) {
                $out.=chr($array[$i]);
            } else {
                $out.=$array[$i];
            }
        }
        return $out;
    }
   
    function array_cpy(&$array1,&$array2) {
        foreach ($array2 as $key=>$data) {
            $array1[$key]=$data;
        }
    }
   
    function read_map_header($filename) {
        $map_header=array("id"=>"",
                          "version"=>0,
                          "size"=>0,
                          "swaplen"=>0,
                          "num_item_types"=>0,
                          "num_items"=>0,
                          "num_raw_data"=>0,
                          "item_size"=>0,
                          "data_size"=>0);
        $fh=fopen("test.map","rb");
        $bdata=fread($fh,36);
        list($tmp,$id[0],$id[1],$id[2],$id[3])=unpack("c4",$bdata);
        $map_header['id']=array2string($id);
        $i[1]=&$map_header['version'];
        $i[2]=&$map_header['size'];
        $i[3]=&$map_header['swaplen'];
        $i[4]=&$map_header['num_item_types'];
        $i[5]=&$map_header['num_items'];
        $i[6]=&$map_header['num_raw_data'];
        $i[7]=&$map_header['item_size'];
        $i[8]=&$map_header['data_size'];
        array_cpy($i,unpack("c4/i8",$bdata));
        fclose($fh);
        return $map_header;
    }
?>

But now I stocking at the rest. So my Question: can someone of the developers or someone else send me a detailed data structure of the teeworlds map file? It wolud be verry nice, and it helps me a lot.

thx, Toilette

P.S. I promise : when I'm ready with that, I'll post the files in this forum, so that everybody who wants, can proffit from it.

2

Re: [HELP] I need help with the map structure

If I understand you right, you want to extract the tilesets out of a map.
In this case, you don't have to reinvent the wheel completely,
because someone already wrote something like this.
Look here.
I know, it's in C++, but the basical structure should come out.
I hope, I could help.

3

Re: [HELP] I need help with the map structure

sorry It uses the same function i'm stucking at, but thx for your reply

4

Re: [HELP] I need help with the map structure

How do you mean that?
Which function are you stucking at?
Maybe I can help you.
I'm programming C++ for myself, and a bit PHP. smile

5

Re: [HELP] I need help with the map structure

Well my problem is, that I do not really know much about type-conversion. Especially in the data_load function. I don't know in what the file structure will be converted in. If you can explain me that one thing and maybe figure out the resulting file structure, maybe I'm able to do the rest.

6

Re: [HELP] I need help with the map structure

Map resource manager
Items
manager header
manager implementation

7 (edited by OFQ 2009-07-14 10:11:39)

Re: [HELP] I need help with the map structure

its huge and crappy old-Schooo C code. I think it will be better if *someone* will write some tool, on C++, that convert
*.map  <-> *.xml + decompressed resources.

it will work out all our problems. Everyone will be able to use his favorite lenguage with out of creating specific import/export module.

PS. PHP image extractor O_o What is the point ?

8 (edited by OFQ 2009-07-15 07:51:51)

Re: [HELP] I need help with the map structure

External tool called "pnglite" is using only by the graphic module "ec_gfx"
There is function "gfx_load_png(&imginfo, filename)" - call in the  modules "ed_editor", "ed_io" and  "skins".

In the "ed_io" we have class "MAP"

And load method ||  Save method

It seems helpful in your case...

But we still requires full converter in the human friendly format. Cuz if you want to write tool for the -_-_Tee_-_- , you need some C\C++ skills, IDE. It is synthetic limit of the community development activity.

PS. Your English is bad for me - sorry smile

9

Re: [HELP] I need help with the map structure

catpaw made a map2xml tool, maybe it will help you: http://www.teeworlds.com/forum/viewtopic.php?id=1986

Drowning dwarves lately

10

Re: [HELP] I need help with the map structure

lol! Nice smile

11

Re: [HELP] I need help with the map structure

Wow that's it. Thx for you Post. and thx for all others, who tried to help me.

Thanks.

12

Re: [HELP] I need help with the map structure

Question answered & thread can be closed.

Never argue with a fool, people might not know the difference.