From 644a08d2a76cbf3caa27d3c8f604a13aa80b3359 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sat, 1 Jan 2022 15:34:24 -0500 Subject: [PATCH] Core/DB: Merge pool_creature, pool_gameobject and pool_pool into a single pool_members table. Port From (https://github.com/TrinityCore/TrinityCore/commit/8b78f5055640bd606751d2ccc9549d14fd1d552e) --- Source/Game/Globals/ObjectManager.cs | 10 ++++---- Source/Game/Pools/PoolManager.cs | 16 ++++++------- ...021_12_16_04_world_2019_07_16_01_world.sql | 23 +++++++++++++++++++ 3 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 sql/updates/world/master/2021_12_16_04_world_2019_07_16_01_world.sql diff --git a/Source/Game/Globals/ObjectManager.cs b/Source/Game/Globals/ObjectManager.cs index 5218b47d4..3b60be76e 100644 --- a/Source/Game/Globals/ObjectManager.cs +++ b/Source/Game/Globals/ObjectManager.cs @@ -3360,11 +3360,11 @@ namespace Game // 0 1 2 3 4 5 6 7 8 9 10 SQLResult result = DB.World.Query("SELECT creature.guid, id, map, position_x, position_y, position_z, orientation, modelid, equipment_id, spawntimesecs, spawndist, " + - //11 12 13 14 15 16 17 18 19 20 21 - "currentwaypoint, curhealth, curmana, MovementType, spawnDifficulties, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.unit_flags2, creature.unit_flags3, " + + //11 12 13 14 15 16 17 18 19 20 21 + "currentwaypoint, curhealth, curmana, MovementType, spawnDifficulties, eventEntry, poolSpawnId, creature.npcflag, creature.unit_flags, creature.unit_flags2, creature.unit_flags3, " + //22 23 24 25 26 27 "creature.dynamicflags, creature.phaseUseFlags, creature.phaseid, creature.phasegroup, creature.terrainSwapMap, creature.ScriptName " + - "FROM creature LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid LEFT OUTER JOIN pool_creature ON creature.guid = pool_creature.guid"); + "FROM creature LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid LEFT OUTER JOIN pool_members ON pool_members.type = 0 AND creature.guid = pool_members.spawnId"); if (result.IsEmpty()) { @@ -4100,11 +4100,11 @@ namespace Game // 0 1 2 3 4 5 6 SQLResult result = DB.World.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation, " + //7 8 9 10 11 12 13 14 15 16 - "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnDifficulties, eventEntry, pool_entry, " + + "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnDifficulties, eventEntry, poolSpawnId, " + //17 18 19 20 21 "phaseUseFlags, phaseid, phasegroup, terrainSwapMap, ScriptName " + "FROM gameobject LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid " + - "LEFT OUTER JOIN pool_gameobject ON gameobject.guid = pool_gameobject.guid"); + "LEFT OUTER JOIN pool_members ON pool_members.type = 1 AND gameobject.guid = pool_members.spawnId"); if (result.IsEmpty()) { diff --git a/Source/Game/Pools/PoolManager.cs b/Source/Game/Pools/PoolManager.cs index 693cefd8a..c0abb8052 100644 --- a/Source/Game/Pools/PoolManager.cs +++ b/Source/Game/Pools/PoolManager.cs @@ -71,8 +71,8 @@ namespace Game { uint oldMSTime = Time.GetMSTime(); - // 1 2 3 - SQLResult result = DB.World.Query("SELECT guid, pool_entry, chance FROM pool_creature"); + // 1 2 3 + SQLResult result = DB.World.Query("SELECT spawnId, poolSpawnId, chance FROM pool_members WHERE type = 0"); if (result.IsEmpty()) { @@ -128,8 +128,8 @@ namespace Game { uint oldMSTime = Time.GetMSTime(); - // 1 2 3 - SQLResult result = DB.World.Query("SELECT guid, pool_entry, chance FROM pool_gameobject"); + // 1 2 3 + SQLResult result = DB.World.Query("SELECT spawnId, poolSpawnId, chance FROM pool_members WHERE type = 1"); if (result.IsEmpty()) { @@ -198,8 +198,8 @@ namespace Game { uint oldMSTime = Time.GetMSTime(); - // 1 2 3 - SQLResult result = DB.World.Query("SELECT pool_id, mother_pool, chance FROM pool_pool"); + // 1 2 3 + SQLResult result = DB.World.Query("SELECT spawnId, poolSpawnId, chance FROM pool_members WHERE type = 2"); if (result.IsEmpty()) { @@ -343,9 +343,9 @@ namespace Game { uint oldMSTime = Time.GetMSTime(); - SQLResult result = DB.World.Query("SELECT DISTINCT pool_template.entry, pool_pool.pool_id, pool_pool.mother_pool FROM pool_template" + + SQLResult result = DB.World.Query("SELECT DISTINCT pool_template.entry, pool_members.spawnId, pool_members.poolSpawnId FROM pool_template" + " LEFT JOIN game_event_pool ON pool_template.entry=game_event_pool.pool_entry" + - " LEFT JOIN pool_pool ON pool_template.entry=pool_pool.pool_id WHERE game_event_pool.pool_entry IS NULL"); + " LEFT JOIN pool_members ON pool_members.type = 2 AND pool_template.entry = pool_members.spawnId WHERE game_event_pool.pool_entry IS NULL"); if (result.IsEmpty()) { diff --git a/sql/updates/world/master/2021_12_16_04_world_2019_07_16_01_world.sql b/sql/updates/world/master/2021_12_16_04_world_2019_07_16_01_world.sql new file mode 100644 index 000000000..9bc838f2c --- /dev/null +++ b/sql/updates/world/master/2021_12_16_04_world_2019_07_16_01_world.sql @@ -0,0 +1,23 @@ +-- +DROP TABLE IF EXISTS `pool_members`; +CREATE TABLE `pool_members` ( + `type` smallint(10) unsigned NOT NULL, + `spawnId` int(10) unsigned NOT NULL, + `poolSpawnId` int(10) unsigned NOT NULL, + `chance` double unsigned NOT NULL, + `description` varchar(255) DEFAULT NULL, + PRIMARY KEY (`type`,`spawnId`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `pool_members` (`type`,`spawnId`,`poolSpawnId`,`chance`,`description`) +SELECT 0 as `type`, `guid` as `spawnId`, `pool_entry` as `poolSpawnId`, `chance`, `description` FROM `pool_creature`; + +INSERT INTO `pool_members` (`type`,`spawnId`,`poolSpawnId`,`chance`,`description`) +SELECT 1 as `type`, `guid` as `spawnId`, `pool_entry` as `poolSpawnId`, `chance`, `description` FROM `pool_gameobject`; + +INSERT INTO `pool_members` (`type`,`spawnId`,`poolSpawnId`,`chance`,`description`) +SELECT 2 as `type`, `pool_id` as `spawnId`, `mother_pool` as `poolSpawnId`, `chance`, `description` FROM `pool_pool`; + +DROP TABLE IF EXISTS `pool_creature`; +DROP TABLE IF EXISTS `pool_gameobject`; +DROP TABLE IF EXISTS `pool_pool`;