// Set linebreak character if (php_sapi_name() == "cli") { $mapfilter = isset($argv[1]) ? $argv[1] : '*'; $force = isset($argv[2]) ? $argv[2] : 0; $linebreak = "\n"; } 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); }
function LoadLanguages($pattern = 'English') { global $langcode, $lang, $rootpath, $command, $datapath, $mod, $version; if (!isset($langcode)) { $langcode = array(); } if (!isset($lang)) { $lang = array(); } // Characters to strip. The files are binary, and the first few bytes break processing. $langfile_regex = '/[\\x00-\\x08\\x0E-\\x1F\\x80-\\xFF]/s'; // Load languages into array with the key as the proper name and value as the code, ex: ['English'] => 'en' $data = trim(preg_replace($langfile_regex, '', file_get_contents("{$datapath}/sourcemod/configs/languages.cfg"))); $data = parseKeyValues($data); foreach ($data['Languages'] as $code => $name) { $names = is_array($name) ? $name : array($name); foreach ($names as $name) { $name = strtolower($name); $langcode[$name] = $code; } } // Load all language files $langfiles = GetDataFiles("resource/*_" . strtolower($pattern) . ".txt"); foreach ($langfiles as $langfile) { $data = trim(preg_replace($langfile_regex, '', file_get_contents($langfile))); $data = parseKeyValues($data, false); if (!isset($data["lang"]["Tokens"])) { continue; } foreach ($data["lang"]["Tokens"] as $key => $val) { if ($command != 'smtrans') { $key = "#" . strtolower($key); } $key = trim($key); if ($key) { // Sometimes NWI declares a string twice! if (is_array($val)) { $val = $val[0]; } if (!isset($lang[$data["lang"]["Language"]][$key])) { $lang[$data["lang"]["Language"]][$key] = $val; } } } } }
if ($_REQUEST['command'] == 'symlinks') { echo "<pre>\n"; echo "#!/bin/bash\n"; foreach ($maps as $mapname => $mapdata) { echo "if [ -e {$mapname}.bsp ]; then\n"; foreach ($mapdata['gametypes'] as $gametype => $gtdata) { echo "\tln -s {$mapname}.bsp \"{$mapname} {$gametype}.bsp\"\n"; } echo "fi\n"; } exit; } if ($_REQUEST['command'] == 'mapcycle') { $maps = array(); $maplist = array(); $mapfiles = GetDataFiles("maps/*.txt", '*', '*'); foreach ($mapfiles as $mapfile) { $mapname = basename($mapfile, ".txt"); if (in_array($mapname, $excludemaps)) { continue; } $mapdir = dirname($mapfile); $mapver = basename(dirname($mapdir)); $mapmod = basename(dirname(dirname($mapdir))); $mapdata = parseKeyValues(strtolower(file_get_contents($mapfile))); foreach ($mapdata as $name => $item) { if ($name == "#base") { if (!is_array($item)) { $item = array($item); } foreach ($item as $base) {