Update LuaInterface::DestroySpells to assure we cover all the new lua states under the spell_scripts instead of the obselete spells map
This commit is contained in:
parent
14003ee3a4
commit
fb592b4d76
@ -143,17 +143,25 @@ void LuaInterface::Process() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LuaInterface::DestroySpells() {
|
void LuaInterface::DestroySpells() {
|
||||||
map<string, LuaSpell*>::iterator itr;
|
|
||||||
MSpells.lock();
|
MSpells.lock();
|
||||||
for(itr = spells.begin(); itr != spells.end(); itr++){
|
map<string, map<lua_State*, LuaSpell*> >::iterator spell_script_itr;
|
||||||
MSpellDelete.lock();
|
for(spell_script_itr = spell_scripts.begin(); spell_script_itr != spell_scripts.end(); spell_script_itr++) {
|
||||||
RemoveCurrentSpell(itr->second->state, itr->second, false);
|
map<lua_State*, LuaSpell*>::iterator inner_itr;
|
||||||
MSpellDelete.unlock();
|
for(inner_itr = spell_script_itr->second.begin(); inner_itr != spell_script_itr->second.end(); inner_itr++) {
|
||||||
lua_close(itr->second->state);
|
LuaSpell* cur_spell = inner_itr->second;
|
||||||
safe_delete(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
Mutex* mutex = GetSpellScriptMutex(spell_script_itr->first.c_str());
|
||||||
|
safe_delete(mutex);
|
||||||
}
|
}
|
||||||
|
current_spells.clear();
|
||||||
|
spell_scripts_mutex.clear();
|
||||||
spell_scripts.clear();
|
spell_scripts.clear();
|
||||||
spells.clear();
|
|
||||||
MSpells.unlock();
|
MSpells.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,13 +605,13 @@ LuaSpell* LuaInterface::GetCurrentSpell(lua_State* state, bool needsLock) {
|
|||||||
return spell;
|
return spell;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaInterface::RemoveCurrentSpell(lua_State* state, LuaSpell* cur_spell, bool needsLock, bool removeCurSpell) {
|
void LuaInterface::RemoveCurrentSpell(lua_State* state, LuaSpell* cur_spell, bool needsLock, bool removeCurSpell, bool removeSpellScript) {
|
||||||
if(needsLock) {
|
if(needsLock) {
|
||||||
MSpells.lock();
|
MSpells.lock();
|
||||||
MSpellDelete.lock();
|
MSpellDelete.lock();
|
||||||
}
|
}
|
||||||
map<lua_State*, LuaSpell*>::iterator itr = current_spells.find(state);
|
map<lua_State*, LuaSpell*>::iterator itr = current_spells.find(state);
|
||||||
if(itr->second) {
|
if(removeSpellScript && itr->second) {
|
||||||
MSpellScripts.readlock(__FUNCTION__, __LINE__);
|
MSpellScripts.readlock(__FUNCTION__, __LINE__);
|
||||||
map<string, map<lua_State*, LuaSpell*> >::iterator spell_script_itr = spell_scripts.find(cur_spell->file_name);
|
map<string, map<lua_State*, LuaSpell*> >::iterator spell_script_itr = spell_scripts.find(cur_spell->file_name);
|
||||||
if(spell_script_itr != spell_scripts.end()) {
|
if(spell_script_itr != spell_scripts.end()) {
|
||||||
|
@ -234,7 +234,7 @@ public:
|
|||||||
|
|
||||||
std::string AddSpawnPointers(LuaSpell* spell, bool first_cast, bool precast = false, const char* function = 0, SpellScriptTimer* timer = 0, bool passLuaSpell=false, Spawn* altTarget = 0);
|
std::string AddSpawnPointers(LuaSpell* spell, bool first_cast, bool precast = false, const char* function = 0, SpellScriptTimer* timer = 0, bool passLuaSpell=false, Spawn* altTarget = 0);
|
||||||
LuaSpell* GetCurrentSpell(lua_State* state, bool needsLock = true);
|
LuaSpell* GetCurrentSpell(lua_State* state, bool needsLock = true);
|
||||||
void RemoveCurrentSpell(lua_State* state, LuaSpell* cur_spell, bool needsLock = true, bool removeCurSpell = 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);
|
bool CallSpellProcess(LuaSpell* spell, int8 num_parameters, std::string functionCalled);
|
||||||
LuaSpell* GetSpell(const char* name);
|
LuaSpell* GetSpell(const char* name);
|
||||||
void UseItemScript(const char* name, lua_State* state, bool val);
|
void UseItemScript(const char* name, lua_State* state, bool val);
|
||||||
@ -322,7 +322,6 @@ private:
|
|||||||
vector<string>* GetDirectoryListing(const char* directory);
|
vector<string>* GetDirectoryListing(const char* directory);
|
||||||
lua_State* LoadLuaFile(const char* name);
|
lua_State* LoadLuaFile(const char* name);
|
||||||
void RegisterFunctions(lua_State* state);
|
void RegisterFunctions(lua_State* state);
|
||||||
map<string, LuaSpell*> spells;
|
|
||||||
map<lua_State*, string> inverse_spells;
|
map<lua_State*, string> inverse_spells;
|
||||||
|
|
||||||
map<int32, Quest*> quests;
|
map<int32, Quest*> quests;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user