From 0a99511f5cd5a5fa307a28044f6e36f13184259f 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) (cherry picked from commit f2334b6500659d9ab0fb8e0accb4e6d514293ae4) --- sql/base/auth_database.sql | 3 +- .../auth/master/2026_01_12_00_auth.sql | 5 +++ ...026_06_29_03_world_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, 12 insertions(+), 74 deletions(-) create mode 100644 sql/updates/auth/master/2026_01_12_00_auth.sql create mode 100644 sql/updates/world/master/2026_06_29_03_world_2026_01_12_00_world.sql diff --git a/sql/base/auth_database.sql b/sql/base/auth_database.sql index ff2b32475b..bd1134a717 100644 --- a/sql/base/auth_database.sql +++ b/sql/base/auth_database.sql @@ -2704,7 +2704,6 @@ INSERT INTO `rbac_linked_permissions` VALUES (196,697), (196,698), (196,699), -(196,700), (196,701), (196,702), (196,703), @@ -3546,7 +3545,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'), @@ -4308,6 +4306,7 @@ INSERT INTO `updates` VALUES ('2025_12_15_00_auth.sql','CA8ADF39030282B3D2627C15E751CC1D81618BAE','ARCHIVED','2025-12-15 15:39:58',0), ('2025_12_19_00_auth.sql','4011518915C83A60C50009949D687080019FA999','ARCHIVED','2025-12-19 00:48:17',0), ('2026_01_10_00_auth.sql','486B3340298309456E4BFB15F5D77EAB6609443E','ARCHIVED','2026-01-10 11:17:32',0), +('2026_01_12_00_auth.sql','91644588146896CA04E6B8FEDEB34CF4FEB64EEF','RELEASED','2026-01-12 21:26:18',0), ('2026_01_14_00_auth.sql','B1623A33EB59B52AEE841F88B075213AE88A6158','ARCHIVED','2026-01-14 23:40:33',0), ('2026_01_28_00_auth.sql','7FB39DD503AC38CA0600D014377DE34F6B99A6E7','ARCHIVED','2026-01-29 00:02:11',0), ('2026_01_30_00_auth.sql','DCE6882AB5D5897F7CEB863196325712F6313E14','ARCHIVED','2026-01-30 23:22:28',0), diff --git a/sql/updates/auth/master/2026_01_12_00_auth.sql b/sql/updates/auth/master/2026_01_12_00_auth.sql new file mode 100644 index 0000000000..99f01d27d7 --- /dev/null +++ b/sql/updates/auth/master/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/master/2026_06_29_03_world_2026_01_12_00_world.sql b/sql/updates/world/master/2026_06_29_03_world_2026_01_12_00_world.sql new file mode 100644 index 0000000000..022bfafb19 --- /dev/null +++ b/sql/updates/world/master/2026_06_29_03_world_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 c6257a2cd6..3f4d634791 100644 --- a/src/server/game/Accounts/RBAC.h +++ b/src/server/game/Accounts/RBAC.h @@ -571,7 +571,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 fed7074283..fc053f0a7c 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -81,7 +81,6 @@ #include #include -ScriptMapMap sSpellScripts; ScriptMapMap sEventScripts; std::string GetScriptsTableNameByType(ScriptsType type) @@ -89,7 +88,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; default: break; } @@ -101,7 +99,6 @@ ScriptMapMap* GetScriptsMapByType(ScriptsType type) ScriptMapMap* res = nullptr; switch (type) { - case SCRIPTS_SPELL: res = &sSpellScripts; break; case SCRIPTS_EVENT: res = &sEventScripts; break; default: break; } @@ -5567,9 +5564,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) { @@ -5585,8 +5581,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(); @@ -5874,35 +5868,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, DIFFICULTY_NONE); - - 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) >= spellInfo->GetEffects().size()) - { - 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::LoadEventSet() { _eventStore.clear(); diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 3320d06c32..9b587bef62 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -169,8 +169,7 @@ enum ScriptsType { SCRIPTS_FIRST = 1, - SCRIPTS_SPELL = SCRIPTS_FIRST, - SCRIPTS_EVENT, + SCRIPTS_EVENT = SCRIPTS_FIRST, SCRIPTS_WAYPOINT, SCRIPTS_LAST @@ -413,7 +412,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; std::string GetScriptsTableNameByType(ScriptsType type); @@ -1210,7 +1208,6 @@ class TC_GAME_API ObjectMgr bool LoadTrinityStrings(); void LoadEventScripts(); - void LoadSpellScripts(); void LoadSpellScriptNames(); void ValidateSpellScripts(); diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 790775dd62..84d5b79316 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -585,10 +585,6 @@ void Spell::EffectDummy() return; } } - - // normal DB scripted effect - TC_LOG_DEBUG("spells", "Spell ScriptStart spellid {} in EffectDummy({})", m_spellInfo->Id, effectInfo->EffectIndex); - m_caster->GetMap()->ScriptsStart(sSpellScripts, uint32(m_spellInfo->Id | (effectInfo->EffectIndex << 24)), m_caster, unitTarget); } void Spell::EffectTriggerSpell() @@ -3214,10 +3210,6 @@ void Spell::EffectScriptEffect() break; } } - - // normal DB scripted effect - TC_LOG_DEBUG("spells", "Spell ScriptStart spellid {} in EffectScriptEffect({})", m_spellInfo->Id, 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 d95c41ed3e..d4dc44b82c 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1904,7 +1904,6 @@ bool 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) TC_LOG_INFO("server.loading", "Loading spell script names..."); diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index e8e15dd014..fe59fbcf0a 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -157,7 +157,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_script_names", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_SCRIPT_NAMES, true, &HandleReloadSpellScriptNamesCommand, "" }, { "spell_target_position", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_TARGET_POSITION, true, &HandleReloadSpellTargetPositionCommand, "" }, { "spell_threats", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_THREATS, true, &HandleReloadSpellThreatsCommand, "" }, @@ -279,7 +278,6 @@ public: TC_LOG_INFO("misc", "Re-Loading Scripts..."); HandleReloadEventScriptsCommand(handler, "a"); - HandleReloadSpellScriptsCommand(handler, "a"); HandleReloadSpellScriptNamesCommand(handler, "a"); handler->SendGlobalGMSysMessage("DB tables `*_scripts` reloaded."); HandleReloadWpCommand(handler, "a"); @@ -920,26 +918,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 HandleReloadSpellScriptNamesCommand(ChatHandler* handler, const char* /*args*/) { TC_LOG_INFO("misc", "Reloading spell_script_names table...");