changeset 2032:d9c15f7ae4c4

Add defines for continent list array index constants and use them.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 26 Jan 2019 01:27:14 +0200
parents 0aea3a66f2db
children 57ecb49d7b4a
files www/common.inc.php www/latest.php www/level.php www/loc.php www/quests.php www/simple.php www/ss.php www/world.inc.php
diffstat 8 files changed, 25 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/www/common.inc.php	Tue Jan 22 15:40:17 2019 +0200
+++ b/www/common.inc.php	Sat Jan 26 01:27:14 2019 +0200
@@ -179,7 +179,7 @@
   {
     $str = mpGetURLLink($data["continent"].".html#loc".$data["x"]."_".$data["y"], $name, "class=\"mapLink\"");
     $c = $continentList[$data["continent"]];
-    if ($gmap && $c[4] == TRUE && $c[7] == TRUE) // hasmap & read regular cont must be true
+    if ($gmap && $c[CTI_HAS_MAP] == TRUE && $c[CTI_REG_CONT] == TRUE) // hasmap & read regular cont must be true
     {
       $str .= " <a class=\"gmapLink\" title=\"GMap link\" ".
       "href=\"".$pageGMapURL."?x=".$data["globalx"].
@@ -234,8 +234,8 @@
   global $continentList, $worldMap;
   if (isset($continentList[$continent]))
   {
-    $gx = $worldMap["ox"] + $continentList[$continent][1] + $xc - 1;
-    $gy = $worldMap["oy"] + $continentList[$continent][2] + $yc - 1;
+    $gx = $worldMap["ox"] + $continentList[$continent][CTI_XOFFS] + $xc - 1;
+    $gy = $worldMap["oy"] + $continentList[$continent][CTI_YOFFS] + $yc - 1;
     return TRUE;
   }
   else
@@ -380,7 +380,7 @@
 
   foreach ($continentList as $id => $data)
   {
-    if ($data[7])
+    if ($data[CTI_REG_CONT])
       mpParseLocFile($id, $locations, $applyFilter, $filterStr);
   }
 
--- a/www/latest.php	Tue Jan 22 15:40:17 2019 +0200
+++ b/www/latest.php	Sat Jan 26 01:27:14 2019 +0200
@@ -82,8 +82,8 @@
       " <tr>\n".
       "  <td>".(($iv["added"] <= 0) ? "?" : mpStrFTime($iv["added"]))."</td>\n".
       "  <td class=\"".$iv["continent"]."\">".mpGetMapLink($iv, TRUE)."</td>\n".
-      "  <td>".$continentList[$iv["continent"]][0]."</td>\n".
       ($showAll ? "  <th>".$iv["flags"]."</td>\n" : "").
+      "  <td>".$continentList[$iv["continent"]][CTI_NAME]."</td>\n".
       "  <td>".implode(", ", $fs)."</td>\n".
       "  <td>".(isset($iv["freeform"]) ? chentities($iv["freeform"]) : "")."</td>\n".
       " </tr>\n";
--- a/www/level.php	Tue Jan 22 15:40:17 2019 +0200
+++ b/www/level.php	Sat Jan 26 01:27:14 2019 +0200
@@ -61,10 +61,10 @@
     echo
       "  <tr>\n".
       "   <td>".
-      mpGetMapLink($loc, !isset($continentList[$loc["continent"]]) || $continentList[$loc["continent"]][4]).
+      mpGetMapLink($loc, !isset($continentList[$loc["continent"]]) || $continentList[$loc["continent"]][CTI_HAS_MAP]).
       "</td>\n".
       "   <td>".($data["limit"] > 0 ? $data["limit"] : "?")."</td>\n".
-      ($hcbat ? "" : "   <td class=\"".$loc["continent"]."\">".$continentList[$loc["continent"]][0]."</td>").
+      ($hcbat ? "" : "   <td class=\"".$loc["continent"]."\">".$continentList[$loc["continent"]][CTI_NAME]."</td>").
       "   <td>".chentities($loc["freeform"])."</td>\n".
       "  </tr>\n";
   }
--- a/www/loc.php	Tue Jan 22 15:40:17 2019 +0200
+++ b/www/loc.php	Sat Jan 26 01:27:14 2019 +0200
@@ -172,8 +172,8 @@
 
 if (isset($setName) && isset($continentList[$setName]))
 {
-  $mtitle .= $continentList[$setName][0].
-    ($continentList[$setName][3] ? " in " : " continent in ");
+  $mtitle .= $continentList[$setName][CTI_NAME].
+    ($continentList[$setName][CTI_SPECIAL] ? " in " : " continent in ");
 }
 
 mpPrintPageHeader($pageTitle." - Locations",
@@ -204,7 +204,7 @@
 printTitleLink($applyFilter, $filterID, $showCoders, "All&nbsp;continents", "", "all");
 foreach ($continentList as $continent => $data)
 {
-  if ($data[4])
+  if ($data[CTI_HAS_MAP])
     printTitleLink($applyFilter, $filterID, $showCoders, $data[0], $continent, $continent);
 }
 printTitleLink($applyFilter, $filterID, $showCoders, "Special", "special", "special");
@@ -320,7 +320,7 @@
       echo
         "  <div class=\"locCell ".$iv["continent"]."\">".
         "<div class=\"locHeader\">".
-        "<span class=\"locTitle\">".mpGetMapLink($iv, $continentList[$iv["continent"]][4])."</span>";
+        "<span class=\"locTitle\">".mpGetMapLink($iv, $continentList[$iv["continent"]][CTI_HAS_MAP])."</span>";
 
       // If either freeform desc or URL field are set, we add those
       if (isset($iv["url"]) || isset($iv["freeform"]))
--- a/www/quests.php	Tue Jan 22 15:40:17 2019 +0200
+++ b/www/quests.php	Sat Jan 26 01:27:14 2019 +0200
@@ -23,9 +23,9 @@
   echo
     "<td><a href=\"".$batQuestURL.urlencode($name)."\">".chentities($name)."</a></td>".
     "<td class=\"".$area["continent"]."\">".
-    mpGetMapLink($area, !isset($continentList[$area["continent"]]) || $continentList[$area["continent"]][4]).
+    mpGetMapLink($area, !isset($continentList[$area["continent"]]) || $continentList[$area["continent"]][CTI_HAS_MAP]).
     "</td>".
-    ($hcbat ? "" : "<td><a href=\"loc.php?n=".$area["continent"]."\">".$continentList[$area["continent"]][0]."</a></td>");
+    ($hcbat ? "" : "<td><a href=\"loc.php?n=".$area["continent"]."\">".$continentList[$area["continent"]][CTI_NAME]."</a></td>");
 }
 
 
--- a/www/simple.php	Tue Jan 22 15:40:17 2019 +0200
+++ b/www/simple.php	Sat Jan 26 01:27:14 2019 +0200
@@ -58,7 +58,7 @@
       // Print location entry
       echo
         " <tr>\n".
-        "  <td class=\"name\">".mpGetMapLink($iv, $continentList[$iv["continent"]][4], FALSE)."</td>\n".
+        "  <td class=\"name\">".mpGetMapLink($iv, $continentList[$iv["continent"]][CTI_HAS_MAP], FALSE)."</td>\n".
         "  <td class=\"continent ".$iv["continent"]."\">".$iv["continent"]."</td>\n".
         "  <td class=\"coords\">".$iv["x"].", ".$iv["y"]."</td>\n";
 
--- a/www/ss.php	Tue Jan 22 15:40:17 2019 +0200
+++ b/www/ss.php	Sat Jan 26 01:27:14 2019 +0200
@@ -45,12 +45,12 @@
   foreach ($sortTable as $name => $data)
   {
     $cont = $data["continent"];
-    $link = $continentList[$cont][4];
+    $link = $continentList[$cont][CTI_HAS_MAP];
     echo
       " <tr>\n".
       "  <td>".mpGetMapURLLink($data, $link, $name)."</td>\n".
       "  <td class=\"".$cont."\">".mpGetMapLink($data, $link)."</td>\n".
-      "  <td>".chentities($continentList[$cont][0])."</td>\n".
+      "  <td>".chentities($continentList[$cont][CTI_NAME])."</td>\n".
       " </tr>\n";
   }
   echo
--- a/www/world.inc.php	Tue Jan 22 15:40:17 2019 +0200
+++ b/www/world.inc.php	Sat Jan 26 01:27:14 2019 +0200
@@ -8,6 +8,15 @@
 
 // Define continents, their coordinates in the "world map",
 // dimensions and other attributes relevant to us.
+define("CTI_NAME"         , 0);
+define("CTI_XOFFS"        , 1);
+define("CTI_YOFFS"        , 2);
+define("CTI_SPECIAL"      , 3);
+define("CTI_HAS_MAP"      , 4);
+define("CTI_WIDTH"        , 5);
+define("CTI_HEIGHT"       , 6);
+define("CTI_REG_CONT"     , 7);
+
 $continentList =
 [
   // ID                   Name                  Xoffs   Yoffs  spec    hasmap  width   height   <read in regular continent list>