DB/Dependency

* remove unmaintained DbSimple
 * add package db/dibi as substitute db abstraction
This commit is contained in:
Sarjuuk 2026-01-05 18:34:19 +01:00
parent 8a404b32aa
commit 69df50619a
254 changed files with 3234 additions and 5566 deletions

View file

@ -651,7 +651,7 @@ class CLISetup
return false;
}
if (DB::Aowow()->selectCell('SHOW TABLES LIKE ?', 'dbc_'.$name) && DB::Aowow()->selectCell('SELECT count(1) FROM ?#', 'dbc_'.$name))
if (DB::Aowow()->selectCell('SHOW TABLES LIKE %s', 'dbc_'.$name) && DB::Aowow()->selectCell('SELECT count(1) FROM %n', 'dbc_'.$name))
return true;
$dbc = new DBC($name, ['temporary' => self::getOpt('delete')]);

View file

@ -64,16 +64,16 @@ CLISetup::registerUtility(new class extends UtilityScript
else
$email = '';
if ($this->fields && CLI::read($this->fields, $uiAccount))
if ($this->fields && CLI::read($this->fields, $uiAccount) && $uiAccount)
{
CLI::write();
if (!$name && !Util::validateUsername($uiAccount['name'], $e))
if (!$name && !Util::validateUsername($uiAccount['name'], $e) && $e)
CLI::write(Lang::account($e == 1 ? 'errNameLength' : 'errNameChars'), CLI::LOG_ERROR);
else if (!$name)
$name = $uiAccount['name'];
if (!$passw && !Util::validatePassword($uiAccount['pass1'], $e))
if (!$passw && !Util::validatePassword($uiAccount['pass1'], $e) && $e)
CLI::write($e == 1 ? Lang::account('errPassLength') : Lang::main('intError'), CLI::LOG_ERROR);
else if (!$passw && $uiAccount['pass1'] != $uiAccount['pass2'])
CLI::write(Lang::account('passMismatch'), CLI::LOG_ERROR);
@ -99,17 +99,17 @@ CLISetup::registerUtility(new class extends UtilityScript
if (!$name || !$passw || !$email)
return false;
if ($username = DB::Aowow()->selectCell('SELECT `username` FROM ?_account WHERE (LOWER(`username`) = LOWER(?) OR LOWER(`email`) = LOWER(?)) AND (`status` <> ?d OR (`status` = ?d AND `statusTimer` > UNIX_TIMESTAMP()))', $name, $email, ACC_STATUS_NEW, ACC_STATUS_NEW))
if ($username = DB::Aowow()->selectCell('SELECT `username` FROM ::account WHERE (LOWER(`username`) = LOWER(%s) OR LOWER(`email`) = LOWER(%s)) AND (`status` <> %i OR (`status` = %i AND `statusTimer` > UNIX_TIMESTAMP()))', $name, $email, ACC_STATUS_NEW, ACC_STATUS_NEW))
{
CLI::write('[account] ' . (Util::lower($name) == Util::lower($username) ? Lang::account('nameInUse') : Lang::account('mailInUse')), CLI::LOG_ERROR);
CLI::write();
return false;
}
if (DB::Aowow()->query('REPLACE INTO ?_account (`login`, `passHash`, `username`, `joindate`, `email`, `userGroups`, `userPerms`) VALUES (?, ?, ?, UNIX_TIMESTAMP(), ?, ?d, 1)',
if (DB::Aowow()->qry('REPLACE INTO ::account (`login`, `passHash`, `username`, `joindate`, `email`, `userGroups`, `userPerms`) VALUES (%s, %s, %s, UNIX_TIMESTAMP(), %s, %i, 1)',
$name, User::hashCrypt($passw), $name, $email, U_GROUP_ADMIN))
{
$newId = DB::Aowow()->selectCell('SELECT `id` FROM ?_account WHERE LOWER(`username`) = LOWER(?)', $name);
$newId = DB::Aowow()->selectCell('SELECT `id` FROM ::account WHERE LOWER(`username`) = LOWER(%s)', $name);
Util::gainSiteReputation($newId, SITEREP_ACTION_REGISTER);
CLI::write("[account] admin ".$name." created successfully", CLI::LOG_OK);
@ -127,7 +127,7 @@ CLISetup::registerUtility(new class extends UtilityScript
public function test(?array &$error = []) : bool
{
$error = [];
return !!DB::Aowow()->selectCell('SELECT `id` FROM ?_account WHERE `userPerms` = 1');
return !!DB::Aowow()->selectCell('SELECT `id` FROM ::account WHERE `userPerms` = 1');
}
});

View file

@ -111,6 +111,14 @@ CLISetup::registerUtility(new class extends UtilityScript
CLI::write('[sql] subscript \''.$cmd.'\' returned '.($success ? 'successfully' : 'with errors'), $success ? CLI::LOG_OK : CLI::LOG_ERROR);
CLI::write();
set_time_limit($this->defaultExecTime); // reset to default for the next script
// try to free memory
unset($scriptRef, $this->generators[$cmd]);
if (gc_enabled())
{
gc_collect_cycles();
gc_mem_caches();
}
}
return $allOk;

View file

@ -86,7 +86,7 @@ CLISetup::registerUtility(new class extends UtilityScript
CLI::write();
if (!DB::isConnectable(DB_AUTH) || !$this->test())
CLI::write('[db] auth server not yet set up.', CLI::LOG_ERROR);
else if ($realms = DB::Auth()->select('SELECT `id` AS "0", `name` AS "1", `icon` AS "2", `timezone` AS "3", `allowedSecurityLevel` AS "4" FROM realmlist'))
else if ($realms = DB::Auth()->selectAssoc('SELECT `id` AS "0", `name` AS "1", `icon` AS "2", `timezone` AS "3", `allowedSecurityLevel` AS "4" FROM realmlist'))
{
$tbl = [['Realm Id', 'Name', 'Type', 'Region', 'GMLevel', 'Status']];
foreach ($realms as [$id, $name, $icon, $region, $level])
@ -216,13 +216,13 @@ CLISetup::registerUtility(new class extends UtilityScript
switch ($idx)
{
case DB_AOWOW:
if (DB::Aowow()->selectCell('SHOW TABLES LIKE ?', 'aowow_dbversion'))
if (DB::Aowow()->selectCell('SHOW TABLES LIKE %s', 'aowow_dbversion'))
Cfg::load(); // first time load after successful db setup
else
$error[] = ' * '.$what.': doesn\'t seem to contain aowow tables!';
break;
case DB_WORLD:
if (!DB::World()->selectCell('SHOW TABLES LIKE ?', 'version'))
if (!DB::World()->selectCell('SHOW TABLES LIKE %s', 'version'))
$error[] = ' * '.$what.': doesn\'t seem to contain TrinityCore world tables!';
else if (DB::World()->selectCell('SELECT `cache_id` FROM `version`') < TDB_WORLD_MINIMUM_VER)
$error[] = ' * '.$what.': TDB world db is structurally outdated! (min rev.: '.CLI::bold(TDB_WORLD_MINIMUM_VER).')';
@ -255,9 +255,9 @@ CLISetup::registerUtility(new class extends UtilityScript
switch ($idx)
{
case DB_AOWOW:
if (DB::Aowow()->selectCell('SHOW TABLES LIKE ?', 'aowow_dbversion'))
if (DB::Aowow()->selectCell('SHOW TABLES LIKE %s', 'aowow_dbversion'))
{
if ($date = DB::Aowow()->selectCell('SELECT `date` FROM ?_dbversion'))
if ($date = DB::Aowow()->selectCell('SELECT `date` FROM ::dbversion'))
{
$note = 'AoWoW DB version @ ' . date(Util::$dateFormatInternal, $date);
$ok = true;
@ -269,7 +269,7 @@ CLISetup::registerUtility(new class extends UtilityScript
$note = CLI::yellow('DB test failed to find dbversion table. ').CLI::bold('setup/sql/01-db_structure.sql').CLI::yellow(' not yet imported?');
break;
case DB_WORLD:
if (DB::World()->selectCell('SHOW TABLES LIKE ?', 'version'))
if (DB::World()->selectCell('SHOW TABLES LIKE %s', 'version'))
{
[$vString, $vNo] = DB::World()->selectRow('SELECT `db_version` AS "0", `cache_id` AS "1" FROM `version`');
if (strpos($vString, 'TDB') === 0)
@ -289,7 +289,7 @@ CLISetup::registerUtility(new class extends UtilityScript
else
$note = CLI::yellow('DB test found unexpected vendor in expected version table. Uhh.. Good Luck..!?');
}
else if (DB::World()->selectCell('SHOW TABLES LIKE ?', 'db_version'))
else if (DB::World()->selectCell('SHOW TABLES LIKE %s', 'db_version'))
$note = CLI::yellow('DB test found MaNGOS styled version table. MaNGOS DB structure is not supported!');
else
$note = CLI::yellow('DB test failed to find version table. TrinityDB world not yet imported?');

View file

@ -126,6 +126,14 @@ CLISetup::registerUtility(new class extends UtilityScript
CLI::write();
set_time_limit($this->defaultExecTime); // reset to default for the next script
// try to free memory
unset($scriptRef, $this->generators[$cmd]);
if (gc_enabled())
{
gc_collect_cycles();
gc_mem_caches();
}
}
return $allOk;

View file

@ -45,14 +45,14 @@ CLISetup::registerUtility(new class extends UtilityScript
{
$io = ['doSql' => $s, 'doneSql' => []];
CLISetup::run('sql', $io);
DB::Aowow()->query('UPDATE ?_dbversion SET `sql` = ?', implode(' ', array_diff($io['doSql'], $io['doneSql'])));
DB::Aowow()->qry('UPDATE ::dbversion SET `sql` = %s', implode(' ', array_diff($io['doSql'], $io['doneSql'])));
}
if ($b)
{
$io = ['doBuild' => $b, 'doneBuild' => []];
CLISetup::run('build', $io);
DB::Aowow()->query('UPDATE ?_dbversion SET `build` = ?', implode(' ', array_diff($io['doBuild'], $io['doneBuild'])));
DB::Aowow()->qry('UPDATE ::dbversion SET `build` = %s', implode(' ', array_diff($io['doBuild'], $io['doneBuild'])));
}
return true;

View file

@ -32,7 +32,7 @@ CLISetup::registerUtility(new class extends UtilityScript
public function __construct()
{
if (DB::isConnected(DB_AOWOW))
[$this->date, $this->part] = array_values(DB::Aowow()->selectRow('SELECT `date`, `part` FROM ?_dbversion'));
[$this->date, $this->part] = array_values(DB::Aowow()->selectRow('SELECT `date`, `part` FROM ::dbversion'));
}
// args: null, null, sqlToDo, buildToDo // nnoo
@ -75,21 +75,21 @@ CLISetup::registerUtility(new class extends UtilityScript
// semicolon at the end -> end of query
if (substr(trim($line), -1, 1) == ';')
{
if (DB::Aowow()->query($updQuery))
if (DB::Aowow()->qry($updQuery))
$nQuerys++;
$updQuery = '';
}
}
DB::Aowow()->query('UPDATE ?_dbversion SET `date`= ?d, `part` = ?d', $fDate, $fPart);
DB::Aowow()->qry('UPDATE ::dbversion SET `date`= %i, `part` = %i', $fDate, $fPart);
CLI::write(' -> '.date('d.m.Y', $fDate).' #'.$fPart.': '.$nQuerys.' queries applied', CLI::LOG_OK);
}
CLI::write('[update] ' . ($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
[$sql, $build] = DB::Aowow()->selectRow('SELECT `sql` AS "0", `build` AS "1" FROM ?_dbversion');
[$sql, $build] = DB::Aowow()->selectRow('SELECT `sql` AS "0", `build` AS "1" FROM ::dbversion');
$sql = trim($sql) ? array_unique(explode(' ', trim(preg_replace('/[^a-z_\-]+/i', ' ', $sql)))) : [];
$build = trim($build) ? array_unique(explode(' ', trim(preg_replace('/[^a-z_\-]+/i', ' ', $build)))) : [];

View file

@ -344,8 +344,8 @@ class DBC
$query .= ') COLLATE=\'utf8mb4_unicode_ci\' ENGINE=InnoDB';
DB::Aowow()->query('DROP TABLE IF EXISTS ?#', $this->tableName);
DB::Aowow()->query($query);
DB::Aowow()->qry('DROP TABLE IF EXISTS %n', $this->tableName);
DB::Aowow()->qry($query);
}
private function writeToDB()
@ -375,7 +375,9 @@ class DBC
if ($this->isGameTable)
array_unshift($cols, 'idx');
DB::Aowow()->query('INSERT INTO ?# (?#) VALUES (?a)', $this->tableName, $cols, $this->dataBuffer);
foreach ($this->dataBuffer as $row)
DB::Aowow()->qry('INSERT INTO %n %v', $this->tableName, array_combine($cols, $row));
$this->dataBuffer = [];
}

View file

@ -67,16 +67,16 @@ CLISetup::registerSetup("build", new class extends SetupScript
$slotPointer = [13, 17, 15, 15, 13, 17, 17, 13, 17, null, 17, null, null, 13, null, 13, null, null, null, null, 17];
$castItems = [];
$enchantSpells = DB::Aowow()->select(
$enchantSpells = DB::Aowow()->selectAssoc(
'SELECT s.`id` AS ARRAY_KEY,
`effect1MiscValue`,
`equippedItemClass`, `equippedItemInventoryTypeMask`, `equippedItemSubClassMask`,
`skillLine1`,
IFNULL(i.`name`, ?) AS "iconString",
IFNULL(i.`name`, %s) AS "iconString",
`name_loc0`, `name_loc2`, `name_loc3`, `name_loc4`, `name_loc6`, `name_loc8`
FROM ?_spell s
LEFT JOIN ?_icons i ON i.`id` = s.`iconId`
WHERE `effect1Id` = ?d AND
FROM ::spell s
LEFT JOIN ::icons i ON i.`id` = s.`iconId`
WHERE `effect1Id` = %i AND
`name_loc0` NOT LIKE "QA%"',
DEFAULT_ICON, SPELL_EFFECT_ENCHANT_ITEM
);
@ -86,7 +86,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
$enchantments = new EnchantmentList(array(['id', $enchIds]));
if ($enchantments->error)
{
CLI::write('[enchants] Required table ?_itemenchantment seems to be empty!', CLI::LOG_ERROR);
CLI::write('[enchants] Required table ::itemenchantment seems to be empty!', CLI::LOG_ERROR);
CLI::write();
return false;
}
@ -94,7 +94,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
$castItems = new ItemList(array(['spellId1', array_keys($enchantSpells)], ['src.typeId', null, '!']));
if ($castItems->error)
{
CLI::write('[enchants] Required table ?_items seems to be empty!', CLI::LOG_ERROR);
CLI::write('[enchants] Required table ::items seems to be empty!', CLI::LOG_ERROR);
CLI::write();
return false;
}

View file

@ -36,18 +36,18 @@ CLISetup::registerSetup("build", new class extends SetupScript
{
// sketchy, but should work
// id < 36'000 || ilevel < 70 ? BC : WOTLK
$gems = DB::Aowow()->select(
$gems = DB::Aowow()->selectAssoc(
'SELECT i.`id` AS "itemId",
i.`name_loc0`, i.`name_loc2`, i.`name_loc3`, i.`name_loc4`, i.`name_loc6`, i.`name_loc8`,
IF (i.`id` < 36000 OR i.`itemLevel` < 70, ?d, ?d) AS "expansion",
IF (i.`id` < 36000 OR i.`itemLevel` < 70, %i, %i) AS "expansion",
i.`quality`,
ic.`name` AS "icon",
i.`gemEnchantmentId` AS "enchId",
i.`gemColorMask` AS "colors",
i.`requiredSkill`,
i.`itemLevel`
FROM ?_items i
JOIN ?_icons ic ON ic.`id` = i.`iconId`
FROM ::items i
JOIN ::icons ic ON ic.`id` = i.`iconId`
WHERE i.`gemEnchantmentId` <> 0
ORDER BY i.`id` DESC',
EXP_BC, EXP_WOTLK
@ -56,7 +56,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
$enchantments = new EnchantmentList(array(['id', array_column($gems, 'enchId')]));
if ($enchantments->error)
{
CLI::write('[gems] Required table ?_itemenchantment seems to be empty!', CLI::LOG_ERROR);
CLI::write('[gems] Required table ::itemenchantment seems to be empty!', CLI::LOG_ERROR);
CLI::write();
return false;
}

View file

@ -33,7 +33,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
public function generate() : bool
{
$glyphList = DB::Aowow()->Select(
$glyphList = DB::Aowow()->selectAssoc(
'SELECT i.`id` AS "itemId",
i.*,
IF (g.`typeFlags` & 0x1, 2, 1) AS "type",
@ -44,12 +44,12 @@ CLISetup::registerSetup("build", new class extends SetupScript
s1.`skillLine1` AS "skillId",
s2.`id` AS "glyphEffect",
s2.`id` AS ARRAY_KEY
FROM ?_items i
JOIN ?_spell s1 ON s1.`id` = i.`spellid1`
JOIN ?_glyphproperties g ON g.`id` = s1.`effect1MiscValue`
JOIN ?_spell s2 ON s2.`id` = g.`spellId`
JOIN ?_icons ic ON ic.`id` = s1.`iconIdAlt`
WHERE i.classBak = ?d',
FROM ::items i
JOIN ::spell s1 ON s1.`id` = i.`spellid1`
JOIN ::glyphproperties g ON g.`id` = s1.`effect1MiscValue`
JOIN ::spell s2 ON s2.`id` = g.`spellId`
JOIN ::icons ic ON ic.`id` = s1.`iconIdAlt`
WHERE i.classBak = %i',
ITEM_CLASS_GLYPH);
$glyphSpells = new SpellList(array(['s.id', array_keys($glyphList)]));

View file

@ -401,9 +401,9 @@ CLISetup::registerSetup("build", new class extends SetupScript
private function prepare() : bool
{
$this->wmOverlays = DB::Aowow()->select('SELECT *, `worldMapAreaId` AS ARRAY_KEY, `id` AS ARRAY_KEY2 FROM dbc_worldmapoverlay WHERE `textureString` <> ""');
$this->wmAreas = DB::Aowow()->select('SELECT `id`, `mapId`, `areaId`, UPPER(`nameINT`) AS `nameINT`, IF(`areaId`, `areaId`, -`id`) AS ARRAY_KEY FROM dbc_worldmaparea');
$this->dmFloorData = DB::Aowow()->select('SELECT IF(`mapId` IN (?a), -`worldMapAreaId`, `mapId`) AS ARRAY_KEY, GROUP_CONCAT(DISTINCT `floor` SEPARATOR " ") AS "0", COUNT(DISTINCT `floor`) AS "1" FROM dbc_dungeonmap WHERE `worldMapAreaId` <> 0 GROUP BY ARRAY_KEY', self::CONTINENTS);
$this->wmOverlays = DB::Aowow()->selectAssoc('SELECT *, `worldMapAreaId` AS ARRAY_KEY, `id` AS ARRAY_KEY2 FROM dbc_worldmapoverlay WHERE `textureString` <> ""');
$this->wmAreas = DB::Aowow()->selectAssoc('SELECT `id`, `mapId`, `areaId`, UPPER(`nameINT`) AS `nameINT`, IF(`areaId`, `areaId`, -`id`) AS ARRAY_KEY FROM dbc_worldmaparea');
$this->dmFloorData = DB::Aowow()->selectAssoc('SELECT IF(`mapId` IN %in, -`worldMapAreaId`, `mapId`) AS ARRAY_KEY, GROUP_CONCAT(DISTINCT `floor` SEPARATOR " ") AS "0", COUNT(DISTINCT `floor`) AS "1" FROM dbc_dungeonmap WHERE `worldMapAreaId` <> 0 GROUP BY ARRAY_KEY', self::CONTINENTS);
if (!$this->wmOverlays || !$this->wmAreas || !$this->dmFloorData)
{
CLI::write('[img-maps] - could not read required dbc files: WorldMapArea.dbc ['.count($this->wmAreas ?: []).' entries]; WorldMapOverlay.dbc ['.count($this->wmOverlays ?: []).'] entries; DungeonMap.dbc ['.count($this->dmFloorData ?: []).' entries]', CLI::LOG_ERROR);

View file

@ -55,7 +55,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
sleep(2);
$tTabs = DB::Aowow()->select('SELECT tt.`creatureFamilyMask`, tt.`textureFile`, tt.`tabNumber`, cc.`fileString` FROM dbc_talenttab tt LEFT JOIN dbc_chrclasses cc ON cc.`id` = IF(tt.`classMask`, LOG(2, tt.`classMask`) + 1, 0)');
$tTabs = DB::Aowow()->selectAssoc('SELECT tt.`creatureFamilyMask`, tt.`textureFile`, tt.`tabNumber`, cc.`fileString` FROM dbc_talenttab tt LEFT JOIN dbc_chrclasses cc ON cc.`id` = IF(tt.`classMask`, LOG(2, tt.`classMask`) + 1, 0)');
if (!$tTabs)
{
CLI::write(' - TalentTab.dbc or ChrClasses.dbc is empty...?', CLI::LOG_ERROR);

View file

@ -74,7 +74,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
$offsets = array_map(function ($v) { // LookupEntry(cr*GT_MAX_LEVEL+level-1)
return $v * 100 + 60 - 1; // combat rating where introduced during the transition vanilla > burnig crusade. So at level 60 (at the time) the rating on the item was equal to 1% effect and is still the baseline in 3.3.5a.
}, $ratings);
$base = DB::Aowow()->selectCol('SELECT CAST((idx + 1 - 60) / 100 AS UNSIGNED) AS ARRAY_KEY, ratio FROM dbc_gtcombatratings WHERE idx IN (?a)', $offsets);
$base = DB::Aowow()->selectCol('SELECT CAST((idx + 1 - 60) / 100 AS UNSIGNED) AS ARRAY_KEY, ratio FROM dbc_gtcombatratings WHERE idx IN %in', $offsets);
/* non-1 scaler in 3.3.5.12340
| ratingId | classId | ratio |
@ -88,7 +88,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
$offsets = array_map(function ($v) { // LookupEntry((getClass()-1)*GT_MAX_RATING+cr+1)
return (ChrClass::WARRIOR->value - 1) * 32 + $v + 1; // should this be dynamic per pinned character? ITEM_MOD HASTE has a worse scaler for a subset of classes (see table)
}, $ratings);
$mods = DB::Aowow()->selectCol('SELECT idx - 1 AS ARRAY_KEY, ratio FROM dbc_gtoctclasscombatratingscalar WHERE idx IN (?a)', $offsets);
$mods = DB::Aowow()->selectCol('SELECT idx - 1 AS ARRAY_KEY, ratio FROM dbc_gtoctclasscombatratingscalar WHERE idx IN %in', $offsets);
foreach ($data as &$val)
$val = Cfg::get('DEBUG') ? $base[$val].' / '.$mods[$val] : $base[$val] / $mods[$val];
@ -115,7 +115,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
$v = $v ?: '0 AS idx'.$k; // NULL => 0 (plus some index so we can have 2x 0)
});
$data = DB::Aowow()->select('SELECT id AS ARRAY_KEY, '.implode(', ', $fields).' FROM dbc_scalingstatvalues');
$data = DB::Aowow()->selectAssoc('SELECT id AS ARRAY_KEY, '.implode(', ', $fields).' FROM dbc_scalingstatvalues');
foreach ($data as &$d)
$d = array_values($d); // strip indizes
@ -124,7 +124,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
private function itemScalingSD() : string
{
$data = DB::Aowow()->select('SELECT *, id AS ARRAY_KEY FROM dbc_scalingstatdistribution');
$data = DB::Aowow()->selectAssoc('SELECT *, id AS ARRAY_KEY FROM dbc_scalingstatdistribution');
foreach ($data as &$row)
{
$row = array_values($row);

View file

@ -43,7 +43,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
public function generate() : bool
{
$setList = DB::Aowow()->Select('SELECT * FROM ?_itemset ORDER BY `refSetId` DESC');
$setList = DB::Aowow()->selectAssoc('SELECT * FROM ::itemset ORDER BY `refSetId` DESC');
$jsonBonus = [];
foreach (CLISetup::$locales as $loc)

View file

@ -15,7 +15,7 @@ if (!CLI)
name:'Forest Spider',
minlevel:5,
maxlevel:6,
location:[12], // master-AreaTableId's (?)
location:[12], // master-AreaTableId's (%s)
react:[-1,-1],
classification:0, // 0:"Normal", 1:"Elite", 2:"Rar Elite", 3:"Boss", 4:"Rar"
family:3, // creatureFamily
@ -40,7 +40,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
public function generate() : bool
{
$petList = DB::Aowow()->Select(
$petList = DB::Aowow()->selectAssoc(
'SELECT cr.`id`,
cr.`name_loc0`, cr.`name_loc2`, cr.`name_loc3`, cr.`name_loc4`, cr.`name_loc6`, cr.`name_loc8`,
cr.`minLevel`, cr.`maxLevel`,
@ -49,17 +49,17 @@ CLISetup::registerSetup("build", new class extends SetupScript
cr.`family`,
cr.`displayId1` AS "displayId",
cr.`textureString` AS "skin",
LOWER(SUBSTRING_INDEX(cf.`iconString`, "\\\\", -1)) AS "icon",
LOWER(SUBSTRING_INDEX(cf.`iconString`, "\\", -1)) AS "icon",
cf.`petTalentType` AS "type"
FROM ?_creature cr
JOIN ?_factiontemplate ft ON ft.`id` = cr.`faction`
FROM ::creature cr
JOIN ::factiontemplate ft ON ft.`id` = cr.`faction`
JOIN dbc_creaturefamily cf ON cf.`id` = cr.`family`
WHERE cr.`typeFlags` & 0x1 AND (cr.`cuFlags` & ?d) = 0
WHERE cr.`typeFlags` & 0x1 AND (cr.`cuFlags` & %i) = 0
ORDER BY cr.`id` ASC',
NPC_CU_DIFFICULTY_DUMMY
);
$locations = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, `areaId` AS ARRAY_KEY2, `areaId` FROM ?_spawns WHERE `type` = ?d AND `typeId` IN (?a) GROUP BY `typeId`, `areaId`', Type::NPC, array_column($petList, 'id'));
$locations = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, `areaId` AS ARRAY_KEY2, `areaId` FROM ::spawns WHERE `type` = %i AND `typeId` IN %in GROUP BY `typeId`, `areaId`', Type::NPC, array_column($petList, 'id'));
foreach (CLISetup::$locales as $loc)
{

View file

@ -56,7 +56,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
$questorder = [];
$questtotal = [];
$condition = [
'AND',
DB::AND,
[['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW | CUSTOM_UNAVAILABLE | CUSTOM_DISABLED, '&'], 0],
[['flags', QUEST_FLAG_DAILY | QUEST_FLAG_WEEKLY | QUEST_FLAG_TRACKING, '&'], 0],
[['specialFlags', QUEST_FLAG_SPECIAL_REPEATABLE | QUEST_FLAG_SPECIAL_DUNGEON_FINDER | QUEST_FLAG_SPECIAL_MONTHLY, '&'], 0]
@ -162,7 +162,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
);
$mountz = new SpellList($condition);
$conditionSet = DB::World()->selectCol('SELECT `SourceEntry` AS ARRAY_KEY, `ConditionValue1` FROM conditions WHERE `SourceTypeOrReferenceId` = ?d AND `ConditionTypeOrReference` = ?d AND `SourceEntry` IN (?a)', Conditions::SRC_SPELL, Conditions::SKILL, $mountz->getFoundIDs());
$conditionSet = DB::World()->selectCol('SELECT `SourceEntry` AS ARRAY_KEY, `ConditionValue1` FROM conditions WHERE `SourceTypeOrReferenceId` = %i AND `ConditionTypeOrReference` = %i AND `SourceEntry` IN %in', Conditions::SRC_SPELL, Conditions::SKILL, $mountz->getFoundIDs());
// get mounts for exclusion
foreach ($conditionSet as $mount => $skill)
@ -208,7 +208,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
['typeCat', -6]
);
$companionz = new SpellList($condition);
$legit = DB::Aowow()->selectCol('SELECT `spellId2` FROM ?_items WHERE `class` = ?d AND `subClass` = ?d AND `spellId1` IN (?a) AND `spellId2` IN (?a)', ITEM_CLASS_MISC, 2, LEARN_SPELLS, $companionz->getFoundIDs());
$legit = DB::Aowow()->selectCol('SELECT `spellId2` FROM ::items WHERE `class` = %i AND `subClass` = %i AND `spellId1` IN %in AND `spellId2` IN %in', ITEM_CLASS_MISC, 2, LEARN_SPELLS, $companionz->getFoundIDs());
foreach ($companionz->iterate() as $id => $_)
if (!$companionz->getSources())
@ -273,7 +273,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
['effect1Id', [SPELL_EFFECT_APPLY_AURA, SPELL_EFFECT_TRADE_SKILL, SPELL_EFFECT_PROSPECTING, SPELL_EFFECT_OPEN_LOCK, SPELL_EFFECT_MILLING, SPELL_EFFECT_DISENCHANT, SPELL_EFFECT_SUMMON, SPELL_EFFECT_SKINNING], '!'],
// not the skill itself
['effect2Id', [SPELL_EFFECT_SKILL, SPELL_EFFECT_PROFICIENCY], '!'],
['OR', ['typeCat', 9], ['typeCat', 11]]
[DB::OR, ['typeCat', 9], ['typeCat', 11]]
);
foreach ($skills as $s)
@ -362,15 +362,15 @@ CLISetup::registerSetup("build", new class extends SetupScript
set_time_limit(2);
CLI::write('[profiler] applying '.count($this->exclusions).' baseline exclusions');
DB::Aowow()->query('DELETE FROM ?_profiler_excludes WHERE `comment` = ""');
DB::Aowow()->qry('DELETE FROM ::profiler_excludes WHERE `comment` = ""');
foreach ($this->exclusions as $ex)
DB::Aowow()->query('REPLACE INTO ?_profiler_excludes (?#) VALUES (?a)', array_keys($ex), array_values($ex));
DB::Aowow()->qry('REPLACE INTO ::profiler_excludes %v', $ex);
// excludes; type => [excludeGroupBit => [typeIds]]
$excludes = [];
$exData = DB::Aowow()->selectCol('SELECT `type` AS ARRAY_KEY, `typeId` AS ARRAY_KEY2, `groups` FROM ?_profiler_excludes');
$exData = DB::Aowow()->selectCol('SELECT `type` AS ARRAY_KEY, `typeId` AS ARRAY_KEY2, `groups` FROM ::profiler_excludes');
for ($i = 0; (1 << $i) < PR_EXCLUDE_GROUP_ANY; $i++)
foreach ($exData as $type => $data)
if ($ids = array_keys(array_filter($data, fn($x) => $x & (1 << $i))))

View file

@ -372,7 +372,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
return $m ? $m[1] : null;
}, $missing);
DB::Aowow()->query('UPDATE ?_icons SET `cuFlags` = `cuFlags` | ?d WHERE `name` IN (?a)', CUSTOM_EXCLUDE_FOR_LISTVIEW, $iconNames);
DB::Aowow()->qry('UPDATE ::icons SET `cuFlags` = `cuFlags` | %i WHERE `name` IN %in', CUSTOM_EXCLUDE_FOR_LISTVIEW, $iconNames);
CLI::write('[simpleimg] 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)

View file

@ -21,7 +21,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
public function generate() : bool
{
// ALL files
$files = DB::Aowow()->selectCol('SELECT ABS(`id`) AS ARRAY_KEY, CONCAT(`path`, "/", `file`) FROM ?_sounds_files');
$files = DB::Aowow()->selectCol('SELECT ABS(`id`) AS ARRAY_KEY, CONCAT(`path`, "/", `file`) FROM ::sounds_files');
$nFiles = count($files);
$qtLen = strlen($nFiles);
$sum = 0;
@ -63,7 +63,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
CLI::write('[soundfiles] - did not find file: '.CLI::bold(CLI::nicePath($filePath, CLISetup::$srcDir, '['.implode(',', array_map(fn($x) => $x->json(), CLISetup::$locales)).']')), CLI::LOG_WARN);
$time->reset();
// flag as unusable in DB
DB::Aowow()->query('UPDATE ?_sounds_files SET `id` = ?d WHERE ABS(`id`) = ?d', -$fileId, $fileId);
DB::Aowow()->qry('UPDATE ::sounds_files SET `id` = %i WHERE ABS(`id`) = %i', -$fileId, $fileId);
}
return $this->success;

View file

@ -73,7 +73,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
);
foreach ($dataz as $class => &$data)
$data[2] = array_values(DB::Aowow()->selectRow('SELECT mle.chance*100 cMle, spl.chance*100 cSpl FROM dbc_gtchancetomeleecritbase mle, dbc_gtchancetospellcritbase spl WHERE mle.idx = spl.idx AND mle.idx = ?d', $class - 1));
$data[2] = array_values(DB::Aowow()->selectRow('SELECT mle.chance*100 cMle, spl.chance*100 cSpl FROM dbc_gtchancetomeleecritbase mle, dbc_gtchancetospellcritbase spl WHERE mle.idx = spl.idx AND mle.idx = %i', $class - 1));
return $dataz;
}
@ -81,7 +81,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
// { str, agi, sta, int, spi, raceMod1, raceMod2 }
private function race() : array
{
$raceData = DB::World()->select('SELECT `race` AS ARRAY_KEY, MIN(`str`), MIN(`agi`), MIN(`sta`), MIN(`inte`), MIN(`spi`) FROM player_levelstats WHERE `level` = 1 GROUP BY `race` ORDER BY `race` ASC');
$raceData = DB::World()->selectAssoc('SELECT `race` AS ARRAY_KEY, MIN(`str`), MIN(`agi`), MIN(`sta`), MIN(`inte`), MIN(`spi`) FROM player_levelstats WHERE `level` = 1 GROUP BY `race` ORDER BY `race` ASC');
foreach ($raceData as &$rd)
$rd = array_values($rd + [[], []]);
@ -130,27 +130,27 @@ CLISetup::registerSetup("build", new class extends SetupScript
else
$offset = array_values(DB::World()->selectRow('SELECT MIN(`str`), MIN(`agi`), MIN(`sta`), MIN(`inte`), MIN(`spi`) FROM player_levelstats WHERE `level` = 1 AND `race` = 1'));
$gtData = DB::Aowow()->select(
'SELECT mlecrt.idx - ?d AS ARRAY_KEY, mlecrt.chance * 100, splcrt.chance * 100, mlecrt.chance * 100 * ?f, baseHP5.ratio * 1, extraHP5.ratio * 1
$gtData = DB::Aowow()->selectAssoc(
'SELECT mlecrt.idx - %i AS ARRAY_KEY, mlecrt.chance * 100, splcrt.chance * 100, mlecrt.chance * 100 * %f, baseHP5.ratio * 1, extraHP5.ratio * 1
FROM dbc_gtchancetomeleecrit mlecrt
JOIN dbc_gtchancetospellcrit splcrt ON splcrt.idx = mlecrt.idx
JOIN dbc_gtoctregenhp baseHP5 ON baseHP5.idx = mlecrt.idx
JOIN dbc_gtregenhpperspt extraHP5 ON extraHP5.idx = mlecrt.idx
WHERE mlecrt.idx BETWEEN ?d AND ?d',
WHERE mlecrt.idx BETWEEN %i AND %i',
(($class - 1) * 100) - 1, // class-offset
$mod,
(($class - 1) * 100) + 0, // lvl 1
(($class - 1) * 100) + 79 // lvl 80
);
$rows = DB::World()->select(
$rows = DB::World()->selectAssoc(
'SELECT pls.level AS ARRAY_KEY,
pls.str - ?d, pls.agi - ?d, pls.sta - ?d, pls.inte - ?d, pls.spi - ?d,
pls.str - %i, pls.agi - %i, pls.sta - %i, pls.inte - %i, pls.spi - %i,
pcls.basehp, IF(pcls.basemana <> 0, pcls.basemana, 100)
FROM player_levelstats pls
JOIN player_classlevelstats pcls ON pls.level = pcls.level AND pls.class = pcls.class
WHERE pls.race = ?d AND
pls.class = ?d
WHERE pls.race = %i AND
pls.class = %i
ORDER BY pls.level ASC',
$offset[0], $offset[1], $offset[2], $offset[3], $offset[4],
in_array($class, [3, 7, 11]) ? 6 : 1,
@ -170,13 +170,13 @@ CLISetup::registerSetup("build", new class extends SetupScript
// content of gtRegenMPPerSpt.dbc
private function level() : array
{
return DB::Aowow()->selectCol('SELECT idx-99 AS ARRAY_KEY, ratio FROM dbc_gtregenmpperspt WHERE idx >= 100 AND idx < 100 + ?d', MAX_LEVEL);
return DB::Aowow()->selectCol('SELECT idx-99 AS ARRAY_KEY, ratio FROM dbc_gtregenmpperspt WHERE idx >= 100 AND idx < 100 + %i', MAX_LEVEL);
}
// profession perks ... too lazy to formulate a search algorithm for two occurences
private function skills() : array
{
// DB::Aowow()->select(
// DB::Aowow()->selectAssoc(
// 'SELECT sk.id AS "skillId", sla.reqSkillLevel, s.effect1AuraId AS "auraId", s.effect1MiscValue, s.effect1BasePoints + s.effect1DieSides AS "qty"
// FROM dbc_skilllineability sla
// JOIN dbc_skillline sk ON sk.id = sla.skilllineid

View file

@ -51,7 +51,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
$this->petFamIcons = ['Ability_Druid_KingoftheJungle', 'Ability_Druid_DemoralizingRoar', 'Ability_EyeOfTheOwl']; // .. i've no idea where to fetch these from
$this->spellMods = (new SpellList(array(['typeCat', -2])))->getProfilerMods();
$petIcons = Util::toJSON(DB::Aowow()->SelectCol('SELECT `id` AS ARRAY_KEY, LOWER(SUBSTRING_INDEX(`iconString`, "\\\\", -1)) AS "iconString" FROM dbc_creaturefamily WHERE `petTalentType` IN (0, 1, 2)'));
$petIcons = Util::toJSON(DB::Aowow()->SelectCol('SELECT `id` AS ARRAY_KEY, LOWER(SUBSTRING_INDEX(`iconString`, "\\", -1)) AS "iconString" FROM dbc_creaturefamily WHERE `petTalentType` IN (0, 1, 2)'));
$tSpellIds = DB::Aowow()->selectCol('SELECT `rank1` FROM dbc_talent UNION SELECT `rank2` FROM dbc_talent UNION SELECT `rank3` FROM dbc_talent UNION SELECT `rank4` FROM dbc_talent UNION SELECT `rank5` FROM dbc_talent');
$this->tSpells = new SpellList(array(['s.id', $tSpellIds]));
@ -89,17 +89,17 @@ CLISetup::registerSetup("build", new class extends SetupScript
$petCategories = [];
// All "tabs" of a given class talent
$tabs = DB::Aowow()->select('SELECT * FROM dbc_talenttab WHERE `classMask` = ?d ORDER BY `tabNumber`, `creatureFamilyMask`', $classMask);
$tabs = DB::Aowow()->selectAssoc('SELECT * FROM dbc_talenttab WHERE `classMask` = %i ORDER BY `tabNumber`, `creatureFamilyMask`', $classMask);
$result = [];
for ($tabIdx = 0; $tabIdx < count($tabs); $tabIdx++)
{
$talents = DB::Aowow()->select(
$talents = DB::Aowow()->selectAssoc(
'SELECT t.id AS "tId", t.*, IF(t.rank5, 5, IF(t.rank4, 4, IF(t.rank3, 3, IF(t.rank2, 2, 1)))) AS "maxRank",
s.`name_loc0`, s.`name_loc2`, s.`name_loc3`, s.`name_loc4`, s.`name_loc6`, s.`name_loc8`,
LOWER(SUBSTRING_INDEX(si.`iconPath`, "\\\\", -1)) AS "iconString"
LOWER(SUBSTRING_INDEX(si.`iconPath`, "\\", -1)) AS "iconString"
FROM dbc_talent t, dbc_spell s, dbc_spellicon si
WHERE si.`id` = s.`iconId` AND t.`tabId`= ?d AND s.`id` = t.`rank1`
WHERE si.`id` = s.`iconId` AND t.`tabId`= %i AND s.`id` = t.`rank1`
ORDER BY t.`row`, t.`column`, t.`id` ASC',
$tabs[$tabIdx]['id']
);
@ -113,7 +113,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
{
$petFamId = log($tabs[$tabIdx]['creatureFamilyMask'], 2);
$result[$tabIdx]['icon'] = $this->petFamIcons[$petFamId];
$petCategories = DB::Aowow()->SelectCol('SELECT `id` AS ARRAY_KEY, `categoryEnumID` FROM dbc_creaturefamily WHERE `petTalentType` = ?d', $petFamId);
$petCategories = DB::Aowow()->SelectCol('SELECT `id` AS ARRAY_KEY, `categoryEnumID` FROM dbc_creaturefamily WHERE `petTalentType` = %i', $petFamId);
$result[$tabIdx]['f'] = array_keys($petCategories);
}

View file

@ -79,12 +79,12 @@ CLISetup::registerSetup("build", new class extends SetupScript
private function compileTexture(string $ttField, int $searchMask, int $tabIdx) : ?\GdImage
{
$icons = DB::Aowow()->SelectCol(
'SELECT ic.`name` AS "iconString"
FROM ?_icons ic
JOIN ?_spell s ON s.`iconId` = ic.`id`
'SELECT ic.`name`
FROM ::icons ic
JOIN ::spell s ON s.`iconId` = ic.`id`
JOIN dbc_talent t ON t.`rank1` = s.`id`
JOIN dbc_talenttab tt ON tt.`id` = t.`tabId`
WHERE tt.?# = ?d AND tt.`tabNumber` = ?d
WHERE tt.%n = %i AND tt.`tabNumber` = %i
ORDER BY t.`row`, t.`column`, t.`id` ASC',
$ttField, $searchMask, $tabIdx);

View file

@ -21,11 +21,11 @@ CLISetup::registerSetup("build", new class extends SetupScript
public function generate() : bool
{
$wtPresets = [];
$scales = DB::Aowow()->select('SELECT `id`, `name`, `icon`, `class` FROM ?_account_weightscales WHERE `userId` = 0 ORDER BY `class`, `orderIdx` ASC');
$scales = DB::Aowow()->selectAssoc('SELECT `id`, `name`, `icon`, `class` FROM ::account_weightscales WHERE `userId` = 0 ORDER BY `class`, `orderIdx` ASC');
foreach ($scales as $s)
{
if ($weights = DB::Aowow()->selectCol('SELECT `field` AS ARRAY_KEY, `val` FROM ?_account_weightscale_data WHERE `id` = ?d', $s['id']))
if ($weights = DB::Aowow()->selectCol('SELECT `field` AS ARRAY_KEY, `val` FROM ::account_weightscale_data WHERE `id` = %i', $s['id']))
$wtPresets[$s['class']]['pve'][$s['name']] = array_merge(['__icon' => $s['icon']], $weights);
else
{

View file

@ -44,11 +44,11 @@ trait TrCustomData
public function applyCustomData() : bool
{
$ok = true;
foreach ((DB::Aowow()->selectCol('SELECT `entry` AS ARRAY_KEY, `field` AS ARRAY_KEY2, `value` FROM ?_setup_custom_data WHERE `command` = ?', $this->getName()) ?: []) as $id => $data)
foreach ((DB::Aowow()->selectCol('SELECT `entry` AS ARRAY_KEY, `field` AS ARRAY_KEY2, `value` FROM ::setup_custom_data WHERE `command` = %s', $this->getName()) ?: []) as $id => $data)
{
try
{
DB::Aowow()->query('UPDATE ?_'.$this->getName().' SET ?a WHERE id = ?d', $data, $id);
DB::Aowow()->qry('UPDATE %n SET %a WHERE id = %i', '::'.$this->getName(), $data, $id);
}
catch (\Exception $e)
{
@ -602,9 +602,9 @@ abstract class SetupScript
return;
}
DB::Aowow()->query('UPDATE ?_'.$tbl.' x, ?_comments y SET x.`cuFlags` = x.`cuFlags` | ?d WHERE x.`id` = y.`typeId` AND y.`type` = ?d AND y.`flags` & ?d', CUSTOM_HAS_COMMENT, $type, CC_FLAG_APPROVED);
DB::Aowow()->query('UPDATE ?_'.$tbl.' x, ?_screenshots y SET x.`cuFlags` = x.`cuFlags` | ?d WHERE x.`id` = y.`typeId` AND y.`type` = ?d AND y.`status` & ?d', CUSTOM_HAS_SCREENSHOT, $type, CC_FLAG_APPROVED);
DB::Aowow()->query('UPDATE ?_'.$tbl.' x, ?_videos y SET x.`cuFlags` = x.`cuFlags` | ?d WHERE x.`id` = y.`typeId` AND y.`type` = ?d AND y.`status` & ?d', CUSTOM_HAS_VIDEO, $type, CC_FLAG_APPROVED);
DB::Aowow()->qry('UPDATE ::'.$tbl.' x, ::comments y SET x.`cuFlags` = x.`cuFlags` | %i WHERE x.`id` = y.`typeId` AND y.`type` = %i AND y.`flags` & %i', CUSTOM_HAS_COMMENT, $type, CC_FLAG_APPROVED);
DB::Aowow()->qry('UPDATE ::'.$tbl.' x, ::screenshots y SET x.`cuFlags` = x.`cuFlags` | %i WHERE x.`id` = y.`typeId` AND y.`type` = %i AND y.`status` & %i', CUSTOM_HAS_SCREENSHOT, $type, CC_FLAG_APPROVED);
DB::Aowow()->qry('UPDATE ::'.$tbl.' x, ::videos y SET x.`cuFlags` = x.`cuFlags` | %i WHERE x.`id` = y.`typeId` AND y.`type` = %i AND y.`status` & %i', CUSTOM_HAS_VIDEO, $type, CC_FLAG_APPROVED);
}
}

View file

@ -21,10 +21,10 @@ CLISetup::registerSetup('sql', new class extends SetupScript
protected $worldDependency = ['dbc_achievement', 'disables'];
protected $setupAfter = [['icons'], []];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_achievement');
DB::Aowow()->query('TRUNCATE ?_achievementcategory');
DB::Aowow()->qry('TRUNCATE ::achievement');
DB::Aowow()->qry('TRUNCATE ::achievementcategory');
/**************/
/* categories */
@ -32,7 +32,7 @@ CLISetup::registerSetup('sql', new class extends SetupScript
CLI::write('[achievement] - resolving categories');
DB::Aowow()->query('INSERT INTO ?_achievementcategory SELECT ac.id, GREATEST(ac.parentcategory, 0), GREATEST(IFNULL(ac1.parentcategory, 0), 0) FROM dbc_achievement_category ac LEFT JOIN dbc_achievement_category ac1 ON ac1.id = ac.parentCategory');
DB::Aowow()->qry('INSERT INTO ::achievementcategory SELECT ac.id, GREATEST(ac.parentcategory, 0), GREATEST(IFNULL(ac1.parentcategory, 0), 0) FROM dbc_achievement_category ac LEFT JOIN dbc_achievement_category ac1 ON ac1.id = ac.parentCategory');
/************/
/* dbc data */
@ -40,8 +40,8 @@ CLISetup::registerSetup('sql', new class extends SetupScript
CLI::write('[achievement] - basic dbc data');
DB::Aowow()->query(
'INSERT INTO ?_achievement
DB::Aowow()->qry(
'INSERT INTO ::achievement
SELECT a.id,
2 - a.faction,
a.map,
@ -64,9 +64,7 @@ CLISetup::registerSetup('sql', new class extends SetupScript
FROM dbc_achievement a
LEFT JOIN dbc_achievement_category ac ON ac.id = a.category
LEFT JOIN dbc_spellicon si ON si.id = a.iconId
LEFT JOIN ?_icons i ON LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1)) = i.name_source
{ WHERE a.id IN (?a) }',
$ids ?: DBSIMPLE_SKIP
LEFT JOIN ::icons i ON LOWER(SUBSTRING_INDEX(si.iconPath, "\\", -1)) = i.name_source',
);
@ -76,9 +74,7 @@ CLISetup::registerSetup('sql', new class extends SetupScript
CLI::write('[achievement] - serverside achievement data');
$serverAchievements = DB::World()->select('SELECT `ID` AS "id", IF(`requiredFaction` = -1, 3, IF(`requiredFaction` = 0, 2, 1)) AS "faction", `mapID` AS "map", `points`, `flags`, `count` AS "reqCriteriaCount", `refAchievement` FROM achievement_dbc{ WHERE `id` IN (?a)}',
$ids ?: DBSIMPLE_SKIP
);
$serverAchievements = DB::World()->selectAssoc('SELECT `ID` AS "id", IF(`requiredFaction` = -1, 3, IF(`requiredFaction` = 0, 2, 1)) AS "faction", `mapID` AS "map", `points`, `flags`, `count` AS "reqCriteriaCount", `refAchievement` FROM achievement_dbc');
foreach ($serverAchievements as &$sa)
{
@ -91,7 +87,7 @@ CLISetup::registerSetup('sql', new class extends SetupScript
unset($sa);
foreach ($serverAchievements as $sa)
DB::Aowow()->query('INSERT INTO ?_achievement (?#) VALUES (?a)', array_keys($sa), array_values($sa));
DB::Aowow()->qry('INSERT INTO ::achievement %v', $sa);
/********************************/
@ -104,7 +100,7 @@ CLISetup::registerSetup('sql', new class extends SetupScript
foreach ($parents as $chainId => $next)
{
$tree = [null, $next];
while ($next = DB::Aowow()->selectCell('SELECT `id` FROM dbc_achievement WHERE `previous` = ?d', $next))
while ($next = DB::Aowow()->selectCell('SELECT `id` FROM dbc_achievement WHERE `previous` = %i', $next))
$tree[] = $next;
foreach ($tree as $idx => $aId)
@ -112,7 +108,7 @@ CLISetup::registerSetup('sql', new class extends SetupScript
if (!$aId)
continue;
DB::Aowow()->query('UPDATE ?_achievement SET `cuFlags` = `cuFlags` | ?d, `chainId` = ?d, `chainPos` = ?d WHERE `id` = ?d',
DB::Aowow()->qry('UPDATE ::achievement SET `cuFlags` = `cuFlags` | %i, `chainId` = %i, `chainPos` = %i WHERE `id` = %i',
$idx == 1 ? ACHIEVEMENT_CU_FIRST_SERIES : (count($tree) == $idx + 1 ? ACHIEVEMENT_CU_LAST_SERIES : 0),
$chainId + 1,
$idx,
@ -129,7 +125,7 @@ CLISetup::registerSetup('sql', new class extends SetupScript
CLI::write('[achievement] - disabling disabled achievements from table disables');
if ($criteria = DB::World()->selectCol('SELECT `entry` FROM disables WHERE `sourceType` = 4'))
DB::Aowow()->query('UPDATE ?_achievement a JOIN ?_achievementcriteria ac ON a.`id` = ac.`refAchievementId` SET a.`cuFlags` = ?d WHERE ac.`id` IN (?a)', CUSTOM_DISABLED, $criteria);
DB::Aowow()->qry('UPDATE ::achievement a JOIN ::achievementcriteria ac ON a.`id` = ac.`refAchievementId` SET a.`cuFlags` = %i WHERE ac.`id` IN %in', CUSTOM_DISABLED, $criteria);
$this->reapplyCCFlags('achievement', Type::ACHIEVEMENT);

View file

@ -18,10 +18,10 @@ CLISetup::registerSetup('sql', new class extends SetupScript
protected $dbcSourceFiles = ['areatrigger'];
protected $worldDependency = ['areatrigger_involvedrelation', 'areatrigger_scripts', 'areatrigger_tavern', 'areatrigger_teleport', 'quest_template', 'quest_template_addon'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_areatrigger');
DB::Aowow()->query('INSERT INTO ?_areatrigger SELECT `id`, 0, 0, `mapId`, `posX`, `posY`, `orientation`, NULL, NULL FROM dbc_areatrigger');
DB::Aowow()->qry('TRUNCATE ::areatrigger');
DB::Aowow()->qry('INSERT INTO ::areatrigger SELECT `id`, 0, 0, `mapId`, `posX`, `posY`, `orientation`, NULL, NULL FROM dbc_areatrigger');
/* notes:
* while areatrigger DO have dimensions, displaying them on a map is almost always futile,
@ -31,42 +31,42 @@ CLISetup::registerSetup('sql', new class extends SetupScript
// 1: Taverns
CLI::write('[areatrigger] - fetching taverns');
$addData = DB::World()->select('SELECT `id` AS ARRAY_KEY, `name`, ?d AS `type` FROM areatrigger_tavern', AT_TYPE_TAVERN);
$addData = DB::World()->selectAssoc('SELECT `id` AS ARRAY_KEY, `name`, %i AS `type` FROM areatrigger_tavern', AT_TYPE_TAVERN);
foreach ($addData as $id => $ad)
DB::Aowow()->query('UPDATE ?_areatrigger SET ?a WHERE `id` = ?d', $ad, $id);
DB::Aowow()->qry('UPDATE ::areatrigger SET %a WHERE `id` = %i', $ad, $id);
// 2: Teleporter
CLI::write('[areatrigger] - teleporter type and name');
$addData = DB::World()->select(
$addData = DB::World()->selectAssoc(
'SELECT `ID` AS ARRAY_KEY, `Name` AS `name` FROM areatrigger_teleport UNION
SELECT `entryorguid` AS ARRAY_KEY, "SAI Teleport" AS `name` FROM smart_scripts WHERE `source_type` = ?d AND `action_type` = ?d',
SELECT `entryorguid` AS ARRAY_KEY, "SAI Teleport" AS `name` FROM smart_scripts WHERE `source_type` = %i AND `action_type` = %i',
SmartAI::SRC_TYPE_AREATRIGGER, SmartAction::ACTION_TELEPORT
);
foreach ($addData as $id => $ad)
DB::Aowow()->query('UPDATE ?_areatrigger SET `name` = ?, `type` = ?d WHERE `id` = ?d', $ad['name'], AT_TYPE_TELEPORT, $id);
DB::Aowow()->qry('UPDATE ::areatrigger SET `name` = %s, `type` = %i WHERE `id` = %i', $ad['name'], AT_TYPE_TELEPORT, $id);
// 3: Quest Objectives
CLI::write('[areatrigger] - satisfying quest objectives');
$addData = DB::World()->select('SELECT atir.`id` AS ARRAY_KEY, `qt`.ID AS `quest`, NULLIF(qt.`AreaDescription`, "") AS `name`, qta.`SpecialFlags` FROM quest_template qt LEFT JOIN quest_template_addon qta ON qta.`ID` = qt.`ID` JOIN areatrigger_involvedrelation atir ON atir.`quest` = qt.`ID`');
$addData = DB::World()->selectAssoc('SELECT atir.`id` AS ARRAY_KEY, `qt`.ID AS `quest`, NULLIF(qt.`AreaDescription`, "") AS `name`, qta.`SpecialFlags` FROM quest_template qt LEFT JOIN quest_template_addon qta ON qta.`ID` = qt.`ID` JOIN areatrigger_involvedrelation atir ON atir.`quest` = qt.`ID`');
foreach ($addData as $id => $ad)
{
if (!($ad['SpecialFlags'] & QUEST_FLAG_SPECIAL_EXT_COMPLETE))
CLI::write('[areatrigger] '.str_pad('['.$id.']', 8).' is involved in quest '.CLI::bold($ad['quest']).', but quest is not flagged for external completion (SpecialFlags & '.Util::asHex(QUEST_FLAG_SPECIAL_EXT_COMPLETE).')', CLI::LOG_WARN);
DB::Aowow()->query('UPDATE ?_areatrigger SET `name` = ?, type = ?d, `quest` = ?d WHERE `id` = ?d', $ad['name'], AT_TYPE_OBJECTIVE, $ad['quest'], $id);
DB::Aowow()->qry('UPDATE ::areatrigger SET `name` = %s, type = %i, `quest` = %i WHERE `id` = %i', $ad['name'], AT_TYPE_OBJECTIVE, $ad['quest'], $id);
}
// 4/5 Scripted
CLI::write('[areatrigger] - assigning scripts');
$addData = DB::World()->select('SELECT `entry` AS ARRAY_KEY, IF(`ScriptName` = "SmartTrigger", NULL, `ScriptName`) AS `name`, IF(`ScriptName` = "SmartTrigger", 4, 5) AS `type` FROM areatrigger_scripts');
$addData = DB::World()->selectAssoc('SELECT `entry` AS ARRAY_KEY, IF(`ScriptName` = "SmartTrigger", NULL, `ScriptName`) AS `name`, IF(`ScriptName` = "SmartTrigger", 4, 5) AS `type` FROM areatrigger_scripts');
foreach ($addData as $id => $ad)
DB::Aowow()->query('UPDATE ?_areatrigger SET ?a WHERE `id` = ?d', $ad, $id);
DB::Aowow()->qry('UPDATE ::areatrigger SET %a WHERE `id` = %i', $ad, $id);
$this->reapplyCCFlags('areatrigger', Type::AREATRIGGER);

View file

@ -20,23 +20,23 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $setupAfter = [['icons'], []];
protected $dbcSourceFiles = ['spell', 'charbaseinfo', 'skillraceclassinfo', 'skilllineability', 'chrclasses'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_classes');
DB::Aowow()->qry('TRUNCATE ::classes');
$classes = DB::Aowow()->select('SELECT *, `id` AS ARRAY_KEY FROM dbc_chrclasses');
$classes = DB::Aowow()->selectAssoc('SELECT *, `id` AS ARRAY_KEY FROM dbc_chrclasses');
// add raceMask
$races = DB::Aowow()->select('SELECT `classId` AS ARRAY_KEY, BIT_OR(1 << (`raceId` - 1)) AS "raceMask" FROM dbc_charbaseinfo GROUP BY `classId`');
$races = DB::Aowow()->selectAssoc('SELECT `classId` AS ARRAY_KEY, BIT_OR(1 << (`raceId` - 1)) AS "raceMask" FROM dbc_charbaseinfo GROUP BY `classId`');
Util::arraySumByKey($classes, $races);
// add skills
if ($skills = DB::Aowow()->selectCol('SELECT LOG(2, `classMask`) + 1 AS ARRAY_KEY, GROUP_CONCAT(`skillLine` SEPARATOR \' \') FROM dbc_skillraceclassinfo WHERE `flags` = ?d GROUP BY `classMask` HAVING ARRAY_KEY = CAST(LOG(2, `classMask`) + 1 AS SIGNED)', 0x410))
if ($skills = DB::Aowow()->selectCol('SELECT LOG(2, `classMask`) + 1 AS ARRAY_KEY, GROUP_CONCAT(`skillLine` SEPARATOR \' \') FROM dbc_skillraceclassinfo WHERE `flags` = %i GROUP BY `classMask` HAVING ARRAY_KEY = CAST(LOG(2, `classMask`) + 1 AS SIGNED)', 0x410))
foreach ($skills as $classId => $skillStr)
$classes[$classId]['skills'] = $skillStr;
// collect iconIds
$iconIds = DB::Aowow()->selectCol('SELECT `id`, `name` AS ARRAY_KEY FROM ?_icons WHERE `name` IN (?a)', array_filter(array_map(fn($x) => 'class_'.strtolower($x['fileString']), $classes)));
$iconIds = DB::Aowow()->selectCol('SELECT `id`, `name` AS ARRAY_KEY FROM ::icons WHERE `name` IN %in', array_filter(array_map(fn($x) => 'class_'.strtolower($x['fileString']), $classes)));
foreach ($classes AS $id => $class)
$classes[$id]['iconId'] = $iconIds['class_'.strtolower($class['fileString'])] ?? 0;
@ -48,22 +48,22 @@ CLISetup::registerSetup("sql", new class extends SetupScript
'SELECT BIT_OR(`equippedItemSubClassMask`)
FROM dbc_spell s
JOIN dbc_skilllineability sla ON sla.`spellId` = s.`id`
JOIN dbc_skillraceclassinfo srci ON srci.`skillLine` = sla.`skillLineId` AND srci.`classMask` & ?d
WHERE sla.`skilllineid` <> 183 AND (sla.`reqClassMask` & ?d OR sla.`reqClassMask` = 0) AND `equippedItemClass` = ?d AND (`effect1Id` = ?d OR `effect2Id` = ?d)',
JOIN dbc_skillraceclassinfo srci ON srci.`skillLine` = sla.`skillLineId` AND srci.`classMask` & %i
WHERE sla.`skilllineid` <> 183 AND (sla.`reqClassMask` & %i OR sla.`reqClassMask` = 0) AND `equippedItemClass` = %i AND (`effect1Id` = %i OR `effect2Id` = %i)',
$mask, $mask, ITEM_CLASS_WEAPON, SPELL_EFFECT_PROFICIENCY, SPELL_EFFECT_PROFICIENCY
);
$data['armorTypeMask'] = DB::Aowow()->selectCell(
'SELECT BIT_OR(`equippedItemSubClassMask`)
FROM dbc_spell s
JOIN dbc_skilllineability sla ON sla.`spellId` = s.`id`
JOIN dbc_skillraceclassinfo srci ON srci.`skillLine` = sla.`skillLineId` AND srci.`classMask` & ?d
WHERE sla.`reqClassMask` & ?d AND `equippedItemClass` = ?d AND (`effect1Id` = ?d OR `effect2Id` = ?d)',
JOIN dbc_skillraceclassinfo srci ON srci.`skillLine` = sla.`skillLineId` AND srci.`classMask` & %i
WHERE sla.`reqClassMask` & %i AND `equippedItemClass` = %i AND (`effect1Id` = %i OR `effect2Id` = %i)',
$mask, $mask, ITEM_CLASS_ARMOR, SPELL_EFFECT_PROFICIENCY, SPELL_EFFECT_PROFICIENCY
);
}
foreach ($classes as $cl)
DB::Aowow()->query('INSERT INTO ?_classes (?#) VALUES (?a)', array_keys($cl), array_values($cl));
DB::Aowow()->qry('INSERT INTO ::classes %v', $cl);
$this->reapplyCCFlags('classes', Type::CHR_CLASS);

View file

@ -18,11 +18,11 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $dbcSourceFiles = ['creaturedisplayinfo', 'creaturedisplayinfoextra'];
protected $worldDependency = ['creature_template', 'creature_template_locale', 'creature_template_resistance', 'creature_template_spell', 'creature_classlevelstats', 'creature_default_trainer', 'trainer', 'instance_encounters'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
$baseQuery =
'SELECT ct.entry,
IF(ie.creditEntry IS NULL, 0, ?d) AS cuFlags,
IF(ie.creditEntry IS NULL, 0, %i) AS cuFlags,
difficulty_entry_1, difficulty_entry_2, difficulty_entry_3,
KillCredit1, KillCredit2,
modelid1, modelid2, modelid3, modelid4,
@ -99,24 +99,23 @@ CLISetup::registerSetup("sql", new class extends SetupScript
LEFT JOIN creature_template_resistance ctr4 ON ct.entry = ctr4.CreatureID AND ctr4.School = 4
LEFT JOIN creature_template_resistance ctr5 ON ct.entry = ctr5.CreatureID AND ctr5.School = 5
LEFT JOIN creature_template_resistance ctr6 ON ct.entry = ctr6.CreatureID AND ctr6.School = 6
{ WHERE ct.entry IN (?a) }
LIMIT ?d, ?d';
LIMIT %i, %i';
DB::Aowow()->query('TRUNCATE ?_creature');
DB::Aowow()->query('SET SESSION innodb_ft_enable_stopword = OFF');
DB::Aowow()->qry('TRUNCATE ::creature');
DB::Aowow()->qry('SET SESSION innodb_ft_enable_stopword = OFF');
$i = 0;
while ($npcs = DB::World()->select($baseQuery, NPC_CU_INSTANCE_BOSS, $ids ?: DBSIMPLE_SKIP, CLISetup::SQL_BATCH * $i, CLISetup::SQL_BATCH))
while ($npcs = DB::World()->selectAssoc($baseQuery, NPC_CU_INSTANCE_BOSS, CLISetup::SQL_BATCH * $i, CLISetup::SQL_BATCH))
{
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));
DB::Aowow()->qry('INSERT INTO ::creature VALUES %l', $npc);
}
// apply "textureString", "modelId" and "iconSring"
DB::Aowow()->query(
'UPDATE ?_creature c
DB::Aowow()->qry(
'UPDATE ::creature c
JOIN dbc_creaturedisplayinfo cdi ON c.displayId1 = cdi.id
LEFT JOIN dbc_creaturedisplayinfoextra cdie ON cdi.extraInfoId = cdie.id
SET c.textureString = IFNULL(cdie.textureString, cdi.skin1),
@ -126,21 +125,21 @@ CLISetup::registerSetup("sql", new class extends SetupScript
);
// apply cuFlag: difficultyDummy
DB::Aowow()->query(
'UPDATE ?_creature a
JOIN (SELECT b.difficultyEntry1 AS dummy FROM ?_creature b UNION
SELECT c.difficultyEntry2 AS dummy FROM ?_creature c UNION
SELECT d.difficultyEntry3 AS dummy FROM ?_creature d) j
SET a.cuFlags = a.cuFlags | ?d
DB::Aowow()->qry(
'UPDATE ::creature a
JOIN (SELECT b.difficultyEntry1 AS dummy FROM ::creature b UNION
SELECT c.difficultyEntry2 AS dummy FROM ::creature c UNION
SELECT d.difficultyEntry3 AS dummy FROM ::creature d) j
SET a.cuFlags = a.cuFlags | %i
WHERE a.id = j.dummy',
NPC_CU_DIFFICULTY_DUMMY | CUSTOM_EXCLUDE_FOR_LISTVIEW
);
// apply cuFlag: excludeFromListview [for trigger-creatures]
DB::Aowow()->query('UPDATE ?_creature SET cuFlags = cuFlags | ?d WHERE flagsExtra & ?d', CUSTOM_EXCLUDE_FOR_LISTVIEW, 0x80);
DB::Aowow()->qry('UPDATE ::creature SET cuFlags = cuFlags | %i WHERE flagsExtra & %i', CUSTOM_EXCLUDE_FOR_LISTVIEW, 0x80);
// apply cuFlag: exCludeFromListview [for nameparts indicating internal usage]
DB::Aowow()->query('UPDATE ?_creature SET cuFlags = cuFlags | ?d WHERE name_loc0 LIKE "%[%" OR name_loc0 LIKE "%(%" OR name_loc0 LIKE "%visual%" OR name_loc0 LIKE "%trigger%" OR name_loc0 LIKE "%credit%" OR name_loc0 LIKE "%marker%"', CUSTOM_EXCLUDE_FOR_LISTVIEW);
DB::Aowow()->qry('UPDATE ::creature SET cuFlags = cuFlags | %i WHERE name_loc0 LIKE "%[%" OR name_loc0 LIKE "%(%" OR name_loc0 LIKE "%visual%" OR name_loc0 LIKE "%trigger%" OR name_loc0 LIKE "%credit%" OR name_loc0 LIKE "%marker%"', CUSTOM_EXCLUDE_FOR_LISTVIEW);
$this->reapplyCCFlags('creature', Type::NPC);

View file

@ -21,15 +21,15 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $worldDependency = ['item_template', 'item_template_locale'];
protected $setupAfter = [['icons'], []];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_currencies');
DB::Aowow()->query('INSERT INTO ?_currencies (`id`, `category`, `itemId`) SELECT `id`, LEAST(`category`, 41), `itemId` FROM dbc_currencytypes');
DB::Aowow()->qry('TRUNCATE ::currencies');
DB::Aowow()->qry('INSERT INTO ::currencies (`id`, `category`, `itemId`) SELECT `id`, LEAST(`category`, 41), `itemId` FROM dbc_currencytypes');
$moneyItems = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, `itemId` FROM dbc_currencytypes{ WHERE `id` IN (?a)}', $ids ?: DBSIMPLE_SKIP);
$moneyItems = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, `itemId` FROM dbc_currencytypes');
// apply names & cap
$moneyNames = DB::World()->select(
$moneyNames = DB::World()->selectAssoc(
'SELECT it.`entry` AS ARRAY_KEY,
it.`name` AS `name_loc0`, IFNULL(itl2.`Name`, "") AS `name_loc2`, IFNULL(itl3.`Name`, "") AS `name_loc3`, IFNULL(itl4.`Name`, "") AS `name_loc4`, IFNULL(itl6.`Name`, "") AS `name_loc6`, IFNULL(itl8.`Name`, "") AS `name_loc8`,
it.`maxCount` AS `cap`
@ -39,7 +39,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
LEFT JOIN item_template_locale itl4 ON it.entry = itl4.ID AND itl4.locale = "zhCN"
LEFT JOIN item_template_locale itl6 ON it.entry = itl6.ID AND itl6.locale = "esES"
LEFT JOIN item_template_locale itl8 ON it.entry = itl8.ID AND itl8.locale = "ruRU"
WHERE it.entry IN (?a)',
WHERE it.entry IN %in',
$moneyItems
);
@ -53,16 +53,16 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$strings = ['name_loc0' => 'Item #'.$itemId.' not in DB', 'iconId' => 0, 'cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW, 'category' => 3];
}
DB::Aowow()->query('UPDATE ?_currencies SET ?a WHERE itemId = ?d', $strings, $itemId);
DB::Aowow()->qry('UPDATE ::currencies SET %a WHERE itemId = %i', $strings, $itemId);
}
// apply icons
$displayIds = DB::World()->selectCol('SELECT `entry` AS ARRAY_KEY, `displayid` FROM item_template WHERE `entry` IN (?a)', $moneyItems);
$displayIds = DB::World()->selectCol('SELECT `entry` AS ARRAY_KEY, `displayid` FROM item_template WHERE `entry` IN %in', $moneyItems);
foreach ($displayIds as $itemId => $iconId)
DB::Aowow()->query(
'UPDATE ?_currencies c, ?_icons i, dbc_itemdisplayinfo idi
DB::Aowow()->qry(
'UPDATE ::currencies c, ::icons i, dbc_itemdisplayinfo idi
SET c.`iconId` = i.`id`
WHERE i.`name_source` = LOWER(idi.`inventoryIcon1`) AND idi.`id` = ?d AND c.`itemId` = ?d',
WHERE i.`name_source` = LOWER(idi.`inventoryIcon1`) AND idi.`id` = %i AND c.`itemId` = %i',
$iconId, $itemId
);

View file

@ -17,15 +17,15 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $dbcSourceFiles = ['declinedword', 'declinedwordcases'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
CLI::write('[declinedwords] - copying declinedword.dbc into aowow_declinedword');
DB::Aowow()->query('TRUNCATE ?_declinedword');
DB::Aowow()->query('INSERT INTO ?_declinedword SELECT * FROM dbc_declinedword');
DB::Aowow()->qry('TRUNCATE ::declinedword');
DB::Aowow()->qry('INSERT INTO ::declinedword SELECT * FROM dbc_declinedword');
CLI::write('[declinedwords] - copying declinedwordcases.dbc into aowow_declinedwordcases');
DB::Aowow()->query('TRUNCATE ?_declinedwordcases');
DB::Aowow()->query('INSERT INTO ?_declinedwordcases SELECT `wordId`, `caseIdx`, `word` FROM dbc_declinedwordcases');
DB::Aowow()->qry('TRUNCATE ::declinedwordcases');
DB::Aowow()->qry('INSERT INTO ::declinedwordcases SELECT `wordId`, `caseIdx`, `word` FROM dbc_declinedwordcases');
return true;
}

View file

@ -20,7 +20,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
private $textData = [];
public function generate(array $ids = []) : bool
public function generate() : bool
{
$globStrPath = CLISetup::$srcDir.'%sInterface/FrameXML/GlobalStrings.lua';
$allOK = true;
@ -33,8 +33,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CLI::write(' Emote aliasses can not be generated for affected locales!', CLI::LOG_WARN);
}
DB::Aowow()->query('TRUNCATE ?_emotes');
DB::Aowow()->query('TRUNCATE ?_emotes_aliasses');
DB::Aowow()->qry('TRUNCATE ::emotes');
DB::Aowow()->qry('TRUNCATE ::emotes_aliasses');
/*********************/
@ -53,13 +53,13 @@ CLISetup::registerSetup("sql", new class extends SetupScript
12 female others no ext -> none 4 -
*/
$this->textData = DB::Aowow()->select('SELECT `id` AS ARRAY_KEY, `text_loc0` AS "0", `text_loc2` AS "2", `text_loc3` AS "3", `text_loc4` AS "4", `text_loc6` AS "6", `text_loc8` AS "8" FROM dbc_emotestextdata');
$this->textData = DB::Aowow()->selectAssoc('SELECT `id` AS ARRAY_KEY, `text_loc0` AS "0", `text_loc2` AS "2", `text_loc3` AS "3", `text_loc4` AS "4", `text_loc6` AS "6", `text_loc8` AS "8" FROM dbc_emotestextdata');
$texts = DB::Aowow()->select('SELECT et.`id` AS ARRAY_KEY, LOWER(`command`) AS "cmd", IF(e.`animationId`, 1, 0) AS "anim", -`emoteId` AS "parent", e.`soundId`, `etd0`, `etd1`, `etd2`, `etd4`, `etd6`, `etd8`, `etd9`, `etd12` FROM dbc_emotestext et LEFT JOIN dbc_emotes e ON e.`id` = et.`emoteId`');
$texts = DB::Aowow()->selectAssoc('SELECT et.`id` AS ARRAY_KEY, LOWER(`command`) AS "cmd", IF(e.`animationId`, 1, 0) AS "anim", -`emoteId` AS "parent", e.`soundId`, `etd0`, `etd1`, `etd2`, `etd4`, `etd6`, `etd8`, `etd9`, `etd12` FROM dbc_emotestext et LEFT JOIN dbc_emotes e ON e.`id` = et.`emoteId`');
foreach ($texts AS $id => $t)
{
DB::Aowow()->query(
'INSERT INTO ?_emotes (
DB::Aowow()->qry(
'INSERT INTO ::emotes (
`id`, `cmd`, `isAnimated`, `parentEmote`, `soundId`,
`extToExt_loc0`, `extToMe_loc0`, `meToExt_loc0`, `extToNone_loc0`, `meToNone_loc0`,
`extToExt_loc2`, `extToMe_loc2`, `meToExt_loc2`, `extToNone_loc2`, `meToNone_loc2`,
@ -68,7 +68,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
`extToExt_loc6`, `extToMe_loc6`, `meToExt_loc6`, `extToNone_loc6`, `meToNone_loc6`,
`extToExt_loc8`, `extToMe_loc8`, `meToExt_loc8`, `extToNone_loc8`, `meToNone_loc8`)
VALUES
(?d, ?, ?d, ?d, ?d, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
(%i, %s, %i, %i, %i, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)',
$id, $t['cmd'], $t['anim'], $t['parent'], $t['soundId'],
$this->mergeGenderedStrings($t['etd0'], $t['etd8'], Locale::EN), $this->mergeGenderedStrings($t['etd1'], $t['etd9'], Locale::EN), $this->textData[$t['etd2']][Locale::EN->value] ?? '', $this->mergeGenderedStrings($t['etd4'], $t['etd12'], Locale::EN), $this->textData[$t['etd6']][Locale::EN->value] ?? '',
$this->mergeGenderedStrings($t['etd0'], $t['etd8'], Locale::FR), $this->mergeGenderedStrings($t['etd1'], $t['etd9'], Locale::FR), $this->textData[$t['etd2']][Locale::FR->value] ?? '', $this->mergeGenderedStrings($t['etd4'], $t['etd12'], Locale::FR), $this->textData[$t['etd6']][Locale::FR->value] ?? '',
@ -88,12 +88,12 @@ CLISetup::registerSetup("sql", new class extends SetupScript
foreach (CLISetup::searchGlobalStrings('/^VOICEMACRO_LABEL_([A-Z]+)\d+ = \"([^"]+)\";$/') as $locId => [, $cmd, $alias])
$voiceAliases[$cmd][] = [$locId, $alias];
$emotes = DB::Aowow()->selectCol('SELECT id AS ARRAY_KEY, cmd FROM ?_emotes');
$emotes = DB::Aowow()->selectCol('SELECT id AS ARRAY_KEY, cmd FROM ::emotes');
foreach($emotes as $eId => $cmd)
{
foreach ($voiceAliases[strtoupper($cmd)] ?? [] as [$locId, $alias])
DB::Aowow()->query('INSERT IGNORE INTO ?_emotes_aliasses VALUES (?d, ?d, ?) ON DUPLICATE KEY UPDATE `locales` = `locales` | ?d', $eId, (1 << $locId), mb_strtolower($alias), (1 << $locId));
DB::Aowow()->qry('INSERT IGNORE INTO ::emotes_aliasses VALUES (%i, %i, %s) ON DUPLICATE KEY UPDATE `locales` = `locales` | %i', $eId, (1 << $locId), mb_strtolower($alias), (1 << $locId));
foreach ($aliasses as $data)
{
@ -101,20 +101,20 @@ CLISetup::registerSetup("sql", new class extends SetupScript
continue;
foreach ($data as [$locId, $alias])
DB::Aowow()->query('INSERT IGNORE INTO ?_emotes_aliasses VALUES (?d, ?d, ?) ON DUPLICATE KEY UPDATE `locales` = `locales` | ?d', $eId, (1 << $locId), mb_strtolower($alias), (1 << $locId));
DB::Aowow()->qry('INSERT IGNORE INTO ::emotes_aliasses VALUES (%i, %i, %s) ON DUPLICATE KEY UPDATE `locales` = `locales` | %i', $eId, (1 << $locId), mb_strtolower($alias), (1 << $locId));
break;
}
}
DB::Aowow()->query('UPDATE ?_emotes e LEFT JOIN ?_emotes_aliasses ea ON ea.`id` = e.`id` SET e.`cuFlags` = e.`cuFlags` | ?d WHERE ea.`id` IS NULL', CUSTOM_EXCLUDE_FOR_LISTVIEW | EMOTE_CU_MISSING_CMD);
DB::Aowow()->qry('UPDATE ::emotes e LEFT JOIN ::emotes_aliasses ea ON ea.`id` = e.`id` SET e.`cuFlags` = e.`cuFlags` | %i WHERE ea.`id` IS NULL', CUSTOM_EXCLUDE_FOR_LISTVIEW | EMOTE_CU_MISSING_CMD);
/*********************/
/* Server controlled */
/*********************/
DB::Aowow()->query('INSERT INTO ?_emotes (`id`, `cmd`, `flags`, `isAnimated`, `parentEmote`, `soundId`, `state`, `stateParam`, `cuFlags`) SELECT -`id`, `name`, `flags`, IF(`animationId`, 1, 0), 0, `soundId`, `state`, `stateParam`, ?d FROM dbc_emotes WHERE 1', CUSTOM_EXCLUDE_FOR_LISTVIEW);
DB::Aowow()->qry('INSERT INTO ::emotes (`id`, `cmd`, `flags`, `isAnimated`, `parentEmote`, `soundId`, `state`, `stateParam`, `cuFlags`) SELECT -`id`, `name`, `flags`, IF(`animationId`, 1, 0), 0, `soundId`, `state`, `stateParam`, %i FROM dbc_emotes WHERE 1', CUSTOM_EXCLUDE_FOR_LISTVIEW);
$this->reapplyCCFlags('emotes', Type::EMOTE);

View file

@ -17,11 +17,11 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $worldDependency = ['game_event', 'game_event_prerequisite'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_events');
DB::Aowow()->qry('TRUNCATE ::events');
$events = DB::World()->select(
$events = DB::World()->selectAssoc(
'SELECT ge.eventEntry,
holiday,
0, -- cuFlags
@ -33,13 +33,11 @@ CLISetup::registerSetup("sql", new class extends SetupScript
description
FROM game_event ge
LEFT JOIN game_event_prerequisite gep ON gep.eventEntry = ge.eventEntry
{ WHERE ge.eventEntry IN (?a) }
GROUP BY ge.eventEntry',
$ids ?: DBSIMPLE_SKIP
);
foreach ($events as $e)
DB::Aowow()->query('INSERT INTO ?_events VALUES (?a)', array_values($e));
DB::Aowow()->qry('INSERT INTO ::events VALUES %l', $e);
$this->reapplyCCFlags('events', Type::WORLDEVENT);

View file

@ -19,13 +19,13 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $dbcSourceFiles = ['faction', 'factiontemplate'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_factions');
DB::Aowow()->query('TRUNCATE ?_factiontemplate');
DB::Aowow()->qry('TRUNCATE ::factions');
DB::Aowow()->qry('TRUNCATE ::factiontemplate');
DB::Aowow()->query(
'INSERT INTO ?_factions
DB::Aowow()->qry(
'INSERT INTO ::factions
SELECT f.`id`,
f.`repIdx`,
`baseRepRaceMask1`, `baseRepRaceMask2`, `baseRepRaceMask3`, `baseRepRaceMask4`,
@ -44,8 +44,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
GROUP BY f.`id`'
);
DB::Aowow()->query(
'INSERT INTO ?_factiontemplate
DB::Aowow()->qry(
'INSERT INTO ::factiontemplate
SELECT `id`,
`factionId`,
IF(`friendFactionId1` = 1 OR `friendFactionId2` = 1 OR `friendFactionId3` = 1 OR `friendFactionId4` = 1 OR `friendlyMask` & 0x3, 1,
@ -55,36 +55,36 @@ CLISetup::registerSetup("sql", new class extends SetupScript
FROM dbc_factiontemplate'
);
DB::Aowow()->query(
'UPDATE ?_factions f
DB::Aowow()->qry(
'UPDATE ::factions f
JOIN (SELECT ft.`factionId`, GROUP_CONCAT(ft.`id` SEPARATOR " ") AS "tplIds" FROM dbc_factiontemplate ft GROUP BY ft.`factionId`) temp ON f.`id` = temp.`factionId`
SET f.`templateIds` = temp.`tplIds`'
);
DB::Aowow()->query(
'UPDATE ?_factions x
DB::Aowow()->qry(
'UPDATE ::factions x
JOIN dbc_faction f ON f.`id` = x.`id`
SET `cuFlags` = `cuFlags` | ?d
WHERE f.`repIdx` < 0 OR f.`id` = 952 OR ( (f.`repFlags1` & ?d) > 0 AND f.`id` NOT IN (67, 169, 469, 589, 1085) AND (f.`repFLags1` & ?d) = 0 )',
SET `cuFlags` = `cuFlags` | %i
WHERE f.`repIdx` < 0 OR f.`id` = 952 OR ( (f.`repFlags1` & %i) > 0 AND f.`id` NOT IN (67, 169, 469, 589, 1085) AND (f.`repFLags1` & %i) = 0 )',
CUSTOM_EXCLUDE_FOR_LISTVIEW,
FACTION_FLAG_HIDDEN | FACTION_FLAG_INVISIBLE_FORCED, FACTION_FLAG_SPECIAL
);
$pairs = array(
[[980], ['expansion' => 1]],
[[1097], ['expansion' => 2]],
[[469, 891, 1037], ['side' => 1]],
[[ 67, 892, 1052], ['side' => 2]],
[[980], ['expansion' => EXP_BC]],
[[1097], ['expansion' => EXP_WOTLK]],
[[469, 891, 1037], ['side' => SIDE_ALLIANCE]],
[[ 67, 892, 1052], ['side' => SIDE_HORDE]],
);
foreach ($pairs as $p)
DB::Aowow()->query(
'UPDATE ?_factions top
JOIN (SELECT `id`, `parentFactionId` FROM ?_factions) mid ON mid.`parentFactionId` IN (?a)
LEFT JOIN (SELECT `id`, `parentFactionId` FROM ?_factions) low ON low.`parentFactionId` = mid.`id`
SET ?a
WHERE `repIdx` > 0 AND (top.`id` IN (?a) OR top.`id` = mid.`id` OR top.`id` = low.`id`)',
$p[0], $p[1], $p[0]
foreach ($pairs as [$factions, $update])
DB::Aowow()->qry(
'UPDATE ::factions top
JOIN (SELECT `id`, `parentFactionId` FROM ::factions) mid ON mid.`parentFactionId` IN %in
LEFT JOIN (SELECT `id`, `parentFactionId` FROM ::factions) low ON low.`parentFactionId` = mid.`id`
SET %a
WHERE `repIdx` > 0 AND (top.`id` IN %in OR top.`id` = mid.`id` OR top.`id` = low.`id`)',
$factions, $update, $factions
);
$this->reapplyCCFlags('factions', Type::FACTION);

View file

@ -18,12 +18,12 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $dbcSourceFiles = ['glyphproperties', 'spellicon'];
protected $setupAfter = [['icons'], []];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_glyphproperties');
DB::Aowow()->query('INSERT INTO ?_glyphproperties SELECT id, spellId, typeFlags, 0, iconId FROM dbc_glyphproperties');
DB::Aowow()->qry('TRUNCATE ::glyphproperties');
DB::Aowow()->qry('INSERT INTO ::glyphproperties SELECT `id`, `spellId`, `typeFlags`, 0, `iconId` FROM dbc_glyphproperties');
DB::Aowow()->query('UPDATE ?_glyphproperties gp, ?_icons ic, dbc_spellicon si SET gp.iconId = ic.id WHERE gp.iconIdBak = si.id AND ic.name_source = LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1))');
DB::Aowow()->qry('UPDATE ::glyphproperties gp, ::icons ic, dbc_spellicon si SET gp.`iconId` = ic.`id` WHERE gp.`iconIdBak` = si.`id` AND ic.`name_source` = LOWER(SUBSTRING_INDEX(si.`iconPath`, "\\", -1))');
return true;
}

View file

@ -31,11 +31,11 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $setupAfter = [['icons'], []];
protected $dbcSourceFiles = ['holidays', 'holidaydescriptions', 'holidaynames'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_holidays');
DB::Aowow()->query(
'INSERT INTO ?_holidays (`id`, `name_loc0`, `name_loc2`, `name_loc3`, `name_loc4`, `name_loc6`, `name_loc8`, `description_loc0`, `description_loc2`, `description_loc3`, `description_loc4`, `description_loc6`, `description_loc8`, `looping`, `scheduleType`, `textureString`)
DB::Aowow()->qry('TRUNCATE ::holidays');
DB::Aowow()->qry(
'INSERT INTO ::holidays (`id`, `name_loc0`, `name_loc2`, `name_loc3`, `name_loc4`, `name_loc6`, `name_loc8`, `description_loc0`, `description_loc2`, `description_loc3`, `description_loc4`, `description_loc6`, `description_loc8`, `looping`, `scheduleType`, `textureString`)
SELECT h.`id`, n.`name_loc0`, n.`name_loc2`, n.`name_loc3`, n.`name_loc4`, n.`name_loc6`, n.`name_loc8`, d.`description_loc0`, d.`description_loc2`, d.`description_loc3`, d.`description_loc4`, d.`description_loc6`, d.`description_loc8`, h.`looping`, h.`scheduleType`, h.`textureString`
FROM dbc_holidays h
LEFT JOIN dbc_holidaynames n ON n.`id` = h.`nameId`
@ -43,11 +43,11 @@ CLISetup::registerSetup("sql", new class extends SetupScript
);
// set derived icons
DB::Aowow()->query('UPDATE ?_holidays h, ?_icons i SET h.`iconId` = i.`id` WHERE i.`name_source` LIKE CONCAT(LOWER(h.`textureString`), "%") AND h.`textureString` <> ""');
DB::Aowow()->qry('UPDATE ::holidays h, ::icons i SET h.`iconId` = i.`id` WHERE i.`name_source` LIKE CONCAT(LOWER(h.`textureString`), "%") AND h.`textureString` <> ""');
// set custom icons
foreach (self::CUSTOM_ICONS as $hId => $iconString)
DB::Aowow()->query('UPDATE ?_holidays h SET h.`iconId` = (SELECT i.`id` FROM ?_icons i WHERE `name_source` = ?) WHERE `id` = ?d', $iconString, $hId);
DB::Aowow()->qry('UPDATE ::holidays h SET h.`iconId` = (SELECT i.`id` FROM ::icons i WHERE `name_source` = ?) WHERE `id` = %i', $iconString, $hId);
return true;
}

View file

@ -37,36 +37,36 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $dbcSourceFiles = ['spellicon', 'itemdisplayinfo', 'creaturefamily'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_icons');
DB::Aowow()->query('ALTER TABLE ?_icons AUTO_INCREMENT = 1');
DB::Aowow()->query(
'INSERT INTO ?_icons (`name`, `name_source`) SELECT REGEXP_REPLACE(x, "\\\\W", "-"), x FROM
DB::Aowow()->qry('TRUNCATE ::icons');
DB::Aowow()->qry('ALTER TABLE ::icons AUTO_INCREMENT = 1');
DB::Aowow()->qry(
'INSERT INTO ::icons (`name`, `name_source`) SELECT REGEXP_REPLACE(x, "\\W", "-"), x FROM
(
(SELECT LOWER(SUBSTRING_INDEX(`iconPath`, "\\\\", -1)) AS x FROM dbc_spellicon WHERE `iconPath` LIKE "%icons%") UNION
(SELECT LOWER(`inventoryIcon1`) AS x FROM dbc_itemdisplayinfo WHERE `inventoryIcon1` <> "") UNION
(SELECT LOWER(SUBSTRING_INDEX(`iconString`, "\\\\", -1)) AS x FROM dbc_creaturefamily WHERE `iconString` LIKE "%icons%")
(SELECT LOWER(SUBSTRING_INDEX(`iconPath`, "\\", -1)) AS x FROM dbc_spellicon WHERE `iconPath` LIKE "%icons%") UNION
(SELECT LOWER(`inventoryIcon1`) AS x FROM dbc_itemdisplayinfo WHERE `inventoryIcon1` <> "") UNION
(SELECT LOWER(SUBSTRING_INDEX(`iconString`, "\\", -1)) AS x FROM dbc_creaturefamily WHERE `iconString` LIKE "%icons%")
) y GROUP BY x'
);
// invent class icons
foreach (ChrClass::cases() as $cl)
DB::Aowow()->query('INSERT INTO ?_icons (`name`, `name_source`) VALUES (?, ?)', 'class_'.$cl->json(), 'class_'.$cl->json());
DB::Aowow()->qry('INSERT INTO ::icons (`name`, `name_source`) VALUES (%s, %s)', 'class_'.$cl->json(), 'class_'.$cl->json());
// invent race icons
foreach (ChrRace::cases() as $ra)
{
if ($na = $ra->json()) // unused races have no json
{
DB::Aowow()->query('INSERT INTO ?_icons (`name`, `name_source`) VALUES (?, ?)', 'race_'.$na.'_male', 'race_'.$na.'_male');
DB::Aowow()->query('INSERT INTO ?_icons (`name`, `name_source`) VALUES (?, ?)', 'race_'.$na.'_female', 'race_'.$na.'_female');
DB::Aowow()->qry('INSERT INTO ::icons (`name`, `name_source`) VALUES (%s, %s)', 'race_'.$na.'_male', 'race_'.$na.'_male');
DB::Aowow()->qry('INSERT INTO ::icons (`name`, `name_source`) VALUES (%s, %s)', 'race_'.$na.'_female', 'race_'.$na.'_female');
}
}
// halucinate holidays
foreach (self::HOLIDAY_ICONS as $h)
DB::Aowow()->query('INSERT INTO ?_icons (`name`, `name_source`) VALUES (?, ?)', $h, $h);
DB::Aowow()->qry('INSERT INTO ::icons (`name`, `name_source`) VALUES (%s, %s)', $h, $h);
$this->reapplyCCFlags('icons', Type::ICON);

View file

@ -18,22 +18,22 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $dbcSourceFiles = ['spellitemenchantment'];
protected $worldDependency = ['spell_enchant_proc_data'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_itemenchantment');
DB::Aowow()->query(
'INSERT INTO ?_itemenchantment
DB::Aowow()->qry('TRUNCATE ::itemenchantment');
DB::Aowow()->qry(
'INSERT INTO ::itemenchantment
SELECT `Id`, `charges`, 0, 0, 0, `type1`, `type2`, `type3`, `amount1`, `amount2`, `amount3`, `object1`, `object2`, `object3`, `name_loc0`, `name_loc2`, `name_loc3`, `name_loc4`, `name_loc6`, `name_loc8`, `conditionId`, `skillLine`, `skillLevel`, `requiredLevel`
FROM dbc_spellitemenchantment'
);
$cuProcs = DB::World()->select('SELECT `EnchantID` AS ARRAY_KEY, `Chance` AS `procChance`, `ProcsPerMinute` AS `ppmRate` FROM spell_enchant_proc_data');
$cuProcs = DB::World()->selectAssoc('SELECT `EnchantID` AS ARRAY_KEY, `Chance` AS `procChance`, `ProcsPerMinute` AS `ppmRate` FROM spell_enchant_proc_data');
foreach ($cuProcs as $id => $vals)
DB::Aowow()->query('UPDATE ?_itemenchantment SET ?a WHERE `id` = ?d', $vals, $id);
DB::Aowow()->qry('UPDATE ::itemenchantment SET %a WHERE `id` = %i', $vals, $id);
// hide strange stuff
DB::Aowow()->query('UPDATE ?_itemenchantment SET `cuFlags` = ?d WHERE `type1` = 0 AND `type2` = 0 AND `type3` = 0', CUSTOM_EXCLUDE_FOR_LISTVIEW);
DB::Aowow()->query('UPDATE ?_itemenchantment SET `cuFlags` = ?d WHERE `name_loc0` LIKE "%test%"', CUSTOM_EXCLUDE_FOR_LISTVIEW);
DB::Aowow()->qry('UPDATE ::itemenchantment SET `cuFlags` = %i WHERE `type1` = 0 AND `type2` = 0 AND `type3` = 0', CUSTOM_EXCLUDE_FOR_LISTVIEW);
DB::Aowow()->qry('UPDATE ::itemenchantment SET `cuFlags` = %i WHERE `name_loc0` LIKE "%test%"', CUSTOM_EXCLUDE_FOR_LISTVIEW);
$this->reapplyCCFlags('itemenchantment', Type::ENCHANTMENT);

View file

@ -17,11 +17,11 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $dbcSourceFiles = ['itemrandomsuffix', 'itemrandomproperties'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_itemrandomenchant');
DB::Aowow()->query(
'INSERT INTO ?_itemrandomenchant
DB::Aowow()->qry('TRUNCATE ::itemrandomenchant');
DB::Aowow()->qry(
'INSERT INTO ::itemrandomenchant
SELECT -id, name_loc0, name_loc2, name_loc3, name_loc4, name_loc6, name_loc8, nameINT, enchantId1, enchantId2, enchantId3, enchantId4, enchantId5, allocationPct1, allocationPct2, allocationPct3, allocationPct4, allocationPct5 FROM dbc_itemrandomsuffix UNION
SELECT id, name_loc0, name_loc2, name_loc3, name_loc4, name_loc6, name_loc8, nameINT, enchantId1, enchantId2, enchantId3, enchantId4, enchantId5, 0, 0, 0, 0, 0 FROM dbc_itemrandomproperties'
);

View file

@ -29,7 +29,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
SKILL_ALCHEMY => 6
);
public function generate(array $ids = []) : bool
public function generate() : bool
{
$baseQuery =
'SELECT it.entry,
@ -128,39 +128,38 @@ CLISetup::registerSetup("sql", new class extends SetupScript
LEFT JOIN item_template_locale itl8 ON it.entry = itl8.ID AND itl8.locale = "ruRU"
LEFT JOIN spell_group sg ON sg.spell_id = it.spellid_1 AND it.class = 0 AND it.subclass = 2 AND sg.id IN (1, 2)
LEFT JOIN game_event ge ON ge.holiday = it.HolidayId AND it.HolidayId > 0
{ WHERE it.entry IN (?a) }
LIMIT ?d, ?d';
LIMIT %i, %i';
DB::Aowow()->query('TRUNCATE ?_items');
DB::Aowow()->query('SET SESSION innodb_ft_enable_stopword = OFF');
DB::Aowow()->qry('TRUNCATE ::items');
DB::Aowow()->qry('SET SESSION innodb_ft_enable_stopword = OFF');
$i = 0;
while ($items = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, CLISetup::SQL_BATCH * $i, CLISetup::SQL_BATCH))
while ($items = DB::World()->selectAssoc($baseQuery, CLISetup::SQL_BATCH * $i, CLISetup::SQL_BATCH))
{
CLI::write(' * batch #' . ++$i . ' (' . count($items) . ')', tmpRow: true);
foreach ($items as $item)
DB::Aowow()->query('INSERT INTO ?_items VALUES (?a)', array_values($item));
DB::Aowow()->qry('INSERT INTO ::items VALUES %l', $item);
}
CLI::write('[items] - applying misc data & fixes');
// merge with gemProperties
DB::Aowow()->query('UPDATE ?_items i, dbc_gemproperties gp SET i.gemEnchantmentId = gp.enchantmentId, i.gemColorMask = gp.colorMask WHERE i.gemColorMask = gp.id');
DB::Aowow()->qry('UPDATE ::items i, dbc_gemproperties gp SET i.gemEnchantmentId = gp.enchantmentId, i.gemColorMask = gp.colorMask WHERE i.gemColorMask = gp.id');
// get modelString
DB::Aowow()->query('UPDATE ?_items i, dbc_itemdisplayinfo idi SET i.model = IF(idi.leftModelName = "", idi.rightModelName, idi.leftModelName) WHERE i.displayId = idi.id');
DB::Aowow()->qry('UPDATE ::items i, dbc_itemdisplayinfo idi SET i.model = IF(idi.leftModelName = "", idi.rightModelName, idi.leftModelName) WHERE i.displayId = idi.id');
// get iconId
DB::Aowow()->query('UPDATE ?_items i, dbc_itemdisplayinfo idi, ?_icons ic SET i.iconId = ic.id WHERE i.displayId = idi.id AND LOWER(idi.inventoryIcon1) = ic.name_source');
DB::Aowow()->qry('UPDATE ::items i, dbc_itemdisplayinfo idi, ::icons ic SET i.iconId = ic.id WHERE i.displayId = idi.id AND LOWER(idi.inventoryIcon1) = ic.name_source');
// unify slots: Robes => Chest; Ranged (right) => Ranged
DB::Aowow()->query('UPDATE ?_items SET slot = ?d WHERE slotbak = ?d', INVTYPE_RANGED, INVTYPE_RANGEDRIGHT);
DB::Aowow()->query('UPDATE ?_items SET slot = ?d WHERE slotbak = ?d', INVTYPE_CHEST, INVTYPE_ROBE);
DB::Aowow()->qry('UPDATE ::items SET slot = %i WHERE slotbak = %i', INVTYPE_RANGED, INVTYPE_RANGEDRIGHT);
DB::Aowow()->qry('UPDATE ::items SET slot = %i WHERE slotbak = %i', INVTYPE_CHEST, INVTYPE_ROBE);
// custom sub-classes
DB::Aowow()->query(
'UPDATE ?_items SET subclass = IF(
DB::Aowow()->qry(
'UPDATE ::items SET subclass = IF(
slotbak = 4, -8, IF( -- shirt
slotbak = 19, -7, IF( -- tabard
slotbak = 16, -6, IF( -- cloak
@ -172,49 +171,49 @@ CLISetup::registerSetup("sql", new class extends SetupScript
);
// move alchemist stones to trinkets (Armor)
DB::Aowow()->query('UPDATE ?_items SET class = 4, subClass = -4 WHERE classBak = 7 AND subClassBak = 11 AND slotBak = ?d', INVTYPE_TRINKET);
DB::Aowow()->qry('UPDATE ::items SET class = 4, subClass = -4 WHERE classBak = 7 AND subClassBak = 11 AND slotBak = %i', INVTYPE_TRINKET);
// mark keys as key (if not quest items)
DB::Aowow()->query('UPDATE ?_items SET class = 13, subClass = 0 WHERE classBak IN (0, 15) AND bagFamily & 0x100');
DB::Aowow()->qry('UPDATE ::items SET class = 13, subClass = 0 WHERE classBak IN (0, 15) AND bagFamily & 0x100');
// set subSubClass for Glyphs (major/minor)
DB::Aowow()->query('UPDATE ?_items i, dbc_spell s, dbc_glyphproperties gp SET i.subSubClass = IF(gp.typeFlags & 0x1, 2, 1) WHERE i.spellId1 = s.id AND s.effect1MiscValue = gp.id AND i.classBak = 16');
DB::Aowow()->qry('UPDATE ::items i, dbc_spell s, dbc_glyphproperties gp SET i.subSubClass = IF(gp.typeFlags & 0x1, 2, 1) WHERE i.spellId1 = s.id AND s.effect1MiscValue = gp.id AND i.classBak = 16');
// filter misc(class:15) junk(subclass:0) to appropriate categories
// assign pets and mounts to category
DB::Aowow()->query('UPDATE ?_items i, dbc_spell s SET subClass = IF(effect1AuraId <> 78, 2, IF(effect2AuraId = 207 OR effect3AuraId = 207 OR (s.id <> 65917 AND effect2AuraId = 4 AND effect3Id = 77), -7, 5)) WHERE s.id = spellId2 AND class = 15 AND spellId1 IN (?a)', LEARN_SPELLS);
DB::Aowow()->qry('UPDATE ::items i, dbc_spell s SET subClass = IF(effect1AuraId <> 78, 2, IF(effect2AuraId = 207 OR effect3AuraId = 207 OR (s.id <> 65917 AND effect2AuraId = 4 AND effect3Id = 77), -7, 5)) WHERE s.id = spellId2 AND class = 15 AND spellId1 IN %in', LEARN_SPELLS);
// more corner cases (mounts that are not actualy learned)
DB::Aowow()->query('UPDATE ?_items i, dbc_spell s SET i.subClass = -7 WHERE (effect1Id = 64 OR (effect1AuraId = 78 AND effect2AuraId = 4 AND effect3Id = 77) OR effect1AuraId = 207 OR effect2AuraId = 207 OR effect3AuraId = 207) AND s.id = i.spellId1 AND i.class = 15 AND i.subClass = 5');
DB::Aowow()->query('UPDATE ?_items i, dbc_spell s SET i.subClass = 5 WHERE s.effect1AuraId = 78 AND s.id = i.spellId1 AND i.class = 15 AND i.subClass = 0');
DB::Aowow()->qry('UPDATE ::items i, dbc_spell s SET i.subClass = -7 WHERE (effect1Id = 64 OR (effect1AuraId = 78 AND effect2AuraId = 4 AND effect3Id = 77) OR effect1AuraId = 207 OR effect2AuraId = 207 OR effect3AuraId = 207) AND s.id = i.spellId1 AND i.class = 15 AND i.subClass = 5');
DB::Aowow()->qry('UPDATE ::items i, dbc_spell s SET i.subClass = 5 WHERE s.effect1AuraId = 78 AND s.id = i.spellId1 AND i.class = 15 AND i.subClass = 0');
// move some permanent enchantments to own category
DB::Aowow()->query('UPDATE ?_items i, dbc_spell s SET i.class = 0, i.subClass = 6 WHERE s.effect1Id = 53 AND s.id = i.spellId1 AND i.class = 15');
DB::Aowow()->qry('UPDATE ::items i, dbc_spell s SET i.class = 0, i.subClass = 6 WHERE s.effect1Id = 53 AND s.id = i.spellId1 AND i.class = 15');
// move temporary enchantments to own category
DB::Aowow()->query('UPDATE ?_items i, dbc_spell s SET i.subClass = -3 WHERE s.effect1Id = 54 AND s.id = i.spellId1 AND i.class = 0 AND i.subClassBak = 8');
DB::Aowow()->qry('UPDATE ::items i, dbc_spell s SET i.subClass = -3 WHERE s.effect1Id = 54 AND s.id = i.spellId1 AND i.class = 0 AND i.subClassBak = 8');
// move armor tokens to own category
DB::Aowow()->query('UPDATE ?_items SET subClass = -2 WHERE quality = 4 AND class = 15 AND subClassBak = 0 AND requiredClass > 0');
DB::Aowow()->qry('UPDATE ::items SET subClass = -2 WHERE quality = 4 AND class = 15 AND subClassBak = 0 AND requiredClass > 0');
// move some junk to holiday if it requires one
DB::Aowow()->query('UPDATE ?_items SET subClass = 3 WHERE classBak = 15 AND subClassBak = 0 AND eventId <> 0');
DB::Aowow()->qry('UPDATE ::items SET subClass = 3 WHERE classBak = 15 AND subClassBak = 0 AND eventId <> 0');
// move misc items that start quests to class: quest (except Sayges scrolls for consistency)
DB::Aowow()->query('UPDATE ?_items SET class = 12 WHERE classBak = 15 AND startQuest <> 0 AND name_loc0 NOT LIKE "sayge\'s fortune%"');
DB::Aowow()->qry('UPDATE ::items SET class = 12 WHERE classBak = 15 AND startQuest <> 0 AND name_loc0 NOT LIKE "sayge\'s fortune%"');
// move perm. enchantments into appropriate cat/subcat
DB::Aowow()->query('UPDATE ?_items i, dbc_spell s SET i.class = 0, i.subClass = 6 WHERE s.id = i.spellId1 AND s.effect1Id = 53 AND i.classBak = 12');
DB::Aowow()->qry('UPDATE ::items i, dbc_spell s SET i.class = 0, i.subClass = 6 WHERE s.id = i.spellId1 AND s.effect1Id = 53 AND i.classBak = 12');
// move some generic recipes into appropriate sub-categories
foreach (self::SKILL_CATG as $skill => $cat)
DB::Aowow()->query('UPDATE ?_items SET subClass = ?d WHERE classBak = 9 AND subClassBak = 0 AND requiredSkill = ?d', $cat, $skill);
DB::Aowow()->qry('UPDATE ::items SET subClass = %i WHERE classBak = 9 AND subClassBak = 0 AND requiredSkill = %i', $cat, $skill);
// assign slot from onUse spell to item (todo (med): handle multi slot enchantments (like armor kits))
DB::Aowow()->query(
'UPDATE ?_items i
JOIN (SELECT `id`, LOG(2, `equippedItemInventoryTypeMask` & ~?d) AS `mask`
DB::Aowow()->qry(
'UPDATE ::items i
JOIN (SELECT `id`, LOG(2, `equippedItemInventoryTypeMask` & ~%i) AS `mask`
FROM dbc_spell
WHERE `equippedItemInventoryTypeMask` > 0
HAVING CAST(`mask` AS UNSIGNED) = CAST(`mask` AS FLOAT)) s
@ -225,8 +224,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
);
// calculate durabilityCosts
DB::Aowow()->query(
'UPDATE ?_items i
DB::Aowow()->qry(
'UPDATE ::items i
JOIN dbc_durabilityquality dq ON dq.id = ((i.quality + 1) * 2)
JOIN dbc_durabilitycosts dc ON dc.id = i.itemLevel
SET i.repairPrice = (durability * dq.mod * IF(i.classBak = 2,
@ -244,9 +243,9 @@ CLISetup::registerSetup("sql", new class extends SetupScript
);
// hide some nonsense
DB::Aowow()->query(
'UPDATE ?_items
SET `cuFlags` = `cuFlags` | ?d
DB::Aowow()->qry(
'UPDATE ::items
SET `cuFlags` = `cuFlags` | %i
WHERE `name_loc0` LIKE "Monster - %" OR `name_loc0` LIKE "Creature - %" OR
`name_loc0` LIKE "%[PH]%" OR `name_loc0` LIKE "% PH %" OR
`name_loc0` LIKE "%(new)%" OR `name_loc0` LIKE "%(old)%" OR
@ -263,22 +262,22 @@ CLISetup::registerSetup("sql", new class extends SetupScript
[[INVTYPE_RANGED, INVTYPE_RANGEDRIGHT], [2, 3, 16, 18, 14, 19]]
);
foreach ($checks as [$slots, $subclasses])
DB::Aowow()->query('UPDATE ?_items SET `cuFlags` = `cuFlags` | ?d WHERE `class`= ?d AND `slotBak` IN (?a) AND `subClass` NOT IN (?a)', CUSTOM_EXCLUDE_FOR_LISTVIEW, ITEM_CLASS_WEAPON, $slots, $subclasses);
DB::Aowow()->qry('UPDATE ::items SET `cuFlags` = `cuFlags` | %i WHERE `class`= %i AND `slotBak` IN %in AND `subClass` NOT IN %in', CUSTOM_EXCLUDE_FOR_LISTVIEW, ITEM_CLASS_WEAPON, $slots, $subclasses);
CLI::write('[items] - collecting spell descriptions');
CLI::write(' * fetching', tmpRow: true);
$itemSpellData = DB::Aowow()->select(
'SELECT `id` AS "0", `spellId1` AS "1" FROM ?_items WHERE `spellId1` > 0 UNION
SELECT `id` AS "0", `spellId2` AS "1" FROM ?_items WHERE `spellId2` > 0 UNION
SELECT `id` AS "0", `spellId3` AS "1" FROM ?_items WHERE `spellId3` > 0 UNION
SELECT `id` AS "0", `spellId4` AS "1" FROM ?_items WHERE `spellId4` > 0 UNION
SELECT `id` AS "0", `spellId5` AS "1" FROM ?_items WHERE `spellId5` > 0'
$itemSpellData = DB::Aowow()->selectAssoc(
'SELECT `id` AS "0", `spellId1` AS "1" FROM ::items WHERE `spellId1` > 0 UNION
SELECT `id` AS "0", `spellId2` AS "1" FROM ::items WHERE `spellId2` > 0 UNION
SELECT `id` AS "0", `spellId3` AS "1" FROM ::items WHERE `spellId3` > 0 UNION
SELECT `id` AS "0", `spellId4` AS "1" FROM ::items WHERE `spellId4` > 0 UNION
SELECT `id` AS "0", `spellId5` AS "1" FROM ::items WHERE `spellId5` > 0'
);
$itemSpells = new SpellList(array(['id', array_column($itemSpellData, 1)]), ['interactive' => SpellList::INTERACTIVE_NONE]);
$items = DB::Aowow()->select('SELECT `id` AS ARRAY_KEY, `spellId1`, `spellId2`, `spellId3`, `spellId4`, `spellId5` FROM ?_items WHERE `id` IN (?a)', array_column($itemSpellData, 0));
$items = DB::Aowow()->selectAssoc('SELECT `id` AS ARRAY_KEY, `spellId1`, `spellId2`, `spellId3`, `spellId4`, `spellId5` FROM ::items WHERE `id` IN %in', array_column($itemSpellData, 0));
if (!$itemSpells->error)
{
$i = 0;
@ -313,7 +312,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
foreach ($update as $itemId => $upd)
{
CLI::write(' * writing ' . str_pad(++$i, strlen($total), pad_type: STR_PAD_LEFT) . ' / ' . $total . str_pad('('.number_format(100 * $i / $total, 1).'%)', 8, pad_type: STR_PAD_LEFT), tmpRow: true);
DB::Aowow()->query('UPDATE ?_items SET ?a WHERE `id` = ?d', $upd, $itemId);
DB::Aowow()->qry('UPDATE ::items SET %a WHERE `id` = %i', $upd, $itemId);
}
}

View file

@ -185,17 +185,17 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$data['contentGroup'] = reset($items)['note'];
}
public function generate(array $ids = []) : bool
public function generate() : bool
{
// find events associated with holidayIds
if ($pairs = DB::World()->selectCol('SELECT `holiday` AS ARRAY_KEY, `eventEntry` FROM game_event WHERE `holiday` IN (?a)', array_values($this->setToHoliday)))
if ($pairs = DB::World()->selectCol('SELECT `holiday` AS ARRAY_KEY, `eventEntry` FROM game_event WHERE `holiday` IN %in', array_values($this->setToHoliday)))
foreach ($this->setToHoliday as &$hId)
$hId = !empty($pairs[$hId]) ? $pairs[$hId] : 0;
DB::Aowow()->query('TRUNCATE TABLE ?_itemset');
DB::Aowow()->qry('TRUNCATE TABLE ::itemset');
$virtualId = 0;
$sets = DB::Aowow()->select('SELECT *, `id` AS ARRAY_KEY FROM dbc_itemset');
$sets = DB::Aowow()->selectAssoc('SELECT *, `id` AS ARRAY_KEY FROM dbc_itemset');
$spells = array_merge(
array_column($sets, 'spellId1'), array_column($sets, 'spellId2'), array_column($sets, 'spellId3'),
array_column($sets, 'spellId4'), array_column($sets, 'spellId5'), array_column($sets, 'spellId6'),
@ -204,7 +204,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$bonusSpells = new SpellList(array(['s.id', array_unique($spells)]), ['interactive' => SpellList::INTERACTIVE_NONE]);
$pieces = DB::World()->select('SELECT `itemset` AS ARRAY_KEY, `entry` AS ARRAY_KEY2, `entry`, `name`, `class`, `subclass`, `Quality`, `AllowableClass`, `ItemLevel`, `RequiredLevel`, `itemset`, IF (`Flags` & ?d, 1, 0) AS "heroic", IF(`InventoryType` = 15, 26, IF(`InventoryType` = 5, 20, `InventoryType`)) AS "slot" FROM item_template WHERE `itemset` > 0', ITEM_FLAG_HEROIC);
$pieces = DB::World()->selectAssoc('SELECT `itemset` AS ARRAY_KEY, `entry` AS ARRAY_KEY2, `entry`, `name`, `class`, `subclass`, `Quality`, `AllowableClass`, `ItemLevel`, `RequiredLevel`, `itemset`, IF (`Flags` & %i, 1, 0) AS "heroic", IF(`InventoryType` = 15, 26, IF(`InventoryType` = 5, 20, `InventoryType`)) AS "slot" FROM item_template WHERE `itemset` > 0', ITEM_FLAG_HEROIC);
foreach ($sets as $setId => $setData)
{
@ -272,7 +272,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
if (count($pieces[$setId] ?? []) < 2)
{
$row['cuFlags'] = CUSTOM_EXCLUDE_FOR_LISTVIEW;
DB::Aowow()->query('INSERT INTO ?_itemset (?#) VALUES (?a)', array_keys($row), array_values($row));
DB::Aowow()->qry('INSERT INTO ::itemset %v', $row);
CLI::write('[item set] '.str_pad('['.$setId.']', 7).CLI::bold($setData['name_loc0']).' has no associated items', CLI::LOG_INFO);
continue;
}
@ -294,7 +294,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
else if (in_array($data['slot'], [INVTYPE_WEAPON, INVTYPE_FINGER, INVTYPE_TRINKET]))
$sorted[$k][-$data['slot']] = $data;
// slot confict. If item is being sold, replace old item (imperfect solution :/)
else if (DB::World()->selectCell('SELECT SUM(`n`) FROM (SELECT COUNT(1) AS "n" FROM npc_vendor WHERE `item` = ?d UNION SELECT COUNT(1) AS "n" FROM game_event_npc_vendor WHERE `item` = ?d) x', $data['entry'], $data['entry']))
else if (DB::World()->selectCell('SELECT SUM(`n`) FROM (SELECT COUNT(1) AS "n" FROM npc_vendor WHERE `item` = %i UNION SELECT COUNT(1) AS "n" FROM game_event_npc_vendor WHERE `item` = %i) x', $data['entry'], $data['entry']))
$sorted[$k][$data['slot']] = $data;
}
@ -311,7 +311,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
if ($i++)
$vRow['id'] = --$virtualId;
DB::Aowow()->query('INSERT INTO ?_itemset (?#) VALUES (?a)', array_keys($vRow), array_values($vRow));
DB::Aowow()->qry('INSERT INTO ::itemset %v', $vRow);
}
}

View file

@ -11,7 +11,7 @@ if (!CLI)
class ItemStatSetup extends ItemList
{
public function __construct(int $start, int $limit, int $itemClass, array $ids, private bool $applyTriggered, private array $relEnchants, private array $relSpells)
public function __construct(int $start, int $limit, int $itemClass, private bool $applyTriggered, private array $relEnchants, private array $relSpells)
{
$this->queryOpts['i']['o'] = 'i.id ASC';
unset($this->queryOpts['is']); // do not reference the stats table we are going to write to
@ -22,9 +22,6 @@ class ItemStatSetup extends ItemList
$limit
);
if ($ids)
$conditions[] = ['id', $ids];
parent::__construct($conditions);
}
@ -40,14 +37,14 @@ class ItemStatSetup extends ItemList
if ($spellIds) // array_merge kills the keys
{
$newSpells = DB::Aowow()->select('SELECT *, id AS ARRAY_KEY FROM ?_spell WHERE id IN (?a)', $spellIds);
$newSpells = DB::Aowow()->selectAssoc('SELECT *, id AS ARRAY_KEY FROM ::spell WHERE id IN %in', $spellIds);
$this->relSpells = array_replace($this->relSpells, $newSpells);
// include triggered spell to calculate nutritional values
if ($this->applyTriggered)
if ($t = array_filter(array_merge(array_column($newSpells, 'effect1TriggerSpell'), array_column($newSpells, 'effect2TriggerSpell'), array_column($newSpells, 'effect3TriggerSpell'))))
if ($t = array_diff($t, array_keys($this->relSpells)))
$this->relSpells = array_replace($this->relSpells, DB::Aowow()->select('SELECT *, id AS ARRAY_KEY FROM ?_spell WHERE id IN (?a)', $t));
$this->relSpells = array_replace($this->relSpells, DB::Aowow()->selectAssoc('SELECT *, id AS ARRAY_KEY FROM ::spell WHERE id IN %in', $t));
}
// fromItem: itemMods, spell, enchants from template - fromJson: calculated stats (feralAP, dps, ...)
@ -58,12 +55,9 @@ class ItemStatSetup extends ItemList
if ($this->getField('class') == ITEM_CLASS_WEAPON)
$stats += $shared + ($this->isRangedWeapon() ? ['rgddps' => 0, 'rgddmgmin' => 0, 'rgddmgmax' => 0, 'rgdspeed' => 0] : ['mledps' => 0, 'mledmgmin' => 0, 'mledmgmax' => 0, 'mlespeed' => 0]);
else if ($this->getField('class') == ITEM_CLASS_ARMOR)
$stats += ['armorbonus' => 0]; //ArmorDamageModifier only valid on armor(?)
$stats += ['armorbonus' => 0]; //ArmorDamageModifier only valid on armor(%s)
// apply PK
$stats += ['type' => Type::ITEM, 'typeId' => $this->id];
DB::Aowow()->query('INSERT INTO ?_item_stats (?#) VALUES (?a)', array_keys($stats), array_values($stats));
DB::Aowow()->qry('INSERT INTO ::item_stats %v', ['type' => Type::ITEM, 'typeId' => $this->id] + $stats);
}
}
}
@ -82,9 +76,9 @@ CLISetup::registerSetup("sql", new class extends SetupScript
private function enchantment_stats(?int &$total = 0, ?int &$effective = 0) : array
{
$enchants = DB::Aowow()->select('SELECT *, `id` AS ARRAY_KEY FROM dbc_spellitemenchantment');
$enchants = DB::Aowow()->selectAssoc('SELECT *, `id` AS ARRAY_KEY FROM dbc_spellitemenchantment');
$spells = [];
$result = [];
$stats = [];
$effective = 0;
$total = count($enchants);
@ -94,21 +88,21 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$spells[] = $e['object'.$i];
if ($spells)
$this->relSpells = DB::Aowow()->select('SELECT *, id AS ARRAY_KEY FROM ?_spell WHERE id IN (?a)', $spells);
$this->relSpells = DB::Aowow()->selectAssoc('SELECT *, id AS ARRAY_KEY FROM ::spell WHERE id IN %in', $spells);
foreach ($enchants as $eId => $e)
if ($result[$eId] = (new StatsContainer($this->relSpells))->fromEnchantment($e)->toJson(Stat::FLAG_ITEM | Stat::FLAG_SERVERSIDE))
if ($stats = (new StatsContainer($this->relSpells))->fromEnchantment($e)->toJson(Stat::FLAG_ITEM | Stat::FLAG_SERVERSIDE))
{
DB::Aowow()->query('INSERT INTO ?_item_stats (?#) VALUES (?a)', array_merge(['type', 'typeId'], array_keys($result[$eId])), array_merge([Type::ENCHANTMENT, $eId], array_values($result[$eId])));
DB::Aowow()->qry('INSERT INTO ::item_stats %v', ['type' => Type::ENCHANTMENT, 'typeId' => $eId] + $stats);
$effective++;
}
return $enchants;
}
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_item_stats');
DB::Aowow()->qry('TRUNCATE ::item_stats');
CLI::write('[stats] - applying stats for enchantments');
@ -130,7 +124,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$offset = 0;
while (true)
{
$items = new ItemStatSetup($offset, CLISetup::SQL_BATCH, $itemClass, $ids, $applyTriggered, $enchStats, $this->relSpells);
$items = new ItemStatSetup($offset, CLISetup::SQL_BATCH, $itemClass, $applyTriggered, $enchStats, $this->relSpells);
if ($items->error)
break;

View file

@ -18,16 +18,16 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $dbcSourceFiles = ['mailtemplate'];
protected $worldDependency = ['achievement_reward', 'achievement_reward_locale', 'mail_loot_template'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_mails');
DB::Aowow()->qry('TRUNCATE ::mails');
// copy data over from dbc
DB::Aowow()->query('INSERT INTO ?_mails SELECT `id`, 0, `subject_loc0`, `subject_loc2`, `subject_loc3`, `subject_loc4`, `subject_loc6`, `subject_loc8`, `text_loc0`, `text_loc2`, `text_loc3`, `text_loc4`, `text_loc6`, `text_loc8`, 0 FROM dbc_mailtemplate');
DB::Aowow()->qry('INSERT INTO ::mails SELECT `id`, 0, `subject_loc0`, `subject_loc2`, `subject_loc3`, `subject_loc4`, `subject_loc6`, `subject_loc8`, `text_loc0`, `text_loc2`, `text_loc3`, `text_loc4`, `text_loc6`, `text_loc8`, 0 FROM dbc_mailtemplate');
CLI::write('[mails] - loading data from achievement_reward');
$acvMail = DB::World()->select(
$acvMail = DB::World()->selectAssoc(
'SELECT -ar.`ID`, 0,
IFNULL(ar.`Subject`, "") AS "s0", IFNULL(arl2.`Subject`, "") AS "s2", IFNULL(arl3.`Subject`, "") AS "s3", IFNULL(arl4.`Subject`, "") AS "s4", IFNULL(arl6.`Subject`, "") AS "s6", IFNULL(arl8.`Subject`, "") AS "s8",
IFNULL(ar.`Body`, "") AS "t0", IFNULL(arl2.`Body`, "") AS "t2", IFNULL(arl3.`Body`, "") AS "t3", IFNULL(arl4.`Body`, "") AS "t4", IFNULL(arl6.`Body`, "") AS "t6", IFNULL(arl8.`Body`, "") AS "t8",
@ -41,14 +41,15 @@ CLISetup::registerSetup("sql", new class extends SetupScript
WHERE ar.`MailTemplateID` = 0 AND ar.`Body` <> ""'
);
DB::Aowow()->query('INSERT INTO ?_mails VALUES (?a)', array_values($acvMail));
foreach ($acvMail as $am)
DB::Aowow()->qry('INSERT INTO ::mails VALUES %l', $am);
CLI::write('[mails] - loading data from mail_loot_template');
// assume mails to only contain one single item, wich works for an unmodded installation
$mlt = DB::World()->selectCol('SELECT `Entry` AS ARRAY_KEY, `Item` FROM mail_loot_template');
foreach ($mlt as $k => $v)
DB::Aowow()->query('UPDATE ?_mails SET `attachment` = ?d WHERE `id` = ?d', $v, $k);
DB::Aowow()->qry('UPDATE ::mails SET `attachment` = %i WHERE `id` = %i', $v, $k);
return true;
}

View file

@ -18,7 +18,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $dbcSourceFiles = ['lock'];
protected $worldDependency = ['gameobject_template', 'gameobject_template_addon', 'gameobject_template_locale', 'gameobject_questitem'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
$baseQuery =
'SELECT go.entry,
@ -63,33 +63,30 @@ CLISetup::registerSetup("sql", new class extends SetupScript
LEFT JOIN gameobject_template_locale gtl6 ON go.entry = gtl6.entry AND gtl6.`locale` = "esES"
LEFT JOIN gameobject_template_locale gtl8 ON go.entry = gtl8.entry AND gtl8.`locale` = "ruRU"
LEFT JOIN gameobject_questitem gqi ON gqi.GameObjectEntry = go.entry
{ WHERE go.entry IN (?a) }
GROUP BY go.entry
LIMIT ?d, ?d';
LIMIT %i, %i';
DB::Aowow()->query('TRUNCATE ?_objects');
DB::Aowow()->query('SET SESSION innodb_ft_enable_stopword = OFF');
DB::Aowow()->qry('TRUNCATE ::objects');
DB::Aowow()->qry('SET SESSION innodb_ft_enable_stopword = OFF');
$i = 0;
while ($objects = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, CLISetup::SQL_BATCH * $i, CLISetup::SQL_BATCH))
while ($objects = DB::World()->selectAssoc($baseQuery, CLISetup::SQL_BATCH * $i, CLISetup::SQL_BATCH))
{
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));
DB::Aowow()->qry('INSERT INTO ::objects VALUES %l', $object);
}
// apply typeCat and reqSkill depending on locks
DB::Aowow()->query(
'UPDATE ?_objects o
DB::Aowow()->qry(
'UPDATE ::objects o
LEFT JOIN dbc_lock l ON l.id = IF(o.`type` = 3, lockId, null)
SET typeCat = IF(`type` = 3 AND (l.properties1 = 1 OR l.properties2 = 1), -5, -- footlocker
IF(`type` = 3 AND (l.properties1 = 2), -3, -- herb
IF(`type` = 3 AND (l.properties1 = 3), -4, typeCat))), -- ore
reqSkill = IF(`type` = 3 AND l.properties1 IN (1, 2, 3), IF(l.reqSkill1 > 1, l.reqSkill1, 1),
IF(`type` = 3 AND l.properties2 = 1, IF(l.reqSkill2 > 1, l.reqSkill2, 1), 0))
{ WHERE o.id IN (?a) }',
$ids ?: DBSIMPLE_SKIP
IF(`type` = 3 AND l.properties2 = 1, IF(l.reqSkill2 > 1, l.reqSkill2, 1), 0))',
);
$this->reapplyCCFlags('objects', Type::OBJECT);

View file

@ -21,13 +21,13 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $worldDependency = ['creature_template', 'creature'];
protected $setupAfter = [['icons'], []];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_pet');
DB::Aowow()->qry('TRUNCATE ::pet');
// basic copy from creaturefamily.dbc
DB::Aowow()->query(
'INSERT INTO ?_pet
DB::Aowow()->qry(
'INSERT INTO ::pet
SELECT f.`id`,
`categoryEnumId`,
0, -- cuFlags
@ -43,28 +43,28 @@ CLISetup::registerSetup("sql", new class extends SetupScript
0, 0, 0, 0, -- spell[1-4]
0, 0, 0 -- armor, damage, health
FROM dbc_creaturefamily f
LEFT JOIN ?_icons ic ON ic.`name_source` = LOWER(SUBSTRING_INDEX(f.`iconString`, "\\\\", -1))
LEFT JOIN ::icons ic ON ic.`name_source` = LOWER(SUBSTRING_INDEX(f.`iconString`, "\\", -1))
WHERE `petTalentType` <> -1'
);
// stats from craeture_template
$spawnInfo = DB::World()->query(
$spawnInfo = DB::World()->selectAssoc(
'SELECT ct.`family` AS ARRAY_KEY,
MIN(ct.`minlevel`) AS "minLevel",
MAX(ct.`maxlevel`) AS "maxLevel",
IF(ct.`type_flags` & ?d, 1, 0) AS "exotic"
IF(ct.`type_flags` & %i, 1, 0) AS "exotic"
FROM creature_template ct
JOIN creature c ON ct.`entry` = c.`id`
WHERE ct.`type_flags` & ?d
WHERE ct.`type_flags` & %i
GROUP BY ct.`family`',
NPC_TYPEFLAG_EXOTIC_PET, NPC_TYPEFLAG_TAMEABLE
);
foreach ($spawnInfo as $id => $info)
DB::Aowow()->query('UPDATE ?_pet SET ?a WHERE id = ?d', $info, $id);
DB::Aowow()->qry('UPDATE ::pet SET %a WHERE id = %i', $info, $id);
// add petFamilyModifier to health, mana, dmg
DB::Aowow()->query(
'UPDATE ?_pet p,
DB::Aowow()->qry(
'UPDATE ::pet p,
dbc_skilllineability sla,
dbc_spell s
SET `armor` = s.`effect2BasePoints` + s.`effect2DieSides`,
@ -76,13 +76,13 @@ CLISetup::registerSetup("sql", new class extends SetupScript
);
// assign pet spells
$pets = DB::Aowow()->select(
$pets = DB::Aowow()->selectAssoc(
'SELECT p.`id`, MAX(s.`id`) AS "spell"
FROM dbc_skilllineability sla
JOIN ?_pet p ON p.`skillLineId` = sla.`skillLineId`
JOIN ::pet p ON p.`skillLineId` = sla.`skillLineId`
JOIN dbc_spell s ON sla.`spellId` = s.`id`
LEFT OUTER JOIN dbc_talent t ON s.`id` = t.`rank1`
WHERE (s.`attributes0` & ?d) = 0 AND t.`id` IS NULL
WHERE (s.`attributes0` & %i) = 0 AND t.`id` IS NULL
GROUP BY s.`name_loc0`, p.`id`',
SPELL_ATTR0_PASSIVE
);
@ -97,7 +97,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
}
foreach ($petSpells as $petId => $row)
DB::Aowow()->query('UPDATE ?_pet SET ?a WHERE `id` = ?d', $row, $petId);
DB::Aowow()->qry('UPDATE ::pet SET %a WHERE `id` = %i', $row, $petId);
$this->reapplyCCFlags('pet', Type::PET);

View file

@ -20,7 +20,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $dbcSourceFiles = ['questxp', 'questfactionreward'];
protected $worldDependency = ['quest_template', 'quest_template_addon', 'quest_template_locale', 'game_event', 'game_event_seasonal_questrelation', 'quest_request_items', 'quest_request_items_locale', 'quest_offer_reward', 'quest_offer_reward_locale', 'disables'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
$baseQuery =
'SELECT q.ID,
@ -113,19 +113,18 @@ CLISetup::registerSetup("sql", new class extends SetupScript
LEFT JOIN quest_template_addon qa ON q.ID = qa.ID
LEFT JOIN game_event_seasonal_questrelation gesqr ON gesqr.questId = q.ID
LEFT JOIN disables d ON d.entry = q.ID AND d.sourceType = 1
{ WHERE q.Id IN (?a) }
LIMIT ?d, ?d';
LIMIT %i, %i';
DB::Aowow()->query('TRUNCATE ?_quests');
DB::Aowow()->query('SET SESSION innodb_ft_enable_stopword = OFF');
DB::Aowow()->qry('TRUNCATE ::quests');
DB::Aowow()->qry('SET SESSION innodb_ft_enable_stopword = OFF');
$i = 0;
while ($quests = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, CLISetup::SQL_BATCH * $i, CLISetup::SQL_BATCH))
while ($quests = DB::World()->selectAssoc($baseQuery, CLISetup::SQL_BATCH * $i, CLISetup::SQL_BATCH))
{
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));
DB::Aowow()->qry('INSERT INTO ::quests VALUES %l', $quest);
}
@ -141,14 +140,13 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CLI::write(' * unpacking XP rewards (1/4)', CLI::LOG_BLANK, true, true);
// unpack XP-reward
DB::Aowow()->query(
'UPDATE ?_quests q, dbc_questxp xp
DB::Aowow()->qry(
'UPDATE ::quests q, dbc_questxp xp
SET `rewardXP` = (CASE `rewardXP`
WHEN 0 THEN xp.`Field1` WHEN 1 THEN xp.`Field2` WHEN 2 THEN xp.`Field3` WHEN 3 THEN xp.`Field4` WHEN 4 THEN xp.`Field5`
WHEN 5 THEN xp.`Field6` WHEN 6 THEN xp.`Field7` WHEN 7 THEN xp.`Field8` WHEN 8 THEN xp.`Field9` WHEN 9 THEN xp.`Field10`
ELSE 0 END)
WHERE xp.`id` = q.`level` { AND q.`id` IN (?a) }',
$ids ?: DBSIMPLE_SKIP
WHERE xp.`id` = q.`level`',
);
@ -156,46 +154,45 @@ CLISetup::registerSetup("sql", new class extends SetupScript
// unpack Rep-rewards
for ($i = 1; $i < 6; $i++)
DB::Aowow()->query(
'UPDATE ?_quests q
LEFT JOIN dbc_questfactionreward rep ON rep.`id` = IF(rewardFactionValue?d > 0, 1, 2)
SET rewardFactionValue?d = (CASE ABS(rewardFactionValue?d)
DB::Aowow()->qry(
'UPDATE ::quests q
LEFT JOIN dbc_questfactionreward rep ON rep.`id` = IF(rewardFactionValue%i > 0, 1, 2)
SET rewardFactionValue%i = (CASE ABS(rewardFactionValue%i)
WHEN 0 THEN rep.`Field1` WHEN 1 THEN rep.`Field2` WHEN 2 THEN rep.`Field3` WHEN 3 THEN rep.`Field4` WHEN 4 THEN rep.`Field5`
WHEN 5 THEN rep.`Field6` WHEN 6 THEN rep.`Field7` WHEN 7 THEN rep.`Field8` WHEN 8 THEN rep.`Field9` WHEN 9 THEN rep.`Field10`
ELSE 0 END)
WHERE ABS(rewardFactionValue?d) BETWEEN 1 AND 10 { AND q.`id` IN (?a) }',
WHERE ABS(rewardFactionValue%i) BETWEEN 1 AND 10',
$i, $i, $i, $i,
$ids ?: DBSIMPLE_SKIP
);
CLI::write(' * flagging quests series (3/4)', CLI::LOG_BLANK, true, true);
// set series flags
DB::Aowow()->query(
'UPDATE ?_quests q
LEFT JOIN ?_quests q2 ON q2.`NextQuestIdChain` = q.id
SET q.`cuFlags` = q.`cuFlags` | ?d
DB::Aowow()->qry(
'UPDATE ::quests q
LEFT JOIN ::quests q2 ON q2.`NextQuestIdChain` = q.id
SET q.`cuFlags` = q.`cuFlags` | %i
WHERE q.`NextQuestIdChain` > 0 AND q2.`id` IS NULL',
QUEST_CU_FIRST_SERIES | QUEST_CU_PART_OF_SERIES
);
DB::Aowow()->query(
'UPDATE ?_quests q
JOIN ?_quests q2 ON q2.`NextQuestIdChain` = q.id
SET q.`cuFlags` = q.`cuFlags` | ?d
DB::Aowow()->qry(
'UPDATE ::quests q
JOIN ::quests q2 ON q2.`NextQuestIdChain` = q.id
SET q.`cuFlags` = q.`cuFlags` | %i
WHERE q.`NextQuestIdChain` = 0',
QUEST_CU_LAST_SERIES | QUEST_CU_PART_OF_SERIES
);
DB::Aowow()->query('UPDATE ?_quests SET `cuFlags` = `cuFlags` | ?d WHERE `NextQuestIdChain` > 0', QUEST_CU_PART_OF_SERIES);
DB::Aowow()->qry('UPDATE ::quests SET `cuFlags` = `cuFlags` | %i WHERE `NextQuestIdChain` > 0', QUEST_CU_PART_OF_SERIES);
CLI::write(' * applying fixes (4/4)', CLI::LOG_BLANK, true, true);
// fix questSorts for instance quests
foreach (Game::$questSortFix as $child => $parent)
DB::Aowow()->query('UPDATE ?_quests SET `questSortId` = ?d WHERE `questSortIdBak` = ?d', $parent, $child);
DB::Aowow()->qry('UPDATE ::quests SET `questSortId` = %i WHERE `questSortIdBak` = %i', $parent, $child);
// move quests linked to holidays into appropirate quests-sorts. create dummy sorts as needed
@ -209,20 +206,20 @@ CLISetup::registerSetup("sql", new class extends SetupScript
foreach ($holidaySorts as $hId => $sort)
if (!empty($eventSet[$hId]))
DB::Aowow()->query('UPDATE ?_quests SET `questSortId` = ?d WHERE `eventId` = ?d{ AND `id` IN (?a)}', $sort, $eventSet[$hId], $ids ?: DBSIMPLE_SKIP);
DB::Aowow()->qry('UPDATE ::quests SET `questSortId` = %i WHERE `eventId` = %i', $sort, $eventSet[$hId]);
// 'special' special cases
// fishing quests to stranglethorn extravaganza
DB::Aowow()->query('UPDATE ?_quests SET `questSortId` = ?d WHERE `id` IN (?a){ AND `id` IN (?a)}', -101, [8228, 8229], $ids ?: DBSIMPLE_SKIP);
DB::Aowow()->qry('UPDATE ::quests SET `questSortId` = %i WHERE `id` IN %in', -101, [8228, 8229]);
// dungeon quests to Misc/Dungeon Finder
DB::Aowow()->query('UPDATE ?_quests SET `questSortId` = ?d WHERE (`specialFlags` & ?d OR `id` IN (?a)){ AND `id` IN (?a)}', -1010, QUEST_FLAG_SPECIAL_DUNGEON_FINDER, [24789, 24791, 24923], $ids ?: DBSIMPLE_SKIP);
DB::Aowow()->qry('UPDATE ::quests SET `questSortId` = %i WHERE (`specialFlags` & %i OR `id` IN %in)', -1010, QUEST_FLAG_SPECIAL_DUNGEON_FINDER, [24789, 24791, 24923]);
// flag internal/unsued quests as unsearchable
DB::Aowow()->query(
'UPDATE ?_quests
SET `cuFlags` = `cuFlags` | ?d
DB::Aowow()->qry(
'UPDATE ::quests
SET `cuFlags` = `cuFlags` | %i
WHERE `name_loc0` LIKE "%<%" OR `name_loc0` LIKE "%[%" OR
`name_loc0` LIKE "%deprecated%" OR
`name_loc0` LIKE "%unused%" OR

View file

@ -17,7 +17,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $worldDependency = ['creature_queststarter', 'creature_questender', 'game_event_creature_quest', 'gameobject_queststarter', 'gameobject_questender', 'game_event_gameobject_quest', 'item_template'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
$query['NPC'] =
'SELECT 1 AS `type`, `id` AS `typeId`, `quest` AS `questId`, 1 AS `method`, 0 AS `eventId` FROM creature_queststarter UNION
@ -31,19 +31,19 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$query['Item'] = 'SELECT 3 AS `type`, `entry` AS `typeId`, `startquest` AS `questId`, 1 AS `method`, 0 AS `eventId` FROM item_template WHERE `startquest` <> 0';
DB::Aowow()->query('TRUNCATE ?_quests_startend');
DB::Aowow()->qry('TRUNCATE ::quests_startend');
foreach ($query as $n => $q)
{
CLI::write(' - ' . $n . ' start/end-points', CLI::LOG_BLANK, true, true);
$data = DB::World()->select($q);
$data = DB::World()->selectAssoc($q);
foreach ($data as $d)
DB::Aowow()->query('INSERT INTO ?_quests_startend (?#) VALUES (?a) ON DUPLICATE KEY UPDATE `method` = `method` | ?d, `eventId` = IF(`eventId` = 0, ?d, `eventId`)', array_keys($d), array_values($d), $d['method'], $d['eventId']);
DB::Aowow()->qry('INSERT INTO ::quests_startend %v ON DUPLICATE KEY UPDATE `method` = `method` | %i, `eventId` = IF(`eventId` = 0, %i, `eventId`)', $d, $d['method'], $d['eventId']);
}
// update quests without start as unavailable
Db::Aowow()->query('UPDATE ?_quests q LEFT JOIN ?_quests_startend qse ON qse.`questId` = q.`id` AND qse.`method` & 1 SET q.`cuFlags` = q.`cuFlags` | ?d WHERE qse.`questId` IS NULL', CUSTOM_UNAVAILABLE);
DB::Aowow()->qry('UPDATE ::quests q LEFT JOIN ::quests_startend qse ON qse.`questId` = q.`id` AND qse.`method` & 1 SET q.`cuFlags` = q.`cuFlags` | %i WHERE qse.`questId` IS NULL', CUSTOM_UNAVAILABLE);
return true;
}

View file

@ -20,23 +20,23 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $setupAfter = [['icons'], []];
protected $dbcSourceFiles = ['chrraces', 'charbaseinfo'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_races');
DB::Aowow()->query(
'INSERT INTO ?_races
DB::Aowow()->qry('TRUNCATE ::races');
DB::Aowow()->qry(
'INSERT INTO ::races
SELECT `id`, 0, `flags`, 0, `factionId`, 0, 0, `baseLanguage`, IF(`side` = 2, 0, `side` + 1), `fileString`, 0, 0, `name_loc0`, `name_loc2`, `name_loc3`, `name_loc4`, `name_loc6`, `name_loc8`, `expansion`
FROM dbc_chrraces'
);
// collect iconIds
DB::Aowow()->query('UPDATE ?_races r, ?_icons i0, ?_icons i1 SET r.`iconId0` = i0.`id`, r.`iconId1` = i1.`id` WHERE i0.`name_source` = CONCAT("race_", LOWER(r.`fileString`), "_male") AND i1.`name_source` = CONCAT("race_", LOWER(r.`fileString`), "_female")');
DB::Aowow()->qry('UPDATE ::races r, ::icons i0, ::icons i1 SET r.`iconId0` = i0.`id`, r.`iconId1` = i1.`id` WHERE i0.`name_source` = CONCAT("race_", LOWER(r.`fileString`), "_male") AND i1.`name_source` = CONCAT("race_", LOWER(r.`fileString`), "_female")');
// add classMask
DB::Aowow()->query('UPDATE ?_races r JOIN (SELECT BIT_OR(1 << (`classId` - 1)) AS "classMask", `raceId` FROM dbc_charbaseinfo GROUP BY `raceId`) cbi ON cbi.`raceId` = r.id SET r.`classMask` = cbi.`classMask`');
DB::Aowow()->qry('UPDATE ::races r JOIN (SELECT BIT_OR(1 << (`classId` - 1)) AS "classMask", `raceId` FROM dbc_charbaseinfo GROUP BY `raceId`) cbi ON cbi.`raceId` = r.id SET r.`classMask` = cbi.`classMask`');
// add cuFlags
DB::Aowow()->query('UPDATE ?_races SET `cuFlags` = ?d WHERE `flags` & ?d', CUSTOM_EXCLUDE_FOR_LISTVIEW, 0x1);
DB::Aowow()->qry('UPDATE ::races SET `cuFlags` = %i WHERE `flags` & %i', CUSTOM_EXCLUDE_FOR_LISTVIEW, 0x1);
$this->reapplyCCFlags('races', Type::CHR_RACE);

View file

@ -19,11 +19,11 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $dbcSourceFiles = ['spellshapeshiftform'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_shapeshiftforms');
DB::Aowow()->query(
'INSERT INTO ?_shapeshiftforms
DB::Aowow()->qry('TRUNCATE ::shapeshiftforms');
DB::Aowow()->qry(
'INSERT INTO ::shapeshiftforms
SELECT id, flags, creatureType, displayIdA, displayIdH,
spellId1, spellId2, spellId3, spellId4, spellId5, spellId6, spellId7, spellId8,
IF(name_loc0 = "", IF(name_loc2 = "", IF(name_loc3 = "", IF(name_loc4 = "", IF(name_loc6 = "", IF(name_loc8 = "", "???", name_loc8), name_loc6), name_loc4), name_loc3), name_loc2), name_loc0)

View file

@ -20,41 +20,41 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $dbcSourceFiles = ['skillline', 'spell', 'skilllineability'];
protected $setupAfter = [['icons'], []];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_skillline');
DB::Aowow()->query(
'INSERT INTO ?_skillline
DB::Aowow()->qry('TRUNCATE ::skillline');
DB::Aowow()->qry(
'INSERT INTO ::skillline
SELECT id, categoryId, 0, categoryId, name_loc0, name_loc2, name_loc3, name_loc4, name_loc6, name_loc8, description_loc0, description_loc2, description_loc3, description_loc4, description_loc6, description_loc8, 0, iconId, 0, 0, ""
FROM dbc_skillline'
);
// categorization
DB::Aowow()->query('UPDATE ?_skillline SET typeCat = -5 WHERE id = 777 OR (categoryId = 9 AND id NOT IN (356, 129, 185, 142, 155))');
DB::Aowow()->query('UPDATE ?_skillline SET typeCat = -4 WHERE categoryId = 9 AND name_loc0 LIKE "%racial%"');
DB::Aowow()->query('UPDATE ?_skillline SET typeCat = -6 WHERE id IN (778, 788, 758) OR (categoryId = 7 AND name_loc0 LIKE "%pet%")');
DB::Aowow()->qry('UPDATE ::skillline SET typeCat = -5 WHERE id = 777 OR (categoryId = 9 AND id NOT IN (356, 129, 185, 142, 155))');
DB::Aowow()->qry('UPDATE ::skillline SET typeCat = -4 WHERE categoryId = 9 AND name_loc0 LIKE "%racial%"');
DB::Aowow()->qry('UPDATE ::skillline SET typeCat = -6 WHERE id IN (778, 788, 758) OR (categoryId = 7 AND name_loc0 LIKE "%pet%")');
// more complex fixups
DB::Aowow()->query('UPDATE ?_skillline SET name_loc8 = REPLACE(name_loc8, " - ", ": ") WHERE categoryId = 7 OR id IN (758, 788)');
DB::Aowow()->query('UPDATE ?_skillline SET cuFlags = ?d WHERE id IN (?a)', CUSTOM_EXCLUDE_FOR_LISTVIEW, [142, 148, 149, 150, 152, 155, 183, 533, 553, 554, 713, 769]);
DB::Aowow()->qry('UPDATE ::skillline SET name_loc8 = REPLACE(name_loc8, " - ", ": ") WHERE categoryId = 7 OR id IN (758, 788)');
DB::Aowow()->qry('UPDATE ::skillline SET cuFlags = %i WHERE id IN %in', CUSTOM_EXCLUDE_FOR_LISTVIEW, [142, 148, 149, 150, 152, 155, 183, 533, 553, 554, 713, 769]);
// apply icons
DB::Aowow()->query('UPDATE ?_skillline sl, ?_icons ic, dbc_spellicon si SET sl.iconId = ic.id WHERE sl.iconIdBak = si.id AND ic.name = LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1))');
DB::Aowow()->query(
'UPDATE ?_skillline sl,
DB::Aowow()->qry('UPDATE ::skillline sl, ::icons ic, dbc_spellicon si SET sl.iconId = ic.id WHERE sl.iconIdBak = si.id AND ic.name = LOWER(SUBSTRING_INDEX(si.iconPath, "\\", -1))');
DB::Aowow()->qry(
'UPDATE ::skillline sl,
dbc_spell s,
dbc_skilllineability sla,
?_icons ic,
::icons ic,
dbc_spellicon si
SET sl.iconId = ic.id
WHERE (s.effect1Id IN (25, 26, 40) OR s.effect2Id = 60) AND
ic.name_source = LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1)) AND
ic.name_source = LOWER(SUBSTRING_INDEX(si.iconPath, "\\", -1)) AND
s.iconId = si.id AND
sla.spellId = s.id AND
sl.id = sla.skillLineId'
);
DB::Aowow()->query('UPDATE ?_skillline sl, ?_icons ic SET sl.iconId = ic.id WHERE ic.name = ? AND sl.id = ?d', 'inv_misc_pelt_wolf_01', 393);
DB::Aowow()->query('UPDATE ?_skillline sl, ?_icons ic SET sl.iconId = ic.id WHERE ic.name = ? AND sl.id = ?d', 'inv_misc_key_03', 633);
DB::Aowow()->qry('UPDATE ::skillline sl, ::icons ic SET sl.iconId = ic.id WHERE ic.name = %s AND sl.id = %i', 'inv_misc_pelt_wolf_01', 393);
DB::Aowow()->qry('UPDATE ::skillline sl, ::icons ic SET sl.iconId = ic.id WHERE ic.name = %s AND sl.id = %i', 'inv_misc_key_03', 633);
$this->reapplyCCFlags('skillline', Type::SKILL);

View file

@ -30,7 +30,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
'material', 'itemgroupsounds', 'itemdisplayinfo', 'weaponimpactsounds', 'itemsubclass', 'weaponswingsounds2' /*, 'sheathesoundlookups' data is redundant with material..? */
);
public function generate(array $ids = []) : bool
public function generate() : bool
{
/*
okay, here's the thing. WMOAreaTable.dbc references WMO-files to get its position in the world (AreTable) and has sparse information on the related AreaTables themself.
@ -67,15 +67,15 @@ CLISetup::registerSetup("sql", new class extends SetupScript
`file6` AS `soundFile6`, `file7` AS `soundFile7`, `file8` AS `soundFile8`, `file9` AS `soundFile9`, `file10` AS `soundFile10`,
`path`, `flags`
FROM dbc_soundentries
LIMIT ?d, ?d';
LIMIT %i, %i';
DB::Aowow()->query('TRUNCATE ?_sounds');
DB::Aowow()->query('TRUNCATE ?_sounds_files');
DB::Aowow()->qry('TRUNCATE ::sounds');
DB::Aowow()->qry('TRUNCATE ::sounds_files');
$soundFileIdx = 0;
$soundIndex = [];
$j = 0;
while ($sounds = DB::Aowow()->select($query, $j * CLISetup::SQL_BATCH, CLISetup::SQL_BATCH))
while ($sounds = DB::Aowow()->selectAssoc($query, $j * CLISetup::SQL_BATCH, CLISetup::SQL_BATCH))
{
CLI::write('[sound] * batch #' . ++$j . ' (' . count($sounds) . ')', CLI::LOG_BLANK, true, true);
@ -108,7 +108,11 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
$soundIndex[$nicePath] = ++$soundFileIdx;
$fileSets[] = [$soundFileIdx, $s['soundFile'.$i], $s['path'], SOUND_TYPE_OGG];
$fileSets['id'][] = $soundFileIdx;
$fileSets['file'][] = $s['soundFile'.$i];
$fileSets['path'][] = $s['path'];
$fileSets['type'][] = SOUND_TYPE_OGG;
$s['soundFile'.$i] = $soundFileIdx;
}
// mp3 .. keep as is
@ -116,7 +120,11 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
$soundIndex[$nicePath] = ++$soundFileIdx;
$fileSets[] = [$soundFileIdx, $s['soundFile'.$i], $s['path'], SOUND_TYPE_MP3];
$fileSets['id'][] = $soundFileIdx;
$fileSets['file'][] = $s['soundFile'.$i];
$fileSets['path'][] = $s['path'];
$fileSets['type'][] = SOUND_TYPE_MP3;
$s['soundFile'.$i] = $soundFileIdx;
}
// i call bullshit
@ -137,14 +145,15 @@ CLISetup::registerSetup("sql", new class extends SetupScript
continue;
}
else if ($fileSets)
DB::Aowow()->query('INSERT INTO ?_sounds_files VALUES (?a)', array_values($fileSets));
DB::Aowow()->qry('INSERT INTO ::sounds_files %m', $fileSets);
unset($s['path']);
$groupSets[] = array_values($s);
}
DB::Aowow()->query('INSERT INTO ?_sounds VALUES (?a)', array_values($groupSets));
foreach ($groupSets as $gs)
DB::Aowow()->qry('INSERT INTO ::sounds VALUES %l', $gs);
}
@ -154,9 +163,9 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CLI::write('[sound] - linking to race');
DB::Aowow()->query('TRUNCATE ?_races_sounds');
DB::Aowow()->query(
'INSERT IGNORE INTO ?_races_sounds
DB::Aowow()->qry('TRUNCATE ::races_sounds');
DB::Aowow()->qry(
'INSERT IGNORE INTO ::races_sounds
SELECT `raceId`, `soundIdMale`, 1 FROM dbc_vocaluisounds WHERE `soundIdMale` <> `soundIdFemale` AND `soundIdMale` > 0 UNION
SELECT `raceId`, `soundIdFemale`, 2 FROM dbc_vocaluisounds WHERE `soundIdMale` <> `soundIdFemale` AND `soundIdFemale` > 0'
);
@ -168,8 +177,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CLI::write('[sound] - 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');
DB::Aowow()->qry('TRUNCATE ::emotes_sounds');
DB::Aowow()->qry('INSERT IGNORE INTO ::emotes_sounds SELECT `emotesTextId`, `raceId`, `gender` + 1, `soundId` FROM dbc_emotestextsound');
/*******************/
@ -184,9 +193,9 @@ CLISetup::registerSetup("sql", new class extends SetupScript
// * customattack2 through 3
// in case of conflicting data CreatureDisplayInfo overrides CreatureModelData (seems to be more specialized (Thral > MaleOrc / Maiden > FemaleTitan))
DB::Aowow()->query('TRUNCATE ?_creature_sounds');
DB::Aowow()->query(
'INSERT INTO ?_creature_sounds
DB::Aowow()->qry('TRUNCATE ::creature_sounds');
DB::Aowow()->qry(
'INSERT INTO ::creature_sounds
SELECT cdi.`id`,
GREATEST(IFNULL(ns.`greetSoundId`, 0), 0),
GREATEST(IFNULL(ns.`byeSoundId`, 0), 0),
@ -236,9 +245,9 @@ CLISetup::registerSetup("sql", new class extends SetupScript
// * missile and impactarea not in js
// * ready, castertargeting, casterstate and targetstate not in dbc
DB::Aowow()->query('TRUNCATE ?_spell_sounds');
DB::Aowow()->query(
'INSERT INTO ?_spell_sounds
DB::Aowow()->qry('TRUNCATE ::spell_sounds');
DB::Aowow()->qry(
'INSERT INTO ::spell_sounds
SELECT sv.`id`,
GREATEST(`animationSoundId`, 0),
0, -- ready
@ -282,9 +291,9 @@ CLISetup::registerSetup("sql", new class extends SetupScript
// omiting data from WMOAreaTable, as its at the moment impossible to link to actual zones
DB::Aowow()->query('TRUNCATE ?_zones_sounds');
DB::Aowow()->query(
'INSERT INTO ?_zones_sounds (`id`, `ambienceDay`, `ambienceNight`, `musicDay`, `musicNight`, `intro`, `worldStateId`, `worldStateValue`)
DB::Aowow()->qry('TRUNCATE ::zones_sounds');
DB::Aowow()->qry(
'INSERT INTO ::zones_sounds (`id`, `ambienceDay`, `ambienceNight`, `musicDay`, `musicNight`, `intro`, `worldStateId`, `worldStateValue`)
SELECT a.`id`,
IFNULL(sa1.`soundIdDay`, 0),
IFNULL(sa1.`soundIdNight`, 0),
@ -311,13 +320,13 @@ CLISetup::registerSetup("sql", new class extends SetupScript
LEFT JOIN dbc_soundambience sa2 ON sa2.`id` = wszs.`soundAmbienceId`
LEFT JOIN dbc_zonemusic zm2 ON zm2.`id` = wszs.`zoneMusicId`
LEFT JOIN dbc_zoneintromusictable zimt2 ON zimt2.`id` = wszs.`zoneIntroMusicId`
WHERE wszs.`zoneMusicId` > 0 AND (wszs.`areaId` OR wszs.`wmoAreaId` IN (?a))',
WHERE wszs.`zoneMusicId` > 0 AND (wszs.`areaId` OR wszs.`wmoAreaId` IN %in)',
array_keys($worldStateZoneSoundFix)
);
// apply post-fix
foreach ($worldStateZoneSoundFix as $old => $new)
DB::Aowow()->query('UPDATE ?_zones_sounds SET `id` = ?d WHERE `id` = ?d', $new, $old);
DB::Aowow()->qry('UPDATE ::zones_sounds SET `id` = %i WHERE `id` = %i', $new, $old);
/***************/
@ -326,8 +335,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CLI::write('[sound] - linking to items');
DB::Aowow()->query(
'UPDATE ?_items i
DB::Aowow()->qry(
'UPDATE ::items i
LEFT JOIN dbc_itemdisplayinfo idi ON idi.`id` = i.`displayId`
LEFT JOIN dbc_itemgroupsounds igs ON igs.`id` = idi.`groupSoundId`
LEFT JOIN dbc_material m ON m.`id` = i.`material`
@ -338,22 +347,22 @@ CLISetup::registerSetup("sql", new class extends SetupScript
i.`unsheatheSoundId` = IFNULL(m.`unsheatheSoundId`, 0)'
);
DB::Aowow()->query('TRUNCATE ?_items_sounds');
DB::Aowow()->qry('TRUNCATE ::items_sounds');
$fields = ['hit', 'crit'];
foreach ($fields as $f)
for ($i = 1; $i <= 10; $i++)
DB::Aowow()->query(
'INSERT INTO ?_items_sounds
SELECT ?#, (1 << wis.`subClass`)
DB::Aowow()->qry(
'INSERT INTO ::items_sounds
SELECT %n, (1 << wis.`subClass`)
FROM dbc_weaponimpactsounds wis
WHERE ?# > 0
WHERE %n > 0
ON DUPLICATE KEY UPDATE `subClassMask` = `subClassMask` | (1 << wis.`subClass`)',
$f.$i, $f.$i
);
DB::Aowow()->query(
'INSERT INTO ?_items_sounds
DB::Aowow()->qry(
'INSERT INTO ::items_sounds
SELECT wss.`soundId`, (1 << isc.`subClass`)
FROM dbc_itemsubclass isc
JOIN dbc_weaponswingsounds2 wss ON wss.`weaponSize` = isc.`weaponSize`
@ -368,9 +377,9 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CLI::write('[sound] - linking to screen effects');
DB::Aowow()->query('TRUNCATE ?_screeneffect_sounds');
DB::Aowow()->query(
'INSERT INTO ?_screeneffect_sounds
DB::Aowow()->qry('TRUNCATE ::screeneffect_sounds');
DB::Aowow()->qry(
'INSERT INTO ::screeneffect_sounds
SELECT se.`id`, se.`name`, IFNULL(sa.`soundIdDay`, 0), IFNULL(sa.`soundIdNight`, 0), IFNULL(zm.`soundIdDay`, 0), IFNULL(zm.`soundIdNight`, 0)
FROM dbc_screeneffect se
LEFT JOIN dbc_soundambience sa ON se.`soundAmbienceId` = sa.`id`

View file

@ -41,34 +41,34 @@ CLISetup::registerSetup("sql", new class extends SetupScript
194326 => 194327
);
public function generate(array $ids = []) : bool
public function generate() : bool
{
/*********************************/
/* resolve difficulty dummy NPCS */
/*********************************/
$this->dummyNPCs = DB::Aowow()->select(
'SELECT `difficultyEntry1` AS ARRAY_KEY, 2 AS "0", `id` AS "1" FROM ?_creature WHERE `difficultyEntry1` > 0 UNION
SELECT `difficultyEntry2` AS ARRAY_KEY, 4 AS "0", `id` AS "1" FROM ?_creature WHERE `difficultyEntry2` > 0 UNION
SELECT `difficultyEntry3` AS ARRAY_KEY, 8 AS "0", `id` AS "1" FROM ?_creature WHERE `difficultyEntry3` > 0'
$this->dummyNPCs = DB::Aowow()->selectAssoc(
'SELECT `difficultyEntry1` AS ARRAY_KEY, 2 AS "0", `id` AS "1" FROM ::creature WHERE `difficultyEntry1` > 0 UNION
SELECT `difficultyEntry2` AS ARRAY_KEY, 4 AS "0", `id` AS "1" FROM ::creature WHERE `difficultyEntry2` > 0 UNION
SELECT `difficultyEntry3` AS ARRAY_KEY, 8 AS "0", `id` AS "1" FROM ::creature WHERE `difficultyEntry3` > 0'
);
$this->dummyGOs = DB::Aowow()->select(
'SELECT `normal10` AS ARRAY_KEY, 1 AS "0", `normal10` AS "1", `mapType` AS "2" FROM ?_objectdifficulty WHERE `normal10` > 0 UNION
SELECT `normal25` AS ARRAY_KEY, 2 AS "0", `normal10` AS "1", `mapType` AS "2" FROM ?_objectdifficulty WHERE `normal25` > 0 UNION
SELECT `heroic10` AS ARRAY_KEY, 4 AS "0", `normal10` AS "1", `mapType` AS "2" FROM ?_objectdifficulty WHERE `heroic10` > 0 UNION
SELECT `heroic25` AS ARRAY_KEY, 8 AS "0", `normal10` AS "1", `mapType` AS "2" FROM ?_objectdifficulty WHERE `heroic25` > 0'
$this->dummyGOs = DB::Aowow()->selectAssoc(
'SELECT `normal10` AS ARRAY_KEY, 1 AS "0", `normal10` AS "1", `mapType` AS "2" FROM ::objectdifficulty WHERE `normal10` > 0 UNION
SELECT `normal25` AS ARRAY_KEY, 2 AS "0", `normal10` AS "1", `mapType` AS "2" FROM ::objectdifficulty WHERE `normal25` > 0 UNION
SELECT `heroic10` AS ARRAY_KEY, 4 AS "0", `normal10` AS "1", `mapType` AS "2" FROM ::objectdifficulty WHERE `heroic10` > 0 UNION
SELECT `heroic25` AS ARRAY_KEY, 8 AS "0", `normal10` AS "1", `mapType` AS "2" FROM ::objectdifficulty WHERE `heroic25` > 0'
);
$this->disables = DB::World()->selectCol(
'SELECT IF(`sourceType`, ?d, ?d) AS ARRAY_KEY, `entry` AS ARRAY_KEY2, `entry`
'SELECT IF(`sourceType`, %i, %i) AS ARRAY_KEY, `entry` AS ARRAY_KEY2, `entry`
FROM disables
WHERE (`sourceType` = 0 AND (`flags` & 0xF)) OR `sourceType` = 1',
Type::QUEST, Type::SPELL
);
CLI::write('[source] - resolving ref-loot tree', CLI::LOG_BLANK, true, true);
$this->refLoot = DB::World()->select(
$this->refLoot = DB::World()->selectAssoc(
'SELECT rlt.`Entry` AS ARRAY_KEY, IF(`Reference`, -`Reference`, `Item`) AS ARRAY_KEY2, it.`entry`, it.`class`, it.`subclass`, it.`spellid_1`, it.`spelltrigger_1`, it.`spellid_2`, it.`spelltrigger_2`
FROM reference_loot_template rlt
LEFT JOIN item_template it ON rlt.`Reference` = 0 AND rlt.`Item` = it.`entry`
@ -98,7 +98,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
}
}
DB::Aowow()->query('TRUNCATE ?_source');
DB::Aowow()->qry('TRUNCATE ::source');
/***************************/
/* Item & inherited Spells */
@ -190,23 +190,23 @@ CLISetup::registerSetup("sql", new class extends SetupScript
// generally treat all items generated by spell as being available. The spells may be triggered in convoluted ways but usually _are_ in use.
$itemSpellSource = DB::Aowow()->selectCol(
'SELECT x.`itemId` FROM (
SELECT `effect1CreateItemId` AS "itemId", s.`id` FROM dbc_spell s WHERE `effect1CreateItemId` > 0 AND (`effect1Id` IN (?a) OR `effect1AuraId` IN (?a)) UNION ALL
SELECT `effect2CreateItemId` AS "itemId", s.`id` FROM dbc_spell s WHERE `effect2CreateItemId` > 0 AND (`effect2Id` IN (?a) OR `effect2AuraId` IN (?a)) UNION ALL
SELECT `effect3CreateItemId` AS "itemId", s.`id` FROM dbc_spell s WHERE `effect3CreateItemId` > 0 AND (`effect3Id` IN (?a) OR `effect3AuraId` IN (?a)) ) AS x
{ WHERE x.`id` NOT IN (?a) }',
SELECT `effect1CreateItemId` AS "itemId", s.`id` FROM dbc_spell s WHERE `effect1CreateItemId` > 0 AND (`effect1Id` IN %in OR `effect1AuraId` IN %in) UNION ALL
SELECT `effect2CreateItemId` AS "itemId", s.`id` FROM dbc_spell s WHERE `effect2CreateItemId` > 0 AND (`effect2Id` IN %in OR `effect2AuraId` IN %in) UNION ALL
SELECT `effect3CreateItemId` AS "itemId", s.`id` FROM dbc_spell s WHERE `effect3CreateItemId` > 0 AND (`effect3Id` IN %in OR `effect3AuraId` IN %in) ) AS x
WHERE x.`id` NOT IN %in',
SpellList::EFFECTS_ITEM_CREATE, SpellList::AURAS_ITEM_CREATE,
SpellList::EFFECTS_ITEM_CREATE, SpellList::AURAS_ITEM_CREATE,
SpellList::EFFECTS_ITEM_CREATE, SpellList::AURAS_ITEM_CREATE,
!empty($this->disables[Type::SPELL]) ? array_values($this->disables[Type::SPELL]) : DBSIMPLE_SKIP
$this->disables[Type::SPELL] ?? [0]
);
// flagging aowow_items for source (note: this is not exact! creatures dropping items may not be spawned, etc.)
DB::Aowow()->query('UPDATE ?_items SET `cuFlags` = `cuFlags` & ?d', ~CUSTOM_UNAVAILABLE);
DB::Aowow()->query(
'UPDATE ?_items i
LEFT JOIN ?_source s ON s.`typeId` = i.`id` AND s.`type` = ?d
SET i.`cuFlags` = i.`cuFlags` | ?d
WHERE (s.`typeId` IS NULL AND i.`id` NOT IN (?a)) OR i.`quality` = ?d',
DB::Aowow()->qry('UPDATE ::items SET `cuFlags` = `cuFlags` & %i', ~CUSTOM_UNAVAILABLE);
DB::Aowow()->qry(
'UPDATE ::items i
LEFT JOIN ::source s ON s.`typeId` = i.`id` AND s.`type` = %i
SET i.`cuFlags` = i.`cuFlags` | %i
WHERE (s.`typeId` IS NULL AND i.`id` NOT IN %in) OR i.`quality` = %i',
Type::ITEM, CUSTOM_UNAVAILABLE, $itemSpellSource, ITEM_QUALITY_ARTIFACT
);
@ -259,7 +259,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
}
$rows = [];
DB::Aowow()->query('INSERT INTO ?_source VALUES '. substr($str, 0, -1));
DB::Aowow()->qry('INSERT INTO ::source VALUES '. substr($str, 0, -1));
}
private function taughtSpell(array $item) : int
@ -287,7 +287,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
'SELECT `effect1CreateItemId` AS ARRAY_KEY, s.`id`
FROM dbc_spell s
JOIN dbc_skilllineability sla ON s.`id` = sla.`spellId`
WHERE `effect1CreateItemId` > 0 AND sla.`skillLineId` IN (?a)
WHERE `effect1CreateItemId` > 0 AND sla.`skillLineId` IN %in
GROUP BY ARRAY_KEY',
array_merge(SKILLS_TRADE_PRIMARY, [SKILL_FIRST_AID, SKILL_COOKING, SKILL_FISHING])
);
@ -299,7 +299,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$itemSpells = array_filter($itemSpells, fn($x) => empty($this->disables[Type::SPELL][$x]));
$spellLoot = DB::World()->selectCol('SELECT IF(`Reference` > 0, -`Reference`, `Item`) AS ARRAY_KEY, `entry` FROM spell_loot_template WHERE `entry` IN (?a)', $itemSpells);
$spellLoot = DB::World()->selectCol('SELECT IF(`Reference` > 0, -`Reference`, `Item`) AS ARRAY_KEY, `entry` FROM spell_loot_template WHERE `entry` IN %in', $itemSpells);
if ($_ = array_filter($spellLoot, fn($x) => $x > 0, ARRAY_FILTER_USE_KEY))
$itemSpells = array_replace($itemSpells, $_);
@ -307,7 +307,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
if (isset($this->refLoot[-$r]))
$itemSpells = array_replace(array_fill_keys(array_keys($this->refLoot[-$r]), $spellId));
$spellItems = DB::World()->select('SELECT `entry` AS ARRAY_KEY, `class`, `subclass`, `spellid_1`, `spelltrigger_1`, `spellid_2`, `spelltrigger_2` FROM item_template WHERE `entry` IN (?a)', array_keys($itemSpells));
$spellItems = DB::World()->selectAssoc('SELECT `entry` AS ARRAY_KEY, `class`, `subclass`, `spellid_1`, `spelltrigger_1`, `spellid_2`, `spelltrigger_2` FROM item_template WHERE `entry` IN %in', array_keys($itemSpells));
foreach ($spellItems as $iId => $si)
{
if ($_ = $this->taughtSpell($si))
@ -324,7 +324,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CLI::write('[source] * #2 Drop [NPC]', CLI::LOG_BLANK, true, true);
$creatureLoot = DB::World()->select(
$creatureLoot = DB::World()->selectAssoc(
'SELECT IF(clt.`Reference` > 0, -clt.`Reference`, clt.`Item`) AS "refOrItem", ct.`entry`, it.`class`, it.`subclass`, it.`spellid_1`, it.`spelltrigger_1`, it.`spellid_2`, it.`spelltrigger_2`, COUNT(DISTINCT clt.`Reference`) AS "qty"
FROM creature_loot_template clt
JOIN creature_template ct ON clt.`entry` = ct.`lootid`
@ -333,9 +333,9 @@ CLISetup::registerSetup("sql", new class extends SetupScript
GROUP BY `refOrItem`, ct.`entry`'
);
$linkedNpcs = DB::Aowow()->selectCol('SELECT l1.`objectId` AS ARRAY_KEY, IFNULL(l2.`npcId`, l1.`npcId`) FROM ?_loot_link l1 LEFT JOIN ?_loot_link l2 ON l1.`objectId` = l2.`objectId` AND l2.`priority` = 1 GROUP BY l1.`objectid`');
$npcSpawns = DB::Aowow()->select('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT s.`areaId`) > 1, 0, s.`areaId`) AS "areaId", z.`type` FROM ?_spawns s JOIN ?_zones z ON z.`id` = s.`areaId` WHERE s.`type` = ?d AND `typeId` IN (?a) GROUP BY `typeId`', Type::NPC, array_merge($linkedNpcs, array_filter(array_column($creatureLoot, 'entry'))));
$bosses = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, IF(`cuFlags` & ?d, 1, IF(`typeFlags` & 0x4 AND `rank` > 0, 1, 0)) FROM ?_creature WHERE `id` IN (?a)', NPC_CU_INSTANCE_BOSS, array_filter(array_column($creatureLoot, 'entry')));
$linkedNpcs = DB::Aowow()->selectCol('SELECT l1.`objectId` AS ARRAY_KEY, IFNULL(l2.`npcId`, l1.`npcId`) FROM ::loot_link l1 LEFT JOIN ::loot_link l2 ON l1.`objectId` = l2.`objectId` AND l2.`priority` = 1 GROUP BY l1.`objectid`');
$npcSpawns = DB::Aowow()->selectAssoc('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT s.`areaId`) > 1, 0, s.`areaId`) AS "areaId", z.`type` FROM ::spawns s JOIN ::zones z ON z.`id` = s.`areaId` WHERE s.`type` = %i AND `typeId` IN %in GROUP BY `typeId`', Type::NPC, array_merge($linkedNpcs, array_filter(array_column($creatureLoot, 'entry'))));
$bosses = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, IF(`cuFlags` & %i, 1, IF(`typeFlags` & 0x4 AND `rank` > 0, 1, 0)) FROM ::creature WHERE `id` IN %in', NPC_CU_INSTANCE_BOSS, array_filter(array_column($creatureLoot, 'entry')));
foreach ($creatureLoot as $l)
{
@ -391,18 +391,18 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CLI::write('[source] * #2 Drop [Object]', CLI::LOG_BLANK, true, true);
$objectLoot = DB::World()->select(
$objectLoot = DB::World()->selectAssoc(
'SELECT IF(glt.`Reference` > 0, -glt.`Reference`, glt.`Item`) AS "refOrItem", gt.`entry`, it.`class`, it.`subclass`, it.`spellid_1`, it.`spelltrigger_1`, it.`spellid_2`, it.`spelltrigger_2`, COUNT(DISTINCT glt.`Reference`) AS "qty"
FROM gameobject_loot_template glt
JOIN gameobject_template gt ON glt.`entry` = gt.`data1`
LEFT JOIN item_template it ON it.`entry` = glt.`Item` AND glt.`Reference` <= 0
WHERE `type` = ?d AND gt.`data1` > 0 AND gt.`data0` NOT IN (?a)
WHERE `type` = %i AND gt.`data1` > 0 AND gt.`data0` NOT IN %in
GROUP BY `refOrItem`, gt.`entry`',
OBJECT_CHEST,
DB::Aowow()->selectCol('SELECT `id` FROM dbc_lock WHERE `properties1` IN (?a)', [LOCK_PROPERTY_HERBALISM, LOCK_PROPERTY_MINING])
DB::Aowow()->selectCol('SELECT `id` FROM dbc_lock WHERE `properties1` IN %in', [LOCK_PROPERTY_HERBALISM, LOCK_PROPERTY_MINING])
);
$goSpawns = DB::Aowow()->select('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT s.`areaId`) > 1, 0, s.`areaId`) AS "areaId", z.`type` FROM ?_spawns s JOIN ?_zones z ON z.`id` = s.`areaId` WHERE s.`type` = ?d AND `typeId`IN (?a) GROUP BY `typeId`', Type::OBJECT, array_filter(array_column($objectLoot, 'entry')));
$goSpawns = DB::Aowow()->selectAssoc('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT s.`areaId`) > 1, 0, s.`areaId`) AS "areaId", z.`type` FROM ::spawns s JOIN ::zones z ON z.`id` = s.`areaId` WHERE s.`type` = %i AND `typeId`IN %in GROUP BY `typeId`', Type::OBJECT, array_filter(array_column($objectLoot, 'entry')));
foreach ($objectLoot as $l)
{
@ -469,24 +469,24 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CLI::write('[source] * #2 Drop [Item]', CLI::LOG_BLANK, true, true);
$itemLoot = DB::World()->select(
$itemLoot = DB::World()->selectAssoc(
'SELECT IF(ilt.`Reference` > 0, -ilt.`Reference`, ilt.`Item`) AS ARRAY_KEY, itA.`entry`, itB.`class`, itB.`subclass`, itB.`spellid_1`, itB.`spelltrigger_1`, itB.`spellid_2`, itB.`spelltrigger_2`, COUNT(DISTINCT ilt.`Reference`) AS "qty"
FROM item_loot_template ilt
JOIN item_template itA ON ilt.`entry` = itA.`entry`
LEFT JOIN item_template itB ON itB.`entry` = ilt.`Item` AND ilt.`Reference` <= 0
WHERE itA.`flags` & ?d
WHERE itA.`flags` & %i
GROUP BY ARRAY_KEY',
ITEM_FLAG_OPENABLE
);
// Clams are not item containers but have SpellLoot
$lootSpells = DB::Aowow()->selectCol('SELECT s.`id` FROM ?_spell s JOIN ?_items i ON i.`spellId1` = s.`id` AND i.`spellTrigger1` = ?d WHERE s.`effect1Id` = ?d', SPELL_TRIGGER_USE, SPELL_EFFECT_CREATE_RANDOM_ITEM);
$spellLoot = DB::World()->select(
$lootSpells = DB::Aowow()->selectCol('SELECT s.`id` FROM ::spell s JOIN ::items i ON i.`spellId1` = s.`id` AND i.`spellTrigger1` = %i WHERE s.`effect1Id` = %i', SPELL_TRIGGER_USE, SPELL_EFFECT_CREATE_RANDOM_ITEM);
$spellLoot = DB::World()->selectAssoc(
'SELECT IF(slt.`Reference` > 0, -slt.`Reference`, slt.`Item`) AS ARRAY_KEY, itA.`entry`, itB.`class`, itB.`subclass`, itB.`spellid_1`, itB.`spelltrigger_1`, itB.`spellid_2`, itB.`spelltrigger_2`, COUNT(DISTINCT slt.`Reference`) AS "qty"
FROM spell_loot_template slt
JOIN item_template itA ON slt.`entry` = itA.`spellid_1`
LEFT JOIN item_template itB ON itB.`entry` = slt.`Item` AND slt.`Reference` <= 0
WHERE itA.`spellid_1` IN (?a) AND itA.`spelltrigger_1` = ?d
WHERE itA.`spellid_1` IN %in AND itA.`spelltrigger_1` = %i
GROUP BY ARRAY_KEY',
$lootSpells, SPELL_TRIGGER_USE
);
@ -518,9 +518,9 @@ CLISetup::registerSetup("sql", new class extends SetupScript
}
if ($itemOT)
DB::Aowow()->query('UPDATE ?_items SET `cuFLags` = `cuFlags` | ?d WHERE `id` IN (?a)', ITEM_CU_OT_ITEMLOOT, $itemOT);
DB::Aowow()->qry('UPDATE ::items SET `cuFLags` = `cuFlags` | %i WHERE `id` IN %in', ITEM_CU_OT_ITEMLOOT, $itemOT);
if ($objectOT)
DB::Aowow()->query('UPDATE ?_items SET `cuFLags` = `cuFlags` | ?d WHERE `id` IN (?a)', ITEM_CU_OT_OBJECTLOOT, $objectOT);
DB::Aowow()->qry('UPDATE ::items SET `cuFLags` = `cuFlags` | %i WHERE `id` IN %in', ITEM_CU_OT_OBJECTLOOT, $objectOT);
}
private function itemPvP() : void
@ -530,19 +530,19 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$subSrcByXCost = array(
SRC_SUB_PVP_BG => DB::Aowow()->selectCol('SELECT `id` FROM dbc_itemextendedcost WHERE `reqArenaPoints` = 0 AND `reqHonorPoints` > 0'),
SRC_SUB_PVP_ARENA => DB::Aowow()->selectCol('SELECT `id` FROM dbc_itemextendedcost WHERE `reqArenaPoints` > 0'),
SRC_SUB_PVP_WORLD => DB::Aowow()->selectCol('SELECT `id` FROM dbc_itemextendedcost WHERE `reqItemId1` IN (?a) OR `reqItemId2` IN (?a) OR `reqItemId3` IN (?a) OR `reqItemId4` IN (?a) OR `reqItemId5` IN (?a)', self::PVP_MONEY, self::PVP_MONEY, self::PVP_MONEY, self::PVP_MONEY, self::PVP_MONEY)
SRC_SUB_PVP_WORLD => DB::Aowow()->selectCol('SELECT `id` FROM dbc_itemextendedcost WHERE `reqItemId1` IN %in OR `reqItemId2` IN %in OR `reqItemId3` IN %in OR `reqItemId4` IN %in OR `reqItemId5` IN %in', self::PVP_MONEY, self::PVP_MONEY, self::PVP_MONEY, self::PVP_MONEY, self::PVP_MONEY)
);
$vendorQuery =
'SELECT n.`item`, SUM(n.`qty`) AS "qty", it.`class`, it.`subclass`, it.`spellid_1`, it.`spelltrigger_1`, it.`spellid_2`, it.`spelltrigger_2`
FROM (SELECT `item`, COUNT(1) AS "qty" FROM npc_vendor WHERE `ExtendedCost` IN (?a) AND `item` > 0 GROUP BY `item` UNION
SELECT nv2.`item`, COUNT(1) AS "qty" FROM npc_vendor nv1 JOIN npc_vendor nv2 ON nv2.`entry` = -nv1.`item` AND nv1.`item` < 0 WHERE nv1.`ExtendedCost` IN (?a) AND `nv1`.`item` < 0 GROUP BY `item` UNION
SELECT `item`, COUNT(1) AS "qty" FROM game_event_npc_vendor genv JOIN creature c ON c.`guid` = genv.`guid` WHERE `ExtendedCost` IN (?a) GROUP BY `item`) n
FROM (SELECT `item`, COUNT(1) AS "qty" FROM npc_vendor WHERE `ExtendedCost` IN %in AND `item` > 0 GROUP BY `item` UNION
SELECT nv2.`item`, COUNT(1) AS "qty" FROM npc_vendor nv1 JOIN npc_vendor nv2 ON nv2.`entry` = -nv1.`item` AND nv1.`item` < 0 WHERE nv1.`ExtendedCost` IN %in AND `nv1`.`item` < 0 GROUP BY `item` UNION
SELECT `item`, COUNT(1) AS "qty" FROM game_event_npc_vendor genv JOIN creature c ON c.`guid` = genv.`guid` WHERE `ExtendedCost` IN %in GROUP BY `item`) n
JOIN item_template it ON it.`entry` = n.`item`
GROUP BY `item`';
foreach ($subSrcByXCost as $subSrc => $xCost)
{
foreach (DB::World()->select($vendorQuery, $xCost, $xCost, $xCost) as $v)
foreach (DB::World()->selectAssoc($vendorQuery, $xCost, $xCost, $xCost) as $v)
{
if ($_ = $this->taughtSpell($v))
$this->pushBuffer(Type::SPELL, $_, SRC_PVP, $subSrc);
@ -556,21 +556,21 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #4 Quest', CLI::LOG_BLANK, true, true);
$quests = DB::World()->select(
$quests = DB::World()->selectAssoc(
'SELECT n.`item` AS ARRAY_KEY, n.`ID` AS "quest", SUM(n.`qty`) AS "qty", BIT_OR(n.`side`) AS "side", IF(COUNT(DISTINCT `zone`) > 1, 0, `zone`) AS "zone", it.`class`, it.`subclass`, it.`spellid_1`, it.`spelltrigger_1`, it.`spellid_2`, it.`spelltrigger_2`
FROM (SELECT `RewardChoiceItemID1` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, ?d)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardChoiceItemID1` > 0 UNION ALL
SELECT `RewardChoiceItemID2` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, ?d)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardChoiceItemID2` > 0 UNION ALL
SELECT `RewardChoiceItemID3` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, ?d)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardChoiceItemID3` > 0 UNION ALL
SELECT `RewardChoiceItemID4` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, ?d)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardChoiceItemID4` > 0 UNION ALL
SELECT `RewardChoiceItemID5` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, ?d)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardChoiceItemID5` > 0 UNION ALL
SELECT `RewardChoiceItemID6` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, ?d)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardChoiceItemID6` > 0 UNION ALL
SELECT `RewardItem1` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, ?d)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardItem1` > 0 UNION ALL
SELECT `RewardItem2` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, ?d)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardItem2` > 0 UNION ALL
SELECT `RewardItem3` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, ?d)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardItem3` > 0 UNION ALL
SELECT `RewardItem4` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, ?d)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardItem4` > 0 UNION ALL
SELECT `StartItem` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, ?d)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `StartItem` > 0) n
FROM (SELECT `RewardChoiceItemID1` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, %i)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardChoiceItemID1` > 0 UNION ALL
SELECT `RewardChoiceItemID2` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, %i)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardChoiceItemID2` > 0 UNION ALL
SELECT `RewardChoiceItemID3` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, %i)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardChoiceItemID3` > 0 UNION ALL
SELECT `RewardChoiceItemID4` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, %i)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardChoiceItemID4` > 0 UNION ALL
SELECT `RewardChoiceItemID5` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, %i)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardChoiceItemID5` > 0 UNION ALL
SELECT `RewardChoiceItemID6` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, %i)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardChoiceItemID6` > 0 UNION ALL
SELECT `RewardItem1` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, %i)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardItem1` > 0 UNION ALL
SELECT `RewardItem2` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, %i)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardItem2` > 0 UNION ALL
SELECT `RewardItem3` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, %i)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardItem3` > 0 UNION ALL
SELECT `RewardItem4` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, %i)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardItem4` > 0 UNION ALL
SELECT `StartItem` AS "item", `ID`, 1 AS "qty", IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, %i)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `StartItem` > 0) n
JOIN item_template it ON it.`entry` = n.`item`
{ WHERE n.`ID` NOT IN (?a) }
WHERE n.`ID` NOT IN %in
GROUP BY `item`',
ChrRace::MASK_HORDE, ChrRace::MASK_ALLIANCE, SIDE_HORDE, ChrRace::MASK_ALLIANCE, ChrRace::MASK_HORDE, SIDE_ALLIANCE, SIDE_BOTH,
ChrRace::MASK_HORDE, ChrRace::MASK_ALLIANCE, SIDE_HORDE, ChrRace::MASK_ALLIANCE, ChrRace::MASK_HORDE, SIDE_ALLIANCE, SIDE_BOTH,
@ -583,9 +583,9 @@ CLISetup::registerSetup("sql", new class extends SetupScript
ChrRace::MASK_HORDE, ChrRace::MASK_ALLIANCE, SIDE_HORDE, ChrRace::MASK_ALLIANCE, ChrRace::MASK_HORDE, SIDE_ALLIANCE, SIDE_BOTH,
ChrRace::MASK_HORDE, ChrRace::MASK_ALLIANCE, SIDE_HORDE, ChrRace::MASK_ALLIANCE, ChrRace::MASK_HORDE, SIDE_ALLIANCE, SIDE_BOTH,
ChrRace::MASK_HORDE, ChrRace::MASK_ALLIANCE, SIDE_HORDE, ChrRace::MASK_ALLIANCE, ChrRace::MASK_HORDE, SIDE_ALLIANCE, SIDE_BOTH,
!empty($this->disables[Type::QUEST]) ? array_values($this->disables[Type::QUEST]) : DBSIMPLE_SKIP
$this->disables[Type::QUEST] ?? [0]
);
$areaParent = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, `parentArea` FROM ?_zones WHERE `id` IN (?a) AND `parentArea` > 0', array_filter(array_column($quests, 'zone')));
$areaParent = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, `parentArea` FROM ::zones WHERE `id` IN %in AND `parentArea` > 0', array_filter(array_column($quests, 'zone')));
foreach ($quests as $iId => $q)
{
@ -598,8 +598,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$this->pushBuffer(Type::ITEM, $iId, SRC_QUEST, $q['side'], $q['qty'] > 1 ? 0 : Type::QUEST, $q['quest'], $areaParent[$q['zone']] ?? Game::$questSortFix[$q['zone']] ?? $q['zone']);
}
$mailLoot = DB::World()->select(
'SELECT IF(mlt.`Reference` > 0, -mlt.`Reference`, mlt.`Item`) AS ARRAY_KEY, qt.`Id` AS "entry", it.`class`, it.`subclass`, it.`spellid_1`, it.`spelltrigger_1`, it.`spellid_2`, it.`spelltrigger_2`, COUNT(DISTINCT mlt.`Reference`) AS "qty", IF(COUNT(DISTINCT `QuestSortID`) > 1, 0, GREATEST(`QuestSortID`, 0)) AS "zone", BIT_OR(IF(qt.`AllowableRaces` & ?d AND NOT (qt.`AllowableRaces` & ?d), ?d, IF(qt.`AllowableRaces` & ?d AND NOT (qt.`AllowableRaces` & ?d), ?d, ?d))) AS "side"
$mailLoot = DB::World()->selectAssoc(
'SELECT IF(mlt.`Reference` > 0, -mlt.`Reference`, mlt.`Item`) AS ARRAY_KEY, qt.`Id` AS "entry", it.`class`, it.`subclass`, it.`spellid_1`, it.`spelltrigger_1`, it.`spellid_2`, it.`spelltrigger_2`, COUNT(DISTINCT mlt.`Reference`) AS "qty", IF(COUNT(DISTINCT `QuestSortID`) > 1, 0, GREATEST(`QuestSortID`, 0)) AS "zone", BIT_OR(IF(qt.`AllowableRaces` & %i AND NOT (qt.`AllowableRaces` & %i), %i, IF(qt.`AllowableRaces` & %i AND NOT (qt.`AllowableRaces` & %i), %i, %i))) AS "side"
FROM mail_loot_template mlt
JOIN quest_template_addon qta ON qta.`RewardMailTemplateId` = mlt.`entry`
JOIN quest_template qt ON qt.`ID` = qta.`ID`
@ -609,7 +609,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
ChrRace::MASK_HORDE, ChrRace::MASK_ALLIANCE, SIDE_HORDE, ChrRace::MASK_ALLIANCE, ChrRace::MASK_HORDE, SIDE_ALLIANCE, SIDE_BOTH
);
$areaParent = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, `parentArea` FROM ?_zones WHERE `id` IN (?a) AND `parentArea` > 0', array_filter(array_column($mailLoot, 'zone')));
$areaParent = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, `parentArea` FROM ::zones WHERE `id` IN %in AND `parentArea` > 0', array_filter(array_column($mailLoot, 'zone')));
foreach ($mailLoot as $roi => $l)
{
@ -642,18 +642,18 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #5 Vendor', CLI::LOG_BLANK, true, true);
$xCostIds = DB::Aowow()->selectCol('SELECT `id` FROM dbc_itemextendedcost WHERE `reqHonorPoints` <> 0 OR `reqArenaPoints` <> 0 OR `reqItemId1` IN (?a) OR `reqItemId2` IN (?a) OR `reqItemId3` IN (?a) OR `reqItemId4` IN (?a) OR `reqItemId5` IN (?a)', self::PVP_MONEY, self::PVP_MONEY, self::PVP_MONEY, self::PVP_MONEY, self::PVP_MONEY);
$vendors = DB::World()->select(
$xCostIds = DB::Aowow()->selectCol('SELECT `id` FROM dbc_itemextendedcost WHERE `reqHonorPoints` <> 0 OR `reqArenaPoints` <> 0 OR `reqItemId1` IN %in OR `reqItemId2` IN %in OR `reqItemId3` IN %in OR `reqItemId4` IN %in OR `reqItemId5` IN %in', self::PVP_MONEY, self::PVP_MONEY, self::PVP_MONEY, self::PVP_MONEY, self::PVP_MONEY);
$vendors = DB::World()->selectAssoc(
'SELECT n.`item`, n.`npc`, SUM(n.`qty`) AS "qty", it.`class`, it.`subclass`, it.`spellid_1`, it.`spelltrigger_1`, it.`spellid_2`, it.`spelltrigger_2`
FROM (SELECT `item`, `entry` AS "npc", COUNT(1) AS "qty" FROM npc_vendor WHERE `ExtendedCost` NOT IN (?a) AND `item` > 0 GROUP BY `item`, `npc` UNION
SELECT nv2.`item`, nv1.`entry` AS "npc", COUNT(1) AS "qty" FROM npc_vendor nv1 JOIN npc_vendor nv2 ON nv2.`entry` = -nv1.`item` AND nv1.`item` < 0 WHERE nv1.`ExtendedCost` NOT IN (?a) AND `nv1`.`item` < 0 GROUP BY `item`, `npc` UNION
SELECT `item`, c.`id` AS "npc", COUNT(1) AS "qty" FROM game_event_npc_vendor genv JOIN creature c ON c.`guid` = genv.`guid` WHERE `ExtendedCost` NOT IN (?a) GROUP BY `item`, `npc`) n
FROM (SELECT `item`, `entry` AS "npc", COUNT(1) AS "qty" FROM npc_vendor WHERE `ExtendedCost` NOT IN %in AND `item` > 0 GROUP BY `item`, `npc` UNION
SELECT nv2.`item`, nv1.`entry` AS "npc", COUNT(1) AS "qty" FROM npc_vendor nv1 JOIN npc_vendor nv2 ON nv2.`entry` = -nv1.`item` AND nv1.`item` < 0 WHERE nv1.`ExtendedCost` NOT IN %in AND `nv1`.`item` < 0 GROUP BY `item`, `npc` UNION
SELECT `item`, c.`id` AS "npc", COUNT(1) AS "qty" FROM game_event_npc_vendor genv JOIN creature c ON c.`guid` = genv.`guid` WHERE `ExtendedCost` NOT IN %in GROUP BY `item`, `npc`) n
JOIN item_template it ON it.`entry` = n.`item`
GROUP BY `item`, `npc`',
$xCostIds, $xCostIds, $xCostIds
);
$spawns = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ?_spawns WHERE `type` = ?d AND `typeId`IN (?a) GROUP BY `typeId`', Type::NPC, array_column($vendors, 'npc'));
$spawns = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ::spawns WHERE `type` = %i AND `typeId`IN %in GROUP BY `typeId`', Type::NPC, array_column($vendors, 'npc'));
foreach ($vendors as $v)
{
@ -673,7 +673,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$this->pushBuffer(Type::ITEM, $item, SRC_STARTER);
for ($i = 1; $i < 21; $i++)
if ($cso = DB::Aowow()->selectCol('SELECT ?# FROM dbc_charstartoutfit WHERE ?# > 0', 'item'.$i, 'item'.$i))
if ($cso = DB::Aowow()->selectCol('SELECT %n FROM dbc_charstartoutfit WHERE %n > 0', 'item'.$i, 'item'.$i))
foreach ($cso as $item)
$this->pushBuffer(Type::ITEM, $item, SRC_STARTER);
}
@ -682,8 +682,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #12 Achievement', CLI::LOG_BLANK, true, true);
$xItems = DB::Aowow()->select('SELECT `id` AS "entry", `itemExtra` AS ARRAY_KEY, COUNT(1) AS "qty" FROM ?_achievement WHERE `itemExtra` > 0 GROUP BY `itemExtra`');
$rewItems = DB::World()->select(
$xItems = DB::Aowow()->selectAssoc('SELECT `id` AS "entry", `itemExtra` AS ARRAY_KEY, COUNT(1) AS "qty" FROM ::achievement WHERE `itemExtra` > 0 GROUP BY `itemExtra`');
$rewItems = DB::World()->selectAssoc(
'SELECT src.`item` AS ARRAY_KEY, src.`entry`, it.`class`, it.`subclass`, it.`spellid_1`, it.`spelltrigger_1`, it.`spellid_2`, it.`spelltrigger_2`, COUNT(1) AS "qty"
FROM (SELECT IFNULL(IF(mlt.`Reference` > 0, -mlt.`Reference`, mlt.`Item`), ar.`ItemID`) AS "item", ar.`ID` AS "entry"
FROM achievement_reward ar
@ -697,7 +697,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CLI::write('[source] itemAchievement() - Reward items are unexpectedly empty.', CLI::LOG_WARN);
else
{
$extraItems = DB::World()->select('SELECT `entry` AS ARRAY_KEY, `class`, `subclass`, `spellid_1`, `spelltrigger_1`, `spellid_2`, `spelltrigger_2` FROM item_template WHERE `entry` IN (?a)', array_keys($xItems));
$extraItems = DB::World()->selectAssoc('SELECT `entry` AS ARRAY_KEY, `class`, `subclass`, `spellid_1`, `spelltrigger_1`, `spellid_2`, `spelltrigger_2` FROM item_template WHERE `entry` IN %in', array_keys($xItems));
foreach ($extraItems as $iId => $l)
{
if ($_ = $this->taughtSpell($l))
@ -720,7 +720,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #15 Disenchanted', CLI::LOG_BLANK, true, true);
$deLoot = DB::World()->select(
$deLoot = DB::World()->selectAssoc(
'SELECT IF(dlt.`Reference` > 0, -dlt.`Reference`, dlt.`Item`) AS "refOrItem", itA.`entry`, itB.`class`, itB.`subclass`, itB.`spellid_1`, itB.`spelltrigger_1`, itB.`spellid_2`, itB.`spelltrigger_2`, COUNT(DISTINCT dlt.`Reference`) AS "qty"
FROM disenchant_loot_template dlt
JOIN item_template itA ON dlt.`entry` = itA.`DisenchantId`
@ -757,10 +757,10 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #16 Fished', CLI::LOG_BLANK, true, true);
$fishLoot = DB::World()->select(
$fishLoot = DB::World()->selectAssoc(
'SELECT src.`itemOrRef` AS "refOrItem", src.`entry`, it.`class`, it.`subclass`, it.`spellid_1`, it.`spelltrigger_1`, it.`spellid_2`, it.`spelltrigger_2`, COUNT(DISTINCT src.`itemOrRef`) AS "qty", IF(COUNT(DISTINCT `zone`) > 2, 0, MAX(`zone`)) AS "zone"
FROM (SELECT 0 AS "entry", IF(flt.`Reference` > 0, -flt.`Reference`, flt.`Item`) AS "itemOrRef", `entry` AS "zone" FROM fishing_loot_template flt UNION
SELECT gt.`entry`, IF(glt.`Reference` > 0, -glt.`Reference`, glt.`Item`) AS "itemOrRef", 0 AS "zone" FROM gameobject_template gt JOIN gameobject_loot_template glt ON glt.`entry` = gt.`data1` WHERE `type` = ?d AND gt.`data1` > 0) src
SELECT gt.`entry`, IF(glt.`Reference` > 0, -glt.`Reference`, glt.`Item`) AS "itemOrRef", 0 AS "zone" FROM gameobject_template gt JOIN gameobject_loot_template glt ON glt.`entry` = gt.`data1` WHERE `type` = %i AND gt.`data1` > 0) src
LEFT JOIN item_template it ON src.`itemOrRef` > 0 AND src.`itemOrRef` = it.`entry`
GROUP BY `refOrItem`, src.`entry`',
OBJECT_FISHINGHOLE
@ -772,8 +772,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
return;
}
$goSpawns = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ?_spawns WHERE `type` = ?d AND `typeId`IN (?a) GROUP BY `typeId`', Type::OBJECT, array_filter(array_column($fishLoot, 'entry')));
$areaParent = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, `parentArea` FROM ?_zones WHERE `id` IN (?a) AND `parentArea` > 0', array_filter(array_column($fishLoot, 'zone')));
$goSpawns = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ::spawns WHERE `type` = %i AND `typeId`IN %in GROUP BY `typeId`', Type::OBJECT, array_filter(array_column($fishLoot, 'entry')));
$areaParent = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, `parentArea` FROM ::zones WHERE `id` IN %in AND `parentArea` > 0', array_filter(array_column($fishLoot, 'zone')));
foreach ($fishLoot as $l)
{
@ -807,14 +807,14 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #17 Gathered', CLI::LOG_BLANK, true, true);
$herbLoot = DB::World()->select(
$herbLoot = DB::World()->selectAssoc(
'SELECT src.`itemOrRef` AS "refOrItem", src.`entry`, it.`class`, it.`subclass`, it.`spellid_1`, it.`spelltrigger_1`, it.`spellid_2`, it.`spelltrigger_2`, COUNT(DISTINCT src.`itemOrRef`) AS "qty", src.`srcType`
FROM (SELECT ct.`entry`, IF(slt.`Reference` > 0, -slt.`Reference`, slt.`Item`) `itemOrRef`, ?d AS "srcType" FROM creature_template ct JOIN skinning_loot_template slt ON slt.`entry` = ct.`skinloot` WHERE (`type_flags` & ?d) AND ct.`skinloot` > 0 UNION
SELECT gt.`entry`, IF(glt.`Reference` > 0, -glt.`Reference`, glt.`Item`) `itemOrRef`, ?d AS "srcType" FROM gameobject_template gt JOIN gameobject_loot_template glt ON glt.`entry` = gt.`data1` WHERE gt.`type` = ?d AND gt.`data1` > 0 AND gt.`data0` IN (?a)) src
FROM (SELECT ct.`entry`, IF(slt.`Reference` > 0, -slt.`Reference`, slt.`Item`) `itemOrRef`, %i AS "srcType" FROM creature_template ct JOIN skinning_loot_template slt ON slt.`entry` = ct.`skinloot` WHERE (`type_flags` & %i) AND ct.`skinloot` > 0 UNION
SELECT gt.`entry`, IF(glt.`Reference` > 0, -glt.`Reference`, glt.`Item`) `itemOrRef`, %i AS "srcType" FROM gameobject_template gt JOIN gameobject_loot_template glt ON glt.`entry` = gt.`data1` WHERE gt.`type` = %i AND gt.`data1` > 0 AND gt.`data0` IN %in) src
LEFT JOIN item_template it ON src.itemOrRef > 0 AND src.`itemOrRef` = it.`entry`
GROUP BY `refOrItem`, src.`entry`',
Type::NPC, NPC_TYPEFLAG_SKIN_WITH_HERBALISM,
Type::OBJECT, OBJECT_CHEST, DB::Aowow()->selectCol('SELECT `id` FROM dbc_lock WHERE `properties1` = ?d', LOCK_PROPERTY_HERBALISM)
Type::OBJECT, OBJECT_CHEST, DB::Aowow()->selectCol('SELECT `id` FROM dbc_lock WHERE `properties1` = %i', LOCK_PROPERTY_HERBALISM)
);
if (!$herbLoot)
@ -823,8 +823,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
return;
}
$spawns[Type::OBJECT] = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ?_spawns WHERE `type` = ?d AND `typeId` IN (?a) GROUP BY `typeId`', Type::OBJECT, array_column(array_filter($herbLoot, fn($x) => $x['srcType'] == Type::OBJECT), 'entry'));
$spawns[Type::NPC] = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ?_spawns WHERE `type` = ?d AND `typeId` IN (?a) GROUP BY `typeId`', Type::NPC, array_column(array_filter($herbLoot, fn($x) => $x['srcType'] == Type::NPC), 'entry'));
$spawns[Type::OBJECT] = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ::spawns WHERE `type` = %i AND `typeId` IN %in GROUP BY `typeId`', Type::OBJECT, array_column(array_filter($herbLoot, fn($x) => $x['srcType'] == Type::OBJECT), 'entry'));
$spawns[Type::NPC] = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ::spawns WHERE `type` = %i AND `typeId` IN %in GROUP BY `typeId`', Type::NPC, array_column(array_filter($herbLoot, fn($x) => $x['srcType'] == Type::NPC), 'entry'));
foreach ($herbLoot as $l)
{
@ -860,7 +860,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #18 Milled', CLI::LOG_BLANK, true, true);
$millLoot = DB::World()->select(
$millLoot = DB::World()->selectAssoc(
'SELECT IF(mlt.`Reference` > 0, -mlt.`Reference`, mlt.`Item`) AS "refOrItem", itA.`entry`, itB.`class`, itB.`subclass`, itB.`spellid_1`, itB.`spelltrigger_1`, itB.`spellid_2`, itB.`spelltrigger_2`, COUNT(DISTINCT mlt.`Reference`) AS "qty"
FROM milling_loot_template mlt
JOIN item_template itA ON mlt.`entry` = itA.`entry`
@ -896,14 +896,14 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #19 Mined', CLI::LOG_BLANK, true, true);
$mineLoot = DB::World()->select(
$mineLoot = DB::World()->selectAssoc(
'SELECT src.`itemOrRef` AS "refOrItem", src.`entry`, it.`class`, it.`subclass`, it.`spellid_1`, it.`spelltrigger_1`, it.`spellid_2`, it.`spelltrigger_2`, COUNT(DISTINCT src.`itemOrRef`) AS "qty", src.`srcType`
FROM (SELECT ct.`entry`, IF(slt.`Reference` > 0, -slt.`Reference`, slt.`Item`) `itemOrRef`, ?d AS "srcType" FROM creature_template ct JOIN skinning_loot_template slt ON slt.`entry` = ct.`skinloot` WHERE (`type_flags` & ?d) AND ct.`skinloot` > 0 UNION
SELECT gt.`entry`, IF(glt.`Reference` > 0, -glt.`Reference`, glt.`Item`) `itemOrRef`, ?d AS "srcType" FROM gameobject_template gt JOIN gameobject_loot_template glt ON glt.`entry` = gt.`data1` WHERE gt.`type` = ?d AND gt.`data1` > 0 AND gt.`data0` IN (?a)) src
FROM (SELECT ct.`entry`, IF(slt.`Reference` > 0, -slt.`Reference`, slt.`Item`) `itemOrRef`, %i AS "srcType" FROM creature_template ct JOIN skinning_loot_template slt ON slt.`entry` = ct.`skinloot` WHERE (`type_flags` & %i) AND ct.`skinloot` > 0 UNION
SELECT gt.`entry`, IF(glt.`Reference` > 0, -glt.`Reference`, glt.`Item`) `itemOrRef`, %i AS "srcType" FROM gameobject_template gt JOIN gameobject_loot_template glt ON glt.`entry` = gt.`data1` WHERE gt.`type` = %i AND gt.`data1` > 0 AND gt.`data0` IN %in) src
LEFT JOIN item_template it ON src.itemOrRef > 0 AND src.`itemOrRef` = it.`entry`
GROUP BY `refOrItem`, src.`entry`',
Type::NPC, NPC_TYPEFLAG_SKIN_WITH_MINING,
Type::OBJECT, OBJECT_CHEST, DB::Aowow()->selectCol('SELECT `id` FROM dbc_lock WHERE `properties1` = ?d', LOCK_PROPERTY_MINING)
Type::OBJECT, OBJECT_CHEST, DB::Aowow()->selectCol('SELECT `id` FROM dbc_lock WHERE `properties1` = %i', LOCK_PROPERTY_MINING)
);
if (!$mineLoot)
@ -912,8 +912,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
return;
}
$spawns[Type::OBJECT] = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ?_spawns WHERE `type` = ?d AND `typeId`IN (?a) GROUP BY `typeId`', Type::OBJECT, array_column(array_filter($mineLoot, fn($x) => $x['srcType'] == Type::OBJECT), 'entry'));
$spawns[Type::NPC] = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ?_spawns WHERE `type` = ?d AND `typeId`IN (?a) GROUP BY `typeId`', Type::NPC, array_column(array_filter($mineLoot, fn($x) => $x['srcType'] == Type::NPC), 'entry'));
$spawns[Type::OBJECT] = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ::spawns WHERE `type` = %i AND `typeId`IN %in GROUP BY `typeId`', Type::OBJECT, array_column(array_filter($mineLoot, fn($x) => $x['srcType'] == Type::OBJECT), 'entry'));
$spawns[Type::NPC] = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ::spawns WHERE `type` = %i AND `typeId`IN %in GROUP BY `typeId`', Type::NPC, array_column(array_filter($mineLoot, fn($x) => $x['srcType'] == Type::NPC), 'entry'));
foreach ($mineLoot as $l)
{
@ -949,7 +949,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #20 Prospected', CLI::LOG_BLANK, true, true);
$prospectLoot = DB::World()->select(
$prospectLoot = DB::World()->selectAssoc(
'SELECT IF(plt.`Reference` > 0, -plt.`Reference`, plt.`Item`) AS "refOrItem", itA.`entry`, itB.`class`, itB.`subclass`, itB.`spellid_1`, itB.`spelltrigger_1`, itB.`spellid_2`, itB.`spelltrigger_2`, COUNT(DISTINCT plt.`Reference`) AS "qty"
FROM prospecting_loot_template plt
JOIN item_template itA ON plt.`entry` = itA.`entry`
@ -985,7 +985,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #21 Pickpocket', CLI::LOG_BLANK, true, true);
$theftLoot = DB::World()->select(
$theftLoot = DB::World()->selectAssoc(
'SELECT src.`itemOrRef` AS "refOrItem", src.`entry`, it.`class`, it.`subclass`, it.`spellid_1`, it.`spelltrigger_1`, it.`spellid_2`, it.`spelltrigger_2`, COUNT(DISTINCT src.`itemOrRef`) AS "qty"
FROM (SELECT ct.`entry`, IF(plt.`Reference` > 0, -plt.`Reference`, plt.`Item`) `itemOrRef` FROM creature_template ct JOIN pickpocketing_loot_template plt ON plt.`entry` = ct.`pickpocketloot` WHERE ct.`pickpocketloot` > 0) src
LEFT JOIN item_template it ON src.`itemOrRef` > 0 AND src.`itemOrRef` = it.`entry`
@ -998,7 +998,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
return;
}
$spawns = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ?_spawns WHERE `type` = ?d AND `typeId`IN (?a) GROUP BY `typeId`', Type::NPC, array_filter(array_column($theftLoot, 'entry')));
$spawns = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ::spawns WHERE `type` = %i AND `typeId`IN %in GROUP BY `typeId`', Type::NPC, array_filter(array_column($theftLoot, 'entry')));
foreach ($theftLoot as $l)
{
@ -1034,9 +1034,9 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #22 Salvaged', CLI::LOG_BLANK, true, true);
$salvageLoot = DB::World()->select(
$salvageLoot = DB::World()->selectAssoc(
'SELECT src.`itemOrRef` AS "refOrItem", src.`entry`, it.`class`, it.`subclass`, it.`spellid_1`, it.`spelltrigger_1`, it.`spellid_2`, it.`spelltrigger_2`, COUNT(DISTINCT src.`itemOrRef`) AS "qty"
FROM (SELECT ct.`entry`, IF(slt.`Reference` > 0, -slt.`Reference`, slt.`Item`) `itemOrRef` FROM creature_template ct JOIN skinning_loot_template slt ON slt.`entry` = ct.`skinloot` WHERE (`type_flags` & ?d) AND ct.`skinloot` > 0) src
FROM (SELECT ct.`entry`, IF(slt.`Reference` > 0, -slt.`Reference`, slt.`Item`) `itemOrRef` FROM creature_template ct JOIN skinning_loot_template slt ON slt.`entry` = ct.`skinloot` WHERE (`type_flags` & %i) AND ct.`skinloot` > 0) src
LEFT JOIN item_template it ON src.`itemOrRef` > 0 AND src.`itemOrRef` = it.`entry`
GROUP BY `refOrItem`, src.`entry`',
NPC_TYPEFLAG_SKIN_WITH_ENGINEERING
@ -1048,7 +1048,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
return;
}
$spawns = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ?_spawns WHERE `type` = ?d AND `typeId`IN (?a) GROUP BY `typeId`', Type::NPC, array_filter(array_column($salvageLoot, 'entry')));
$spawns = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ::spawns WHERE `type` = %i AND `typeId`IN %in GROUP BY `typeId`', Type::NPC, array_filter(array_column($salvageLoot, 'entry')));
foreach ($salvageLoot as $l)
{
@ -1084,9 +1084,9 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #23 Skinned', CLI::LOG_BLANK, true, true);
$skinLoot = DB::World()->select(
$skinLoot = DB::World()->selectAssoc(
'SELECT src.`itemOrRef` AS "refOrItem", src.`entry`, it.`class`, it.`subclass`, it.`spellid_1`, it.`spelltrigger_1`, it.`spellid_2`, it.`spelltrigger_2`, COUNT(DISTINCT src.`itemOrRef`) AS "qty"
FROM (SELECT ct.`entry`, IF(slt.`Reference` > 0, -slt.`Reference`, slt.`Item`) `itemOrRef` FROM creature_template ct JOIN skinning_loot_template slt ON slt.`entry` = ct.`skinloot` WHERE (`type_flags` & ?d) = 0 AND ct.`skinloot` > 0 AND ct.`type` <> 13) src
FROM (SELECT ct.`entry`, IF(slt.`Reference` > 0, -slt.`Reference`, slt.`Item`) `itemOrRef` FROM creature_template ct JOIN skinning_loot_template slt ON slt.`entry` = ct.`skinloot` WHERE (`type_flags` & %i) = 0 AND ct.`skinloot` > 0 AND ct.`type` <> 13) src
LEFT JOIN item_template it ON src.`itemOrRef` > 0 AND src.`itemOrRef` = it.`entry`
GROUP BY `refOrItem`, src.`entry`',
NPC_TYPEFLAG_SPECIALLOOT
@ -1098,7 +1098,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
return;
}
$spawns = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ?_spawns WHERE `type` = ?d AND `typeId`IN (?a) GROUP BY `typeId`', Type::NPC, array_filter(array_column($skinLoot, 'entry')));
$spawns = DB::Aowow()->selectCol('SELECT `typeId` AS ARRAY_KEY, IF(COUNT(DISTINCT `areaId`) > 1, 0, `areaId`) FROM ::spawns WHERE `type` = %i AND `typeId`IN %in GROUP BY `typeId`', Type::NPC, array_filter(array_column($skinLoot, 'entry')));
foreach ($skinLoot as $l)
{
@ -1134,15 +1134,15 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #4 Quest', CLI::LOG_BLANK, true, true);
$quests = DB::World()->select(
$quests = DB::World()->selectAssoc(
'SELECT `spell` AS ARRAY_KEY, `ID` AS "id", SUM(`qty`) AS "qty", BIT_OR(`side`) AS "side", IF(COUNT(DISTINCT `zone`) > 1, 0, `zone`) AS "zone"
FROM (SELECT IF(`RewardSpell` = 0, `RewardDisplaySpell`, `RewardSpell`) AS "spell", `ID`, 1 AS "qty", IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, ?d)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE IF(`RewardSpell` = 0, `RewardDisplaySpell`, `RewardSpell`) > 0 UNION ALL
SELECT qta.`SourceSpellId` AS "spell", qt.`ID`, 1 AS "qty", IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, ?d)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template qt JOIN quest_template_addon qta ON qta.ID = qt.ID WHERE qta.`SourceSpellId` > 0 ) t
{ WHERE t.`ID` NOT IN (?a) }
FROM (SELECT IF(`RewardSpell` = 0, `RewardDisplaySpell`, `RewardSpell`) AS "spell", `ID`, 1 AS "qty", IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, %i)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE IF(`RewardSpell` = 0, `RewardDisplaySpell`, `RewardSpell`) > 0 UNION ALL
SELECT qta.`SourceSpellId` AS "spell", qt.`ID`, 1 AS "qty", IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, %i)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template qt JOIN quest_template_addon qta ON qta.ID = qt.ID WHERE qta.`SourceSpellId` > 0 ) t
WHERE t.`ID` NOT IN %in
GROUP BY `spell`',
ChrRace::MASK_HORDE, ChrRace::MASK_ALLIANCE, SIDE_HORDE, ChrRace::MASK_ALLIANCE, ChrRace::MASK_HORDE, SIDE_ALLIANCE, SIDE_BOTH,
ChrRace::MASK_HORDE, ChrRace::MASK_ALLIANCE, SIDE_HORDE, ChrRace::MASK_ALLIANCE, ChrRace::MASK_HORDE, SIDE_ALLIANCE, SIDE_BOTH,
!empty($this->disables[Type::QUEST]) ? array_values($this->disables[Type::QUEST]) : DBSIMPLE_SKIP
$this->disables[Type::QUEST] ?? [0]
);
if (!$quests)
@ -1151,8 +1151,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
return;
}
$areaParent = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, `parentArea` FROM ?_zones WHERE `id` IN (?a) AND `parentArea` > 0', array_filter(array_column($quests, 'zone')));
$qSpells = DB::Aowow()->select('SELECT `id` AS ARRAY_KEY, `effect1Id`, `effect2Id`, `effect3Id`, `effect1TriggerSpell`, `effect2TriggerSpell`, `effect3TriggerSpell` FROM dbc_spell WHERE `id` IN (?a) AND (`effect1Id` = ?d OR `effect2Id` = ?d OR `effect3Id` = ?d)',
$areaParent = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, `parentArea` FROM ::zones WHERE `id` IN %in AND `parentArea` > 0', array_filter(array_column($quests, 'zone')));
$qSpells = DB::Aowow()->selectAssoc('SELECT `id` AS ARRAY_KEY, `effect1Id`, `effect2Id`, `effect3Id`, `effect1TriggerSpell`, `effect2TriggerSpell`, `effect3TriggerSpell` FROM dbc_spell WHERE `id` IN %in AND (`effect1Id` = %i OR `effect2Id` = %i OR `effect3Id` = %i)',
array_keys($quests), SPELL_EFFECT_LEARN_SPELL, SPELL_EFFECT_LEARN_SPELL, SPELL_EFFECT_LEARN_SPELL
);
@ -1166,7 +1166,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #6 Trainer', CLI::LOG_BLANK, true, true);
$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');
$tNpcs = DB::World()->selectAssoc('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');
if (!$tNpcs)
{
CLI::write('[source] spelltrainer() - trainer_spell contained no spell or creature_default_trainer no trainer.', CLI::LOG_WARN);
@ -1175,7 +1175,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
// note: for consistency you could check for boss dummys and get the zone where the trainer resides, but seriously. Whats wrong with you‽
$tSpells = DB::Aowow()->select('SELECT `id` AS ARRAY_KEY, `effect1Id`, `effect2Id`, `effect3Id`, `effect1TriggerSpell`, `effect2TriggerSpell`, `effect3TriggerSpell` FROM dbc_spell WHERE `id` IN (?a)', array_keys($tNpcs));
$tSpells = DB::Aowow()->selectAssoc('SELECT `id` AS ARRAY_KEY, `effect1Id`, `effect2Id`, `effect3Id`, `effect1TriggerSpell`, `effect2TriggerSpell`, `effect3TriggerSpell` FROM dbc_spell WHERE `id` IN %in', array_keys($tNpcs));
// todo (med): this skips some spells (e.g. riding)
foreach ($tNpcs as $spellId => $npc)
@ -1206,7 +1206,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CLI::write('[source] * #7 Discovery', CLI::LOG_BLANK, true, true);
// 61756: Northrend Inscription Research (FAST QA VERSION);
if ($disco = DB::World()->selectCol('SELECT `spellId` FROM skill_discovery_template WHERE `reqSpell` <> ?d', 61756))
if ($disco = DB::World()->selectCol('SELECT `spellId` FROM skill_discovery_template WHERE `reqSpell` <> %i', 61756))
foreach ($disco as $d)
$this->pushBuffer(Type::SPELL, $d, SRC_DISCOVERY);
}
@ -1215,11 +1215,11 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #9 Talent', CLI::LOG_BLANK, true, true);
$tSpells = DB::Aowow()->select(
$tSpells = DB::Aowow()->selectAssoc(
'SELECT s.`id` AS ARRAY_KEY, s.`effect1Id`, s.`effect2Id`, s.`effect3Id`, s.`effect1TriggerSpell`, s.`effect2TriggerSpell`, s.`effect3TriggerSpell`
FROM dbc_talent t
JOIN dbc_spell s ON s.`id` = t.`rank1`
WHERE t.`rank2` < 1 AND (t.`talentSpell` = 1 OR (s.`effect1Id` = ?d OR s.`effect2Id` = ?d OR s.`effect3Id` = ?d))',
WHERE t.`rank2` < 1 AND (t.`talentSpell` = 1 OR (s.`effect1Id` = %i OR s.`effect2Id` = %i OR s.`effect3Id` = %i))',
SPELL_EFFECT_LEARN_SPELL, SPELL_EFFECT_LEARN_SPELL, SPELL_EFFECT_LEARN_SPELL
);
@ -1245,7 +1245,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
if (!$recurse)
break;
$tSpells = DB::Aowow()->select('SELECT `id` AS ARRAY_KEY, `effect1Id`, `effect2Id`, `effect3Id`, `effect1TriggerSpell`, `effect2TriggerSpell`, `effect3TriggerSpell` FROM dbc_spell WHERE `id` IN (?a)', array_keys($recurse));
$tSpells = DB::Aowow()->selectAssoc('SELECT `id` AS ARRAY_KEY, `effect1Id`, `effect2Id`, `effect3Id`, `effect1TriggerSpell`, `effect2TriggerSpell`, `effect3TriggerSpell` FROM dbc_spell WHERE `id` IN %in', array_keys($recurse));
}
}
@ -1258,7 +1258,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CLI::write('[source] * #10 Starter', CLI::LOG_BLANK, true, true);
$pcis = DB::World()->selectCol('SELECT DISTINCT `skill` FROM playercreateinfo_skills');
$subSkills = DB::Aowow()->selectCol('SELECT `spellId` FROM dbc_skilllineability WHERE {(`skillLineId` IN (?a) AND `acquireMethod` = 2) OR} (`acquireMethod` = 1 AND (`reqSkillLevel` = 1 OR `skillLineId` = ?d)) GROUP BY `spellId`', $pcis ?: DBSIMPLE_SKIP, SKILL_FIRST_AID);
$subSkills = DB::Aowow()->selectCol('SELECT `spellId` FROM dbc_skilllineability WHERE %if', $pcis, '(`skillLineId` IN %in AND `acquireMethod` = 2) OR', $pcis, '%end (`acquireMethod` = 1 AND (`reqSkillLevel` = 1 OR `skillLineId` = %i)) GROUP BY `spellId`', SKILL_FIRST_AID);
foreach ($subSkills as $s)
$this->pushBuffer(Type::SPELL, $s, SRC_STARTER);
}
@ -1267,13 +1267,13 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #4 Quest', CLI::LOG_BLANK, true, true);
$quests = DB::World()->select(
$quests = DB::World()->selectAssoc(
'SELECT `RewardTitle` AS ARRAY_KEY, `ID` AS "id", SUM(`qty`) AS "qty", BIT_OR(`side`) AS "side", IF(COUNT(DISTINCT `zone`) > 1, 0, `zone`) AS "zone"
FROM (SELECT `RewardTitle`, `ID`, 1 AS "qty", IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, IF(`AllowableRaces` & ?d AND NOT (`AllowableRaces` & ?d), ?d, ?d)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardTitle` > 0) q
{ WHERE q.`Id` NOT IN (?a) }
FROM (SELECT `RewardTitle`, `ID`, 1 AS "qty", IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, IF(`AllowableRaces` & %i AND NOT (`AllowableRaces` & %i), %i, %i)) AS "side", GREATEST(`QuestSortID`, 0) AS "zone" FROM quest_template WHERE `RewardTitle` > 0) q
WHERE q.`Id` NOT IN %in
GROUP BY `RewardTitle`',
ChrRace::MASK_HORDE, ChrRace::MASK_ALLIANCE, SIDE_HORDE, ChrRace::MASK_ALLIANCE, ChrRace::MASK_HORDE, SIDE_ALLIANCE, SIDE_BOTH,
!empty($this->disables[Type::QUEST]) ? array_values($this->disables[Type::QUEST]) : DBSIMPLE_SKIP
$this->disables[Type::QUEST] ?? [0]
);
if (!$quests)
@ -1282,7 +1282,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
return;
}
$areaParent = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, `parentArea` FROM ?_zones WHERE `id` IN (?a) AND parentArea > 0', array_filter(array_column($quests, 'zone')));
$areaParent = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, `parentArea` FROM ::zones WHERE `id` IN %in AND parentArea > 0', array_filter(array_column($quests, 'zone')));
foreach ($quests as $titleId => $q)
$this->pushBuffer(Type::TITLE, $titleId, SRC_QUEST, $q['side'], $q['qty'] > 1 ? 0 : Type::QUEST, $q['id'], $areaParent[$q['zone']] ?? Game::$questSortFix[$q['zone']] ?? $q['zone']);
@ -1292,7 +1292,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
CLI::write('[source] * #12 Achievement', CLI::LOG_BLANK, true, true);
$sets = DB::World()->select(
$sets = DB::World()->selectAssoc(
'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 UNION
SELECT `TitleH` AS "titleId", `ID` FROM achievement_reward WHERE `TitleH` <> 0) AS x
@ -1304,7 +1304,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$this->pushBuffer(Type::TITLE, $tId, SRC_ACHIEVEMENT, 1, Type::ACHIEVEMENT, $set['srcId']);
if ($set['altSrcId'])
DB::Aowow()->query('UPDATE ?_titles SET src12Ext = ?d WHERE id = ?d', $set['altSrcId'], $tId);
DB::Aowow()->qry('UPDATE ::titles SET src12Ext = %i WHERE id = %i', $set['altSrcId'], $tId);
}
}
@ -1318,9 +1318,9 @@ CLISetup::registerSetup("sql", new class extends SetupScript
private function itemset() : void
{
// every item in ?_itemset needs a source. if so merge fields. if not it's not available.
// every item in ::itemset needs a source. if so merge fields. if not it's not available.
$sets = DB::Aowow()->select('SELECT `id` AS ARRAY_KEY, `contentGroup`, `item1`, `item2`, `item3`, `item4`, `item5`, `item6`, `item7`, `item8`, `item9`, `item10` FROM ?_itemset');
$sets = DB::Aowow()->selectAssoc('SELECT `id` AS ARRAY_KEY, `contentGroup`, `item1`, `item2`, `item3`, `item4`, `item5`, `item6`, `item7`, `item8`, `item9`, `item10` FROM ::itemset');
$metaSrc = [];
foreach ($sets as $id => $set)

View file

@ -27,8 +27,10 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $worldDependency = ['creature', 'creature_addon', 'creature_template_addon', 'gameobject', 'gameobject_template', 'vehicle_accessory', 'vehicle_accessory_template', 'waypoint_data', 'smart_scripts', 'areatrigger_teleport'];
protected $setupAfter = [['dungeonmap', 'worldmaparea', 'zones'], ['img-maps']];
private $transports = [];
private $overrideData = [];
private array $transports = [];
private array $overrideData = [];
private array $mapToArea = [];
private array $areaParents = [];
private $steps = array(
0x01 => ['creature', Type::NPC, false, '`creature` spawns', ],
@ -40,7 +42,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
);
public function generate(array $ids = []) : bool
public function generate() : bool
{
/*****************************/
/* find out what to generate */
@ -74,30 +76,32 @@ CLISetup::registerSetup("sql", new class extends SetupScript
/*********************************/
if (!$todoMask || ($todoMask & 0x1F) == 0x1F)
DB::Aowow()->query('TRUNCATE TABLE ?_spawns');
DB::Aowow()->qry('TRUNCATE TABLE ::spawns');
else
foreach ($this->steps as $idx => [, $type, $isWP, ])
if (($idx & $todoMask) && !$isWP)
DB::Aowow()->query('DELETE FROM ?_spawns WHERE `type` = ?d', $type);
DB::Aowow()->qry('DELETE FROM ::spawns WHERE `type` = %i', $type);
if (!$todoMask || ($todoMask & 0x20))
DB::Aowow()->query('TRUNCATE TABLE ?_creature_waypoints');
DB::Aowow()->qry('TRUNCATE TABLE ::creature_waypoints');
/**************************/
/* offsets for transports */
/**************************/
$this->transports = DB::World()->selectCol('SELECT `data0` AS `pathId`, `data6` AS ARRAY_KEY FROM gameobject_template WHERE `type` = ?d AND `data6` <> 0', OBJECT_MO_TRANSPORT);
$this->transports = DB::World()->selectCol('SELECT `data0` AS `pathId`, `data6` AS ARRAY_KEY FROM gameobject_template WHERE `type` = %i AND `data6` <> 0', OBJECT_MO_TRANSPORT);
foreach ($this->transports as &$t)
$t = DB::Aowow()->selectRow('SELECT `posX`, `posY`, `mapId` FROM dbc_taxipathnode tpn WHERE tpn.`pathId` = ?d AND `nodeIdx` = 0', $t);
$t = DB::Aowow()->selectRow('SELECT `posX`, `posY`, `mapId` FROM dbc_taxipathnode tpn WHERE tpn.`pathId` = %i AND `nodeIdx` = 0', $t);
/*********************/
/* get override data */
/*********************/
$this->overrideData = DB::Aowow()->select('SELECT `type` AS ARRAY_KEY, `typeGuid` AS ARRAY_KEY2, `areaId`, `floor` FROM ?_spawns_override');
$this->overrideData = DB::Aowow()->selectAssoc('SELECT `type` AS ARRAY_KEY, `typeGuid` AS ARRAY_KEY2, `areaId`, `floor` FROM ::spawns_override');
$this->mapToArea = DB::Aowow()->selectCol('SELECT `mapId` AS ARRAY_KEY, `id` FROM ::zones WHERE `parentArea` = 0 AND (`cuFlags` & %i) = 0', CUSTOM_EXCLUDE_FOR_LISTVIEW);
$this->areaParents = DB::Aowow()->selectCol('SELECT `id` AS ARRAY_KEY, IF(`parentArea`, `parentArea`, `id`) FROM ::zones');
/**************/
@ -109,6 +113,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$time = new Timer(500);
$sum = 0;
$lastOverride = 0;
$insertData = [];
$nSteps = count($this->steps);
$queryResult = $this->$generator();
$queryTotal = count($queryResult);
@ -139,16 +144,28 @@ CLISetup::registerSetup("sql", new class extends SetupScript
continue;
}
$set = array_merge($spawn, $point);
if (!$isWP) // REPLACE: because there is bogus data where one path may be assigned to multiple npcs
[
$insertData['areaId'][],
$insertData['posX'][],
$insertData['posY'][],
$insertData['floor'][]
] = $point; // [areaId, posX, posY, floor]
unset($spawn['map'], $spawn['posX'], $spawn['posY'], $spawn['areaId']);
foreach ($spawn as $k => $v)
$insertData[$k][] = $v;
if (!($sum % 1000) || $sum == $queryTotal)
{
unset($set['map']);
DB::Aowow()->query('REPLACE INTO ?_spawns (?#) VALUES (?a)', array_keys($set), array_values($set));
}
else
{
unset($set['map'], $set['guid']);
DB::Aowow()->query('REPLACE INTO ?_creature_waypoints (?#) VALUES (?a)', array_keys($set), array_values($set));
if (!$isWP) // REPLACE: because there is bogus data where one path may be assigned to multiple npcs
DB::Aowow()->qry('REPLACE INTO ::spawns %m', $insertData);
else
{
unset($insertData['guid']);
DB::Aowow()->qry('REPLACE INTO ::creature_waypoints %m', $insertData);
}
$insertData = [];
}
}
}
@ -161,7 +178,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
if ($todoMask & 0x01) // only when creature is set
{
// get vehicle template accessories
$accessories = DB::World()->select(
$accessories = DB::World()->selectAssoc(
'SELECT vta.`accessory_entry` AS `typeId`, c.`guid`, vta.`entry`, COUNT(1) AS `nSeats` FROM vehicle_template_accessory vta LEFT JOIN creature c ON c.`id` = vta.`entry` GROUP BY `accessory_entry`, c.`guid` UNION
SELECT va.`accessory_entry` AS `typeId`, va.`guid`, 0 AS `entry`, COUNT(1) AS `nSeats` FROM vehicle_accessory va GROUP BY `accessory_entry`, va.`guid`'
);
@ -178,16 +195,16 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
$vehicles = [];
if ($data['guid']) // vehicle already spawned
$vehicles = DB::Aowow()->select('SELECT s.`areaId`, s.`posX`, s.`posY`, s.`floor` FROM ?_spawns s WHERE s.`guid` = ?d AND s.`type` = ?d', $data['guid'], Type::NPC);
$vehicles = DB::Aowow()->selectAssoc('SELECT s.`areaId`, s.`posX`, s.`posY`, s.`floor` FROM ::spawns s WHERE s.`guid` = %i AND s.`type` = %i', $data['guid'], Type::NPC);
else if ($data['entry']) // vehicle on unspawned vehicle action
$vehicles = DB::Aowow()->select('SELECT s.`areaId`, s.`posX`, s.`posY`, s.`floor` FROM ?_spawns s WHERE s.`typeId` = ?d AND s.`type` = ?d', $data['entry'], Type::NPC);
$vehicles = DB::Aowow()->selectAssoc('SELECT s.`areaId`, s.`posX`, s.`posY`, s.`floor` FROM ::spawns s WHERE s.`typeId` = %i AND s.`type` = %i', $data['entry'], Type::NPC);
if ($vehicles)
{
$matches++;
foreach ($vehicles as $v) // if there is more than one vehicle, its probably due to overlapping zones
for ($i = 0; $i < $data['nSeats']; $i++)
DB::Aowow()->query('INSERT INTO ?_spawns (`guid`, `type`, `typeId`, `respawn`, `spawnMask`, `phaseMask`, `areaId`, `floor`, `posX`, `posY`, `pathId`) VALUES (?d, ?d, ?d, 0, 0, 1, ?d, ?d, ?f, ?f, 0)',
DB::Aowow()->qry('INSERT INTO ::spawns (`guid`, `type`, `typeId`, `respawn`, `spawnMask`, `phaseMask`, `areaId`, `floor`, `posX`, `posY`, `pathId`) VALUES (%i, %i, %i, 0, 0, 1, %i, %i, %f, %f, 0)',
--$vGuid, Type::NPC, $data['typeId'], $v['areaId'], $v['floor'], $v['posX'], $v['posY']);
unset($accessories[$idx]);
@ -205,7 +222,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
/* restrict difficulty displays */
/********************************/
DB::Aowow()->query('UPDATE ?_spawns s, dbc_worldmaparea wma, dbc_map m SET s.`spawnMask` = 0 WHERE s.`areaId` = wma.`areaId` AND wma.`mapId` = m.`id` AND m.`areaType` IN (0, 3, 4)');
DB::Aowow()->qry('UPDATE ::spawns s, dbc_worldmaparea wma, dbc_map m SET s.`spawnMask` = 0 WHERE s.`areaId` = wma.`areaId` AND wma.`mapId` = m.`id` AND m.`areaType` IN (0, 3, 4)');
return true;
}
@ -213,8 +230,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
private function creature() : array
{
// [guid, type, typeId, map, posX, posY [, respawn, spawnMask, phaseMask, areaId, floor, pathId, ScriptName, StringId]]
return DB::World()->select(
'SELECT c.`guid`, ?d AS `type`, c.`id` AS `typeId`, c.`map`, c.`position_x` AS `posX`, c.`position_y` AS `posY`, c.`spawntimesecs` AS `respawn`, c.`spawnMask`, c.`phaseMask`, c.`zoneId` AS `areaId`, IFNULL(ca.`path_id`, IFNULL(cta.`path_id`, 0)) AS `pathId`, NULLIF(`ScriptName`, "") AS "ScriptName", NULLIF(`StringId`, "") AS "StringId"
return DB::World()->selectAssoc(
'SELECT c.`guid`, %i AS `type`, c.`id` AS `typeId`, c.`map`, c.`position_x` AS `posX`, c.`position_y` AS `posY`, c.`spawntimesecs` AS `respawn`, c.`spawnMask`, c.`phaseMask`, c.`zoneId` AS `areaId`, IFNULL(ca.`path_id`, IFNULL(cta.`path_id`, 0)) AS `pathId`, NULLIF(`ScriptName`, "") AS "ScriptName", NULLIF(`StringId`, "") AS "StringId"
FROM creature c
LEFT JOIN creature_addon ca ON ca.guid = c.guid
LEFT JOIN creature_template_addon cta ON cta.entry = c.id',
@ -225,8 +242,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
private function gameobject() : array
{
// [guid, type, typeId, map, posX, posY [, respawn, spawnMask, phaseMask, areaId, floor, pathId, ScriptName, StringId]]
return DB::World()->select(
'SELECT `guid`, ?d AS `type`, `id` AS `typeId`, `map`, `position_x` AS `posX`, `position_y` AS `posY`, `spawntimesecs` AS `respawn`, `spawnMask`, `phaseMask`, `zoneId` AS `areaId`, NULLIF(`ScriptName`, "") AS "ScriptName", NULLIF(`StringId`, "") AS "StringId"
return DB::World()->selectAssoc(
'SELECT `guid`, %i AS `type`, `id` AS `typeId`, `map`, `position_x` AS `posX`, `position_y` AS `posY`, `spawntimesecs` AS `respawn`, `spawnMask`, `phaseMask`, `zoneId` AS `areaId`, NULLIF(`ScriptName`, "") AS "ScriptName", NULLIF(`StringId`, "") AS "StringId"
FROM gameobject',
Type::OBJECT
);
@ -235,8 +252,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
private function soundemitter() : array
{
// [guid, type, typeId, map, posX, posY [, respawn, spawnMask, phaseMask, areaId, floor, pathId, ScriptName, StringId]]
return DB::Aowow()->select(
'SELECT `id` AS `guid`, ?d AS `type`, `soundId` AS `typeId`, `mapId` AS `map`, `posX`, `posY`
return DB::Aowow()->selectAssoc(
'SELECT `id` AS `guid`, %i AS `type`, `soundId` AS `typeId`, `mapId` AS `map`, `posX`, `posY`
FROM dbc_soundemitters',
Type::SOUND
);
@ -245,18 +262,18 @@ CLISetup::registerSetup("sql", new class extends SetupScript
private function areatrigger() : array
{
// [guid, type, typeId, map, posX, posY [, respawn, spawnMask, phaseMask, areaId, floor, pathId, ScriptName, StringId]]
$base = DB::Aowow()->select(
'SELECT `id` AS `guid`, ?d AS `type`, `id` AS `typeId`, `mapId` AS `map`, `posX`, `posY`
$base = DB::Aowow()->selectAssoc(
'SELECT `id` AS `guid`, %i AS `type`, `id` AS `typeId`, `mapId` AS `map`, `posX`, `posY`
FROM dbc_areatrigger',
Type::AREATRIGGER
);
$addData = DB::World()->select(
'SELECT -`ID` AS `guid`, ?d AS `type`, ID AS `typeId`, `target_map` AS `map`, `target_position_x` AS `posX`, `target_position_y` AS `posY`
$addData = DB::World()->selectAssoc(
'SELECT -`ID` AS `guid`, %i AS `type`, ID AS `typeId`, `target_map` AS `map`, `target_position_x` AS `posX`, `target_position_y` AS `posY`
FROM areatrigger_teleport UNION
SELECT -`entryorguid` AS `guid`, ?d AS `type`, entryorguid AS `typeId`, `action_param1` AS `map`, `target_x` AS `posX`, `target_y` AS `posY`
SELECT -`entryorguid` AS `guid`, %i AS `type`, entryorguid AS `typeId`, `action_param1` AS `map`, `target_x` AS `posX`, `target_y` AS `posY`
FROM smart_scripts
WHERE `source_type` = ?d AND `action_type` = ?d',
WHERE `source_type` = %i AND `action_type` = %i',
Type::AREATRIGGER, Type::AREATRIGGER, SmartAI::SRC_TYPE_AREATRIGGER, SmartAction::ACTION_TELEPORT
);
@ -266,10 +283,10 @@ CLISetup::registerSetup("sql", new class extends SetupScript
private function instances() : array
{
// maps with set graveyard
return DB::Aowow()->select(
'SELECT -`id` AS `guid`, ?d AS `type`, `id` AS `typeId`, `parentMapId` AS `map`, `parentX` AS `posX`, `parentY` AS `posY`
FROM ?_zones
WHERE `parentX` <> 0 AND `parentY` <> 0 AND `parentArea` = 0 AND (`cuFlags` & ?d) = 0',
return DB::Aowow()->selectAssoc(
'SELECT -`id` AS `guid`, %i AS `type`, `id` AS `typeId`, `parentMapId` AS `map`, `parentX` AS `posX`, `parentY` AS `posY`
FROM ::zones
WHERE `parentX` <> 0 AND `parentY` <> 0 AND `parentArea` = 0 AND (`cuFlags` & %i) = 0',
Type::ZONE, CUSTOM_EXCLUDE_FOR_LISTVIEW
);
}
@ -280,7 +297,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
// in the future guid should be optional and additional parameters substituting guid should be passed down from NpcPage after SmartAI has been evaluated
// assume that creature_template_addon data isn't stupid and only creatures with a single spawn are referenced here
return DB::World()->select(
return DB::World()->selectAssoc(
'SELECT c.`guid`, -w.`id` AS `creatureOrPath`, w.`point`, c.`zoneId` AS `areaId`, c.`map`, w.`delay` AS `wait`, w.`position_x` AS `posX`, w.`position_y` AS `posY`
FROM creature c
JOIN creature_addon ca ON ca.`guid` = c.`guid`
@ -294,7 +311,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
);
}
private function transformPoint(array $point, int $type, ?string &$notice = '') : array
private function transformPoint(array $point, int $type, ?string &$notice = '') : ?array
{
// npc/object is on a transport -> apply offsets to path of transport
// note, that transport DO spawn outside of displayable area maps .. another todo i guess..
@ -318,22 +335,21 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
// if areaId is set and we match it .. we're fine .. mostly
if (count($points) == 1 && $area == $points[0]['areaId'])
return ['areaId' => $points[0]['areaId'], 'posX' => $points[0]['posX'], 'posY' => $points[0]['posY'], 'floor' => $points[0]['floor']];
return [$points[0]['areaId'], $points[0]['posX'], $points[0]['posY'], $points[0]['floor']];
$point = WorldPosition::checkZonePos($points); // try to determine best found point by alphamap
return ['areaId' => $point['areaId'], 'posX' => $point['posX'], 'posY' => $point['posY'], 'floor' => $point['floor']];
return [$point['areaId'], $point['posX'], $point['posY'], $point['floor']];
}
// cannot be placed on a map, try to reuse TC assigned areaId (note: area has been invalid in the past)
if ($area && ($selfOrParent = DB::Aowow()->selectCell('SELECT IF(`parentArea`, `parentArea`, `id`) FROM ?_zones WHERE `id` = ?d', $area)))
return ['areaId' => $selfOrParent, 'posX' => 0, 'posY' => 0, 'floor' => 0];
if ($area && isset($this->areaParents[$area]))
return [$this->areaParents[$area], 0, 0, 0];
// we know the instanced map; try to assign a zone this way
if (!in_array($point['map'], [0, 1, 530, 571]))
if ($area = DB::Aowow()->selectCell('SELECT `id` FROM ?_zones WHERE `mapId` = ?d AND `parentArea` = 0 AND (`cuFlags` & ?d) = 0', $point['map'], CUSTOM_EXCLUDE_FOR_LISTVIEW))
return ['areaId' => $area, 'posX' => 0, 'posY' => 0, 'floor' => 0];
if (!in_array($point['map'], [0, 1, 530, 571]) && isset($this->mapToArea[$point['map']]))
return [$this->mapToArea[$point['map']], 0, 0, 0];
return [];
return null;
}
});

View file

@ -21,14 +21,14 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $worldDependency = ['item_template', 'creature_template', 'creature_template_addon', 'creature_template_spell', 'smart_scripts', 'trainer_spell', 'disables', 'spell_ranks', 'spell_dbc', 'skill_discovery_template'];
protected $setupAfter = [['icons', 'spellrange'], []]; // spellrange required to use SpellList
public function generate(array $ids = []) : bool
public function generate() : bool
{
$ssQuery = 'SELECT id,
0 AS category,
Dispel,
Mechanic,
Attributes, AttributesEx, AttributesEx2, AttributesEx3, AttributesEx4, AttributesEx5, AttributesEx6, AttributesEx7,
?d AS cuFlags,
%i AS cuFlags,
0 AS typeCat,
Stances, StancesNot,
Targets,
@ -105,7 +105,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
0 AS spellDescriptionVariable,
0 AS trainingCost
FROM spell_dbc
LIMIT ?d,?d';
LIMIT %i,%i';
$baseQry = 'SELECT s.id,
category,
@ -195,17 +195,17 @@ CLISetup::registerSetup("sql", new class extends SetupScript
LEFT JOIN dbc_spellradius sr1 ON s.effect1RadiusId = sr1.id
LEFT JOIN dbc_spellradius sr2 ON s.effect2RadiusId = sr2.id
LEFT JOIN dbc_spellradius sr3 ON s.effect3RadiusId = sr3.id
LIMIT ?d,?d';
LIMIT %i,%i';
DB::Aowow()->query('TRUNCATE ?_spell');
DB::Aowow()->query('SET SESSION innodb_ft_enable_stopword = OFF');
DB::Aowow()->qry('TRUNCATE ::spell');
DB::Aowow()->qry('SET SESSION innodb_ft_enable_stopword = OFF');
// merge serverside spells into aowow_spell
$lastMax = 0;
$n = 0;
CLI::write('[spell] - copying serverside spells into aowow_spell');
while ($spells = DB::World()->select($ssQuery, CUSTOM_SERVERSIDE, $n++ * CLISetup::SQL_BATCH, CLISetup::SQL_BATCH))
while ($spells = DB::World()->selectAssoc($ssQuery, CUSTOM_SERVERSIDE, $n++ * CLISetup::SQL_BATCH, CLISetup::SQL_BATCH))
{
$newMax = max(array_column($spells, 'id'));
@ -214,21 +214,21 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$lastMax = $newMax;
foreach ($spells as $spell)
DB::Aowow()->query('INSERT INTO ?_spell VALUES (?a)', array_values($spell));
DB::Aowow()->qry('INSERT INTO ::spell VALUES %l', $spell);
}
// apply spell radii, duration & casting time
DB::Aowow()->query('UPDATE ?_spell s LEFT JOIN dbc_spellradius sr ON s.`effect1RadiusMin` = sr.`id` SET s.`effect1RadiusMin` = IFNULL(sr.`radiusMin`, 0), s.`effect1RadiusMax` = IFNULL(sr.`radiusMax`, 0)');
DB::Aowow()->query('UPDATE ?_spell s LEFT JOIN dbc_spellradius sr ON s.`effect2RadiusMin` = sr.`id` SET s.`effect2RadiusMin` = IFNULL(sr.`radiusMin`, 0), s.`effect2RadiusMax` = IFNULL(sr.`radiusMax`, 0)');
DB::Aowow()->query('UPDATE ?_spell s LEFT JOIN dbc_spellradius sr ON s.`effect3RadiusMin` = sr.`id` SET s.`effect3RadiusMin` = IFNULL(sr.`radiusMin`, 0), s.`effect3RadiusMax` = IFNULL(sr.`radiusMax`, 0)');
DB::Aowow()->query('UPDATE ?_spell s LEFT JOIN dbc_spellduration sd ON s.`duration` = sd.`id` SET s.`duration` = IF(sd.`baseTime` iS NULL, -1, IF(sd.`baseTime` <> -1, ABS(sd.`baseTime`), -1))');
DB::Aowow()->query('UPDATE ?_spell s LEFT JOIN dbc_spellcasttimes sct ON s.`castTime` = sct.`id` SET s.`castTime` = GREATEST(IFNULL(sct.`baseTime`, 0), 0) / 1000');
DB::Aowow()->qry('UPDATE ::spell s LEFT JOIN dbc_spellradius sr ON s.`effect1RadiusMin` = sr.`id` SET s.`effect1RadiusMin` = IFNULL(sr.`radiusMin`, 0), s.`effect1RadiusMax` = IFNULL(sr.`radiusMax`, 0)');
DB::Aowow()->qry('UPDATE ::spell s LEFT JOIN dbc_spellradius sr ON s.`effect2RadiusMin` = sr.`id` SET s.`effect2RadiusMin` = IFNULL(sr.`radiusMin`, 0), s.`effect2RadiusMax` = IFNULL(sr.`radiusMax`, 0)');
DB::Aowow()->qry('UPDATE ::spell s LEFT JOIN dbc_spellradius sr ON s.`effect3RadiusMin` = sr.`id` SET s.`effect3RadiusMin` = IFNULL(sr.`radiusMin`, 0), s.`effect3RadiusMax` = IFNULL(sr.`radiusMax`, 0)');
DB::Aowow()->qry('UPDATE ::spell s LEFT JOIN dbc_spellduration sd ON s.`duration` = sd.`id` SET s.`duration` = IF(sd.`baseTime` iS NULL, -1, IF(sd.`baseTime` <> -1, ABS(sd.`baseTime`), -1))');
DB::Aowow()->qry('UPDATE ::spell s LEFT JOIN dbc_spellcasttimes sct ON s.`castTime` = sct.`id` SET s.`castTime` = GREATEST(IFNULL(sct.`baseTime`, 0), 0) / 1000');
// merge spell.dbc into aowow_spell
$lastMax = 0;
$n = 0;
CLI::write('[spell] - merging spell.dbc into aowow_spell');
while ($spells = DB::Aowow()->select($baseQry, $n++ * CLISetup::SQL_BATCH, CLISetup::SQL_BATCH))
while ($spells = DB::Aowow()->selectAssoc($baseQry, $n++ * CLISetup::SQL_BATCH, CLISetup::SQL_BATCH))
{
$newMax = max(array_column($spells, 'id'));
@ -237,26 +237,26 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$lastMax = $newMax;
foreach ($spells as $spell)
DB::Aowow()->query('INSERT INTO ?_spell VALUES (?a)', array_values($spell));
DB::Aowow()->qry('INSERT INTO ::spell VALUES %l', $spell);
}
// apply flag: CUSTOM_DISABLED [0xD: players (0x1), pets (0x4), general (0x8); only generally disabled spells]
if ($disables = DB::World()->selectCol('SELECT `entry` FROM disables WHERE `sourceType` = 0 AND `params_0` = "" AND `params_1` = "" AND `flags` & 0xD'))
DB::Aowow()->query('UPDATE ?_spell SET `cuFlags` = `cuFlags` | ?d WHERE `id` IN (?a)', CUSTOM_DISABLED, $disables);
DB::Aowow()->qry('UPDATE ::spell SET `cuFlags` = `cuFlags` | %i WHERE `id` IN %in', CUSTOM_DISABLED, $disables);
// apply spell ranks (can't use skilllineability.dbc, as it does not contain ranks for non-player/pet spells)
$ranks = DB::World()->selectCol('SELECT `first_spell_id` AS ARRAY_KEY, `spell_id` AS ARRAY_KEY2, `rank` FROM spell_ranks');
foreach ($ranks as $firstSpell => $sets)
{
// apply flag: SPELL_CU_FIRST_RANK
DB::Aowow()->query('UPDATE ?_spell SET `cuFlags` = `cuFlags` | ?d WHERE `id` = ?d', SPELL_CU_FIRST_RANK, $firstSpell);
DB::Aowow()->qry('UPDATE ::spell SET `cuFlags` = `cuFlags` | %i WHERE `id` = %i', SPELL_CU_FIRST_RANK, $firstSpell);
foreach ($sets as $spell => $rank)
DB::Aowow()->query('UPDATE ?_spell SET `rankNo` = ?d WHERE `id` = ?d', $rank, $spell);
DB::Aowow()->qry('UPDATE ::spell SET `rankNo` = %i WHERE `id` = %i', $rank, $spell);
// apply flag: SPELL_CU_LAST_RANK
end($sets);
DB::Aowow()->query('UPDATE ?_spell SET `cuFlags` = `cuFlags` | ?d WHERE `id` = ?d', SPELL_CU_LAST_RANK, key($sets));
DB::Aowow()->qry('UPDATE ::spell SET `cuFlags` = `cuFlags` | %i WHERE `id` = %i', SPELL_CU_LAST_RANK, key($sets));
}
@ -271,7 +271,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CLI::write('[spell] - linking with skilllineability');
$results = DB::Aowow()->select('SELECT `spellId` AS ARRAY_KEY, `id` AS ARRAY_KEY2, `skillLineId`, `reqRaceMask`, `reqClassMask`, `reqSkillLevel`, `acquireMethod`, `skillLevelGrey`, `skillLevelYellow` FROM dbc_skilllineability sla');
$results = DB::Aowow()->selectAssoc('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)
{
$names = array_keys(current($sets));
@ -320,7 +320,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
}
if ($trainer)
DB::Aowow()->query('UPDATE ?_spell SET `learnedAt` = 1 WHERE `id` = ?d', $spellId);
DB::Aowow()->qry('UPDATE ::spell SET `learnedAt` = 1 WHERE `id` = %i', $spellId);
// check skillLineId against mask
switch (count($lines))
@ -344,13 +344,13 @@ CLISetup::registerSetup("sql", new class extends SetupScript
}
}
DB::Aowow()->query('UPDATE ?_spell SET ?a WHERE `id` = ?d', $update, $spellId);
DB::Aowow()->qry('UPDATE ::spell SET %a WHERE `id` = %i', $update, $spellId);
}
// fill learnedAt, trainingCost from trainer
if ($trainer = DB::World()->select('SELECT `spellID` AS ARRAY_KEY, MIN(`ReqSkillRank`) AS `reqSkill`, MIN(`MoneyCost`) AS `cost`, `ReqAbility1` AS `reqSpellId`, COUNT(*) AS `count` FROM trainer_spell GROUP BY `SpellID`'))
if ($trainer = DB::World()->selectAssoc('SELECT `spellID` AS ARRAY_KEY, MIN(`ReqSkillRank`) AS `reqSkill`, MIN(`MoneyCost`) AS `cost`, `ReqAbility1` AS `reqSpellId`, COUNT(*) AS `count` FROM trainer_spell GROUP BY `SpellID`'))
{
$spells = DB::Aowow()->select('SELECT `id` AS ARRAY_KEY, `effect1Id`, `effect2Id`, `effect3Id`, `effect1TriggerSpell`, `effect2TriggerSpell`, `effect3TriggerSpell` FROM dbc_spell WHERE `id` IN (?a)', array_keys($trainer));
$spells = DB::Aowow()->selectAssoc('SELECT `id` AS ARRAY_KEY, `effect1Id`, `effect2Id`, `effect3Id`, `effect1TriggerSpell`, `effect2TriggerSpell`, `effect3TriggerSpell` FROM dbc_spell WHERE `id` IN %in', array_keys($trainer));
$links = [];
// todo (med): this skips some spells (e.g. riding)
@ -397,14 +397,14 @@ CLISetup::registerSetup("sql", new class extends SetupScript
}
foreach ($links as $spell => $link)
DB::Aowow()->query("UPDATE ?_spell s SET s.`learnedAt` = ?d, s.`trainingCost` = ?d WHERE s.`id` = ?d", $link[0], $link[1], $spell);
DB::Aowow()->qry("UPDATE ::spell s SET s.`learnedAt` = %i, s.`trainingCost` = %i WHERE s.`id` = %i", $link[0], $link[1], $spell);
}
// fill learnedAt from recipe-items
$recipes = DB::World()->selectCol('SELECT IF(`spelltrigger_2` = ?d, `spellid_2`, `spellid_1`) AS ARRAY_KEY, MIN(`RequiredSkillRank`) FROM item_template WHERE `class` = ?d AND `spelltrigger_1` <> ?d AND `RequiredSkillRank` > 0 GROUP BY ARRAY_KEY',
$recipes = DB::World()->selectCol('SELECT IF(`spelltrigger_2` = %i, `spellid_2`, `spellid_1`) AS ARRAY_KEY, MIN(`RequiredSkillRank`) FROM item_template WHERE `class` = %i AND `spelltrigger_1` <> %i AND `RequiredSkillRank` > 0 GROUP BY ARRAY_KEY',
SPELL_TRIGGER_LEARN, ITEM_CLASS_RECIPE, SPELL_TRIGGER_EQUIP);
foreach ($recipes as $spell => $reqSkill)
DB::Aowow()->query('UPDATE ?_spell SET `learnedAt` = IF(`learnedAt` = 0 OR `learnedAt` > ?d, ?d, `learnedAt`) WHERE `id` = ?d', $reqSkill, $reqSkill, $spell);
DB::Aowow()->qry('UPDATE ::spell SET `learnedAt` = IF(`learnedAt` = 0 OR `learnedAt` > %i, %i, `learnedAt`) WHERE `id` = %i', $reqSkill, $reqSkill, $spell);
// fill learnedAt from Discovery
// 61756: Northrend Inscription Research (FAST QA VERSION);
@ -412,20 +412,20 @@ CLISetup::registerSetup("sql", new class extends SetupScript
// 28571 - 28576: $element Protection Potion (todo: get reqSkill from teaching spell [360])
$discovery = DB::World()->selectCol(
'SELECT `spellId` AS ARRAY_KEY,
IF(`reqSpell` = ?d, ?d,
IF(`reqSpell` BETWEEN ?d AND ?d, ?d,
IF(`reqSpell` = %i, %i,
IF(`reqSpell` BETWEEN %i AND %i, %i,
IF(`reqSkillValue`, `reqSkillValue`, 1)))
FROM skill_discovery_template
WHERE `reqSpell` NOT IN (?a)',
WHERE `reqSpell` NOT IN %in',
64323, 425, 28571, 28576, 360, [61756]
);
foreach ($discovery as $spell => $reqSkill)
DB::Aowow()->query('UPDATE ?_spell SET `learnedAt` = ?d WHERE `id` = ?d', $reqSkill, $spell);
DB::Aowow()->qry('UPDATE ::spell SET `learnedAt` = %i WHERE `id` = %i', $reqSkill, $spell);
// calc reqSkill for gathering-passives (herbing, mining, skinning) (on second thought .. it is set in skilllineability >.<)
$sets = DB::World()->selectCol('SELECT `spell_id` AS ARRAY_KEY, `rank` * 75 AS `reqSkill` FROM spell_ranks WHERE `first_spell_id` IN (?a)', [55428, 53120, 53125]);
$sets = DB::World()->selectCol('SELECT `spell_id` AS ARRAY_KEY, `rank` * 75 AS `reqSkill` FROM spell_ranks WHERE `first_spell_id` IN %in', [55428, 53120, 53125]);
foreach ($sets as $spell => $reqSkill)
DB::Aowow()->query('UPDATE ?_spell SET `learnedAt` = ?d WHERE `id` = ?d', $reqSkill, $spell);
DB::Aowow()->qry('UPDATE ::spell SET `learnedAt` = %i WHERE `id` = %i', $reqSkill, $spell);
/******************/
@ -437,16 +437,16 @@ CLISetup::registerSetup("sql", new class extends SetupScript
for ($i = 1; $i < 6; $i++)
{
// classMask
DB::Aowow()->query('UPDATE ?_spell s, dbc_talent t, dbc_talenttab tt SET s.`reqClassMask` = tt.`classMask` WHERE tt.`creatureFamilyMask` = 0 AND tt.`id` = t.`tabId` AND t.?# = s.`id`', 'rank'.$i);
DB::Aowow()->qry('UPDATE ::spell s, dbc_talent t, dbc_talenttab tt SET s.`reqClassMask` = tt.`classMask` WHERE tt.`creatureFamilyMask` = 0 AND tt.`id` = t.`tabId` AND t.%n = s.`id`', 'rank'.$i);
// talentLevel
DB::Aowow()->query('UPDATE ?_spell s, dbc_talent t, dbc_talenttab tt SET s.`talentLevel` = (t.`row` * 5) + 10 + (?d * 1) WHERE tt.`id` = t.`tabId` AND tt.`creatureFamilyMask` = 0 AND t.?# = s.`id`', $i - 1, 'rank'.$i);
DB::Aowow()->query('UPDATE ?_spell s, dbc_talent t, dbc_talenttab tt SET s.`talentLevel` = (t.`row` * 12) + 20 + (?d * 4) WHERE tt.`id` = t.`tabId` AND tt.`creatureFamilyMask` <> 0 AND t.?# = s.`id`', $i - 1, 'rank'.$i);
DB::Aowow()->qry('UPDATE ::spell s, dbc_talent t, dbc_talenttab tt SET s.`talentLevel` = (t.`row` * 5) + 10 + (%i * 1) WHERE tt.`id` = t.`tabId` AND tt.`creatureFamilyMask` = 0 AND t.%n = s.`id`', $i - 1, 'rank'.$i);
DB::Aowow()->qry('UPDATE ::spell s, dbc_talent t, dbc_talenttab tt SET s.`talentLevel` = (t.`row` * 12) + 20 + (%i * 4) WHERE tt.`id` = t.`tabId` AND tt.`creatureFamilyMask` <> 0 AND t.%n = s.`id`', $i - 1, 'rank'.$i);
}
// passive talent
DB::Aowow()->query('UPDATE ?_spell s, dbc_talent t SET s.`cuFlags` = s.`cuFlags` | ?d WHERE t.`talentSpell` = 0 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`)', SPELL_CU_TALENT);
DB::Aowow()->qry('UPDATE ::spell s, dbc_talent t SET s.`cuFlags` = s.`cuFlags` | %i WHERE t.`talentSpell` = 0 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`)', SPELL_CU_TALENT);
// spell taught by talent
DB::Aowow()->query('UPDATE ?_spell s, dbc_talent t SET s.`cuFlags` = s.`cuFlags` | ?d WHERE t.`talentSpell` = 1 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`)', SPELL_CU_TALENTSPELL);
DB::Aowow()->qry('UPDATE ::spell s, dbc_talent t SET s.`cuFlags` = s.`cuFlags` | %i WHERE t.`talentSpell` = 1 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`)', SPELL_CU_TALENTSPELL);
/*********/
@ -456,17 +456,17 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CLI::write('[spell] - misc fixups & icons');
// FU [FixUps]
DB::Aowow()->query('UPDATE ?_spell SET `reqRaceMask` = ?d WHERE `skillLine1` = ?d', ChrRace::DRAENEI->toMask(), 760); // Draenei Racials
DB::Aowow()->query('UPDATE ?_spell SET `reqRaceMask` = ?d WHERE `skillLine1` = ?d', ChrRace::BLOODELF->toMask(), 756); // Bloodelf Racials
DB::Aowow()->query('UPDATE ?_spell SET `reqClassMask` = ?d WHERE `id` = ?d', ChrClass::MAGE->toMask(), 30449); // Mage - Spellsteal
DB::Aowow()->qry('UPDATE ::spell SET `reqRaceMask` = %i WHERE `skillLine1` = %i', ChrRace::DRAENEI->toMask(), 760); // Draenei Racials
DB::Aowow()->qry('UPDATE ::spell SET `reqRaceMask` = %i WHERE `skillLine1` = %i', ChrRace::BLOODELF->toMask(), 756); // Bloodelf Racials
DB::Aowow()->qry('UPDATE ::spell SET `reqClassMask` = %i WHERE `id` = %i', ChrClass::MAGE->toMask(), 30449); // Mage - Spellsteal
// triggered by spell
DB::Aowow()->query(
'UPDATE ?_spell a
JOIN ( SELECT effect1TriggerSpell as id FROM ?_spell WHERE effect1Id NOT IN (36, 57, 133) AND effect1TriggerSpell <> 0 UNION
SELECT effect2TriggerSpell as id FROM ?_spell WHERE effect2Id NOT IN (36, 57, 133) AND effect2TriggerSpell <> 0 UNION
SELECT effect3TriggerSpell as id FROM ?_spell WHERE effect3Id NOT IN (36, 57, 133) AND effect3TriggerSpell <> 0 ) as b
SET cuFlags = cuFlags | ?d
DB::Aowow()->qry(
'UPDATE ::spell a
JOIN ( SELECT effect1TriggerSpell as id FROM ::spell WHERE effect1Id NOT IN (36, 57, 133) AND effect1TriggerSpell <> 0 UNION
SELECT effect2TriggerSpell as id FROM ::spell WHERE effect2Id NOT IN (36, 57, 133) AND effect2TriggerSpell <> 0 UNION
SELECT effect3TriggerSpell as id FROM ::spell WHERE effect3Id NOT IN (36, 57, 133) AND effect3TriggerSpell <> 0 ) as b
SET cuFlags = cuFlags | %i
WHERE a.id = b.id',
SPELL_CU_TRIGGERED);
@ -477,41 +477,41 @@ CLISetup::registerSetup("sql", new class extends SetupScript
LEFT JOIN dbc_talent t1 ON t1.rank1 = s.id
LEFT JOIN dbc_talent t2 ON t2.rank2 = s.id
LEFT JOIN dbc_talent t3 ON t3.rank3 = s.id
WHERE effect1CreateItemId > 0 AND (effect1Id in (?a) OR effect1AuraId in (?a)) AND t1.id IS NULL AND t2.id IS NULL AND t3.id IS NULL
WHERE effect1CreateItemId > 0 AND (effect1Id IN %in OR effect1AuraId IN %in) AND t1.id IS NULL AND t2.id IS NULL AND t3.id IS NULL
UNION
SELECT s.id AS ARRAY_KEY, effect2CreateItemId
FROM dbc_spell s
LEFT JOIN dbc_talent t1 ON t1.rank1 = s.id
LEFT JOIN dbc_talent t2 ON t2.rank2 = s.id
LEFT JOIN dbc_talent t3 ON t3.rank3 = s.id
WHERE effect2CreateItemId > 0 AND (effect2Id in (?a) OR effect2AuraId in (?a)) AND t1.id IS NULL AND t2.id IS NULL AND t3.id IS NULL
WHERE effect2CreateItemId > 0 AND (effect2Id IN %in OR effect2AuraId IN %in) AND t1.id IS NULL AND t2.id IS NULL AND t3.id IS NULL
UNION
SELECT s.id AS ARRAY_KEY, effect3CreateItemId
FROM dbc_spell s
LEFT JOIN dbc_talent t1 ON t1.rank1 = s.id
LEFT JOIN dbc_talent t2 ON t2.rank2 = s.id
LEFT JOIN dbc_talent t3 ON t3.rank3 = s.id
WHERE effect3CreateItemId > 0 AND (effect3Id in (?a) OR effect3AuraId in (?a)) AND t1.id IS NULL AND t2.id IS NULL AND t3.id IS NULL',
WHERE effect3CreateItemId > 0 AND (effect3Id IN %in OR effect3AuraId IN %in) AND t1.id IS NULL AND t2.id IS NULL AND t3.id IS NULL',
SpellList::EFFECTS_ITEM_CREATE, SpellList::AURAS_ITEM_CREATE,
SpellList::EFFECTS_ITEM_CREATE, SpellList::AURAS_ITEM_CREATE,
SpellList::EFFECTS_ITEM_CREATE, SpellList::AURAS_ITEM_CREATE);
$itemInfo = DB::World()->select('SELECT entry AS ARRAY_KEY, displayId AS d, Quality AS q FROM item_template WHERE entry IN (?a)', $itemSpells);
$itemInfo = DB::World()->selectAssoc('SELECT entry AS ARRAY_KEY, displayId AS d, Quality AS q FROM item_template WHERE entry IN %in', $itemSpells);
foreach ($itemSpells as $sId => $itemId)
if (isset($itemInfo[$itemId]))
DB::Aowow()->query('UPDATE ?_spell s, ?_icons ic, dbc_itemdisplayinfo idi SET s.iconIdAlt = ic.id, s.cuFlags = s.cuFlags | ?d WHERE ic.name_source = LOWER(idi.inventoryIcon1) AND idi.id = ?d AND s.id = ?d', ((7 - $itemInfo[$itemId]['q']) << 8), $itemInfo[$itemId]['d'], $sId);
DB::Aowow()->qry('UPDATE ::spell s, ::icons ic, dbc_itemdisplayinfo idi SET s.iconIdAlt = ic.id, s.cuFlags = s.cuFlags | %i WHERE ic.name_source = LOWER(idi.inventoryIcon1) AND idi.id = %i AND s.id = %i', ((7 - $itemInfo[$itemId]['q']) << 8), $itemInfo[$itemId]['d'], $sId);
$itemReqs = DB::World()->selectCol('SELECT entry AS ARRAY_KEY, requiredSpell FROM item_template WHERE requiredSpell NOT IN (?a)', [0, 34090, 34091]); // not riding
$itemReqs = DB::World()->selectCol('SELECT entry AS ARRAY_KEY, requiredSpell FROM item_template WHERE requiredSpell NOT IN %in', [0, 34090, 34091]); // not riding
foreach ($itemReqs AS $itemId => $req)
DB::Aowow()->query('UPDATE ?_spell SET reqSpellId = ?d WHERE skillLine1 IN (?a) AND effect1CreateItemId = ?d', $req, [SKILL_BLACKSMITHING, SKILL_LEATHERWORKING, SKILL_TAILORING, SKILL_ENGINEERING], $itemId);
DB::Aowow()->qry('UPDATE ::spell SET reqSpellId = %i WHERE skillLine1 IN %in AND effect1CreateItemId = %i', $req, [SKILL_BLACKSMITHING, SKILL_LEATHERWORKING, SKILL_TAILORING, SKILL_ENGINEERING], $itemId);
// setting icons
DB::Aowow()->query('UPDATE ?_spell s, ?_icons ic, dbc_spellicon si SET s.iconId = ic.id WHERE s.iconIdBak = si.id AND ic.name_source = LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1))');
DB::Aowow()->qry('UPDATE ::spell s, ::icons ic, dbc_spellicon si SET s.`iconId` = ic.`id` WHERE s.`iconIdBak` = si.`id` AND ic.`name_source` = LOWER(SUBSTRING_INDEX(si.`iconPath`, "\\", -1))');
// hide internal stuff from listviews
// QA*; *DND*; square brackets anything; *(NYI)*; *(TEST)*
// cant catch raw: NYI (uNYIelding); PH (PHasing)
DB::Aowow()->query('UPDATE ?_spell SET cuFlags = cuFlags | ?d WHERE name_loc0 LIKE "QA%" OR name_loc0 LIKE "%DND%" OR name_loc0 LIKE "%[%" OR name_loc0 LIKE "%(NYI)%" OR name_loc0 LIKE "%(TEST)%"', CUSTOM_EXCLUDE_FOR_LISTVIEW);
DB::Aowow()->qry('UPDATE ::spell SET cuFlags = cuFlags | %i WHERE name_loc0 LIKE "QA%" OR name_loc0 LIKE "%DND%" OR name_loc0 LIKE "%[%" OR name_loc0 LIKE "%(NYI)%" OR name_loc0 LIKE "%(TEST)%"', CUSTOM_EXCLUDE_FOR_LISTVIEW);
/**************/
@ -521,10 +521,10 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CLI::write('[spell] - 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)');
DB::Aowow()->qry('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)');
// pet spells (-3)
DB::Aowow()->query('UPDATE ?_spell s SET s.typeCat = -3 WHERE (s.cuFlags & 0x3) = 0 AND s.skillline1 IN (?a)',
DB::Aowow()->qry('UPDATE ::spell s SET s.typeCat = -3 WHERE (s.cuFlags & 0x3) = 0 AND s.skillline1 IN %in',
array_merge(
array_column(Game::$skillLineMask[-1], 1), // hunter pets
array_column(Game::$skillLineMask[-2], 1), // warlock pets
@ -534,22 +534,22 @@ CLISetup::registerSetup("sql", new class extends SetupScript
);
// racials (-4)
DB::Aowow()->query('UPDATE ?_spell s SET s.typeCat = -4 WHERE s.skillLine1 IN (101, 124, 125, 126, 220, 733, 753, 754, 756, 760)');
DB::Aowow()->qry('UPDATE ::spell s SET s.typeCat = -4 WHERE s.skillLine1 IN (101, 124, 125, 126, 220, 733, 753, 754, 756, 760)');
// mounts (-5)
DB::Aowow()->query('UPDATE ?_spell s SET s.typeCat = -5 WHERE s.effect1AuraId = 78 AND (s.skillLine1 IN (354, 594, 772, 777) OR (s.skillLine1 > 0 AND s.skillLine2OrMask = 777))');
DB::Aowow()->qry('UPDATE ::spell s SET s.typeCat = -5 WHERE s.effect1AuraId = 78 AND (s.skillLine1 IN (354, 594, 772, 777) OR (s.skillLine1 > 0 AND s.skillLine2OrMask = 777))');
// companions (-6)
DB::Aowow()->query('UPDATE ?_spell s SET s.typeCat = -6 WHERE s.skillLine1 = 778');
DB::Aowow()->qry('UPDATE ::spell s SET s.typeCat = -6 WHERE s.skillLine1 = 778');
// pet talents (-7)
DB::Aowow()->query('UPDATE ?_spell s, dbc_talent t SET s.typeCat = -7, s.cuFlags = s.cuFlags | 0x10 WHERE t.tabId = 409 AND (s.id = t.rank1 OR s.id = t.rank2 OR s.id = t.rank3)');
DB::Aowow()->query('UPDATE ?_spell s, dbc_talent t SET s.typeCat = -7, s.cuFlags = s.cuFlags | 0x08 WHERE t.tabId = 410 AND (s.id = t.rank1 OR s.id = t.rank2 OR s.id = t.rank3)');
DB::Aowow()->query('UPDATE ?_spell s, dbc_talent t SET s.typeCat = -7, s.cuFlags = s.cuFlags | 0x20 WHERE t.tabId = 411 AND (s.id = t.rank1 OR s.id = t.rank2 OR s.id = t.rank3)');
DB::Aowow()->qry('UPDATE ::spell s, dbc_talent t SET s.typeCat = -7, s.cuFlags = s.cuFlags | 0x10 WHERE t.tabId = 409 AND (s.id = t.rank1 OR s.id = t.rank2 OR s.id = t.rank3)');
DB::Aowow()->qry('UPDATE ::spell s, dbc_talent t SET s.typeCat = -7, s.cuFlags = s.cuFlags | 0x08 WHERE t.tabId = 410 AND (s.id = t.rank1 OR s.id = t.rank2 OR s.id = t.rank3)');
DB::Aowow()->qry('UPDATE ::spell s, dbc_talent t SET s.typeCat = -7, s.cuFlags = s.cuFlags | 0x20 WHERE t.tabId = 411 AND (s.id = t.rank1 OR s.id = t.rank2 OR s.id = t.rank3)');
// internal (-9) by faaaaaar not complete
DB::Aowow()->query('UPDATE ?_spell s SET s.typeCat = -9 WHERE s.skillLine1 = 769');
DB::Aowow()->query('UPDATE ?_spell s SET s.typeCat = -9 WHERE s.typeCat = 0 AND s.cuFlags = 0 AND (
DB::Aowow()->qry('UPDATE ::spell s SET s.typeCat = -9 WHERE s.skillLine1 = 769');
DB::Aowow()->qry('UPDATE ::spell s SET s.typeCat = -9 WHERE s.typeCat = 0 AND s.cuFlags = 0 AND (
s.name_loc0 LIKE "%qa%" OR
s.name_loc0 LIKE "%debug%" OR
s.name_loc0 LIKE "%internal%" OR
@ -559,48 +559,48 @@ CLISetup::registerSetup("sql", new class extends SetupScript
);
// proficiencies (-11)
DB::Aowow()->query('UPDATE ?_spell s, dbc_skillline sl SET s.typeCat = -11 WHERE s.skillLine1 = sl.id AND sl.categoryId IN (6, 8, 10)');
DB::Aowow()->qry('UPDATE ::spell s, dbc_skillline sl SET s.typeCat = -11 WHERE s.skillLine1 = sl.id AND sl.categoryId IN (6, 8, 10)');
// glyphs (-13)
DB::Aowow()->query('UPDATE ?_spell s, dbc_glyphproperties gp SET s.cuFlags = s.cuFlags | IF(gp.typeFlags, ?d, ?d), s.typeCat = -13 WHERE gp.typeFlags IN (0, 1) AND gp.id = s.effect1MiscValue AND s.effect1Id = 74', SPELL_CU_GLYPH_MINOR, SPELL_CU_GLYPH_MAJOR);
DB::Aowow()->qry('UPDATE ::spell s, dbc_glyphproperties gp SET s.cuFlags = s.cuFlags | IF(gp.typeFlags, %i, %i), s.typeCat = -13 WHERE gp.typeFlags IN (0, 1) AND gp.id = s.effect1MiscValue AND s.effect1Id = 74', SPELL_CU_GLYPH_MINOR, SPELL_CU_GLYPH_MAJOR);
$glyphs = DB::World()->selectCol('SELECT it.spellid_1 AS ARRAY_KEY, it.AllowableClass FROM item_template it WHERE it.class = 16');
foreach ($glyphs as $spell => $classMask)
DB::Aowow()->query('UPDATE ?_spell s, dbc_glyphproperties gp SET s.reqClassMask = ?d WHERE gp.typeFlags IN (0, 1) AND gp.id = s.effect1MiscValue AND s.effect1Id = 74 AND s.id = ?d', $classMask, $spell);
DB::Aowow()->qry('UPDATE ::spell s, dbc_glyphproperties gp SET s.reqClassMask = %i WHERE gp.typeFlags IN (0, 1) AND gp.id = s.effect1MiscValue AND s.effect1Id = 74 AND s.id = %i', $classMask, $spell);
// class Spells (7)
DB::Aowow()->query('UPDATE ?_spell s, dbc_skillline sl SET s.typeCat = 7 WHERE s.typeCat = 0 AND s.skillLine1 = sl.id AND sl.categoryId = 7');
DB::Aowow()->qry('UPDATE ::spell s, dbc_skillline sl SET s.typeCat = 7 WHERE s.typeCat = 0 AND s.skillLine1 = sl.id AND sl.categoryId = 7');
// hide some internal/unused stuffs
DB::Aowow()->query('UPDATE ?_spell s SET s.cuFlags = ?d WHERE s.typeCat = 7 AND (
DB::Aowow()->qry('UPDATE ::spell s SET s.cuFlags = %i WHERE s.typeCat = 7 AND (
s.name_loc0 LIKE "%passive%" OR s.name_loc0 LIKE "%effect%" OR s.name_loc0 LIKE "%improved%" OR s.name_loc0 LIKE "%prototype%" OR -- can probably be extended
(s.id NOT IN (47241, 59879, 59671) AND s.baseLevel <= 1 AND s.reqclassMask = 0) OR -- can probably still be extended
(s.SpellFamilyId = 15 AND s.SpellFamilyFlags1 & 0x2000 AND s.SpellDescriptionVariableId <> 84) OR -- DK: Skill Coil
(s.SpellFamilyId = 10 AND s.SpellFamilyFlags2 & 0x1000000 AND s.attributes1 = 0) OR -- Paladin: Bacon of Light hmm.. Bacon.... :]
(s.SpellFamilyId = 6 AND s.SpellFamilyFlags3 & 0x4000) OR -- Priest: Lolwell Renew
(s.SpellFamilyId = 6 AND s.SpellFamilyFlags1 & 0x8000000 AND s.rank_loc0 <> "") OR -- Priest: Bling Bling
(s.SpellFamilyId = 8 AND s.attributes0 = 0x50 AND s.attributes1 & 0x400) OR -- Rogue: Intuition (dropped Talent..? looks nice though)
(s.SpellFamilyId = 8 AND s.attributes0 = 0x50 AND s.attributes1 & 0x400) OR -- Rogue: Intuition
(s.SpellfamilyId = 11 AND s.SpellFamilyFlags1 & 3 AND s.attributes1 = 1024) OR -- Shaman: Lightning Overload procs
(s.attributes0 = 0x20000000 AND s.attributes3 = 0x10000000) -- Master Demonologist (FamilyId = 0)
)', CUSTOM_EXCLUDE_FOR_LISTVIEW);
foreach (ChrClass::cases() as $cl)
DB::Aowow()->query(
'UPDATE ?_spell s, dbc_skillline sl, dbc_skillraceclassinfo srci
DB::Aowow()->qry(
'UPDATE ::spell s, dbc_skillline sl, dbc_skillraceclassinfo srci
SET s.`reqClassMask` = srci.`classMask`
WHERE s.`typeCat` IN (-2, 7) AND (s.`attributes0` & 0x80) = 0 AND s.`skillLine1` = srci.`skillLine` AND sl.`categoryId` = 7 AND
srci.`skillline` <> 769 AND srci.`skillline` = sl.`id` AND srci.`flags` & 0x90 AND srci.`classMask` & ?d',
srci.`skillline` <> 769 AND srci.`skillline` = sl.`id` AND srci.`flags` & 0x90 AND srci.`classMask` & %i',
$cl->toMask()
);
// secondary Skills (9)
DB::Aowow()->query('UPDATE ?_spell s SET s.typeCat = 9 WHERE s.typeCat = 0 AND (s.skillLine1 IN (?a) OR (s.skillLine1 > 0 AND s.skillLine2OrMask IN (?a)))', SKILLS_TRADE_SECONDARY, SKILLS_TRADE_SECONDARY);
DB::Aowow()->qry('UPDATE ::spell s SET s.typeCat = 9 WHERE s.typeCat = 0 AND (s.skillLine1 IN %in OR (s.skillLine1 > 0 AND s.skillLine2OrMask IN %in))', SKILLS_TRADE_SECONDARY, SKILLS_TRADE_SECONDARY);
// primary Skills (11)
DB::Aowow()->query('UPDATE ?_spell s SET s.typeCat = 11 WHERE s.typeCat = 0 AND s.skillLine1 IN (?a)', SKILLS_TRADE_PRIMARY);
DB::Aowow()->qry('UPDATE ::spell s SET s.typeCat = 11 WHERE s.typeCat = 0 AND s.skillLine1 IN %in', SKILLS_TRADE_PRIMARY);
// npc spells (-8) (run as last! .. missing from npc_scripts? "enum Spells { \s+(\w\d_)+\s+=\s(\d+) }" and "#define SPELL_(\d\w_)+\s+(\d+)") // RAID_MODE(1, 2[, 3, 4]) - macro still not considered
$world = DB::World()->selectCol(
'SELECT ss.`action_param1` FROM smart_scripts ss WHERE ss.`action_type` IN (?a) UNION
'SELECT ss.`action_param1` FROM smart_scripts ss WHERE ss.`action_type` IN %in UNION
SELECT cts.`Spell` FROM creature_template_spell cts UNION
SELECT nscs.`spell_id` FROM npc_spellclick_spells nscs',
[SmartAction::ACTION_CAST, SmartAction::ACTION_ADD_AURA, SmartAction::ACTION_SELF_CAST, SmartAction::ACTION_CROSS_CAST]
@ -617,7 +617,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$world = array_merge($world, array_filter(explode(' ', $a)));
}
DB::Aowow()->query('UPDATE ?_spell s SET s.typeCat = -8 WHERE s.typeCat = 0 AND s.id IN (?a)', $world);
DB::Aowow()->qry('UPDATE ::spell s SET s.typeCat = -8 WHERE s.typeCat = 0 AND s.id IN %in', $world);
/**********/
@ -658,14 +658,14 @@ CLISetup::registerSetup("sql", new class extends SetupScript
);
$queryIcons =
'SELECT s.id, s.name_loc0, s.skillLine1 as skill, ic.id as icon, s.typeCat * s.typeCat AS prio
FROM ?_spell s
LEFT JOIN dbc_spellicon si ON s.iconIdBak = si.id
LEFT JOIN ?_icons ic ON ic.name_source = LOWER(SUBSTRING_INDEX(si.iconPath, "\\\\", -1))
WHERE [WHERE] AND (s.cuFlags & ?d) = 0 AND s.typeCat IN (0, 7, -2) -- not triggered; class spells first, talents second, unk last
'SELECT s.`id`, s.`name_loc0`, s.`skillLine1` AS "skill", ic.`id` AS "icon", s.`typeCat` * s.`typeCat` AS "prio"
FROM ::spell s
LEFT JOIN dbc_spellicon si ON s.`iconIdBak` = si.`id`
LEFT JOIN ::icons ic ON ic.`name_source` = LOWER(SUBSTRING_INDEX(si.`iconPath`, "\\", -1))
WHERE %and
ORDER BY prio DESC';
$effects = DB::Aowow()->select(
$effects = DB::Aowow()->selectAssoc(
'SELECT s2.id AS ARRAY_KEY,
s1.id,
s1.name_loc0,
@ -676,9 +676,10 @@ CLISetup::registerSetup("sql", new class extends SetupScript
s1.effect1SpellClassMaskB, s1.effect2SpellClassMaskB, s1.effect3SpellClassMaskB,
s1.effect1SpellClassMaskC, s1.effect2SpellClassMaskC, s1.effect3SpellClassMaskC
FROM dbc_glyphproperties gp
JOIN ?_spell s1 ON s1.id = gp.spellId
JOIN ?_spell s2 ON s2.effect1MiscValue = gp.id AND s2.effect1Id = 74
WHERE gp.typeFlags IN (0, 1)' // AND s2.id In (58271, 56297, 56289, 63941, 58275)
JOIN ::spell s1 ON s1.id = gp.spellId
JOIN ::spell s2 ON s2.effect1MiscValue = gp.id AND s2.effect1Id = %i
WHERE gp.typeFlags IN (0, 1)', // AND s2.id In (58271, 56297, 56289, 63941, 58275)
SPELL_EFFECT_APPLY_GLYPH
);
foreach ($effects as $applyId => $glyphEffect)
@ -690,41 +691,54 @@ CLISetup::registerSetup("sql", new class extends SetupScript
// first: manuall replace
if ($applyId == 57144) // has no skillLine.. :/
{
DB::Aowow()->query('UPDATE ?_spell s, ?_icons ic SET s.skillLine1 = ?d, s.iconIdAlt = ic.id WHERE s.id = ?d AND ic.name = ?', 253, 57144, 'ability_poisonsting');
DB::Aowow()->qry('UPDATE ::spell s, ::icons ic SET s.skillLine1 = %i, s.iconIdAlt = ic.id WHERE s.id = %i AND ic.name = %s', 253, 57144, 'ability_poisonsting');
continue;
}
// second: search by name and family equality
if (!$icons)
{
$where = array(
['(s.cuFlags & %i) = 0', SPELL_CU_TRIGGERED],
['s.typeCat IN (0, 7, -2)'] // not triggered; class spells first, talents second, unk last
);
$search = !empty($glyphAffects[$applyId]) ? $glyphAffects[$applyId] : str_replace('Glyph of ', '', $glyphEffect['name_loc0']);
if (is_int($search))
$where = "?d AND s.id = ?d";
$where[] = ['s.`id` = %i', $search];
else
$where = "s.SpellFamilyId = ?d AND s.name_loc0 LIKE ?";
$where[] = ['s.`SpellFamilyId` = %i AND s.`name_loc0` = %s', $fam, $search];
$qry = str_replace('[WHERE]', $where, $queryIcons);
$icons = DB::Aowow()->selectRow($qry, $fam ?: 1, $search, SPELL_CU_TRIGGERED);
$icons = DB::Aowow()->selectRow($queryIcons, $where);
}
// third: match by SpellFamily affect mask
while (empty($icons) && $i < 3)
{
$i++;
$m1 = $glyphEffect['effect'.$i.'SpellClassMaskA'];
$m2 = $glyphEffect['effect'.$i.'SpellClassMaskB'];
$m3 = $glyphEffect['effect'.$i.'SpellClassMaskC'];
$m1 = $glyphEffect['effect'.$i.'SpellClassMaskA'];
$m2 = $glyphEffect['effect'.$i.'SpellClassMaskB'];
$m3 = $glyphEffect['effect'.$i.'SpellClassMaskC'];
if ($glyphEffect['effect'.$i.'Id'] != 6 || (!$m1 && !$m2 && !$m3))
if ($glyphEffect['effect'.$i.'Id'] != SPELL_EFFECT_APPLY_AURA || (!$m1 && !$m2 && !$m3))
continue;
$where = "s.SpellFamilyId = ?d AND (s.SpellFamilyFlags1 & ?d OR s.SpellFamilyFlags2 & ?d OR s.SpellFamilyFlags3 & ?d)";
$where = array(
['(s.`cuFlags` & %i) = 0', SPELL_CU_TRIGGERED],
['s.`typeCat` IN (0, 7, -2)'], // not triggered; class spells first, talents second, unk last
['s.`SpellFamilyId` = %i', $fam],
[DB::OR, [
['s.`SpellFamilyFlags1` & %i', $m1],
['s.`SpellFamilyFlags2` & %i', $m2],
['s.`SpellFamilyFlags3` & %i', $m3]
]]
);
$icons = DB::Aowow()->selectRow(str_replace('[WHERE]', $where, $queryIcons), $fam, $m1, $m2, $m3, SPELL_CU_TRIGGERED);
$icons = DB::Aowow()->selectRow($queryIcons, $where);
}
if ($icons)
DB::Aowow()->query('UPDATE ?_spell s SET s.skillLine1 = ?d, s.iconIdAlt = ?d WHERE s.id = ?d', $icons['skill'], $icons['icon'], $applyId);
DB::Aowow()->qry('UPDATE ::spell s SET s.`skillLine1` = %i, s.`iconIdAlt` = %i WHERE s.`id` = %i', $icons['skill'], $icons['icon'], $applyId);
else
CLI::write('[spell] '.str_pad('['.$glyphEffect['id'].']', 8).'could not match '.CLI::bold($glyphEffect['name_loc0']).' with affected spells', CLI::LOG_WARN);
}

View file

@ -19,32 +19,32 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $worldDependency = ['spelldifficulty_dbc'];
protected $setupAfter = [['creature', 'spawns'], []];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE TABLE ?_spelldifficulty');
DB::Aowow()->qry('TRUNCATE TABLE ::spelldifficulty');
DB::Aowow()->query('INSERT INTO ?_spelldifficulty SELECT GREATEST(`normal10`, 0), GREATEST(`normal25`, 0), GREATEST(`heroic10`, 0), GREATEST(`heroic25`, 0), IF(`heroic10` > 0, 2, 0) FROM dbc_spelldifficulty');
DB::Aowow()->qry('INSERT INTO ::spelldifficulty SELECT GREATEST(`normal10`, 0), GREATEST(`normal25`, 0), GREATEST(`heroic10`, 0), GREATEST(`heroic25`, 0), IF(`heroic10` > 0, 2, 0) FROM dbc_spelldifficulty');
$rows = DB::World()->select('SELECT `spellid0`, `spellid1`, `spellid2`, `spellid3`, IF(`spellid2` > 0, 2, 0) FROM spelldifficulty_dbc');
$rows = DB::World()->selectAssoc('SELECT `spellid0`, `spellid1`, `spellid2`, `spellid3`, IF(`spellid2` > 0, 2, 0) FROM spelldifficulty_dbc');
foreach ($rows as $r)
DB::Aowow()->query('INSERT INTO ?_spelldifficulty VALUES (?a)', array_values($r));
DB::Aowow()->qry('INSERT INTO ::spelldifficulty VALUES %l', $r);
CLI::write('[spelldifficulty] - trying to assign map type by traversing creature spells > spawns');
// try to update mode of ambiguous entries
$baseSpells = DB::Aowow()->selectCol('SELECT `normal10` FROM ?_spelldifficulty WHERE `heroic10` = 0 AND `heroic25` = 0');
$baseSpells = DB::Aowow()->selectCol('SELECT `normal10` FROM ::spelldifficulty WHERE `heroic10` = 0 AND `heroic25` = 0');
for ($i = 1; $i < 9; $i++)
DB::Aowow()->query(
'UPDATE ?_spelldifficulty sd,
(SELECT c.?# AS "spell", BIT_OR(CASE WHEN z.`type` = ?d THEN 1 WHEN z.`type` = ?d THEN 2 WHEN z.`type` = ?d THEN 2 ELSE 0 END) AS "mapType"
FROM ?_creature c
JOIN ?_spawns s ON c.id = s.typeId AND s.type = ?d
JOIN ?_zones z ON z.id = s.areaId
WHERE c.?# IN (?a)
GROUP BY c.?#
HAVING c.?# <> 0) x
DB::Aowow()->qry(
'UPDATE ::spelldifficulty sd,
(SELECT c.%n AS "spell", BIT_OR(CASE WHEN z.`type` = %i THEN 1 WHEN z.`type` = %i THEN 2 WHEN z.`type` = %i THEN 2 ELSE 0 END) AS "mapType"
FROM ::creature c
JOIN ::spawns s ON c.id = s.typeId AND s.type = %i
JOIN ::zones z ON z.id = s.areaId
WHERE c.%n IN %in
GROUP BY c.%n
HAVING c.%n <> 0) x
SET sd.`mapType` = x.`mapType`
WHERE sd.`normal10` = x.`spell`',
'spell'.$i, MAP_TYPE_DUNGEON_HC, MAP_TYPE_MMODE_RAID, MAP_TYPE_MMODE_RAID_HC,
@ -62,14 +62,14 @@ CLISetup::registerSetup("sql", new class extends SetupScript
foreach ($smartCaster as $type => $spells)
foreach ($spells as $spellId => $casterEntries)
DB::Aowow()->query(
'UPDATE ?_spelldifficulty sd,
(SELECT BIT_OR(CASE WHEN z.`type` = ?d THEN 1 WHEN z.`type` = ?d THEN 2 WHEN z.`type` = ?d THEN 2 ELSE 0 END) AS "mapType"
FROM ?_spawns s
JOIN ?_zones z ON z.id = s.areaId
WHERE s.type = ?d AND s.typeId IN (?a) ) sp
DB::Aowow()->qry(
'UPDATE ::spelldifficulty sd,
(SELECT BIT_OR(CASE WHEN z.`type` = %i THEN 1 WHEN z.`type` = %i THEN 2 WHEN z.`type` = %i THEN 2 ELSE 0 END) AS "mapType"
FROM ::spawns s
JOIN ::zones z ON z.id = s.areaId
WHERE s.type = %i AND s.typeId IN %in ) sp
SET sd.`mapType` = IF(sp.`mapType` > 2, 0, sp.`mapType`)
WHERE sd.`normal10` = ?d',
WHERE sd.`normal10` = %i',
MAP_TYPE_DUNGEON_HC, MAP_TYPE_MMODE_RAID, MAP_TYPE_MMODE_RAID_HC,
$type, $casterEntries,
$spellId

View file

@ -17,25 +17,25 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $dbcSourceFiles = ['talent', 'talenttab'];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_talents');
DB::Aowow()->qry('TRUNCATE ::talents');
// class: 0 => hunter pets
for ($i = 1; $i < 6; $i++)
DB::Aowow()->query(
'INSERT INTO ?_talents
DB::Aowow()->qry(
'INSERT INTO ::talents
SELECT t.id,
IF(tt.classMask <> 0, LOG(2, tt.classMask) + 1, 0),
tt.creatureFamilyMask,
IF(tt.creaturefamilyMask <> 0, LOG(2, tt.creaturefamilyMask), tt.tabNumber),
t.row,
t.column,
t.rank?d,
?d
t.rank%i,
%i
FROM dbc_talenttab tt
JOIN dbc_talent t ON tt.id = t.tabId
WHERE t.rank?d <> 0',
WHERE t.rank%i <> 0',
$i, $i, $i
);

View file

@ -19,19 +19,19 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $worldDependency = ['creature', 'creature_template'];
protected $setupAfter = [['dungeonmap', 'worldmaparea'], []]; // accessed by WorldPosition::toZonePos
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_taxipath');
DB::Aowow()->query('TRUNCATE ?_taxinodes');
DB::Aowow()->qry('TRUNCATE ::taxipath');
DB::Aowow()->qry('TRUNCATE ::taxinodes');
/*********/
/* paths */
/*********/
DB::Aowow()->query('INSERT INTO ?_taxipath SELECT tp.id, tp.startNodeId, tp.endNodeId FROM dbc_taxipath tp WHERE tp.startNodeId > 0 AND tp.EndNodeId > 0');
DB::Aowow()->qry('INSERT INTO ::taxipath SELECT tp.id, tp.startNodeId, tp.endNodeId FROM dbc_taxipath tp WHERE tp.startNodeId > 0 AND tp.EndNodeId > 0');
// paths are monodirectional and thus exist twice for regular flight travel (which is bidirectional)
$paths = DB::Aowow()->select('SELECT id AS ARRAY_KEY, tp.* FROM ?_taxipath tp');
$paths = DB::Aowow()->selectAssoc('SELECT id AS ARRAY_KEY, tp.* FROM ::taxipath tp');
foreach ($paths as $i => $p)
{
foreach ($paths as $j => $_)
@ -39,7 +39,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
if ($_['startNodeId'] != $p['endNodeId'] || $_['endNodeId'] != $p['startNodeId'])
continue;
DB::Aowow()->query('DELETE FROM ?_taxipath WHERE id = ?d', $j);
DB::Aowow()->qry('DELETE FROM ::taxipath WHERE id = %i', $j);
unset($paths[$j]);
unset($paths[$i]);
break;
@ -52,7 +52,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
/*********/
// all sensible nodes
$fNodes = DB::Aowow()->select(
$fNodes = DB::Aowow()->selectAssoc(
'SELECT tn.`id`,
tn.`mapId`,
100 - ROUND((tn.`posY` - wma.`right`) * 100 / (wma.`left` - wma.`right`), 1) AS "mapX",
@ -92,17 +92,18 @@ CLISetup::registerSetup("sql", new class extends SetupScript
);
// all available flightmaster
$fMaster = DB::World()->select('SELECT ct.`entry`, ct.`faction`, c.`map`, c.`position_x` AS "posX", c.`position_y` AS "posY" FROM creature_template ct JOIN creature c ON c.`id` = ct.`entry` WHERE ct.`npcflag` & ?d OR c.`npcflag` & ?d',
$fMaster = DB::World()->selectAssoc(
'SELECT ct.`entry`, ct.`faction`, c.`map`, c.`position_x` AS "posX", c.`position_y` AS "posY" FROM creature_template ct JOIN creature c ON c.`id` = ct.`entry` WHERE ct.`npcflag` & %i OR c.`npcflag` & %i',
NPC_FLAG_FLIGHT_MASTER, NPC_FLAG_FLIGHT_MASTER
);
// fetch reactions per faction
$factions = DB::Aowow()->query(
$factions = DB::Aowow()->selectAssoc(
'SELECT `id` AS ARRAY_KEY,
IF(`enemyFactionId1` = 1 OR `enemyFactionId2` = 1 OR `enemyFactionId3` = 1 OR `enemyFactionId4` = 1 OR `hostileMask` & 0x3, -1, 1) AS "reactA",
IF(`enemyFactionId1` = 2 OR `enemyFactionId2` = 2 OR `enemyFactionId3` = 2 OR `enemyFactionId4` = 2 OR `hostileMask` & 0x5, -1, 1) AS "reactH"
FROM dbc_factiontemplate
WHERE `id` IN (?a)',
WHERE `id` IN %in',
array_column($fMaster, 'faction'));
foreach ($fNodes as $n)
@ -125,8 +126,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript
{
$n['_dist'] = $dist;
$n['typeId'] = $c['entry'];
$n['reactA'] = $factions[$c['faction']]['reactA'] ?? null;
$n['reactH'] = $factions[$c['faction']]['reactH'] ?? null;
$n['reactA'] = $factions[$c['faction']]['reactA'] ?? 0;
$n['reactH'] = $factions[$c['faction']]['reactH'] ?? 0;
}
}
}
@ -141,7 +142,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
unset($n['_mapId'], $n['_posX'], $n['_posY'], $n['_dist'], $n['_scripted']);
DB::Aowow()->query('INSERT INTO ?_taxinodes VALUES (?a)', array_values($n));
DB::Aowow()->qry('INSERT INTO ::taxinodes VALUES %l', $n);
}
return true;

View file

@ -34,7 +34,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
168 => 404
);
public function generate(array $ids = []) : bool
public function generate() : bool
{
$questQuery =
'SELECT qt.`RewardTitle` AS ARRAY_KEY, qt.`AllowableRaces`, IFNULL(ge.`eventEntry`, 0) AS `eventEntry`
@ -43,38 +43,38 @@ CLISetup::registerSetup("sql", new class extends SetupScript
LEFT JOIN game_event ge ON ge.`eventEntry` = sq.`eventEntry`
WHERE qt.`RewardTitle` <> 0';
DB::Aowow()->query('TRUNCATE ?_titles');
DB::Aowow()->query('INSERT INTO ?_titles SELECT `id`, 0, 0, 0, 0, 0, 0, 0, `bitIdx`, `male_loc0`, `male_loc2`, `male_loc3`, `male_loc4`, `male_loc6`, `male_loc8`, `female_loc0`, `female_loc2`, `female_loc3`, `female_loc4`, `female_loc6`, `female_loc8` FROM dbc_chartitles');
DB::Aowow()->qry('TRUNCATE ::titles');
DB::Aowow()->qry('INSERT INTO ::titles SELECT `id`, 0, 0, 0, 0, 0, 0, 0, `bitIdx`, `male_loc0`, `male_loc2`, `male_loc3`, `male_loc4`, `male_loc6`, `male_loc8`, `female_loc0`, `female_loc2`, `female_loc3`, `female_loc4`, `female_loc6`, `female_loc8` FROM dbc_chartitles');
// hide unused titles
DB::Aowow()->query('UPDATE ?_titles SET `cuFlags` = ?d WHERE `id` BETWEEN 85 AND 123 AND `id` NOT IN (113, 120, 121, 122)', CUSTOM_EXCLUDE_FOR_LISTVIEW);
DB::Aowow()->qry('UPDATE ::titles SET `cuFlags` = %i WHERE `id` BETWEEN 85 AND 123 AND `id` NOT IN (113, 120, 121, 122)', CUSTOM_EXCLUDE_FOR_LISTVIEW);
// set expansion
DB::Aowow()->query('UPDATE ?_titles SET `expansion` = 2 WHERE `id` >= 72 AND `id` <> 80');
DB::Aowow()->query('UPDATE ?_titles SET `expansion` = 1 WHERE `id` >= 42 AND `id` <> 46 AND `expansion` = 0');
DB::Aowow()->qry('UPDATE ::titles SET `expansion` = 2 WHERE `id` >= 72 AND `id` <> 80');
DB::Aowow()->qry('UPDATE ::titles SET `expansion` = 1 WHERE `id` >= 42 AND `id` <> 46 AND `expansion` = 0');
// set category
DB::Aowow()->query('UPDATE ?_titles SET `category` = 1 WHERE `id` <= 28 OR `id` IN (42, 43, 44, 45, 47, 48, 62, 71, 72, 80, 82, 126, 127, 128, 157, 163, 167, 169, 177)');
DB::Aowow()->query('UPDATE ?_titles SET `category` = 5 WHERE `id` BETWEEN 96 AND 109 OR `id` IN (83, 84)');
DB::Aowow()->query('UPDATE ?_titles SET `category` = 2 WHERE `id` BETWEEN 144 AND 156 OR `id` IN (63, 77, 79, 113, 123, 130, 131, 132, 176)');
DB::Aowow()->query('UPDATE ?_titles SET `category` = 6 WHERE `id` IN (46, 74, 75, 76, 124, 133, 134, 135, 137, 138, 155, 168)');
DB::Aowow()->query('UPDATE ?_titles SET `category` = 4 WHERE `id` IN (81, 125)');
DB::Aowow()->query('UPDATE ?_titles SET `category` = 3 WHERE `id` IN (53, 64, 120, 121, 122, 129, 139, 140, 141, 142) OR (`id` >= 158 AND `category` = 0)');
DB::Aowow()->qry('UPDATE ::titles SET `category` = 1 WHERE `id` <= 28 OR `id` IN (42, 43, 44, 45, 47, 48, 62, 71, 72, 80, 82, 126, 127, 128, 157, 163, 167, 169, 177)');
DB::Aowow()->qry('UPDATE ::titles SET `category` = 5 WHERE `id` BETWEEN 96 AND 109 OR `id` IN (83, 84)');
DB::Aowow()->qry('UPDATE ::titles SET `category` = 2 WHERE `id` BETWEEN 144 AND 156 OR `id` IN (63, 77, 79, 113, 123, 130, 131, 132, 176)');
DB::Aowow()->qry('UPDATE ::titles SET `category` = 6 WHERE `id` IN (46, 74, 75, 76, 124, 133, 134, 135, 137, 138, 155, 168)');
DB::Aowow()->qry('UPDATE ::titles SET `category` = 4 WHERE `id` IN (81, 125)');
DB::Aowow()->qry('UPDATE ::titles SET `category` = 3 WHERE `id` IN (53, 64, 120, 121, 122, 129, 139, 140, 141, 142) OR (`id` >= 158 AND `category` = 0)');
// update event
if ($assoc = DB::World()->selectCol('SELECT `holiday` AS ARRAY_KEY, `eventEntry` FROM game_event WHERE `holiday` IN (?a)', array_values($this->titleHoliday)))
if ($assoc = DB::World()->selectCol('SELECT `holiday` AS ARRAY_KEY, `eventEntry` FROM game_event WHERE `holiday` IN %in', array_values($this->titleHoliday)))
foreach ($this->titleHoliday as $tId => $hId)
if (!empty($assoc[$hId]))
DB::Aowow()->query('UPDATE ?_titles SET `eventId` = ?d WHERE `id` = ?d', $assoc[$hId], $tId);
DB::Aowow()->qry('UPDATE ::titles SET `eventId` = %i WHERE `id` = %i', $assoc[$hId], $tId);
// update side
$questInfo = DB::World()->select($questQuery);
$sideUpd = DB::World()->selectCol('SELECT IF(`TitleA`, `TitleA`, `TitleH`) AS ARRAY_KEY, BIT_OR(IF(`TitleA`, ?d, ?d)) AS `side` FROM achievement_reward WHERE (`TitleA` <> 0 AND `TitleH` = 0) OR (`TitleH` <> 0 AND `TitleA` = 0) GROUP BY ARRAY_KEY HAVING `side` <> ?d',
$questInfo = DB::World()->selectAssoc($questQuery);
$sideUpd = DB::World()->selectCol('SELECT IF(`TitleA`, `TitleA`, `TitleH`) AS ARRAY_KEY, BIT_OR(IF(`TitleA`, %i, %i)) AS `side` FROM achievement_reward WHERE (`TitleA` <> 0 AND `TitleH` = 0) OR (`TitleH` <> 0 AND `TitleA` = 0) GROUP BY ARRAY_KEY HAVING `side` <> %i',
SIDE_ALLIANCE, SIDE_HORDE, SIDE_BOTH);
foreach ($questInfo as $tId => $data)
{
if ($data['eventEntry'])
DB::Aowow()->query('UPDATE ?_titles SET `eventId` = ?d WHERE `id` = ?d', $data['eventEntry'], $tId);
DB::Aowow()->qry('UPDATE ::titles SET `eventId` = %i WHERE `id` = %i', $data['eventEntry'], $tId);
$side = ChrRace::sideFromMask($data['AllowableRaces']);
if ($side == SIDE_BOTH)
@ -87,11 +87,11 @@ CLISetup::registerSetup("sql", new class extends SetupScript
}
foreach ($sideUpd as $tId => $side)
if ($side != SIDE_BOTH)
DB::Aowow()->query("UPDATE ?_titles SET `side` = ?d WHERE `id` = ?d", $side, $tId);
DB::Aowow()->qry("UPDATE ::titles SET `side` = %i WHERE `id` = %i", $side, $tId);
// update side - sourceless titles (maintain query order)
DB::Aowow()->query('UPDATE ?_titles SET `side` = ?d WHERE `id` <= 28 OR `id` IN (118, 119, 116, 117, 110, 127)', SIDE_HORDE);
DB::Aowow()->query('UPDATE ?_titles SET `side` = ?d WHERE `id` <= 14 OR `id` IN (111, 115, 112, 114, 126)', SIDE_ALLIANCE);
DB::Aowow()->qry('UPDATE ::titles SET `side` = %i WHERE `id` <= 28 OR `id` IN (118, 119, 116, 117, 110, 127)', SIDE_HORDE);
DB::Aowow()->qry('UPDATE ::titles SET `side` = %i WHERE `id` <= 14 OR `id` IN (111, 115, 112, 114, 126)', SIDE_ALLIANCE);
$this->reapplyCCFlags('titles', Type::TITLE);

View file

@ -26,18 +26,18 @@ CLISetup::registerSetup("sql", new class extends SetupScript
protected $worldDependency = ['access_requirement', 'areatrigger_teleport'];
protected $setupAfter = [['dungeonmap', 'worldmaparea'], []];
public function generate(array $ids = []) : bool
public function generate() : bool
{
DB::Aowow()->query('TRUNCATE ?_zones');
DB::Aowow()->qry('TRUNCATE ::zones');
$baseData = DB::Aowow()->query(
$baseData = DB::Aowow()->selectAssoc(
'SELECT a.id,
IFNULL(wmt.targetMapId, m.id) AS map,
m.id AS mapBak,
a.areaTable AS parentArea,
IFNULL(wmt.targetMapId, IF(m.areaType = 1, 2, IF(m.areaType = 2, 3, IF(m.areaType = 4, 9, IF(m.isBG = 1, 6, IF(m.id = 571, 10, IF(m.id = 530, 8, m.id))))))) AS category,
a.flags,
IF(a.mapId IN (13, 25, 37, 42, 169) OR (a.mapId IN (0, 1, 530, 571) AND wma.id IS NULL) OR a.areaTable <> 0 OR (a.soundAmbience = 0 AND a.mapId IN (0, 1, 530, 571)), ?d, 0) AS cuFlags,
IF(a.mapId IN (13, 25, 37, 42, 169) OR (a.mapId IN (0, 1, 530, 571) AND wma.id IS NULL) OR a.areaTable <> 0 OR (a.soundAmbience = 0 AND a.mapId IN (0, 1, 530, 571)), %i, 0) AS cuFlags,
IF(a.flags & 0x01000000, 5, IF(m.isBG = 1, 4, IF(m.areaType = 4, 4, IF(a.flags & 0x00000800, 3, IF(a.factionGroupMask = 6, 2, IF(a.factionGroupMask > 0, LOG2(a.factionGroupMask) - 1, 2)))))) AS faction, -- g_zone_territories
m.expansion,
IF(m.areaType = 0, 0, IF(m.isBG = 1, 4, IF(m.areaType = 4, 6, IF(md.modeMask & 0xC, 8, IF(md.minPl = 10 AND md.maxPL = 25, 7, IF(m.areaType = 2, 3, IF(m.areaType = 1 AND md.modeMask & 0x2, 5, 2))))))) AS `type`, -- g_zone_instancetypes
@ -48,7 +48,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
IFNULL(lfgIni.levelLFG, 0) AS `levelReqLFG`,
0 AS `levelHeroic`,
IF(a.flags & 0x8, 1, IFNULL(bm.minLevel, IFNULL(lfgIni.levelMin, IFNULL(lfgOpen.levelMin, 0)))) AS `levelMin`,
IF(a.flags & 0x8, ?d, IFNULL(bm.maxLevel, IFNULL(lfgIni.levelMax, IFNULL(lfgOpen.levelMax, 0)))) AS `levelMax`,
IF(a.flags & 0x8, %i, IFNULL(bm.maxLevel, IFNULL(lfgIni.levelMax, IFNULL(lfgOpen.levelMax, 0)))) AS `levelMax`,
"" AS `attunementsN`,
"" AS `attunementsH`,
GREATEST(m.parentMapId, 0),
@ -79,20 +79,21 @@ CLISetup::registerSetup("sql", new class extends SetupScript
CUSTOM_EXCLUDE_FOR_LISTVIEW, MAX_LEVEL
);
DB::Aowow()->query('INSERT INTO ?_zones VALUES (?a)', $baseData);
foreach ($baseData as $bd)
DB::Aowow()->qry('INSERT INTO ::zones VALUES %l', $bd);
// set missing graveyards from areatrigger data (auto-resurrect map or just plain errors)
// grouped because naxxramas _just has_ to be special with 4 entrances...
if ($missingMaps = DB::Aowow()->selectCol('SELECT `id` FROM dbc_map WHERE `parentX` = 0 AND `parentY` = 0 AND `parentMapId` > -1 AND `areaType` NOT IN (0, 3, 4)'))
if ($triggerIds = DB::World()->selectCol('SELECT `target_map`, `id` AS ARRAY_KEY FROM areatrigger_teleport WHERE `target_map` IN (?a) GROUP BY `target_map`', $missingMaps))
if ($positions = DB::Aowow()->select('SELECT `id` AS `ARRAY_KEY`, `mapId` AS "parentMapId", `posX` AS "parentX", `posY` AS "parentY" FROM dbc_areatrigger WHERE `id` IN (?a)', array_keys($triggerIds)))
if ($triggerIds = DB::World()->selectCol('SELECT `target_map`, `id` AS ARRAY_KEY FROM areatrigger_teleport WHERE `target_map` IN %in GROUP BY `target_map`', $missingMaps))
if ($positions = DB::Aowow()->selectAssoc('SELECT `id` AS `ARRAY_KEY`, `mapId` AS "parentMapId", `posX` AS "parentX", `posY` AS "parentY" FROM dbc_areatrigger WHERE `id` IN %in', array_keys($triggerIds)))
foreach ($positions as $atId => $parentPos)
DB::Aowow()->query('UPDATE ?_zones SET ?a WHERE `mapId` = ?d', $parentPos, $triggerIds[$atId]);
DB::Aowow()->qry('UPDATE ::zones SET %a WHERE `mapId` = %i', $parentPos, $triggerIds[$atId]);
// get requirements from world.access_requirement
$zoneReq = DB::World()->select(
$zoneReq = DB::World()->selectAssoc(
'SELECT mapId AS ARRAY_KEY,
MIN(level_min) AS reqLevel,
MAX(IF(difficulty > 0, level_min, 0)) AS heroicLevel,
@ -108,7 +109,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
GROUP BY mapId'
);
$heroics = DB::Aowow()->selectCol('SELECT DISTINCT mapId FROM ?_zones WHERE type IN (5, 8)');
$heroics = DB::Aowow()->selectCol('SELECT DISTINCT mapId FROM ::zones WHERE type IN (5, 8)');
foreach ($zoneReq as $mapId => $req)
{
@ -167,7 +168,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript
$update['attunementsH'] = implode(' ', $aH);
}
DB::Aowow()->query('UPDATE ?_zones SET ?a WHERE mapId = ?d', $update, $mapId);
DB::Aowow()->qry('UPDATE ::zones SET %a WHERE mapId = %i', $update, $mapId);
}
$this->reapplyCCFlags('zones', Type::ZONE);