Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion includes/game.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion includes/types/item.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
4 changes: 2 additions & 2 deletions pages/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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];
}

Expand Down
6 changes: 3 additions & 3 deletions pages/npc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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]']);
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pages/quest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup/tools/sqlgen/pet.ss.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
Expand Down
2 changes: 1 addition & 1 deletion setup/tools/sqlgen/source.ss.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions setup/tools/sqlgen/spawns.ss.php
Original file line number Diff line number Diff line change
Expand Up @@ -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`'
);

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion setup/tools/sqlgen/taxi.ss.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand Down