From f2334b6500659d9ab0fb8e0accb4e6d514293ae4 Mon Sep 17 00:00:00 2001 From: offl <11556157+offl@users.noreply.github.com> Date: Mon, 12 Jan 2026 23:03:33 +0200 Subject: [PATCH] Core/Scripts: Remove old database spell script system (#31484) --- sql/base/auth_database.sql | 5 +-- sql/updates/auth/3.3.5/2026_01_12_00_auth.sql | 5 +++ .../world/3.3.5/2026_01_12_00_world.sql | 3 ++ src/server/game/Accounts/RBAC.h | 2 +- src/server/game/Globals/ObjectMgr.cpp | 37 +------------------ src/server/game/Globals/ObjectMgr.h | 5 +-- src/server/game/Spells/SpellEffects.cpp | 8 ---- src/server/game/World/World.cpp | 1 - src/server/scripts/Commands/cs_reload.cpp | 22 ----------- 9 files changed, 13 insertions(+), 75 deletions(-) create mode 100644 sql/updates/auth/3.3.5/2026_01_12_00_auth.sql create mode 100644 sql/updates/world/3.3.5/2026_01_12_00_world.sql diff --git a/sql/base/auth_database.sql b/sql/base/auth_database.sql index 890b885d496..8084c6c6d67 100644 --- a/sql/base/auth_database.sql +++ b/sql/base/auth_database.sql @@ -1342,7 +1342,6 @@ INSERT INTO `rbac_linked_permissions` VALUES (196,697), (196,698), (196,699), -(196,700), (196,701), (196,702), (196,703), @@ -2169,7 +2168,6 @@ INSERT INTO `rbac_permissions` VALUES (697,'Command: reload spell_pet_auras'), (698,'Command: character changeaccount'), (699,'Command: reload spell_proc'), -(700,'Command: reload spell_scripts'), (701,'Command: reload spell_target_position'), (702,'Command: reload spell_threats'), (703,'Command: reload spell_group_stack_rules'), @@ -2533,7 +2531,8 @@ INSERT INTO `updates` VALUES ('2024_09_26_00_auth.sql','E37C3997FD7851EA360774AC568912846C448272','ARCHIVED','2024-09-26 18:27:26',0), ('2024_11_22_00_auth.sql','F2C1D1572A3968E9E9D778EF7DC82778DF3EF887','ARCHIVED','2024-11-22 23:18:14',0), ('2025_02_14_00_auth.sql','4A30E92FF519BB41C520CDBF90019291217C26A2','ARCHIVED','2025-02-14 17:20:00',0), -('2025_10_21_00_auth.sql','1A221989F98337CB285B4328E791F5531CFD2454','ARCHIVED','2025-10-21 18:16:45',0); +('2025_10_21_00_auth.sql','1A221989F98337CB285B4328E791F5531CFD2454','ARCHIVED','2025-10-21 18:16:45',0), +('2026_01_12_00_auth.sql','91644588146896CA04E6B8FEDEB34CF4FEB64EEF','RELEASED','2026-01-12 21:26:18',0); /*!40000 ALTER TABLE `updates` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/updates/auth/3.3.5/2026_01_12_00_auth.sql b/sql/updates/auth/3.3.5/2026_01_12_00_auth.sql new file mode 100644 index 00000000000..99f01d27d7f --- /dev/null +++ b/sql/updates/auth/3.3.5/2026_01_12_00_auth.sql @@ -0,0 +1,5 @@ +-- +DELETE FROM `rbac_account_permissions` WHERE `permissionId`=700; +DELETE FROM `rbac_default_permissions` WHERE `permissionId`=700; +DELETE FROM `rbac_linked_permissions` WHERE `linkedId`=700; +DELETE FROM `rbac_permissions` WHERE `id`=700; diff --git a/sql/updates/world/3.3.5/2026_01_12_00_world.sql b/sql/updates/world/3.3.5/2026_01_12_00_world.sql new file mode 100644 index 00000000000..022bfafb19e --- /dev/null +++ b/sql/updates/world/3.3.5/2026_01_12_00_world.sql @@ -0,0 +1,3 @@ +-- +DROP TABLE IF EXISTS `spell_scripts`; +DELETE FROM `command` WHERE `name` = 'reload spell_scripts'; diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h index 5fdc0fe7c1d..e4ae4da4d92 100644 --- a/src/server/game/Accounts/RBAC.h +++ b/src/server/game/Accounts/RBAC.h @@ -567,7 +567,7 @@ enum RBACPermissions RBAC_PERM_COMMAND_RELOAD_SPELL_PET_AURAS = 697, RBAC_PERM_COMMAND_CHARACTER_CHANGEACCOUNT = 698, RBAC_PERM_COMMAND_RELOAD_SPELL_PROC = 699, - RBAC_PERM_COMMAND_RELOAD_SPELL_SCRIPTS = 700, + // 700 previously used, do not reuse RBAC_PERM_COMMAND_RELOAD_SPELL_TARGET_POSITION = 701, RBAC_PERM_COMMAND_RELOAD_SPELL_THREATS = 702, RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP_STACK_RULES = 703, diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index b738e885f3b..01555141b3c 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -57,7 +57,6 @@ #include "Vehicle.h" #include "World.h" -ScriptMapMap sSpellScripts; ScriptMapMap sEventScripts; ScriptMapMap sWaypointScripts; @@ -66,7 +65,6 @@ std::string GetScriptsTableNameByType(ScriptsType type) std::string res = ""; switch (type) { - case SCRIPTS_SPELL: res = "spell_scripts"; break; case SCRIPTS_EVENT: res = "event_scripts"; break; case SCRIPTS_WAYPOINT: res = "waypoint_scripts"; break; default: break; @@ -79,7 +77,6 @@ ScriptMapMap* GetScriptsMapByType(ScriptsType type) ScriptMapMap* res = nullptr; switch (type) { - case SCRIPTS_SPELL: res = &sSpellScripts; break; case SCRIPTS_EVENT: res = &sEventScripts; break; case SCRIPTS_WAYPOINT: res = &sWaypointScripts; break; default: break; @@ -5444,9 +5441,8 @@ void ObjectMgr::LoadScripts(ScriptsType type) scripts->clear(); // need for reload support - bool isSpellScriptTable = (type == SCRIPTS_SPELL); // 0 1 2 3 4 5 6 7 8 9 - QueryResult result = WorldDatabase.PQuery("SELECT id, delay, command, datalong, datalong2, dataint, x, y, z, o{} FROM {}", isSpellScriptTable ? ", effIndex" : "", tableName); + QueryResult result = WorldDatabase.PQuery("SELECT id, delay, command, datalong, datalong2, dataint, x, y, z, o FROM {}", tableName); if (!result) { @@ -5462,8 +5458,6 @@ void ObjectMgr::LoadScripts(ScriptsType type) ScriptInfo tmp; tmp.type = type; tmp.id = fields[0].GetUInt32(); - if (isSpellScriptTable) - tmp.id |= fields[10].GetUInt8() << 24; tmp.delay = fields[1].GetUInt32(); tmp.command = ScriptCommands(fields[2].GetUInt32()); tmp.Raw.nData[0] = fields[3].GetUInt32(); @@ -5738,35 +5732,6 @@ void ObjectMgr::LoadScripts(ScriptsType type) TC_LOG_INFO("server.loading", ">> Loaded {} script definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); } -void ObjectMgr::LoadSpellScripts() -{ - LoadScripts(SCRIPTS_SPELL); - - // check ids - for (ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr) - { - uint32 spellId = uint32(itr->first) & 0x00FFFFFF; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); - - if (!spellInfo) - { - TC_LOG_ERROR("sql.sql", "Table `spell_scripts` has not existing spell (Id: {}) as script id", spellId); - continue; - } - - SpellEffIndex i = SpellEffIndex((uint32(itr->first) >> 24) & 0x000000FF); - if (uint32(i) >= MAX_SPELL_EFFECTS) - { - TC_LOG_ERROR("sql.sql", "Table `spell_scripts` has too high effect index {} for spell (Id: {}) as script id", uint32(i), spellId); - continue; - } - - //check for correct spellEffect - if (!spellInfo->GetEffect(i).Effect || (spellInfo->GetEffect(i).Effect != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->GetEffect(i).Effect != SPELL_EFFECT_DUMMY)) - TC_LOG_ERROR("sql.sql", "Table `spell_scripts` - spell {} effect {} is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, uint32(i)); - } -} - void ObjectMgr::LoadEventScripts() { LoadScripts(SCRIPTS_EVENT); diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 162feb35b3e..aada65ed912 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -173,8 +173,7 @@ enum ScriptsType { SCRIPTS_FIRST = 1, - SCRIPTS_SPELL = SCRIPTS_FIRST, - SCRIPTS_EVENT, + SCRIPTS_EVENT = SCRIPTS_FIRST, SCRIPTS_WAYPOINT, SCRIPTS_LAST @@ -412,7 +411,6 @@ typedef std::multimap ScriptMap; typedef std::map ScriptMapMap; typedef std::multimap> SpellScriptsContainer; typedef std::pair SpellScriptsBounds; -TC_GAME_API extern ScriptMapMap sSpellScripts; TC_GAME_API extern ScriptMapMap sEventScripts; TC_GAME_API extern ScriptMapMap sWaypointScripts; @@ -1138,7 +1136,6 @@ class TC_GAME_API ObjectMgr bool LoadTrinityStrings(); void LoadEventScripts(); - void LoadSpellScripts(); void LoadWaypointScripts(); void LoadSpellScriptNames(); diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index d367f02698d..89ed2e269ff 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -699,10 +699,6 @@ void Spell::EffectDummy() return; } } - - // normal DB scripted effect - TC_LOG_DEBUG("spells", "Spell ScriptStart spellid {} in EffectDummy({})", m_spellInfo->Id, uint32(effectInfo->EffectIndex)); - m_caster->GetMap()->ScriptsStart(sSpellScripts, uint32(m_spellInfo->Id | (effectInfo->EffectIndex << 24)), m_caster, unitTarget); } void Spell::EffectTriggerSpell() @@ -3572,10 +3568,6 @@ void Spell::EffectScriptEffect() break; } } - - // normal DB scripted effect - TC_LOG_DEBUG("spells", "Spell ScriptStart spellid {} in EffectScriptEffect({})", m_spellInfo->Id, uint32(effectInfo->EffectIndex)); - m_caster->GetMap()->ScriptsStart(sSpellScripts, uint32(m_spellInfo->Id | (effectInfo->EffectIndex << 24)), m_caster, unitTarget); } void Spell::EffectSanctuary() diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index d51323a0672..7dda27363ea 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -2087,7 +2087,6 @@ void World::SetInitialWorldSettings() LoadAutobroadcasts(); ///- Load and initialize scripts - sObjectMgr->LoadSpellScripts(); // must be after load Creature/Gameobject(Template/Data) sObjectMgr->LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data) sObjectMgr->LoadWaypointScripts(); diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index 125f83a15f4..4437b2799a2 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -155,7 +155,6 @@ public: { "spell_linked_spell", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LINKED_SPELL, true, &HandleReloadSpellLinkedSpellCommand, "" }, { "spell_pet_auras", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PET_AURAS, true, &HandleReloadSpellPetAurasCommand, "" }, { "spell_proc", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PROC, true, &HandleReloadSpellProcsCommand, "" }, - { "spell_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_SCRIPTS, true, &HandleReloadSpellScriptsCommand, "" }, { "spell_target_position", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_TARGET_POSITION, true, &HandleReloadSpellTargetPositionCommand, "" }, { "spell_threats", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_THREATS, true, &HandleReloadSpellThreatsCommand, "" }, { "spell_group_stack_rules", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP_STACK_RULES, true, &HandleReloadSpellGroupStackRulesCommand, "" }, @@ -271,7 +270,6 @@ public: TC_LOG_INFO("misc", "Re-Loading Scripts..."); HandleReloadEventScriptsCommand(handler, "a"); - HandleReloadSpellScriptsCommand(handler, "a"); handler->SendGlobalGMSysMessage("DB tables `*_scripts` reloaded."); HandleReloadWpScriptsCommand(handler, "a"); HandleReloadWpCommand(handler, "a"); @@ -956,26 +954,6 @@ public: return true; } - static bool HandleReloadSpellScriptsCommand(ChatHandler* handler, char const* args) - { - if (sMapMgr->IsScriptScheduled()) - { - handler->SendSysMessage("DB scripts used currently, please attempt reload later."); - handler->SetSentErrorMessage(true); - return false; - } - - if (*args != 'a') - TC_LOG_INFO("misc", "Re-Loading Scripts from `spell_scripts`..."); - - sObjectMgr->LoadSpellScripts(); - - if (*args != 'a') - handler->SendGlobalGMSysMessage("DB table `spell_scripts` reloaded."); - - return true; - } - static bool HandleReloadGameGraveyardZoneCommand(ChatHandler* handler, char const* /*args*/) { TC_LOG_INFO("misc", "Re-Loading Graveyard-zone links...");