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.