diff --git a/endpoints/class/class.php b/endpoints/class/class.php index cef7395e..346cb5c0 100644 --- a/endpoints/class/class.php +++ b/endpoints/class/class.php @@ -186,9 +186,7 @@ class ClassBaseResponse extends TemplateResponse implements ICache // tab: items (grouped) $conditions = array( - ['requiredClass', 0, '>'], ['requiredClass', $cl->toMask(), '&'], - [['requiredClass', ChrClass::MASK_ALL, '&'], ChrClass::MASK_ALL, '!'], ['itemset', 0] ); diff --git a/endpoints/item/item.php b/endpoints/item/item.php index 89859ce4..1f9f4123 100644 --- a/endpoints/item/item.php +++ b/endpoints/item/item.php @@ -920,7 +920,7 @@ class ItemBaseResponse extends TemplateResponse implements ICache ['itemLevel', $_ilvl - 15, '>'], ['itemLevel', $_ilvl + 15, '<'], ['quality', $this->subject->getField('quality')], - ['requiredClass', $this->subject->getField('requiredClass') ?: -1] // todo: fix db data in setup and not on fetch + ['requiredClass', $this->subject->getField('requiredClass')] ] ] ); diff --git a/includes/dbtypes/item.class.php b/includes/dbtypes/item.class.php index 1a0ef207..f0aa9c01 100644 --- a/includes/dbtypes/item.class.php +++ b/includes/dbtypes/item.class.php @@ -63,19 +63,6 @@ class ItemList extends DBTypeList $this->relEnchant = $miscData['extraOpts']['relEnchant']; } - // unify those pesky masks - $_ = &$_curTpl['requiredClass']; - $_ &= ChrClass::MASK_ALL; - if ($_ < 0 || $_ == ChrClass::MASK_ALL) - $_ = 0; - unset($_); - - $_ = &$_curTpl['requiredRace']; - $_ &= ChrRace::MASK_ALL; - if ($_ < 0 || $_ == ChrRace::MASK_ALL) - $_ = 0; - unset($_); - // sources for ($i = 1; $i < 25; $i++) { @@ -439,7 +426,7 @@ class ItemList extends DBTypeList $data[$this->id]['nslots'] = $x; $_ = $this->curTpl['requiredRace']; - if ($_ && $_ & ChrRace::MASK_ALLIANCE != ChrRace::MASK_ALLIANCE && $_ & ChrRace::MASK_HORDE != ChrRace::MASK_HORDE) + if (ChrRace::sideFromMask($_) != SIDE_BOTH) $data[$this->id]['reqrace'] = $_; if ($_ = $this->curTpl['requiredClass']) @@ -1972,8 +1959,8 @@ class ItemListFilter extends Filter 149 => [parent::CR_CALLBACK, 'cbDropsInInstance', SRC_FLAG_RAID_DROP, 4, ], // dropsinheroic10 [heroicraid-any] 150 => [parent::CR_CALLBACK, 'cbDropsInInstance', SRC_FLAG_RAID_DROP, 8, ], // dropsinheroic25 [heroicraid-any] 151 => [parent::CR_NUMERIC, 'id', NUM_CAST_INT, true ], // id - 152 => [parent::CR_CALLBACK, 'cbClassRaceSpec', 'requiredClass', ChrClass::MASK_ALL], // classspecific [enum] - 153 => [parent::CR_CALLBACK, 'cbClassRaceSpec', 'requiredRace', ChrRace::MASK_ALL ], // racespecific [enum] + 152 => [parent::CR_CALLBACK, 'cbClassRaceSpec', 'requiredClass' ], // classspecific [enum] + 153 => [parent::CR_CALLBACK, 'cbClassRaceSpec', 'requiredRace' ], // racespecific [enum] 154 => [parent::CR_FLAG, 'flags', ITEM_FLAG_REFUNDABLE ], // refundable 155 => [parent::CR_FLAG, 'flags', ITEM_FLAG_USABLE_ARENA ], // usableinarenas 156 => [parent::CR_FLAG, 'flags', ITEM_FLAG_USABLE_SHAPED ], // usablewhenshapeshifted @@ -2144,17 +2131,14 @@ class ItemListFilter extends Filter // side if ($_v['si']) { - $excl = [['requiredRace', ChrRace::MASK_ALL, '&'], ChrRace::MASK_ALL, '!']; - $incl = ['OR', ['requiredRace', 0], [['requiredRace', ChrRace::MASK_ALL, '&'], ChrRace::MASK_ALL]]; - - // we sanitized v['si'] earlier .. right? $parts[] = match ($_v['si']) { - SIDE_BOTH => ['OR', [['flagsExtra', 0x3, '&'], [0, 3]], ['requiredRace', ChrRace::MASK_ALL], ['requiredRace', 0]], - SIDE_HORDE => ['AND', [['flagsExtra', 0x3, '&'], [0, 1]], ['OR', $incl, ['requiredRace', ChrRace::MASK_HORDE, '&']]], - -SIDE_HORDE => ['OR', [['flagsExtra', 0x3, '&'], 1], ['AND', $excl, ['requiredRace', ChrRace::MASK_HORDE, '&']]], - SIDE_ALLIANCE => ['AND', [['flagsExtra', 0x3, '&'], [0, 2]], ['OR', $incl, ['requiredRace', ChrRace::MASK_ALLIANCE, '&']]], - -SIDE_ALLIANCE => ['OR', [['flagsExtra', 0x3, '&'], 2], ['AND', $excl, ['requiredRace', ChrRace::MASK_ALLIANCE, '&']]], + // in theory an item could be requiring orc|nightelf etc. and would then be SIDE_BOTH without cleanly fitting the filters below, but in that case; WTF are you doing?! + SIDE_BOTH => ['AND', [['flagsExtra', 0x3, '&'], [0, 3]], ['requiredRace', 0]], + -SIDE_HORDE => ['OR', [['flagsExtra', 0x3, '&'], 1], ['requiredRace', ChrRace::MASK_HORDE, '&']], + -SIDE_ALLIANCE => ['OR', [['flagsExtra', 0x3, '&'], 2], ['requiredRace', ChrRace::MASK_ALLIANCE, '&']], + SIDE_HORDE => ['AND', [['flagsExtra', 0x3, '&'], [0, 1]], ['OR', ['requiredRace', 0], ['requiredRace', ChrRace::MASK_HORDE, '&']]], + SIDE_ALLIANCE => ['AND', [['flagsExtra', 0x3, '&'], [0, 2]], ['OR', ['requiredRace', 0], ['requiredRace', ChrRace::MASK_ALLIANCE, '&']]], }; } @@ -2276,16 +2260,16 @@ class ItemListFilter extends Filter return ['id', $items]; } - protected function cbClassRaceSpec(int $cr, int $crs, string $crv, string $field, int $mask) : ?array + protected function cbClassRaceSpec(int $cr, int $crs, string $crv, string $field) : ?array { if (!isset(self::$enums[$cr][$crs])) return null; $_ = self::$enums[$cr][$crs]; if (is_bool($_)) - return $_ ? ['AND', [[$field, $mask, '&'], $mask, '!'], [$field, 0, '>']] : ['OR', [[$field, $mask, '&'], $mask], [$field, 0]]; + return $_ ? [$field, 0, '>'] : [$field, 0]; else if (is_int($_)) - return ['AND', [[$field, $mask, '&'], $mask, '!'], [$field, 1 << ($_ - 1), '&']]; + return [$field, 1 << ($_ - 1), '&']; return null; } diff --git a/setup/sql/01-db_structure.sql b/setup/sql/01-db_structure.sql index fb755c88..e57e99e0 100644 --- a/setup/sql/01-db_structure.sql +++ b/setup/sql/01-db_structure.sql @@ -1306,8 +1306,8 @@ CREATE TABLE `aowow_items` ( `repairPrice` int(10) unsigned NOT NULL, `slot` tinyint(4) NOT NULL, `slotBak` tinyint(3) unsigned NOT NULL DEFAULT 0, - `requiredClass` int(11) NOT NULL DEFAULT -1, - `requiredRace` int(11) NOT NULL DEFAULT -1, + `requiredClass` smallint(5) unsigned NOT NULL DEFAULT 0, + `requiredRace` smallint(5) unsigned NOT NULL DEFAULT 0, `itemLevel` smallint(5) unsigned NOT NULL DEFAULT 0, `requiredLevel` tinyint(3) unsigned NOT NULL DEFAULT 0, `requiredSkill` smallint(5) unsigned NOT NULL DEFAULT 0, diff --git a/setup/sql/02-db_initial_data.sql b/setup/sql/02-db_initial_data.sql index 9f7ea58b..b679437b 100644 --- a/setup/sql/02-db_initial_data.sql +++ b/setup/sql/02-db_initial_data.sql @@ -71,7 +71,7 @@ UNLOCK TABLES; LOCK TABLES `aowow_dbversion` WRITE; /*!40000 ALTER TABLE `aowow_dbversion` DISABLE KEYS */; -INSERT INTO `aowow_dbversion` VALUES (1768385061,0,NULL,NULL); +INSERT INTO `aowow_dbversion` VALUES (1768517244,0,NULL,NULL); /*!40000 ALTER TABLE `aowow_dbversion` ENABLE KEYS */; UNLOCK TABLES; diff --git a/setup/sql/updates/1768517243_01.sql b/setup/sql/updates/1768517243_01.sql new file mode 100644 index 00000000..e2fa5d5c --- /dev/null +++ b/setup/sql/updates/1768517243_01.sql @@ -0,0 +1,9 @@ +UPDATE `aowow_items` SET + `requiredClass` = IF((`requiredClass` & 1535) = 1535, 0, `requiredClass` & 1535), + `requiredRace` = IF((`requiredRace` & 1791) = 1791, 0, `requiredRace` & 1791) +; + +ALTER TABLE `aowow_items` + MODIFY COLUMN `requiredClass` smallint(5) unsigned NOT NULL DEFAULT 0, + MODIFY COLUMN `requiredRace` smallint(5) unsigned NOT NULL DEFAULT 0 +; diff --git a/setup/tools/filegen/enchants.ss.php b/setup/tools/filegen/enchants.ss.php index a33f0b7a..4bbb0ad8 100644 --- a/setup/tools/filegen/enchants.ss.php +++ b/setup/tools/filegen/enchants.ss.php @@ -203,10 +203,10 @@ CLISetup::registerSetup("build", new class extends SetupScript if ($cI->getField('quality') > $ench['quality']) $ench['quality'] = $cI->getField('quality'); - if ($cI->getField('requiredClass') > 0) + if ($rc = $cI->getField('requiredClass')) { - $ench['classes'] = $cI->getField('requiredClass'); - $ench['jsonequip']['classes'] = $cI->getField('requiredClass'); + $ench['classes'] = $rc; + $ench['jsonequip']['classes'] = $rc; } if (!isset($ench['jsonequip']['reqlevel'])) diff --git a/setup/tools/sqlgen/items.ss.php b/setup/tools/sqlgen/items.ss.php index 640a65bd..b2a22193 100644 --- a/setup/tools/sqlgen/items.ss.php +++ b/setup/tools/sqlgen/items.ss.php @@ -46,7 +46,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript BuyCount, BuyPrice, SellPrice, 0 AS repairPrice, InventoryType AS slot, InventoryType AS slotBak, - AllowableClass, AllowableRace, + IF((`AllowableClass` & 1535) = 1535, 0, `AllowableClass` & 1535) AS "requiredClass", + IF((`AllowableRace` & 1791) = 1791, 0, `AllowableRace` & 1791) AS "requiredRace", ItemLevel, RequiredLevel, RequiredSkill, RequiredSkillRank, @@ -190,7 +191,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript 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'); // 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 AND (requiredClass & 0x5FF) <> 0x5FF'); + DB::Aowow()->query('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'); diff --git a/setup/tools/sqlgen/quests.ss.php b/setup/tools/sqlgen/quests.ss.php index bbb9c9fe..7f56eb00 100644 --- a/setup/tools/sqlgen/quests.ss.php +++ b/setup/tools/sqlgen/quests.ss.php @@ -45,8 +45,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript IF(d.entry IS NULL, 0, 134217728) + -- disabled IF(q.Flags & 16384, 536870912, 0) -- unavailable ) AS cuFlags, - IFNULL(qa.AllowableClasses, 0), - AllowableRaces, + IFNULL(IF((qa.`AllowableClasses` & 1535) = 1535, 0, qa.`AllowableClasses` & 1535), 0) AS "reqClassMask", + IF((`AllowableRaces` & 1791) = 1791, 0, `AllowableRaces` & 1791) AS "reqRaceMask", IFNULL(qa.RequiredSkillId, 0), IFNULL(qa.RequiredSkillPoints, 0), RequiredFactionId1, RequiredFactionId2, RequiredFactionValue1, RequiredFactionValue2,