mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Setup/Log
* allow overwriting generic/fine log output * fix some errors * can't catch notices generated by mysqli_connect * removed some unnessecary ORDER from querys
This commit is contained in:
@@ -56,15 +56,14 @@ class DB
|
||||
if (strstr($options['host'], ':'))
|
||||
[$options['host'], $port] = explode(':', $options['host']);
|
||||
|
||||
try {
|
||||
$link = @mysqli_connect($options['host'], $options['user'], $options['pass'], $options['db'], $port ?: $defPort);
|
||||
if ($link = @mysqli_connect($options['host'], $options['user'], $options['pass'], $options['db'], $port ?: $defPort))
|
||||
mysqli_close($link);
|
||||
}
|
||||
catch (Exception $e)
|
||||
else
|
||||
{
|
||||
$err = '['.mysqli_connect_errno().'] '.mysqli_connect_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +141,7 @@ abstract class CLI
|
||||
private static $logHandle = null;
|
||||
private static $hasReadline = null;
|
||||
|
||||
private static $overwriteLast = false;
|
||||
|
||||
/********************/
|
||||
/* formatted output */
|
||||
@@ -232,7 +233,7 @@ abstract class CLI
|
||||
return OS_WIN ? $str : "\e[1m".$str."\e[0m";
|
||||
}
|
||||
|
||||
public static function write(string $txt = '', int $lvl = self::LOG_BLANK, bool $timestamp = true) : void
|
||||
public static function write(string $txt = '', int $lvl = self::LOG_BLANK, bool $timestamp = true, bool $tmpRow = false) : void
|
||||
{
|
||||
$msg = '';
|
||||
if ($txt)
|
||||
@@ -259,15 +260,16 @@ abstract class CLI
|
||||
break;
|
||||
}
|
||||
|
||||
$msg .= $txt."\n";
|
||||
$msg .= $txt;
|
||||
}
|
||||
else
|
||||
$msg = "\n";
|
||||
|
||||
$msg = (self::$overwriteLast && !OS_WIN ? "\e[1G\e[0K" : "\n") . $msg;
|
||||
self::$overwriteLast = $tmpRow;
|
||||
|
||||
echo $msg;
|
||||
|
||||
if (self::$logHandle) // remove highlights for logging
|
||||
fwrite(self::$logHandle, preg_replace(["/\e\[\d+m/", "/\e\[0m/"], '', $msg));
|
||||
if (self::$logHandle) // remove control sequences from log
|
||||
fwrite(self::$logHandle, preg_replace(["/\e\[\d+[mK]/", "/\e\[\d+G/"], ['', "\n"], $msg));
|
||||
|
||||
flush();
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ class CLISetup
|
||||
{
|
||||
if (Util::writeFile($file, $content))
|
||||
{
|
||||
CLI::write(sprintf(ERR_NONE, CLI::bold($file)), CLI::LOG_OK);
|
||||
CLI::write(sprintf(ERR_NONE, CLI::bold($file)), CLI::LOG_OK, true, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ function dbconfig() : void
|
||||
|
||||
while (true)
|
||||
{
|
||||
CLI::write();
|
||||
CLI::write("select a numerical index to use the corresponding entry");
|
||||
|
||||
$nCharDBs = 0;
|
||||
@@ -63,6 +62,7 @@ function dbconfig() : void
|
||||
}
|
||||
|
||||
CLI::write("[".CLI::bold(3 + $nCharDBs)."] add an additional Character DB");
|
||||
CLI::write();
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -127,8 +127,8 @@ function dbconfig() : void
|
||||
}
|
||||
else
|
||||
{
|
||||
CLI::write();
|
||||
CLI::write("edit canceled! returning to list...", CLI::LOG_INFO);
|
||||
CLI::write();
|
||||
sleep(1);
|
||||
continue 2;
|
||||
}
|
||||
@@ -136,8 +136,8 @@ function dbconfig() : void
|
||||
}
|
||||
else
|
||||
{
|
||||
CLI::write();
|
||||
CLI::write("leaving db setup...", CLI::LOG_INFO);
|
||||
CLI::write();
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ function siteconfig() : void
|
||||
|
||||
if (!DB::isConnectable(DB_AOWOW))
|
||||
{
|
||||
CLI::write();
|
||||
CLI::write("database not yet set up!\n Please use --dbconfig for setup", CLI::LOG_WARN);
|
||||
CLI::write();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ function siteconfig() : void
|
||||
|
||||
while (true)
|
||||
{
|
||||
CLI::write();
|
||||
CLI::write('select a numerical index to use the corresponding entry');
|
||||
CLI::write();
|
||||
|
||||
$sumNum = 0;
|
||||
$cfgList = [];
|
||||
@@ -161,11 +161,12 @@ function siteconfig() : void
|
||||
CLI::write($b);
|
||||
|
||||
CLI::write(str_pad("[".CLI::bold($sumNum)."]", 21)."add another php configuration");
|
||||
CLI::write();
|
||||
|
||||
if ($hasEmpty)
|
||||
{
|
||||
CLI::write("please configure the required empty settings", CLI::LOG_WARN);
|
||||
CLI::write();
|
||||
CLI::write("please configure the required empty setings", CLI::LOG_WARN);
|
||||
}
|
||||
|
||||
$inp = ['idx' => ['', false, '/\d/']];
|
||||
@@ -174,8 +175,8 @@ function siteconfig() : void
|
||||
// add new php setting
|
||||
if ($inp['idx'] == $sumNum)
|
||||
{
|
||||
CLI::write();
|
||||
CLI::write("Adding additional php configuration.");
|
||||
CLI::write();
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -185,8 +186,6 @@ function siteconfig() : void
|
||||
);
|
||||
if (CLI::read($setting) && $setting)
|
||||
{
|
||||
CLI::write();
|
||||
|
||||
$key = strtolower($setting['key']);
|
||||
if (ini_get($key) === false || ini_set($key, $setting['val']) === false)
|
||||
{
|
||||
@@ -205,12 +204,13 @@ function siteconfig() : void
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
CLI::write();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
CLI::write();
|
||||
CLI::write("edit canceled! returning to list...", CLI::LOG_INFO);
|
||||
CLI::write();
|
||||
sleep(1);
|
||||
break;
|
||||
}
|
||||
@@ -224,7 +224,6 @@ function siteconfig() : void
|
||||
$key = strtolower($conf['key']);
|
||||
$buff = '';
|
||||
|
||||
CLI::write();
|
||||
$buff .= $conf['flags'] & CON_FLAG_PHP ? " PHP: " : "AOWOW: ";
|
||||
$buff .= $conf['flags'] & CON_FLAG_PHP ? $key : strtoupper('cfg_'.$conf['key']);
|
||||
|
||||
@@ -232,6 +231,7 @@ function siteconfig() : void
|
||||
$buff .= " - ".$info[1];
|
||||
|
||||
CLI::write($buff);
|
||||
CLI::write();
|
||||
|
||||
$buff = "VALUE: ";
|
||||
|
||||
@@ -270,6 +270,8 @@ function siteconfig() : void
|
||||
if (strstr($info[0], 'default:'))
|
||||
CLI::write("[".CLI::bold('R')."]estore Default - ".trim(explode('default:', $info[0])[1]));
|
||||
|
||||
CLI::write();
|
||||
|
||||
while (true)
|
||||
{
|
||||
$action = ['idx' => ['', true, '/[edr]/i']];
|
||||
@@ -306,7 +308,7 @@ function siteconfig() : void
|
||||
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; };
|
||||
$validate = function ($v) use($_valid) { $v = ($v ?: 0) & $_valid; return $v; };
|
||||
}
|
||||
else if ($conf['flags'] & CON_FLAG_TYPE_BOOL)
|
||||
{
|
||||
@@ -395,8 +397,8 @@ function siteconfig() : void
|
||||
}
|
||||
else
|
||||
{
|
||||
CLI::write();
|
||||
CLI::write('edit canceled! returning to list...', CLI::LOG_INFO);
|
||||
CLI::write();
|
||||
sleep(1);
|
||||
break;
|
||||
}
|
||||
@@ -404,15 +406,15 @@ function siteconfig() : void
|
||||
}
|
||||
else
|
||||
{
|
||||
CLI::write();
|
||||
CLI::write('invalid selection', CLI::LOG_ERROR);
|
||||
CLI::write();
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CLI::write();
|
||||
CLI::write('leaving site configuration...', CLI::LOG_INFO);
|
||||
CLI::write();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ if (!CLI)
|
||||
if ($ok)
|
||||
{
|
||||
chmod($name.'.'.$ext, Util::FILE_ACCESS);
|
||||
CLI::write($done.' - image '.$name.'.'.$ext.' written', CLI::LOG_OK);
|
||||
CLI::write($done.' - image '.$name.'.'.$ext.' written', CLI::LOG_OK, true, true);
|
||||
}
|
||||
else
|
||||
CLI::write($done.' - could not create image '.$name.'.'.$ext, CLI::LOG_ERROR);
|
||||
@@ -314,7 +314,7 @@ if (!CLI)
|
||||
|
||||
if (!CLISetup::getOpt('force') && file_exists($name.'.jpg'))
|
||||
{
|
||||
CLI::write($done.' - file '.$name.'.jpg was already processed');
|
||||
CLI::write($done.' - file '.$name.'.jpg was already processed', CLI::LOG_BLANK, true, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -566,7 +566,7 @@ if (!CLI)
|
||||
|
||||
if (!CLISetup::getOpt('force') && file_exists($outFile[$idx].'.'.$info[1]))
|
||||
{
|
||||
CLI::write($progress.' - file '.$outFile[$idx].'.'.$info[1].' was already processed');
|
||||
CLI::write($progress.' - file '.$outFile[$idx].'.'.$info[1].' was already processed', CLI::LOG_BLANK, true, true);
|
||||
$doSkip |= (1 << $idx);
|
||||
}
|
||||
}
|
||||
@@ -615,7 +615,7 @@ if (!CLI)
|
||||
$outFile[$idx] = $destDir . sprintf($info[0], strtolower(Util::$localeStrings[$l]).'/') . $row['areaTableId'];
|
||||
if (!CLISetup::getOpt('force') && file_exists($outFile[$idx].'.'.$info[1]))
|
||||
{
|
||||
CLI::write($progress.' - file '.$outFile[$idx].'.'.$info[1].' was already processed');
|
||||
CLI::write($progress.' - file '.$outFile[$idx].'.'.$info[1].' was already processed', CLI::LOG_BLANK, true, true);
|
||||
$doSkip |= (1 << $idx);
|
||||
}
|
||||
}
|
||||
@@ -715,7 +715,7 @@ if (!CLI)
|
||||
|
||||
if (!CLISetup::getOpt('force') && file_exists($name.'.png'))
|
||||
{
|
||||
CLI::write($done.' - file '.$name.'.png was already processed');
|
||||
CLI::write($done.' - file '.$name.'.png was already processed', CLI::LOG_BLANK, true, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ if (!CLI)
|
||||
if ($ok)
|
||||
{
|
||||
chmod($name.$ext, Util::FILE_ACCESS);
|
||||
CLI::write($done.' - image '.$name.$ext.' written', CLI::LOG_OK);
|
||||
CLI::write($done.' - image '.$name.$ext.' written', CLI::LOG_OK, true, true);
|
||||
}
|
||||
else
|
||||
CLI::write($done.' - could not create image '.$name.$ext, CLI::LOG_ERROR);
|
||||
@@ -347,7 +347,7 @@ if (!CLI)
|
||||
|
||||
if (!CLISetup::getOpt('force') && file_exists($destDir.$dest.$img.$ext))
|
||||
{
|
||||
CLI::write($done.' - file '.$dest.$img.$ext.' was already processed');
|
||||
CLI::write($done.' - file '.$dest.$img.$ext.' was already processed', CLI::LOG_BLANK, true, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -416,7 +416,7 @@ if (!CLI)
|
||||
|
||||
if (!CLISetup::getOpt('force') && file_exists($destDir.$dest.$img.$ext))
|
||||
{
|
||||
CLI::write($done.' - file '.$dest.$img.$ext.' was already processed');
|
||||
CLI::write($done.' - file '.$dest.$img.$ext.' was already processed', CLI::LOG_BLANK, true, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,16 +13,21 @@ if (!CLI)
|
||||
// ALL files
|
||||
$files = DB::Aowow()->selectCol('SELECT ABS(id) AS ARRAY_KEY, CONCAT(path, "/", `file`) FROM ?_sounds_files');
|
||||
$nFiles = count($files);
|
||||
$itr = $i = 0;
|
||||
$step = 1000;
|
||||
$qtLen = strlen($nFiles);
|
||||
$sum = 0;
|
||||
|
||||
$intv = 0.5;
|
||||
$time = microtime(true);
|
||||
$sum = 0;
|
||||
|
||||
foreach ($files as $fileId => $filePath)
|
||||
{
|
||||
$i++;
|
||||
$itr++;
|
||||
if ($i == $step)
|
||||
$sum++;
|
||||
$newTime = microtime(true);
|
||||
if ($newTime > $time + $intv)
|
||||
{
|
||||
$i = 0;
|
||||
CLI::write(' - '.$itr.'/'.$nFiles.' ('.(intVal(100 * $itr / $nFiles).'%) done'));
|
||||
CLI::write(sprintf(' * %'.$qtLen.'d / %d (%4.1f%%)', $sum, $nFiles, round(100 * $sum / $nFiles, 1)), CLI::LOG_BLANK, true, true);
|
||||
$time = $newTime;
|
||||
DB::Aowow()->selectCell('SELECT 1'); // keep mysql busy or it may go away
|
||||
}
|
||||
|
||||
@@ -42,6 +47,7 @@ if (!CLI)
|
||||
{
|
||||
$ok = false;
|
||||
CLI::write(' - could not copy '.CLI::bold($p).' into '.CLI::bold('static/wowsounds/'.$fileId), CLI::LOG_ERROR);
|
||||
$time = 0;
|
||||
break 2;
|
||||
}
|
||||
|
||||
@@ -50,6 +56,7 @@ if (!CLI)
|
||||
}
|
||||
|
||||
CLI::write(' - did not find file: '.CLI::bold(CLI::nicePath($filePath, CLISetup::$srcDir, '['.implode(',', CLISetup::$locales).']')), CLI::LOG_WARN);
|
||||
$time = 0;
|
||||
// flag as unusable in DB
|
||||
DB::Aowow()->query('UPDATE ?_sounds_files SET id = ?d WHERE ABS(id) = ?d', -$fileId, $fileId);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ if (!CLI)
|
||||
}
|
||||
|
||||
if (@imagejpeg($res, $outFile))
|
||||
CLI::write(sprintf(ERR_NONE, CLI::bold($outFile)), CLI::LOG_OK);
|
||||
CLI::write(sprintf(ERR_NONE, CLI::bold($outFile)), CLI::LOG_OK, true, true);
|
||||
else
|
||||
{
|
||||
$success = false;
|
||||
|
||||
@@ -124,8 +124,6 @@ SqlGen::register(new class extends SetupScript
|
||||
WHERE
|
||||
ct.entry IN (?a)
|
||||
}
|
||||
ORDER BY
|
||||
ct.entry ASC
|
||||
LIMIT
|
||||
?d, ?d';
|
||||
|
||||
@@ -160,7 +158,7 @@ SqlGen::register(new class extends SetupScript
|
||||
DB::Aowow()->query('TRUNCATE ?_creature');
|
||||
while ($npcs = DB::World()->select($baseQuery, NPC_CU_INSTANCE_BOSS, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize))
|
||||
{
|
||||
CLI::write(' * batch #' . ++$i . ' (' . count($npcs) . ')');
|
||||
CLI::write(' * batch #' . ++$i . ' (' . count($npcs) . ')', CLI::LOG_BLANK, true, true);
|
||||
|
||||
foreach ($npcs as $npc)
|
||||
DB::Aowow()->query('INSERT INTO ?_creature VALUES (?a)', array_values($npc));
|
||||
|
||||
@@ -28,9 +28,7 @@ SqlGen::register(new class extends SetupScript
|
||||
(SELECT LOWER(SUBSTRING_INDEX(iconString, "\\\\", -1)) AS x FROM dbc_creaturefamily WHERE iconString LIKE "%icons%")
|
||||
) y
|
||||
GROUP BY
|
||||
x
|
||||
ORDER BY
|
||||
x ASC';
|
||||
x';
|
||||
|
||||
DB::Aowow()->query($baseQuery);
|
||||
|
||||
|
||||
@@ -252,18 +252,16 @@ SqlGen::register(new class extends SetupScript
|
||||
CLI::write(' '.count($enchStats).' enchantments parsed');
|
||||
CLI::write(' - applying stats for items');
|
||||
|
||||
$i = 0;
|
||||
while (true)
|
||||
{
|
||||
$items = new ItemStatSetup($offset, SqlGen::$sqlBatchSize, $ids, $enchStats);
|
||||
if ($items->error)
|
||||
break;
|
||||
|
||||
$max = max($items->getFoundIDs());
|
||||
$num = count($items->getFoundIDs());
|
||||
CLI::write(' * batch #' . ++$i . ' (' . count($items->getFoundIDs()) . ')', CLI::LOG_BLANK, true, true);
|
||||
|
||||
CLI::write(' * sets '.($offset + 1).' - '.($max));
|
||||
|
||||
$offset = $max;
|
||||
$offset = max($items->getFoundIDs());
|
||||
|
||||
$items->writeStatsTable();
|
||||
}
|
||||
|
||||
@@ -135,8 +135,6 @@ SqlGen::register(new class extends SetupScript
|
||||
WHERE
|
||||
it.entry IN (?a)
|
||||
}
|
||||
ORDER BY
|
||||
it.entry ASC
|
||||
LIMIT
|
||||
?d, ?d';
|
||||
|
||||
@@ -144,7 +142,7 @@ SqlGen::register(new class extends SetupScript
|
||||
DB::Aowow()->query('TRUNCATE ?_items');
|
||||
while ($items = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize))
|
||||
{
|
||||
CLI::write(' * batch #' . ++$i . ' (' . count($items) . ')');
|
||||
CLI::write(' * batch #' . ++$i . ' (' . count($items) . ')', CLI::LOG_BLANK, true, true);
|
||||
|
||||
foreach ($items as $item)
|
||||
DB::Aowow()->query('INSERT INTO ?_items VALUES (?a)', array_values($item));
|
||||
|
||||
@@ -82,8 +82,6 @@ SqlGen::register(new class extends SetupScript
|
||||
}
|
||||
GROUP BY
|
||||
go.entry
|
||||
ORDER BY
|
||||
go.entry ASC
|
||||
LIMIT
|
||||
?d, ?d';
|
||||
|
||||
@@ -107,7 +105,7 @@ SqlGen::register(new class extends SetupScript
|
||||
DB::Aowow()->query('TRUNCATE ?_objects');
|
||||
while ($objects = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize))
|
||||
{
|
||||
CLI::write(' * batch #' . ++$i . ' (' . count($objects) . ')');
|
||||
CLI::write(' * batch #' . ++$i . ' (' . count($objects) . ')', CLI::LOG_BLANK, true, true);
|
||||
|
||||
foreach ($objects as $object)
|
||||
DB::Aowow()->query('INSERT INTO ?_objects VALUES (?a)', array_values($object));
|
||||
|
||||
@@ -133,8 +133,6 @@ SqlGen::register(new class extends SetupScript
|
||||
WHERE
|
||||
q.ID IN (?a)
|
||||
}
|
||||
ORDER BY
|
||||
q.ID ASC
|
||||
LIMIT
|
||||
?d, ?d';
|
||||
|
||||
@@ -174,7 +172,7 @@ SqlGen::register(new class extends SetupScript
|
||||
DB::Aowow()->query('TRUNCATE ?_quests');
|
||||
while ($quests = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize))
|
||||
{
|
||||
CLI::write(' * batch #' . ++$i . ' (' . count($quests) . ')');
|
||||
CLI::write(' * batch #' . ++$i . ' (' . count($quests) . ')', CLI::LOG_BLANK, true, true);
|
||||
|
||||
foreach ($quests as $quest)
|
||||
DB::Aowow()->query('INSERT INTO ?_quests VALUES (?a)', array_values($quest));
|
||||
|
||||
@@ -72,11 +72,12 @@ SqlGen::register(new class extends SetupScript
|
||||
$lastMax = 0;
|
||||
$soundFileIdx = 0;
|
||||
$soundIndex = [];
|
||||
$j = 0;
|
||||
while ($sounds = DB::Aowow()->select($query, $lastMax, SqlGen::$sqlBatchSize))
|
||||
{
|
||||
$newMax = max(array_column($sounds, 'id'));
|
||||
|
||||
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
CLI::write(' * batch #' . ++$j . ' (' . count($sounds) . ')', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$lastMax = $newMax;
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ SqlGen::register(new class extends SetupScript
|
||||
# also everything from items that teach spells, is src of spell
|
||||
# todo: check if items have learn-spells (effect: 36)
|
||||
|
||||
CLI::write(' * resolve ref-loot tree');
|
||||
CLI::write(' * resolve ref-loot tree', CLI::LOG_BLANK, true, true);
|
||||
$refLoot = DB::World()->select('
|
||||
SELECT
|
||||
rlt.Entry AS ARRAY_KEY,
|
||||
@@ -135,7 +135,7 @@ SqlGen::register(new class extends SetupScript
|
||||
###############
|
||||
# 1: Crafted #
|
||||
###############
|
||||
CLI::write(' * #1 Crafted');
|
||||
CLI::write(' * #1 Crafted', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -176,7 +176,7 @@ SqlGen::register(new class extends SetupScript
|
||||
############
|
||||
# 2: Drop #
|
||||
############
|
||||
CLI::write(' * #2 Drop');
|
||||
CLI::write(' * #2 Drop', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -318,7 +318,7 @@ SqlGen::register(new class extends SetupScript
|
||||
###########
|
||||
# 3: PvP # (Vendors w/ xCost Arena/Honor)
|
||||
###########
|
||||
CLI::write(' * #3 PvP');
|
||||
CLI::write(' * #3 PvP', CLI::LOG_BLANK, true, true);
|
||||
|
||||
// var g_sources_pvp = {
|
||||
// 1: 'Arena',
|
||||
@@ -363,7 +363,7 @@ SqlGen::register(new class extends SetupScript
|
||||
#############
|
||||
# 4: Quest #
|
||||
#############
|
||||
CLI::write(' * #4 Quest');
|
||||
CLI::write(' * #4 Quest', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -445,7 +445,7 @@ SqlGen::register(new class extends SetupScript
|
||||
##############
|
||||
# 5: Vendor # (w/o xCost Arena/Honor)
|
||||
##############
|
||||
CLI::write(' * #5 Vendor');
|
||||
CLI::write(' * #5 Vendor', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -479,7 +479,7 @@ SqlGen::register(new class extends SetupScript
|
||||
###############
|
||||
# 10: Starter #
|
||||
###############
|
||||
CLI::write(' * #10 Starter');
|
||||
CLI::write(' * #10 Starter', CLI::LOG_BLANK, true, true);
|
||||
|
||||
if ($pcii = DB::World()->select('SELECT ?d, itemid, 1 FROM playercreateinfo_item', Type::ITEM))
|
||||
DB::Aowow()->query($this->queryfy($pcii, $insBasic), 10, 10, 10);
|
||||
@@ -491,7 +491,7 @@ SqlGen::register(new class extends SetupScript
|
||||
###################
|
||||
# 12: Achievement #
|
||||
###################
|
||||
CLI::write(' * #12 Achievement');
|
||||
CLI::write(' * #12 Achievement', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -553,7 +553,7 @@ SqlGen::register(new class extends SetupScript
|
||||
####################
|
||||
# 15: Disenchanted #
|
||||
####################
|
||||
CLI::write(' * #15 Disenchanted');
|
||||
CLI::write(' * #15 Disenchanted', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -606,7 +606,7 @@ SqlGen::register(new class extends SetupScript
|
||||
##############
|
||||
# 16: Fished #
|
||||
##############
|
||||
CLI::write(' * #16 Fished');
|
||||
CLI::write(' * #16 Fished', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -657,7 +657,7 @@ SqlGen::register(new class extends SetupScript
|
||||
################
|
||||
# 17: Gathered #
|
||||
################
|
||||
CLI::write(' * #17 Gathered');
|
||||
CLI::write(' * #17 Gathered', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -712,7 +712,7 @@ SqlGen::register(new class extends SetupScript
|
||||
##############
|
||||
# 18: Milled #
|
||||
##############
|
||||
CLI::write(' * #18 Milled');
|
||||
CLI::write(' * #18 Milled', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -763,7 +763,7 @@ SqlGen::register(new class extends SetupScript
|
||||
#############
|
||||
# 19: Mined #
|
||||
#############
|
||||
CLI::write(' * #19 Mined');
|
||||
CLI::write(' * #19 Mined', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -818,7 +818,7 @@ SqlGen::register(new class extends SetupScript
|
||||
##################
|
||||
# 20: Prospected #
|
||||
##################
|
||||
CLI::write(' * #20 Prospected');
|
||||
CLI::write(' * #20 Prospected', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -869,7 +869,7 @@ SqlGen::register(new class extends SetupScript
|
||||
##################
|
||||
# 21: Pickpocket #
|
||||
##################
|
||||
CLI::write(' * #21 Pickpocket');
|
||||
CLI::write(' * #21 Pickpocket', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -919,7 +919,7 @@ SqlGen::register(new class extends SetupScript
|
||||
################
|
||||
# 22: Salvaged #
|
||||
################
|
||||
CLI::write(' * #22 Salvaged');
|
||||
CLI::write(' * #22 Salvaged', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -970,7 +970,7 @@ SqlGen::register(new class extends SetupScript
|
||||
###############
|
||||
# 23: Skinned #
|
||||
###############
|
||||
CLI::write(' * #23 Skinned');
|
||||
CLI::write(' * #23 Skinned', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$spellBuff = [];
|
||||
$itemBuff = [];
|
||||
@@ -1029,7 +1029,7 @@ SqlGen::register(new class extends SetupScript
|
||||
CLI::write(' - Spells [original]');
|
||||
|
||||
# 4: Quest
|
||||
CLI::write(' * #4 Quest');
|
||||
CLI::write(' * #4 Quest', CLI::LOG_BLANK, true, true);
|
||||
$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
|
||||
@@ -1051,7 +1051,7 @@ SqlGen::register(new class extends SetupScript
|
||||
}
|
||||
|
||||
# 6: Trainer
|
||||
CLI::write(' * #6 Trainer');
|
||||
CLI::write(' * #6 Trainer', CLI::LOG_BLANK, true, true);
|
||||
if ($tNpcs = DB::World()->select('SELECT SpellID AS ARRAY_KEY, cdt.CreatureId AS entry, COUNT(1) AS qty FROM `trainer_spell` ts JOIN `creature_default_trainer` cdt ON cdt.TrainerId = ts.TrainerId 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));
|
||||
@@ -1077,13 +1077,13 @@ SqlGen::register(new class extends SetupScript
|
||||
}
|
||||
|
||||
# 7: Discovery
|
||||
CLI::write(' * #7 Discovery');
|
||||
CLI::write(' * #7 Discovery', CLI::LOG_BLANK, true, true);
|
||||
// 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($this->queryfy($disco, $insBasic), 7, 7, 7);
|
||||
|
||||
# 9: Talent
|
||||
CLI::write(' * #9 Talent');
|
||||
CLI::write(' * #9 Talent', CLI::LOG_BLANK, true, true);
|
||||
$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
|
||||
@@ -1095,7 +1095,7 @@ SqlGen::register(new class extends SetupScript
|
||||
$buff = [];
|
||||
while ($tSpells)
|
||||
{
|
||||
CLI::write(' - '.++$n.'. pass');
|
||||
CLI::write(' - '.++$n.'. pass', CLI::LOG_BLANK, true, true);
|
||||
|
||||
$recurse = [];
|
||||
foreach ($tSpells as $tId => $spell)
|
||||
@@ -1120,7 +1120,7 @@ SqlGen::register(new class extends SetupScript
|
||||
DB::Aowow()->query($this->queryfy($buff, $insBasic), 9, 9, 9);
|
||||
|
||||
# 10: Starter
|
||||
CLI::write(' * #10 Starter');
|
||||
CLI::write(' * #10 Starter', CLI::LOG_BLANK, true, true);
|
||||
/* acquireMethod
|
||||
ABILITY_LEARNED_ON_GET_PROFESSION_SKILL = 1, learnedAt = 1 && source10 = 1
|
||||
ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL = 2
|
||||
@@ -1138,12 +1138,12 @@ SqlGen::register(new class extends SetupScript
|
||||
CLI::write(' - Titles');
|
||||
|
||||
# 4: Quest
|
||||
CLI::write(' * #4 Quest');
|
||||
CLI::write(' * #4 Quest', CLI::LOG_BLANK, true, true);
|
||||
if ($quests = DB::World()->select('SELECT ?d, RewardTitle, 1, ?d, ID FROM quest_template WHERE RewardTitle > 0', Type::TITLE, Type::QUEST))
|
||||
DB::Aowow()->query($this->queryfy($quests, $insMore), 4, 4, 4);
|
||||
|
||||
# 12: Achievement
|
||||
CLI::write(' * #12 Achievement');
|
||||
CLI::write(' * #12 Achievement', CLI::LOG_BLANK, true, true);
|
||||
$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
|
||||
@@ -1160,7 +1160,7 @@ SqlGen::register(new class extends SetupScript
|
||||
}
|
||||
|
||||
# 13: Source-String
|
||||
CLI::write(' * #13 cuStrings');
|
||||
CLI::write(' * #13 cuStrings', CLI::LOG_BLANK, true, true);
|
||||
$src13 = [null, 42, 52, 71, 80, 157, 163, 167, 169, 177];
|
||||
foreach ($src13 as $src => $tId)
|
||||
if ($tId)
|
||||
|
||||
@@ -19,31 +19,31 @@ SqlGen::register(new class extends SetupScript
|
||||
private $querys = array(
|
||||
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 creature spawns', Type::NPC],
|
||||
'creature spawns', Type::NPC],
|
||||
|
||||
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 gameobject spawns', Type::OBJECT],
|
||||
'gameobject spawns', Type::OBJECT],
|
||||
|
||||
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 sound emitter spawns', Type::SOUND],
|
||||
'sound emitter spawns', Type::SOUND],
|
||||
|
||||
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 areatrigger spawns', Type::AREATRIGGER],
|
||||
'areatrigger spawns', Type::AREATRIGGER],
|
||||
|
||||
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 table script_waypoint', Type::NPC],
|
||||
'script_waypoint table', Type::NPC],
|
||||
|
||||
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 table waypoints', Type::NPC],
|
||||
'waypoints table', Type::NPC],
|
||||
|
||||
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 table waypoint_data', Type::NPC]
|
||||
'waypoint_data table', Type::NPC]
|
||||
);
|
||||
|
||||
public function generate(array $ids = []) : bool
|
||||
@@ -78,9 +78,8 @@ SqlGen::register(new class extends SetupScript
|
||||
|
||||
foreach ($this->querys as $idx => $q)
|
||||
{
|
||||
CLI::write($q[1]);
|
||||
|
||||
$n = 0;
|
||||
$intv = 0.5;
|
||||
$time = microtime(true);
|
||||
$sum = 0;
|
||||
|
||||
if ($idx == 3 || $idx == 4)
|
||||
@@ -88,14 +87,22 @@ SqlGen::register(new class extends SetupScript
|
||||
else
|
||||
$queryResult = DB::World()->select($q[0]);
|
||||
|
||||
$qryProgress = array_combine(array_keys($this->querys), array_column($this->querys, 1));
|
||||
array_walk($qryProgress, function (&$v, $k) use ($idx) { if ($idx == $k) $v = CLI::bold('<'.$v.'>'); });
|
||||
$qryProgress = ' ['.implode(', ', $qryProgress).']';
|
||||
|
||||
$qryTotal = count($queryResult);
|
||||
$qtLen = strlen($qryTotal);
|
||||
$doneGUID = 0;
|
||||
foreach ($queryResult as $spawn)
|
||||
{
|
||||
if (!$n)
|
||||
CLI::write(' * sets '.($sum + 1).' - '.($sum += SqlGen::$sqlBatchSize));
|
||||
|
||||
if ($n++ > SqlGen::$sqlBatchSize)
|
||||
$n = 0;
|
||||
$sum++;
|
||||
$newTime = microtime(true);
|
||||
if ($newTime > $time + $intv)
|
||||
{
|
||||
CLI::write(sprintf(' * %'.$qtLen.'d / %d (%4.1f%%)', $sum, $qryTotal, round(100 * $sum / $qryTotal, 1)) . $qryProgress, CLI::LOG_BLANK, true, true);
|
||||
$time = $newTime;
|
||||
}
|
||||
|
||||
// npc/object is on a transport -> apply offsets to path of transport
|
||||
// note, that the coordinates are mixed up .. again
|
||||
@@ -116,6 +123,7 @@ SqlGen::register(new class extends SetupScript
|
||||
if ($doneGUID != $spawn['guid'])
|
||||
{
|
||||
CLI::write('GUID '.$spawn['guid'].' was manually moved [A:'.$spawn['areaId'].' => '.$area.'; F: '.$floor.']', CLI::LOG_INFO);
|
||||
$time = 0; // force refresh progress
|
||||
$doneGUID = $spawn['guid']; // do not spam on waypoints
|
||||
}
|
||||
}
|
||||
@@ -129,6 +137,7 @@ SqlGen::register(new class extends SetupScript
|
||||
if (!$area)
|
||||
{
|
||||
CLI::write('tried to default GUID '.$spawn['guid'].' to instanced area by mapId, but returned empty [M:'.$spawn['map'].']', CLI::LOG_WARN);
|
||||
$time = 0; // force refresh progress
|
||||
continue;
|
||||
}
|
||||
$final = ['areaId' => $area, 'posX' => 0, 'posY' => 0, 'floor' => 0];
|
||||
@@ -136,11 +145,13 @@ SqlGen::register(new class extends SetupScript
|
||||
else if (!$points) // still impossible (there are areas that are intentionally off the map (e.g. the isles south of tanaris))
|
||||
{
|
||||
CLI::write('GUID '.$spawn['guid'].($idx < 5 ? '' : ' on path/point '.$spawn['npcOrPath'].'/'.$spawn['point']).' could not be matched to displayable area [A:'.$area.'; X:'.$spawn['posY'].'; Y:'.$spawn['posX'].']', CLI::LOG_WARN);
|
||||
$time = 0; // force refresh progress
|
||||
continue;
|
||||
}
|
||||
else // if areaId is set, area was determined by TC .. we're fine .. mostly
|
||||
{
|
||||
if (in_array($spawn['map'], [564, 580])) // Black Temple and Sunwell floor offset bullshit
|
||||
// Black Temple and Sunwell floor offset bullshit
|
||||
if (in_array($spawn['map'], [564, 580]))
|
||||
$points[0]['floor']++;
|
||||
|
||||
$final = $area ? $points[0] : Game::checkCoords($points);
|
||||
@@ -219,7 +230,7 @@ SqlGen::register(new class extends SetupScript
|
||||
}
|
||||
}
|
||||
if ($matches)
|
||||
CLI::write(' * assigned '.$matches.' accessories on '.++$n.'. pass on vehicle accessories');
|
||||
CLI::write(' * assigned '.$matches.' accessories on '.++$n.'. pass on vehicle accessories', CLI::LOG_BLANK, true, true);
|
||||
}
|
||||
if ($accessories)
|
||||
CLI::write(count($accessories).' accessories could not be fitted onto a spawned vehicle.', CLI::LOG_WARN);
|
||||
|
||||
@@ -208,7 +208,7 @@ SqlGen::register(new class extends SetupScript
|
||||
{
|
||||
$newMax = max(array_column($spells, 'id'));
|
||||
|
||||
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax, CLI::LOG_BLANK, true, true);
|
||||
|
||||
$lastMax = $newMax;
|
||||
|
||||
@@ -226,7 +226,7 @@ SqlGen::register(new class extends SetupScript
|
||||
{
|
||||
$newMax = max(array_column($spells, 'id'));
|
||||
|
||||
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax);
|
||||
CLI::write(' * sets '.($lastMax + 1).' - '.$newMax, CLI::LOG_BLANK, true, true);
|
||||
|
||||
$lastMax = $newMax;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user