restrict spell state assignment during deletion of spells
This commit is contained in:
parent
d9d2121b62
commit
231c866c2c
3 changed files with 14 additions and 6 deletions
|
@ -624,13 +624,19 @@ LuaSpell* LuaInterface::GetCurrentSpell(lua_State* state, bool needsLock) {
|
|||
return spell;
|
||||
}
|
||||
|
||||
void LuaInterface::RemoveCurrentSpell(lua_State* state) {
|
||||
void LuaInterface::RemoveCurrentSpell(lua_State* state, bool needsLock) {
|
||||
if(needsLock) {
|
||||
MSpells.lock();
|
||||
MSpellDelete.lock();
|
||||
}
|
||||
map<lua_State*, LuaSpell*>::iterator itr = current_spells.find(state);
|
||||
if(itr != current_spells.end())
|
||||
current_spells.erase(itr);
|
||||
if(needsLock) {
|
||||
MSpellDelete.unlock();
|
||||
MSpells.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
bool LuaInterface::CallSpellProcess(LuaSpell* spell, int8 num_parameters, std::string customFunction) {
|
||||
if(shutting_down || !spell || !spell->caster)
|
||||
|
@ -1570,6 +1576,7 @@ void LuaInterface::AddUserDataPtr(LUAUserData* data, void* data_ptr) {
|
|||
}
|
||||
|
||||
void LuaInterface::DeletePendingSpells(bool all) {
|
||||
MSpells.lock();
|
||||
MSpellDelete.lock();
|
||||
if (spells_pending_delete.size() > 0) {
|
||||
int32 time = Timer::GetCurrentTime2();
|
||||
|
@ -1609,11 +1616,12 @@ void LuaInterface::DeletePendingSpells(bool all) {
|
|||
}
|
||||
|
||||
SetLuaUserDataStale(spell);
|
||||
RemoveCurrentSpell(spell->state);
|
||||
RemoveCurrentSpell(spell->state, false);
|
||||
safe_delete(spell);
|
||||
}
|
||||
}
|
||||
MSpellDelete.unlock();
|
||||
MSpells.unlock();
|
||||
}
|
||||
|
||||
void LuaInterface::DeletePendingSpell(LuaSpell* spell) {
|
||||
|
|
|
@ -233,7 +233,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);
|
||||
LuaSpell* GetCurrentSpell(lua_State* state, bool needsLock = true);
|
||||
void RemoveCurrentSpell(lua_State* state);
|
||||
void RemoveCurrentSpell(lua_State* state, bool needsLock = true);
|
||||
bool CallSpellProcess(LuaSpell* spell, int8 num_parameters, std::string functionCalled);
|
||||
LuaSpell* GetSpell(const char* name);
|
||||
void UseItemScript(const char* name, lua_State* state, bool val);
|
||||
|
|
|
@ -2947,7 +2947,7 @@ void SpellProcess::DeleteSpell(LuaSpell* spell)
|
|||
}
|
||||
|
||||
lua_interface->SetLuaUserDataStale(spell);
|
||||
lua_interface->RemoveCurrentSpell(spell->state);
|
||||
lua_interface->RemoveCurrentSpell(spell->state, true);
|
||||
|
||||
DeleteActiveSpell(spell);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue