[[], CLISetup::ARGV_PARAM, 'Compiles data for type: Currency from dbc and world db.'] ); protected $dbcSourceFiles = ['itemdisplayinfo', 'currencytypes']; protected $worldDependency = ['item_template', 'item_template_locale']; protected $setupAfter = [['icons'], []]; public function generate() : bool { 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'); // apply names & cap $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` FROM item_template it LEFT JOIN item_template_locale itl2 ON it.entry = itl2.ID AND itl2.locale = "frFR" LEFT JOIN item_template_locale itl3 ON it.entry = itl3.ID AND itl3.locale = "deDE" 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 %in', $moneyItems ); foreach ($moneyItems as $cId => $itemId) { if (!empty($moneyNames[$itemId])) $strings = $moneyNames[$itemId]; else { CLI::write('[currencies] '.str_pad('['.$cId.']', 6).' referenced item '.CLI::bold($itemId).' is not in item_template', CLI::LOG_WARN); $strings = ['name_loc0' => 'Item #'.$itemId.' not in DB', 'iconId' => 0, 'cuFlags' => CUSTOM_EXCLUDE_FOR_LISTVIEW, 'category' => 3]; } 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 %in', $moneyItems); foreach ($displayIds as $itemId => $iconId) 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` = %i AND c.`itemId` = %i', $iconId, $itemId ); $this->reapplyCCFlags('currencies', Type::CURRENCY); return true; } }); ?>