Skip to content

Commit f2334b6

Browse files
authored
Core/Scripts: Remove old database spell script system (#31484)
1 parent 8787dfe commit f2334b6

File tree

9 files changed

+13
-75
lines changed

9 files changed

+13
-75
lines changed

sql/base/auth_database.sql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,6 @@ INSERT INTO `rbac_linked_permissions` VALUES
13421342
(196,697),
13431343
(196,698),
13441344
(196,699),
1345-
(196,700),
13461345
(196,701),
13471346
(196,702),
13481347
(196,703),
@@ -2169,7 +2168,6 @@ INSERT INTO `rbac_permissions` VALUES
21692168
(697,'Command: reload spell_pet_auras'),
21702169
(698,'Command: character changeaccount'),
21712170
(699,'Command: reload spell_proc'),
2172-
(700,'Command: reload spell_scripts'),
21732171
(701,'Command: reload spell_target_position'),
21742172
(702,'Command: reload spell_threats'),
21752173
(703,'Command: reload spell_group_stack_rules'),
@@ -2533,7 +2531,8 @@ INSERT INTO `updates` VALUES
25332531
('2024_09_26_00_auth.sql','E37C3997FD7851EA360774AC568912846C448272','ARCHIVED','2024-09-26 18:27:26',0),
25342532
('2024_11_22_00_auth.sql','F2C1D1572A3968E9E9D778EF7DC82778DF3EF887','ARCHIVED','2024-11-22 23:18:14',0),
25352533
('2025_02_14_00_auth.sql','4A30E92FF519BB41C520CDBF90019291217C26A2','ARCHIVED','2025-02-14 17:20:00',0),
2536-
('2025_10_21_00_auth.sql','1A221989F98337CB285B4328E791F5531CFD2454','ARCHIVED','2025-10-21 18:16:45',0);
2534+
('2025_10_21_00_auth.sql','1A221989F98337CB285B4328E791F5531CFD2454','ARCHIVED','2025-10-21 18:16:45',0),
2535+
('2026_01_12_00_auth.sql','91644588146896CA04E6B8FEDEB34CF4FEB64EEF','RELEASED','2026-01-12 21:26:18',0);
25372536
/*!40000 ALTER TABLE `updates` ENABLE KEYS */;
25382537
UNLOCK TABLES;
25392538

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--
2+
DELETE FROM `rbac_account_permissions` WHERE `permissionId`=700;
3+
DELETE FROM `rbac_default_permissions` WHERE `permissionId`=700;
4+
DELETE FROM `rbac_linked_permissions` WHERE `linkedId`=700;
5+
DELETE FROM `rbac_permissions` WHERE `id`=700;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--
2+
DROP TABLE IF EXISTS `spell_scripts`;
3+
DELETE FROM `command` WHERE `name` = 'reload spell_scripts';

src/server/game/Accounts/RBAC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ enum RBACPermissions
567567
RBAC_PERM_COMMAND_RELOAD_SPELL_PET_AURAS = 697,
568568
RBAC_PERM_COMMAND_CHARACTER_CHANGEACCOUNT = 698,
569569
RBAC_PERM_COMMAND_RELOAD_SPELL_PROC = 699,
570-
RBAC_PERM_COMMAND_RELOAD_SPELL_SCRIPTS = 700,
570+
// 700 previously used, do not reuse
571571
RBAC_PERM_COMMAND_RELOAD_SPELL_TARGET_POSITION = 701,
572572
RBAC_PERM_COMMAND_RELOAD_SPELL_THREATS = 702,
573573
RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP_STACK_RULES = 703,

src/server/game/Globals/ObjectMgr.cpp

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
#include "Vehicle.h"
5858
#include "World.h"
5959

60-
ScriptMapMap sSpellScripts;
6160
ScriptMapMap sEventScripts;
6261
ScriptMapMap sWaypointScripts;
6362

@@ -66,7 +65,6 @@ std::string GetScriptsTableNameByType(ScriptsType type)
6665
std::string res = "";
6766
switch (type)
6867
{
69-
case SCRIPTS_SPELL: res = "spell_scripts"; break;
7068
case SCRIPTS_EVENT: res = "event_scripts"; break;
7169
case SCRIPTS_WAYPOINT: res = "waypoint_scripts"; break;
7270
default: break;
@@ -79,7 +77,6 @@ ScriptMapMap* GetScriptsMapByType(ScriptsType type)
7977
ScriptMapMap* res = nullptr;
8078
switch (type)
8179
{
82-
case SCRIPTS_SPELL: res = &sSpellScripts; break;
8380
case SCRIPTS_EVENT: res = &sEventScripts; break;
8481
case SCRIPTS_WAYPOINT: res = &sWaypointScripts; break;
8582
default: break;
@@ -5444,9 +5441,8 @@ void ObjectMgr::LoadScripts(ScriptsType type)
54445441

54455442
scripts->clear(); // need for reload support
54465443

5447-
bool isSpellScriptTable = (type == SCRIPTS_SPELL);
54485444
// 0 1 2 3 4 5 6 7 8 9
5449-
QueryResult result = WorldDatabase.PQuery("SELECT id, delay, command, datalong, datalong2, dataint, x, y, z, o{} FROM {}", isSpellScriptTable ? ", effIndex" : "", tableName);
5445+
QueryResult result = WorldDatabase.PQuery("SELECT id, delay, command, datalong, datalong2, dataint, x, y, z, o FROM {}", tableName);
54505446

54515447
if (!result)
54525448
{
@@ -5462,8 +5458,6 @@ void ObjectMgr::LoadScripts(ScriptsType type)
54625458
ScriptInfo tmp;
54635459
tmp.type = type;
54645460
tmp.id = fields[0].GetUInt32();
5465-
if (isSpellScriptTable)
5466-
tmp.id |= fields[10].GetUInt8() << 24;
54675461
tmp.delay = fields[1].GetUInt32();
54685462
tmp.command = ScriptCommands(fields[2].GetUInt32());
54695463
tmp.Raw.nData[0] = fields[3].GetUInt32();
@@ -5738,35 +5732,6 @@ void ObjectMgr::LoadScripts(ScriptsType type)
57385732
TC_LOG_INFO("server.loading", ">> Loaded {} script definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
57395733
}
57405734

5741-
void ObjectMgr::LoadSpellScripts()
5742-
{
5743-
LoadScripts(SCRIPTS_SPELL);
5744-
5745-
// check ids
5746-
for (ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr)
5747-
{
5748-
uint32 spellId = uint32(itr->first) & 0x00FFFFFF;
5749-
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
5750-
5751-
if (!spellInfo)
5752-
{
5753-
TC_LOG_ERROR("sql.sql", "Table `spell_scripts` has not existing spell (Id: {}) as script id", spellId);
5754-
continue;
5755-
}
5756-
5757-
SpellEffIndex i = SpellEffIndex((uint32(itr->first) >> 24) & 0x000000FF);
5758-
if (uint32(i) >= MAX_SPELL_EFFECTS)
5759-
{
5760-
TC_LOG_ERROR("sql.sql", "Table `spell_scripts` has too high effect index {} for spell (Id: {}) as script id", uint32(i), spellId);
5761-
continue;
5762-
}
5763-
5764-
//check for correct spellEffect
5765-
if (!spellInfo->GetEffect(i).Effect || (spellInfo->GetEffect(i).Effect != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->GetEffect(i).Effect != SPELL_EFFECT_DUMMY))
5766-
TC_LOG_ERROR("sql.sql", "Table `spell_scripts` - spell {} effect {} is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, uint32(i));
5767-
}
5768-
}
5769-
57705735
void ObjectMgr::LoadEventScripts()
57715736
{
57725737
LoadScripts(SCRIPTS_EVENT);

src/server/game/Globals/ObjectMgr.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ enum ScriptsType
173173
{
174174
SCRIPTS_FIRST = 1,
175175

176-
SCRIPTS_SPELL = SCRIPTS_FIRST,
177-
SCRIPTS_EVENT,
176+
SCRIPTS_EVENT = SCRIPTS_FIRST,
178177
SCRIPTS_WAYPOINT,
179178

180179
SCRIPTS_LAST
@@ -412,7 +411,6 @@ typedef std::multimap<uint32, ScriptInfo> ScriptMap;
412411
typedef std::map<uint32, ScriptMap> ScriptMapMap;
413412
typedef std::multimap<uint32 /*spell id*/, std::pair<uint32 /*script id*/, bool /*enabled*/>> SpellScriptsContainer;
414413
typedef std::pair<SpellScriptsContainer::iterator, SpellScriptsContainer::iterator> SpellScriptsBounds;
415-
TC_GAME_API extern ScriptMapMap sSpellScripts;
416414
TC_GAME_API extern ScriptMapMap sEventScripts;
417415
TC_GAME_API extern ScriptMapMap sWaypointScripts;
418416

@@ -1138,7 +1136,6 @@ class TC_GAME_API ObjectMgr
11381136
bool LoadTrinityStrings();
11391137

11401138
void LoadEventScripts();
1141-
void LoadSpellScripts();
11421139
void LoadWaypointScripts();
11431140

11441141
void LoadSpellScriptNames();

src/server/game/Spells/SpellEffects.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,6 @@ void Spell::EffectDummy()
699699
return;
700700
}
701701
}
702-
703-
// normal DB scripted effect
704-
TC_LOG_DEBUG("spells", "Spell ScriptStart spellid {} in EffectDummy({})", m_spellInfo->Id, uint32(effectInfo->EffectIndex));
705-
m_caster->GetMap()->ScriptsStart(sSpellScripts, uint32(m_spellInfo->Id | (effectInfo->EffectIndex << 24)), m_caster, unitTarget);
706702
}
707703

708704
void Spell::EffectTriggerSpell()
@@ -3572,10 +3568,6 @@ void Spell::EffectScriptEffect()
35723568
break;
35733569
}
35743570
}
3575-
3576-
// normal DB scripted effect
3577-
TC_LOG_DEBUG("spells", "Spell ScriptStart spellid {} in EffectScriptEffect({})", m_spellInfo->Id, uint32(effectInfo->EffectIndex));
3578-
m_caster->GetMap()->ScriptsStart(sSpellScripts, uint32(m_spellInfo->Id | (effectInfo->EffectIndex << 24)), m_caster, unitTarget);
35793571
}
35803572

35813573
void Spell::EffectSanctuary()

src/server/game/World/World.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,6 @@ void World::SetInitialWorldSettings()
20872087
LoadAutobroadcasts();
20882088

20892089
///- Load and initialize scripts
2090-
sObjectMgr->LoadSpellScripts(); // must be after load Creature/Gameobject(Template/Data)
20912090
sObjectMgr->LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data)
20922091
sObjectMgr->LoadWaypointScripts();
20932092

