changeset 2416:e2fe94bbca17

Make HTML+JS maps go to continent's main city as default.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 11 Dec 2021 12:49:38 +0200
parents 0f59b108b988
children eba783bef2ee
files www/common.inc.php www/index.php www/world.inc.php
diffstat 3 files changed, 78 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/www/common.inc.php	Wed Nov 17 07:00:22 2021 +0200
+++ b/www/common.inc.php	Sat Dec 11 12:49:38 2021 +0200
@@ -211,27 +211,23 @@
 }
 
 
-function mpGetURLLink($url, $name, $extra = FALSE)
-{
-  return
-    "<a ".($extra !== FALSE ? $extra." " : "").
-    "href=\"".$url."\">".chentities($name)."</a>";
-}
-
-
 function mpGetMapURLLink($data, $link, $name, $gmap)
 {
   global $pageGMapURL, $continentList;
   if ($link)
   {
-    $str = mpGetURLLink($data["continent"].".html#loc".$data["x"]."_".$data["y"], $name, "class=\"mapLink\"");
     $c = $continentList[$data["continent"]];
+
+    $str = "<a class=\"mapLink\" href=\"".
+      $data["continent"].".html#loc".$data["x"]."_".$data["y"].
+      "\">".chentities($name)."</a>";
+
     if (isset($pageGMapURL) && $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"].
-      "&amp;y=".$data["globaly"]."&amp;zoom=9\">&#x2605;</a>";
+      "&amp;y=".$data["globaly"]."&amp;zoom=10\">&#x2605;</a>";
     }
     return $str;
   }
--- a/www/index.php	Wed Nov 17 07:00:22 2021 +0200
+++ b/www/index.php	Sat Dec 11 12:49:38 2021 +0200
@@ -51,7 +51,15 @@
 }
 
 
-function mpPrintLine($n, $filename, $mapName, $noExtra = FALSE)
+function mpGetURLLink($url, $name, $extra = FALSE)
+{
+  return
+    "<a ".($extra !== FALSE ? $extra." " : "").
+    "href=\"".$url."\">".chentities($name)."</a>";
+}
+
+
+function mpPrintLineBase($n, $filename, $mapName, $urlExtra)
 {
   global $lastMTime;
   mpPrintTR($n);
@@ -63,42 +71,31 @@
   if (file_exists($fname))
   {
     mpCheckMTime($fname);
-    echo mpGetURLLink($fname, $mapName);
+    echo mpGetURLLink($fname.$urlExtra, $mapName);
   }
   else
-    echo "  <td>".$mapName."</td>\n";
+    echo $mapName;
 
   if (file_exists($filename.".htm"))
-    echo " ".mpGetURLLink($filename.".htm", "(*)");
+    echo " ".mpGetURLLink($filename.".htm".$urlExtra, "(*)");
 
   echo "</td>\n";
+}
 
-  if ($noExtra)
-  {
-    $mtime1 = mpPrintFileTD($filename.".map", "ASCII");
-    $mtime2 = mpCheckMTime($filename.".loc");
-    if ($mtime1 > 0 || $mtime2 > 0)
-      echo "  <td>".mpGetMTimeStr($mtime1 > $mtime2 ? $mtime1 : $mtime2)."</td>\n";
-  }
-  else
-  {
-    mpPrintFileTD($filename.".png", "PNG");
-    mpPrintFileTD($filename.".ansi", "ANSI");
+
+function mpPrintLine($n, $filename, $mapName)
+{
+  mpPrintLineBase($n, $filename, $mapName, "");
 
-    if (file_exists($filename.".loc"))
-    {
-      echo "  <td>";
-      echo "[<a href=\"loc.php?n=".$filename."\">Locations</a>] ";
-      echo "[<a href=\"loc.php?c&amp;n=".$filename."\">PCities</a>] ";
-      echo "</td>\n";
-    }
-    else
-      echo "  <td>-</td>\n";
-  }
+  $mtime1 = mpPrintFileTD($filename.".map", "ASCII");
+  $mtime2 = mpCheckMTime($filename.".loc");
+  if ($mtime1 > 0 || $mtime2 > 0)
+    echo "  <td>".mpGetMTimeStr($mtime1 > $mtime2 ? $mtime1 : $mtime2)."</td>\n";
 
   echo " </tr>\n";
 }
 
+
 mpPrintPageHeader($pageTitle);
 
 if (1)
@@ -153,8 +150,30 @@
 $lastMTime = 0;
 foreach ($continentList as $continent => $data)
 {
-  if (!$data[3])
-    mpPrintLine($n++, $continent, $data[0]);
+  if (!$data[CTI_SPECIAL])
+  {
+    mpPrintLineBase($n++, $continent, $data[CTI_NAME],
+      is_array($data[CTI_INIT_LOC]) ? "#loc".$data[CTI_INIT_LOC][0]."_".$data[CTI_INIT_LOC][1] : "");
+
+    mpPrintFileTD($continent.".png", "PNG");
+    mpPrintFileTD($continent.".ansi", "ANSI");
+
+    echo "  <td>";
+    if (file_exists($continent.".loc"))
+    {
+      echo
+        "[<a href=\"loc.php?n=".$continent."\">Locations</a>] ".
+        "[<a href=\"loc.php?c&amp;n=".$continent."\">PCities</a>]";
+    }
+    else
+    {
+      echo "-";
+    }
+
+    echo
+      "</td>\n".
+      " </tr>\n";
+  }
 }
 
 echo
@@ -172,22 +191,22 @@
   "  </tr>\n";
 
 $n = 0;
-mpPrintLine($n++, "dortlewall", "Village of Dortlewall", TRUE);
-mpPrintLine($n++, "arelium", "City of Arelium", TRUE);
-mpPrintLine($n++, "calythien", "City of Calythien", TRUE);
-mpPrintLine($n++, "lorenchia", "City of Lorenchia", TRUE);
-mpPrintLine($n++, "rilynttar", "City of Rilynt'tar", TRUE);
-mpPrintLine($n++, "esiris", "E'siris, the Ethereal City (upper level)", TRUE);
-mpPrintLine($n++, "esiris2", "E'siris, the Ethereal City (lower level)", TRUE);
-mpPrintLine($n++, "votk", "Valley of the Kings", TRUE);
-mpPrintLine($n++, "lanzia", "The Isle of Lanzia", TRUE);
-mpPrintLine($n++, "faerieforest", "Faerie Forest", TRUE);
-mpPrintLine($n++, "renardy", "Renardy", TRUE);
-mpPrintLine($n++, "tyr_farwyn", "Tyr Farwyn", TRUE);
-mpPrintLine($n++, "vendace_shore", "Vendace Shore", TRUE);
-//mpPrintLine($n++, "tormentas", "Islas de Tormentas", TRUE);
+mpPrintLine($n++, "dortlewall", "Village of Dortlewall");
+mpPrintLine($n++, "arelium", "City of Arelium");
+mpPrintLine($n++, "calythien", "City of Calythien");
+mpPrintLine($n++, "lorenchia", "City of Lorenchia");
+mpPrintLine($n++, "rilynttar", "City of Rilynt'tar");
+mpPrintLine($n++, "esiris", "E'siris, the Ethereal City (upper level)");
+mpPrintLine($n++, "esiris2", "E'siris, the Ethereal City (lower level)");
+mpPrintLine($n++, "votk", "Valley of the Kings");
+mpPrintLine($n++, "lanzia", "The Isle of Lanzia");
+mpPrintLine($n++, "faerieforest", "Faerie Forest");
+mpPrintLine($n++, "renardy", "Renardy");
+mpPrintLine($n++, "tyr_farwyn", "Tyr Farwyn");
+mpPrintLine($n++, "vendace_shore", "Vendace Shore");
+//mpPrintLine($n++, "tormentas", "Islas de Tormentas");
 
