Mercurial > hg > batmud > gmap2
changeset 209:1288e2f8d769 gmap2
Rename variables.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 12 Mar 2014 16:15:09 +0200 |
parents | ce92bb3e3a02 |
children | 265debcae71c |
files | tools/makegmaps.php |
diffstat | 1 files changed, 41 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/makegmaps.php Wed Mar 12 16:11:12 2014 +0200 +++ b/tools/makegmaps.php Wed Mar 12 16:15:09 2014 +0200 @@ -2,30 +2,31 @@ <?php // Paths and files -$convert = "convert"; -$mercurial = "hg"; +$binConvert = "convert"; +$binMercurial = "hg"; -$mapUtils = "maputils/"; -$rawPath = $mapUtils."maps/"; +$pathMapUtils = "maputils/"; +$pathImageCache = "cache/"; +$pathMarkerData = "../"; +$pathTileData = "../tiles/"; + +$pathRawMaps = $pathMapUtils."maps/"; + $rawSuffix = ".new"; $rawAltSuffix = ".map"; -$cachePath = "cache/"; + $fontFile = "./lucon.ttf"; - -$markerPath = "../"; -$tilePath = "../tiles/"; $tileDim = 256; - /* Internal data and settings */ -$locPath = $mapUtils."maps/"; -$continentJS = $markerPath."continents.js"; -$tradelaneOut = $markerPath."tradelane.json"; -$tradelaneOverlay = $markerPath."troverlay.json"; -$mkloc = $mapUtils."mkloc"; +$locPath = $pathMapUtils."maps/"; +$continentJS = $pathMarkerData."continents.js"; +$tradelaneOut = $pathMarkerData."tradelane.json"; +$tradelaneOverlay = $pathMarkerData."troverlay.json"; +$mkloc = $pathMapUtils."mkloc"; $modes = array( "xml" => array("batclient.xml" , 0, 0), @@ -87,30 +88,30 @@ /* * Build maputils and fetch latest map data */ -if (!file_exists($mapUtils)) +if (!file_exists($pathMapUtils)) { // If maputils does not exist, clone the repository - $tmp = $mercurial." clone http://pupunen.net/hg/maputils/ ".escapeshellarg($mapUtils); + $tmp = $binMercurial." clone http://pupunen.net/hg/maputils/ ".escapeshellarg($pathMapUtils); echo "* $tmp\n"; passthru($tmp) == 0 or die("Error executing: ".$tmp."\n"); // Clone th-libs - $tmp = $mercurial." clone http://tnsp.org/hg/th-libs/ ".escapeshellarg($mapUtils."th-libs/"); + $tmp = $binMercurial." clone http://tnsp.org/hg/th-libs/ ".escapeshellarg($pathMapUtils."th-libs/"); echo "* $tmp\n"; passthru($tmp) == 0 or die("Error executing: ".$tmp."\n"); } else { - $tmp = "cd ".escapeshellarg($mapUtils)." && ".$mercurial." pull && ".$mercurial." update"; + $tmp = "cd ".escapeshellarg($pathMapUtils)." && ".$binMercurial." pull && ".$binMercurial." update"; echo "* $tmp\n"; passthru($tmp) == 0 or die("Error executing: ".$tmp."\n"); - $tmp = "cd ".escapeshellarg($mapUtils."th-libs/")." && ".$mercurial." pull && ".$mercurial." update"; + $tmp = "cd ".escapeshellarg($pathMapUtils."th-libs/")." && ".$binMercurial." pull && ".$binMercurial." update"; echo "* $tmp\n"; passthru($tmp) == 0 or die("Error executing: ".$tmp."\n"); } -$tmp = "cd ".escapeshellarg($mapUtils)." && make"; +$tmp = "cd ".escapeshellarg($pathMapUtils)." && make"; echo "* $tmp\n"; passthru($tmp) == 0 or die("Error executing: ".$tmp."\n"); @@ -118,17 +119,17 @@ if (!file_exists($mkloc)) die($mkloc." not found. Maputils package not built, or some other error occured.\n"); -$tmp = "cd ".escapeshellarg($mapUtils)." && make"; +$tmp = "cd ".escapeshellarg($pathMapUtils)." && make"; passthru($tmp) == 0 or die("Error executing: ".$tmp."\n"); -$tmp = "cd ".escapeshellarg($rawPath)." && make fetch 2> /dev/null"; +$tmp = "cd ".escapeshellarg($pathRawMaps)." && make fetch 2> /dev/null"; passthru($tmp) == 0 or die("Error executing: ".$tmp."\n"); /* * Include continent and tradelane configuration */ -$config = $mapUtils."www/world.inc.php"; +$config = $pathMapUtils."www/world.inc.php"; if (!file_exists($config)) die("Required continent/tradelane configuration file '$config' not found.\n"); @@ -164,7 +165,7 @@ foreach ($modes as $mode => $mdata) { - $tmp = escapeshellcmd($mkloc)." -v -o ".escapeshellarg($markerPath.$mdata[0])." -G ".$mode." "; + $tmp = escapeshellcmd($mkloc)." -v -o ".escapeshellarg($pathMarkerData.$mdata[0])." -G ".$mode." "; foreach ($continentList as $name => $data) { @@ -357,26 +358,26 @@ return TRUE; } -if (!makeDir($cachePath)) { - die("Failed to create cache directory '".$cachePath."'!\n"); +if (!makeDir($pathImageCache)) { + die("Failed to create cache directory '".$pathImageCache."'!\n"); } echo "Generating basic map data...\n"; foreach ($continentList as $name => $data) if ($data[4] && $data[7]) { - $inFilename = $rawPath.$name.$rawSuffix; + $inFilename = $pathRawMaps.$name.$rawSuffix; if (!file_exists($inFilename)) { - $inFilename = $rawPath.$name.$rawAltSuffix; + $inFilename = $pathRawMaps.$name.$rawAltSuffix; if (!file_exists($inFilename)) - die("Required file '".$rawPath.$name."(".$rawSuffix."|".$rawAltSuffix.")' does not exist.\n"); + die("Required file '".$pathRawMaps.$name."(".$rawSuffix."|".$rawAltSuffix.")' does not exist.\n"); } $inMtime = filemtime($inFilename); for ($zoom = 1; $zoom <= 5; $zoom++) { - $outFilename = $cachePath.$name."_".($zoom + 4).".png"; + $outFilename = $pathImageCache.$name."_".($zoom + 4).".png"; $outMtime = file_exists($outFilename) ? filemtime($outFilename) : -1; echo "- ".$name." (".$data[0]."): "; if ($inMtime > $outMtime) @@ -399,7 +400,7 @@ if ($data[4] && $data[7]) { $n = count($mapScales); - $inFilename = $cachePath.$name."_".$n.".png"; + $inFilename = $pathImageCache.$name."_".$n.".png"; if (!file_exists($inFilename)) { die("Required file '".$inFilename."' does not exist.\n"); @@ -409,13 +410,13 @@ foreach ($mapScales as $scale) { $n--; - $outFilename = $cachePath.$name."_".$n.".png"; + $outFilename = $pathImageCache.$name."_".$n.".png"; $outMtime = file_exists($outFilename) ? filemtime($outFilename) : -1; echo "* ".$inFilename." -> ".$outFilename.": "; if ($inMtime > $outMtime) { - $tmp = escapeshellcmd($convert)." ".escapeshellarg($inFilename)." -scale ".escapeshellarg($scale."%")." -type Palette ".escapeshellarg($outFilename); + $tmp = escapeshellcmd($binConvert)." ".escapeshellarg($inFilename)." -scale ".escapeshellarg($scale."%")." -type Palette ".escapeshellarg($outFilename); passthru($tmp) == 0 or die("Error executing: ".$tmp."\n"); echo "OK\n"; } @@ -430,9 +431,9 @@ */ function createTile($scale, $zoom, $x, $y, $mapData, $mapMtime) { - global $continentList, $worldMap, $cachePath, $tilePath, $tileDim; + global $continentList, $worldMap, $pathImageCache, $pathTileData, $tileDim; - $outFilename = $tilePath.$zoom."/".$y."/".$x.".png"; + $outFilename = $pathTileData.$zoom."/".$y."/".$x.".png"; if (file_exists($outFilename) && filemtime($outFilename) >= $mapMtime) { echo "!"; @@ -467,7 +468,7 @@ } else { - $inFilename = $tilePath.$zoom."/sea.png"; + $inFilename = $pathTileData.$zoom."/sea.png"; $im = @imagecreatefrompng($inFilename); if ($im === false) die("\nCould not open '".$inFilename."'.\n"); @@ -509,7 +510,7 @@ if ($drawn > 0) { - makeDir($tilePath.$zoom."/".$y, 0755); + makeDir($pathTileData.$zoom."/".$y, 0755); imagepng($im, $outFilename); imagedestroy($im); } @@ -518,7 +519,7 @@ if (file_exists($outFilename)) unlink($outFilename); - symlink($tilePath."sea.png", $outFilename); + symlink($pathTileData."sea.png", $outFilename); echo "+"; } */ @@ -534,7 +535,7 @@ $zoom2 = $zoom - 1; $scale = pow(2, $zoom2 - 5); - makeDir($tilePath.$zoom); + makeDir($pathTileData.$zoom); echo "\nzoom level $zoom: "; @@ -547,7 +548,7 @@ foreach ($continentList as $continent => $data) if ($data[4] && $data[7]) { - $mapFile = $cachePath.$continent."_".$zoom2.".png"; + $mapFile = $pathImageCache.$continent."_".$zoom2.".png"; $mapData[$continent] = @imagecreatefrompng($mapFile); $tmp = filemtime($mapFile); if ($tmp > $mapMtime)