diff --git a/includes/game.php b/includes/game.php index 532c065b..0e3c94b6 100644 --- a/includes/game.php +++ b/includes/game.php @@ -324,10 +324,10 @@ class Game $result = DB::World()->select('SELECT `guid` AS ARRAY_KEY, `id`, `map` AS `mapId`, `position_y` AS `posX`, `position_x` AS `posY` FROM gameobject WHERE `guid` IN (?a)', $guids); break; case Type::SOUND: - $result = DB::AoWoW()->select('SELECT `soundId` AS ARRAY_KEY, `soundId` AS `id`, `mapId`, `posX`, `posY` FROM dbc_soundemitters WHERE `soundId` IN (?a)', $guids); + $result = DB::AoWoW()->select('SELECT `soundId` AS ARRAY_KEY, `soundId` AS `id`, `mapId`, `posX`, `posY` FROM ?_soundemitters WHERE `soundId` IN (?a)', $guids); break; case Type::AREATRIGGER: - $result = DB::AoWoW()->select('SELECT `id` AS ARRAY_KEY, `id`, `mapId`, `posX`, `posY` FROM dbc_areatrigger WHERE `id` IN (?a)', $guids); + $result = DB::AoWoW()->select('SELECT `id` AS ARRAY_KEY, `id`, `mapId`, `posX`, `posY` FROM ?_areatrigger WHERE `id` IN (?a)', $guids); break; default: trigger_error('Game::getWorldPosForGUID - instanced with unsupported TYPE #'.$type, E_USER_WARNING); @@ -345,19 +345,19 @@ class Game return []; $query = 'SELECT - dm.id, - wma.areaId, - IFNULL(dm.floor, 0) AS floor, - 100 - ROUND(IF(dm.id IS NOT NULL, (?f - dm.minY) * 100 / (dm.maxY - dm.minY), (?f - wma.right) * 100 / (wma.left - wma.right)), 1) AS `posX`, - 100 - ROUND(IF(dm.id IS NOT NULL, (?f - dm.minX) * 100 / (dm.maxX - dm.minX), (?f - wma.bottom) * 100 / (wma.top - wma.bottom)), 1) AS `posY`, - SQRT(POWER(abs(IF(dm.id IS NOT NULL, (?f - dm.minY) * 100 / (dm.maxY - dm.minY), (?f - wma.right) * 100 / (wma.left - wma.right)) - 50), 2) + - POWER(abs(IF(dm.id IS NOT NULL, (?f - dm.minX) * 100 / (dm.maxX - dm.minX), (?f - wma.bottom) * 100 / (wma.top - wma.bottom)) - 50), 2)) AS `dist` + dm.`id`, + wma.`areaId`, + IFNULL(dm.`floor`, 0) AS `floor`, + 100 - ROUND(IF(dm.`id` IS NOT NULL, (?f - dm.`minY`) * 100 / (dm.`maxY` - dm.`minY`), (?f - wma.`right`) * 100 / (wma.`left` - wma.`right`)), 1) AS `posX`, + 100 - ROUND(IF(dm.`id` IS NOT NULL, (?f - dm.`minX`) * 100 / (dm.`maxX` - dm.`minX`), (?f - wma.`bottom`) * 100 / (wma.`top` - wma.`bottom`)), 1) AS `posY`, + SQRT(POWER(ABS(IF(dm.`id` IS NOT NULL, (?f - dm.`minY`) * 100 / (dm.`maxY` - dm.`minY`), (?f - wma.`right`) * 100 / (wma.`left` - wma.`right`)) - 50), 2) + + POWER(ABS(IF(dm.`id` IS NOT NULL, (?f - dm.`minX`) * 100 / (dm.`maxX` - dm.`minX`), (?f - wma.`bottom`) * 100 / (wma.`top` - wma.`bottom`)) - 50), 2)) AS `dist` FROM - dbc_worldmaparea wma + ?_worldmaparea wma LEFT JOIN - dbc_dungeonmap dm ON dm.mapId = IF(?d AND (wma.mapId NOT IN (0, 1, 530, 571) OR wma.areaId = 4395), wma.mapId, -1) + ?_dungeonmap dm ON dm.`mapId` = IF(?d AND (wma.`mapId` NOT IN (0, 1, 530, 571) OR wma.`areaId` = 4395), wma.`mapId`, -1) WHERE - wma.mapId = ?d AND IF(?d, wma.areaId = ?d, wma.areaId <> 0){ AND IF(dm.floor IS NULL, 1, dm.floor = ?d)} + wma.`mapId` = ?d AND IF(?d, wma.`areaId` = ?d, wma.`areaId` <> 0){ AND IF(dm.`floor` IS NULL, 1, dm.`floor` = ?d)} HAVING (`posX` BETWEEN 0.1 AND 99.9 AND `posY` BETWEEN 0.1 AND 99.9) ORDER BY diff --git a/includes/profiler.class.php b/includes/profiler.class.php index de62298e..4dfc4b02 100644 --- a/includes/profiler.class.php +++ b/includes/profiler.class.php @@ -617,7 +617,7 @@ class Profiler DB::Aowow()->query(' INSERT INTO ?_profiler_completion SELECT ?d, ?d, spellId, NULL, NULL - FROM dbc_skilllineability + FROM ?_skilllineability WHERE skillLineId IN (?a) AND acquireMethod = 1 AND (reqRaceMask = 0 OR reqRaceMask & ?d) AND diff --git a/setup/db_structure.sql b/setup/db_structure.sql index e7947014..7ed615c3 100644 --- a/setup/db_structure.sql +++ b/setup/db_structure.sql @@ -344,8 +344,11 @@ CREATE TABLE `aowow_areatrigger` ( `id` int unsigned NOT NULL, `cuFlags` int unsigned NOT NULL DEFAULT 0 COMMENT 'see defines.php for flags', `type` smallint unsigned NOT NULL, - `name` varchar(100) DEFAULT NULL, + `mapId` smallint unsigned NOT NULL COMMENT 'world pos. from dbc', + `posX` float NOT NULL COMMENT 'world pos. from dbc', + `posY` float NOT NULL COMMENT 'world pos. from dbc', `orientation` float NOT NULL, + `name` varchar(100) DEFAULT NULL, `quest` mediumint unsigned DEFAULT NULL, `teleportA` smallint unsigned DEFAULT NULL, `teleportX` float unsigned DEFAULT NULL, @@ -3227,7 +3230,7 @@ UNLOCK TABLES; LOCK TABLES `aowow_dbversion` WRITE; /*!40000 ALTER TABLE `aowow_dbversion` DISABLE KEYS */; -INSERT INTO `aowow_dbversion` VALUES (1718468661,0,NULL,NULL); +INSERT INTO `aowow_dbversion` VALUES (1718629022,0,NULL,NULL); /*!40000 ALTER TABLE `aowow_dbversion` ENABLE KEYS */; UNLOCK TABLES; diff --git a/setup/tools/clisetup/setup.func.php b/setup/tools/clisetup/setup.func.php index 043b8ab6..f5dd71cc 100644 --- a/setup/tools/clisetup/setup.func.php +++ b/setup/tools/clisetup/setup.func.php @@ -30,6 +30,10 @@ function setup() : void ['dbconfig', [null, null], 'testDB', 'Please enter your database credentials.', 'could not establish connection to:'], ['siteconfig', [null, null], 'testSelf', 'SITE_HOST and STATIC_HOST '.CLI::bold('must').' be set. Also enable FORCE_SSL if needed. You may also want to change other variables such as NAME, NAME_SHORT or LOCALES.', 'could not access:'], // sql- and build- stuff here + ['SqlGen::generate', 'dungeonmap', null, null, null], + ['SqlGen::generate', 'skilllineability', null, null, null], + ['SqlGen::generate', 'soundemitters', null, null, null], + ['SqlGen::generate', 'worldmaparea', null, null, null], ['SqlGen::generate', 'areatrigger', null, null, null], ['SqlGen::generate', 'achievementcriteria', null, null, null], ['SqlGen::generate', 'glyphproperties', null, null, null], diff --git a/setup/tools/sqlgen/areatrigger.func.php b/setup/tools/sqlgen/areatrigger.func.php index 2288bb20..6df6d036 100644 --- a/setup/tools/sqlgen/areatrigger.func.php +++ b/setup/tools/sqlgen/areatrigger.func.php @@ -17,7 +17,7 @@ SqlGen::register(new class extends SetupScript public function generate(array $ids = []) : bool { DB::Aowow()->query('TRUNCATE ?_areatrigger'); - DB::Aowow()->query('INSERT INTO ?_areatrigger SELECT id, 0, 0, NULL, orientation, NULL, NULL, NULL, NULL, NULL, NULL FROM dbc_areatrigger'); + DB::Aowow()->query('INSERT INTO ?_areatrigger SELECT `id`, 0, 0, `mapId`, `posX`, `posY`, `orientation`, NULL, NULL, NULL, NULL, NULL, NULL, NULL FROM dbc_areatrigger'); /* notes: * while areatrigger DO have dimensions, displaying them on a map is almost always futile, @@ -27,24 +27,29 @@ SqlGen::register(new class extends SetupScript // 1: Taverns CLI::write(' - fetching taverns'); - $addData = DB::World()->select('SELECT id AS ARRAY_KEY, name, ?d AS `type` FROM areatrigger_tavern', AT_TYPE_TAVERN); + $addData = DB::World()->select('SELECT `id` AS ARRAY_KEY, `name`, ?d AS `type` FROM areatrigger_tavern', AT_TYPE_TAVERN); foreach ($addData as $id => $ad) - DB::Aowow()->query('UPDATE ?_areatrigger SET ?a WHERE id = ?d', $ad, $id); + DB::Aowow()->query('UPDATE ?_areatrigger SET ?a WHERE `id` = ?d', $ad, $id); // 2: Teleporter + teleporting 4: Smart Trigger CLI::write(' - calculation teleporter coordinates'); - $addData = DB::World()->select(' - SELECT ID AS ARRAY_KEY, Name AS `name`, target_map AS `map`, target_position_x AS `posY`, target_position_y AS `posX`, target_orientation AS `orientation` FROM areatrigger_teleport UNION - SELECT entryorguid AS ARRAY_KEY, "TBD" AS `name`, action_param1 AS `map`, target_x AS `posY`, target_y AS `posX`, target_o AS `orientation` FROM smart_scripts WHERE source_type = 2 AND action_type = 62 - '); + $addData = DB::World()->select( + 'SELECT `ID` AS ARRAY_KEY, `Name` AS `name`, `target_map` AS `map`, `target_position_x` AS `posY`, `target_position_y` AS `posX`, `target_orientation` AS `orientation` + FROM areatrigger_teleport + UNION + SELECT `entryorguid` AS ARRAY_KEY, "TBD" AS `name`, `action_param1` AS `map`, `target_x` AS `posY`, `target_y` AS `posX`, `target_o` AS `orientation` + FROM smart_scripts + WHERE `source_type` = 2 AND `action_type` = 62' + ); + foreach ($addData as $id => $ad) { - $points = Game::worldPosToZonePos($ad['map'], $ad['posX'], $ad['posY']/*, 0*/); + $points = Game::worldPosToZonePos($ad['map'], $ad['posX'], $ad['posY']); if (!$points) { CLI::write(' * AT '.$id.' teleporter endpoint '.CLI::bold($ad['name']).' could not be matched to displayable area [M:'.$ad['map'].'; X:'.$ad['posY'].'; Y:'.$ad['posX'].']', CLI::LOG_WARN); - DB::Aowow()->query('UPDATE ?_areatrigger SET `name` = ?, `type` = ?d WHERE id = ?d', $ad['name'], AT_TYPE_TELEPORT, $id); + DB::Aowow()->query('UPDATE ?_areatrigger SET `name` = ?, `type` = ?d WHERE `id` = ?d', $ad['name'], AT_TYPE_TELEPORT, $id); continue; } @@ -58,27 +63,27 @@ SqlGen::register(new class extends SetupScript 'teleportF' => $points[0]['floor'] ); - DB::Aowow()->query('UPDATE ?_areatrigger SET ?a WHERE id = ?d', $update, $id); + DB::Aowow()->query('UPDATE ?_areatrigger SET ?a WHERE `id` = ?d', $update, $id); } // 3: Quest Objectives CLI::write(' - satisfying quest objectives'); - $addData = DB::World()->select('SELECT atir.id AS ARRAY_KEY, qt.ID AS quest, NULLIF(qt.AreaDescription, "") AS `name`, qta.SpecialFlags FROM quest_template qt LEFT JOIN quest_template_addon qta ON qta.ID = qt.ID JOIN areatrigger_involvedrelation atir ON atir.quest = qt.ID'); + $addData = DB::World()->select('SELECT atir.`id` AS ARRAY_KEY, qt.`ID` AS `quest`, NULLIF(qt.AreaDescription, "") AS `name`, qta.`SpecialFlags` FROM quest_template qt LEFT JOIN quest_template_addon qta ON qta.`ID` = qt.`ID` JOIN areatrigger_involvedrelation atir ON atir.`quest` = qt.`ID`'); foreach ($addData as $id => $ad) { if (!($ad['SpecialFlags'] & QUEST_FLAG_SPECIAL_EXT_COMPLETE)) - CLI::write(' * Areatrigger '.CLI::bold($id).' is involved in Quest '.CLI::bold($ad['quest']).', but Quest is not flagged for external completion (SpecialFlags & '.Util::asHex(QUEST_FLAG_SPECIAL_EXT_COMPLETE).')', CLI::LOG_WARN); + CLI::write(' * Areatrigger '.CLI::bold($id).' is involved in quest '.CLI::bold($ad['quest']).', but quest is not flagged for external completion (SpecialFlags & '.Util::asHex(QUEST_FLAG_SPECIAL_EXT_COMPLETE).')', CLI::LOG_WARN); - DB::Aowow()->query('UPDATE ?_areatrigger SET name = ?, type = ?d, quest = ?d WHERE id = ?d', $ad['name'], AT_TYPE_OBJECTIVE, $ad['quest'], $id); + DB::Aowow()->query('UPDATE ?_areatrigger SET `name` = ?, `type` = ?d, `quest` = ?d WHERE `id` = ?d', $ad['name'], AT_TYPE_OBJECTIVE, $ad['quest'], $id); } // 4/5 Scripted CLI::write(' - assigning scripts'); - $addData = DB::World()->select('SELECT entry AS ARRAY_KEY, IF(ScriptName = "SmartTrigger", NULL, ScriptName) AS `name`, IF(ScriptName = "SmartTrigger", 4, 5) AS `type` FROM areatrigger_scripts'); + $addData = DB::World()->select('SELECT `entry` AS ARRAY_KEY, IF(`ScriptName` = "SmartTrigger", NULL, `ScriptName`) AS `name`, IF(`ScriptName` = "SmartTrigger", 4, 5) AS `type` FROM areatrigger_scripts'); foreach ($addData as $id => $ad) - DB::Aowow()->query('UPDATE ?_areatrigger SET ?a WHERE id = ?d', $ad, $id); + DB::Aowow()->query('UPDATE ?_areatrigger SET ?a WHERE `id` = ?d', $ad, $id); $this->reapplyCCFlags('areatrigger', Type::AREATRIGGER); diff --git a/setup/tools/sqlgen/dungeonmap.func.php b/setup/tools/sqlgen/dungeonmap.func.php new file mode 100644 index 00000000..0537c18b --- /dev/null +++ b/setup/tools/sqlgen/dungeonmap.func.php @@ -0,0 +1,18 @@ + diff --git a/setup/tools/sqlgen/skilllineability.func.php b/setup/tools/sqlgen/skilllineability.func.php new file mode 100644 index 00000000..eebdb015 --- /dev/null +++ b/setup/tools/sqlgen/skilllineability.func.php @@ -0,0 +1,18 @@ + diff --git a/setup/tools/sqlgen/soundemitter.func.php b/setup/tools/sqlgen/soundemitter.func.php new file mode 100644 index 00000000..5a551d40 --- /dev/null +++ b/setup/tools/sqlgen/soundemitter.func.php @@ -0,0 +1,18 @@ + diff --git a/setup/tools/sqlgen/worldmaparea.func.php b/setup/tools/sqlgen/worldmaparea.func.php new file mode 100644 index 00000000..ca74dda2 --- /dev/null +++ b/setup/tools/sqlgen/worldmaparea.func.php @@ -0,0 +1,18 @@ + diff --git a/setup/updates/1718629021_01.sql b/setup/updates/1718629021_01.sql new file mode 100644 index 00000000..3201b8dd --- /dev/null +++ b/setup/updates/1718629021_01.sql @@ -0,0 +1,20 @@ +DROP TABLE IF EXISTS aowow_areatrigger; +CREATE TABLE aowow_areatrigger ( + `id` int unsigned NOT NULL, + `cuFlags` int unsigned NOT NULL DEFAULT 0 COMMENT 'see defines.php for flags', + `type` smallint unsigned NOT NULL, + `mapId` smallint unsigned NOT NULL COMMENT 'world pos. from dbc', + `posX` float NOT NULL COMMENT 'world pos. from dbc', + `posY` float NOT NULL COMMENT 'world pos. from dbc', + `orientation` float NOT NULL, + `name` varchar(100) NULL DEFAULT NULL, + `quest` mediumint unsigned NULL DEFAULT NULL, + `teleportA` smallint unsigned NULL DEFAULT NULL, + `teleportX` float NULL DEFAULT NULL, + `teleportY` float NULL DEFAULT NULL, + `teleportO` float NULL DEFAULT NULL, + `teleportF` tinyint unsigned NULL DEFAULT NULL, + PRIMARY KEY (`id`), + INDEX `quest` (`quest`), + INDEX `type` (`type`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE='utf8mb4_general_ci' ;