Core/Scripts: Remove old database spell script system (#31484)
(cherry picked from commit f2334b6500659d9ab0fb8e0accb4e6d514293ae4)
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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;
|
||||
@@ -0,0 +1,3 @@
|
||||
--
|
||||
DROP TABLE IF EXISTS `spell_scripts`;
|
||||
DELETE FROM `command` WHERE `name` = 'reload spell_scripts';
|
||||
@@ -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,
|
||||
|
||||
@@ -81,7 +81,6 @@
|
||||
#include <limits>
|
||||
#include <numeric>
|
||||
|
||||
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();
|
||||
|
||||
@@ -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<uint32, ScriptInfo> ScriptMap;
|
||||
typedef std::map<uint32, ScriptMap> ScriptMapMap;
|
||||
typedef std::multimap<uint32 /*spell id*/, std::pair<uint32 /*script id*/, bool /*enabled*/>> SpellScriptsContainer;
|
||||
typedef std::pair<SpellScriptsContainer::iterator, SpellScriptsContainer::iterator> 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();
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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...");
|
||||
|
||||
@@ -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...");
|
||||
|
||||
Reference in New Issue
Block a user