Skip to content

Commit

Permalink
DB/Structure (thx @Carbenium for the heads up & suggestions)
Browse files Browse the repository at this point in the history
  * adapted structure to TDB 335.59
  * dropped questItem[1-6] fields from ?_creature and ?_object (why were they even there)

 - removed a function-stub from Util (already forgot, what it was supposed to achieve)
  • Loading branch information
Sarjuuk committed Jul 19, 2015
1 parent 11ab3e0 commit 5b8a862
Show file tree
Hide file tree
Showing 18 changed files with 166 additions and 170 deletions.
Binary file modified README.md
Binary file not shown.
2 changes: 1 addition & 1 deletion includes/shared.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

define('AOWOW_REVISION', 5);
define('AOWOW_REVISION', 6);
define('CLI', PHP_SAPI === 'cli');


Expand Down
10 changes: 0 additions & 10 deletions includes/utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -1541,16 +1541,6 @@ public static function getCCTableParent($type)
}
}

public static function createShowOnMap()
{
/*
quest: "Quest Givers",
daily: "Quest Givers (Daily)",
alliancequests: "Quest Givers",
hordequests: "Quest Givers",
*/
}

public static function getServerConditions($srcType, $srcGroup = null, $srcEntry = null)
{
if (!$srcGroup && !$srcEntry)
Expand Down
4 changes: 2 additions & 2 deletions pages/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@ protected function generateContent()
{
while ($next)
{
if ($row = DB::World()->selectRow('SELECT *, text as Text_loc0 FROM page_text pt LEFT JOIN locales_page_text lpt ON pt.entry = lpt.entry WHERE pt.entry = ?d', $next))
if ($row = DB::World()->selectRow('SELECT *, Text as Text_loc0 FROM page_text pt LEFT JOIN locales_page_text lpt ON pt.ID = lpt.entry WHERE pt.ID = ?d', $next))
{
$next = $row['next_page'];
$next = $row['NextPageID'];
$this->pageText[] = Util::parseHtmlText(Util::localizedString($row, 'Text'));
}
else
Expand Down
14 changes: 7 additions & 7 deletions pages/npc.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,14 @@ protected function generateContent()
if ($this->subject->getField('npcflag') & NPC_FLAG_TRAINER)
{
$teachQuery = '
SELECT IFNULL(t2.spell, t1.spell) AS ARRAY_KEY,
IFNULL(t2.spellcost, t1.spellcost) AS cost,
IFNULL(t2.reqskill, t1.reqskill) AS reqSkillId,
IFNULL(t2.reqskillvalue, t1.reqskillvalue) AS reqSkillValue,
IFNULL(t2.reqlevel, t1.reqlevel) AS reqLevel
SELECT IFNULL(t2.SpellID, t1.SpellID) AS ARRAY_KEY,
IFNULL(t2.MoneyCost, t1.MoneyCost) AS cost,
IFNULL(t2.ReqSkillLine, t1.ReqSkillLine) AS reqSkillId,
IFNULL(t2.ReqSkillRank, t1.ReqSkillRank) AS reqSkillValue,
IFNULL(t2.ReqLevel, t1.ReqLevel) AS reqLevel
FROM npc_trainer t1
LEFT JOIN npc_trainer t2 ON t2.entry = IF(t1.spell < 0, -t1.spell, null)
WHERE t1.entry = ?d
LEFT JOIN npc_trainer t2 ON t2.ID = IF(t1.SpellID < 0, -t1.SpellID, null)
WHERE t1.ID = ?d
';

if ($tSpells = DB::World()->select($teachQuery, $this->typeId))
Expand Down
4 changes: 2 additions & 2 deletions pages/object.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ protected function generateContent()
{
while ($next)
{
if ($row = DB::World()->selectRow('SELECT *, text as Text_loc0 FROM page_text pt LEFT JOIN locales_page_text lpt ON pt.entry = lpt.entry WHERE pt.entry = ?d', $next))
if ($row = DB::World()->selectRow('SELECT *, Text as Text_loc0 FROM page_text pt LEFT JOIN locales_page_text lpt ON pt.ID = lpt.entry WHERE pt.ID = ?d', $next))
{
$next = $row['next_page'];
$next = $row['NextPageID'];
$pageText[] = Util::parseHtmlText(Util::localizedString($row, 'Text'));
}
else
Expand Down
8 changes: 4 additions & 4 deletions pages/skill.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ protected function generateContent()
{
$list = [];
if (!empty(Util::$trainerTemplates[TYPE_SKILL][$this->typeId]))
$list = DB::World()->selectCol('SELECT DISTINCT entry FROM npc_trainer WHERE spell IN (?a) AND entry < 200000', Util::$trainerTemplates[TYPE_SKILL][$this->typeId]);
$list = DB::World()->selectCol('SELECT DISTINCT ID FROM npc_trainer WHERE SpellID IN (?a) AND ID < 200000', Util::$trainerTemplates[TYPE_SKILL][$this->typeId]);
else
{
$mask = 0;
Expand All @@ -266,10 +266,10 @@ protected function generateContent()
);

$list = $spellIds ? DB::World()->selectCol('
SELECT IF(t1.entry > 200000, t2.entry, t1.entry)
SELECT IF(t1.ID > 200000, t2.ID, t1.ID)
FROM npc_trainer t1
LEFT JOIN npc_trainer t2 ON t2.spell = -t1.entry
WHERE t1.spell IN (?a)',
LEFT JOIN npc_trainer t2 ON t2.SpellID = -t1.ID
WHERE t1.SpellID IN (?a)',
$spellIds
) : [];
}
Expand Down
8 changes: 4 additions & 4 deletions pages/spell.php
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ protected function generateContent()
}

if ($tt)
$list = DB::World()->selectCol('SELECT DISTINCT entry FROM npc_trainer WHERE spell IN (?a) AND entry < 200000', $tt);
$list = DB::World()->selectCol('SELECT DISTINCT ID FROM npc_trainer WHERE SpellID IN (?a) AND ID < 200000', $tt);
else
{
$mask = 0;
Expand All @@ -1019,10 +1019,10 @@ protected function generateContent()
$mask |= 1 << $idx;

$list = DB::World()->selectCol('
SELECT IF(t1.entry > 200000, t2.entry, t1.entry)
SELECT IF(t1.ID > 200000, t2.ID, t1.ID)
FROM npc_trainer t1
LEFT JOIN npc_trainer t2 ON t2.spell = -t1.entry
WHERE t1.spell = ?d',
LEFT JOIN npc_trainer t2 ON t2.SpellID = -t1.ID
WHERE t1.SpellID IN (?a)',
$this->typeId
);
}
Expand Down
12 changes: 0 additions & 12 deletions setup/db_structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,6 @@ CREATE TABLE `aowow_creature` (
`armorMin` mediumint(8) unsigned NOT NULL DEFAULT '1',
`armorMax` mediumint(8) unsigned NOT NULL DEFAULT '1',
`racialLeader` tinyint(3) unsigned NOT NULL DEFAULT '0',
`questItem1` int(10) unsigned NOT NULL DEFAULT '0',
`questItem2` int(10) unsigned NOT NULL DEFAULT '0',
`questItem3` int(10) unsigned NOT NULL DEFAULT '0',
`questItem4` int(10) unsigned NOT NULL DEFAULT '0',
`questItem5` int(10) unsigned NOT NULL DEFAULT '0',
`questItem6` int(10) unsigned NOT NULL DEFAULT '0',
`mechanicImmuneMask` int(10) unsigned NOT NULL DEFAULT '0',
`flagsExtra` int(10) unsigned NOT NULL DEFAULT '0',
`scriptName` varchar(50) NOT NULL DEFAULT '',
Expand Down Expand Up @@ -1273,12 +1267,6 @@ CREATE TABLE `aowow_objects` (
`faction` smallint(5) unsigned NOT NULL DEFAULT '0',
`flags` int(10) unsigned NOT NULL DEFAULT '0',
`cuFlags` int(10) unsigned NOT NULL DEFAULT '0',
`questItem1` int(11) unsigned NOT NULL DEFAULT '0',
`questItem2` int(11) unsigned NOT NULL DEFAULT '0',
`questItem3` int(11) unsigned NOT NULL DEFAULT '0',
`questItem4` int(11) unsigned NOT NULL DEFAULT '0',
`questItem5` int(11) unsigned NOT NULL DEFAULT '0',
`questItem6` int(11) unsigned NOT NULL DEFAULT '0',
`lootId` mediumint(8) unsigned NOT NULL DEFAULT '0',
`lockId` smallint(5) unsigned NOT NULL DEFAULT '0',
`reqSkill` smallint(5) unsigned NOT NULL DEFAULT '0',
Expand Down
2 changes: 1 addition & 1 deletion setup/tools/sqlGen.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SqlGen
'creature' => [null, null, null, ['creature_template', 'locales_creature', 'creature_classlevelstats', 'instance_encounters']],
'currencies' => [null, null, null, ['item_template', 'locales_item']],
'events' => [null, null, null, ['game_event', 'game_event_prerequisite']],
'objects' => [null, null, null, ['gameobject_template', 'locales_gameobject']],
'objects' => [null, null, null, ['gameobject_template', 'locales_gameobject', 'gameobject_questitem']],
'pet' => [null, null, null, ['creature_template', 'creature']],
'quests' => [null, null, null, ['quest_template', 'locales_quest', 'game_event', 'game_event_seasonal_questrelation']],
'quests_startend' => [null, null, null, ['creature_queststarter', 'creature_questender', 'game_event_creature_quest', 'gameobject_queststarter', 'gameobject_questender', 'game_event_gameobject_quest', 'item_template']],
Expand Down
1 change: 0 additions & 1 deletion setup/tools/sqlgen/creature.func.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ function creature(array $ids = [])
min.basearmor * ct.ArmorModifier AS armorMin,
max.basearmor * ct.ArmorModifier AS armorMax,
RacialLeader,
questItem1, questItem2, questItem3, questItem4, questItem5, questItem6,
mechanic_immune_mask,
flags_extra,
ScriptName
Expand Down
56 changes: 30 additions & 26 deletions setup/tools/sqlgen/objects.func.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/* deps:
* gameobject_template
* locales_gameobject
* gameobject_questitem
*/


Expand All @@ -24,49 +25,52 @@ function objects(array $ids = [])
go.entry,
`type`,
IF(`type` = 2, -2, -- quests 1
IF(`type` = 8 AND data0 IN (1, 2, 3, 4, 1552), -6, -- tools
IF(`type` = 3 AND questitem1 <> 0, -2, -- quests 2
IF(`type` = 8 AND Data0 IN (1, 2, 3, 4, 1552), -6, -- tools
IF(`type` = 3 AND IFNULL(gqi.ItemId, 0) <> 0, -2, -- quests 2
IF(`type` IN (3, 9, 25), `type`, 0)))), -- regular chests, books, pools
0 AS event, -- linked worldevent
displayId,
name, name_loc2, name_loc3, name_loc6, name_loc8,
faction,
flags,
0 AS cuFlags, -- custom Flags
questItem1, questItem2, questItem3, questItem4, questItem5, questItem6,
IF(`type` IN (3, 25), data1, 0), -- lootId
IF(`type` IN (2, 3, 6, 10, 13, 24, 26), data0, IF(`type` IN (0, 1), data1, 0)), -- lockId
IF(`type` IN (3, 25), Data1, 0), -- lootId
IF(`type` IN (2, 3, 6, 10, 13, 24, 26), Data0, IF(`type` IN (0, 1), Data1, 0)), -- lockId
0 AS reqSkill, -- reqSkill
IF(`type` = 9, data0, IF(`type` = 10, data7, 0)), -- pageTextId
IF(`type` = 1, data3, -- linkedTrapIds
IF(`type` = 3, data7,
IF(`type` = 10, data12,
IF(`type` = 8, data2, 0)))),
IF(`type` = 5, data5, -- reqQuest
IF(`type` = 3, data8,
IF(`type` = 10, data1,
IF(`type` = 8, data4, 0)))),
IF(`type` = 8, data0, 0), -- spellFocusId
IF(`type` = 10, data10, -- onUseSpell
IF(`type` IN (18, 24), data1,
IF(`type` = 26, data2,
IF(`type` = 22, data0, 0)))),
IF(`type` = 18, data4, 0), -- onSuccessSpell
IF(`type` = 18, data2, IF(`type` = 24, data3, 0)), -- auraSpell
IF(`type` = 30, data2, IF(`type` = 24, data4, IF(`type` = 6, data3, 0))), -- triggeredSpell
IF(`type` = 29, CONCAT_WS(" ", data14, data15, data16, data17, data0), -- miscInfo: capturePoint
IF(`type` = 3, CONCAT_WS(" ", data4, data5, data2), -- miscInfo: loot v
IF(`type` = 25, CONCAT_WS(" ", data2, data3, 0),
IF(`type` = 23, CONCAT_WS(" ", data0, data1, data2), "")))), -- miscInfo: meetingStone
IF(`type` = 9, Data0, IF(`type` = 10, Data7, 0)), -- pageTextId
IF(`type` = 1, Data3, -- linkedTrapIds
IF(`type` = 3, Data7,
IF(`type` = 10, Data12,
IF(`type` = 8, Data2, 0)))),
IF(`type` = 5, Data5, -- reqQuest
IF(`type` = 3, Data8,
IF(`type` = 10, Data1,
IF(`type` = 8, Data4, 0)))),
IF(`type` = 8, Data0, 0), -- spellFocusId
IF(`type` = 10, Data10, -- onUseSpell
IF(`type` IN (18, 24), Data1,
IF(`type` = 26, Data2,
IF(`type` = 22, Data0, 0)))),
IF(`type` = 18, Data4, 0), -- onSuccessSpell
IF(`type` = 18, Data2, IF(`type` = 24, Data3, 0)), -- auraSpell
IF(`type` = 30, Data2, IF(`type` = 24, Data4, IF(`type` = 6, Data3, 0))), -- triggeredSpell
IF(`type` = 29, CONCAT_WS(" ", Data14, Data15, Data16, Data17, Data0), -- miscInfo: capturePoint
IF(`type` = 3, CONCAT_WS(" ", Data4, Data5, Data2), -- miscInfo: loot v
IF(`type` = 25, CONCAT_WS(" ", Data2, Data3, 0),
IF(`type` = 23, CONCAT_WS(" ", Data0, Data1, Data2), "")))), -- miscInfo: meetingStone
IF(ScriptName <> "", ScriptName, AIName)
FROM
gameobject_template go
LEFT JOIN
locales_gameobject lgo ON go.entry = lgo.entry
LEFT JOIN
gameobject_questitem gqi ON gqi.GameObjectEntry = go.entry
{
WHERE
go.entry IN (?a)
}
GROUP BY
go.entry
LIMIT
?d, ?d';

Expand Down
Loading

0 comments on commit 5b8a862

Please sign in to comment.