comparison tools/makegmaps.php @ 312:b0decfe4d3e4 gmap2

Delete trailing whitespace.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 11 Apr 2020 05:11:00 +0300
parents 3a67c8425d1b
children 372ae2fd1db0
comparison
equal deleted inserted replaced
311:3a67c8425d1b 312:b0decfe4d3e4
132 132
133 // Get worldmap coordinates for a given tradelane waypoint 133 // Get worldmap coordinates for a given tradelane waypoint
134 function stGetWaypointCoords($waypoint, &$xc, &$yc) 134 function stGetWaypointCoords($waypoint, &$xc, &$yc)
135 { 135 {
136 global $tradelanePoints; 136 global $tradelanePoints;
137 137
138 if (!isset($tradelanePoints[$waypoint])) 138 if (!isset($tradelanePoints[$waypoint]))
139 return FALSE; 139 return FALSE;
140 140
141 return stGetWorldCoords($tradelanePoints[$waypoint][0], 141 return stGetWorldCoords($tradelanePoints[$waypoint][0],
142 $tradelanePoints[$waypoint][1], $tradelanePoints[$waypoint][2], $xc, $yc); 142 $tradelanePoints[$waypoint][1], $tradelanePoints[$waypoint][2], $xc, $yc);
286 286
287 echo 287 echo
288 "\nNext up are some files and paths. All of them can be safely\n". 288 "\nNext up are some files and paths. All of them can be safely\n".
289 "left to their default values (e.g. just press <enter>) unless\n". 289 "left to their default values (e.g. just press <enter>) unless\n".
290 "you know you want something set differently.\n\n"; 290 "you know you want something set differently.\n\n";
291 291
292 stQueryConfigItems(1); 292 stQueryConfigItems(1);
293 stQueryConfigItems(2); 293 stQueryConfigItems(2);
294 294
295 $cfg["pathRawMaps"] = $cfg["pathMapUtils"]."world/"; 295 $cfg["pathRawMaps"] = $cfg["pathMapUtils"]."world/";
296 $cfg["pathLocFiles"] = $cfg["pathMapUtils"]."world/"; 296 $cfg["pathLocFiles"] = $cfg["pathMapUtils"]."world/";
299 stQueryConfigItems(3); 299 stQueryConfigItems(3);
300 300
301 301
302 stOutputToFile($gmapsConfig, "<?php\n\$cfg = ".var_export($cfg, TRUE)."\n?>"); 302 stOutputToFile($gmapsConfig, "<?php\n\$cfg = ".var_export($cfg, TRUE)."\n?>");
303 303
304 stOutputToFile($cfg["pathGMap"]."config.inc.php", 304 stOutputToFile($cfg["pathGMap"]."config.inc.php",
305 "<?php\n". 305 "<?php\n".
306 "\$pageBaseURL = \"".$cfg["pageBaseURL"]."\";\n". 306 "\$pageBaseURL = \"".$cfg["pageBaseURL"]."\";\n".
307 "\$gmapsKey = \"".$cfg["gmapsKey"]."\";\n". 307 "\$gmapsKey = \"".$cfg["gmapsKey"]."\";\n".
308 "\$gmapsVersion = \"3\";\n". 308 "\$gmapsVersion = \"3\";\n".
309 "?>\n"); 309 "?>\n");
379 $tmp = "cd ".escapeshellarg($cfg["pathRawMaps"])." && ".$cfg["binMake"]." fetch 2> /dev/null"; 379 $tmp = "cd ".escapeshellarg($cfg["pathRawMaps"])." && ".$cfg["binMake"]." fetch 2> /dev/null";
380 passthru($tmp) == 0 or die("Error executing: ".$tmp."\n"); 380 passthru($tmp) == 0 or die("Error executing: ".$tmp."\n");
381 381
382 382
383 // 383 //
384 // Include continent and tradelane configuration 384 // Include continent and tradelane configuration
385 // 385 //
386 if (!file_exists($cfg["worldConfig"])) 386 if (!file_exists($cfg["worldConfig"]))
387 die("Required continent/tradelane configuration file '".$cfg["worldConfig"]."' not found.\n"); 387 die("Required continent/tradelane configuration file '".$cfg["worldConfig"]."' not found.\n");
388 388
389 require $cfg["worldConfig"]; 389 require $cfg["worldConfig"];
493 $qline[] = [ 493 $qline[] = [
494 "x" => $xc, 494 "x" => $xc,
495 "y" => $yc 495 "y" => $yc
496 ]; 496 ];
497 } 497 }
498 498
499 $qdata[] = $qline; 499 $qdata[] = $qline;
500 } 500 }
501 501
502 502
503 stOutputToJSONFile($tradelaneOverlay, $qdata); 503 stOutputToJSONFile($tradelaneOverlay, $qdata);
535 535
536 imagefilledrectangle($im, 0, 0, $width*$zoom, $height*$zoom, $black); 536 imagefilledrectangle($im, 0, 0, $width*$zoom, $height*$zoom, $black);
537 537
538 // Read input raw 538 // Read input raw
539 $y = 0; 539 $y = 0;
540 while ($y < $height && ($data = fgets($file, 4096)) !== FALSE) 540 while ($y < $height && ($data = fgets($file, 4096)) !== FALSE)
541 { 541 {
542 for ($x = 0; $x < $width; $x++) 542 for ($x = 0; $x < $width; $x++)
543 { 543 {
544 if ($zoom == 1) 544 if ($zoom == 1)
545 { 545 {
546 imagesetpixel($im, $x, $y, $colors[$data[$x]]); 546 imagesetpixel($im, $x, $y, $colors[$data[$x]]);
547 } 547 }
548 else 548 else
549 if ($zoom < 6) 549 if ($zoom < 6)
550 { 550 {
551 imagefilledrectangle($im, $x*$zoom, $y*$zoom, ($x+1)*$zoom-1, ($y+1)*$zoom-1, $colors[$data[$x]]); 551 imagefilledrectangle($im, $x*$zoom, $y*$zoom, ($x+1)*$zoom-1, ($y+1)*$zoom-1, $colors[$data[$x]]);
552 } 552 }
553 else 553 else
591 $inFilename = $cfg["pathRawMaps"].$cname.$rawAltSuffix; 591 $inFilename = $cfg["pathRawMaps"].$cname.$rawAltSuffix;
592 if (!file_exists($inFilename)) 592 if (!file_exists($inFilename))
593 die("Required file '".$cfg["pathRawMaps"].$cname."(".$rawSuffix."|".$rawAltSuffix.")' does not exist.\n"); 593 die("Required file '".$cfg["pathRawMaps"].$cname."(".$rawSuffix."|".$rawAltSuffix.")' does not exist.\n");
594 } 594 }
595 $inMtime = filemtime($inFilename); 595 $inMtime = filemtime($inFilename);
596 596
597 for ($zoom = 1; $zoom <= 5; $zoom++) 597 for ($zoom = 1; $zoom <= 5; $zoom++)
598 { 598 {
599 $outFilename = $cfg["pathImageCache"].$cname."_".($zoom + 4).".png"; 599 $outFilename = $cfg["pathImageCache"].$cname."_".($zoom + 4).".png";
600 $outMtime = file_exists($outFilename) ? filemtime($outFilename) : -1; 600 $outMtime = file_exists($outFilename) ? filemtime($outFilename) : -1;
601 echo "- ".$cname." (".$cdata[CTI_NAME]."): "; 601 echo "- ".$cname." (".$cdata[CTI_NAME]."): ";
669 669
670 foreach ($continentList as $cname => &$cdata) 670 foreach ($continentList as $cname => &$cdata)
671 { 671 {
672 if (!$cdata[CTI_HAS_MAP] || !$cdata[CTI_REG_CONT]) 672 if (!$cdata[CTI_HAS_MAP] || !$cdata[CTI_REG_CONT])
673 continue; 673 continue;
674 674
675 $cx = $cdata[CTI_XOFFS] + $worldMap["ox"]; 675 $cx = $cdata[CTI_XOFFS] + $worldMap["ox"];
676 $cy = $cdata[CTI_YOFFS] + $worldMap["oy"]; 676 $cy = $cdata[CTI_YOFFS] + $worldMap["oy"];
677 $cw = $cdata[CTI_WIDTH]; 677 $cw = $cdata[CTI_WIDTH];
678 $ch = $cdata[CTI_HEIGHT]; 678 $ch = $cdata[CTI_HEIGHT];
679 679
680 $tx = -($cx*$scale - $x*$tileDim); 680 $tx = -($cx*$scale - $x*$tileDim);
681 $ty = -($cy*$scale - $y*$tileDim); 681 $ty = -($cy*$scale - $y*$tileDim);
682 682
683 if (($cx + $cw)*$scale > $x*$tileDim && 683 if (($cx + $cw)*$scale > $x*$tileDim &&
684 ($cy + $ch)*$scale > $y*$tileDim && 684 ($cy + $ch)*$scale > $y*$tileDim &&
685 ($cx * $scale) < ($x+1)*$tileDim && 685 ($cx * $scale) < ($x+1)*$tileDim &&
686 ($cy * $scale) < ($y+1)*$tileDim) 686 ($cy * $scale) < ($y+1)*$tileDim)
687 { 687 {
688 if (!$drawn) 688 if (!$drawn)
689 { 689 {
690 if ($zoom < 9) 690 if ($zoom < 9)
746 { 746 {
747 stMakeDir($cfg["pathTileData"].$zoom."/".$y, 0755); 747 stMakeDir($cfg["pathTileData"].$zoom."/".$y, 0755);
748 imagepng($im, $outFilename); 748 imagepng($im, $outFilename);
749 imagedestroy($im); 749 imagedestroy($im);
750 } 750 }
751 /* 751 /*
752 else { 752 else {
753 if (file_exists($outFilename)) 753 if (file_exists($outFilename))
754 unlink($outFilename); 754 unlink($outFilename);
755 755
756 symlink($cfg["pathTileData"]."sea.png", $outFilename); 756 symlink($cfg["pathTileData"]."sea.png", $outFilename);