diff options
-rw-r--r-- | do.php | 32 |
1 files changed, 17 insertions, 15 deletions
@@ -128,22 +128,24 @@ if ($_GET['r'] == 'getpath') { $map = GenerateMapByCode($mapcode);
$mygrid = MergeMapSolution($map, $solution);
- // Old
- //$json = routePath($mygrid);
-
- // New
- // TODO: Broken!
- //Route the path
- $json['path'][] = routePath($mygrid);
- $json['path'][] = routePath($mygrid, false, true);
+ //Check both starting point groups for paths
+ $moves = 0;
+ $json['blocked'] = false;
+ $containsNormalStart = (findTiles($mygrid, "s") !== false);
+ $containsReverseStart = (findTiles($mygrid, "S") !== false);
+ if($containsNormalStart)
+ {
+ $json['path'][0] = routePath($mygrid);
+ $moves += $json['path'][0]['moves'];
+ $json['blocked'] = $json['path'][0]['blocked'];
+ }
+ if($containsReverseStart)
+ {
+ $json['path'][1] = routePath($mygrid, false, true);
+ $moves += $json['path'][1]['moves'];
+ $json['blocked'] = $json['path'][1]['blocked'] || $json['blocked'];
+ }
- // TODO: Tmp
- //$moves = $json['moves'];
- $moves = $json['path1']['moves'];
-
- // TODO: Tmp
- $json['blocked'] = ($json['path1']['blocked']);
-
$json['mapid'] = $mapID;
//What could go wrong?
|