From 085c10f3e53a86481b71076d1fd916ac321648cb Mon Sep 17 00:00:00 2001 From: Helias Date: Thu, 18 Jun 2026 00:35:27 +0200 Subject: [PATCH] feat: align creature table --- includes/game.php | 2 +- includes/types/item.class.php | 2 +- pages/event.php | 4 ++-- pages/npc.php | 6 +++--- pages/quest.php | 2 +- setup/tools/sqlgen/pet.ss.php | 2 +- setup/tools/sqlgen/source.ss.php | 2 +- setup/tools/sqlgen/spawns.ss.php | 8 ++++---- setup/tools/sqlgen/taxi.ss.php | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/includes/game.php b/includes/game.php index 52254b866..9cbec24dc 100644 --- a/includes/game.php +++ b/includes/game.php @@ -322,7 +322,7 @@ public static function getWorldPosForGUID(int $type, int ...$guids) : array switch ($type) { case Type::NPC: - $result = DB::World()->select('SELECT `guid` AS ARRAY_KEY, `id1`, `map` AS `mapId`, `position_x` AS `posX`, `position_y` AS `posY` FROM creature WHERE `guid` IN (?a)', $guids); + $result = DB::World()->select('SELECT `guid` AS ARRAY_KEY, `id`, `map` AS `mapId`, `position_x` AS `posX`, `position_y` AS `posY` FROM creature WHERE `guid` IN (?a)', $guids); break; case Type::OBJECT: $result = DB::World()->select('SELECT `guid` AS ARRAY_KEY, `id`, `map` AS `mapId`, `position_x` AS `posX`, `position_y` AS `posY` FROM gameobject WHERE `guid` IN (?a)', $guids); diff --git a/includes/types/item.class.php b/includes/types/item.class.php index eef66bfe3..28fd38abe 100644 --- a/includes/types/item.class.php +++ b/includes/types/item.class.php @@ -110,7 +110,7 @@ public function getExtendedCost($filter = [], &$reqRating = []) $rawEntries = DB::World()->select(' SELECT nv.item, nv.entry, 0 AS eventId, nv.maxcount, nv.extendedCost, nv.incrtime FROM npc_vendor nv WHERE {nv.entry IN (?a) AND} nv.item IN (?a) UNION - SELECT genv.item, c.id1 AS `entry`, ge.eventEntry AS eventId, genv.maxcount, genv.extendedCost, genv.incrtime FROM game_event_npc_vendor genv LEFT JOIN game_event ge ON genv.eventEntry = ge.eventEntry JOIN creature c ON c.guid = genv.guid WHERE {c.id1 IN (?a) AND} genv.item IN (?a)', + SELECT genv.item, c.id AS `entry`, ge.eventEntry AS eventId, genv.maxcount, genv.extendedCost, genv.incrtime FROM game_event_npc_vendor genv LEFT JOIN game_event ge ON genv.eventEntry = ge.eventEntry JOIN creature c ON c.guid = genv.guid WHERE {c.id IN (?a) AND} genv.item IN (?a)', empty($filter[Type::NPC]) || !is_array($filter[Type::NPC]) ? DBSIMPLE_SKIP : $filter[Type::NPC], array_keys($this->templates), empty($filter[Type::NPC]) || !is_array($filter[Type::NPC]) ? DBSIMPLE_SKIP : $filter[Type::NPC], diff --git a/pages/event.php b/pages/event.php index 601e29e3a..50e85eb3e 100644 --- a/pages/event.php +++ b/pages/event.php @@ -109,7 +109,7 @@ protected function generateContent() $hasFilter = in_array($this->hId, [372, 283, 285, 353, 420, 400, 284, 201, 374, 409, 141, 324, 321, 424, 335, 327, 341, 181, 404, 398, 301]); // tab: npcs - if ($npcIds = DB::World()->selectCol('SELECT id1 AS ARRAY_KEY, IF(ec.eventEntry > 0, 1, 0) AS added FROM creature c, game_event_creature ec WHERE ec.guid = c.guid AND ABS(ec.eventEntry) = ?d', $this->eId)) + if ($npcIds = DB::World()->selectCol('SELECT id AS ARRAY_KEY, IF(ec.eventEntry > 0, 1, 0) AS added FROM creature c, game_event_creature ec WHERE ec.guid = c.guid AND ABS(ec.eventEntry) = ?d', $this->eId)) { $creatures = new CreatureList(array(['id', array_keys($npcIds)])); if (!$creatures->error) @@ -208,7 +208,7 @@ protected function generateContent() { // vendor $cIds = $creatures->getFoundIDs(); - if ($sells = DB::World()->selectCol('SELECT item FROM npc_vendor nv WHERE entry IN (?a) UNION SELECT item FROM game_event_npc_vendor genv JOIN creature c ON genv.guid = c.guid WHERE c.id1 IN (?a)', $cIds, $cIds)) + if ($sells = DB::World()->selectCol('SELECT item FROM npc_vendor nv WHERE entry IN (?a) UNION SELECT item FROM game_event_npc_vendor genv JOIN creature c ON genv.guid = c.guid WHERE c.id IN (?a)', $cIds, $cIds)) $itemCnd[] = ['id', $sells]; } diff --git a/pages/npc.php b/pages/npc.php index d79920a2d..1d523650c 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -126,7 +126,7 @@ protected function generateContent() $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); // Event (ignore events, where the object only gets removed) - if ($_ = DB::World()->selectCol('SELECT DISTINCT ge.`eventEntry` FROM game_event ge, game_event_creature gec, creature c WHERE ge.`eventEntry` = gec.`eventEntry` AND c.`guid` = gec.`guid` AND c.`id1` = ?d', $this->typeId)) + if ($_ = DB::World()->selectCol('SELECT DISTINCT ge.`eventEntry` FROM game_event ge, game_event_creature gec, creature c WHERE ge.`eventEntry` = gec.`eventEntry` AND c.`guid` = gec.`guid` AND c.`id` = ?d', $this->typeId)) { $this->extendGlobalIds(Type::WORLDEVENT, ...$_); $ev = []; @@ -382,7 +382,7 @@ protected function generateContent() if (!$sai->prepare()) // no smartAI found .. check per guid { // at least one of many - $guids = DB::World()->selectCol('SELECT `guid` FROM creature WHERE `id1` = ?d', $this->typeId); + $guids = DB::World()->selectCol('SELECT `guid` FROM creature WHERE `id` = ?d', $this->typeId); while ($_ = array_pop($guids)) { $sai = new SmartAI(SmartAI::SRC_TYPE_CREATURE, -$_, ['baseEntry' => $this->typeId, 'title' => ' [small](for GUID: '.$_.')[/small]']); @@ -634,7 +634,7 @@ protected function generateContent() } // tab: sells - if ($sells = DB::World()->selectCol('SELECT item FROM npc_vendor nv WHERE entry = ?d UNION SELECT item FROM game_event_npc_vendor genv JOIN creature c ON genv.guid = c.guid WHERE c.id1 = ?d', $this->typeId, $this->typeId)) + if ($sells = DB::World()->selectCol('SELECT item FROM npc_vendor nv WHERE entry = ?d UNION SELECT item FROM game_event_npc_vendor genv JOIN creature c ON genv.guid = c.guid WHERE c.id = ?d', $this->typeId, $this->typeId)) { $soldItems = new ItemList(array(['id', $sells])); if (!$soldItems->error) diff --git a/pages/quest.php b/pages/quest.php index 59d6a7458..440076c74 100644 --- a/pages/quest.php +++ b/pages/quest.php @@ -631,7 +631,7 @@ protected function generateContent() // so yeah .. no recursion checking $vendors = DB::World()->selectCol(' SELECT nv.entry FROM npc_vendor nv WHERE nv.item = ?d UNION - SELECT c.id1 FROM game_event_npc_vendor genv JOIN creature c ON c.guid = genv.guid WHERE genv.item = ?d', + SELECT c.id FROM game_event_npc_vendor genv JOIN creature c ON c.guid = genv.guid WHERE genv.item = ?d', $itemId, $itemId ); foreach ($vendors as $v) diff --git a/setup/tools/sqlgen/pet.ss.php b/setup/tools/sqlgen/pet.ss.php index d48bb567b..11da37436 100644 --- a/setup/tools/sqlgen/pet.ss.php +++ b/setup/tools/sqlgen/pet.ss.php @@ -50,7 +50,7 @@ public function generate(array $ids = []) : bool MAX(ct.maxlevel) AS maxLevel, IF(ct.type_flags & 0x10000, 1, 0) AS exotic FROM creature_template ct - JOIN creature c ON ct.entry = c.id1 + JOIN creature c ON ct.entry = c.id WHERE ct.type_flags & 0x1 GROUP BY ct.family' ); diff --git a/setup/tools/sqlgen/source.ss.php b/setup/tools/sqlgen/source.ss.php index 026ea67f8..f89c38967 100644 --- a/setup/tools/sqlgen/source.ss.php +++ b/setup/tools/sqlgen/source.ss.php @@ -521,7 +521,7 @@ private function itemVendor() : void $vendors = DB::World()->select( '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) GROUP BY `item`, `npc` UNION - SELECT `item`, c.`id1` 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 + 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 JOIN item_template it ON it.`entry` = n.`item` GROUP BY `item`, `npc`', $xCostIds, $xCostIds diff --git a/setup/tools/sqlgen/spawns.ss.php b/setup/tools/sqlgen/spawns.ss.php index a12e1b98b..90284c1ed 100644 --- a/setup/tools/sqlgen/spawns.ss.php +++ b/setup/tools/sqlgen/spawns.ss.php @@ -160,7 +160,7 @@ public function generate(array $ids = []) : bool { // get vehicle template accessories $accessories = DB::World()->select( - '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.`id1` = vta.`entry` GROUP BY `accessory_entry`, c.`guid` UNION + '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`' ); @@ -212,7 +212,7 @@ private function creature() : array { // [guid, type, typeId, map, posX, posY [, respawn, spawnMask, phaseMask, areaId, floor, pathId]] return DB::World()->select( - 'SELECT c.`guid`, ?d AS `type`, c.`id1` 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`, 0) AS `pathId` + '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`, 0) AS `pathId` FROM creature c LEFT JOIN creature_addon ca ON ca.guid = c.guid', Type::NPC @@ -278,10 +278,10 @@ private function waypoints() : array return DB::World()->select( 'SELECT c.`guid`, w.`entry` AS `creatureOrPath`, w.`pointId` AS `point`, c.`zoneId` AS `areaId`, c.`map`, w.`waittime` AS `wait`, w.`location_x` AS `posX`, w.`location_y` AS `posY` FROM creature c - JOIN script_waypoint w ON c.`id1` = w.`entry` UNION + JOIN script_waypoint w ON c.`id` = w.`entry` UNION SELECT c.`guid`, w.`entry` AS `creatureOrPath`, w.`pointId` AS `point`, c.`zoneId` AS `areaId`, c.`map`, 0 AS `wait`, w.`position_x` AS `posX`, w.`position_y` AS `posY` FROM creature c - JOIN waypoints w ON c.`id1` = w.`entry` UNION + JOIN waypoints w ON c.`id` = w.`entry` UNION 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` diff --git a/setup/tools/sqlgen/taxi.ss.php b/setup/tools/sqlgen/taxi.ss.php index 06c5899c5..6ac232b41 100644 --- a/setup/tools/sqlgen/taxi.ss.php +++ b/setup/tools/sqlgen/taxi.ss.php @@ -82,7 +82,7 @@ public function generate(array $ids = []) : bool // 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.id1 = ct.entry WHERE ct.npcflag & ?d OR c.npcflag & ?d', + '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', NPC_FLAG_FLIGHT_MASTER, NPC_FLAG_FLIGHT_MASTER );