//Root Path Discovery
do {
    $rd = isset($rd) ? dirname($rd) : realpath(dirname(__FILE__));
    $tp = "{$rd}/rootpath.php";
    if (file_exists($tp)) {
        require_once $tp;
        break;
    }
} while ($rd != '/');
require_once "{$includepath}/functions.php";
$files = glob("{$datapath}/maps/navmesh/*.json");
//Open all files and add gamemodes and other map info to array
//var_dump($files);
foreach ($files as $file) {
    $map = basename($file, ".json");
    ParseMap($map);
}
function ParseMap($map)
{
    echo "Starting {$map}... ";
    if (file_exists("{$datapath}maps/navmesh/{$map}.png")) {
        if (filemtime("{$datapath}maps/navmesh/{$map}.json") < filemtime("{$datapath}maps/navmesh/{$map}.png")) {
            echo "<i>Not processing {$map}, no new data</i><br>\n";
            return;
        }
    }
    $data = json_decode(file_get_contents("{$datapath}maps/navmesh/{$map}.json"), true);
    /*
    	$tile = imagecreatetruecolor(32,16);
    	$black = imagecolorallocatealpha($tile, 0, 0, 0, 64);
    	$yellow = imagecolorallocatealpha($tile, 255, 255, 0, 64);
예제 #2
0
} else {
    // Only run from CLI
    exit;
    $mapfilter = isset($_REQUEST['mapfilter']) ? $_REQUEST['mapfilter'] : '*';
    $force = isset($_REQUEST['force']);
    $linebreak = "<br>\n";
}
// MapData version
$mapdata_version = 1;
// Get all map text files. This could probably be safer.
$files = GetDataFiles("resource/overviews/{$mapfilter}.txt");
// Open all files and add gamemodes and other map info to array
foreach ($files as $file) {
    $mapname = basename($file, ".txt");
    if (CheckMap($mapname, $force)) {
        ParseMap($mapname);
    }
}
exit;
// Parse the map into JSON
function recur_ksort(&$array)
{
    foreach ($array as &$value) {
        if (is_array($value)) {
            recur_ksort($value);
        }
    }
    return ksort($array);
}
function CheckMap($mapname, $force = 0)
{