Mercurial > hg > batmud > gmap2
changeset 52:d296121fcc5a gmap2
Fixes.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 08 Jan 2011 22:42:16 +0200 |
parents | b2caa543eec4 |
children | de1512fcc3c9 |
files | tools/makegmaps.php |
diffstat | 1 files changed, 36 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/makegmaps.php Sat Jan 08 22:13:51 2011 +0200 +++ b/tools/makegmaps.php Sat Jan 08 22:42:16 2011 +0200 @@ -137,7 +137,7 @@ imagefilledrectangle($im, 0, 0, $width*$zoom, $height*$zoom, $black); // Font sizes - $fontsize[8] = 7; + $fontsize[ 8] = 7; $fontsize[16] = 13; $fontsize[32] = 26; @@ -153,7 +153,8 @@ if ($zoom < 6) { imagefilledrectangle($im, $x*$zoom, $y*$zoom, ($x+1)*$zoom-1, ($y+1)*$zoom-1, $colors[$data[$x]]); } else { - imagettftext($im, $fontsize[$zoom], 0, + imagettftext($im, + $fontsize[$zoom], 0, $x*$zoom + $fontsize[$zoom]/4, $y*$zoom + $fontsize[$zoom], $colors[$data[$x]], @@ -279,6 +280,7 @@ } $drawn = 0; + $im = false; foreach ($continentList as $continent => $data) { @@ -290,22 +292,27 @@ $tx = -($cx*$scale - $x*$tileDim); $ty = -($cy*$scale - $y*$tileDim); - if (($cx+$cw)*$scale>$x*$tileDim&($cy+$ch)*$scale>$y*$tileDim&$cx*$scale<$x*$tileDim+$tileDim&$cy*$scale<$y*$tileDim+$tileDim) { + if (($cx + $cw)*$scale > $x*$tileDim && + ($cy + $ch)*$scale > $y*$tileDim && + ($cx * $scale) < ($x+1)*$tileDim && + ($cy * $scale) < ($y+1)*$tileDim) { if ($drawn==0) { -// if ($zoom<9) -// { + if ($zoom < 9) { $im = @imagecreate($tileDim, $tileDim); $sea = imagecolorallocate($im, 51, 51, 170); imagefilledrectangle($im, 0, 0, $tileDim, $tileDim, $sea); -// } else { -// $im = FALSE; -// } + } else { + $inFilename = $tilePath.$zoom."/sea.png"; + $im = @imagecreatefrompng($inFilename); + if ($im === false) + die("\nCould not open '".$inFilename."'.\n"); + } } - $dx=$tileDim; - $dy=$tileDim; - $xx=0; - $yy=0; + $dx = $tileDim; + $dy = $tileDim; + $xx = 0; + $yy = 0; if ($tx<0) { $xx-=$tx; @@ -320,25 +327,33 @@ } if ($dx > $cw*$scale-$tx) { - $dx = $cw*$scale-$tx; + $dx = $cw*$scale - $tx; } if ($dy > $ch*$scale-$ty) { - $dy = $ch*$scale-$ty; + $dy = $ch*$scale - $ty; } - imagecopy($im, $mapData[$continent], $xx, $yy, $tx, $ty, $dx, $dy); - $drawn++; + if ($im !== false) { + imagecopy($im, $mapData[$continent], $xx, $yy, $tx, $ty, $dx, $dy); + $drawn++; + } } } if ($drawn) { - if ($im !== FALSE) { - imagepng($im, $outFilename); - imagedestroy($im); - } else - echo "?"; + imagepng($im, $outFilename); + imagedestroy($im); } +/* + else { + if (file_exists($outFilename)) + unlink($outFilename); + + symlink($tilePath."sea.png", $outFilename); + echo "+"; + } +*/ }