From e246609d3498108e018547b1a21c915355a25913 Mon Sep 17 00:00:00 2001 From: Emagi Date: Tue, 10 Sep 2024 18:36:47 -0400 Subject: [PATCH] AddControlEffect requires a luaspell be passed. On load of spell script data we remove the useless luaspell ptr. --- source/WorldServer/LuaFunctions.cpp | 2 +- source/WorldServer/WorldDatabase.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source/WorldServer/LuaFunctions.cpp b/source/WorldServer/LuaFunctions.cpp index 559418f..239148c 100644 --- a/source/WorldServer/LuaFunctions.cpp +++ b/source/WorldServer/LuaFunctions.cpp @@ -2725,7 +2725,7 @@ int EQ2Emu_lua_AddControlEffect(lua_State* state) { bool only_add_spawn = lua_interface->GetInt8Value(state, 3) == 1; LuaSpell* luaspell = lua_interface->GetCurrentSpell(state); - if(luaspell && luaspell->resisted) { + if(!luaspell || luaspell->resisted) { lua_interface->ResetFunctionStack(state); return 0; } diff --git a/source/WorldServer/WorldDatabase.cpp b/source/WorldServer/WorldDatabase.cpp index 665c199..833a7e5 100644 --- a/source/WorldServer/WorldDatabase.cpp +++ b/source/WorldServer/WorldDatabase.cpp @@ -4508,8 +4508,13 @@ int32 WorldDatabase::LoadSpellScriptData() { while (result && (row = mysql_fetch_row(result))) { if (row[0] && strlen(row[0]) > 0) { - if (lua_interface->GetSpell(row[0], false)) + LuaSpell* testSpell = nullptr; + if ((testSpell = lua_interface->GetSpell(row[0], false)) != nullptr) { LogWrite(SPELL__DEBUG, 5, "Spells", "SpellScript: %s loaded.", row[0]); + // make the lua_state available to the queue, this isn't a real Spell just a test load + lua_interface->RemoveCurrentSpell(testSpell->state, testSpell); + safe_delete(testSpell); + } } }