Itemset/Listpage

* implement filter: available to players
This commit is contained in:
Sarjuuk
2023-05-23 16:32:50 +02:00
parent e9622e6991
commit a6f6e0b05d
5 changed files with 80 additions and 19 deletions

View File

@@ -18,7 +18,8 @@ class ItemsetList extends BaseType
protected $queryBase = 'SELECT `set`.*, `set`.id AS ARRAY_KEY FROM ?_itemset `set`'; protected $queryBase = 'SELECT `set`.*, `set`.id AS ARRAY_KEY FROM ?_itemset `set`';
protected $queryOpts = array( protected $queryOpts = array(
'set' => ['o' => 'maxlevel DESC'], 'set' => ['o' => 'maxlevel DESC'],
'e' => ['j' => ['?_events e ON e.id = `set`.eventId', true], 's' => ', e.holidayId'] 'e' => ['j' => ['?_events e ON `e`.`id` = `set`.`eventId`', true], 's' => ', e.holidayId'],
'src' => ['j' => ['?_source src ON `src`.`typeId` = `set`.`id` AND `src`.`type` = 4', true], 's' => ', src1, src2, src3, src4, src5, src6, src7, src8, src9, src10, src11, src12, src13, src14, src15, src16, src17, src18, src19, src20, src21, src22, src23, src24']
); );
public function __construct($conditions = []) public function __construct($conditions = [])
@@ -184,7 +185,7 @@ class ItemsetListFilter extends Filter
8 => [FILTER_CR_FLAG, 'cuFlags', CUSTOM_HAS_COMMENT ], // hascomments 8 => [FILTER_CR_FLAG, 'cuFlags', CUSTOM_HAS_COMMENT ], // hascomments
9 => [FILTER_CR_FLAG, 'cuFlags', CUSTOM_HAS_SCREENSHOT ], // hasscreenshots 9 => [FILTER_CR_FLAG, 'cuFlags', CUSTOM_HAS_SCREENSHOT ], // hasscreenshots
10 => [FILTER_CR_FLAG, 'cuFlags', CUSTOM_HAS_VIDEO ], // hasvideos 10 => [FILTER_CR_FLAG, 'cuFlags', CUSTOM_HAS_VIDEO ], // hasvideos
12 => [FILTER_CR_NYI_PH, null, 1 ] // available to players [yn] - ugh .. scan loot, quest and vendor templates and write to ?_itemset 12 => [FILTER_CR_CALLBACK, 'cbAvaliable', ] // available to players [yn]
); );
protected $inputFields = array( protected $inputFields = array(
@@ -258,6 +259,19 @@ class ItemsetListFilter extends Filter
return $parts; return $parts;
} }
protected function cbAvaliable($cr)
{
switch ($cr[1])
{
case 1: // Yes
return ['src.typeId', null, '!'];
case 2: // No
return ['src.typeId', null];
}
return false;
}
} }
?> ?>

View File

