changeset 324:b0c2f11e60fa gmap2 tip

Canonize boolean values to true/false instead of mixing TRUE/FALSE in.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 12 Mar 2023 14:58:57 +0200
parents a157aa18ec75
children
files tools/makegmaps.php
diffstat 1 files changed, 42 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/tools/makegmaps.php	Sun Mar 12 14:58:12 2023 +0200
+++ b/tools/makegmaps.php	Sun Mar 12 14:58:57 2023 +0200
@@ -22,9 +22,9 @@
   "pathGMap"        => [2, "../", "Path to map main directory and marker data files."],
   "pathTileData"    => [2, "../tiles/", "Path to map tiles directory structure."],
 
-  "pathRawMaps"     => [3, FALSE, "Path to the raw ASCII maps."],
-  "pathLocFiles"    => [3, FALSE, "Path to the location data LOC files."],
-  "worldConfig"     => [3, FALSE, "Path of the world configuration file 'world.inc.php' from MapUtils."],
+  "pathRawMaps"     => [3, false, "Path to the raw ASCII maps."],
+  "pathLocFiles"    => [3, false, "Path to the location data LOC files."],
+  "worldConfig"     => [3, false, "Path of the world configuration file 'world.inc.php' from MapUtils."],
 ];
 
 
@@ -97,15 +97,15 @@
 function stMakeDir($path)
 {
   if (file_exists($path))
-    return TRUE;
+    return true;
   else
-    return mkdir($path, 0755, TRUE);
+    return mkdir($path, 0755, true);
 }
 
 
 function stOutputToFile($sfilename, $sdata)
 {
-  if (file_put_contents($sfilename, $sdata, LOCK_EX) === FALSE)
+  if (file_put_contents($sfilename, $sdata, LOCK_EX) === false)
     die("Error writing to '".$sfilename."'.\n");
 }
 
@@ -122,11 +122,11 @@
   global $worldMap, $continentList;
 
   if (!isset($continentList[$cname]))
-    return FALSE;
+    return false;
 
   $xc = $worldMap["ox"] + $continentList[$cname][CTI_XOFFS] + $xp - 1;
   $yc = $worldMap["oy"] + $continentList[$cname][CTI_YOFFS] + $yp - 1;
-  return TRUE;
+  return true;
 }
 
 
@@ -136,14 +136,14 @@
   global $tradelanePoints;
 
   if (!isset($tradelanePoints[$waypoint]))
-    return FALSE;
+    return false;
 
   return stGetWorldCoords($tradelanePoints[$waypoint][0],
     $tradelanePoints[$waypoint][1], $tradelanePoints[$waypoint][2], $xc, $yc);
 }
 
 
-function stYesNoPrompt($msg, $default = FALSE)
+function stYesNoPrompt($msg, $default = false)
 {
   echo $msg." [".($default ? "Y/n" : "y/N")."]? ";
   $sprompt = strtolower(trim(fgets(STDIN)));
@@ -155,16 +155,16 @@
 }
 
 
-function stInputPrompt($msg, $default = FALSE, $validate = null)
+function stInputPrompt($msg, $default = false, $validate = null)
 {
-  $valid = FALSE;
+  $valid = false;
   while (!$valid)
   {
-    echo $msg."\n".($default !== FALSE ? "[".$default."]" : "")."> ";
+    echo $msg."\n".($default !== false ? "[".$default."]" : "")."> ";
     $sprompt = trim(fgets(STDIN));
 
     if ($sprompt == "")
-      $sprompt = ($default !== FALSE ? $default : "");
+      $sprompt = ($default !== false ? $default : "");
 
     $valid =  !is_callable($validate) || call_user_func($validate, $sprompt);
   }
@@ -177,10 +177,10 @@
   if ($val == "")
   {
     echo "The value can't be empty.\n";
-    return FALSE;
+    return false;
   }
   else
-    return TRUE;
+    return true;
 }
 
 
@@ -190,22 +190,22 @@
       substr($sprefix, 0, 8) != "https://")
   {
     echo "URL must start with http:// or https://\n";
-    return FALSE;
+    return false;
   }
   else
   if (substr($sprefix, -1) != "/")
   {
     echo "URL must end with /\n";
-    return FALSE;
+    return false;
   }
   else
-  if (preg_match("/^https?:\/\/[a-zA-Z0-9]+[a-zA-Z0-9\/\.\:\-]*?\//", $sprefix) === FALSE)
+  if (preg_match("/^https?:\/\/[a-zA-Z0-9]+[a-zA-Z0-9\/\.\:\-]*?\//", $sprefix) === false)
   {
     echo "Malformed URL (or atleast this silly regexp does not accept it.\n";
-    return FALSE;
+    return false;
   }
   else
-    return TRUE;
+    return true;
 }
 
 
