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
|
||||
$AoWoWconf = [];
|
||||
|
||||
|
||||
mb_internal_encoding('UTF-8');
|
||||
|
||||
|
||||
define('OS_WIN', substr(PHP_OS, 0, 3) == 'WIN');
|
||||
|
||||
|
||||
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/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
|
||||
{
|
||||
const FILE_ACCESS = 0777;
|
||||
|
||||
@@ -23,7 +23,7 @@ require_once 'setup/tools/imagecreatefromblp.func.php';
|
||||
function finish()
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -9,24 +9,6 @@ if (!CLI)
|
||||
|
||||
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 $localeIds = [];
|
||||
|
||||
@@ -45,18 +27,15 @@ class CLISetup
|
||||
|
||||
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']))
|
||||
{
|
||||
// optional logging
|
||||
if (!empty($_['log']))
|
||||
self::$logFile = trim($_['log']);
|
||||
CLI::initLogFile(trim($_['log']));
|
||||
|
||||
// alternative data source (no quotes, use forward slash)
|
||||
if (!empty($_['mpqDataDir']))
|
||||
self::$srcDir = self::nicePath($_['mpqDataDir']);
|
||||
self::$srcDir = CLI::nicePath($_['mpqDataDir']);
|
||||
|
||||
// optional limit handled locales
|
||||
if (!empty($_['locales']))
|
||||
@@ -82,6 +61,7 @@ class CLISetup
|
||||
self::$localeIds[] = $idx;
|
||||
}
|
||||
|
||||
|
||||
/*******************/
|
||||
/* MPQ-file access */
|
||||
/*******************/
|
||||
@@ -94,8 +74,8 @@ class CLISetup
|
||||
*/
|
||||
private static function buildFileList()
|
||||
{
|
||||
self::log();
|
||||
self::log('reading MPQdata from '.self::$srcDir.' to list for first time use...');
|
||||
CLI::write();
|
||||
CLI::write('reading MPQdata from '.self::$srcDir.' to list for first time use...');
|
||||
|
||||
$setupDirs = glob('setup/*');
|
||||
foreach ($setupDirs as $sd)
|
||||
@@ -124,12 +104,12 @@ class CLISetup
|
||||
self::$mpqFiles[strtolower($_)] = $_;
|
||||
}
|
||||
|
||||
self::log('done');
|
||||
self::log();
|
||||
CLI::write('done');
|
||||
CLI::write();
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -182,87 +162,6 @@ class CLISetup
|
||||
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 */
|
||||
@@ -270,42 +169,23 @@ class CLISetup
|
||||
|
||||
public static function writeFile($file, $content)
|
||||
{
|
||||
$success = false;
|
||||
if ($handle = @fOpen($file, "w"))
|
||||
if (Util::writeFile($file, $content))
|
||||
{
|
||||
if (fWrite($handle, $content))
|
||||
{
|
||||
$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);
|
||||
CLI::write(sprintf(ERR_NONE, CLI::bold($file)), CLI::LOG_OK);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
self::log(sprintf(ERR_CREATE_FILE, self::bold($file)), self::LOG_ERROR);
|
||||
|
||||
if ($success)
|
||||
@chmod($file, Util::FILE_ACCESS);
|
||||
|
||||
return $success;
|
||||
$e = error_get_last();
|
||||
CLI::write($e['message'].' '.CLI::bold($file), CLI::LOG_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function writeDir($dir)
|
||||
{
|
||||
if (is_dir($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))
|
||||
if (Util::writeDir($dir))
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -317,158 +197,18 @@ class CLISetup
|
||||
$dbc = new DBC($name, ['temporary' => self::$tmpDBC]);
|
||||
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;
|
||||
}
|
||||
|
||||
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 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);
|
||||
Lang::load(Util::$localeStrings[LOCALE_EN]);
|
||||
|
||||
if (CLISetup::readInput($fields))
|
||||
if (CLI::readInput($fields))
|
||||
{
|
||||
CLISetup::log();
|
||||
CLI::write();
|
||||
|
||||
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))
|
||||
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'])
|
||||
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))
|
||||
CLISetup::log(Lang::account('nameInUse'), CLISetup::LOG_ERROR);
|
||||
CLI::write(Lang::account('nameInUse'), CLI::LOG_ERROR);
|
||||
else
|
||||
{
|
||||
// write to db
|
||||
@@ -49,16 +49,16 @@ function account()
|
||||
$newId = DB::Aowow()->selectCell('SELECT id FROM ?_account WHERE user = ?', $fields['name']);
|
||||
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
|
||||
CLISetup::log(Lang::main('intError'), CLISetup::LOG_ERROR);
|
||||
CLI::write(Lang::main('intError'), CLI::LOG_ERROR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CLISetup::log();
|
||||
CLISetup::log("account creation aborted", CLISetup::LOG_INFO);
|
||||
CLI::write();
|
||||
CLI::write("account creation aborted", CLI::LOG_INFO);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ function build($syncMe = null)
|
||||
$allOk = true;
|
||||
|
||||
// start file generation
|
||||
CLISetup::log('begin generation of '. implode(', ', FileGen::$subScripts));
|
||||
CLISetup::log();
|
||||
CLI::write('begin generation of '. implode(', ', FileGen::$subScripts));
|
||||
CLI::write();
|
||||
|
||||
// files with template
|
||||
foreach (FileGen::$tplFiles as $name => list($file, $destPath, $deps))
|
||||
@@ -36,7 +36,7 @@ function build($syncMe = null)
|
||||
|
||||
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;
|
||||
continue;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ function build($syncMe = null)
|
||||
else
|
||||
$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
|
||||
}
|
||||
|
||||
@@ -70,19 +70,19 @@ function build($syncMe = null)
|
||||
else
|
||||
$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
|
||||
}
|
||||
|
||||
// end
|
||||
CLISetup::log();
|
||||
CLI::write();
|
||||
if ($allOk)
|
||||
CLISetup::log('successfully finished file generation', CLISetup::LOG_OK);
|
||||
CLI::write('successfully finished file generation', CLI::LOG_OK);
|
||||
else
|
||||
CLISetup::log('finished file generation with errors', CLISetup::LOG_ERROR);
|
||||
CLI::write('finished file generation with errors', CLI::LOG_ERROR);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ function dbconfig()
|
||||
);
|
||||
$testDB = function($idx, $name, $dbInfo)
|
||||
{
|
||||
$buff = '['.CLISetup::bold($idx).'] '.str_pad($name, 17);
|
||||
$buff = '['.CLI::bold($idx).'] '.str_pad($name, 17);
|
||||
$errStr = '';
|
||||
$defPort = ini_get('mysqli.default_port');
|
||||
$port = 0;
|
||||
@@ -40,12 +40,12 @@ function dbconfig()
|
||||
else
|
||||
$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 .= ($dbInfo['prefix'] ? ' table prefix: '.$dbInfo['prefix'] : null).' '.$errStr;
|
||||
}
|
||||
else
|
||||
$buff .= ' '.CLISetup::bold('<empty>');
|
||||
$buff .= ' '.CLI::bold('<empty>');
|
||||
|
||||
return $buff;
|
||||
};
|
||||
@@ -61,25 +61,25 @@ function dbconfig()
|
||||
|
||||
while (true)
|
||||
{
|
||||
CLISetup::log();
|
||||
CLISetup::log("select a numerical index to use the corresponding entry");
|
||||
CLI::write();
|
||||
CLI::write("select a numerical index to use the corresponding entry");
|
||||
|
||||
$nCharDBs = 0;
|
||||
foreach ($databases as $idx => $name)
|
||||
{
|
||||
if ($idx != 3)
|
||||
CLISetup::log($testDB($idx, $name, $AoWoWconf[$name]));
|
||||
CLI::write($testDB($idx, $name, $AoWoWconf[$name]));
|
||||
else if (!empty($AoWoWconf[$name]))
|
||||
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)
|
||||
{
|
||||
$inp = ['idx' => ['', true, '/\d/']];
|
||||
if (CLISetup::readInput($inp, true) && $inp)
|
||||
if (CLI::readInput($inp, true) && $inp)
|
||||
{
|
||||
if ($inp['idx'] >= 0 && $inp['idx'] <= (3 + $nCharDBs))
|
||||
{
|
||||
@@ -88,7 +88,7 @@ function dbconfig()
|
||||
if ($inp['idx'] == 3 + $nCharDBs) // add new realmDB
|
||||
$curFields['realmId'] = ['Realm Id', false, '/[1-9][0-9]*/'];
|
||||
|
||||
if (CLISetup::readInput($curFields))
|
||||
if (CLI::readInput($curFields))
|
||||
{
|
||||
if ($inp['idx'] == 0 && $curFields)
|
||||
$curFields['prefix'] = 'aowow_';
|
||||
@@ -133,14 +133,14 @@ function dbconfig()
|
||||
$buff .= '$AoWoWconf[\''.$db.'\'][\''.$idx.'\'] = '.var_export($AoWoWconf[$db][$idx], true).";\n\n";
|
||||
}
|
||||
$buff .= "?>\n";
|
||||
CLISetup::log();
|
||||
CLI::write();
|
||||
CLISetup::writeFile('config/config.php', $buff);
|
||||
continue 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
CLISetup::log();
|
||||
CLISetup::log("edit canceled! returning to list...", CLISetup::LOG_INFO);
|
||||
CLI::write();
|
||||
CLI::write("edit canceled! returning to list...", CLI::LOG_INFO);
|
||||
sleep(1);
|
||||
continue 2;
|
||||
}
|
||||
@@ -148,8 +148,8 @@ function dbconfig()
|
||||
}
|
||||
else
|
||||
{
|
||||
CLISetup::log();
|
||||
CLISetup::log("leaving db setup...", CLISetup::LOG_INFO);
|
||||
CLI::write();
|
||||
CLI::write("leaving db setup...", CLI::LOG_INFO);
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ function firstrun()
|
||||
$steps = array(
|
||||
// clisetup/, params, test script result, introText, errorText
|
||||
['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
|
||||
['SqlGen::generate', 'achievementcategory', null, null, null],
|
||||
['SqlGen::generate', 'achievementcriteria', null, null, null],
|
||||
@@ -183,9 +183,9 @@ function firstrun()
|
||||
{
|
||||
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);
|
||||
$inp = ['x' => ['should '.CLISetup::bold($conf).' be set to '.CLISetup::bold($host).' and force_ssl be updated?', true, '/y|n/i']];
|
||||
if (!CLISetup::readInput($inp, true) || !$inp || strtolower($inp['x']) == 'n')
|
||||
CLI::write('self test received status '.CLI::bold($resp).' (page moved) for '.$conf.', pointing to: '.$protocol.$host.$testFile, CLI::LOG_WARN);
|
||||
$inp = ['x' => ['should '.CLI::bold($conf).' be set to '.CLI::bold($host).' and force_ssl be updated?', true, '/y|n/i']];
|
||||
if (!CLI::readInput($inp, true) || !$inp || strtolower($inp['x']) == 'n')
|
||||
$error[] = ' * could not access '.$protocol.$host.$testFile.' ['.$resp.']';
|
||||
else
|
||||
{
|
||||
@@ -193,7 +193,7 @@ function firstrun()
|
||||
DB::Aowow()->query('UPDATE ?_config SET `value` = ?d WHERE `key` = "force_ssl"', intVal($protocol == 'https://'));
|
||||
}
|
||||
|
||||
CLISetup::log();
|
||||
CLI::write();
|
||||
}
|
||||
else
|
||||
$error[] = ' * could not access '.$protocol.$host.$testFile.' ['.$resp.']';
|
||||
@@ -232,10 +232,10 @@ function firstrun()
|
||||
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']];
|
||||
$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...';
|
||||
$startStep = 0;
|
||||
@@ -243,8 +243,8 @@ function firstrun()
|
||||
else
|
||||
$msg = 'Resuming setup from step '.$startStep.'...';
|
||||
|
||||
CLISetup::log();
|
||||
CLISetup::log($msg);
|
||||
CLI::write();
|
||||
CLI::write($msg);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
@@ -262,10 +262,10 @@ function firstrun()
|
||||
|
||||
if ($step[3])
|
||||
{
|
||||
CLISetup::log($step[3]);
|
||||
CLI::write($step[3]);
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -278,9 +278,9 @@ function firstrun()
|
||||
{
|
||||
if (!$step[2]($errors))
|
||||
{
|
||||
CLISetup::log($step[4], CLISetup::LOG_ERROR);
|
||||
CLI::write($step[4], CLI::LOG_ERROR);
|
||||
foreach ($errors as $e)
|
||||
CLISetup::log($e);
|
||||
CLI::write($e);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -294,10 +294,10 @@ function firstrun()
|
||||
break;
|
||||
}
|
||||
|
||||
$inp = ['x' => ['['.CLISetup::bold('c').']ontinue anyway? ['.CLISetup::bold('r').']etry? ['.CLISetup::bold('a').']bort?', true, '/c|r|a/i']];
|
||||
if (CLISetup::readInput($inp, true) && $inp)
|
||||
$inp = ['x' => ['['.CLI::bold('c').']ontinue anyway? ['.CLI::bold('r').']etry? ['.CLI::bold('a').']bort?', true, '/c|r|a/i']];
|
||||
if (CLI::readInput($inp, true) && $inp)
|
||||
{
|
||||
CLISetup::log();
|
||||
CLI::write();
|
||||
switch(strtolower($inp['x']))
|
||||
{
|
||||
case 'c':
|
||||
@@ -311,14 +311,14 @@ function firstrun()
|
||||
}
|
||||
else
|
||||
{
|
||||
CLISetup::log();
|
||||
CLI::write();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
CLISetup::log();
|
||||
CLISetup::log("database not yet set up!\n Please use --dbconfig for setup", CLISetup::LOG_WARN);
|
||||
CLI::write();
|
||||
CLI::write("database not yet set up!\n Please use --dbconfig for setup", CLI::LOG_WARN);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ function siteconfig()
|
||||
break;
|
||||
case 'locales':
|
||||
array_push($updScripts, 'locales');
|
||||
CLISetup::log(' * remember to rebuild all static files for the language you just added.', CLISetup::LOG_INFO);
|
||||
CLISetup::log(' * you can speed this up by supplying the regionCode to the setup: '.CLISetup::bold('--locales=<regionCodes,> -f'));
|
||||
CLI::write(' * remember to rebuild all static files for the language you just added.', CLI::LOG_INFO);
|
||||
CLI::write(' * you can speed this up by supplying the regionCode to the setup: '.CLI::bold('--locales=<regionCodes,> -f'));
|
||||
break;
|
||||
case 'profiler_queue':
|
||||
$fn = function($x) {
|
||||
@@ -53,7 +53,7 @@ function siteconfig()
|
||||
|
||||
$ok = Profiler::queueStart($msg);
|
||||
if ($msg)
|
||||
CLISetup::log($msg, CLISetup::LOG_ERROR);
|
||||
CLI::write($msg, CLI::LOG_ERROR);
|
||||
|
||||
return $ok;
|
||||
};
|
||||
@@ -67,8 +67,8 @@ function siteconfig()
|
||||
|
||||
while (true)
|
||||
{
|
||||
CLISetup::log();
|
||||
CLISetup::log('select a numerical index to use the corresponding entry');
|
||||
CLI::write();
|
||||
CLI::write('select a numerical index to use the corresponding entry');
|
||||
|
||||
$sumNum = 0;
|
||||
$cfgList = [];
|
||||
@@ -93,10 +93,10 @@ function siteconfig()
|
||||
$cfgList[$sumNum + $num] = $data;
|
||||
|
||||
$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);
|
||||
if ($data['value'] === '')
|
||||
$buff .= in_array($data['key'], $reqKeys) ? CLISetup::red('<empty>') : '<empty>';
|
||||
$buff .= in_array($data['key'], $reqKeys) ? CLI::red('<empty>') : '<empty>';
|
||||
else
|
||||
{
|
||||
$info = explode(' - ', $data['comment']);
|
||||
@@ -140,27 +140,27 @@ function siteconfig()
|
||||
}
|
||||
|
||||
foreach ($mainBuff as $b)
|
||||
CLISetup::log($b);
|
||||
CLI::write($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)
|
||||
{
|
||||
CLISetup::log();
|
||||
CLISetup::log("please configure the required empty setings", CLISetup::LOG_WARN);
|
||||
CLI::write();
|
||||
CLI::write("please configure the required empty setings", CLI::LOG_WARN);
|
||||
}
|
||||
|
||||
$inp = ['idx' => ['', false, '/\d/']];
|
||||
if (CLISetup::readInput($inp) && $inp && $inp['idx'] !== '')
|
||||
if (CLI::readInput($inp) && $inp && $inp['idx'] !== '')
|
||||
{
|
||||
// add new php setting
|
||||
if ($inp['idx'] == $sumNum)
|
||||
{
|
||||
CLISetup::log();
|
||||
CLISetup::log("Adding additional php configuration.");
|
||||
CLI::write();
|
||||
CLI::write("Adding additional php configuration.");
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -168,25 +168,25 @@ function siteconfig()
|
||||
'key' => ['option name', false, '/[\w_\.\-]/i'],
|
||||
'val' => ['value', ]
|
||||
);
|
||||
if (CLISetup::readInput($setting) && $setting)
|
||||
if (CLI::readInput($setting) && $setting)
|
||||
{
|
||||
CLISetup::log();
|
||||
CLI::write();
|
||||
|
||||
$key = strtolower($setting['key']);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
CLISetup::log("new php configuration added", CLISetup::LOG_OK);
|
||||
CLI::write("new php configuration added", CLI::LOG_OK);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
@@ -194,8 +194,8 @@ function siteconfig()
|
||||
}
|
||||
else
|
||||
{
|
||||
CLISetup::log();
|
||||
CLISetup::log("edit canceled! returning to list...", CLISetup::LOG_INFO);
|
||||
CLI::write();
|
||||
CLI::write("edit canceled! returning to list...", CLI::LOG_INFO);
|
||||
sleep(1);
|
||||
break;
|
||||
}
|
||||
@@ -209,14 +209,14 @@ function siteconfig()
|
||||
$key = strtolower($conf['key']);
|
||||
$buff = '';
|
||||
|
||||
CLISetup::log();
|
||||
CLI::write();
|
||||
$buff .= $conf['flags'] & CON_FLAG_PHP ? " PHP: " : "AOWOW: ";
|
||||
$buff .= $conf['flags'] & CON_FLAG_PHP ? $key : strtoupper('cfg_'.$conf['key']);
|
||||
|
||||
if (!empty($info[1]))
|
||||
$buff .= " - ".$info[1];
|
||||
|
||||
CLISetup::log($buff);
|
||||
CLI::write($buff);
|
||||
|
||||
$buff = "VALUE: ";
|
||||
|
||||
@@ -245,20 +245,20 @@ function siteconfig()
|
||||
else /* if ($conf['flags'] & CON_FLAG_TYPE_INT) */
|
||||
$buff .= intVal($conf['value']);
|
||||
|
||||
CLISetup::log($buff);
|
||||
CLISetup::log();
|
||||
CLISetup::log("[".CLISetup::bold('E')."]dit");
|
||||
CLI::write($buff);
|
||||
CLI::write();
|
||||
CLI::write("[".CLI::bold('E')."]dit");
|
||||
|
||||
if (!($conf['flags'] & CON_FLAG_PERSISTENT))
|
||||
CLISetup::log("[".CLISetup::bold('D')."]elete");
|
||||
CLI::write("[".CLI::bold('D')."]elete");
|
||||
|
||||
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)
|
||||
{
|
||||
$action = ['idx' => ['', true, '/[edr]/i']];
|
||||
if (CLISetup::readInput($action, true) && $action)
|
||||
if (CLI::readInput($action, true) && $action)
|
||||
{
|
||||
switch (strtoupper($action['idx']))
|
||||
{
|
||||
@@ -274,7 +274,7 @@ function siteconfig()
|
||||
{
|
||||
$opt = explode(':', $option);
|
||||
$_valid[] = $opt[0];
|
||||
CLISetup::log('['.CLISetup::bold($opt[0]).'] '.$opt[1]);
|
||||
CLI::write('['.CLI::bold($opt[0]).'] '.$opt[1]);
|
||||
}
|
||||
$single = true;
|
||||
$pattern = '/\d/';
|
||||
@@ -282,21 +282,21 @@ function siteconfig()
|
||||
}
|
||||
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;
|
||||
foreach (explode(', ', $info[2]) as $option)
|
||||
{
|
||||
$opt = explode(':', $option);
|
||||
$_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+/';
|
||||
$validate = function ($v) use($_valid) { $v = $v & $_valid; return $v; };
|
||||
}
|
||||
else if ($conf['flags'] & CON_FLAG_TYPE_BOOL)
|
||||
{
|
||||
CLISetup::log('['.CLISetup::bold(0).'] Disabled');
|
||||
CLISetup::log('['.CLISetup::bold(1).'] Enabled');
|
||||
CLI::write('['.CLI::bold(0).'] Disabled');
|
||||
CLI::write('['.CLI::bold(1).'] Enabled');
|
||||
|
||||
$single = true;
|
||||
$pattern = '/[01]/';
|
||||
@@ -313,13 +313,13 @@ function siteconfig()
|
||||
while (true)
|
||||
{
|
||||
$use = $value;
|
||||
if (CLISetup::readInput($use, $single))
|
||||
if (CLI::readInput($use, $single))
|
||||
{
|
||||
CLISetup::log();
|
||||
CLI::write();
|
||||
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
@@ -336,14 +336,14 @@ function siteconfig()
|
||||
break;
|
||||
}
|
||||
|
||||
CLISetup::log("setting updated", CLISetup::LOG_OK);
|
||||
CLI::write("setting updated", CLI::LOG_OK);
|
||||
sleep(1);
|
||||
break 3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CLISetup::log("edit canceled! returning to selection...", CLISetup::LOG_INFO);
|
||||
CLI::write("edit canceled! returning to selection...", CLI::LOG_INFO);
|
||||
sleep(1);
|
||||
break;
|
||||
}
|
||||
@@ -360,8 +360,8 @@ function siteconfig()
|
||||
$val = @eval('return ('.$val.');');
|
||||
if (DB::Aowow()->query('UPDATE ?_config SET `value` = ? WHERE `key` = ?', $val, $key))
|
||||
{
|
||||
CLI::write("default value restored", CLI::LOG_OK);
|
||||
$onChange($key, $val);
|
||||
CLISetup::log("default value restored", CLISetup::LOG_OK);
|
||||
sleep(1);
|
||||
}
|
||||
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))
|
||||
{
|
||||
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);
|
||||
}
|
||||
break 2;
|
||||
@@ -379,8 +379,8 @@ function siteconfig()
|
||||
}
|
||||
else
|
||||
{
|
||||
CLISetup::log();
|
||||
CLISetup::log('edit canceled! returning to list...', CLISetup::LOG_INFO);
|
||||
CLI::write();
|
||||
CLI::write('edit canceled! returning to list...', CLI::LOG_INFO);
|
||||
sleep(1);
|
||||
break;
|
||||
}
|
||||
@@ -388,15 +388,15 @@ function siteconfig()
|
||||
}
|
||||
else
|
||||
{
|
||||
CLISetup::log();
|
||||
CLISetup::log('invalid selection', CLISetup::LOG_ERROR);
|
||||
CLI::write();
|
||||
CLI::write('invalid selection', CLI::LOG_ERROR);
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CLISetup::log();
|
||||
CLISetup::log('site configuration aborted', CLISetup::LOG_INFO);
|
||||
CLI::write();
|
||||
CLI::write('site configuration aborted', CLI::LOG_INFO);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -404,14 +404,14 @@ function siteconfig()
|
||||
if ($updScripts && (!class_exists('FileGen') || FileGen::getMode() != FileGen::MODE_FIRSTRUN))
|
||||
{
|
||||
require_once 'setup/tools/clisetup/build.func.php';
|
||||
CLISetup::log();
|
||||
CLISetup::log('regenerating affected static content', CLISetup::LOG_INFO);
|
||||
CLISetup::log();
|
||||
CLI::write();
|
||||
CLI::write('regenerating affected static content', CLI::LOG_INFO);
|
||||
CLI::write();
|
||||
sleep(1);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ function sql($syncMe = null)
|
||||
$allOk = true;
|
||||
|
||||
// start file generation
|
||||
CLISetup::log('begin generation of '. implode(', ', SqlGen::$subScripts));
|
||||
CLISetup::log();
|
||||
CLI::write('begin generation of '. implode(', ', SqlGen::$subScripts));
|
||||
CLI::write();
|
||||
|
||||
foreach (SqlGen::$subScripts as $tbl)
|
||||
{
|
||||
@@ -36,19 +36,19 @@ function sql($syncMe = null)
|
||||
else
|
||||
$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
|
||||
}
|
||||
|
||||
// end
|
||||
CLISetup::log();
|
||||
CLI::write();
|
||||
if ($allOk)
|
||||
CLISetup::log('successfully finished sql generation', CLISetup::LOG_OK);
|
||||
CLI::write('successfully finished sql generation', CLI::LOG_OK);
|
||||
else
|
||||
CLISetup::log('finished sql generation with errors', CLISetup::LOG_ERROR);
|
||||
CLI::write('finished sql generation with errors', CLI::LOG_ERROR);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ function update()
|
||||
{
|
||||
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;
|
||||
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);
|
||||
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
|
||||
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))) : [];
|
||||
|
||||
if ($sql)
|
||||
CLISetup::log('The following table(s) require syncing: '.implode(', ', $sql));
|
||||
CLI::write('The following table(s) require syncing: '.implode(', ', $sql));
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ class DBC
|
||||
$file = strtolower($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;
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ class DBC
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ class DBC
|
||||
if ($foundMask & (1 << $locId))
|
||||
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))
|
||||
continue;
|
||||
|
||||
@@ -310,7 +310,7 @@ class DBC
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -319,19 +319,19 @@ class DBC
|
||||
$x = array_unique(array_column($headers, 'recordCount'));
|
||||
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;
|
||||
}
|
||||
$x = array_unique(array_column($headers, 'fieldCount'));
|
||||
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;
|
||||
}
|
||||
$x = array_unique(array_column($headers, 'recordSize'));
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -345,11 +345,11 @@ class DBC
|
||||
|
||||
$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())
|
||||
{
|
||||
CLISetup::log(' - DBC::read() returned with error', CLISetup::LOG_ERROR);
|
||||
CLI::write(' - DBC::read() returned with error', CLI::LOG_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -374,7 +374,7 @@ class DBC
|
||||
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
@@ -387,14 +387,14 @@ class DBC
|
||||
$filesize = filesize($this->curFile);
|
||||
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;
|
||||
}
|
||||
|
||||
$header = $this->readHeader($handle);
|
||||
if (!$header)
|
||||
{
|
||||
CLISetup::log('cannot open file '.$this->curFile, CLISetup::LOG_ERROR);
|
||||
CLI::write('cannot open file '.$this->curFile, CLI::LOG_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -406,14 +406,14 @@ class DBC
|
||||
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
@@ -519,7 +519,7 @@ class DBC
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -541,7 +541,7 @@ class DBC
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,19 +95,19 @@ class FileGen
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// create directory structure
|
||||
CLISetup::log('FileGen::init() - creating required directories');
|
||||
CLI::write('FileGen::init() - creating required directories');
|
||||
$pathOk = 0;
|
||||
foreach (self::$reqDirs as $rd)
|
||||
if (CLISetup::writeDir($rd))
|
||||
$pathOk++;
|
||||
|
||||
CLISetup::log('created '.$pathOk.' extra paths'.($pathOk == count(self::$reqDirs) ? '' : ' with errors'));
|
||||
CLISetup::log();
|
||||
CLI::write('created '.$pathOk.' extra paths'.($pathOk == count(self::$reqDirs) ? '' : ' with errors'));
|
||||
CLI::write();
|
||||
|
||||
self::$mode = $mode;
|
||||
}
|
||||
@@ -196,11 +196,11 @@ class FileGen
|
||||
require_once 'setup/tools/filegen/'.$key.'.func.php';
|
||||
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;
|
||||
}
|
||||
|
||||
CLISetup::log('FileGen::generate() - gathering data for '.$key);
|
||||
CLI::write('FileGen::generate() - gathering data for '.$key);
|
||||
|
||||
if (!empty(self::$tplFiles[$key]))
|
||||
{
|
||||
@@ -228,9 +228,9 @@ class FileGen
|
||||
else
|
||||
{
|
||||
$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))
|
||||
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;
|
||||
}
|
||||
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]))
|
||||
{
|
||||
@@ -254,7 +254,7 @@ class FileGen
|
||||
$success = $key($updateIds);
|
||||
}
|
||||
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
|
||||
|
||||
@@ -86,7 +86,7 @@ if (!CLI)
|
||||
$file = $path.'.png';
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ if (!CLI)
|
||||
$src = $loadImageFile($baseName.$suffix);
|
||||
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);
|
||||
return null;
|
||||
}
|
||||
@@ -148,7 +148,7 @@ if (!CLI)
|
||||
$ok = imagepng($dest, $name.'.'.$ext);
|
||||
break;
|
||||
default:
|
||||
CLISetup::log($done.' - unsupported file fromat: '.$ext, CLISetup::LOG_WARN);
|
||||
CLI::write($done.' - unsupported file fromat: '.$ext, CLI::LOG_WARN);
|
||||
}
|
||||
|
||||
imagedestroy($dest);
|
||||
@@ -156,17 +156,17 @@ if (!CLI)
|
||||
if ($ok)
|
||||
{
|
||||
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
|
||||
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;
|
||||
};
|
||||
|
||||
$createSpawnMap = function($img, $zoneId) use ($mapHeight, $mapWidth, $threshold)
|
||||
{
|
||||
CLISetup::log(' - creating spawn map');
|
||||
CLI::write(' - creating spawn map');
|
||||
|
||||
$tmp = imagecreate(1000, 1000);
|
||||
$cbg = imagecolorallocate($tmp, 255, 255, 255);
|
||||
@@ -235,11 +235,11 @@ if (!CLI)
|
||||
if (in_array($locId, CLISetup::$localeIds))
|
||||
$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))
|
||||
{
|
||||
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)
|
||||
{
|
||||
$foundLoc = [];
|
||||
@@ -252,25 +252,28 @@ if (!CLI)
|
||||
{
|
||||
$buff = [];
|
||||
foreach ($diff as $d)
|
||||
$buff[] = CLISetup::yellow(Util::$localeStrings[$d]);
|
||||
$buff[] = CLI::yellow(Util::$localeStrings[$d]);
|
||||
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
|
||||
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
|
||||
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 (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;
|
||||
}
|
||||
else
|
||||
@@ -296,7 +299,7 @@ if (!CLI)
|
||||
{
|
||||
$sum = 0;
|
||||
$total = count($tTabs);
|
||||
CLISetup::log('Processing '.$total.' files from TalentFrame/ ...');
|
||||
CLI::write('Processing '.$total.' files from TalentFrame/ ...');
|
||||
|
||||
foreach ($tTabs as $tt)
|
||||
{
|
||||
@@ -317,14 +320,14 @@ if (!CLI)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
$im = $assembleImage($paths[0x1][2].'/'.$tt['textureFile'], $order, 256 + 44, 256 + 75);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -371,7 +374,7 @@ if (!CLI)
|
||||
if (!$wma || !$wmo)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -393,7 +396,7 @@ if (!CLI)
|
||||
|
||||
$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)
|
||||
{
|
||||
@@ -410,7 +413,7 @@ if (!CLI)
|
||||
if ($dirError)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -423,15 +426,19 @@ if (!CLI)
|
||||
if(!isset($paths[0x16][2][$mapLoc]))
|
||||
continue;
|
||||
|
||||
CLISetup::log(' - using files from '.($mapLoc ?: '/').' for locale '.Util::$localeStrings[$l], CLISetup::LOG_INFO);
|
||||
$mapSrcDir = $paths[0x16][2][$mapLoc].'/';
|
||||
break;
|
||||
$p = sprintf($imgPath, $mapLoc).$paths[0];
|
||||
if (CLISetup::fileExists($p))
|
||||
{
|
||||
CLI::write(' - using files from '.($mapLoc ?: '/').' for locale '.Util::$localeStrings[$l], CLI::LOG_INFO);
|
||||
$mapSrcDir = $p.'/';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($mapSrcDir === null)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -449,7 +456,7 @@ if (!CLI)
|
||||
if (!CLISetup::fileExists($path))
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -459,14 +466,14 @@ if (!CLI)
|
||||
[9, 10, 11, 12]
|
||||
);
|
||||
|
||||
CLISetup::log($textureStr . " [" . $zoneId . "]");
|
||||
CLI::write($textureStr . " [" . $zoneId . "]");
|
||||
|
||||
$overlay = $createAlphaImage($mapWidth, $mapHeight);
|
||||
|
||||
// zone has overlays (is in open world; is not multiLeveled)
|
||||
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)
|
||||
{
|
||||
@@ -480,7 +487,7 @@ if (!CLI)
|
||||
$img = $loadImageFile($path . '/' . $row['textureString'] . $i);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -533,7 +540,7 @@ if (!CLI)
|
||||
$file = $path.'/'.$textureStr.'1.blp';
|
||||
$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;
|
||||
for ($i = 0; $i <= $multiLevel; $i++)
|
||||
@@ -565,7 +572,7 @@ if (!CLI)
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -577,7 +584,7 @@ if (!CLI)
|
||||
if (!$map)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -614,7 +621,7 @@ if (!CLI)
|
||||
$outFile[$idx] = $destDir . sprintf($info[0], strtolower(Util::$localeStrings[$l]).'/') . $row['areaTableId'];
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -702,7 +709,7 @@ if (!CLI)
|
||||
$total = count($imgGroups);
|
||||
$sum = 0;
|
||||
|
||||
CLISetup::log('Processing '.$total.' files from Glues/Credits/...');
|
||||
CLI::write('Processing '.$total.' files from Glues/Credits/...');
|
||||
|
||||
foreach ($imgGroups as $file => $fmt)
|
||||
{
|
||||
@@ -714,20 +721,20 @@ if (!CLI)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
$im = $assembleImage($paths[0x8][2].'/'.$file, $order[$fmt], count($order[$fmt][0]) * 256, count($order[$fmt]) * 256);
|
||||
if (!$im)
|
||||
{
|
||||
CLISetup::log(' - could not assemble file '.$name, CLISetup::LOG_ERROR);
|
||||
CLI::write(' - could not assemble file '.$name, CLI::LOG_ERROR);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,8 +86,8 @@ if (!CLI)
|
||||
$enchantments = new EnchantmentList(array(['id', $enchIds], CFG_SQL_LIMIT_NONE));
|
||||
if ($enchantments->error)
|
||||
{
|
||||
CLISetup::log('Required table ?_itemenchantment seems to be empty! Leaving enchants()...', CLISetup::LOG_ERROR);
|
||||
CLISetup::log();
|
||||
CLI::write('Required table ?_itemenchantment seems to be empty! Leaving enchants()...', CLI::LOG_ERROR);
|
||||
CLI::write();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ if (!CLI)
|
||||
$eId = $es['effect1MiscValue'];
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,8 +56,8 @@ if (!CLI)
|
||||
$enchantments = new EnchantmentList(array(['id', $enchIds], CFG_SQL_LIMIT_NONE));
|
||||
if ($enchantments->error)
|
||||
{
|
||||
CLISetup::log('Required table ?_itemenchantment seems to be empty! Leaving gems()...', CLISetup::LOG_ERROR);
|
||||
CLISetup::log();
|
||||
CLI::write('Required table ?_itemenchantment seems to be empty! Leaving gems()...', CLI::LOG_ERROR);
|
||||
CLI::write();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ if (!CLI)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ if (!CLI)
|
||||
if (!$buff)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ if (!CLI)
|
||||
}
|
||||
|
||||
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))
|
||||
array_pop($menu);
|
||||
|
||||
@@ -30,7 +30,7 @@ if (!CLI)
|
||||
{
|
||||
$realms = Util::getRealms();
|
||||
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
|
||||
foreach ($realms as &$r)
|
||||
$r['battlegroup'] = CFG_BATTLEGROUP;
|
||||
|
||||
@@ -27,7 +27,7 @@ if (!CLI)
|
||||
$file = $path.'.png';
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ if (!CLI)
|
||||
$ok = imagepng($dest, $name.$ext);
|
||||
break;
|
||||
default:
|
||||
CLISetup::log($done.' - unsupported file fromat: '.$ext, CLISetup::LOG_WARN);
|
||||
CLI::write($done.' - unsupported file fromat: '.$ext, CLI::LOG_WARN);
|
||||
}
|
||||
|
||||
imagedestroy($dest);
|
||||
@@ -182,10 +182,10 @@ if (!CLI)
|
||||
if ($ok)
|
||||
{
|
||||
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
|
||||
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;
|
||||
};
|
||||
@@ -242,21 +242,24 @@ if (!CLI)
|
||||
if (in_array($locId, CLISetup::$localeIds))
|
||||
$locList[] = $xp;
|
||||
|
||||
CLISetup::log('required resources overview:', CLISetup::LOG_INFO);
|
||||
CLI::write('required resources overview:', CLI::LOG_INFO);
|
||||
foreach ($paths as list($path, , , , , $realPath))
|
||||
{
|
||||
if ($realPath)
|
||||
CLISetup::log(CLISetup::green(' FOUND ').' - '.str_pad($path, 53).' @ '.$realPath);
|
||||
CLI::write(CLI::green(' FOUND ').' - '.str_pad($path, 53).' @ '.$realPath);
|
||||
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 (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;
|
||||
}
|
||||
else
|
||||
@@ -316,7 +319,7 @@ if (!CLI)
|
||||
$files = CLISetup::filesInPath($search, !!$pattern);
|
||||
$allPaths = array_merge($allPaths, $files);
|
||||
|
||||
CLISetup::log('processing '.count($files).' files in '.$path.'...');
|
||||
CLI::write('processing '.count($files).' files in '.$path.'...');
|
||||
|
||||
$j = 0;
|
||||
foreach ($files as $f)
|
||||
@@ -336,7 +339,7 @@ if (!CLI)
|
||||
else if (!$tileSize)
|
||||
{
|
||||
$j += count($outInfo);
|
||||
CLISetup::log('skipping extraneous file '.$img.' (+'.count($outInfo).')');
|
||||
CLI::write('skipping extraneous file '.$img.' (+'.count($outInfo).')');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -357,7 +360,7 @@ if (!CLI)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -404,10 +407,10 @@ if (!CLI)
|
||||
imagecopyresampled($dest, $src, 5, 0, 64 + 1, 32 + 1, 10, 16, 18, 28);
|
||||
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -426,7 +429,7 @@ if (!CLI)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -472,9 +475,9 @@ if (!CLI)
|
||||
DB::Aowow()->query('UPDATE ?_icons SET cuFlags = cuFlags | ?d WHERE name IN (?a)', CUSTOM_EXCLUDE_FOR_LISTVIEW, $iconNames);
|
||||
|
||||
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)
|
||||
CLISetup::log(' - '.$m);
|
||||
CLI::write(' - '.$m);
|
||||
}
|
||||
|
||||
return $success;
|
||||
|
||||
@@ -22,7 +22,7 @@ if (!CLI)
|
||||
if ($i == $step)
|
||||
{
|
||||
$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
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ if (!CLI)
|
||||
foreach (CLISetup::$expectedPaths as $locStr => $__)
|
||||
{
|
||||
// get your paths straight!
|
||||
$p = CLISetup::nicePath($filePath, CLISetup::$srcDir, $locStr);
|
||||
$p = CLI::nicePath($filePath, CLISetup::$srcDir, $locStr);
|
||||
|
||||
if (CLISetup::fileExists($p))
|
||||
{
|
||||
@@ -41,7 +41,7 @@ if (!CLI)
|
||||
if (!copy($p, 'static/wowsounds/'.$fileId))
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
DB::Aowow()->query('UPDATE ?_sounds_files SET id = ?d WHERE ABS(id) = ?d', -$fileId, $fileId);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ if (!CLI)
|
||||
$res = $$s();
|
||||
$out[$s] = $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)).';';
|
||||
|
||||
@@ -44,7 +44,7 @@ if (!CLI)
|
||||
|
||||
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;
|
||||
continue;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ if (!CLI)
|
||||
$imgFile = 'static/images/wow/icons/medium/'.strtolower($icons[$i]).'.jpg';
|
||||
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;
|
||||
break;
|
||||
}
|
||||
@@ -80,17 +80,17 @@ if (!CLI)
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
$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
|
||||
{
|
||||
$success = false;
|
||||
CLISetup::log('talentIcons - image resource not created', CLISetup::LOG_ERROR);
|
||||
CLI::write('talentIcons - image resource not created', CLI::LOG_ERROR);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ if (!CLI)
|
||||
$wtPresets[$s['class']]['pve'][$s['name']] = array_merge(['__icon' => $s['icon']], $weights);
|
||||
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']];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -41,14 +41,14 @@
|
||||
|
||||
if (!$file)
|
||||
{
|
||||
CLISetup::log('could not open file '.$fileName, CLISetup::LOG_ERROR);
|
||||
CLI::write('could not open file '.$fileName, CLI::LOG_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
$fileSize = fileSize($fileName);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -64,14 +64,14 @@
|
||||
$data = substr($data, 0x44);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -99,12 +99,12 @@
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
$img = icfb3($header['width'], $header['height'], substr($data, $offs, $size));
|
||||
else
|
||||
{
|
||||
CLISetup::log('file '.$fileName.' has unsupported type'.$debugStr, CLISetup::LOG_ERROR);
|
||||
CLI::write('file '.$fileName.' has unsupported type'.$debugStr, CLI::LOG_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ class SqlGen
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -158,14 +158,14 @@ class SqlGen
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
if (!empty(self::$tables[$tableName][0])) // straight copy from dbc source
|
||||
{
|
||||
$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]);
|
||||
if ($dbc->error)
|
||||
@@ -177,7 +177,7 @@ class SqlGen
|
||||
{
|
||||
$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';
|
||||
|
||||
@@ -196,12 +196,12 @@ class SqlGen
|
||||
DB::Aowow()->query('UPDATE ?_'.$tableName.' SET ?a WHERE id = ?d', $data, $id);
|
||||
}
|
||||
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;
|
||||
}
|
||||
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'));
|
||||
|
||||
CLISetup::log(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
|
||||
$lastMax = $newMax;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ function currencies(array $ids = [])
|
||||
$strings = $moneyNames[$itemId];
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,10 +142,10 @@ function item_stats(array $ids = [])
|
||||
{
|
||||
$offset = 0;
|
||||
|
||||
CLISetup::log(' - applying stats for enchantments');
|
||||
CLI::write(' - applying stats for enchantments');
|
||||
$enchStats = enchantment_stats();
|
||||
CLISetup::log(' '.count($enchStats).' enchantments parsed');
|
||||
CLISetup::log(' - applying stats for items');
|
||||
CLI::write(' '.count($enchStats).' enchantments parsed');
|
||||
CLI::write(' - applying stats for items');
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -156,7 +156,7 @@ function item_stats(array $ids = [])
|
||||
$max = max($items->getFoundIDs());
|
||||
$num = count($items->getFoundIDs());
|
||||
|
||||
CLISetup::log(' * sets '.($offset + 1).' - '.($max));
|
||||
CLI::write(' * sets '.($offset + 1).' - '.($max));
|
||||
|
||||
$offset = $max;
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ function items(array $ids = [])
|
||||
{
|
||||
$newMax = max(array_column($items, 'entry'));
|
||||
|
||||
CLISetup::log(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
|
||||
$lastMax = $newMax;
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ function itemset()
|
||||
$items[$vId][$piece['slot'].$itemId] = $itemId;
|
||||
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)
|
||||
$items[$vId][$piece['slot']] = $itemId;
|
||||
@@ -243,7 +243,7 @@ function itemset()
|
||||
foreach ($subset as $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
|
||||
$temp[] = $item;
|
||||
else
|
||||
|
||||
@@ -110,7 +110,7 @@ function objects(array $ids = [])
|
||||
{
|
||||
$newMax = max(array_column($objects, 'entry'));
|
||||
|
||||
CLISetup::log(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
|
||||
$lastMax = $newMax;
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ function quests(array $ids = [])
|
||||
{
|
||||
$newMax = max(array_column($quests, 'ID'));
|
||||
|
||||
CLISetup::log(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
|
||||
$lastMax = $newMax;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ function sounds(/*array $ids = [] */)
|
||||
/* M A I N */
|
||||
/***********/
|
||||
|
||||
CLISetup::log(' - sounds main data');
|
||||
CLI::write(' - sounds main data');
|
||||
|
||||
// file extraction and conversion manually
|
||||
// moving files in build step. data here is purely structural
|
||||
@@ -74,7 +74,7 @@ function sounds(/*array $ids = [] */)
|
||||
{
|
||||
$newMax = max(array_column($sounds, 'id'));
|
||||
|
||||
CLISetup::log(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
|
||||
$lastMax = $newMax;
|
||||
|
||||
@@ -94,7 +94,7 @@ function sounds(/*array $ids = [] */)
|
||||
$hasDupes = false;
|
||||
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))
|
||||
{
|
||||
$s['soundFile'.$i] = $soundIndex[$nicePath];
|
||||
@@ -131,7 +131,7 @@ function sounds(/*array $ids = [] */)
|
||||
// i call bullshit
|
||||
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;
|
||||
}
|
||||
// empty case
|
||||
@@ -141,7 +141,7 @@ function sounds(/*array $ids = [] */)
|
||||
|
||||
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;
|
||||
}
|
||||
else if ($fileSets)
|
||||
@@ -160,7 +160,7 @@ function sounds(/*array $ids = [] */)
|
||||
/* VocalUI Sounds */
|
||||
/******************/
|
||||
|
||||
CLISetup::log(' - linking to race');
|
||||
CLI::write(' - linking to race');
|
||||
|
||||
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');
|
||||
@@ -173,7 +173,7 @@ function sounds(/*array $ids = [] */)
|
||||
/* Emote Sound */
|
||||
/***************/
|
||||
|
||||
CLISetup::log(' - linking to emotes');
|
||||
CLI::write(' - linking to emotes');
|
||||
|
||||
DB::Aowow()->query('TRUNCATE ?_emotes_sounds');
|
||||
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 */
|
||||
/*******************/
|
||||
|
||||
CLISetup::log(' - linking to creatures');
|
||||
CLI::write(' - linking to creatures');
|
||||
|
||||
// currently ommitting:
|
||||
// * footsteps (matrix of: creature + terrain + humidity)
|
||||
@@ -240,7 +240,7 @@ function sounds(/*array $ids = [] */)
|
||||
/* Spell Sounds */
|
||||
/****************/
|
||||
|
||||
CLISetup::log(' - linking to spells');
|
||||
CLI::write(' - linking to spells');
|
||||
|
||||
// issues: (probably because of 335-data)
|
||||
// * animate is probably wrong
|
||||
@@ -300,7 +300,7 @@ function sounds(/*array $ids = [] */)
|
||||
/* 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
|
||||
|
||||
@@ -358,7 +358,7 @@ function sounds(/*array $ids = [] */)
|
||||
/* Item Sounds */
|
||||
/***************/
|
||||
|
||||
CLISetup::log(' - linking to items');
|
||||
CLI::write(' - linking to items');
|
||||
|
||||
DB::Aowow()->query('
|
||||
UPDATE
|
||||
|
||||
@@ -112,11 +112,11 @@ function source(array $ids = [])
|
||||
/* Item & inherited Spells */
|
||||
/***************************/
|
||||
|
||||
CLISetup::log(' - Items & Spells [inherited]');
|
||||
CLI::write(' - Items & Spells [inherited]');
|
||||
# also everything from items that teach spells, is src of spell
|
||||
# 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('
|
||||
SELECT
|
||||
rlt.Entry AS ARRAY_KEY,
|
||||
@@ -163,7 +163,7 @@ function source(array $ids = [])
|
||||
###############
|
||||
# 1: Crafted #
|
||||
###############
|
||||
CLISetup::log(' * #1 Crafted');
|
||||
CLI::write(' * #1 Crafted');
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -204,7 +204,7 @@ function source(array $ids = [])
|
||||
############
|
||||
# 2: Drop #
|
||||
############
|
||||
CLISetup::log(' * #2 Drop');
|
||||
CLI::write(' * #2 Drop');
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -346,7 +346,7 @@ function source(array $ids = [])
|
||||
###########
|
||||
# 3: PvP # (Vendors w/ xCost Arena/Honor)
|
||||
###########
|
||||
CLISetup::log(' * #3 PvP');
|
||||
CLI::write(' * #3 PvP');
|
||||
|
||||
// var g_sources_pvp = {
|
||||
// 1: 'Arena',
|
||||
@@ -391,7 +391,7 @@ function source(array $ids = [])
|
||||
#############
|
||||
# 4: Quest #
|
||||
#############
|
||||
CLISetup::log(' * #4 Quest');
|
||||
CLI::write(' * #4 Quest');
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -473,7 +473,7 @@ function source(array $ids = [])
|
||||
##############
|
||||
# 5: Vendor # (w/o xCost Arena/Honor)
|
||||
##############
|
||||
CLISetup::log(' * #5 Vendor');
|
||||
CLI::write(' * #5 Vendor');
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -507,7 +507,7 @@ function source(array $ids = [])
|
||||
###############
|
||||
# 10: Starter #
|
||||
###############
|
||||
CLISetup::log(' * #10 Starter');
|
||||
CLI::write(' * #10 Starter');
|
||||
|
||||
if ($pcii = DB::World()->select('SELECT ?d, itemid, 1 FROM playercreateinfo_item', TYPE_ITEM))
|
||||
DB::Aowow()->query(queryfy('[V]', $pcii, $insBasic), 10, 10, 10);
|
||||
@@ -519,7 +519,7 @@ function source(array $ids = [])
|
||||
###################
|
||||
# 12: Achievement #
|
||||
###################
|
||||
CLISetup::log(' * #12 Achievement');
|
||||
CLI::write(' * #12 Achievement');
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -581,7 +581,7 @@ function source(array $ids = [])
|
||||
####################
|
||||
# 15: Disenchanted #
|
||||
####################
|
||||
CLISetup::log(' * #15 Disenchanted');
|
||||
CLI::write(' * #15 Disenchanted');
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -634,7 +634,7 @@ function source(array $ids = [])
|
||||
##############
|
||||
# 16: Fished #
|
||||
##############
|
||||
CLISetup::log(' * #16 Fished');
|
||||
CLI::write(' * #16 Fished');
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -685,7 +685,7 @@ function source(array $ids = [])
|
||||
################
|
||||
# 17: Gathered #
|
||||
################
|
||||
CLISetup::log(' * #17 Gathered');
|
||||
CLI::write(' * #17 Gathered');
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -740,7 +740,7 @@ function source(array $ids = [])
|
||||
##############
|
||||
# 18: Milled #
|
||||
##############
|
||||
CLISetup::log(' * #18 Milled');
|
||||
CLI::write(' * #18 Milled');
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -791,7 +791,7 @@ function source(array $ids = [])
|
||||
#############
|
||||
# 19: Mined #
|
||||
#############
|
||||
CLISetup::log(' * #19 Mined');
|
||||
CLI::write(' * #19 Mined');
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -846,7 +846,7 @@ function source(array $ids = [])
|
||||
##################
|
||||
# 20: Prospected #
|
||||
##################
|
||||
CLISetup::log(' * #20 Prospected');
|
||||
CLI::write(' * #20 Prospected');
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -897,7 +897,7 @@ function source(array $ids = [])
|
||||
##################
|
||||
# 21: Pickpocket #
|
||||
##################
|
||||
CLISetup::log(' * #21 Pickpocket');
|
||||
CLI::write(' * #21 Pickpocket');
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -947,7 +947,7 @@ function source(array $ids = [])
|
||||
################
|
||||
# 22: Salvaged #
|
||||
################
|
||||
CLISetup::log(' * #22 Salvaged');
|
||||
CLI::write(' * #22 Salvaged');
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -998,7 +998,7 @@ function source(array $ids = [])
|
||||
###############
|
||||
# 23: Skinned #
|
||||
###############
|
||||
CLISetup::log(' * #23 Skinned');
|
||||
CLI::write(' * #23 Skinned');
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -1054,10 +1054,10 @@ function source(array $ids = [])
|
||||
/* Spell */
|
||||
/*********/
|
||||
|
||||
CLISetup::log(' - Spells [original]');
|
||||
CLI::write(' - Spells [original]');
|
||||
|
||||
# 4: Quest
|
||||
CLISetup::log(' * #4 Quest');
|
||||
CLI::write(' * #4 Quest');
|
||||
$quests = DB::World()->select('
|
||||
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
|
||||
@@ -1085,7 +1085,7 @@ function source(array $ids = [])
|
||||
}
|
||||
|
||||
# 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'))
|
||||
{
|
||||
$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
|
||||
CLISetup::log(' * #7 Discovery');
|
||||
CLI::write(' * #7 Discovery');
|
||||
// 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))
|
||||
DB::Aowow()->query(queryfy('[V]', $disco, $insBasic), 7, 7, 7);
|
||||
|
||||
# 9: Talent
|
||||
CLISetup::log(' * #9 Talent');
|
||||
CLI::write(' * #9 Talent');
|
||||
$tSpells = DB::Aowow()->select('
|
||||
SELECT s.id AS ARRAY_KEY, s.effect1Id, s.effect2Id, s.effect3Id, s.effect1TriggerSpell, s.effect2TriggerSpell, s.effect3TriggerSpell
|
||||
FROM dbc_talent t
|
||||
@@ -1136,7 +1136,7 @@ function source(array $ids = [])
|
||||
$buff = [];
|
||||
while ($tSpells)
|
||||
{
|
||||
CLISetup::log(' - '.++$n.'. pass');
|
||||
CLI::write(' - '.++$n.'. pass');
|
||||
|
||||
$recurse = [];
|
||||
foreach ($tSpells as $tId => $spell)
|
||||
@@ -1161,7 +1161,7 @@ function source(array $ids = [])
|
||||
DB::Aowow()->query(queryfy('[V]', $buff, $insBasic), 9, 9, 9);
|
||||
|
||||
# 10: Starter
|
||||
CLISetup::log(' * #10 Starter');
|
||||
CLI::write(' * #10 Starter');
|
||||
/* acquireMethod
|
||||
ABILITY_LEARNED_ON_GET_PROFESSION_SKILL = 1, learnedAt = 1 && source10 = 1
|
||||
ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL = 2
|
||||
@@ -1176,15 +1176,15 @@ function source(array $ids = [])
|
||||
/* Titles */
|
||||
/**********/
|
||||
|
||||
CLISetup::log(' - Titles');
|
||||
CLI::write(' - Titles');
|
||||
|
||||
# 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))
|
||||
DB::Aowow()->query(queryfy('[V]', $quests, $insMore), 4, 4, 4);
|
||||
|
||||
# 12: Achievement
|
||||
CLISetup::log(' * #12 Achievement');
|
||||
CLI::write(' * #12 Achievement');
|
||||
$sets = DB::World()->select('
|
||||
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
|
||||
@@ -1201,7 +1201,7 @@ function source(array $ids = [])
|
||||
}
|
||||
|
||||
# 13: Source-String
|
||||
CLISetup::log(' * #13 cuStrings');
|
||||
CLI::write(' * #13 cuStrings');
|
||||
$src13 = [null, 42, 52, 71, 80, 157, 163, 167, 169, 177];
|
||||
foreach ($src13 as $src => $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` ' .
|
||||
'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` ' .
|
||||
'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 ' .
|
||||
'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 ' .
|
||||
'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` ' .
|
||||
'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` ' .
|
||||
'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` ' .
|
||||
'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, ' .
|
||||
'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)
|
||||
{
|
||||
CLISetup::log($q[1]);
|
||||
CLI::write($q[1]);
|
||||
|
||||
$n = 0;
|
||||
$sum = 0;
|
||||
@@ -166,7 +166,7 @@ function spawns() // and waypoints
|
||||
foreach ($queryResult as $spawn)
|
||||
{
|
||||
if (!$n)
|
||||
CLISetup::log(' * sets '.($sum + 1).' - '.($sum += SqlGen::$stepSize));
|
||||
CLI::write(' * sets '.($sum + 1).' - '.($sum += SqlGen::$stepSize));
|
||||
|
||||
if ($n++ > SqlGen::$stepSize)
|
||||
$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))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -267,10 +267,10 @@ function spawns() // and waypoints
|
||||
}
|
||||
}
|
||||
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)
|
||||
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)
|
||||
$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))
|
||||
{
|
||||
$newMax = max(array_column($spells, 'id'));
|
||||
|
||||
CLISetup::log(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
|
||||
$lastMax = $newMax;
|
||||
|
||||
@@ -240,12 +240,12 @@ function spell()
|
||||
|
||||
// merge everything into aowow_spell
|
||||
$lastMax = 0;
|
||||
CLISetup::log(' - filling aowow_spell');
|
||||
CLI::write(' - filling aowow_spell');
|
||||
while ($spells = DB::Aowow()->select($baseQuery, $lastMax, SqlGen::$stepSize))
|
||||
{
|
||||
$newMax = max(array_column($spells, 'id'));
|
||||
|
||||
CLISetup::log(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
|
||||
$lastMax = $newMax;
|
||||
|
||||
@@ -286,7 +286,7 @@ function spell()
|
||||
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');
|
||||
foreach ($results as $spellId => $sets)
|
||||
@@ -445,7 +445,7 @@ function spell()
|
||||
/* talent related */
|
||||
/******************/
|
||||
|
||||
CLISetup::log(' - linking with talent');
|
||||
CLI::write(' - linking with talent');
|
||||
|
||||
for ($i = 1; $i < 6; $i++)
|
||||
{
|
||||
@@ -467,7 +467,7 @@ function spell()
|
||||
/* Other */
|
||||
/*********/
|
||||
|
||||
CLISetup::log(' - misc fixups & icons');
|
||||
CLI::write(' - misc fixups & icons');
|
||||
|
||||
// FU [FixUps]
|
||||
DB::Aowow()->query('UPDATE ?_spell SET reqRaceMask = ?d WHERE skillLine1 = ?d', 1 << 10, 760); // Draenai Racials
|
||||
@@ -529,7 +529,7 @@ function spell()
|
||||
/* Categories */
|
||||
/**************/
|
||||
|
||||
CLISetup::log(' - applying categories');
|
||||
CLI::write(' - applying categories');
|
||||
|
||||
// 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)');
|
||||
@@ -645,7 +645,7 @@ function spell()
|
||||
/* Glyphs */
|
||||
/**********/
|
||||
|
||||
CLISetup::log(' - fixing glyph data');
|
||||
CLI::write(' - fixing glyph data');
|
||||
|
||||
// glyphSpell => affectedSpell
|
||||
$glyphAffects = array(
|
||||
@@ -754,7 +754,7 @@ function spell()
|
||||
if ($icons)
|
||||
DB::Aowow()->query('UPDATE ?_spell s SET s.skillLine1 = ?d, s.iconIdAlt = ?d WHERE s.id = ?d', $icons['skill'], $icons['icon'], $applyId);
|
||||
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
|
||||
|
||||
@@ -151,7 +151,7 @@ function taxi() // path & nodes
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user