mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Profiler/CLI
* move command line related functions to its own class
This commit is contained in:
@@ -9,8 +9,13 @@ if (file_exists('config/config.php'))
|
|||||||
else
|
else
|
||||||
$AoWoWconf = [];
|
$AoWoWconf = [];
|
||||||
|
|
||||||
|
|
||||||
mb_internal_encoding('UTF-8');
|
mb_internal_encoding('UTF-8');
|
||||||
|
|
||||||
|
|
||||||
|
define('OS_WIN', substr(PHP_OS, 0, 3) == 'WIN');
|
||||||
|
|
||||||
|
|
||||||
require_once 'includes/defines.php';
|
require_once 'includes/defines.php';
|
||||||
require_once 'includes/libs/DbSimple/Generic.php'; // Libraray: http://en.dklab.ru/lib/DbSimple (using variant: https://github.com/ivan1986/DbSimple/tree/master)
|
require_once 'includes/libs/DbSimple/Generic.php'; // Libraray: http://en.dklab.ru/lib/DbSimple (using variant: https://github.com/ivan1986/DbSimple/tree/master)
|
||||||
require_once 'includes/utilities.php'; // helper functions
|
require_once 'includes/utilities.php'; // helper functions
|
||||||
|
|||||||
@@ -16,6 +16,258 @@ class SimpleXML extends SimpleXMLElement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class CLI
|
||||||
|
{
|
||||||
|
const CHR_BELL = 7;
|
||||||
|
const CHR_BACK = 8;
|
||||||
|
const CHR_TAB = 9;
|
||||||
|
const CHR_LF = 10;
|
||||||
|
const CHR_CR = 13;
|
||||||
|
const CHR_ESC = 27;
|
||||||
|
const CHR_BACKSPACE = 127;
|
||||||
|
|
||||||
|
const LOG_OK = 0;
|
||||||
|
const LOG_WARN = 1;
|
||||||
|
const LOG_ERROR = 2;
|
||||||
|
const LOG_INFO = 3;
|
||||||
|
|
||||||
|
private static $logHandle = null;
|
||||||
|
private static $hasReadline = null;
|
||||||
|
|
||||||
|
|
||||||
|
/***********/
|
||||||
|
/* logging */
|
||||||
|
/***********/
|
||||||
|
|
||||||
|
public static function initLogFile($file = '')
|
||||||
|
{
|
||||||
|
if (!$file)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$file = self::nicePath($file);
|
||||||
|
if (!file_exists($file))
|
||||||
|
self::$logHandle = fopen($file, 'w');
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$logFileParts = pathinfo($file);
|
||||||
|
|
||||||
|
$i = 1;
|
||||||
|
while (file_exists($logFileParts['dirname'].'/'.$logFileParts['filename'].$i.(isset($logFileParts['extension']) ? '.'.$logFileParts['extension'] : '')))
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
$file = $logFileParts['dirname'].'/'.$logFileParts['filename'].$i.(isset($logFileParts['extension']) ? '.'.$logFileParts['extension'] : '');
|
||||||
|
self::$logHandle = fopen($file, 'w');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function red($str)
|
||||||
|
{
|
||||||
|
return OS_WIN ? $str : "\e[31m".$str."\e[0m";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function green($str)
|
||||||
|
{
|
||||||
|
return OS_WIN ? $str : "\e[32m".$str."\e[0m";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function yellow($str)
|
||||||
|
{
|
||||||
|
return OS_WIN ? $str : "\e[33m".$str."\e[0m";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function blue($str)
|
||||||
|
{
|
||||||
|
return OS_WIN ? $str : "\e[36m".$str."\e[0m";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function bold($str)
|
||||||
|
{
|
||||||
|
return OS_WIN ? $str : "\e[1m".$str."\e[0m";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function write($txt = '', $lvl = -1)
|
||||||
|
{
|
||||||
|
$msg = "\n";
|
||||||
|
if ($txt)
|
||||||
|
{
|
||||||
|
$msg = str_pad(date('H:i:s'), 10);
|
||||||
|
switch ($lvl)
|
||||||
|
{
|
||||||
|
case self::LOG_ERROR: // red critical error
|
||||||
|
$msg .= '['.self::red('ERR').'] ';
|
||||||
|
break;
|
||||||
|
case self::LOG_WARN: // yellow notice
|
||||||
|
$msg .= '['.self::yellow('WARN').'] ';
|
||||||
|
break;
|
||||||
|
case self::LOG_OK: // green success
|
||||||
|
$msg .= '['.self::green('OK').'] ';
|
||||||
|
break;
|
||||||
|
case self::LOG_INFO: // blue info
|
||||||
|
$msg .= '['.self::blue('INFO').'] ';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$msg .= ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$msg .= $txt."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $msg;
|
||||||
|
|
||||||
|
if (self::$logHandle) // remove highlights for logging
|
||||||
|
fwrite(self::$logHandle, preg_replace(["/\e\[\d+m/", "/\e\[0m/"], '', $msg));
|
||||||
|
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function nicePath(/* $file = '', ...$pathParts */)
|
||||||
|
{
|
||||||
|
$path = '';
|
||||||
|
|
||||||
|
switch (func_num_args())
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return '';
|
||||||
|
case 1:
|
||||||
|
$path = func_get_arg(0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$args = func_get_args();
|
||||||
|
$file = array_shift($args);
|
||||||
|
$path = implode(DIRECTORY_SEPARATOR, $args).DIRECTORY_SEPARATOR.$file;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DIRECTORY_SEPARATOR == '/') // *nix
|
||||||
|
{
|
||||||
|
$path = str_replace('\\', '/', $path);
|
||||||
|
$path = preg_replace('/\/+/i', '/', $path);
|
||||||
|
}
|
||||||
|
else if (DIRECTORY_SEPARATOR == '\\') // win
|
||||||
|
{
|
||||||
|
$path = str_replace('/', '\\', $path);
|
||||||
|
$path = preg_replace('/\\\\+/i', '\\', $path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
CLI::write('Dafuq! Your directory separator is "'.DIRECTORY_SEPARATOR.'". Please report this!', CLI::LOG_ERROR);
|
||||||
|
|
||||||
|
$path = trim($path);
|
||||||
|
|
||||||
|
// resolve *nix home shorthand
|
||||||
|
if (!OS_WIN)
|
||||||
|
{
|
||||||
|
if (preg_match('/^~(\w+)\/.*/i', $path, $m))
|
||||||
|
$path = '/home/'.substr($path, 1);
|
||||||
|
else if (substr($path, 0, 2) == '~/')
|
||||||
|
$path = getenv('HOME').substr($path, 1);
|
||||||
|
else if ($path[0] == DIRECTORY_SEPARATOR && substr($path, 0, 6) != '/home/')
|
||||||
|
$path = substr($path, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove quotes (from erronous user input)
|
||||||
|
$path = str_replace(['"', "'"], ['', ''], $path);
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************/
|
||||||
|
/* read input */
|
||||||
|
/**************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
since the CLI on WIN ist not interactive, the following things have to be considered
|
||||||
|
you do not receive keystrokes but whole strings upon pressing <Enter> (wich also appends a \r)
|
||||||
|
as such <ESC> and probably other control chars can not be registered
|
||||||
|
this also means, you can't hide input at all, least process it
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static function readInput(&$fields, $singleChar = false)
|
||||||
|
{
|
||||||
|
// first time set
|
||||||
|
if (self::$hasReadline === null)
|
||||||
|
self::$hasReadline = function_exists('readline_callback_handler_install');
|
||||||
|
|
||||||
|
// prevent default output if able
|
||||||
|
if (self::$hasReadline)
|
||||||
|
readline_callback_handler_install('', function() { });
|
||||||
|
|
||||||
|
foreach ($fields as $name => $data)
|
||||||
|
{
|
||||||
|
$vars = ['desc', 'isHidden', 'validPattern'];
|
||||||
|
foreach ($vars as $idx => $v)
|
||||||
|
$$v = isset($data[$idx]) ? $data[$idx] : false;
|
||||||
|
|
||||||
|
$charBuff = '';
|
||||||
|
|
||||||
|
if ($desc)
|
||||||
|
echo "\n".$desc.": ";
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
$r = [STDIN];
|
||||||
|
$w = $e = null;
|
||||||
|
$n = stream_select($r, $w, $e, 200000);
|
||||||
|
|
||||||
|
if ($n && in_array(STDIN, $r)) {
|
||||||
|
$char = stream_get_contents(STDIN, 1);
|
||||||
|
$keyId = ord($char);
|
||||||
|
|
||||||
|
// ignore this one
|
||||||
|
if ($keyId == self::CHR_TAB)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// WIN sends \r\n as sequence, ignore one
|
||||||
|
if ($keyId == self::CHR_CR && OS_WIN)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// will not be send on WIN .. other ways of returning from setup? (besides ctrl + c)
|
||||||
|
if ($keyId == self::CHR_ESC)
|
||||||
|
{
|
||||||
|
echo chr(self::CHR_BELL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if ($keyId == self::CHR_BACKSPACE)
|
||||||
|
{
|
||||||
|
if (!$charBuff)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$charBuff = mb_substr($charBuff, 0, -1);
|
||||||
|
if (!$isHidden && self::$hasReadline)
|
||||||
|
echo chr(self::CHR_BACK)." ".chr(self::CHR_BACK);
|
||||||
|
}
|
||||||
|
else if ($keyId == self::CHR_LF)
|
||||||
|
{
|
||||||
|
$fields[$name] = $charBuff;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (!$validPattern || preg_match($validPattern, $char))
|
||||||
|
{
|
||||||
|
$charBuff .= $char;
|
||||||
|
if (!$isHidden && self::$hasReadline)
|
||||||
|
echo $char;
|
||||||
|
|
||||||
|
if ($singleChar && self::$hasReadline)
|
||||||
|
{
|
||||||
|
$fields[$name] = $charBuff;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo chr(self::CHR_BELL);
|
||||||
|
|
||||||
|
foreach ($fields as $f)
|
||||||
|
if (strlen($f))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
$fields = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Util
|
class Util
|
||||||
{
|
{
|
||||||
const FILE_ACCESS = 0777;
|
const FILE_ACCESS = 0777;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ require_once 'setup/tools/imagecreatefromblp.func.php';
|
|||||||
function finish()
|
function finish()
|
||||||
{
|
{
|
||||||
if (!getopt('d', ['delete'])) // generated with TEMPORARY keyword. Manual deletion is not needed
|
if (!getopt('d', ['delete'])) // generated with TEMPORARY keyword. Manual deletion is not needed
|
||||||
CLISetup::log('generated dbc_* - tables kept available', CLISetup::LOG_INFO);
|
CLI::write('generated dbc_* - tables kept available', CLI::LOG_INFO);
|
||||||
|
|
||||||
die("\n");
|
die("\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,24 +9,6 @@ if (!CLI)
|
|||||||
|
|
||||||
class CLISetup
|
class CLISetup
|
||||||
{
|
{
|
||||||
const CHR_BELL = 7;
|
|
||||||
const CHR_BACK = 8;
|
|
||||||
const CHR_TAB = 9;
|
|
||||||
const CHR_LF = 10;
|
|
||||||
const CHR_CR = 13;
|
|
||||||
const CHR_ESC = 27;
|
|
||||||
const CHR_BACKSPACE = 127;
|
|
||||||
|
|
||||||
const LOG_OK = 0;
|
|
||||||
const LOG_WARN = 1;
|
|
||||||
const LOG_ERROR = 2;
|
|
||||||
const LOG_INFO = 3;
|
|
||||||
|
|
||||||
private static $win = true;
|
|
||||||
private static $hasReadline = false;
|
|
||||||
private static $logFile = '';
|
|
||||||
private static $logHandle = null;
|
|
||||||
|
|
||||||
public static $locales = [];
|
public static $locales = [];
|
||||||
public static $localeIds = [];
|
public static $localeIds = [];
|
||||||
|
|
||||||
@@ -45,18 +27,15 @@ class CLISetup
|
|||||||
|
|
||||||
public static function init()
|
public static function init()
|
||||||
{
|
{
|
||||||
self::$win = substr(PHP_OS, 0, 3) == 'WIN';
|
|
||||||
self::$hasReadline = function_exists('readline_callback_handler_install');
|
|
||||||
|
|
||||||
if ($_ = getopt('d', ['log::', 'locales::', 'mpqDataDir::', 'delete']))
|
if ($_ = getopt('d', ['log::', 'locales::', 'mpqDataDir::', 'delete']))
|
||||||
{
|
{
|
||||||
// optional logging
|
// optional logging
|
||||||
if (!empty($_['log']))
|
if (!empty($_['log']))
|
||||||
self::$logFile = trim($_['log']);
|
CLI::initLogFile(trim($_['log']));
|
||||||
|
|
||||||
// alternative data source (no quotes, use forward slash)
|
// alternative data source (no quotes, use forward slash)
|
||||||
if (!empty($_['mpqDataDir']))
|
if (!empty($_['mpqDataDir']))
|
||||||
self::$srcDir = self::nicePath($_['mpqDataDir']);
|
self::$srcDir = CLI::nicePath($_['mpqDataDir']);
|
||||||
|
|
||||||
// optional limit handled locales
|
// optional limit handled locales
|
||||||
if (!empty($_['locales']))
|
if (!empty($_['locales']))
|
||||||
@@ -82,6 +61,7 @@ class CLISetup
|
|||||||
self::$localeIds[] = $idx;
|
self::$localeIds[] = $idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************/
|
/*******************/
|
||||||
/* MPQ-file access */
|
/* MPQ-file access */
|
||||||
/*******************/
|
/*******************/
|
||||||
@@ -94,8 +74,8 @@ class CLISetup
|
|||||||
*/
|
*/
|
||||||
private static function buildFileList()
|
private static function buildFileList()
|
||||||
{
|
{
|
||||||
self::log();
|
CLI::write();
|
||||||
self::log('reading MPQdata from '.self::$srcDir.' to list for first time use...');
|
CLI::write('reading MPQdata from '.self::$srcDir.' to list for first time use...');
|
||||||
|
|
||||||
$setupDirs = glob('setup/*');
|
$setupDirs = glob('setup/*');
|
||||||
foreach ($setupDirs as $sd)
|
foreach ($setupDirs as $sd)
|
||||||
@@ -124,12 +104,12 @@ class CLISetup
|
|||||||
self::$mpqFiles[strtolower($_)] = $_;
|
self::$mpqFiles[strtolower($_)] = $_;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::log('done');
|
CLI::write('done');
|
||||||
self::log();
|
CLI::write();
|
||||||
}
|
}
|
||||||
catch (UnexpectedValueException $e)
|
catch (UnexpectedValueException $e)
|
||||||
{
|
{
|
||||||
self::log('- mpqData dir '.self::$srcDir.' does not exist', self::LOG_ERROR);
|
CLI::write('- mpqData dir '.self::$srcDir.' does not exist', CLI::LOG_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,87 +162,6 @@ class CLISetup
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********/
|
|
||||||
/* logging */
|
|
||||||
/***********/
|
|
||||||
|
|
||||||
public static function red($str)
|
|
||||||
{
|
|
||||||
return self::$win ? $str : "\e[31m".$str."\e[0m";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function green($str)
|
|
||||||
{
|
|
||||||
return self::$win ? $str : "\e[32m".$str."\e[0m";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function yellow($str)
|
|
||||||
{
|
|
||||||
return self::$win ? $str : "\e[33m".$str."\e[0m";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function blue($str)
|
|
||||||
{
|
|
||||||
return self::$win ? $str : "\e[36m".$str."\e[0m";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function bold($str)
|
|
||||||
{
|
|
||||||
return self::$win ? $str : "\e[1m".$str."\e[0m";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function log($txt = '', $lvl = -1)
|
|
||||||
{
|
|
||||||
if (self::$logFile && !self::$logHandle)
|
|
||||||
{
|
|
||||||
if (!file_exists(self::$logFile))
|
|
||||||
self::$logHandle = fopen(self::$logFile, 'w');
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$logFileParts = pathinfo(self::$logFile);
|
|
||||||
|
|
||||||
$i = 1;
|
|
||||||
while (file_exists($logFileParts['dirname'].'/'.$logFileParts['filename'].$i.(isset($logFileParts['extension']) ? '.'.$logFileParts['extension'] : '')))
|
|
||||||
$i++;
|
|
||||||
|
|
||||||
self::$logFile = $logFileParts['dirname'].'/'.$logFileParts['filename'].$i.(isset($logFileParts['extension']) ? '.'.$logFileParts['extension'] : '');
|
|
||||||
self::$logHandle = fopen(self::$logFile, 'w');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$msg = "\n";
|
|
||||||
if ($txt)
|
|
||||||
{
|
|
||||||
$msg = str_pad(date('H:i:s'), 10);
|
|
||||||
switch ($lvl)
|
|
||||||
{
|
|
||||||
case self::LOG_ERROR: // red critical error
|
|
||||||
$msg .= '['.self::red('ERR').'] ';
|
|
||||||
break;
|
|
||||||
case self::LOG_WARN: // yellow notice
|
|
||||||
$msg .= '['.self::yellow('WARN').'] ';
|
|
||||||
break;
|
|
||||||
case self::LOG_OK: // green success
|
|
||||||
$msg .= '['.self::green('OK').'] ';
|
|
||||||
break;
|
|
||||||
case self::LOG_INFO: // blue info
|
|
||||||
$msg .= '['.self::blue('INFO').'] ';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$msg .= ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$msg .= $txt."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
echo $msg;
|
|
||||||
|
|
||||||
if (self::$logHandle) // remove highlights for logging
|
|
||||||
fwrite(self::$logHandle, preg_replace(["/\e\[\d+m/", "/\e\[0m/"], '', $msg));
|
|
||||||
|
|
||||||
flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*****************/
|
/*****************/
|
||||||
/* file handling */
|
/* file handling */
|
||||||
@@ -270,42 +169,23 @@ class CLISetup
|
|||||||
|
|
||||||
public static function writeFile($file, $content)
|
public static function writeFile($file, $content)
|
||||||
{
|
{
|
||||||
$success = false;
|
if (Util::writeFile($file, $content))
|
||||||
if ($handle = @fOpen($file, "w"))
|
|
||||||
{
|
{
|
||||||
if (fWrite($handle, $content))
|
CLI::write(sprintf(ERR_NONE, CLI::bold($file)), CLI::LOG_OK);
|
||||||
{
|
return true;
|
||||||
$success = true;
|
|
||||||
self::log(sprintf(ERR_NONE, self::bold($file)), self::LOG_OK);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
self::log(sprintf(ERR_WRITE_FILE, self::bold($file)), self::LOG_ERROR);
|
|
||||||
|
|
||||||
fClose($handle);
|
$e = error_get_last();
|
||||||
}
|
CLI::write($e['message'].' '.CLI::bold($file), CLI::LOG_ERROR);
|
||||||
else
|
return false;
|
||||||
self::log(sprintf(ERR_CREATE_FILE, self::bold($file)), self::LOG_ERROR);
|
|
||||||
|
|
||||||
if ($success)
|
|
||||||
@chmod($file, Util::FILE_ACCESS);
|
|
||||||
|
|
||||||
return $success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function writeDir($dir)
|
public static function writeDir($dir)
|
||||||
{
|
{
|
||||||
if (is_dir($dir))
|
if (Util::writeDir($dir))
|
||||||
{
|
|
||||||
if (!is_writable($dir) && !@chmod($dir, Util::FILE_ACCESS))
|
|
||||||
self::log('cannot write into output directory '.$dir, self::LOG_ERROR);
|
|
||||||
|
|
||||||
return is_writable($dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (@mkdir($dir, Util::FILE_ACCESS, true))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
self::log('could not create output directory '.$dir, self::LOG_ERROR);
|
CLI::write(error_get_last()['message'].' '.CLI::bold($dir), CLI::LOG_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,158 +197,18 @@ class CLISetup
|
|||||||
$dbc = new DBC($name, ['temporary' => self::$tmpDBC]);
|
$dbc = new DBC($name, ['temporary' => self::$tmpDBC]);
|
||||||
if ($dbc->error)
|
if ($dbc->error)
|
||||||
{
|
{
|
||||||
self::log('SqlGen::generate() - required DBC '.$name.'.dbc not found!', self::LOG_ERROR);
|
CLI::write('SqlGen::generate() - required DBC '.$name.'.dbc not found!', CLI::LOG_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$dbc->readFile())
|
if (!$dbc->readFile())
|
||||||
{
|
{
|
||||||
self::log('SqlGen::generate() - DBC '.$name.'.dbc could not be written to DB!', self::LOG_ERROR);
|
CLI::write('SqlGen::generate() - DBC '.$name.'.dbc could not be written to DB!', CLI::LOG_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function nicePath(/* $file = '', ...$pathParts */)
|
|
||||||
{
|
|
||||||
$path = '';
|
|
||||||
|
|
||||||
switch (func_num_args())
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
return '';
|
|
||||||
case 1:
|
|
||||||
$path = func_get_arg(0);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$args = func_get_args();
|
|
||||||
$file = array_shift($args);
|
|
||||||
$path = implode(DIRECTORY_SEPARATOR, $args).DIRECTORY_SEPARATOR.$file;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DIRECTORY_SEPARATOR == '/') // *nix
|
|
||||||
{
|
|
||||||
$path = str_replace('\\', '/', $path);
|
|
||||||
$path = preg_replace('/\/+/i', '/', $path);
|
|
||||||
}
|
|
||||||
else if (DIRECTORY_SEPARATOR == '\\') // win
|
|
||||||
{
|
|
||||||
$path = str_replace('/', '\\', $path);
|
|
||||||
$path = preg_replace('/\\\\+/i', '\\', $path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
CLISetup::log('Dafuq! Your directory separator is "'.DIRECTORY_SEPARATOR.'". Please report this!', CLISetup::LOG_ERROR);
|
|
||||||
|
|
||||||
$path = trim($path);
|
|
||||||
|
|
||||||
// resolve *nix home shorthand
|
|
||||||
if (!self::$win)
|
|
||||||
{
|
|
||||||
if (preg_match('/^~(\w+)\/.*/i', $path, $m))
|
|
||||||
$path = '/home/'.substr($path, 1);
|
|
||||||
else if (substr($path, 0, 2) == '~/')
|
|
||||||
$path = getenv('HOME').substr($path, 1);
|
|
||||||
else if ($path[0] == DIRECTORY_SEPARATOR && substr($path, 0, 6) != '/home/')
|
|
||||||
$path = substr($path, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove quotes (from erronous user input)
|
|
||||||
$path = str_replace(['"', "'"], ['', ''], $path);
|
|
||||||
|
|
||||||
return $path;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************/
|
|
||||||
/* read input */
|
|
||||||
/**************/
|
|
||||||
|
|
||||||
/*
|
|
||||||
since the CLI on WIN ist not interactive, the following things have to be considered
|
|
||||||
you do not receive keystrokes but whole strings upon pressing <Enter> (wich also appends a \r)
|
|
||||||
as such <ESC> and probably other control chars can not be registered
|
|
||||||
this also means, you can't hide input at all, least process it
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static function readInput(&$fields, $singleChar = false)
|
|
||||||
{
|
|
||||||
// prevent default output if able
|
|
||||||
if (self::$hasReadline)
|
|
||||||
readline_callback_handler_install('', function() { });
|
|
||||||
|
|
||||||
foreach ($fields as $name => $data)
|
|
||||||
{
|
|
||||||
$vars = ['desc', 'isHidden', 'validPattern'];
|
|
||||||
foreach ($vars as $idx => $v)
|
|
||||||
$$v = isset($data[$idx]) ? $data[$idx] : false;
|
|
||||||
|
|
||||||
$charBuff = '';
|
|
||||||
|
|
||||||
if ($desc)
|
|
||||||
echo "\n".$desc.": ";
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
$r = [STDIN];
|
|
||||||
$w = $e = null;
|
|
||||||
$n = stream_select($r, $w, $e, 200000);
|
|
||||||
|
|
||||||
if ($n && in_array(STDIN, $r)) {
|
|
||||||
$char = stream_get_contents(STDIN, 1);
|
|
||||||
$keyId = ord($char);
|
|
||||||
|
|
||||||
// ignore this one
|
|
||||||
if ($keyId == self::CHR_TAB)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// WIN sends \r\n as sequence, ignore one
|
|
||||||
if ($keyId == self::CHR_CR && self::$win)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// will not be send on WIN .. other ways of returning from setup? (besides ctrl + c)
|
|
||||||
if ($keyId == self::CHR_ESC)
|
|
||||||
{
|
|
||||||
echo chr(self::CHR_BELL);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if ($keyId == self::CHR_BACKSPACE)
|
|
||||||
{
|
|
||||||
if (!$charBuff)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
$charBuff = mb_substr($charBuff, 0, -1);
|
|
||||||
if (!$isHidden && self::$hasReadline)
|
|
||||||
echo chr(self::CHR_BACK)." ".chr(self::CHR_BACK);
|
|
||||||
}
|
|
||||||
else if ($keyId == self::CHR_LF)
|
|
||||||
{
|
|
||||||
$fields[$name] = $charBuff;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (!$validPattern || preg_match($validPattern, $char))
|
|
||||||
{
|
|
||||||
$charBuff .= $char;
|
|
||||||
if (!$isHidden && self::$hasReadline)
|
|
||||||
echo $char;
|
|
||||||
|
|
||||||
if ($singleChar && self::$hasReadline)
|
|
||||||
{
|
|
||||||
$fields[$name] = $charBuff;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
echo chr(self::CHR_BELL);
|
|
||||||
|
|
||||||
foreach ($fields as $f)
|
|
||||||
if (strlen($f))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
$fields = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -22,18 +22,18 @@ function account()
|
|||||||
User::useLocale(LOCALE_EN);
|
User::useLocale(LOCALE_EN);
|
||||||
Lang::load(Util::$localeStrings[LOCALE_EN]);
|
Lang::load(Util::$localeStrings[LOCALE_EN]);
|
||||||
|
|
||||||
if (CLISetup::readInput($fields))
|
if (CLI::readInput($fields))
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
|
|
||||||
if (!User::isValidName($fields['name'], $e))
|
if (!User::isValidName($fields['name'], $e))
|
||||||
CLISetup::log(Lang::account($e == 1 ? 'errNameLength' : 'errNameChars'), CLISetup::LOG_ERROR);
|
CLI::write(Lang::account($e == 1 ? 'errNameLength' : 'errNameChars'), CLI::LOG_ERROR);
|
||||||
else if (!User::isValidPass($fields['pass1'], $e))
|
else if (!User::isValidPass($fields['pass1'], $e))
|
||||||
CLISetup::log(Lang::account($e == 1 ? 'errPassLength' : 'errPassChars'), CLISetup::LOG_ERROR);
|
CLI::write(Lang::account($e == 1 ? 'errPassLength' : 'errPassChars'), CLI::LOG_ERROR);
|
||||||
else if ($fields['pass1'] != $fields['pass2'])
|
else if ($fields['pass1'] != $fields['pass2'])
|
||||||
CLISetup::log(Lang::account('passMismatch'), CLISetup::LOG_ERROR);
|
CLI::write(Lang::account('passMismatch'), CLI::LOG_ERROR);
|
||||||
else if ($_ = DB::Aowow()->SelectCell('SELECT 1 FROM ?_account WHERE user = ? AND (status <> ?d OR (status = ?d AND statusTimer > UNIX_TIMESTAMP()))', $fields['name'], ACC_STATUS_NEW, ACC_STATUS_NEW))
|
else if ($_ = DB::Aowow()->SelectCell('SELECT 1 FROM ?_account WHERE user = ? AND (status <> ?d OR (status = ?d AND statusTimer > UNIX_TIMESTAMP()))', $fields['name'], ACC_STATUS_NEW, ACC_STATUS_NEW))
|
||||||
CLISetup::log(Lang::account('nameInUse'), CLISetup::LOG_ERROR);
|
CLI::write(Lang::account('nameInUse'), CLI::LOG_ERROR);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// write to db
|
// write to db
|
||||||
@@ -49,16 +49,16 @@ function account()
|
|||||||
$newId = DB::Aowow()->selectCell('SELECT id FROM ?_account WHERE user = ?', $fields['name']);
|
$newId = DB::Aowow()->selectCell('SELECT id FROM ?_account WHERE user = ?', $fields['name']);
|
||||||
Util::gainSiteReputation($newId, SITEREP_ACTION_REGISTER);
|
Util::gainSiteReputation($newId, SITEREP_ACTION_REGISTER);
|
||||||
|
|
||||||
CLISetup::log("account ".$fields['name']." created successfully", CLISetup::LOG_OK);
|
CLI::write("account ".$fields['name']." created successfully", CLI::LOG_OK);
|
||||||
}
|
}
|
||||||
else // something went wrong
|
else // something went wrong
|
||||||
CLISetup::log(Lang::main('intError'), CLISetup::LOG_ERROR);
|
CLI::write(Lang::main('intError'), CLI::LOG_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::log("account creation aborted", CLISetup::LOG_INFO);
|
CLI::write("account creation aborted", CLI::LOG_INFO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ function build($syncMe = null)
|
|||||||
$allOk = true;
|
$allOk = true;
|
||||||
|
|
||||||
// start file generation
|
// start file generation
|
||||||
CLISetup::log('begin generation of '. implode(', ', FileGen::$subScripts));
|
CLI::write('begin generation of '. implode(', ', FileGen::$subScripts));
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
|
|
||||||
// files with template
|
// files with template
|
||||||
foreach (FileGen::$tplFiles as $name => list($file, $destPath, $deps))
|
foreach (FileGen::$tplFiles as $name => list($file, $destPath, $deps))
|
||||||
@@ -36,7 +36,7 @@ function build($syncMe = null)
|
|||||||
|
|
||||||
if (!file_exists(FileGen::$tplPath.$file.'.in'))
|
if (!file_exists(FileGen::$tplPath.$file.'.in'))
|
||||||
{
|
{
|
||||||
CLISetup::log(sprintf(ERR_MISSING_FILE, FileGen::$tplPath.$file.'.in'), CLISetup::LOG_ERROR);
|
CLI::write(sprintf(ERR_MISSING_FILE, FileGen::$tplPath.$file.'.in'), CLI::LOG_ERROR);
|
||||||
$allOk = false;
|
$allOk = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ function build($syncMe = null)
|
|||||||
else
|
else
|
||||||
$done[] = $name;
|
$done[] = $name;
|
||||||
|
|
||||||
CLISetup::log(' - subscript \''.$file.'\' returned '.($ok ? 'sucessfully' : 'with errors'), $ok ? CLISetup::LOG_OK : CLISetup::LOG_ERROR);
|
CLI::write(' - subscript \''.$file.'\' returned '.($ok ? 'sucessfully' : 'with errors'), $ok ? CLI::LOG_OK : CLI::LOG_ERROR);
|
||||||
set_time_limit(FileGen::$defaultExecTime); // reset to default for the next script
|
set_time_limit(FileGen::$defaultExecTime); // reset to default for the next script
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,19 +70,19 @@ function build($syncMe = null)
|
|||||||
else
|
else
|
||||||
$done[] = $file;
|
$done[] = $file;
|
||||||
|
|
||||||
CLISetup::log(' - subscript \''.$file.'\' returned '.($ok ? 'sucessfully' : 'with errors'), $ok ? CLISetup::LOG_OK : CLISetup::LOG_ERROR);
|
CLI::write(' - subscript \''.$file.'\' returned '.($ok ? 'sucessfully' : 'with errors'), $ok ? CLI::LOG_OK : CLI::LOG_ERROR);
|
||||||
set_time_limit(FileGen::$defaultExecTime); // reset to default for the next script
|
set_time_limit(FileGen::$defaultExecTime); // reset to default for the next script
|
||||||
}
|
}
|
||||||
|
|
||||||
// end
|
// end
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
if ($allOk)
|
if ($allOk)
|
||||||
CLISetup::log('successfully finished file generation', CLISetup::LOG_OK);
|
CLI::write('successfully finished file generation', CLI::LOG_OK);
|
||||||
else
|
else
|
||||||
CLISetup::log('finished file generation with errors', CLISetup::LOG_ERROR);
|
CLI::write('finished file generation with errors', CLI::LOG_ERROR);
|
||||||
}
|
}
|
||||||
else if ($syncMe)
|
else if ($syncMe)
|
||||||
CLISetup::log('no valid script names supplied', CLISetup::LOG_ERROR);
|
CLI::write('no valid script names supplied', CLI::LOG_ERROR);
|
||||||
|
|
||||||
return $done;
|
return $done;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ function dbconfig()
|
|||||||
);
|
);
|
||||||
$testDB = function($idx, $name, $dbInfo)
|
$testDB = function($idx, $name, $dbInfo)
|
||||||
{
|
{
|
||||||
$buff = '['.CLISetup::bold($idx).'] '.str_pad($name, 17);
|
$buff = '['.CLI::bold($idx).'] '.str_pad($name, 17);
|
||||||
$errStr = '';
|
$errStr = '';
|
||||||
$defPort = ini_get('mysqli.default_port');
|
$defPort = ini_get('mysqli.default_port');
|
||||||
$port = 0;
|
$port = 0;
|
||||||
@@ -40,12 +40,12 @@ function dbconfig()
|
|||||||
else
|
else
|
||||||
$errStr = '['.mysqli_connect_errno().'] '.mysqli_connect_error();
|
$errStr = '['.mysqli_connect_errno().'] '.mysqli_connect_error();
|
||||||
|
|
||||||
$buff .= $errStr ? CLISetup::red('ERR ') : CLISetup::green('OK ');
|
$buff .= $errStr ? CLI::red('ERR ') : CLI::green('OK ');
|
||||||
$buff .= 'mysqli://'.$dbInfo['user'].':'.str_pad('', mb_strlen($dbInfo['pass']), '*').'@'.$dbInfo['host'].($port ? ':'.$port : null).'/'.$dbInfo['db'];
|
$buff .= 'mysqli://'.$dbInfo['user'].':'.str_pad('', mb_strlen($dbInfo['pass']), '*').'@'.$dbInfo['host'].($port ? ':'.$port : null).'/'.$dbInfo['db'];
|
||||||
$buff .= ($dbInfo['prefix'] ? ' table prefix: '.$dbInfo['prefix'] : null).' '.$errStr;
|
$buff .= ($dbInfo['prefix'] ? ' table prefix: '.$dbInfo['prefix'] : null).' '.$errStr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$buff .= ' '.CLISetup::bold('<empty>');
|
$buff .= ' '.CLI::bold('<empty>');
|
||||||
|
|
||||||
return $buff;
|
return $buff;
|
||||||
};
|
};
|
||||||
@@ -61,25 +61,25 @@ function dbconfig()
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::log("select a numerical index to use the corresponding entry");
|
CLI::write("select a numerical index to use the corresponding entry");
|
||||||
|
|
||||||
$nCharDBs = 0;
|
$nCharDBs = 0;
|
||||||
foreach ($databases as $idx => $name)
|
foreach ($databases as $idx => $name)
|
||||||
{
|
{
|
||||||
if ($idx != 3)
|
if ($idx != 3)
|
||||||
CLISetup::log($testDB($idx, $name, $AoWoWconf[$name]));
|
CLI::write($testDB($idx, $name, $AoWoWconf[$name]));
|
||||||
else if (!empty($AoWoWconf[$name]))
|
else if (!empty($AoWoWconf[$name]))
|
||||||
foreach ($AoWoWconf[$name] as $charIdx => $dbInfo)
|
foreach ($AoWoWconf[$name] as $charIdx => $dbInfo)
|
||||||
CLISetup::log($testDB($idx + $nCharDBs++, $name.' ['.$charIdx.']', $AoWoWconf[$name][$charIdx]));
|
CLI::write($testDB($idx + $nCharDBs++, $name.' ['.$charIdx.']', $AoWoWconf[$name][$charIdx]));
|
||||||
}
|
}
|
||||||
|
|
||||||
CLISetup::log("[".CLISetup::bold(3 + $nCharDBs)."] add an additional Character DB");
|
CLI::write("[".CLI::bold(3 + $nCharDBs)."] add an additional Character DB");
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
$inp = ['idx' => ['', true, '/\d/']];
|
$inp = ['idx' => ['', true, '/\d/']];
|
||||||
if (CLISetup::readInput($inp, true) && $inp)
|
if (CLI::readInput($inp, true) && $inp)
|
||||||
{
|
{
|
||||||
if ($inp['idx'] >= 0 && $inp['idx'] <= (3 + $nCharDBs))
|
if ($inp['idx'] >= 0 && $inp['idx'] <= (3 + $nCharDBs))
|
||||||
{
|
{
|
||||||
@@ -88,7 +88,7 @@ function dbconfig()
|
|||||||
if ($inp['idx'] == 3 + $nCharDBs) // add new realmDB
|
if ($inp['idx'] == 3 + $nCharDBs) // add new realmDB
|
||||||
$curFields['realmId'] = ['Realm Id', false, '/[1-9][0-9]*/'];
|
$curFields['realmId'] = ['Realm Id', false, '/[1-9][0-9]*/'];
|
||||||
|
|
||||||
if (CLISetup::readInput($curFields))
|
if (CLI::readInput($curFields))
|
||||||
{
|
{
|
||||||
if ($inp['idx'] == 0 && $curFields)
|
if ($inp['idx'] == 0 && $curFields)
|
||||||
$curFields['prefix'] = 'aowow_';
|
$curFields['prefix'] = 'aowow_';
|
||||||
@@ -133,14 +133,14 @@ function dbconfig()
|
|||||||
$buff .= '$AoWoWconf[\''.$db.'\'][\''.$idx.'\'] = '.var_export($AoWoWconf[$db][$idx], true).";\n\n";
|
$buff .= '$AoWoWconf[\''.$db.'\'][\''.$idx.'\'] = '.var_export($AoWoWconf[$db][$idx], true).";\n\n";
|
||||||
}
|
}
|
||||||
$buff .= "?>\n";
|
$buff .= "?>\n";
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::writeFile('config/config.php', $buff);
|
CLISetup::writeFile('config/config.php', $buff);
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::log("edit canceled! returning to list...", CLISetup::LOG_INFO);
|
CLI::write("edit canceled! returning to list...", CLI::LOG_INFO);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
@@ -148,8 +148,8 @@ function dbconfig()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::log("leaving db setup...", CLISetup::LOG_INFO);
|
CLI::write("leaving db setup...", CLI::LOG_INFO);
|
||||||
break 2;
|
break 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ function firstrun()
|
|||||||
$steps = array(
|
$steps = array(
|
||||||
// clisetup/, params, test script result, introText, errorText
|
// clisetup/, params, test script result, introText, errorText
|
||||||
['dbconfig', null, 'testDB', 'Please enter your database credentials.', 'could not establish connection to:'],
|
['dbconfig', null, 'testDB', 'Please enter your database credentials.', 'could not establish connection to:'],
|
||||||
['siteconfig', null, 'testSelf', 'SITE_HOST and STATIC_HOST '.CLISetup::bold('must').' be set. Also enable FORCE_SSL if needed. You may also want to change other variables such as NAME, NAME_SHORT OR LOCALES.', 'could not access:'],
|
['siteconfig', null, 'testSelf', 'SITE_HOST and STATIC_HOST '.CLI::bold('must').' be set. Also enable FORCE_SSL if needed. You may also want to change other variables such as NAME, NAME_SHORT OR LOCALES.', 'could not access:'],
|
||||||
// sql- and build- stuff here
|
// sql- and build- stuff here
|
||||||
['SqlGen::generate', 'achievementcategory', null, null, null],
|
['SqlGen::generate', 'achievementcategory', null, null, null],
|
||||||
['SqlGen::generate', 'achievementcriteria', null, null, null],
|
['SqlGen::generate', 'achievementcriteria', null, null, null],
|
||||||
@@ -183,9 +183,9 @@ function firstrun()
|
|||||||
{
|
{
|
||||||
if ($resp == 301 || $resp == 302)
|
if ($resp == 301 || $resp == 302)
|
||||||
{
|
{
|
||||||
CLISetup::log('self test received status '.CLISetup::bold($resp).' (page moved) for '.$conf.', pointing to: '.$protocol.$host.$testFile, CLISetup::LOG_WARN);
|
CLI::write('self test received status '.CLI::bold($resp).' (page moved) for '.$conf.', pointing to: '.$protocol.$host.$testFile, CLI::LOG_WARN);
|
||||||
$inp = ['x' => ['should '.CLISetup::bold($conf).' be set to '.CLISetup::bold($host).' and force_ssl be updated?', true, '/y|n/i']];
|
$inp = ['x' => ['should '.CLI::bold($conf).' be set to '.CLI::bold($host).' and force_ssl be updated?', true, '/y|n/i']];
|
||||||
if (!CLISetup::readInput($inp, true) || !$inp || strtolower($inp['x']) == 'n')
|
if (!CLI::readInput($inp, true) || !$inp || strtolower($inp['x']) == 'n')
|
||||||
$error[] = ' * could not access '.$protocol.$host.$testFile.' ['.$resp.']';
|
$error[] = ' * could not access '.$protocol.$host.$testFile.' ['.$resp.']';
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -193,7 +193,7 @@ function firstrun()
|
|||||||
DB::Aowow()->query('UPDATE ?_config SET `value` = ?d WHERE `key` = "force_ssl"', intVal($protocol == 'https://'));
|
DB::Aowow()->query('UPDATE ?_config SET `value` = ?d WHERE `key` = "force_ssl"', intVal($protocol == 'https://'));
|
||||||
}
|
}
|
||||||
|
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$error[] = ' * could not access '.$protocol.$host.$testFile.' ['.$resp.']';
|
$error[] = ' * could not access '.$protocol.$host.$testFile.' ['.$resp.']';
|
||||||
@@ -232,10 +232,10 @@ function firstrun()
|
|||||||
if ($startStep)
|
if ($startStep)
|
||||||
{
|
{
|
||||||
|
|
||||||
CLISetup::log('Found firstrun progression info. (Halted on subscript '.($steps[$startStep][1] ?: $steps[$startStep][0]).')', CLISetup::LOG_INFO);
|
CLI::write('Found firstrun progression info. (Halted on subscript '.($steps[$startStep][1] ?: $steps[$startStep][0]).')', CLI::LOG_INFO);
|
||||||
$inp = ['x' => ['continue setup? (y/n)', true, '/y|n/i']];
|
$inp = ['x' => ['continue setup? (y/n)', true, '/y|n/i']];
|
||||||
$msg = '';
|
$msg = '';
|
||||||
if (!CLISetup::readInput($inp, true) || !$inp || strtolower($inp['x']) == 'n')
|
if (!CLI::readInput($inp, true) || !$inp || strtolower($inp['x']) == 'n')
|
||||||
{
|
{
|
||||||
$msg = 'Starting setup from scratch...';
|
$msg = 'Starting setup from scratch...';
|
||||||
$startStep = 0;
|
$startStep = 0;
|
||||||
@@ -243,8 +243,8 @@ function firstrun()
|
|||||||
else
|
else
|
||||||
$msg = 'Resuming setup from step '.$startStep.'...';
|
$msg = 'Resuming setup from step '.$startStep.'...';
|
||||||
|
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::log($msg);
|
CLI::write($msg);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,10 +262,10 @@ function firstrun()
|
|||||||
|
|
||||||
if ($step[3])
|
if ($step[3])
|
||||||
{
|
{
|
||||||
CLISetup::log($step[3]);
|
CLI::write($step[3]);
|
||||||
$inp = ['x' => ['Press any key to continue', true]];
|
$inp = ['x' => ['Press any key to continue', true]];
|
||||||
|
|
||||||
if (!CLISetup::readInput($inp, true)) // we don't actually care about the input
|
if (!CLI::readInput($inp, true)) // we don't actually care about the input
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,9 +278,9 @@ function firstrun()
|
|||||||
{
|
{
|
||||||
if (!$step[2]($errors))
|
if (!$step[2]($errors))
|
||||||
{
|
{
|
||||||
CLISetup::log($step[4], CLISetup::LOG_ERROR);
|
CLI::write($step[4], CLI::LOG_ERROR);
|
||||||
foreach ($errors as $e)
|
foreach ($errors as $e)
|
||||||
CLISetup::log($e);
|
CLI::write($e);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -294,10 +294,10 @@ function firstrun()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$inp = ['x' => ['['.CLISetup::bold('c').']ontinue anyway? ['.CLISetup::bold('r').']etry? ['.CLISetup::bold('a').']bort?', true, '/c|r|a/i']];
|
$inp = ['x' => ['['.CLI::bold('c').']ontinue anyway? ['.CLI::bold('r').']etry? ['.CLI::bold('a').']bort?', true, '/c|r|a/i']];
|
||||||
if (CLISetup::readInput($inp, true) && $inp)
|
if (CLI::readInput($inp, true) && $inp)
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
switch(strtolower($inp['x']))
|
switch(strtolower($inp['x']))
|
||||||
{
|
{
|
||||||
case 'c':
|
case 'c':
|
||||||
@@ -311,14 +311,14 @@ function firstrun()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unlink('cache/firstrun');
|
unlink('cache/firstrun');
|
||||||
CLISetup::log('setup finished', CLISetup::LOG_OK);
|
CLI::write('setup finished', CLI::LOG_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ function siteconfig()
|
|||||||
|
|
||||||
if (!DB::isConnected(DB_AOWOW))
|
if (!DB::isConnected(DB_AOWOW))
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::log("database not yet set up!\n Please use --dbconfig for setup", CLISetup::LOG_WARN);
|
CLI::write("database not yet set up!\n Please use --dbconfig for setup", CLI::LOG_WARN);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,8 +43,8 @@ function siteconfig()
|
|||||||
break;
|
break;
|
||||||
case 'locales':
|
case 'locales':
|
||||||
array_push($updScripts, 'locales');
|
array_push($updScripts, 'locales');
|
||||||
CLISetup::log(' * remember to rebuild all static files for the language you just added.', CLISetup::LOG_INFO);
|
CLI::write(' * remember to rebuild all static files for the language you just added.', CLI::LOG_INFO);
|
||||||
CLISetup::log(' * you can speed this up by supplying the regionCode to the setup: '.CLISetup::bold('--locales=<regionCodes,> -f'));
|
CLI::write(' * you can speed this up by supplying the regionCode to the setup: '.CLI::bold('--locales=<regionCodes,> -f'));
|
||||||
break;
|
break;
|
||||||
case 'profiler_queue':
|
case 'profiler_queue':
|
||||||
$fn = function($x) {
|
$fn = function($x) {
|
||||||
@@ -53,7 +53,7 @@ function siteconfig()
|
|||||||
|
|
||||||
$ok = Profiler::queueStart($msg);
|
$ok = Profiler::queueStart($msg);
|
||||||
if ($msg)
|
if ($msg)
|
||||||
CLISetup::log($msg, CLISetup::LOG_ERROR);
|
CLI::write($msg, CLI::LOG_ERROR);
|
||||||
|
|
||||||
return $ok;
|
return $ok;
|
||||||
};
|
};
|
||||||
@@ -67,8 +67,8 @@ function siteconfig()
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::log('select a numerical index to use the corresponding entry');
|
CLI::write('select a numerical index to use the corresponding entry');
|
||||||
|
|
||||||
$sumNum = 0;
|
$sumNum = 0;
|
||||||
$cfgList = [];
|
$cfgList = [];
|
||||||
@@ -93,10 +93,10 @@ function siteconfig()
|
|||||||
$cfgList[$sumNum + $num] = $data;
|
$cfgList[$sumNum + $num] = $data;
|
||||||
|
|
||||||
$php = $data['flags'] & CON_FLAG_PHP;
|
$php = $data['flags'] & CON_FLAG_PHP;
|
||||||
$buff = "[".CLISetup::bold($sumNum + $num)."] ".(($sumNum + $num) > 9 ? '' : ' ').($php ? ' PHP ' : ' AOWOW ');
|
$buff = "[".CLI::bold($sumNum + $num)."] ".(($sumNum + $num) > 9 ? '' : ' ').($php ? ' PHP ' : ' AOWOW ');
|
||||||
$buff .= str_pad($php ? strtolower($data['key']) : strtoupper($data['key']), 35);
|
$buff .= str_pad($php ? strtolower($data['key']) : strtoupper($data['key']), 35);
|
||||||
if ($data['value'] === '')
|
if ($data['value'] === '')
|
||||||
$buff .= in_array($data['key'], $reqKeys) ? CLISetup::red('<empty>') : '<empty>';
|
$buff .= in_array($data['key'], $reqKeys) ? CLI::red('<empty>') : '<empty>';
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$info = explode(' - ', $data['comment']);
|
$info = explode(' - ', $data['comment']);
|
||||||
@@ -140,27 +140,27 @@ function siteconfig()
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($mainBuff as $b)
|
foreach ($mainBuff as $b)
|
||||||
CLISetup::log($b);
|
CLI::write($b);
|
||||||
|
|
||||||
foreach ($miscBuff as $b)
|
foreach ($miscBuff as $b)
|
||||||
CLISetup::log($b);
|
CLI::write($b);
|
||||||
|
|
||||||
CLISetup::log(str_pad("[".CLISetup::bold($sumNum)."]", 21)."add another php configuration");
|
CLI::write(str_pad("[".CLI::bold($sumNum)."]", 21)."add another php configuration");
|
||||||
|
|
||||||
if ($hasEmpty)
|
if ($hasEmpty)
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::log("please configure the required empty setings", CLISetup::LOG_WARN);
|
CLI::write("please configure the required empty setings", CLI::LOG_WARN);
|
||||||
}
|
}
|
||||||
|
|
||||||
$inp = ['idx' => ['', false, '/\d/']];
|
$inp = ['idx' => ['', false, '/\d/']];
|
||||||
if (CLISetup::readInput($inp) && $inp && $inp['idx'] !== '')
|
if (CLI::readInput($inp) && $inp && $inp['idx'] !== '')
|
||||||
{
|
{
|
||||||
// add new php setting
|
// add new php setting
|
||||||
if ($inp['idx'] == $sumNum)
|
if ($inp['idx'] == $sumNum)
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::log("Adding additional php configuration.");
|
CLI::write("Adding additional php configuration.");
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
@@ -168,25 +168,25 @@ function siteconfig()
|
|||||||
'key' => ['option name', false, '/[\w_\.\-]/i'],
|
'key' => ['option name', false, '/[\w_\.\-]/i'],
|
||||||
'val' => ['value', ]
|
'val' => ['value', ]
|
||||||
);
|
);
|
||||||
if (CLISetup::readInput($setting) && $setting)
|
if (CLI::readInput($setting) && $setting)
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
|
|
||||||
$key = strtolower($setting['key']);
|
$key = strtolower($setting['key']);
|
||||||
if (ini_get($key) === false || ini_set($key, $setting['val']) === false)
|
if (ini_get($key) === false || ini_set($key, $setting['val']) === false)
|
||||||
{
|
{
|
||||||
CLISetup::log("this configuration option cannot be set", CLISetup::LOG_ERROR);
|
CLI::write("this configuration option cannot be set", CLI::LOG_ERROR);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
else if (DB::Aowow()->selectCell('SELECT 1 FROM ?_config WHERE `flags` & ?d AND `key` = ?', CON_FLAG_PHP, $key))
|
else if (DB::Aowow()->selectCell('SELECT 1 FROM ?_config WHERE `flags` & ?d AND `key` = ?', CON_FLAG_PHP, $key))
|
||||||
{
|
{
|
||||||
CLISetup::log("this configuration option is already in use", CLISetup::LOG_ERROR);
|
CLI::write("this configuration option is already in use", CLI::LOG_ERROR);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DB::Aowow()->query('INSERT IGNORE INTO ?_config (`key`, `value`, `cat`, `flags`) VALUES (?, ?, 0, ?d)', $key, $setting['val'], CON_FLAG_TYPE_STRING | CON_FLAG_PHP);
|
DB::Aowow()->query('INSERT IGNORE INTO ?_config (`key`, `value`, `cat`, `flags`) VALUES (?, ?, 0, ?d)', $key, $setting['val'], CON_FLAG_TYPE_STRING | CON_FLAG_PHP);
|
||||||
CLISetup::log("new php configuration added", CLISetup::LOG_OK);
|
CLI::write("new php configuration added", CLI::LOG_OK);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,8 +194,8 @@ function siteconfig()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::log("edit canceled! returning to list...", CLISetup::LOG_INFO);
|
CLI::write("edit canceled! returning to list...", CLI::LOG_INFO);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -209,14 +209,14 @@ function siteconfig()
|
|||||||
$key = strtolower($conf['key']);
|
$key = strtolower($conf['key']);
|
||||||
$buff = '';
|
$buff = '';
|
||||||
|
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
$buff .= $conf['flags'] & CON_FLAG_PHP ? " PHP: " : "AOWOW: ";
|
$buff .= $conf['flags'] & CON_FLAG_PHP ? " PHP: " : "AOWOW: ";
|
||||||
$buff .= $conf['flags'] & CON_FLAG_PHP ? $key : strtoupper('cfg_'.$conf['key']);
|
$buff .= $conf['flags'] & CON_FLAG_PHP ? $key : strtoupper('cfg_'.$conf['key']);
|
||||||
|
|
||||||
if (!empty($info[1]))
|
if (!empty($info[1]))
|
||||||
$buff .= " - ".$info[1];
|
$buff .= " - ".$info[1];
|
||||||
|
|
||||||
CLISetup::log($buff);
|
CLI::write($buff);
|
||||||
|
|
||||||
$buff = "VALUE: ";
|
$buff = "VALUE: ";
|
||||||
|
|
||||||
@@ -245,20 +245,20 @@ function siteconfig()
|
|||||||
else /* if ($conf['flags'] & CON_FLAG_TYPE_INT) */
|
else /* if ($conf['flags'] & CON_FLAG_TYPE_INT) */
|
||||||
$buff .= intVal($conf['value']);
|
$buff .= intVal($conf['value']);
|
||||||
|
|
||||||
CLISetup::log($buff);
|
CLI::write($buff);
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::log("[".CLISetup::bold('E')."]dit");
|
CLI::write("[".CLI::bold('E')."]dit");
|
||||||
|
|
||||||
if (!($conf['flags'] & CON_FLAG_PERSISTENT))
|
if (!($conf['flags'] & CON_FLAG_PERSISTENT))
|
||||||
CLISetup::log("[".CLISetup::bold('D')."]elete");
|
CLI::write("[".CLI::bold('D')."]elete");
|
||||||
|
|
||||||
if (strstr($info[0], 'default:'))
|
if (strstr($info[0], 'default:'))
|
||||||
CLISetup::log("[".CLISetup::bold('R')."]estore Default - ".trim(explode('default:', $info[0])[1]));
|
CLI::write("[".CLI::bold('R')."]estore Default - ".trim(explode('default:', $info[0])[1]));
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
$action = ['idx' => ['', true, '/[edr]/i']];
|
$action = ['idx' => ['', true, '/[edr]/i']];
|
||||||
if (CLISetup::readInput($action, true) && $action)
|
if (CLI::readInput($action, true) && $action)
|
||||||
{
|
{
|
||||||
switch (strtoupper($action['idx']))
|
switch (strtoupper($action['idx']))
|
||||||
{
|
{
|
||||||
@@ -274,7 +274,7 @@ function siteconfig()
|
|||||||
{
|
{
|
||||||
$opt = explode(':', $option);
|
$opt = explode(':', $option);
|
||||||
$_valid[] = $opt[0];
|
$_valid[] = $opt[0];
|
||||||
CLISetup::log('['.CLISetup::bold($opt[0]).'] '.$opt[1]);
|
CLI::write('['.CLI::bold($opt[0]).'] '.$opt[1]);
|
||||||
}
|
}
|
||||||
$single = true;
|
$single = true;
|
||||||
$pattern = '/\d/';
|
$pattern = '/\d/';
|
||||||
@@ -282,21 +282,21 @@ function siteconfig()
|
|||||||
}
|
}
|
||||||
else if ($conf['flags'] & CON_FLAG_BITMASK)
|
else if ($conf['flags'] & CON_FLAG_BITMASK)
|
||||||
{
|
{
|
||||||
CLISetup::log('Bitmask: sum fields to select multiple options');
|
CLI::write('Bitmask: sum fields to select multiple options');
|
||||||
$_valid = 0x0;
|
$_valid = 0x0;
|
||||||
foreach (explode(', ', $info[2]) as $option)
|
foreach (explode(', ', $info[2]) as $option)
|
||||||
{
|
{
|
||||||
$opt = explode(':', $option);
|
$opt = explode(':', $option);
|
||||||
$_valid |= (1 << $opt[0]);
|
$_valid |= (1 << $opt[0]);
|
||||||
CLISetup::log('['.CLISetup::bold(1 << $opt[0]).']'.str_pad('', 4-strlen(1 << $opt[0])).$opt[1]);
|
CLI::write('['.CLI::bold(1 << $opt[0]).']'.str_pad('', 4-strlen(1 << $opt[0])).$opt[1]);
|
||||||
}
|
}
|
||||||
$pattern = '/\d+/';
|
$pattern = '/\d+/';
|
||||||
$validate = function ($v) use($_valid) { $v = $v & $_valid; return $v; };
|
$validate = function ($v) use($_valid) { $v = $v & $_valid; return $v; };
|
||||||
}
|
}
|
||||||
else if ($conf['flags'] & CON_FLAG_TYPE_BOOL)
|
else if ($conf['flags'] & CON_FLAG_TYPE_BOOL)
|
||||||
{
|
{
|
||||||
CLISetup::log('['.CLISetup::bold(0).'] Disabled');
|
CLI::write('['.CLI::bold(0).'] Disabled');
|
||||||
CLISetup::log('['.CLISetup::bold(1).'] Enabled');
|
CLI::write('['.CLI::bold(1).'] Enabled');
|
||||||
|
|
||||||
$single = true;
|
$single = true;
|
||||||
$pattern = '/[01]/';
|
$pattern = '/[01]/';
|
||||||
@@ -313,13 +313,13 @@ function siteconfig()
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
$use = $value;
|
$use = $value;
|
||||||
if (CLISetup::readInput($use, $single))
|
if (CLI::readInput($use, $single))
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
|
|
||||||
if (!$validate($use ? $use['idx'] : ''))
|
if (!$validate($use ? $use['idx'] : ''))
|
||||||
{
|
{
|
||||||
CLISetup::log("value not in range", CLISetup::LOG_ERROR);
|
CLI::write("value not in range", CLI::LOG_ERROR);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -336,14 +336,14 @@ function siteconfig()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLISetup::log("setting updated", CLISetup::LOG_OK);
|
CLI::write("setting updated", CLI::LOG_OK);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
break 3;
|
break 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLISetup::log("edit canceled! returning to selection...", CLISetup::LOG_INFO);
|
CLI::write("edit canceled! returning to selection...", CLI::LOG_INFO);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -360,8 +360,8 @@ function siteconfig()
|
|||||||
$val = @eval('return ('.$val.');');
|
$val = @eval('return ('.$val.');');
|
||||||
if (DB::Aowow()->query('UPDATE ?_config SET `value` = ? WHERE `key` = ?', $val, $key))
|
if (DB::Aowow()->query('UPDATE ?_config SET `value` = ? WHERE `key` = ?', $val, $key))
|
||||||
{
|
{
|
||||||
|
CLI::write("default value restored", CLI::LOG_OK);
|
||||||
$onChange($key, $val);
|
$onChange($key, $val);
|
||||||
CLISetup::log("default value restored", CLISetup::LOG_OK);
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
break 2;
|
break 2;
|
||||||
@@ -371,7 +371,7 @@ function siteconfig()
|
|||||||
|
|
||||||
if (DB::Aowow()->query('DELETE FROM ?_config WHERE `key` = ? AND (`flags` & ?d) = 0', $key, CON_FLAG_PERSISTENT))
|
if (DB::Aowow()->query('DELETE FROM ?_config WHERE `key` = ? AND (`flags` & ?d) = 0', $key, CON_FLAG_PERSISTENT))
|
||||||
{
|
{
|
||||||
CLISetup::log("php setting deleted ['".$conf['key']."': '".$conf['value']."']", CLISetup::LOG_OK);
|
CLI::write("php setting deleted ['".$conf['key']."': '".$conf['value']."']", CLI::LOG_OK);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
break 2;
|
break 2;
|
||||||
@@ -379,8 +379,8 @@ function siteconfig()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::log('edit canceled! returning to list...', CLISetup::LOG_INFO);
|
CLI::write('edit canceled! returning to list...', CLI::LOG_INFO);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -388,15 +388,15 @@ function siteconfig()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::log('invalid selection', CLISetup::LOG_ERROR);
|
CLI::write('invalid selection', CLI::LOG_ERROR);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::log('site configuration aborted', CLISetup::LOG_INFO);
|
CLI::write('site configuration aborted', CLI::LOG_INFO);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,14 +404,14 @@ function siteconfig()
|
|||||||
if ($updScripts && (!class_exists('FileGen') || FileGen::getMode() != FileGen::MODE_FIRSTRUN))
|
if ($updScripts && (!class_exists('FileGen') || FileGen::getMode() != FileGen::MODE_FIRSTRUN))
|
||||||
{
|
{
|
||||||
require_once 'setup/tools/clisetup/build.func.php';
|
require_once 'setup/tools/clisetup/build.func.php';
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
CLISetup::log('regenerating affected static content', CLISetup::LOG_INFO);
|
CLI::write('regenerating affected static content', CLI::LOG_INFO);
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
if ($_ = array_diff($updScripts, build($updScripts)))
|
if ($_ = array_diff($updScripts, build($updScripts)))
|
||||||
{
|
{
|
||||||
CLISetup::log(' - the following updates returned with errors, please recheck those - '.implode(', ', $_), CLISetup::LOG_ERROR);
|
CLI::write(' - the following updates returned with errors, please recheck those - '.implode(', ', $_), CLI::LOG_ERROR);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ function sql($syncMe = null)
|
|||||||
$allOk = true;
|
$allOk = true;
|
||||||
|
|
||||||
// start file generation
|
// start file generation
|
||||||
CLISetup::log('begin generation of '. implode(', ', SqlGen::$subScripts));
|
CLI::write('begin generation of '. implode(', ', SqlGen::$subScripts));
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
|
|
||||||
foreach (SqlGen::$subScripts as $tbl)
|
foreach (SqlGen::$subScripts as $tbl)
|
||||||
{
|
{
|
||||||
@@ -36,19 +36,19 @@ function sql($syncMe = null)
|
|||||||
else
|
else
|
||||||
$done[] = $tbl;
|
$done[] = $tbl;
|
||||||
|
|
||||||
CLISetup::log(' - subscript \''.$tbl.'\' returned '.($ok ? 'sucessfully' : 'with errors'), $ok ? CLISetup::LOG_OK : CLISetup::LOG_ERROR);
|
CLI::write(' - subscript \''.$tbl.'\' returned '.($ok ? 'sucessfully' : 'with errors'), $ok ? CLI::LOG_OK : CLI::LOG_ERROR);
|
||||||
set_time_limit(SqlGen::$defaultExecTime); // reset to default for the next script
|
set_time_limit(SqlGen::$defaultExecTime); // reset to default for the next script
|
||||||
}
|
}
|
||||||
|
|
||||||
// end
|
// end
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
if ($allOk)
|
if ($allOk)
|
||||||
CLISetup::log('successfully finished sql generation', CLISetup::LOG_OK);
|
CLI::write('successfully finished sql generation', CLI::LOG_OK);
|
||||||
else
|
else
|
||||||
CLISetup::log('finished sql generation with errors', CLISetup::LOG_ERROR);
|
CLI::write('finished sql generation with errors', CLI::LOG_ERROR);
|
||||||
}
|
}
|
||||||
else if ($syncMe)
|
else if ($syncMe)
|
||||||
CLISetup::log('no valid script names supplied', CLISetup::LOG_ERROR);
|
CLI::write('no valid script names supplied', CLI::LOG_ERROR);
|
||||||
|
|
||||||
return $done;
|
return $done;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ function update()
|
|||||||
{
|
{
|
||||||
list($date, $part) = array_values(DB::Aowow()->selectRow('SELECT `date`, `part` FROM ?_dbversion'));
|
list($date, $part) = array_values(DB::Aowow()->selectRow('SELECT `date`, `part` FROM ?_dbversion'));
|
||||||
|
|
||||||
CLISetup::log('checking sql updates');
|
CLI::write('checking sql updates');
|
||||||
|
|
||||||
$nFiles = 0;
|
$nFiles = 0;
|
||||||
foreach (glob('setup/updates/*.sql') as $file)
|
foreach (glob('setup/updates/*.sql') as $file)
|
||||||
@@ -53,10 +53,10 @@ function update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
DB::Aowow()->query('UPDATE ?_dbversion SET `date`= ?d, `part` = ?d', $fDate, $fPart);
|
DB::Aowow()->query('UPDATE ?_dbversion SET `date`= ?d, `part` = ?d', $fDate, $fPart);
|
||||||
CLISetup::log(' -> '.date('d.m.Y', $fDate).' #'.$fPart.': '.$nQuerys.' queries applied', CLISetup::LOG_OK);
|
CLI::write(' -> '.date('d.m.Y', $fDate).' #'.$fPart.': '.$nQuerys.' queries applied', CLI::LOG_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLISetup::log($nFiles ? 'applied '.$nFiles.' update(s)' : 'db is already up to date', CLISetup::LOG_OK);
|
CLI::write($nFiles ? 'applied '.$nFiles.' update(s)' : 'db is already up to date', CLI::LOG_OK);
|
||||||
|
|
||||||
// fetch sql/build after applying updates, as they may contain sync-prompts
|
// fetch sql/build after applying updates, as they may contain sync-prompts
|
||||||
list($sql, $build) = array_values(DB::Aowow()->selectRow('SELECT `sql`, `build` FROM ?_dbversion'));
|
list($sql, $build) = array_values(DB::Aowow()->selectRow('SELECT `sql`, `build` FROM ?_dbversion'));
|
||||||
@@ -67,10 +67,10 @@ function update()
|
|||||||
$build = trim($build) ? array_unique(explode(' ', trim($build))) : [];
|
$build = trim($build) ? array_unique(explode(' ', trim($build))) : [];
|
||||||
|
|
||||||
if ($sql)
|
if ($sql)
|
||||||
CLISetup::log('The following table(s) require syncing: '.implode(', ', $sql));
|
CLI::write('The following table(s) require syncing: '.implode(', ', $sql));
|
||||||
|
|
||||||
if ($build)
|
if ($build)
|
||||||
CLISetup::log('The following file(s) require syncing: '.implode(', ', $build));
|
CLI::write('The following file(s) require syncing: '.implode(', ', $build));
|
||||||
|
|
||||||
return [$sql, $build];
|
return [$sql, $build];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ class DBC
|
|||||||
$file = strtolower($file);
|
$file = strtolower($file);
|
||||||
if (empty($this->_fields[$file]) || empty($this->_formats[$file]))
|
if (empty($this->_fields[$file]) || empty($this->_formats[$file]))
|
||||||
{
|
{
|
||||||
CLISetup::log('no structure known for '.$file.'.dbc, aborting.', CLISetup::LOG_ERROR);
|
CLI::write('no structure known for '.$file.'.dbc, aborting.', CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,7 +274,7 @@ class DBC
|
|||||||
|
|
||||||
if (count($this->fields) != strlen(str_ireplace('x', '', $this->format)))
|
if (count($this->fields) != strlen(str_ireplace('x', '', $this->format)))
|
||||||
{
|
{
|
||||||
CLISetup::log('known field types ['.count($this->fields).'] and names ['.strlen(str_ireplace('x', '', $this->format)).'] do not match for '.$file.'.dbc, aborting.', CLISetup::LOG_ERROR);
|
CLI::write('known field types ['.count($this->fields).'] and names ['.strlen(str_ireplace('x', '', $this->format)).'] do not match for '.$file.'.dbc, aborting.', CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +299,7 @@ class DBC
|
|||||||
if ($foundMask & (1 << $locId))
|
if ($foundMask & (1 << $locId))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$fullPath = CLISetup::nicePath($this->file.'.dbc', CLISetup::$srcDir, $locStr, 'DBFilesClient');
|
$fullPath = CLI::nicePath($this->file.'.dbc', CLISetup::$srcDir, $locStr, 'DBFilesClient');
|
||||||
if (!CLISetup::fileExists($fullPath))
|
if (!CLISetup::fileExists($fullPath))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -310,7 +310,7 @@ class DBC
|
|||||||
|
|
||||||
if (!$this->fileRefs)
|
if (!$this->fileRefs)
|
||||||
{
|
{
|
||||||
CLISetup::log('no suitable files found for '.$file.'.dbc, aborting.', CLISetup::LOG_ERROR);
|
CLI::write('no suitable files found for '.$file.'.dbc, aborting.', CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,19 +319,19 @@ class DBC
|
|||||||
$x = array_unique(array_column($headers, 'recordCount'));
|
$x = array_unique(array_column($headers, 'recordCount'));
|
||||||
if (count($x) != 1)
|
if (count($x) != 1)
|
||||||
{
|
{
|
||||||
CLISetup::log('some DBCs have differenct record counts ('.implode(', ', $x).' respectively). cannot merge!', CLISetup::LOG_ERROR);
|
CLI::write('some DBCs have differenct record counts ('.implode(', ', $x).' respectively). cannot merge!', CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$x = array_unique(array_column($headers, 'fieldCount'));
|
$x = array_unique(array_column($headers, 'fieldCount'));
|
||||||
if (count($x) != 1)
|
if (count($x) != 1)
|
||||||
{
|
{
|
||||||
CLISetup::log('some DBCs have differenct field counts ('.implode(', ', $x).' respectively). cannot merge!', CLISetup::LOG_ERROR);
|
CLI::write('some DBCs have differenct field counts ('.implode(', ', $x).' respectively). cannot merge!', CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$x = array_unique(array_column($headers, 'recordSize'));
|
$x = array_unique(array_column($headers, 'recordSize'));
|
||||||
if (count($x) != 1)
|
if (count($x) != 1)
|
||||||
{
|
{
|
||||||
CLISetup::log('some DBCs have differenct record sizes ('.implode(', ', $x).' respectively). cannot merge!', CLISetup::LOG_ERROR);
|
CLI::write('some DBCs have differenct record sizes ('.implode(', ', $x).' respectively). cannot merge!', CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,11 +345,11 @@ class DBC
|
|||||||
|
|
||||||
$this->createTable();
|
$this->createTable();
|
||||||
|
|
||||||
CLISetup::log(' - reading '.($this->localized ? 'and merging ' : '').$this->file.'.dbc for locales '.implode(', ', array_keys($this->fileRefs)));
|
CLI::write(' - reading '.($this->localized ? 'and merging ' : '').$this->file.'.dbc for locales '.implode(', ', array_keys($this->fileRefs)));
|
||||||
|
|
||||||
if (!$this->read())
|
if (!$this->read())
|
||||||
{
|
{
|
||||||
CLISetup::log(' - DBC::read() returned with error', CLISetup::LOG_ERROR);
|
CLI::write(' - DBC::read() returned with error', CLI::LOG_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,7 +374,7 @@ class DBC
|
|||||||
|
|
||||||
if (fread($handle, 4) != 'WDBC')
|
if (fread($handle, 4) != 'WDBC')
|
||||||
{
|
{
|
||||||
CLISetup::log('file '.$this->curFile.' has incorrect magic bytes', CLISetup::LOG_ERROR);
|
CLI::write('file '.$this->curFile.' has incorrect magic bytes', CLI::LOG_ERROR);
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -387,14 +387,14 @@ class DBC
|
|||||||
$filesize = filesize($this->curFile);
|
$filesize = filesize($this->curFile);
|
||||||
if ($filesize < 20)
|
if ($filesize < 20)
|
||||||
{
|
{
|
||||||
CLISetup::log('file '.$this->curFile.' is too small for a DBC file', CLISetup::LOG_ERROR);
|
CLI::write('file '.$this->curFile.' is too small for a DBC file', CLI::LOG_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$header = $this->readHeader($handle);
|
$header = $this->readHeader($handle);
|
||||||
if (!$header)
|
if (!$header)
|
||||||
{
|
{
|
||||||
CLISetup::log('cannot open file '.$this->curFile, CLISetup::LOG_ERROR);
|
CLI::write('cannot open file '.$this->curFile, CLI::LOG_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,14 +406,14 @@ class DBC
|
|||||||
|
|
||||||
if ($header['recordCount'] * $header['recordSize'] + $header['stringSize'] + 20 != $filesize)
|
if ($header['recordCount'] * $header['recordSize'] + $header['stringSize'] + 20 != $filesize)
|
||||||
{
|
{
|
||||||
CLISetup::log('file '.$this->curFile.' has incorrect size '.$filesize.': '.$debugStr, CLISetup::LOG_ERROR);
|
CLI::write('file '.$this->curFile.' has incorrect size '.$filesize.': '.$debugStr, CLI::LOG_ERROR);
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($header['fieldCount'] != strlen($this->format))
|
if ($header['fieldCount'] != strlen($this->format))
|
||||||
{
|
{
|
||||||
CLISetup::log('incorrect format string ('.$this->format.') specified for file '.$this->curFile.' fieldCount='.$header['fieldCount'], CLISetup::LOG_ERROR);
|
CLI::write('incorrect format string ('.$this->format.') specified for file '.$this->curFile.' fieldCount='.$header['fieldCount'], CLI::LOG_ERROR);
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -519,7 +519,7 @@ class DBC
|
|||||||
|
|
||||||
if (!isset($unpackFmt[$ch]))
|
if (!isset($unpackFmt[$ch]))
|
||||||
{
|
{
|
||||||
CLISetup::log('unknown format parameter \''.$ch.'\' in format string', CLISetup::LOG_ERROR);
|
CLI::write('unknown format parameter \''.$ch.'\' in format string', CLI::LOG_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,7 +541,7 @@ class DBC
|
|||||||
|
|
||||||
if ($recSize != $header['recordSize'])
|
if ($recSize != $header['recordSize'])
|
||||||
{
|
{
|
||||||
CLISetup::log('format string size ('.$recSize.') for file '.$this->file.' does not match actual size ('.$header['recordSize'].')', CLISetup::LOG_ERROR);
|
CLI::write('format string size ('.$recSize.') for file '.$this->file.' does not match actual size ('.$header['recordSize'].')', CLI::LOG_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,19 +95,19 @@ class FileGen
|
|||||||
|
|
||||||
if (!CLISetup::$localeIds /* todo: && this script has localized text */)
|
if (!CLISetup::$localeIds /* todo: && this script has localized text */)
|
||||||
{
|
{
|
||||||
CLISetup::log('No valid locale specified. Check your config or --locales parameter, if used', CLISetup::LOG_ERROR);
|
CLI::write('No valid locale specified. Check your config or --locales parameter, if used', CLI::LOG_ERROR);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create directory structure
|
// create directory structure
|
||||||
CLISetup::log('FileGen::init() - creating required directories');
|
CLI::write('FileGen::init() - creating required directories');
|
||||||
$pathOk = 0;
|
$pathOk = 0;
|
||||||
foreach (self::$reqDirs as $rd)
|
foreach (self::$reqDirs as $rd)
|
||||||
if (CLISetup::writeDir($rd))
|
if (CLISetup::writeDir($rd))
|
||||||
$pathOk++;
|
$pathOk++;
|
||||||
|
|
||||||
CLISetup::log('created '.$pathOk.' extra paths'.($pathOk == count(self::$reqDirs) ? '' : ' with errors'));
|
CLI::write('created '.$pathOk.' extra paths'.($pathOk == count(self::$reqDirs) ? '' : ' with errors'));
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
|
|
||||||
self::$mode = $mode;
|
self::$mode = $mode;
|
||||||
}
|
}
|
||||||
@@ -196,11 +196,11 @@ class FileGen
|
|||||||
require_once 'setup/tools/filegen/'.$key.'.func.php';
|
require_once 'setup/tools/filegen/'.$key.'.func.php';
|
||||||
else if (empty(self::$tplFiles[$key]))
|
else if (empty(self::$tplFiles[$key]))
|
||||||
{
|
{
|
||||||
CLISetup::log(sprintf(ERR_MISSING_INCL, $key, 'setup/tools/filegen/'.$key.'.func.php', CLISetup::LOG_ERROR));
|
CLI::write(sprintf(ERR_MISSING_INCL, $key, 'setup/tools/filegen/'.$key.'.func.php', CLI::LOG_ERROR));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLISetup::log('FileGen::generate() - gathering data for '.$key);
|
CLI::write('FileGen::generate() - gathering data for '.$key);
|
||||||
|
|
||||||
if (!empty(self::$tplFiles[$key]))
|
if (!empty(self::$tplFiles[$key]))
|
||||||
{
|
{
|
||||||
@@ -228,9 +228,9 @@ class FileGen
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$funcOK = false;
|
$funcOK = false;
|
||||||
CLISetup::log('No function for was registered for placeholder '.$func.'().', CLISetup::LOG_ERROR);
|
CLI::write('No function for was registered for placeholder '.$func.'().', CLI::LOG_ERROR);
|
||||||
if (!array_reduce(get_included_files(), function ($inArray, $itr) use ($func) { return $inArray || false !== strpos($itr, $func); }, false))
|
if (!array_reduce(get_included_files(), function ($inArray, $itr) use ($func) { return $inArray || false !== strpos($itr, $func); }, false))
|
||||||
CLISetup::log('Also, expected include setup/tools/filegen/'.$name.'.func.php was not found.');
|
CLI::write('Also, expected include setup/tools/filegen/'.$name.'.func.php was not found.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,7 +240,7 @@ class FileGen
|
|||||||
$success = true;
|
$success = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CLISetup::log(sprintf(ERR_READ_FILE, CLISetup::bold(FileGen::$tplPath.$file.'.in')), CLISetup::LOG_ERROR);
|
CLI::write(sprintf(ERR_READ_FILE, CLI::bold(FileGen::$tplPath.$file.'.in')), CLI::LOG_ERROR);
|
||||||
}
|
}
|
||||||
else if (!empty(self::$datasets[$key]))
|
else if (!empty(self::$datasets[$key]))
|
||||||
{
|
{
|
||||||
@@ -254,7 +254,7 @@ class FileGen
|
|||||||
$success = $key($updateIds);
|
$success = $key($updateIds);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CLISetup::log(' - subscript \''.$key.'\' not defined in included file', CLISetup::LOG_ERROR);
|
CLI::write(' - subscript \''.$key.'\' not defined in included file', CLI::LOG_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_time_limit(FileGen::$defaultExecTime); // reset to default for the next script
|
set_time_limit(FileGen::$defaultExecTime); // reset to default for the next script
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ if (!CLI)
|
|||||||
$file = $path.'.png';
|
$file = $path.'.png';
|
||||||
if (CLISetup::fileExists($file))
|
if (CLISetup::fileExists($file))
|
||||||
{
|
{
|
||||||
CLISetup::log('manually converted png file present for '.$path.'.', CLISetup::LOG_INFO);
|
CLI::write('manually converted png file present for '.$path.'.', CLI::LOG_INFO);
|
||||||
$result = imagecreatefrompng($file);
|
$result = imagecreatefrompng($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ if (!CLI)
|
|||||||
$src = $loadImageFile($baseName.$suffix);
|
$src = $loadImageFile($baseName.$suffix);
|
||||||
if (!$src)
|
if (!$src)
|
||||||
{
|
{
|
||||||
CLISetup::log(' - complexImg: tile '.$baseName.$suffix.'.blp missing.', CLISetup::LOG_ERROR);
|
CLI::write(' - complexImg: tile '.$baseName.$suffix.'.blp missing.', CLI::LOG_ERROR);
|
||||||
unset($dest);
|
unset($dest);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ if (!CLI)
|
|||||||
$ok = imagepng($dest, $name.'.'.$ext);
|
$ok = imagepng($dest, $name.'.'.$ext);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CLISetup::log($done.' - unsupported file fromat: '.$ext, CLISetup::LOG_WARN);
|
CLI::write($done.' - unsupported file fromat: '.$ext, CLI::LOG_WARN);
|
||||||
}
|
}
|
||||||
|
|
||||||
imagedestroy($dest);
|
imagedestroy($dest);
|
||||||
@@ -156,17 +156,17 @@ if (!CLI)
|
|||||||
if ($ok)
|
if ($ok)
|
||||||
{
|
{
|
||||||
chmod($name.'.'.$ext, Util::FILE_ACCESS);
|
chmod($name.'.'.$ext, Util::FILE_ACCESS);
|
||||||
CLISetup::log($done.' - image '.$name.'.'.$ext.' written', CLISetup::LOG_OK);
|
CLI::write($done.' - image '.$name.'.'.$ext.' written', CLI::LOG_OK);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CLISetup::log($done.' - could not create image '.$name.'.'.$ext, CLISetup::LOG_ERROR);
|
CLI::write($done.' - could not create image '.$name.'.'.$ext, CLI::LOG_ERROR);
|
||||||
|
|
||||||
return $ok;
|
return $ok;
|
||||||
};
|
};
|
||||||
|
|
||||||
$createSpawnMap = function($img, $zoneId) use ($mapHeight, $mapWidth, $threshold)
|
$createSpawnMap = function($img, $zoneId) use ($mapHeight, $mapWidth, $threshold)
|
||||||
{
|
{
|
||||||
CLISetup::log(' - creating spawn map');
|
CLI::write(' - creating spawn map');
|
||||||
|
|
||||||
$tmp = imagecreate(1000, 1000);
|
$tmp = imagecreate(1000, 1000);
|
||||||
$cbg = imagecolorallocate($tmp, 255, 255, 255);
|
$cbg = imagecolorallocate($tmp, 255, 255, 255);
|
||||||
@@ -235,11 +235,11 @@ if (!CLI)
|
|||||||
if (in_array($locId, CLISetup::$localeIds))
|
if (in_array($locId, CLISetup::$localeIds))
|
||||||
$locList[] = $xp;
|
$locList[] = $xp;
|
||||||
|
|
||||||
CLISetup::log('required resources overview:', CLISetup::LOG_INFO);
|
CLI::write('required resources overview:', CLI::LOG_INFO);
|
||||||
foreach ($paths as list($path, $isLocalized, $realPath))
|
foreach ($paths as list($path, $isLocalized, $realPath))
|
||||||
{
|
{
|
||||||
if (!$realPath)
|
if (!$realPath)
|
||||||
CLISetup::log(CLISetup::red('MISSING').' - '.str_pad($path, 14).' @ '.sprintf($imgPath, '['.implode(',', $locList).']/').$path);
|
CLI::write(CLI::red('MISSING').' - '.str_pad($path, 14).' @ '.sprintf($imgPath, '['.implode(',', $locList).']/').$path);
|
||||||
else if ($isLocalized)
|
else if ($isLocalized)
|
||||||
{
|
{
|
||||||
$foundLoc = [];
|
$foundLoc = [];
|
||||||
@@ -252,25 +252,28 @@ if (!CLI)
|
|||||||
{
|
{
|
||||||
$buff = [];
|
$buff = [];
|
||||||
foreach ($diff as $d)
|
foreach ($diff as $d)
|
||||||
$buff[] = CLISetup::yellow(Util::$localeStrings[$d]);
|
$buff[] = CLI::yellow(Util::$localeStrings[$d]);
|
||||||
foreach ($foundLoc as $str)
|
foreach ($foundLoc as $str)
|
||||||
$buff[] = CLISetup::green($str);
|
$buff[] = CLI::green($str);
|
||||||
|
|
||||||
CLISetup::log(CLISetup::yellow('PARTIAL').' - '.str_pad($path, 14).' @ '.sprintf($imgPath, '['.implode(',', $buff).']/').$path);
|
CLI::write(CLI::yellow('PARTIAL').' - '.str_pad($path, 14).' @ '.sprintf($imgPath, '['.implode(',', $buff).']/').$path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CLISetup::log(CLISetup::green(' FOUND ').' - '.str_pad($path, 14).' @ '.sprintf($imgPath, '['.implode(',', $foundLoc).']/').$path);
|
CLI::write(CLI::green(' FOUND ').' - '.str_pad($path, 14).' @ '.sprintf($imgPath, '['.implode(',', $foundLoc).']/').$path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CLISetup::log(CLISetup::green(' FOUND ').' - '.str_pad($path, 14).' @ '.$realPath);
|
CLI::write(CLI::green(' FOUND ').' - '.str_pad($path, 14).' @ '.$realPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
|
|
||||||
// if no subdir had sufficient data, diaf
|
// if no subdir had sufficient data, diaf
|
||||||
if (count(array_filter(array_column($paths, 2))) != count($paths))
|
if (count(array_filter(array_column($paths, 2))) != count($paths))
|
||||||
{
|
{
|
||||||
CLISetup::log('one or more required directories are missing:', CLISetup::LOG_ERROR);
|
CLI::write('one or more required directories are missing:', CLI::LOG_ERROR);
|
||||||
|
foreach ($missing as $m)
|
||||||
|
CLI::write(' - '.$m, CLI::LOG_ERROR);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -296,7 +299,7 @@ if (!CLI)
|
|||||||
{
|
{
|
||||||
$sum = 0;
|
$sum = 0;
|
||||||
$total = count($tTabs);
|
$total = count($tTabs);
|
||||||
CLISetup::log('Processing '.$total.' files from TalentFrame/ ...');
|
CLI::write('Processing '.$total.' files from TalentFrame/ ...');
|
||||||
|
|
||||||
foreach ($tTabs as $tt)
|
foreach ($tTabs as $tt)
|
||||||
{
|
{
|
||||||
@@ -317,14 +320,14 @@ if (!CLI)
|
|||||||
|
|
||||||
if (!isset(FileGen::$cliOpts['force']) && file_exists($name.'.jpg'))
|
if (!isset(FileGen::$cliOpts['force']) && file_exists($name.'.jpg'))
|
||||||
{
|
{
|
||||||
CLISetup::log($done.' - file '.$name.'.jpg was already processed');
|
CLI::write($done.' - file '.$name.'.jpg was already processed');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$im = $assembleImage($paths[0x1][2].'/'.$tt['textureFile'], $order, 256 + 44, 256 + 75);
|
$im = $assembleImage($paths[0x1][2].'/'.$tt['textureFile'], $order, 256 + 44, 256 + 75);
|
||||||
if (!$im)
|
if (!$im)
|
||||||
{
|
{
|
||||||
CLISetup::log(' - could not assemble file '.$tt['textureFile'], CLISetup::LOG_ERROR);
|
CLI::write(' - could not assemble file '.$tt['textureFile'], CLI::LOG_ERROR);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,7 +374,7 @@ if (!CLI)
|
|||||||
if (!$wma || !$wmo)
|
if (!$wma || !$wmo)
|
||||||
{
|
{
|
||||||
$success = false;
|
$success = false;
|
||||||
CLISetup::log(' - could not read required dbc files: WorldMapArea.dbc ['.count($wma).' entries]; WorldMapOverlay.dbc ['.count($wmo).' entries]', CLISetup::LOG_ERROR);
|
CLI::write(' - could not read required dbc files: WorldMapArea.dbc ['.count($wma).' entries]; WorldMapOverlay.dbc ['.count($wmo).' entries]', CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,7 +396,7 @@ if (!CLI)
|
|||||||
|
|
||||||
$sumMaps = count(CLISetup::$localeIds) * count($wma);
|
$sumMaps = count(CLISetup::$localeIds) * count($wma);
|
||||||
|
|
||||||
CLISetup::log('Processing '.$sumMaps.' files from WorldMap/ ...');
|
CLI::write('Processing '.$sumMaps.' files from WorldMap/ ...');
|
||||||
|
|
||||||
foreach (CLISetup::$localeIds as $progressLoc => $l)
|
foreach (CLISetup::$localeIds as $progressLoc => $l)
|
||||||
{
|
{
|
||||||
@@ -410,7 +413,7 @@ if (!CLI)
|
|||||||
if ($dirError)
|
if ($dirError)
|
||||||
{
|
{
|
||||||
$success = false;
|
$success = false;
|
||||||
CLISetup::log(' - complexImg: could not create map directories for locale '.$l.'. skipping...', CLISetup::LOG_ERROR);
|
CLI::write(' - complexImg: could not create map directories for locale '.$l.'. skipping...', CLI::LOG_ERROR);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,15 +426,19 @@ if (!CLI)
|
|||||||
if(!isset($paths[0x16][2][$mapLoc]))
|
if(!isset($paths[0x16][2][$mapLoc]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CLISetup::log(' - using files from '.($mapLoc ?: '/').' for locale '.Util::$localeStrings[$l], CLISetup::LOG_INFO);
|
$p = sprintf($imgPath, $mapLoc).$paths[0];
|
||||||
$mapSrcDir = $paths[0x16][2][$mapLoc].'/';
|
if (CLISetup::fileExists($p))
|
||||||
|
{
|
||||||
|
CLI::write(' - using files from '.($mapLoc ?: '/').' for locale '.Util::$localeStrings[$l], CLI::LOG_INFO);
|
||||||
|
$mapSrcDir = $p.'/';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($mapSrcDir === null)
|
if ($mapSrcDir === null)
|
||||||
{
|
{
|
||||||
$success = false;
|
$success = false;
|
||||||
CLISetup::log(' - no suitable localized map files found for locale '.$l, CLISetup::LOG_ERROR);
|
CLI::write(' - no suitable localized map files found for locale '.$l, CLI::LOG_ERROR);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,7 +456,7 @@ if (!CLI)
|
|||||||
if (!CLISetup::fileExists($path))
|
if (!CLISetup::fileExists($path))
|
||||||
{
|
{
|
||||||
$success = false;
|
$success = false;
|
||||||
CLISetup::log('worldmap file '.$path.' missing for selected locale '.Util::$localeStrings[$l], CLISetup::LOG_ERROR);
|
CLI::write('worldmap file '.$path.' missing for selected locale '.Util::$localeStrings[$l], CLI::LOG_ERROR);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,14 +466,14 @@ if (!CLI)
|
|||||||
[9, 10, 11, 12]
|
[9, 10, 11, 12]
|
||||||
);
|
);
|
||||||
|
|
||||||
CLISetup::log($textureStr . " [" . $zoneId . "]");
|
CLI::write($textureStr . " [" . $zoneId . "]");
|
||||||
|
|
||||||
$overlay = $createAlphaImage($mapWidth, $mapHeight);
|
$overlay = $createAlphaImage($mapWidth, $mapHeight);
|
||||||
|
|
||||||
// zone has overlays (is in open world; is not multiLeveled)
|
// zone has overlays (is in open world; is not multiLeveled)
|
||||||
if (isset($wmo[$wmaId]))
|
if (isset($wmo[$wmaId]))
|
||||||
{
|
{
|
||||||
CLISetup::log(' - area has '.count($wmo[$wmaId]).' overlays');
|
CLI::write(' - area has '.count($wmo[$wmaId]).' overlays');
|
||||||
|
|
||||||
foreach ($wmo[$wmaId] as &$row)
|
foreach ($wmo[$wmaId] as &$row)
|
||||||
{
|
{
|
||||||
@@ -480,7 +487,7 @@ if (!CLI)
|
|||||||
$img = $loadImageFile($path . '/' . $row['textureString'] . $i);
|
$img = $loadImageFile($path . '/' . $row['textureString'] . $i);
|
||||||
if (!$img)
|
if (!$img)
|
||||||
{
|
{
|
||||||
CLISetup::log(' - complexImg: tile '.$path.'/'.$row['textureString'].$i.'.blp missing.', CLISetup::LOG_ERROR);
|
CLI::write(' - complexImg: tile '.$path.'/'.$row['textureString'].$i.'.blp missing.', CLI::LOG_ERROR);
|
||||||
break 2;
|
break 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -533,7 +540,7 @@ if (!CLI)
|
|||||||
$file = $path.'/'.$textureStr.'1.blp';
|
$file = $path.'/'.$textureStr.'1.blp';
|
||||||
$hasBaseMap = CLISetup::fileExists($file);
|
$hasBaseMap = CLISetup::fileExists($file);
|
||||||
|
|
||||||
CLISetup::log(' - area has '.($multiLeveled ? $multiLevel . ' levels' : 'only base level'));
|
CLI::write(' - area has '.($multiLeveled ? $multiLevel . ' levels' : 'only base level'));
|
||||||
|
|
||||||
$map = null;
|
$map = null;
|
||||||
for ($i = 0; $i <= $multiLevel; $i++)
|
for ($i = 0; $i <= $multiLevel; $i++)
|
||||||
@@ -565,7 +572,7 @@ if (!CLI)
|
|||||||
|
|
||||||
if (!isset(FileGen::$cliOpts['force']) && file_exists($outFile[$idx].'.'.$info[1]))
|
if (!isset(FileGen::$cliOpts['force']) && file_exists($outFile[$idx].'.'.$info[1]))
|
||||||
{
|
{
|
||||||
CLISetup::log($progress.' - file '.$outFile[$idx].'.'.$info[1].' was already processed');
|
CLI::write($progress.' - file '.$outFile[$idx].'.'.$info[1].' was already processed');
|
||||||
$doSkip |= (1 << $idx);
|
$doSkip |= (1 << $idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -577,7 +584,7 @@ if (!CLI)
|
|||||||
if (!$map)
|
if (!$map)
|
||||||
{
|
{
|
||||||
$success = false;
|
$success = false;
|
||||||
CLISetup::log(' - could not create image resource for map '.$zoneId.($multiLevel ? ' level '.$i : ''));
|
CLI::write(' - could not create image resource for map '.$zoneId.($multiLevel ? ' level '.$i : ''));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -614,7 +621,7 @@ if (!CLI)
|
|||||||
$outFile[$idx] = $destDir . sprintf($info[0], strtolower(Util::$localeStrings[$l]).'/') . $row['areaTableId'];
|
$outFile[$idx] = $destDir . sprintf($info[0], strtolower(Util::$localeStrings[$l]).'/') . $row['areaTableId'];
|
||||||
if (!isset(FileGen::$cliOpts['force']) && file_exists($outFile[$idx].'.'.$info[1]))
|
if (!isset(FileGen::$cliOpts['force']) && file_exists($outFile[$idx].'.'.$info[1]))
|
||||||
{
|
{
|
||||||
CLISetup::log($progress.' - file '.$outFile[$idx].'.'.$info[1].' was already processed');
|
CLI::write($progress.' - file '.$outFile[$idx].'.'.$info[1].' was already processed');
|
||||||
$doSkip |= (1 << $idx);
|
$doSkip |= (1 << $idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -702,7 +709,7 @@ if (!CLI)
|
|||||||
$total = count($imgGroups);
|
$total = count($imgGroups);
|
||||||
$sum = 0;
|
$sum = 0;
|
||||||
|
|
||||||
CLISetup::log('Processing '.$total.' files from Glues/Credits/...');
|
CLI::write('Processing '.$total.' files from Glues/Credits/...');
|
||||||
|
|
||||||
foreach ($imgGroups as $file => $fmt)
|
foreach ($imgGroups as $file => $fmt)
|
||||||
{
|
{
|
||||||
@@ -714,20 +721,20 @@ if (!CLI)
|
|||||||
|
|
||||||
if (!isset(FileGen::$cliOpts['force']) && file_exists($name.'.png'))
|
if (!isset(FileGen::$cliOpts['force']) && file_exists($name.'.png'))
|
||||||
{
|
{
|
||||||
CLISetup::log($done.' - file '.$name.'.png was already processed');
|
CLI::write($done.' - file '.$name.'.png was already processed');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($order[$fmt]))
|
if (!isset($order[$fmt]))
|
||||||
{
|
{
|
||||||
CLISetup::log(' - pattern for file '.$name.' not set. skipping', CLISetup::LOG_WARN);
|
CLI::write(' - pattern for file '.$name.' not set. skipping', CLI::LOG_WARN);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$im = $assembleImage($paths[0x8][2].'/'.$file, $order[$fmt], count($order[$fmt][0]) * 256, count($order[$fmt]) * 256);
|
$im = $assembleImage($paths[0x8][2].'/'.$file, $order[$fmt], count($order[$fmt][0]) * 256, count($order[$fmt]) * 256);
|
||||||
if (!$im)
|
if (!$im)
|
||||||
{
|
{
|
||||||
CLISetup::log(' - could not assemble file '.$name, CLISetup::LOG_ERROR);
|
CLI::write(' - could not assemble file '.$name, CLI::LOG_ERROR);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ if (!CLI)
|
|||||||
$enchantments = new EnchantmentList(array(['id', $enchIds], CFG_SQL_LIMIT_NONE));
|
$enchantments = new EnchantmentList(array(['id', $enchIds], CFG_SQL_LIMIT_NONE));
|
||||||
if ($enchantments->error)
|
if ($enchantments->error)
|
||||||
{
|
{
|
||||||
CLISetup::log('Required table ?_itemenchantment seems to be empty! Leaving enchants()...', CLISetup::LOG_ERROR);
|
CLI::write('Required table ?_itemenchantment seems to be empty! Leaving enchants()...', CLI::LOG_ERROR);
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ if (!CLI)
|
|||||||
$eId = $es['effect1MiscValue'];
|
$eId = $es['effect1MiscValue'];
|
||||||
if (!$enchantments->getEntry($eId))
|
if (!$enchantments->getEntry($eId))
|
||||||
{
|
{
|
||||||
CLISetup::log(' * could not find enchantment #'.$eId.' referenced by spell #'.$esId, CLISetup::LOG_WARN);
|
CLI::write(' * could not find enchantment #'.$eId.' referenced by spell #'.$esId, CLI::LOG_WARN);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ if (!CLI)
|
|||||||
$enchantments = new EnchantmentList(array(['id', $enchIds], CFG_SQL_LIMIT_NONE));
|
$enchantments = new EnchantmentList(array(['id', $enchIds], CFG_SQL_LIMIT_NONE));
|
||||||
if ($enchantments->error)
|
if ($enchantments->error)
|
||||||
{
|
{
|
||||||
CLISetup::log('Required table ?_itemenchantment seems to be empty! Leaving gems()...', CLISetup::LOG_ERROR);
|
CLI::write('Required table ?_itemenchantment seems to be empty! Leaving gems()...', CLI::LOG_ERROR);
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ if (!CLI)
|
|||||||
{
|
{
|
||||||
if (!$enchantments->getEntry($pop['enchId']))
|
if (!$enchantments->getEntry($pop['enchId']))
|
||||||
{
|
{
|
||||||
CLISetup::log(' * could not find enchantment #'.$pop['enchId'].' referenced by item #'.$gem['itemId'], CLISetup::LOG_WARN);
|
CLI::write(' * could not find enchantment #'.$pop['enchId'].' referenced by item #'.$gem['itemId'], CLI::LOG_WARN);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ if (!CLI)
|
|||||||
if (!$buff)
|
if (!$buff)
|
||||||
{
|
{
|
||||||
// this behaviour is intended, do not create an error
|
// this behaviour is intended, do not create an error
|
||||||
CLISetup::log('profiler - file datasets/'.User::$localeString.'/p-recipes-'.$file.' has no content => skipping', CLISetup::LOG_WARN);
|
CLI::write('profiler - file datasets/'.User::$localeString.'/p-recipes-'.$file.' has no content => skipping', CLI::LOG_WARN);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ if (!CLI)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$set)
|
if (!$set)
|
||||||
CLISetup::log(' - realmMenu: Auth-DB not set up .. menu will be empty', CLISetup::LOG_WARN);
|
CLI::write(' - realmMenu: Auth-DB not set up .. menu will be empty', CLI::LOG_WARN);
|
||||||
|
|
||||||
if (!($set & 0x1))
|
if (!($set & 0x1))
|
||||||
array_pop($menu);
|
array_pop($menu);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ if (!CLI)
|
|||||||
{
|
{
|
||||||
$realms = Util::getRealms();
|
$realms = Util::getRealms();
|
||||||
if (!$realms)
|
if (!$realms)
|
||||||
CLISetup::log(' - realms: Auth-DB not set up .. static data g_realms will be empty', CLISetup::LOG_WARN);
|
CLI::write(' - realms: Auth-DB not set up .. static data g_realms will be empty', CLI::LOG_WARN);
|
||||||
else
|
else
|
||||||
foreach ($realms as &$r)
|
foreach ($realms as &$r)
|
||||||
$r['battlegroup'] = CFG_BATTLEGROUP;
|
$r['battlegroup'] = CFG_BATTLEGROUP;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ if (!CLI)
|
|||||||
$file = $path.'.png';
|
$file = $path.'.png';
|
||||||
if (CLISetup::fileExists($file))
|
if (CLISetup::fileExists($file))
|
||||||
{
|
{
|
||||||
CLISetup::log('manually converted png file present for '.$path.'.', CLISetup::LOG_INFO);
|
CLI::write('manually converted png file present for '.$path.'.', CLI::LOG_INFO);
|
||||||
$result = imagecreatefrompng($file);
|
$result = imagecreatefrompng($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ if (!CLI)
|
|||||||
$ok = imagepng($dest, $name.$ext);
|
$ok = imagepng($dest, $name.$ext);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CLISetup::log($done.' - unsupported file fromat: '.$ext, CLISetup::LOG_WARN);
|
CLI::write($done.' - unsupported file fromat: '.$ext, CLI::LOG_WARN);
|
||||||
}
|
}
|
||||||
|
|
||||||
imagedestroy($dest);
|
imagedestroy($dest);
|
||||||
@@ -182,10 +182,10 @@ if (!CLI)
|
|||||||
if ($ok)
|
if ($ok)
|
||||||
{
|
{
|
||||||
chmod($name.$ext, Util::FILE_ACCESS);
|
chmod($name.$ext, Util::FILE_ACCESS);
|
||||||
CLISetup::log($done.' - image '.$name.$ext.' written', CLISetup::LOG_OK);
|
CLI::write($done.' - image '.$name.$ext.' written', CLI::LOG_OK);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CLISetup::log($done.' - could not create image '.$name.$ext, CLISetup::LOG_ERROR);
|
CLI::write($done.' - could not create image '.$name.$ext, CLI::LOG_ERROR);
|
||||||
|
|
||||||
return $ok;
|
return $ok;
|
||||||
};
|
};
|
||||||
@@ -242,21 +242,24 @@ if (!CLI)
|
|||||||
if (in_array($locId, CLISetup::$localeIds))
|
if (in_array($locId, CLISetup::$localeIds))
|
||||||
$locList[] = $xp;
|
$locList[] = $xp;
|
||||||
|
|
||||||
CLISetup::log('required resources overview:', CLISetup::LOG_INFO);
|
CLI::write('required resources overview:', CLI::LOG_INFO);
|
||||||
foreach ($paths as list($path, , , , , $realPath))
|
foreach ($paths as list($path, , , , , $realPath))
|
||||||
{
|
{
|
||||||
if ($realPath)
|
if ($realPath)
|
||||||
CLISetup::log(CLISetup::green(' FOUND ').' - '.str_pad($path, 53).' @ '.$realPath);
|
CLI::write(CLI::green(' FOUND ').' - '.str_pad($path, 53).' @ '.$realPath);
|
||||||
else
|
else
|
||||||
CLISetup::log(CLISetup::red('MISSING').' - '.str_pad($path, 53).' @ '.sprintf($imgPath, '['.implode(',', $locList).']/').$path);
|
CLI::write(CLI::red('MISSING').' - '.str_pad($path, 53).' @ '.sprintf($imgPath, '['.implode(',', $locList).']/').$path);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLISetup::log();
|
CLI::write();
|
||||||
|
|
||||||
// if no subdir had sufficient data, diaf
|
// if no subdir had sufficient data, diaf
|
||||||
if (count(array_filter(array_column($paths, 5))) != count($paths))
|
if (count(array_filter(array_column($paths, 5))) != count($paths))
|
||||||
{
|
{
|
||||||
CLISetup::log('one or more required directories are missing:', CLISetup::LOG_ERROR);
|
CLI::write('one or more required directories are missing:', CLI::LOG_ERROR);
|
||||||
|
foreach ($missing as $m)
|
||||||
|
CLI::write(' - '.$m, CLI::LOG_ERROR);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -316,7 +319,7 @@ if (!CLI)
|
|||||||
$files = CLISetup::filesInPath($search, !!$pattern);
|
$files = CLISetup::filesInPath($search, !!$pattern);
|
||||||
$allPaths = array_merge($allPaths, $files);
|
$allPaths = array_merge($allPaths, $files);
|
||||||
|
|
||||||
CLISetup::log('processing '.count($files).' files in '.$path.'...');
|
CLI::write('processing '.count($files).' files in '.$path.'...');
|
||||||
|
|
||||||
$j = 0;
|
$j = 0;
|
||||||
foreach ($files as $f)
|
foreach ($files as $f)
|
||||||
@@ -336,7 +339,7 @@ if (!CLI)
|
|||||||
else if (!$tileSize)
|
else if (!$tileSize)
|
||||||
{
|
{
|
||||||
$j += count($outInfo);
|
$j += count($outInfo);
|
||||||
CLISetup::log('skipping extraneous file '.$img.' (+'.count($outInfo).')');
|
CLI::write('skipping extraneous file '.$img.' (+'.count($outInfo).')');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -357,7 +360,7 @@ if (!CLI)
|
|||||||
|
|
||||||
if (!isset(FileGen::$cliOpts['force']) && file_exists($destDir.$dest.$img.$ext))
|
if (!isset(FileGen::$cliOpts['force']) && file_exists($destDir.$dest.$img.$ext))
|
||||||
{
|
{
|
||||||
CLISetup::log($done.' - file '.$dest.$img.$ext.' was already processed');
|
CLI::write($done.' - file '.$dest.$img.$ext.' was already processed');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,10 +407,10 @@ if (!CLI)
|
|||||||
imagecopyresampled($dest, $src, 5, 0, 64 + 1, 32 + 1, 10, 16, 18, 28);
|
imagecopyresampled($dest, $src, 5, 0, 64 + 1, 32 + 1, 10, 16, 18, 28);
|
||||||
|
|
||||||
if (imagegif($dest, $destDir.$dest.'quest_startend.gif'))
|
if (imagegif($dest, $destDir.$dest.'quest_startend.gif'))
|
||||||
CLISetup::log(' extra - image '.$destDir.$dest.'quest_startend.gif written', CLISetup::LOG_OK);
|
CLI::write(' extra - image '.$destDir.$dest.'quest_startend.gif written', CLI::LOG_OK);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLISetup::log(' extra - could not create image '.$destDir.$dest.'quest_startend.gif', CLISetup::LOG_ERROR);
|
CLI::write(' extra - could not create image '.$destDir.$dest.'quest_startend.gif', CLI::LOG_ERROR);
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,7 +429,7 @@ if (!CLI)
|
|||||||
|
|
||||||
if (!isset(FileGen::$cliOpts['force']) && file_exists($destDir.$dest.$img.$ext))
|
if (!isset(FileGen::$cliOpts['force']) && file_exists($destDir.$dest.$img.$ext))
|
||||||
{
|
{
|
||||||
CLISetup::log($done.' - file '.$dest.$img.$ext.' was already processed');
|
CLI::write($done.' - file '.$dest.$img.$ext.' was already processed');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,9 +475,9 @@ if (!CLI)
|
|||||||
DB::Aowow()->query('UPDATE ?_icons SET cuFlags = cuFlags | ?d WHERE name IN (?a)', CUSTOM_EXCLUDE_FOR_LISTVIEW, $iconNames);
|
DB::Aowow()->query('UPDATE ?_icons SET cuFlags = cuFlags | ?d WHERE name IN (?a)', CUSTOM_EXCLUDE_FOR_LISTVIEW, $iconNames);
|
||||||
|
|
||||||
asort($missing);
|
asort($missing);
|
||||||
CLISetup::log('the following '.count($missing).' images where referenced by DBC but not in the mpqData directory. They may need to be converted by hand later on.', CLISetup::LOG_WARN);
|
CLI::write('the following '.count($missing).' images where referenced by DBC but not in the mpqData directory. They may need to be converted by hand later on.', CLI::LOG_WARN);
|
||||||
foreach ($missing as $m)
|
foreach ($missing as $m)
|
||||||
CLISetup::log(' - '.$m);
|
CLI::write(' - '.$m);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $success;
|
return $success;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ if (!CLI)
|
|||||||
if ($i == $step)
|
if ($i == $step)
|
||||||
{
|
{
|
||||||
$i = 0;
|
$i = 0;
|
||||||
CLISetup::log(' - '.$itr.'/'.$nFiles.' ('.(intVal(100 * $itr / $nFiles).'%) done'));
|
CLI::write(' - '.$itr.'/'.$nFiles.' ('.(intVal(100 * $itr / $nFiles).'%) done'));
|
||||||
DB::Aowow()->selectCell('SELECT 1'); // keep mysql busy or it may go away
|
DB::Aowow()->selectCell('SELECT 1'); // keep mysql busy or it may go away
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ if (!CLI)
|
|||||||
foreach (CLISetup::$expectedPaths as $locStr => $__)
|
foreach (CLISetup::$expectedPaths as $locStr => $__)
|
||||||
{
|
{
|
||||||
// get your paths straight!
|
// get your paths straight!
|
||||||
$p = CLISetup::nicePath($filePath, CLISetup::$srcDir, $locStr);
|
$p = CLI::nicePath($filePath, CLISetup::$srcDir, $locStr);
|
||||||
|
|
||||||
if (CLISetup::fileExists($p))
|
if (CLISetup::fileExists($p))
|
||||||
{
|
{
|
||||||
@@ -41,7 +41,7 @@ if (!CLI)
|
|||||||
if (!copy($p, 'static/wowsounds/'.$fileId))
|
if (!copy($p, 'static/wowsounds/'.$fileId))
|
||||||
{
|
{
|
||||||
$ok = false;
|
$ok = false;
|
||||||
CLISetup::log(' - could not copy '.CLISetup::bold($p).' into '.CLISetup::bold('static/wowsounds/'.$fileId), CLISetup::LOG_ERROR);
|
CLI::write(' - could not copy '.CLI::bold($p).' into '.CLI::bold('static/wowsounds/'.$fileId), CLI::LOG_ERROR);
|
||||||
break 2;
|
break 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ if (!CLI)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CLISetup::log(' - did not find file: '.CLISetup::bold(CLISetup::nicePath($filePath, CLISetup::$srcDir, '<locale>')), CLISetup::LOG_WARN);
|
CLI::write(' - did not find file: '.CLI::bold(CLI::nicePath($filePath, CLISetup::$srcDir, '<locale>')), CLI::LOG_WARN);
|
||||||
// flag as unusable in DB
|
// flag as unusable in DB
|
||||||
DB::Aowow()->query('UPDATE ?_sounds_files SET id = ?d WHERE ABS(id) = ?d', -$fileId, $fileId);
|
DB::Aowow()->query('UPDATE ?_sounds_files SET id = ?d WHERE ABS(id) = ?d', -$fileId, $fileId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ if (!CLI)
|
|||||||
$res = $$s();
|
$res = $$s();
|
||||||
$out[$s] = $res;
|
$out[$s] = $res;
|
||||||
if (!$res)
|
if (!$res)
|
||||||
CLISetup::log('statistics - generator $'.$s.'() returned empty', CLISetup::LOG_WARN);
|
CLI::write('statistics - generator $'.$s.'() returned empty', CLI::LOG_WARN);
|
||||||
}
|
}
|
||||||
|
|
||||||
$toFile = 'g_statistics = '.preg_replace('/"\$([^$"]+)"/', '\1', Util::toJSON($out)).';';
|
$toFile = 'g_statistics = '.preg_replace('/"\$([^$"]+)"/', '\1', Util::toJSON($out)).';';
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ if (!CLI)
|
|||||||
|
|
||||||
if (empty($icons))
|
if (empty($icons))
|
||||||
{
|
{
|
||||||
CLISetup::log('talentIcons - query for '.$v.' tree: '.$k.' returned empty', CLISetup::LOG_ERROR);
|
CLI::write('talentIcons - query for '.$v.' tree: '.$k.' returned empty', CLI::LOG_ERROR);
|
||||||
$success = false;
|
$success = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ if (!CLI)
|
|||||||
$imgFile = 'static/images/wow/icons/medium/'.strtolower($icons[$i]).'.jpg';
|
$imgFile = 'static/images/wow/icons/medium/'.strtolower($icons[$i]).'.jpg';
|
||||||
if (!file_exists($imgFile))
|
if (!file_exists($imgFile))
|
||||||
{
|
{
|
||||||
CLISetup::log('talentIcons - raw image '.CLISetup::bold($imgFile). ' not found', CLISetup::LOG_ERROR);
|
CLI::write('talentIcons - raw image '.CLI::bold($imgFile). ' not found', CLI::LOG_ERROR);
|
||||||
$success = false;
|
$success = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -80,17 +80,17 @@ if (!CLI)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (@imagejpeg($res, $outFile))
|
if (@imagejpeg($res, $outFile))
|
||||||
CLISetup::log(sprintf(ERR_NONE, CLISetup::bold($outFile)), CLISetup::LOG_OK);
|
CLI::write(sprintf(ERR_NONE, CLI::bold($outFile)), CLI::LOG_OK);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$success = false;
|
$success = false;
|
||||||
CLISetup::log('talentIcons - '.CLISetup::bold($outFile.'.jpg').' could not be written', CLISetup::LOG_ERROR);
|
CLI::write('talentIcons - '.CLI::bold($outFile.'.jpg').' could not be written', CLI::LOG_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$success = false;
|
$success = false;
|
||||||
CLISetup::log('talentIcons - image resource not created', CLISetup::LOG_ERROR);
|
CLI::write('talentIcons - image resource not created', CLI::LOG_ERROR);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ if (!CLI)
|
|||||||
$wtPresets[$s['class']]['pve'][$s['name']] = array_merge(['__icon' => $s['icon']], $weights);
|
$wtPresets[$s['class']]['pve'][$s['name']] = array_merge(['__icon' => $s['icon']], $weights);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLISetup::log('WeightScale \''.CLISetup::bold($s['name']).'\' has no data set. Skipping...', CLISetup::LOG_WARN);
|
CLI::write('WeightScale \''.CLI::bold($s['name']).'\' has no data set.', CLI::LOG_WARN);
|
||||||
$wtPresets[$s['class']]['pve'][$s['name']] = ['__icon' => $s['icon']];
|
$wtPresets[$s['class']]['pve'][$s['name']] = ['__icon' => $s['icon']];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
{
|
{
|
||||||
if (!CLISetup::fileExists($fileName))
|
if (!CLISetup::fileExists($fileName))
|
||||||
{
|
{
|
||||||
CLISetup::log('file '.$fileName.' could not be found', CLISetup::LOG_ERROR);
|
CLI::write('file '.$fileName.' could not be found', CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,14 +41,14 @@
|
|||||||
|
|
||||||
if (!$file)
|
if (!$file)
|
||||||
{
|
{
|
||||||
CLISetup::log('could not open file '.$fileName, CLISetup::LOG_ERROR);
|
CLI::write('could not open file '.$fileName, CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fileSize = fileSize($fileName);
|
$fileSize = fileSize($fileName);
|
||||||
if ($fileSize < 16)
|
if ($fileSize < 16)
|
||||||
{
|
{
|
||||||
CLISetup::log('file '.$fileName.' is too small for a BLP file', CLISetup::LOG_ERROR);
|
CLI::write('file '.$fileName.' is too small for a BLP file', CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,14 +64,14 @@
|
|||||||
$data = substr($data, 0x44);
|
$data = substr($data, 0x44);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLISetup::log('file '.$fileName.' is an incremental patch file and cannot be used by this script.', CLISetup::LOG_ERROR);
|
CLI::write('file '.$fileName.' is an incremental patch file and cannot be used by this script.', CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (substr($data, 0, 4) != "BLP2")
|
if (substr($data, 0, 4) != "BLP2")
|
||||||
{
|
{
|
||||||
CLISetup::log('file '.$fileName.' has incorrect/unsupported magic bytes', CLISetup::LOG_ERROR);
|
CLI::write('file '.$fileName.' has incorrect/unsupported magic bytes', CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
|
|
||||||
if ($header['format'] != 1)
|
if ($header['format'] != 1)
|
||||||
{
|
{
|
||||||
CLISetup::log('file '.$fileName.' has unsupported format'.$debugStr, CLISetup::LOG_ERROR);
|
CLI::write('file '.$fileName.' has unsupported format'.$debugStr, CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,12 +99,12 @@
|
|||||||
|
|
||||||
if ($size == 0)
|
if ($size == 0)
|
||||||
{
|
{
|
||||||
CLISetup::log('file '.$fileName.' contains zeroes in a mips table'.$debugStr, CLISetup::LOG_ERROR);
|
CLI::write('file '.$fileName.' contains zeroes in a mips table'.$debugStr, CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($offs + $size > $fileSize)
|
if ($offs + $size > $fileSize)
|
||||||
{
|
{
|
||||||
CLISetup::log('file '.$fileName.' is corrupted/incomplete'.$debugStr, CLISetup::LOG_ERROR);
|
CLI::write('file '.$fileName.' is corrupted/incomplete'.$debugStr, CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@
|
|||||||
$img = icfb3($header['width'], $header['height'], substr($data, $offs, $size));
|
$img = icfb3($header['width'], $header['height'], substr($data, $offs, $size));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLISetup::log('file '.$fileName.' has unsupported type'.$debugStr, CLISetup::LOG_ERROR);
|
CLI::write('file '.$fileName.' has unsupported type'.$debugStr, CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@
|
|||||||
{
|
{
|
||||||
if (!in_array($alphaBits * 10 + $alphaType, [0, 10, 41, 81, 87, 88]))
|
if (!in_array($alphaBits * 10 + $alphaType, [0, 10, 41, 81, 87, 88]))
|
||||||
{
|
{
|
||||||
CLISetup::log('unsupported compression type', CLISetup::LOG_ERROR);
|
CLI::write('unsupported compression type', CLI::LOG_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class SqlGen
|
|||||||
|
|
||||||
if (!CLISetup::$localeIds /* && this script has localized text */)
|
if (!CLISetup::$localeIds /* && this script has localized text */)
|
||||||
{
|
{
|
||||||
CLISetup::log('No valid locale specified. Check your config or --locales parameter, if used', CLISetup::LOG_ERROR);
|
CLI::write('No valid locale specified. Check your config or --locales parameter, if used', CLI::LOG_ERROR);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,14 +158,14 @@ class SqlGen
|
|||||||
{
|
{
|
||||||
if (!isset(self::$tables[$tableName]))
|
if (!isset(self::$tables[$tableName]))
|
||||||
{
|
{
|
||||||
CLISetup::log('SqlGen::generate - invalid table given', CLISetup::LOG_ERROR);
|
CLI::write('SqlGen::generate - invalid table given', CLI::LOG_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty(self::$tables[$tableName][0])) // straight copy from dbc source
|
if (!empty(self::$tables[$tableName][0])) // straight copy from dbc source
|
||||||
{
|
{
|
||||||
$tbl = self::$tables[$tableName]; // shorthand
|
$tbl = self::$tables[$tableName]; // shorthand
|
||||||
CLISetup::log('SqlGen::generate() - copying '.$tbl[0].'.dbc into aowow_'.$tableName);
|
CLI::write('SqlGen::generate() - copying '.$tbl[0].'.dbc into aowow_'.$tableName);
|
||||||
|
|
||||||
$dbc = new DBC($tbl[0], ['temporary' => CLISetup::$tmpDBC, 'tableName' => 'aowow_'.$tableName]);
|
$dbc = new DBC($tbl[0], ['temporary' => CLISetup::$tmpDBC, 'tableName' => 'aowow_'.$tableName]);
|
||||||
if ($dbc->error)
|
if ($dbc->error)
|
||||||
@@ -177,7 +177,7 @@ class SqlGen
|
|||||||
{
|
{
|
||||||
$customData = $reqDBC = [];
|
$customData = $reqDBC = [];
|
||||||
|
|
||||||
CLISetup::log('SqlGen::generate() - filling aowow_'.$tableName.' with data');
|
CLI::write('SqlGen::generate() - filling aowow_'.$tableName.' with data');
|
||||||
|
|
||||||
require_once 'setup/tools/sqlgen/'.$tableName.'.func.php';
|
require_once 'setup/tools/sqlgen/'.$tableName.'.func.php';
|
||||||
|
|
||||||
@@ -196,12 +196,12 @@ class SqlGen
|
|||||||
DB::Aowow()->query('UPDATE ?_'.$tableName.' SET ?a WHERE id = ?d', $data, $id);
|
DB::Aowow()->query('UPDATE ?_'.$tableName.' SET ?a WHERE id = ?d', $data, $id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CLISetup::log(' - subscript \''.$tableName.'\' not defined in included file', CLISetup::LOG_ERROR);
|
CLI::write(' - subscript \''.$tableName.'\' not defined in included file', CLI::LOG_ERROR);
|
||||||
|
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CLISetup::log(sprintf(ERR_MISSING_INCL, $tableName, 'setup/tools/sqlgen/'.$tableName.'.func.php'), CLISetup::LOG_ERROR);
|
CLI::write(sprintf(ERR_MISSING_INCL, $tableName, 'setup/tools/sqlgen/'.$tableName.'.func.php'), CLI::LOG_ERROR);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ function creature(array $ids = [])
|
|||||||
{
|
{
|
||||||
$newMax = max(array_column($npcs, 'entry'));
|
$newMax = max(array_column($npcs, 'entry'));
|
||||||
|
|
||||||
CLISetup::log(' * sets '.($lastMax + 1).' - '.$newMax);
|
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||||
|
|
||||||
$lastMax = $newMax;
|
$lastMax = $newMax;
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function currencies(array $ids = [])
|
|||||||
$strings = $moneyNames[$itemId];
|
$strings = $moneyNames[$itemId];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLISetup::log('item #'.$itemId.' required by currency #'.$cId.' not in item_template', CLISetup::LOG_WARN);
|
CLI::write('item #'.$itemId.' required by currency #'.$cId.' not in item_template', CLI::LOG_WARN);
|
||||||
$strings = ['name_loc0' => 'Item #'.$itemId.' not in DB', 'iconId' => 0, 'cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW, 'category' => 3];
|
$strings = ['name_loc0' => 'Item #'.$itemId.' not in DB', 'iconId' => 0, 'cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW, 'category' => 3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ function emotes(/*array $ids = [] */)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CLISetup::log('GlobalStrings.lua not found for selected locale '.CLISetup::bold(Util::$localeStrings[$lId]), CLISetup::LOG_WARN);
|
CLI::write('GlobalStrings.lua not found for selected locale '.CLI::bold(Util::$localeStrings[$lId]), CLI::LOG_WARN);
|
||||||
$allOK = false;
|
$allOK = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,10 +142,10 @@ function item_stats(array $ids = [])
|
|||||||
{
|
{
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
|
|
||||||
CLISetup::log(' - applying stats for enchantments');
|
CLI::write(' - applying stats for enchantments');
|
||||||
$enchStats = enchantment_stats();
|
$enchStats = enchantment_stats();
|
||||||
CLISetup::log(' '.count($enchStats).' enchantments parsed');
|
CLI::write(' '.count($enchStats).' enchantments parsed');
|
||||||
CLISetup::log(' - applying stats for items');
|
CLI::write(' - applying stats for items');
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
@@ -156,7 +156,7 @@ function item_stats(array $ids = [])
|
|||||||
$max = max($items->getFoundIDs());
|
$max = max($items->getFoundIDs());
|
||||||
$num = count($items->getFoundIDs());
|
$num = count($items->getFoundIDs());
|
||||||
|
|
||||||
CLISetup::log(' * sets '.($offset + 1).' - '.($max));
|
CLI::write(' * sets '.($offset + 1).' - '.($max));
|
||||||
|
|
||||||
$offset = $max;
|
$offset = $max;
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ function items(array $ids = [])
|
|||||||
{
|
{
|
||||||
$newMax = max(array_column($items, 'entry'));
|
$newMax = max(array_column($items, 'entry'));
|
||||||
|
|
||||||
CLISetup::log(' * sets '.($lastMax + 1).' - '.$newMax);
|
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||||
|
|
||||||
$lastMax = $newMax;
|
$lastMax = $newMax;
|
||||||
|
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ function itemset()
|
|||||||
$items[$vId][$piece['slot'].$itemId] = $itemId;
|
$items[$vId][$piece['slot'].$itemId] = $itemId;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLISetup::log("set: ".$setId." ilvl: ".$piece['ItemLevel']." - conflict between item: ".$items[$vId][$piece['slot']]." and item: ".$itemId." choosing lower itemId", CLISetup::LOG_WARN);
|
CLI::write("set: ".$setId." ilvl: ".$piece['ItemLevel']." - conflict between item: ".$items[$vId][$piece['slot']]." and item: ".$itemId." choosing lower itemId", CLI::LOG_WARN);
|
||||||
|
|
||||||
if ($items[$vId][$piece['slot']] > $itemId)
|
if ($items[$vId][$piece['slot']] > $itemId)
|
||||||
$items[$vId][$piece['slot']] = $itemId;
|
$items[$vId][$piece['slot']] = $itemId;
|
||||||
@@ -243,7 +243,7 @@ function itemset()
|
|||||||
foreach ($subset as $slot => $item)
|
foreach ($subset as $slot => $item)
|
||||||
{
|
{
|
||||||
if (isset($temp[$slot]) && $temp[$slot] < $item)
|
if (isset($temp[$slot]) && $temp[$slot] < $item)
|
||||||
CLISetup::log("set: ".$setId." - conflict between item: ".$item." and item: ".$temp[$slot]." choosing lower itemId", CLISetup::LOG_WARN);
|
CLI::write("set: ".$setId." - conflict between item: ".$item." and item: ".$temp[$slot]." choosing lower itemId", CLI::LOG_WARN);
|
||||||
else if ($slot == 13 || $slot = 11) // special case
|
else if ($slot == 13 || $slot = 11) // special case
|
||||||
$temp[] = $item;
|
$temp[] = $item;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ function objects(array $ids = [])
|
|||||||
{
|
{
|
||||||
$newMax = max(array_column($objects, 'entry'));
|
$newMax = max(array_column($objects, 'entry'));
|
||||||
|
|
||||||
CLISetup::log(' * sets '.($lastMax + 1).' - '.$newMax);
|
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||||
|
|
||||||
$lastMax = $newMax;
|
$lastMax = $newMax;
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ function quests(array $ids = [])
|
|||||||
{
|
{
|
||||||
$newMax = max(array_column($quests, 'ID'));
|
$newMax = max(array_column($quests, 'ID'));
|
||||||
|
|
||||||
CLISetup::log(' * sets '.($lastMax + 1).' - '.$newMax);
|
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||||
|
|
||||||
$lastMax = $newMax;
|
$lastMax = $newMax;
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ function sounds(/*array $ids = [] */)
|
|||||||
/* M A I N */
|
/* M A I N */
|
||||||
/***********/
|
/***********/
|
||||||
|
|
||||||
CLISetup::log(' - sounds main data');
|
CLI::write(' - sounds main data');
|
||||||
|
|
||||||
// file extraction and conversion manually
|
// file extraction and conversion manually
|
||||||
// moving files in build step. data here is purely structural
|
// moving files in build step. data here is purely structural
|
||||||
@@ -74,7 +74,7 @@ function sounds(/*array $ids = [] */)
|
|||||||
{
|
{
|
||||||
$newMax = max(array_column($sounds, 'id'));
|
$newMax = max(array_column($sounds, 'id'));
|
||||||
|
|
||||||
CLISetup::log(' * sets '.($lastMax + 1).' - '.$newMax);
|
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||||
|
|
||||||
$lastMax = $newMax;
|
$lastMax = $newMax;
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ function sounds(/*array $ids = [] */)
|
|||||||
$hasDupes = false;
|
$hasDupes = false;
|
||||||
for ($i = 1; $i < 11; $i++)
|
for ($i = 1; $i < 11; $i++)
|
||||||
{
|
{
|
||||||
$nicePath = CLISetup::nicePath($s['soundFile'.$i], $s['path']);
|
$nicePath = CLI::nicePath($s['soundFile'.$i], $s['path']);
|
||||||
if ($s['soundFile'.$i] && array_key_exists($nicePath, $soundIndex))
|
if ($s['soundFile'.$i] && array_key_exists($nicePath, $soundIndex))
|
||||||
{
|
{
|
||||||
$s['soundFile'.$i] = $soundIndex[$nicePath];
|
$s['soundFile'.$i] = $soundIndex[$nicePath];
|
||||||
@@ -131,7 +131,7 @@ function sounds(/*array $ids = [] */)
|
|||||||
// i call bullshit
|
// i call bullshit
|
||||||
else if ($s['soundFile'.$i])
|
else if ($s['soundFile'.$i])
|
||||||
{
|
{
|
||||||
CLISetup::log(' - sound group #'.$s['id'].' "'.$s['name'].'" has invalid sound file "'.$s['soundFile'.$i].'" on index '.$i.'! Skipping...', CLISetup::LOG_WARN);
|
CLI::write(' - sound group #'.$s['id'].' "'.$s['name'].'" has invalid sound file "'.$s['soundFile'.$i].'" on index '.$i.'! Skipping...', CLI::LOG_WARN);
|
||||||
$s['soundFile'.$i] = null;
|
$s['soundFile'.$i] = null;
|
||||||
}
|
}
|
||||||
// empty case
|
// empty case
|
||||||
@@ -141,7 +141,7 @@ function sounds(/*array $ids = [] */)
|
|||||||
|
|
||||||
if (!$fileSets && !$hasDupes)
|
if (!$fileSets && !$hasDupes)
|
||||||
{
|
{
|
||||||
CLISetup::log(' - sound group #'.$s['id'].' "'.$s['name'].'" contains no sound files! Skipping...', CLISetup::LOG_WARN);
|
CLI::write(' - sound group #'.$s['id'].' "'.$s['name'].'" contains no sound files! Skipping...', CLI::LOG_WARN);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if ($fileSets)
|
else if ($fileSets)
|
||||||
@@ -160,7 +160,7 @@ function sounds(/*array $ids = [] */)
|
|||||||
/* VocalUI Sounds */
|
/* VocalUI Sounds */
|
||||||
/******************/
|
/******************/
|
||||||
|
|
||||||
CLISetup::log(' - linking to race');
|
CLI::write(' - linking to race');
|
||||||
|
|
||||||
DB::Aowow()->query('TRUNCATE ?_races_sounds');
|
DB::Aowow()->query('TRUNCATE ?_races_sounds');
|
||||||
DB::Aowow()->query('INSERT IGNORE INTO ?_races_sounds SELECT raceId, soundIdMale, 1 FROM dbc_vocaluisounds WHERE soundIdMale <> soundIdFemale AND soundIdMale > 0');
|
DB::Aowow()->query('INSERT IGNORE INTO ?_races_sounds SELECT raceId, soundIdMale, 1 FROM dbc_vocaluisounds WHERE soundIdMale <> soundIdFemale AND soundIdMale > 0');
|
||||||
@@ -173,7 +173,7 @@ function sounds(/*array $ids = [] */)
|
|||||||
/* Emote Sound */
|
/* Emote Sound */
|
||||||
/***************/
|
/***************/
|
||||||
|
|
||||||
CLISetup::log(' - linking to emotes');
|
CLI::write(' - linking to emotes');
|
||||||
|
|
||||||
DB::Aowow()->query('TRUNCATE ?_emotes_sounds');
|
DB::Aowow()->query('TRUNCATE ?_emotes_sounds');
|
||||||
DB::Aowow()->query('INSERT IGNORE INTO ?_emotes_sounds SELECT emotesTextId, raceId, gender + 1, soundId FROM dbc_emotestextsound');
|
DB::Aowow()->query('INSERT IGNORE INTO ?_emotes_sounds SELECT emotesTextId, raceId, gender + 1, soundId FROM dbc_emotestextsound');
|
||||||
@@ -183,7 +183,7 @@ function sounds(/*array $ids = [] */)
|
|||||||
/* Creature Sounds */
|
/* Creature Sounds */
|
||||||
/*******************/
|
/*******************/
|
||||||
|
|
||||||
CLISetup::log(' - linking to creatures');
|
CLI::write(' - linking to creatures');
|
||||||
|
|
||||||
// currently ommitting:
|
// currently ommitting:
|
||||||
// * footsteps (matrix of: creature + terrain + humidity)
|
// * footsteps (matrix of: creature + terrain + humidity)
|
||||||
@@ -240,7 +240,7 @@ function sounds(/*array $ids = [] */)
|
|||||||
/* Spell Sounds */
|
/* Spell Sounds */
|
||||||
/****************/
|
/****************/
|
||||||
|
|
||||||
CLISetup::log(' - linking to spells');
|
CLI::write(' - linking to spells');
|
||||||
|
|
||||||
// issues: (probably because of 335-data)
|
// issues: (probably because of 335-data)
|
||||||
// * animate is probably wrong
|
// * animate is probably wrong
|
||||||
@@ -300,7 +300,7 @@ function sounds(/*array $ids = [] */)
|
|||||||
/* Zone Sounds */
|
/* Zone Sounds */
|
||||||
/***************/
|
/***************/
|
||||||
|
|
||||||
CLISetup::log(' - linking to zones');
|
CLI::write(' - linking to zones');
|
||||||
|
|
||||||
// omiting data from WMOAreaTable, as its at the moment impossible to link to actual zones
|
// omiting data from WMOAreaTable, as its at the moment impossible to link to actual zones
|
||||||
|
|
||||||
@@ -358,7 +358,7 @@ function sounds(/*array $ids = [] */)
|
|||||||
/* Item Sounds */
|
/* Item Sounds */
|
||||||
/***************/
|
/***************/
|
||||||
|
|
||||||
CLISetup::log(' - linking to items');
|
CLI::write(' - linking to items');
|
||||||
|
|
||||||
DB::Aowow()->query('
|
DB::Aowow()->query('
|
||||||
UPDATE
|
UPDATE
|
||||||
|
|||||||
@@ -112,11 +112,11 @@ function source(array $ids = [])
|
|||||||
/* Item & inherited Spells */
|
/* Item & inherited Spells */
|
||||||
/***************************/
|
/***************************/
|
||||||
|
|
||||||
CLISetup::log(' - Items & Spells [inherited]');
|
CLI::write(' - Items & Spells [inherited]');
|
||||||
# also everything from items that teach spells, is src of spell
|
# also everything from items that teach spells, is src of spell
|
||||||
# todo: check if items have learn-spells (effect: 36)
|
# todo: check if items have learn-spells (effect: 36)
|
||||||
|
|
||||||
CLISetup::log(' * resolve ref-loot tree');
|
CLI::write(' * resolve ref-loot tree');
|
||||||
$refLoot = DB::World()->select('
|
$refLoot = DB::World()->select('
|
||||||
SELECT
|
SELECT
|
||||||
rlt.Entry AS ARRAY_KEY,
|
rlt.Entry AS ARRAY_KEY,
|
||||||
@@ -163,7 +163,7 @@ function source(array $ids = [])
|
|||||||
###############
|
###############
|
||||||
# 1: Crafted #
|
# 1: Crafted #
|
||||||
###############
|
###############
|
||||||
CLISetup::log(' * #1 Crafted');
|
CLI::write(' * #1 Crafted');
|
||||||
|
|
||||||
$spellBuff = [];
|
$spellBuff = [];
|
||||||
$itemBuff = [];
|
$itemBuff = [];
|
||||||
@@ -204,7 +204,7 @@ function source(array $ids = [])
|
|||||||
############
|
############
|
||||||
# 2: Drop #
|
# 2: Drop #
|
||||||
############
|
############
|
||||||
CLISetup::log(' * #2 Drop');
|
CLI::write(' * #2 Drop');
|
||||||
|
|
||||||
$spellBuff = [];
|
$spellBuff = [];
|
||||||
$itemBuff = [];
|
$itemBuff = [];
|
||||||
@@ -346,7 +346,7 @@ function source(array $ids = [])
|
|||||||
###########
|
###########
|
||||||
# 3: PvP # (Vendors w/ xCost Arena/Honor)
|
# 3: PvP # (Vendors w/ xCost Arena/Honor)
|
||||||
###########
|
###########
|
||||||
CLISetup::log(' * #3 PvP');
|
CLI::write(' * #3 PvP');
|
||||||
|
|
||||||
// var g_sources_pvp = {
|
// var g_sources_pvp = {
|
||||||
// 1: 'Arena',
|
// 1: 'Arena',
|
||||||
@@ -391,7 +391,7 @@ function source(array $ids = [])
|
|||||||
#############
|
#############
|
||||||
# 4: Quest #
|
# 4: Quest #
|
||||||
#############
|
#############
|
||||||
CLISetup::log(' * #4 Quest');
|
CLI::write(' * #4 Quest');
|
||||||
|
|
||||||
$spellBuff = [];
|
$spellBuff = [];
|
||||||
$itemBuff = [];
|
$itemBuff = [];
|
||||||
@@ -473,7 +473,7 @@ function source(array $ids = [])
|
|||||||
##############
|
##############
|
||||||
# 5: Vendor # (w/o xCost Arena/Honor)
|
# 5: Vendor # (w/o xCost Arena/Honor)
|
||||||
##############
|
##############
|
||||||
CLISetup::log(' * #5 Vendor');
|
CLI::write(' * #5 Vendor');
|
||||||
|
|
||||||
$spellBuff = [];
|
$spellBuff = [];
|
||||||
$itemBuff = [];
|
$itemBuff = [];
|
||||||
@@ -507,7 +507,7 @@ function source(array $ids = [])
|
|||||||
###############
|
###############
|
||||||
# 10: Starter #
|
# 10: Starter #
|
||||||
###############
|
###############
|
||||||
CLISetup::log(' * #10 Starter');
|
CLI::write(' * #10 Starter');
|
||||||
|
|
||||||
if ($pcii = DB::World()->select('SELECT ?d, itemid, 1 FROM playercreateinfo_item', TYPE_ITEM))
|
if ($pcii = DB::World()->select('SELECT ?d, itemid, 1 FROM playercreateinfo_item', TYPE_ITEM))
|
||||||
DB::Aowow()->query(queryfy('[V]', $pcii, $insBasic), 10, 10, 10);
|
DB::Aowow()->query(queryfy('[V]', $pcii, $insBasic), 10, 10, 10);
|
||||||
@@ -519,7 +519,7 @@ function source(array $ids = [])
|
|||||||
###################
|
###################
|
||||||
# 12: Achievement #
|
# 12: Achievement #
|
||||||
###################
|
###################
|
||||||
CLISetup::log(' * #12 Achievement');
|
CLI::write(' * #12 Achievement');
|
||||||
|
|
||||||
$spellBuff = [];
|
$spellBuff = [];
|
||||||
$itemBuff = [];
|
$itemBuff = [];
|
||||||
@@ -581,7 +581,7 @@ function source(array $ids = [])
|
|||||||
####################
|
####################
|
||||||
# 15: Disenchanted #
|
# 15: Disenchanted #
|
||||||
####################
|
####################
|
||||||
CLISetup::log(' * #15 Disenchanted');
|
CLI::write(' * #15 Disenchanted');
|
||||||
|
|
||||||
$spellBuff = [];
|
$spellBuff = [];
|
||||||
$itemBuff = [];
|
$itemBuff = [];
|
||||||
@@ -634,7 +634,7 @@ function source(array $ids = [])
|
|||||||
##############
|
##############
|
||||||
# 16: Fished #
|
# 16: Fished #
|
||||||
##############
|
##############
|
||||||
CLISetup::log(' * #16 Fished');
|
CLI::write(' * #16 Fished');
|
||||||
|
|
||||||
$spellBuff = [];
|
$spellBuff = [];
|
||||||
$itemBuff = [];
|
$itemBuff = [];
|
||||||
@@ -685,7 +685,7 @@ function source(array $ids = [])
|
|||||||
################
|
################
|
||||||
# 17: Gathered #
|
# 17: Gathered #
|
||||||
################
|
################
|
||||||
CLISetup::log(' * #17 Gathered');
|
CLI::write(' * #17 Gathered');
|
||||||
|
|
||||||
$spellBuff = [];
|
$spellBuff = [];
|
||||||
$itemBuff = [];
|
$itemBuff = [];
|
||||||
@@ -740,7 +740,7 @@ function source(array $ids = [])
|
|||||||
##############
|
##############
|
||||||
# 18: Milled #
|
# 18: Milled #
|
||||||
##############
|
##############
|
||||||
CLISetup::log(' * #18 Milled');
|
CLI::write(' * #18 Milled');
|
||||||
|
|
||||||
$spellBuff = [];
|
$spellBuff = [];
|
||||||
$itemBuff = [];
|
$itemBuff = [];
|
||||||
@@ -791,7 +791,7 @@ function source(array $ids = [])
|
|||||||
#############
|
#############
|
||||||
# 19: Mined #
|
# 19: Mined #
|
||||||
#############
|
#############
|
||||||
CLISetup::log(' * #19 Mined');
|
CLI::write(' * #19 Mined');
|
||||||
|
|
||||||
$spellBuff = [];
|
$spellBuff = [];
|
||||||
$itemBuff = [];
|
$itemBuff = [];
|
||||||
@@ -846,7 +846,7 @@ function source(array $ids = [])
|
|||||||
##################
|
##################
|
||||||
# 20: Prospected #
|
# 20: Prospected #
|
||||||
##################
|
##################
|
||||||
CLISetup::log(' * #20 Prospected');
|
CLI::write(' * #20 Prospected');
|
||||||
|
|
||||||
$spellBuff = [];
|
$spellBuff = [];
|
||||||
$itemBuff = [];
|
$itemBuff = [];
|
||||||
@@ -897,7 +897,7 @@ function source(array $ids = [])
|
|||||||
##################
|
##################
|
||||||
# 21: Pickpocket #
|
# 21: Pickpocket #
|
||||||
##################
|
##################
|
||||||
CLISetup::log(' * #21 Pickpocket');
|
CLI::write(' * #21 Pickpocket');
|
||||||
|
|
||||||
$spellBuff = [];
|
$spellBuff = [];
|
||||||
$itemBuff = [];
|
$itemBuff = [];
|
||||||
@@ -947,7 +947,7 @@ function source(array $ids = [])
|
|||||||
################
|
################
|
||||||
# 22: Salvaged #
|
# 22: Salvaged #
|
||||||
################
|
################
|
||||||
CLISetup::log(' * #22 Salvaged');
|
CLI::write(' * #22 Salvaged');
|
||||||
|
|
||||||
$spellBuff = [];
|
$spellBuff = [];
|
||||||
$itemBuff = [];
|
$itemBuff = [];
|
||||||
@@ -998,7 +998,7 @@ function source(array $ids = [])
|
|||||||
###############
|
###############
|
||||||
# 23: Skinned #
|
# 23: Skinned #
|
||||||
###############
|
###############
|
||||||
CLISetup::log(' * #23 Skinned');
|
CLI::write(' * #23 Skinned');
|
||||||
|
|
||||||
$spellBuff = [];
|
$spellBuff = [];
|
||||||
$itemBuff = [];
|
$itemBuff = [];
|
||||||
@@ -1054,10 +1054,10 @@ function source(array $ids = [])
|
|||||||
/* Spell */
|
/* Spell */
|
||||||
/*********/
|
/*********/
|
||||||
|
|
||||||
CLISetup::log(' - Spells [original]');
|
CLI::write(' - Spells [original]');
|
||||||
|
|
||||||
# 4: Quest
|
# 4: Quest
|
||||||
CLISetup::log(' * #4 Quest');
|
CLI::write(' * #4 Quest');
|
||||||
$quests = DB::World()->select('
|
$quests = DB::World()->select('
|
||||||
SELECT spell AS ARRAY_KEY, id, SUM(qty) AS qty, BIT_OR(side) AS side FROM (
|
SELECT spell AS ARRAY_KEY, id, SUM(qty) AS qty, BIT_OR(side) AS side FROM (
|
||||||
SELECT IF(RewardSpell = 0, RewardDisplaySpell, RewardSpell) AS spell, ID, COUNT(1) AS qty, IF(AllowableRaces & 0x2B2 AND !(AllowableRaces & 0x44D), 2, IF(AllowableRaces & 0x44D AND !(AllowableRaces & 0x2B2), 1, 3)) AS side FROM quest_template WHERE IF(RewardSpell = 0, RewardDisplaySpell, RewardSpell) > 0 GROUP BY spell
|
SELECT IF(RewardSpell = 0, RewardDisplaySpell, RewardSpell) AS spell, ID, COUNT(1) AS qty, IF(AllowableRaces & 0x2B2 AND !(AllowableRaces & 0x44D), 2, IF(AllowableRaces & 0x44D AND !(AllowableRaces & 0x2B2), 1, 3)) AS side FROM quest_template WHERE IF(RewardSpell = 0, RewardDisplaySpell, RewardSpell) > 0 GROUP BY spell
|
||||||
@@ -1085,7 +1085,7 @@ function source(array $ids = [])
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 6: Trainer
|
# 6: Trainer
|
||||||
CLISetup::log(' * #6 Trainer');
|
CLI::write(' * #6 Trainer');
|
||||||
if ($tNpcs = DB::World()->select('SELECT SpellID AS ARRAY_KEY, ID AS entry, COUNT(1) AS qty FROM npc_trainer WHERE SpellID > 0 GROUP BY ARRAY_KEY'))
|
if ($tNpcs = DB::World()->select('SELECT SpellID AS ARRAY_KEY, ID AS entry, COUNT(1) AS qty FROM npc_trainer WHERE SpellID > 0 GROUP BY ARRAY_KEY'))
|
||||||
{
|
{
|
||||||
$tSpells = DB::Aowow()->select('SELECT id AS ARRAY_KEY, effect1Id, effect2Id, effect3Id, effect1TriggerSpell, effect2TriggerSpell, effect3TriggerSpell FROM dbc_spell WHERE id IN (?a)', array_keys($tNpcs));
|
$tSpells = DB::Aowow()->select('SELECT id AS ARRAY_KEY, effect1Id, effect2Id, effect3Id, effect1TriggerSpell, effect2TriggerSpell, effect3TriggerSpell FROM dbc_spell WHERE id IN (?a)', array_keys($tNpcs));
|
||||||
@@ -1118,13 +1118,13 @@ function source(array $ids = [])
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 7: Discovery
|
# 7: Discovery
|
||||||
CLISetup::log(' * #7 Discovery');
|
CLI::write(' * #7 Discovery');
|
||||||
// 61756: Northrend Inscription Research (FAST QA VERSION);
|
// 61756: Northrend Inscription Research (FAST QA VERSION);
|
||||||
if ($disco = DB::World()->select('SELECT ?d, spellId, 1 FROM skill_discovery_template WHERE reqSpell <> ?d', TYPE_SPELL, 61756))
|
if ($disco = DB::World()->select('SELECT ?d, spellId, 1 FROM skill_discovery_template WHERE reqSpell <> ?d', TYPE_SPELL, 61756))
|
||||||
DB::Aowow()->query(queryfy('[V]', $disco, $insBasic), 7, 7, 7);
|
DB::Aowow()->query(queryfy('[V]', $disco, $insBasic), 7, 7, 7);
|
||||||
|
|
||||||
# 9: Talent
|
# 9: Talent
|
||||||
CLISetup::log(' * #9 Talent');
|
CLI::write(' * #9 Talent');
|
||||||
$tSpells = DB::Aowow()->select('
|
$tSpells = DB::Aowow()->select('
|
||||||
SELECT s.id AS ARRAY_KEY, s.effect1Id, s.effect2Id, s.effect3Id, s.effect1TriggerSpell, s.effect2TriggerSpell, s.effect3TriggerSpell
|
SELECT s.id AS ARRAY_KEY, s.effect1Id, s.effect2Id, s.effect3Id, s.effect1TriggerSpell, s.effect2TriggerSpell, s.effect3TriggerSpell
|
||||||
FROM dbc_talent t
|
FROM dbc_talent t
|
||||||
@@ -1136,7 +1136,7 @@ function source(array $ids = [])
|
|||||||
$buff = [];
|
$buff = [];
|
||||||
while ($tSpells)
|
while ($tSpells)
|
||||||
{
|
{
|
||||||
CLISetup::log(' - '.++$n.'. pass');
|
CLI::write(' - '.++$n.'. pass');
|
||||||
|
|
||||||
$recurse = [];
|
$recurse = [];
|
||||||
foreach ($tSpells as $tId => $spell)
|
foreach ($tSpells as $tId => $spell)
|
||||||
@@ -1161,7 +1161,7 @@ function source(array $ids = [])
|
|||||||
DB::Aowow()->query(queryfy('[V]', $buff, $insBasic), 9, 9, 9);
|
DB::Aowow()->query(queryfy('[V]', $buff, $insBasic), 9, 9, 9);
|
||||||
|
|
||||||
# 10: Starter
|
# 10: Starter
|
||||||
CLISetup::log(' * #10 Starter');
|
CLI::write(' * #10 Starter');
|
||||||
/* acquireMethod
|
/* acquireMethod
|
||||||
ABILITY_LEARNED_ON_GET_PROFESSION_SKILL = 1, learnedAt = 1 && source10 = 1
|
ABILITY_LEARNED_ON_GET_PROFESSION_SKILL = 1, learnedAt = 1 && source10 = 1
|
||||||
ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL = 2
|
ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL = 2
|
||||||
@@ -1176,15 +1176,15 @@ function source(array $ids = [])
|
|||||||
/* Titles */
|
/* Titles */
|
||||||
/**********/
|
/**********/
|
||||||
|
|
||||||
CLISetup::log(' - Titles');
|
CLI::write(' - Titles');
|
||||||
|
|
||||||
# 4: Quest
|
# 4: Quest
|
||||||
CLISetup::log(' * #4 Quest');
|
CLI::write(' * #4 Quest');
|
||||||
if ($quests = DB::World()->select('SELECT ?d, RewardTitle, 1, ?d, ID FROM quest_template WHERE RewardTitle > 0', TYPE_TITLE, TYPE_QUEST))
|
if ($quests = DB::World()->select('SELECT ?d, RewardTitle, 1, ?d, ID FROM quest_template WHERE RewardTitle > 0', TYPE_TITLE, TYPE_QUEST))
|
||||||
DB::Aowow()->query(queryfy('[V]', $quests, $insMore), 4, 4, 4);
|
DB::Aowow()->query(queryfy('[V]', $quests, $insMore), 4, 4, 4);
|
||||||
|
|
||||||
# 12: Achievement
|
# 12: Achievement
|
||||||
CLISetup::log(' * #12 Achievement');
|
CLI::write(' * #12 Achievement');
|
||||||
$sets = DB::World()->select('
|
$sets = DB::World()->select('
|
||||||
SELECT titleId AS ARRAY_KEY, MIN(ID) AS srcId, NULLIF(MAX(ID), MIN(ID)) AS altSrcId FROM (
|
SELECT titleId AS ARRAY_KEY, MIN(ID) AS srcId, NULLIF(MAX(ID), MIN(ID)) AS altSrcId FROM (
|
||||||
SELECT TitleA AS `titleId`, ID FROM achievement_reward WHERE TitleA <> 0
|
SELECT TitleA AS `titleId`, ID FROM achievement_reward WHERE TitleA <> 0
|
||||||
@@ -1201,7 +1201,7 @@ function source(array $ids = [])
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 13: Source-String
|
# 13: Source-String
|
||||||
CLISetup::log(' * #13 cuStrings');
|
CLI::write(' * #13 cuStrings');
|
||||||
$src13 = [null, 42, 52, 71, 80, 157, 163, 167, 169, 177];
|
$src13 = [null, 42, 52, 71, 80, 157, 163, 167, 169, 177];
|
||||||
foreach ($src13 as $src => $tId)
|
foreach ($src13 as $src => $tId)
|
||||||
if ($tId)
|
if ($tId)
|
||||||
|
|||||||
@@ -92,31 +92,31 @@ function spawns() // and waypoints
|
|||||||
|
|
||||||
$query[1] = ['SELECT c.guid, 1 AS "type", c.id AS typeId, c.spawntimesecs AS respawn, c.phaseMask, c.zoneId AS areaId, c.map, IFNULL(ca.path_id, 0) AS pathId, c.position_y AS `posX`, c.position_x AS `posY` ' .
|
$query[1] = ['SELECT c.guid, 1 AS "type", c.id AS typeId, c.spawntimesecs AS respawn, c.phaseMask, c.zoneId AS areaId, c.map, IFNULL(ca.path_id, 0) AS pathId, c.position_y AS `posX`, c.position_x AS `posY` ' .
|
||||||
'FROM creature c LEFT JOIN creature_addon ca ON ca.guid = c.guid',
|
'FROM creature c LEFT JOIN creature_addon ca ON ca.guid = c.guid',
|
||||||
' - assembling '.CLISetup::bold('creature').' spawns'];
|
' - assembling '.CLI::bold('creature').' spawns'];
|
||||||
|
|
||||||
$query[2] = ['SELECT c.guid, 2 AS "type", c.id AS typeId, ABS(c.spawntimesecs) AS respawn, c.phaseMask, c.zoneId AS areaId, c.map, 0 as pathId, c.position_y AS `posX`, c.position_x AS `posY` ' .
|
$query[2] = ['SELECT c.guid, 2 AS "type", c.id AS typeId, ABS(c.spawntimesecs) AS respawn, c.phaseMask, c.zoneId AS areaId, c.map, 0 as pathId, c.position_y AS `posX`, c.position_x AS `posY` ' .
|
||||||
'FROM gameobject c',
|
'FROM gameobject c',
|
||||||
' - assembling '.CLISetup::bold('gameobject').' spawns'];
|
' - assembling '.CLI::bold('gameobject').' spawns'];
|
||||||
|
|
||||||
$query[3] = ['SELECT id AS "guid", 19 AS "type", soundId AS typeId, 0 AS respawn, 0 AS phaseMask, 0 AS areaId, mapId AS "map", 0 AS pathId, posX, posY ' .
|
$query[3] = ['SELECT id AS "guid", 19 AS "type", soundId AS typeId, 0 AS respawn, 0 AS phaseMask, 0 AS areaId, mapId AS "map", 0 AS pathId, posX, posY ' .
|
||||||
'FROM dbc_soundemitters',
|
'FROM dbc_soundemitters',
|
||||||
' - assembling '.CLISetup::bold('sound emitter').' spawns'];
|
' - assembling '.CLI::bold('sound emitter').' spawns'];
|
||||||
|
|
||||||
$query[4] = ['SELECT id AS "guid", 503 AS "type", id AS typeId, 0 AS respawn, 0 AS phaseMask, 0 AS areaId, mapId AS "map", 0 AS pathId, posX, posY ' .
|
$query[4] = ['SELECT id AS "guid", 503 AS "type", id AS typeId, 0 AS respawn, 0 AS phaseMask, 0 AS areaId, mapId AS "map", 0 AS pathId, posX, posY ' .
|
||||||
'FROM dbc_areatrigger',
|
'FROM dbc_areatrigger',
|
||||||
' - assembling '.CLISetup::bold('areatrigger').' spawns'];
|
' - assembling '.CLI::bold('areatrigger').' spawns'];
|
||||||
|
|
||||||
$query[5] = ['SELECT c.guid, w.entry AS "npcOrPath", w.pointId AS "point", c.zoneId AS areaId, c.map, w.waittime AS "wait", w.location_y AS `posX`, w.location_x AS `posY` ' .
|
$query[5] = ['SELECT c.guid, w.entry AS "npcOrPath", w.pointId AS "point", c.zoneId AS areaId, c.map, w.waittime AS "wait", w.location_y AS `posX`, w.location_x AS `posY` ' .
|
||||||
'FROM creature c JOIN script_waypoint w ON c.id = w.entry',
|
'FROM creature c JOIN script_waypoint w ON c.id = w.entry',
|
||||||
' - assembling waypoints from '.CLISetup::bold('script_waypoint')];
|
' - assembling waypoints from '.CLI::bold('script_waypoint')];
|
||||||
|
|
||||||
$query[6] = ['SELECT c.guid, w.entry AS "npcOrPath", w.pointId AS "point", c.zoneId AS areaId, c.map, 0 AS "wait", w.position_y AS `posX`, w.position_x AS `posY` ' .
|
$query[6] = ['SELECT c.guid, w.entry AS "npcOrPath", w.pointId AS "point", c.zoneId AS areaId, c.map, 0 AS "wait", w.position_y AS `posX`, w.position_x AS `posY` ' .
|
||||||
'FROM creature c JOIN waypoints w ON c.id = w.entry',
|
'FROM creature c JOIN waypoints w ON c.id = w.entry',
|
||||||
' - assembling waypoints from '.CLISetup::bold('waypoints')];
|
' - assembling waypoints from '.CLI::bold('waypoints')];
|
||||||
|
|
||||||
$query[7] = ['SELECT c.guid, -w.id AS "npcOrPath", w.point, c.zoneId AS areaId, c.map, w.delay AS "wait", w.position_y AS `posX`, w.position_x AS `posY` ' .
|
$query[7] = ['SELECT c.guid, -w.id AS "npcOrPath", w.point, c.zoneId AS areaId, c.map, w.delay AS "wait", w.position_y AS `posX`, w.position_x AS `posY` ' .
|
||||||
'FROM creature c JOIN creature_addon ca ON ca.guid = c.guid JOIN waypoint_data w ON w.id = ca.path_id WHERE ca.path_id <> 0',
|
'FROM creature c JOIN creature_addon ca ON ca.guid = c.guid JOIN waypoint_data w ON w.id = ca.path_id WHERE ca.path_id <> 0',
|
||||||
' - assembling waypoints from '.CLISetup::bold('waypoint_data')];
|
' - assembling waypoints from '.CLI::bold('waypoint_data')];
|
||||||
|
|
||||||
$queryPost = 'SELECT dm.id, wma.areaId, IFNULL(dm.floor, 0) AS floor, ' .
|
$queryPost = 'SELECT dm.id, wma.areaId, IFNULL(dm.floor, 0) AS floor, ' .
|
||||||
'100 - ROUND(IF(dm.id IS NOT NULL, (?f - dm.minY) * 100 / (dm.maxY - dm.minY), (?f - wma.right) * 100 / (wma.left - wma.right)), 1) AS `posX`, ' .
|
'100 - ROUND(IF(dm.id IS NOT NULL, (?f - dm.minY) * 100 / (dm.maxY - dm.minY), (?f - wma.right) * 100 / (wma.left - wma.right)), 1) AS `posX`, ' .
|
||||||
@@ -153,7 +153,7 @@ function spawns() // and waypoints
|
|||||||
|
|
||||||
foreach ($query as $idx => $q)
|
foreach ($query as $idx => $q)
|
||||||
{
|
{
|
||||||
CLISetup::log($q[1]);
|
CLI::write($q[1]);
|
||||||
|
|
||||||
$n = 0;
|
$n = 0;
|
||||||
$sum = 0;
|
$sum = 0;
|
||||||
@@ -166,7 +166,7 @@ function spawns() // and waypoints
|
|||||||
foreach ($queryResult as $spawn)
|
foreach ($queryResult as $spawn)
|
||||||
{
|
{
|
||||||
if (!$n)
|
if (!$n)
|
||||||
CLISetup::log(' * sets '.($sum + 1).' - '.($sum += SqlGen::$stepSize));
|
CLI::write(' * sets '.($sum + 1).' - '.($sum += SqlGen::$stepSize));
|
||||||
|
|
||||||
if ($n++ > SqlGen::$stepSize)
|
if ($n++ > SqlGen::$stepSize)
|
||||||
$n = 0;
|
$n = 0;
|
||||||
@@ -187,7 +187,7 @@ function spawns() // and waypoints
|
|||||||
|
|
||||||
if (!$points) // still impossible (there are areas that are intentionally off the map (e.g. the isles south of tanaris))
|
if (!$points) // still impossible (there are areas that are intentionally off the map (e.g. the isles south of tanaris))
|
||||||
{
|
{
|
||||||
CLISetup::log('GUID '.$spawn['guid'].($idx < 5 ? '' : ' on path/point '.$spawn['npcOrPath'].'/'.$spawn['point']).' could not be matched to displayable area [A:'.$spawn['areaId'].'; X:'.$spawn['posY'].'; Y:'.$spawn['posX'].']', CLISetup::LOG_WARN);
|
CLI::write('GUID '.$spawn['guid'].($idx < 5 ? '' : ' on path/point '.$spawn['npcOrPath'].'/'.$spawn['point']).' could not be matched to displayable area [A:'.$spawn['areaId'].'; X:'.$spawn['posY'].'; Y:'.$spawn['posX'].']', CLI::LOG_WARN);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,10 +267,10 @@ function spawns() // and waypoints
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($matches)
|
if ($matches)
|
||||||
CLISetup::log(' * assigned '.$matches.' accessories on '.++$n.'. pass on vehicle accessories');
|
CLI::write(' * assigned '.$matches.' accessories on '.++$n.'. pass on vehicle accessories');
|
||||||
}
|
}
|
||||||
if ($accessories)
|
if ($accessories)
|
||||||
CLISetup::log(count($accessories).' accessories could not be fitted onto a spawned vehicle.', CLISetup::LOG_WARN);
|
CLI::write(count($accessories).' accessories could not be fitted onto a spawned vehicle.', CLI::LOG_WARN);
|
||||||
|
|
||||||
|
|
||||||
/********************************/
|
/********************************/
|
||||||
|
|||||||
@@ -222,12 +222,12 @@ function spell()
|
|||||||
|
|
||||||
// merge serverside spells into dbc_spell (should not affect other scripts)
|
// merge serverside spells into dbc_spell (should not affect other scripts)
|
||||||
$lastMax = 0;
|
$lastMax = 0;
|
||||||
CLISetup::log(' - merging serverside spells into spell.dbc');
|
CLI::write(' - merging serverside spells into spell.dbc');
|
||||||
while ($spells = DB::World()->select($ssQuery, $lastMax, SqlGen::$stepSize))
|
while ($spells = DB::World()->select($ssQuery, $lastMax, SqlGen::$stepSize))
|
||||||
{
|
{
|
||||||
$newMax = max(array_column($spells, 'id'));
|
$newMax = max(array_column($spells, 'id'));
|
||||||
|
|
||||||
CLISetup::log(' * sets '.($lastMax + 1).' - '.$newMax);
|
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||||
|
|
||||||
$lastMax = $newMax;
|
$lastMax = $newMax;
|
||||||
|
|
||||||
@@ -240,12 +240,12 @@ function spell()
|
|||||||
|
|
||||||
// merge everything into aowow_spell
|
// merge everything into aowow_spell
|
||||||
$lastMax = 0;
|
$lastMax = 0;
|
||||||
CLISetup::log(' - filling aowow_spell');
|
CLI::write(' - filling aowow_spell');
|
||||||
while ($spells = DB::Aowow()->select($baseQuery, $lastMax, SqlGen::$stepSize))
|
while ($spells = DB::Aowow()->select($baseQuery, $lastMax, SqlGen::$stepSize))
|
||||||
{
|
{
|
||||||
$newMax = max(array_column($spells, 'id'));
|
$newMax = max(array_column($spells, 'id'));
|
||||||
|
|
||||||
CLISetup::log(' * sets '.($lastMax + 1).' - '.$newMax);
|
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||||
|
|
||||||
$lastMax = $newMax;
|
$lastMax = $newMax;
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ function spell()
|
|||||||
ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL = 2 not used for now
|
ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL = 2 not used for now
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CLISetup::log(' - linking with skillineability');
|
CLI::write(' - linking with skillineability');
|
||||||
|
|
||||||
$results = DB::Aowow()->select('SELECT spellId AS ARRAY_KEY, id AS ARRAY_KEY2, skillLineId, reqRaceMask, reqClassMask, reqSkillLevel, acquireMethod, skillLevelGrey, skillLevelYellow FROM dbc_skilllineability sla');
|
$results = DB::Aowow()->select('SELECT spellId AS ARRAY_KEY, id AS ARRAY_KEY2, skillLineId, reqRaceMask, reqClassMask, reqSkillLevel, acquireMethod, skillLevelGrey, skillLevelYellow FROM dbc_skilllineability sla');
|
||||||
foreach ($results as $spellId => $sets)
|
foreach ($results as $spellId => $sets)
|
||||||
@@ -445,7 +445,7 @@ function spell()
|
|||||||
/* talent related */
|
/* talent related */
|
||||||
/******************/
|
/******************/
|
||||||
|
|
||||||
CLISetup::log(' - linking with talent');
|
CLI::write(' - linking with talent');
|
||||||
|
|
||||||
for ($i = 1; $i < 6; $i++)
|
for ($i = 1; $i < 6; $i++)
|
||||||
{
|
{
|
||||||
@@ -467,7 +467,7 @@ function spell()
|
|||||||
/* Other */
|
/* Other */
|
||||||
/*********/
|
/*********/
|
||||||
|
|
||||||
CLISetup::log(' - misc fixups & icons');
|
CLI::write(' - misc fixups & icons');
|
||||||
|
|
||||||
// FU [FixUps]
|
// FU [FixUps]
|
||||||
DB::Aowow()->query('UPDATE ?_spell SET reqRaceMask = ?d WHERE skillLine1 = ?d', 1 << 10, 760); // Draenai Racials
|
DB::Aowow()->query('UPDATE ?_spell SET reqRaceMask = ?d WHERE skillLine1 = ?d', 1 << 10, 760); // Draenai Racials
|
||||||
@@ -529,7 +529,7 @@ function spell()
|
|||||||
/* Categories */
|
/* Categories */
|
||||||
/**************/
|
/**************/
|
||||||
|
|
||||||
CLISetup::log(' - applying categories');
|
CLI::write(' - applying categories');
|
||||||
|
|
||||||
// player talents (-2)
|
// player talents (-2)
|
||||||
DB::Aowow()->query('UPDATE ?_spell s, dbc_talent t SET s.typeCat = -2 WHERE t.tabId NOT IN (409, 410, 411) AND (s.id = t.rank1 OR s.id = t.rank2 OR s.id = t.rank3 OR s.id = t.rank4 OR s.id = t.rank5)');
|
DB::Aowow()->query('UPDATE ?_spell s, dbc_talent t SET s.typeCat = -2 WHERE t.tabId NOT IN (409, 410, 411) AND (s.id = t.rank1 OR s.id = t.rank2 OR s.id = t.rank3 OR s.id = t.rank4 OR s.id = t.rank5)');
|
||||||
@@ -645,7 +645,7 @@ function spell()
|
|||||||
/* Glyphs */
|
/* Glyphs */
|
||||||
/**********/
|
/**********/
|
||||||
|
|
||||||
CLISetup::log(' - fixing glyph data');
|
CLI::write(' - fixing glyph data');
|
||||||
|
|
||||||
// glyphSpell => affectedSpell
|
// glyphSpell => affectedSpell
|
||||||
$glyphAffects = array(
|
$glyphAffects = array(
|
||||||
@@ -754,7 +754,7 @@ function spell()
|
|||||||
if ($icons)
|
if ($icons)
|
||||||
DB::Aowow()->query('UPDATE ?_spell s SET s.skillLine1 = ?d, s.iconIdAlt = ?d WHERE s.id = ?d', $icons['skill'], $icons['icon'], $applyId);
|
DB::Aowow()->query('UPDATE ?_spell s SET s.skillLine1 = ?d, s.iconIdAlt = ?d WHERE s.id = ?d', $icons['skill'], $icons['icon'], $applyId);
|
||||||
else
|
else
|
||||||
CLISetup::log('could not match '.$glyphEffect['name_loc0'].' ('.$glyphEffect['id'].') with affected spells', CLISetup::LOG_WARN);
|
CLI::write('could not match '.$glyphEffect['name_loc0'].' ('.$glyphEffect['id'].') with affected spells', CLI::LOG_WARN);
|
||||||
}
|
}
|
||||||
|
|
||||||
// hide unused glyphs
|
// hide unused glyphs
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ function taxi() // path & nodes
|
|||||||
{
|
{
|
||||||
if (empty($n['faction']))
|
if (empty($n['faction']))
|
||||||
{
|
{
|
||||||
CLISetup::log(' - ['.$n['id'].'] "'.$n['name_loc0'].'" has no NPC assigned ... skipping', CLISetup::LOG_WARN);
|
CLI::write(' - ['.$n['id'].'] "'.$n['name_loc0'].'" has no NPC assigned ... skipping', CLI::LOG_WARN);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user