1
0

reload spells now works with the lua state redesign and we delete spell in the spell_scripts instead of other places (casttimer, active_spells, so on)

This commit is contained in:
Emagi 2024-09-10 09:14:40 -04:00
parent 297c17b177
commit 555045cbe2
5 changed files with 10 additions and 16 deletions

View File

@ -1948,10 +1948,11 @@ void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* clie
else {
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells & NPC Spell Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
world.SetReloadingSubsystem("Spells");
zone_list.DeleteSpellProcess();
master_spell_list.Reload();
if (lua_interface)
lua_interface->ReloadSpells();
lua_interface->DestroySpells();
master_spell_list.Reload();
zone_list.LoadSpellProcess();
world.RemoveReloadingSubSystem("Spells");
world.PurgeNPCSpells();
@ -3081,9 +3082,9 @@ void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* clie
}
zone_list.DeleteSpellProcess();
master_spell_list.Reload();
if (lua_interface)
lua_interface->ReloadSpells();
lua_interface->DestroySpells();
master_spell_list.Reload();
zone_list.LoadSpellProcess();
if(lua_interface){
map<Client*, int32> debug_clients = lua_interface->GetDebugClients();

View File

@ -151,9 +151,9 @@ void LuaInterface::DestroySpells() {
LuaSpell* cur_spell = inner_itr->second;
MSpellDelete.lock();
RemoveCurrentSpell(inner_itr->first, inner_itr->second, false, true, false);
MSpellDelete.unlock();
lua_close(inner_itr->first);
safe_delete(cur_spell);
MSpellDelete.unlock();
}
Mutex* mutex = GetSpellScriptMutex(spell_script_itr->first.c_str());
@ -260,11 +260,6 @@ void LuaInterface::DestroyRegionScripts() {
MRegionScripts.releasewritelock(__FUNCTION__, __LINE__);
}
void LuaInterface::ReloadSpells() {
DestroySpells();
database.LoadSpellScriptData();
}
bool LuaInterface::LoadItemScript(string name) {
return LoadItemScript(name.c_str());
}
@ -2357,8 +2352,8 @@ LuaSpell* LuaInterface::CreateSpellScript(const char* name, lua_State* existStat
return new_spell;
}
LuaSpell* LuaInterface::GetSpell(const char* name) {
return GetSpellScript(name, true);
LuaSpell* LuaInterface::GetSpell(const char* name, bool use) {
return GetSpellScript(name, true, use);
}
bool LuaInterface::RunItemScript(string script_name, const char* function_name, Item* item, Spawn* spawn, Spawn* target, sint64* returnValue) {

View File

@ -236,7 +236,7 @@ public:
LuaSpell* GetCurrentSpell(lua_State* state, bool needsLock = true);
void RemoveCurrentSpell(lua_State* state, LuaSpell* cur_spell, bool needsLock = true, bool removeCurSpell = true, bool removeSpellScript = true);
bool CallSpellProcess(LuaSpell* spell, int8 num_parameters, std::string functionCalled);
LuaSpell* GetSpell(const char* name);
LuaSpell* GetSpell(const char* name, bool use = true);
void UseItemScript(const char* name, lua_State* state, bool val);
void UseSpawnScript(const char* name, lua_State* state, bool val);
void UseZoneScript(const char* name, lua_State* state, bool val);
@ -269,7 +269,6 @@ public:
void DestroySpells();
void DestroySpawnScripts();
void DestroyItemScripts();
void ReloadSpells();
void DestroyQuests(bool reload = false);
void DestroyZoneScripts();
void DestroyRegionScripts();

View File

@ -83,7 +83,6 @@ void SpellProcess::RemoveAllSpells(bool reload_spells){
MutexList<CastTimer*>::iterator cast_timers_itr = cast_timers.begin();
while(cast_timers_itr.Next()){
safe_delete(cast_timers_itr->value->timer);
safe_delete(cast_timers_itr->value->spell);
cast_timers.Remove(cast_timers_itr->value, true);
}
cast_timers.clear();

View File

@ -4508,7 +4508,7 @@ int32 WorldDatabase::LoadSpellScriptData() {
while (result && (row = mysql_fetch_row(result))) {
if (row[0] && strlen(row[0]) > 0) {
if (lua_interface->GetSpell(row[0]))
if (lua_interface->GetSpell(row[0], false))
LogWrite(SPELL__DEBUG, 5, "Spells", "SpellScript: %s loaded.", row[0]);
}
}