-mpPrintLine($n++, "batcity", "Old BatCity map", TRUE);
+mpPrintLine($n++, "batcity", "Old BatCity map");
 mpPrintTR($n++);
 
 $filename = "hcbat";
--- a/www/world.inc.php	Wed Nov 17 07:00:22 2021 +0200
+++ b/www/world.inc.php	Sat Dec 11 12:49:38 2021 +0200
@@ -16,22 +16,23 @@
 define("CTI_WIDTH"        , 5);
 define("CTI_HEIGHT"       , 6);
 define("CTI_REG_CONT"     , 7);
+define("CTI_INIT_LOC"     , 8);
 
 $continentList =
 [
   // ID             Name                   Xoffs   Yoffs  spec    hasmap  width   height  <read in regular continent list>
-  "laenor"      => ["Laenor",              1    ,  1    , FALSE , TRUE  , 827   , 781   , TRUE  ],
-  "rothikgen"   => ["Rothikgen",           1311 , -1255 , FALSE , TRUE  , 480   , 480   , TRUE  ],
-  "lucentium"   => ["Lucentium",          -634  ,  2345 , FALSE , TRUE  , 700   , 500   , TRUE  ],
-  "furnachia"   => ["Furnachia",           1211 ,  1155 , FALSE , TRUE  , 440   , 480   , TRUE  ],
-  "desolathya"  => ["Desolathya",         -1210 ,  820  , FALSE , TRUE  , 540   , 530   , TRUE  ],
+  "laenor"      => ["Laenor",              1    ,  1    , FALSE , TRUE  , 827   , 781   , TRUE    , [365, 471] ],
+  "rothikgen"   => ["Rothikgen",           1311 , -1255 , FALSE , TRUE  , 480   , 480   , TRUE    , [224, 271] ],
+  "lucentium"   => ["Lucentium",          -634  ,  2345 , FALSE , TRUE  , 700   , 500   , TRUE    , [413, 153] ],
+  "furnachia"   => ["Furnachia",           1211 ,  1155 , FALSE , TRUE  , 440   , 480   , TRUE    , [197, 85] ],
+  "desolathya"  => ["Desolathya",         -1210 ,  820  , FALSE , TRUE  , 540   , 530   , TRUE    , [285, 272] ],
 
-  "renardy"     => ["Renardy",             2070 , -910  , TRUE  , TRUE  , 168   , 86    , TRUE  ],
-# "tormentas"   => ["Tormentas",  1311 - 34 - 99, -1255 - 85 - 99 , TRUE  , TRUE  , 99    , 99, TRUE ],
+  "renardy"     => ["Renardy",             2070 , -910  , TRUE  , TRUE  , 168   , 86    , TRUE    , NULL ],
+# "tormentas"   => ["Tormentas",  1311 - 34 - 99, -1255 - 85 - 99 , TRUE  , TRUE  , 99    , 99, TRUE  , NULL ],
 
-  "limbo"       => ["Limbo",               0    ,  0    , TRUE  , FALSE , 0     , 0     , FALSE ],
-  "special"     => ["Special",             0    ,  0    , TRUE  , FALSE , 0     , 0     , TRUE ],
-  "hcbat"       => ["HCBat",               0    ,  0    , TRUE  , TRUE  , 0     , 0     , FALSE ],
+  "limbo"       => ["Limbo",               0    ,  0    , TRUE  , FALSE , 0     , 0     , FALSE   , NULL ],
+  "special"     => ["Special",             0    ,  0    , TRUE  , FALSE , 0     , 0     , TRUE    , NULL ],
+  "hcbat"       => ["HCBat",               0    ,  0    , TRUE  , TRUE  , 0     , 0     , FALSE   , [103, 53] ],
 ];