-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.php
More file actions
56 lines (46 loc) · 982 Bytes
/
map.php
File metadata and controls
56 lines (46 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
date_default_timezone_set("Europe/London");
$ddd=date("Y-m-d H:i:s");
echo "start: $ddd\n\r";
$date1 = time();
$filename = "map.bin";
$fp = fopen($filename, "rb");
$contents = file_get_contents('map.bin', null,null,2);
$fsize = filesize($filename);
$b=unpack("C*",$contents);
$xx=0;
$yy=0;
for($x=1;$x<=sizeof($b);$x=$x+1)
{
$ctype=tipo($b[$x] >> 4) ;
$bin=decbin($b[$x]);
$wtype=bindec(substr(decbin($b[$x]),-4 ));
$tile=$b[$x] ;
$y=($x-1);
$format="-%6d- [$xx x $yy] ctype[%10s] level[%2d] %8s";
printf($format,$y,$ctype,$wtype,$bin);
$xxx=sprintf('%1$03d',$xx);
$yyy=sprintf('%1$03d',$yy);
echo "x $x [x$xxx y$yyy] \n\r";
$yy++;
if($yy>749)
{
$xx++;
echo "xx $xx ";
$yy=0;
}
}
function tipo($x)
{
if($x==1) return("plain");
if($x==2) return("mountain");
if($x==3) return("forest");
if($x==4) return("hill");
if($x==5) return("savana");
if($x==6) return("lake");
if($x==7) return("city");
if($x==8) return("anthro");
if($x==9) return("clouds");
}
fclose($fp);
?>