aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/updates/world/master/2021_12_11_08_world_2019_06_15_01_world.sql59
-rw-r--r--src/server/database/Database/Implementation/WorldDatabase.cpp2
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp195
-rw-r--r--src/server/game/Globals/ObjectMgr.h4
4 files changed, 206 insertions, 54 deletions
diff --git a/sql/updates/world/master/2021_12_11_08_world_2019_06_15_01_world.sql b/sql/updates/world/master/2021_12_11_08_world_2019_06_15_01_world.sql
new file mode 100644
index 00000000000..8e2bceaa6b1
--- /dev/null
+++ b/sql/updates/world/master/2021_12_11_08_world_2019_06_15_01_world.sql
@@ -0,0 +1,59 @@
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET NAMES utf8 */;
+/*!50503 SET NAMES utf8mb4 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+
+DROP TABLE IF EXISTS `creature_template_resistance`;
+CREATE TABLE IF NOT EXISTS `creature_template_resistance` (
+ `CreatureID` INT(10) UNSIGNED NOT NULL,
+ `School` TINYINT(3) UNSIGNED NOT NULL,
+ `Resistance` SMALLINT(6) NOT NULL,
+ `VerifiedBuild` INT(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (`CreatureID`, `School`)
+) ENGINE=INNODB DEFAULT CHARSET=utf8;
+
+DROP TABLE IF EXISTS `creature_template_spell`;
+CREATE TABLE IF NOT EXISTS `creature_template_spell` (
+ `CreatureID` INT(10) unsigned NOT NULL,
+ `Index` TINYINT(3) unsigned NOT NULL DEFAULT '0',
+ `Spell` INT(10) unsigned NOT NULL,
+ `VerifiedBuild` INT(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (`CreatureID`, `Index`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
+/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+
+INSERT INTO creature_template_resistance SELECT entry, 1, resistance1, VerifiedBuild FROM creature_template WHERE resistance1 <> 0;
+INSERT INTO creature_template_resistance SELECT entry, 2, resistance2, VerifiedBuild FROM creature_template WHERE resistance2 <> 0;
+INSERT INTO creature_template_resistance SELECT entry, 3, resistance3, VerifiedBuild FROM creature_template WHERE resistance3 <> 0;
+INSERT INTO creature_template_resistance SELECT entry, 4, resistance4, VerifiedBuild FROM creature_template WHERE resistance4 <> 0;
+INSERT INTO creature_template_resistance SELECT entry, 5, resistance5, VerifiedBuild FROM creature_template WHERE resistance5 <> 0;
+INSERT INTO creature_template_resistance SELECT entry, 6, resistance6, VerifiedBuild FROM creature_template WHERE resistance6 <> 0;
+
+INSERT INTO creature_template_spell SELECT entry, 0, spell1, VerifiedBuild FROM creature_template WHERE spell1 <> 0;
+INSERT INTO creature_template_spell SELECT entry, 1, spell2, VerifiedBuild FROM creature_template WHERE spell2 <> 0;
+INSERT INTO creature_template_spell SELECT entry, 2, spell3, VerifiedBuild FROM creature_template WHERE spell3 <> 0;
+INSERT INTO creature_template_spell SELECT entry, 3, spell4, VerifiedBuild FROM creature_template WHERE spell4 <> 0;
+INSERT INTO creature_template_spell SELECT entry, 4, spell5, VerifiedBuild FROM creature_template WHERE spell5 <> 0;
+INSERT INTO creature_template_spell SELECT entry, 5, spell6, VerifiedBuild FROM creature_template WHERE spell6 <> 0;
+INSERT INTO creature_template_spell SELECT entry, 6, spell7, VerifiedBuild FROM creature_template WHERE spell7 <> 0;
+INSERT INTO creature_template_spell SELECT entry, 7, spell8, VerifiedBuild FROM creature_template WHERE spell8 <> 0;
+
+ALTER TABLE `creature_template`
+ DROP COLUMN `resistance1`,
+ DROP COLUMN `resistance2`,
+ DROP COLUMN `resistance3`,
+ DROP COLUMN `resistance4`,
+ DROP COLUMN `resistance5`,
+ DROP COLUMN `resistance6`,
+ DROP COLUMN `spell1`,
+ DROP COLUMN `spell2`,
+ DROP COLUMN `spell3`,
+ DROP COLUMN `spell4`,
+ DROP COLUMN `spell5`,
+ DROP COLUMN `spell6`,
+ DROP COLUMN `spell7`,
+ DROP COLUMN `spell8`;
diff --git a/src/server/database/Database/Implementation/WorldDatabase.cpp b/src/server/database/Database/Implementation/WorldDatabase.cpp
index e21f3016d28..624defd6952 100644
--- a/src/server/database/Database/Implementation/WorldDatabase.cpp
+++ b/src/server/database/Database/Implementation/WorldDatabase.cpp
@@ -78,7 +78,7 @@ void WorldDatabaseConnection::DoPrepareStatements()
PrepareStatement(WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID, "SELECT id FROM waypoint_scripts WHERE guid = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_DEL_CREATURE, "DELETE FROM creature WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(WORLD_SEL_COMMANDS, "SELECT name, permission, help FROM command", CONNECTION_SYNCH);
- PrepareStatement(WORLD_SEL_CREATURE_TEMPLATE, "SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, name, femaleName, subname, TitleAlt, IconName, gossip_menu_id, minlevel, maxlevel, HealthScalingExpansion, RequiredExpansion, VignetteID, faction, npcflag, speed_walk, speed_run, scale, `rank`, dmgschool, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, unit_class, unit_flags, unit_flags2, unit_flags3, dynamicflags, family, trainer_class, type, type_flags, type_flags2, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, VehicleId, mingold, maxgold, AIName, MovementType, ctm.Ground, ctm.Swim, ctm.Flight, ctm.Rooted, ctm.Chase, ctm.Random, HoverHeight, HealthModifier, HealthModifierExtra, ManaModifier, ManaModifierExtra, ArmorModifier, DamageModifier, ExperienceModifier, RacialLeader, movementId, CreatureDifficultyID, WidgetSetID, WidgetSetUnitConditionID, RegenHealth, mechanic_immune_mask, spell_school_immune_mask, flags_extra, ScriptName FROM creature_template ct LEFT JOIN creature_template_movement ctm ON ct.entry = ctm.CreatureId WHERE entry = ? OR 1 = ?", CONNECTION_SYNCH);
+ PrepareStatement(WORLD_SEL_CREATURE_TEMPLATE, "SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, name, femaleName, subname, TitleAlt, IconName, gossip_menu_id, minlevel, maxlevel, HealthScalingExpansion, RequiredExpansion, VignetteID, faction, npcflag, speed_walk, speed_run, scale, `rank`, dmgschool, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, unit_class, unit_flags, unit_flags2, unit_flags3, dynamicflags, family, trainer_class, type, type_flags, type_flags2, lootid, pickpocketloot, skinloot, VehicleId, mingold, maxgold, AIName, MovementType, ctm.Ground, ctm.Swim, ctm.Flight, ctm.Rooted, ctm.Chase, ctm.Random, HoverHeight, HealthModifier, HealthModifierExtra, ManaModifier, ManaModifierExtra, ArmorModifier, DamageModifier, ExperienceModifier, RacialLeader, movementId, CreatureDifficultyID, WidgetSetID, WidgetSetUnitConditionID, RegenHealth, mechanic_immune_mask, spell_school_immune_mask, flags_extra, ScriptName FROM creature_template ct LEFT JOIN creature_template_movement ctm ON ct.entry = ctm.CreatureId WHERE entry = ? OR 1 = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_WAYPOINT_SCRIPT_BY_ID, "SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_CREATURE_BY_ID, "SELECT guid FROM creature WHERE id = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_GAMEOBJECT_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM gameobject WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? ORDER BY order_", CONNECTION_SYNCH);
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 029dd7eb455..b655a7d734e 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -356,17 +356,15 @@ void ObjectMgr::LoadCreatureTemplates()
// "faction, npcflag, speed_walk, speed_run, scale, `rank`, dmgschool, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, "
// 28 29 30 31 32 33 34 35
// "unit_class, unit_flags, unit_flags2, unit_flags3, dynamicflags, family, trainer_class, type, "
- // 36 37 38 39 40 41 42 43 44 45 46
- // "type_flags, type_flags2, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, "
- // 47 48 49 50 51 52 53 54 55 56 57 58 59
- // "spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, VehicleId, mingold, maxgold, AIName, MovementType, "
- // 60 61 62 63 64 65 66 67 68 69 70 71 72 73
+ // 36 37 38 39 40 41 42 43 44 45
+ // "type_flags, type_flags2, lootid, pickpocketloot, skinloot, VehicleId, mingold, maxgold, AIName, MovementType, "
+ // 46 47 48 49 50 51 52 53 54 55 56 57 58 59
// "ctm.Ground, ctm.Swim, ctm.Flight, ctm.Rooted, ctm.Chase, ctm.Random, HoverHeight, HealthModifier, HealthModifierExtra, ManaModifier, ManaModifierExtra, ArmorModifier, DamageModifier, ExperienceModifier, "
- // 74 75 76 77 78 79
+ // 60 61 62 63 64 65
// "RacialLeader, movementId, CreatureDifficultyID, WidgetSetID, WidgetSetUnitConditionID, RegenHealth, "
- // 80 81 82
+ // 66 67 68
// "mechanic_immune_mask, spell_school_immune_mask, flags_extra, "
- // 83
+ // 69
// "ScriptName FROM creature_template WHERE entry = ? OR 1 = ?");
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_TEMPLATE);
@@ -387,6 +385,9 @@ void ObjectMgr::LoadCreatureTemplates()
LoadCreatureTemplate(fields);
} while (result->NextRow());
+ LoadCreatureTemplateResistances();
+ LoadCreatureTemplateSpells();
+
// We load the creature models after loading but before checking
LoadCreatureTemplateModels();
@@ -447,52 +448,142 @@ void ObjectMgr::LoadCreatureTemplate(Field* fields)
creatureTemplate.SkinLootId = fields[40].GetUInt32();
for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
- creatureTemplate.resistance[i] = fields[41 + i - 1].GetInt16();
+ creatureTemplate.resistance[i] = 0;
for (uint8 i = 0; i < MAX_CREATURE_SPELLS; ++i)
- creatureTemplate.spells[i] = fields[47 + i].GetUInt32();
-
- creatureTemplate.VehicleId = fields[55].GetUInt32();
- creatureTemplate.mingold = fields[56].GetUInt32();
- creatureTemplate.maxgold = fields[57].GetUInt32();
- creatureTemplate.AIName = fields[58].GetString();
- creatureTemplate.MovementType = uint32(fields[59].GetUInt8());
- if (!fields[60].IsNull())
- creatureTemplate.Movement.Ground = static_cast<CreatureGroundMovementType>(fields[60].GetUInt8());
-
- if (!fields[61].IsNull())
- creatureTemplate.Movement.Swim = fields[61].GetBool();
-
- if (!fields[62].IsNull())
- creatureTemplate.Movement.Flight = static_cast<CreatureFlightMovementType>(fields[62].GetUInt8());
-
- if (!fields[63].IsNull())
- creatureTemplate.Movement.Rooted = fields[63].GetBool();
-
- if (!fields[64].IsNull())
- creatureTemplate.Movement.Chase = static_cast<CreatureChaseMovementType>(fields[64].GetUInt8());
-
- if (!fields[65].IsNull())
- creatureTemplate.Movement.Random = static_cast<CreatureRandomMovementType>(fields[65].GetUInt8());
-
- creatureTemplate.HoverHeight = fields[66].GetFloat();
- creatureTemplate.ModHealth = fields[67].GetFloat();
- creatureTemplate.ModHealthExtra = fields[68].GetFloat();
- creatureTemplate.ModMana = fields[69].GetFloat();
- creatureTemplate.ModManaExtra = fields[70].GetFloat();
- creatureTemplate.ModArmor = fields[71].GetFloat();
- creatureTemplate.ModDamage = fields[72].GetFloat();
- creatureTemplate.ModExperience = fields[73].GetFloat();
- creatureTemplate.RacialLeader = fields[74].GetBool();
- creatureTemplate.movementId = fields[75].GetUInt32();
- creatureTemplate.CreatureDifficultyID = fields[76].GetInt32();
- creatureTemplate.WidgetSetID = fields[77].GetInt32();
- creatureTemplate.WidgetSetUnitConditionID = fields[78].GetInt32();
- creatureTemplate.RegenHealth = fields[79].GetBool();
- creatureTemplate.MechanicImmuneMask = fields[80].GetUInt32();
- creatureTemplate.SpellSchoolImmuneMask = fields[81].GetUInt32();
- creatureTemplate.flags_extra = fields[82].GetUInt32();
- creatureTemplate.ScriptID = GetScriptId(fields[83].GetString());
+ creatureTemplate.spells[i] = 0;
+
+ creatureTemplate.VehicleId = fields[41].GetUInt32();
+ creatureTemplate.mingold = fields[42].GetUInt32();
+ creatureTemplate.maxgold = fields[43].GetUInt32();
+ creatureTemplate.AIName = fields[44].GetString();
+ creatureTemplate.MovementType = uint32(fields[45].GetUInt8());
+ if (!fields[46].IsNull())
+ creatureTemplate.Movement.Ground = static_cast<CreatureGroundMovementType>(fields[46].GetUInt8());
+
+ if (!fields[47].IsNull())
+ creatureTemplate.Movement.Swim = fields[47].GetBool();
+
+ if (!fields[48].IsNull())
+ creatureTemplate.Movement.Flight = static_cast<CreatureFlightMovementType>(fields[48].GetUInt8());
+
+ if (!fields[49].IsNull())
+ creatureTemplate.Movement.Rooted = fields[49].GetBool();
+
+ if (!fields[50].IsNull())
+ creatureTemplate.Movement.Chase = static_cast<CreatureChaseMovementType>(fields[50].GetUInt8());
+
+ if (!fields[51].IsNull())
+ creatureTemplate.Movement.Random = static_cast<CreatureRandomMovementType>(fields[51].GetUInt8());
+
+ creatureTemplate.HoverHeight = fields[52].GetFloat();
+ creatureTemplate.ModHealth = fields[53].GetFloat();
+ creatureTemplate.ModHealthExtra = fields[54].GetFloat();
+ creatureTemplate.ModMana = fields[55].GetFloat();
+ creatureTemplate.ModManaExtra = fields[56].GetFloat();
+ creatureTemplate.ModArmor = fields[57].GetFloat();
+ creatureTemplate.ModDamage = fields[58].GetFloat();
+ creatureTemplate.ModExperience = fields[59].GetFloat();
+ creatureTemplate.RacialLeader = fields[60].GetBool();
+ creatureTemplate.movementId = fields[61].GetUInt32();
+ creatureTemplate.CreatureDifficultyID = fields[62].GetInt32();
+ creatureTemplate.WidgetSetID = fields[63].GetInt32();
+ creatureTemplate.WidgetSetUnitConditionID = fields[64].GetInt32();
+ creatureTemplate.RegenHealth = fields[65].GetBool();
+ creatureTemplate.MechanicImmuneMask = fields[66].GetUInt32();
+ creatureTemplate.SpellSchoolImmuneMask = fields[67].GetUInt32();
+ creatureTemplate.flags_extra = fields[68].GetUInt32();
+ creatureTemplate.ScriptID = GetScriptId(fields[69].GetString());
+}
+
+void ObjectMgr::LoadCreatureTemplateResistances()
+{
+ uint32 oldMSTime = getMSTime();
+
+ // 0 1 2
+ QueryResult result = WorldDatabase.Query("SELECT CreatureID, School, Resistance FROM creature_template_resistance");
+
+ if (!result)
+ {
+ TC_LOG_INFO("server.loading", ">> Loaded 0 creature template resistance definitions. DB table `creature_template_resistance` is empty.");
+ return;
+ }
+
+ uint32 count = 0;
+
+ do
+ {
+ Field* fields = result->Fetch();
+
+ uint32 creatureID = fields[0].GetUInt32();
+ uint8 school = fields[1].GetUInt8();
+
+ if (school == SPELL_SCHOOL_NORMAL || school >= MAX_SPELL_SCHOOL)
+ {
+ TC_LOG_INFO("sql.sql", "creature_template_resistance has resistance definitions for creature %u but this school %u doesn't exist", creatureID, school);
+ continue;
+ }
+
+ CreatureTemplateContainer::iterator itr = _creatureTemplateStore.find(creatureID);
+ if (itr == _creatureTemplateStore.end())
+ {
+ TC_LOG_INFO("sql.sql", "creature_template_resistance has resistance definitions for creature %u but this creature doesn't exist", creatureID);
+ continue;
+ }
+
+ CreatureTemplate& creatureTemplate = itr->second;
+ creatureTemplate.resistance[school] = fields[2].GetInt16();
+
+ ++count;
+
+ } while (result->NextRow());
+
+ TC_LOG_INFO("server.loading", ">> Loaded %u creature template resistances in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
+}
+
+void ObjectMgr::LoadCreatureTemplateSpells()
+{
+ uint32 oldMSTime = getMSTime();
+
+ // 0 1 2
+ QueryResult result = WorldDatabase.Query("SELECT CreatureID, `Index`, Spell FROM creature_template_spell");
+
+ if (!result)
+ {
+ TC_LOG_INFO("server.loading", ">> Loaded 0 creature template spell definitions. DB table `creature_template_spell` is empty.");
+ return;
+ }
+
+ uint32 count = 0;
+
+ do
+ {
+ Field* fields = result->Fetch();
+
+ uint32 creatureID = fields[0].GetUInt32();
+ uint8 index = fields[1].GetUInt8();
+
+ if (index >= MAX_CREATURE_SPELLS)
+ {
+ TC_LOG_INFO("sql.sql", "creature_template_spell has spell definitions for creature %u with a incorrect index %u", creatureID, index);
+ continue;
+ }
+
+ CreatureTemplateContainer::iterator itr = _creatureTemplateStore.find(creatureID);
+ if (itr == _creatureTemplateStore.end())
+ {
+ TC_LOG_INFO("sql.sql", "creature_template_spell has spell definitions for creature %u but this creature doesn't exist", creatureID);
+ continue;
+ }
+
+ CreatureTemplate& creatureTemplate = itr->second;
+ creatureTemplate.spells[index] = fields[2].GetUInt32();;
+
+ ++count;
+
+ } while (result->NextRow());
+
+ TC_LOG_INFO("server.loading", ">> Loaded %u creature template spells in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadCreatureTemplateModels()
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index b5f5b7496a0..2ed245776aa 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -1277,9 +1277,11 @@ class TC_GAME_API ObjectMgr
void LoadCreatureClassLevelStats();
void LoadCreatureLocales();
void LoadCreatureTemplates();
- void LoadCreatureTemplateModels();
void LoadCreatureTemplateAddons();
void LoadCreatureTemplate(Field* fields);
+ void LoadCreatureTemplateResistances();
+ void LoadCreatureTemplateSpells();
+ void LoadCreatureTemplateModels();
void LoadCreatureScalingData();
void CheckCreatureTemplate(CreatureTemplate const* cInfo);
void CheckCreatureMovement(char const* table, uint64 id, CreatureMovementData& creatureMovement);