Relocate where we set the state into the iterator
This commit is contained in:
parent
a736e1865f
commit
adc9ee0846
@ -614,7 +614,7 @@ void LuaInterface::RemoveCurrentSpell(lua_State* state, LuaSpell* cur_spell, boo
|
|||||||
Mutex* mutex = GetSpellScriptMutex(cur_spell->file_name.c_str());
|
Mutex* mutex = GetSpellScriptMutex(cur_spell->file_name.c_str());
|
||||||
mutex->writelock(__FUNCTION__, __LINE__);
|
mutex->writelock(__FUNCTION__, __LINE__);
|
||||||
map<lua_State*, LuaSpell*>::iterator spell_script_itr2 = spell_script_itr->second.find(state);
|
map<lua_State*, LuaSpell*>::iterator spell_script_itr2 = spell_script_itr->second.find(state);
|
||||||
if(spell_script_itr2 != spell_script_itr->second.end()) {
|
if(spell_script_itr2 != spell_script_itr->second.end() && spell_script_itr2->second == cur_spell) {
|
||||||
spell_script_itr2->second = nullptr;
|
spell_script_itr2->second = nullptr;
|
||||||
}
|
}
|
||||||
mutex->releasewritelock(__FUNCTION__, __LINE__);
|
mutex->releasewritelock(__FUNCTION__, __LINE__);
|
||||||
@ -2317,6 +2317,7 @@ LuaSpell* LuaInterface::GetSpellScript(const char* name, bool create_new, bool u
|
|||||||
{
|
{
|
||||||
lua_State* state = spell_script_itr->first;
|
lua_State* state = spell_script_itr->first;
|
||||||
ret = CreateSpellScript(name, state);
|
ret = CreateSpellScript(name, state);
|
||||||
|
spell_script_itr->second = ret;
|
||||||
break; // don't keep iterating, we already have our result
|
break; // don't keep iterating, we already have our result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2337,7 +2338,6 @@ LuaSpell* LuaInterface::GetSpellScript(const char* name, bool create_new, bool u
|
|||||||
LuaSpell* LuaInterface::CreateSpellScript(const char* name, lua_State* existState) {
|
LuaSpell* LuaInterface::CreateSpellScript(const char* name, lua_State* existState) {
|
||||||
LuaSpell* new_spell = new LuaSpell;
|
LuaSpell* new_spell = new LuaSpell;
|
||||||
new_spell->state = existState;
|
new_spell->state = existState;
|
||||||
spell_scripts[std::string(name)][new_spell->state] = new_spell;
|
|
||||||
new_spell->file_name = string(name);
|
new_spell->file_name = string(name);
|
||||||
new_spell->resisted = false;
|
new_spell->resisted = false;
|
||||||
new_spell->is_damage_spell = false;
|
new_spell->is_damage_spell = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user