src/server/scripts/Commands/cs_reload.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ class reload_commandscript : public CommandScript
155155
{ "spell_linked_spell", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LINKED_SPELL, true, &HandleReloadSpellLinkedSpellCommand, "" },
156156
{ "spell_pet_auras", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PET_AURAS, true, &HandleReloadSpellPetAurasCommand, "" },
157157
{ "spell_proc", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PROC, true, &HandleReloadSpellProcsCommand, "" },
158-
{ "spell_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_SCRIPTS, true, &HandleReloadSpellScriptsCommand, "" },
159158
{ "spell_target_position", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_TARGET_POSITION, true, &HandleReloadSpellTargetPositionCommand, "" },
160159
{ "spell_threats", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_THREATS, true, &HandleReloadSpellThreatsCommand, "" },
161160
{ "spell_group_stack_rules", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP_STACK_RULES, true, &HandleReloadSpellGroupStackRulesCommand, "" },
@@ -271,7 +270,6 @@ class reload_commandscript : public CommandScript
271270

272271
TC_LOG_INFO("misc", "Re-Loading Scripts...");
273272
HandleReloadEventScriptsCommand(handler, "a");
274-
HandleReloadSpellScriptsCommand(handler, "a");
275273
handler->SendGlobalGMSysMessage("DB tables `*_scripts` reloaded.");
276274
HandleReloadWpScriptsCommand(handler, "a");
277275
HandleReloadWpCommand(handler, "a");
@@ -956,26 +954,6 @@ class reload_commandscript : public CommandScript
956954
return true;
957955
}
958956

959-
static bool HandleReloadSpellScriptsCommand(ChatHandler* handler, char const* args)
960-
{
961-
if (sMapMgr->IsScriptScheduled())
962-
{
963-
handler->SendSysMessage("DB scripts used currently, please attempt reload later.");
964-
handler->SetSentErrorMessage(true);
965-
return false;
966-
}
967-
968-
if (*args != 'a')
969-
TC_LOG_INFO("misc", "Re-Loading Scripts from `spell_scripts`...");
970-
971-
sObjectMgr->LoadSpellScripts();
972-
973-
if (*args != 'a')
974-
handler->SendGlobalGMSysMessage("DB table `spell_scripts` reloaded.");
975-
976-
return true;
977-
}
978-
979957
static bool HandleReloadGameGraveyardZoneCommand(ChatHandler* handler, char const* /*args*/)
980958
{
981959
TC_LOG_INFO("misc", "Re-Loading Graveyard-zone links...");

0 commit comments

Comments
 (0)