@@ -2473,7 +2473,7 @@ DROP TABLE IF EXISTS `aowow_source`;
/*!40101 SET character_set_client = utf8 */; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `aowow_source` ( CREATE TABLE `aowow_source` (
`type` tinyint(4) unsigned NOT NULL, `type` tinyint(4) unsigned NOT NULL,
`typeId` mediumint(9) unsigned NOT NULL, `typeId` mediumint(9) NOT NULL,
`moreType` tinyint(4) unsigned DEFAULT NULL, `moreType` tinyint(4) unsigned DEFAULT NULL,
`moreTypeId` mediumint(9) unsigned DEFAULT NULL, `moreTypeId` mediumint(9) unsigned DEFAULT NULL,
`moreZoneId` mediumint(9) unsigned DEFAULT NULL, `moreZoneId` mediumint(9) unsigned DEFAULT NULL,
@@ -3186,7 +3186,7 @@ UNLOCK TABLES;
LOCK TABLES `aowow_dbversion` WRITE; LOCK TABLES `aowow_dbversion` WRITE;
/*!40000 ALTER TABLE `aowow_dbversion` DISABLE KEYS */; /*!40000 ALTER TABLE `aowow_dbversion` DISABLE KEYS */;
INSERT INTO `aowow_dbversion` VALUES (1684793470,0,NULL,NULL); INSERT INTO `aowow_dbversion` VALUES (1684849476,0,NULL,NULL);
/*!40000 ALTER TABLE `aowow_dbversion` ENABLE KEYS */; /*!40000 ALTER TABLE `aowow_dbversion` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;

View File

@@ -274,7 +274,7 @@ SqlGen::register(new class extends SetupScript
3) one itemset from one dbc entry (basic case). duplicate items per slot possible 3) one itemset from one dbc entry (basic case). duplicate items per slot possible
*/ */
if (!$pieces) if (count($pieces) < 2)
{ {
$row['cuFlags'] = CUSTOM_EXCLUDE_FOR_LISTVIEW; $row['cuFlags'] = CUSTOM_EXCLUDE_FOR_LISTVIEW;
DB::Aowow()->query('REPLACE INTO ?_itemset (?#) VALUES (?a)', array_keys($row), array_values($row)); DB::Aowow()->query('REPLACE INTO ?_itemset (?#) VALUES (?a)', array_keys($row), array_values($row));
@@ -295,11 +295,11 @@ SqlGen::register(new class extends SetupScript
// create new // create new
if (!isset($sorted[$k][$data['slot']])) if (!isset($sorted[$k][$data['slot']]))
$sorted[$k][$data['slot']] = $data; $sorted[$k][$data['slot']] = $data;
// can have multiple // can have two
else if (in_array($data['slot'], [INVTYPE_WEAPON, INVTYPE_FINGER, INVTYPE_TRINKET])) else if (in_array($data['slot'], [INVTYPE_WEAPON, INVTYPE_FINGER, INVTYPE_TRINKET]))
$sorted[$k][-$data['slot']] = $data; $sorted[$k][-$data['slot']] = $data;
// use item with lower itemId // slot confict. If item is being sold, replace old item (imperfect solution :/)
else if ($sorted[$k][$data['slot']]['entry'] > $data['entry']) 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']))
$sorted[$k][$data['slot']] = $data; $sorted[$k][$data['slot']] = $data;
} }

View File

@@ -11,8 +11,8 @@ SqlGen::register(new class extends SetupScript
{ {
protected $command = 'source'; protected $command = 'source';
protected $tblDependancyAowow = ['spell', 'achievement', 'items', 'spawns', 'creature', 'zones', 'titles']; protected $tblDependancyAowow = ['spell', 'achievement', 'items', 'itemset', 'spawns', 'creature', 'zones', 'titles'];
protected $tblDependancyTC = ['playercreateinfo_skills', 'playercreateinfo_item', 'skill_discovery_template', 'achievement_reward', 'skill_perfect_item_template', 'item_template', 'gameobject_template', 'quest_template', 'quest_template_addon', 'creature_template', 'creature', 'creature_default_trainer', 'npc_vendor', 'game_event_npc_vendor', 'reference_loot_template', 'item_loot_template', 'creature_loot_template', 'gameobject_loot_template', 'mail_loot_template', 'disenchant_loot_template', 'fishing_loot_template', 'skinning_loot_template', 'milling_loot_template', 'prospecting_loot_template', 'pickpocketing_loot_template']; protected $tblDependancyTC = ['playercreateinfo_skills', 'playercreateinfo_item', 'skill_discovery_template', 'achievement_reward', 'skill_perfect_item_template', 'item_template', 'gameobject_template', 'quest_template', 'quest_template_addon', 'creature_template', 'creature', 'npc_trainer', 'npc_vendor', 'game_event_npc_vendor', 'reference_loot_template', 'item_loot_template', 'creature_loot_template', 'gameobject_loot_template', 'mail_loot_template', 'disenchant_loot_template', 'fishing_loot_template', 'skinning_loot_template', 'milling_loot_template', 'prospecting_loot_template', 'pickpocketing_loot_template'];
protected $dbcSourceFiles = ['charstartoutfit', 'talent', 'spell', 'skilllineability', 'itemextendedcost', 'lock']; protected $dbcSourceFiles = ['charstartoutfit', 'talent', 'spell', 'skilllineability', 'itemextendedcost', 'lock'];
private $srcBuffer = []; private $srcBuffer = [];
@@ -118,6 +118,14 @@ SqlGen::register(new class extends SetupScript
$this->titleAchievement(); # 12: Achievement # $this->titleAchievement(); # 12: Achievement #
$this->titleCustomString(); # 13: Source-String # $this->titleCustomString(); # 13: Source-String #
/************/
/* Itemsets */
/************/
CLI::write(' - Itemsets');
$this->itemset(); # Meta category .. inherit from items #
$t = new Timer(500); $t = new Timer(500);
foreach ($this->srcBuffer as $type => $data) foreach ($this->srcBuffer as $type => $data)
@@ -184,7 +192,7 @@ SqlGen::register(new class extends SetupScript
$str = ''; $str = '';
foreach ($rows as &$r) foreach ($rows as &$r)
{ {
array_walk($r, function(&$x) {$x = (int)$x < 1 ? 'NULL' : $x; }); array_walk($r, function(&$x) {$x = (int)$x === 0 ? 'NULL' : $x; });
$str .= '(' . implode(', ', $r) . '),'; $str .= '(' . implode(', ', $r) . '),';
} }
@@ -1156,6 +1164,43 @@ SqlGen::register(new class extends SetupScript
foreach (Lang::game('pvpSources') as $src => $__) foreach (Lang::game('pvpSources') as $src => $__)
$this->pushBuffer(Type::TITLE, $src, SRC_CUSTOM_STRING, $src); $this->pushBuffer(Type::TITLE, $src, SRC_CUSTOM_STRING, $src);
} }
private function itemset() : void
{
// 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');
$metaSrc = [];
foreach ($sets as $id => $set)
{
$available = true;
for ($i = 1; $i < 11; $i++)
{
if (!$set['item'.$i])
continue;
if (!isset($this->srcBuffer[Type::ITEM][$set['item'.$i]]))
{
// Todo: remove HACK - neck in Zul'Gurub set ist created by spell from onUse item trigger
if ($set['contentGroup'] == 11)
continue;
$available = false;
break;
}
$metaSrc[$id] = ($metaSrc[$id] ?? []) + $this->srcBuffer[Type::ITEM][$set['item'.$i]][6];
}
if (!$available)
unset($metaSrc[$id]);
}
foreach($metaSrc as $id => $bits)
foreach ($bits as $src => $bit)
$this->pushBuffer(Type::ITEMSET, $id, $src, $bit);
}
}); });
?> ?>

View File

@@ -0,0 +1,2 @@
ALTER TABLE `aowow_source`
MODIFY `typeId` mediumint(9) signed NOT NULL AFTER `type`;