Mercurial > hg > batmud > maputils
changeset 621:537fae9ebf1d
Synced.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 26 Jun 2008 20:43:23 +0000 |
parents | 97ae939651cd |
children | 6d2c28904660 |
files | www/common.inc.php www/loc.php www/ss.php |
diffstat | 3 files changed, 55 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/www/common.inc.php Thu Jun 26 19:23:39 2008 +0000 +++ b/www/common.inc.php Thu Jun 26 20:43:23 2008 +0000 @@ -33,8 +33,22 @@ } -function parseLocFile($filename, &$locations, $showPCities) +$locationTypes = array( + ";" => array(FALSE, "ALL", "Locations"), + "S" => array(TRUE, "SHRINE", "Shrines"), + "G" => array(TRUE, "GUILD", "Guilds"), + "P" => array(TRUE, "SS", "Outworld Secret Societies"), + "M" => array(TRUE, "MONSTER", "Special Outworld Monsters"), + "c" => array(TRUE, "CITY", "Cities"), + "T" => array(TRUE, "TRAINER", "Guild Trainers"), + "C" => array(FALSE,"PCITY", "Player Cities"), +); + + +function parseLocFile($filename, &$locations, $applyFilter, $filter) { + global $locationTypes; + $inFile = @fopen($filename.".loc", "r"); if (!$inFile) { return FALSE; @@ -65,20 +79,19 @@ $added = -1; if (!strstr($m[3], "-")) { - - if (strstr($m[3], "C")) - $isPCity = TRUE; - else - $isPCity = FALSE; - - if (($showPCities && $isPCity) || (!$showPCities && !$isPCity)) { + $filterMatch = strpos($m[3], $filter) !== FALSE; + if (($applyFilter && $filterMatch) || (!$applyFilter && !$filterMatch)) { + $s = ""; - if (strstr($m[3], "S")) $s = "SHRINE "; - else if (strstr($m[3], "G")) $s = "GUILD "; - else if (strstr($m[3], "P")) $s = "SS "; - else if (strstr($m[3], "M")) $s = "MONSTER "; - else if (strstr($m[3], "c")) $s = "CITY "; - else if (strstr($m[3], "T")) $s = "TRAINER "; + $flags = $m[3]; + $found = FALSE; + for ($i = 0; $found === FALSE && $i < strlen($flags); $i++) { + if (array_key_exists($flags[$i], $locationTypes)) { + $found = $flags[$i]; + if (!$filterMatch && $locationTypes[$found][0]) + $s = $locationTypes[$found][1]." "; + } + } $s .= $m[4]; if (isset($locations[$s])) { @@ -110,7 +123,7 @@ } -function readLocationFiles($onlyPCities) +function readLocationFiles($applyFilter, $filter = "C") { global $continentList, $specialList; @@ -118,12 +131,12 @@ reset($continentList); while (list($iKey, $iValue) = each($continentList)) { - parseLocFile($iKey, $locations, $onlyPCities); + parseLocFile($iKey, $locations, $applyFilter, $filter); } reset($specialList); while (list($iKey, $iValue) = each($specialList)) { - parseLocFile($iKey, $locations, $onlyPCities); + parseLocFile($iKey, $locations, $applyFilter, $filter); } reset($specialList);
--- a/www/loc.php Thu Jun 26 19:23:39 2008 +0000 +++ b/www/loc.php Thu Jun 26 20:43:23 2008 +0000 @@ -34,6 +34,19 @@ $onlyPCities = isset($_GET["c"]); +if ($onlyPCities) { + $filter = "C"; + $applyFilter = TRUE; +} else { + if (isset($_GET["f"])) { + $filter = $_GET["f"]; + $applyFilter = TRUE; + } else { + $filter = "C"; + $applyFilter = FALSE; + } +} + $showCoders = !isset($_GET["s"]); if (isset($_GET["a"])) { @@ -46,24 +59,30 @@ $locTable = array(); $setName = strtolower(basename($_GET["n"])); if (file_exists($setName.".loc")) { - parseLocFile($setName, $locTable, $onlyPCities); + parseLocFile($setName, $locTable, $applyFilter, $filter); } else { echo "<h1>No such continent ID!</h1>"; unset($setName); } } else { - $locTable = readLocationFiles($onlyPCities); + $locTable = readLocationFiles($applyFilter, $filter); } /* Start of the page */ echo "<h1>"; -if ($onlyPCities) - echo "Player cities"; -else +if ($applyFilter) { + if (array_key_exists($filter, $locationTypes)) { + echo $locationTypes[$filter][2]; + } else { + echo "lol?"; + } +} else echo "Locations"; + echo " of "; + if (isset($continentList[$setName])) echo $continentList[$setName]." continent in "; else
--- a/www/ss.php Thu Jun 26 19:23:39 2008 +0000 +++ b/www/ss.php Thu Jun 26 20:43:23 2008 +0000 @@ -7,7 +7,7 @@ printPageHeader($pageTitle." - Secret societies"); //echo "<div><b>DEVELOPMENT VERSION</b></div>"; -$locTable = readLocationFiles(TRUE); +$locTable = readLocationFiles(TRUE, "C"); /* Header */