@@ -228,9 +228,9 @@
   {
     if ($cdata[0] == $level)
     {
-      $def = ($cdata[1] !== FALSE) ? $cdata[1] : $cfg[$citem];
+      $def = ($cdata[1] !== false) ? $cdata[1] : $cfg[$citem];
 
-      $sdone = FALSE;
+      $sdone = false;
       while (!$sdone)
       {
         $tmp = $cfg[$citem] = stInputPrompt($cdata[2], $def, "stValidateNotEmpty");
@@ -244,11 +244,11 @@
               echo "ERROR: Could not find '".$tmp."'. Perhaps it is not in path, or path is wrong.\n";
             }
             else
-              $sdone = TRUE;
+              $sdone = true;
             break;
 
           default:
-            $sdone = TRUE;
+            $sdone = true;
         }
       }
     }
@@ -266,30 +266,30 @@
 
 if (file_exists($gmapsConfig))
 {
-  $firstRun = FALSE;
+  $firstRun = false;
   include $gmapsConfig;
 }
 else
 {
-  $firstRun = TRUE;
+  $firstRun = true;
   echo
     "It seems you are running this for the first time ..\n".
     "You will be asked some information this time, which will be\n".
     "and saved for later use in file '".$gmapsConfig."'\n\n";
 
-  $sdone = FALSE;
+  $sdone = false;
   while (!$sdone)
   {
     $cfg["pageBaseURL"] = stInputPrompt(
       "Enter base URL for the map page. For example: http://foobar.com/map/\n",
-      FALSE, "stValidateURLPrefix");
+      false, "stValidateURLPrefix");
     $sdone = stYesNoPrompt("The page base URL to be used is \"".$cfg["pageBaseURL"]."\", e.g.\n".
       "index.php would be: \"".$cfg["pageBaseURL"]."index.php\"\n".
       "Is this correct?");
     echo "\n";
   }
 
-  $sdone = FALSE;
+  $sdone = false;
   while (!$sdone)
   {
     $cfg["urlTilePrefix"] = stInputPrompt(
@@ -303,7 +303,7 @@
 
   $cfg["gmapsKey"] = stInputPrompt(
     "Enter your Google Maps API key (or leave empty, and edit later)\n",
-    FALSE, FALSE);
+    false, false);
 
   echo
     "\nNext up are some files and paths. All of them can be safely\n".
@@ -320,7 +320,7 @@
   stQueryConfigItems(3);
 
 
-  stOutputToFile($gmapsConfig, "<?php\n\$cfg = ".var_export($cfg, TRUE)."\n?>");
+  stOutputToFile($gmapsConfig, "<?php\n\$cfg = ".var_export($cfg, true)."\n?>");
 
   stOutputToFile($cfg["pathGMap"]."config.inc.php",
   "<?php\n".
@@ -346,7 +346,7 @@
 /*
 foreach (["." => 0600, $cfg["pathMapUtils"] => 0600] as $spath => $sperm)
 {
-  if (chmod($spath, $sperm) === FALSE)
+  if (chmod($spath, $sperm) === false)
     echo "Could not set permissions for '".$spath."'.\n");
 }
 */
@@ -532,10 +532,10 @@
   global $mapPalette, $fontFile, $fontSize;
 
   // Try to open input file
-  if (($file = @fopen($inFilename, "r")) === FALSE)
+  if (($file = @fopen($inFilename, "r")) === false)
   {
     echo "Could not open input '".$inFilename."'\n";
-    return FALSE;
+    return false;
   }
 
   // Derp
@@ -544,10 +544,10 @@
   $height = $cdata[CTI_HEIGHT];
 
   // Create image and assign colors
-  if (($im = imagecreate($width*$zoom, $height*$zoom)) === FALSE)
+  if (($im = imagecreate($width*$zoom, $height*$zoom)) === false)
   {
     echo "Could not allocate image data for '".$inFilename."'\n";
-    return FALSE;
+    return false;
   }
 
   $black = imagecolorallocate($im, 0, 0, 0);
@@ -558,7 +558,7 @@
 
   // Read input raw
   $y = 0;
-  while ($y < $height && ($data = fgets($file, 4096)) !== FALSE)
+  while ($y < $height && ($data = fgets($file, 4096)) !== false)
   {
     for ($x = 0; $x < $width; $x++)
     {
@@ -586,15 +586,15 @@
     echo ".";
   }
 
-  if (imagepng($im, $outFilename) === FALSE)
+  if (imagepng($im, $outFilename) === false)
   {
     echo "Error creating '".$outFilename."'\n";
     imagedestroy($im);
-    return FALSE;
+    return false;
   }
 
   imagedestroy($im);
-  return TRUE;
+  return true;
 }
 
 if (!stMakeDir($cfg["pathImageCache"]))
@@ -755,7 +755,7 @@
       if ($im !== false)
       {
         imagecopy($im, $mapData[$cname], $xx, $yy, $tx, $ty, $dx, $dy);
-        $drawn = TRUE;
+        $drawn = true;
       }
     }
   }