summaryrefslogtreecommitdiffstats
path: root/includes/maps.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/maps.php')
-rw-r--r--includes/maps.php28
1 files changed, 26 insertions, 2 deletions
diff --git a/includes/maps.php b/includes/maps.php
index b6912a2..431f006 100644
--- a/includes/maps.php
+++ b/includes/maps.php
@@ -108,7 +108,8 @@ function DisplayMap($mapMatrix, $idprefix = 1, $style = 'normal', $speed = NULL)
$mapdata['example'] = $example;
$mapdata['mapid'] = $idprefix;
- $path = routePath($mapMatrix);
+ //TODO: del
+ //$path = routePath($mapMatrix);
$mapdata['code'] = GenerateMapCode($mapMatrix);
$width = (($j * 35) + 2).'px';
@@ -460,7 +461,8 @@ function GenerateShapedMap($shape, $params) {
}
//echo "\n";
}
- $path = routePath($mapMatrix, true);
+ //$path = routePath($mapMatrix, true);
+ $path = routeMultiPath($mapMatrix, true);
//echo $path['blocked']."\n";
//Only repeat if it's blocked.
} while ($path['blocked'] == true);
@@ -889,6 +891,28 @@ function GetTile($mapMatrix, $id)
return $toReturn;
}
*/
+
+function routeMultiPath($map, $validate = false) {
+ //Check both starting point groups for paths
+ $r['totalMoves'] = 0;
+ $r['blocked'] = false;
+ $containsNormalStart = (findTiles($map, "s") !== false);
+ $containsReverseStart = (findTiles($map, "S") !== false);
+ if($containsNormalStart) {
+ $r['path'][0] = routePath($map, $validate);
+ $r['totalMoves'] += $r['path'][0]['moves'];
+ $r['blocked'] = $r['path'][0]['blocked'];
+ }
+ if ($r['blocked'])
+ return $r;
+ if($containsReverseStart) {
+ //No need to run the "validation" twice;
+ $r['path'][1] = routePath($map, false, true);
+ $r['totalMoves'] += $r['path'][1]['moves'];
+ $r['blocked'] = $r['path'][1]['blocked'] || $r['blocked'];
+ }
+ return $r;
+}
//Routes a path through all checkpoints and teleports, returning an array.
// [path] path-string. [blocked] boolean, [moves] int.