aowow/setup/tools/sqlgen/questsstartend.ss.php
Sarjuuk 69df50619a DB/Dependency
* remove unmaintained DbSimple
 * add package db/dibi as substitute db abstraction
2026-02-26 16:26:02 +01:00

52 lines
2.4 KiB
PHP

<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
CLISetup::registerSetup("sql", new class extends SetupScript
{
protected $info = array(
'quests_startend' => [[], CLISetup::ARGV_PARAM, 'Compiles supplemental data for type: Quest from world db.']
);
protected $worldDependency = ['creature_queststarter', 'creature_questender', 'game_event_creature_quest', 'gameobject_queststarter', 'gameobject_questender', 'game_event_gameobject_quest', 'item_template'];
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
SELECT 1 AS `type`, `id` AS `typeId`, `quest` AS `questId`, 2 AS `method`, 0 AS `eventId` FROM creature_questender UNION
SELECT 1 AS `type`, `id` AS `typeId`, `quest` AS `questId`, 1 AS `method`, `eventEntry` AS `eventId` FROM game_event_creature_quest';
$query['Object'] =
'SELECT 2 AS `type`, `id` AS `typeId`, `quest` AS `questId`, 1 AS `method`, 0 AS `eventId` FROM gameobject_queststarter UNION
SELECT 2 AS `type`, `id` AS `typeId`, `quest` AS `questId`, 2 AS `method`, 0 AS `eventId` FROM gameobject_questender UNION
SELECT 2 AS `type`, `id` AS `typeId`, `quest` AS `questId`, 1 AS `method`, `eventEntry` AS `eventId` FROM game_event_gameobject_quest';
$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()->qry('TRUNCATE ::quests_startend');
foreach ($query as $n => $q)
{
CLI::write(' - ' . $n . ' start/end-points', CLI::LOG_BLANK, true, true);
$data = DB::World()->selectAssoc($q);
foreach ($data as $d)
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()->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;
}
});
?>