fix hangup on cure

This commit is contained in:
Emagi 2022-11-07 07:43:52 -05:00
parent cd17261b83
commit c7358a5fed
4 changed files with 8 additions and 15 deletions

View file

@ -5866,7 +5866,7 @@ void Commands::Command_CancelMaintained(Client* client, Seperator* sep)
MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
client->GetPlayer()->MMaintainedSpells.releasereadlock(__FUNCTION__, __LINE__);
if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false, true))
if (!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(mEffects.spell, "canceled", false))
client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
}
}
@ -11767,7 +11767,7 @@ void Commands::Command_CancelEffect(Client* client, Seperator* sep)
MaintainedEffects* meffect = effect->caster->GetMaintainedSpell(spell_id);
if (!meffect || !meffect->spell || !meffect->spell->caster ||
!meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, true, client->GetPlayer()))
!meffect->spell->caster->GetZone()->GetSpellProcess()->DeleteCasterSpell(meffect->spell, "canceled", false, client->GetPlayer()))
client->Message(CHANNEL_COLOR_RED, "The spell effect could not be cancelled.");
}
}

View file

@ -2272,7 +2272,7 @@ void Entity::CureDetrimentByType(int8 cure_count, int8 det_type, string cure_nam
LogWrite(PLAYER__ERROR, 0, "Debug", "Remove spell %s", remove_list.at(i)->spell->GetName());
GetZone()->SendDispellPacket(caster, this, cure_name, (string)remove_list.at(i)->spell->GetName(), DISPELL_TYPE_CURE);
GetZone()->GetSpellProcess()->DeleteCasterSpell(spell, "cured", false, true, this);
GetZone()->GetSpellProcess()->DeleteCasterSpell(spell, "cured", false, this);
}
remove_list.clear();
}

View file

@ -49,7 +49,7 @@ void SpellProcess::RemoveAllSpells(){
MutexList<LuaSpell*>::iterator active_spells_itr = active_spells.begin();
while(active_spells_itr.Next()){
DeleteCasterSpell(active_spells_itr->value, "", true);
DeleteCasterSpell(active_spells_itr->value, "");
}
active_spells_itr = active_spells.begin();
@ -368,9 +368,8 @@ bool SpellProcess::DeleteCasterSpell(Spawn* caster, Spell* spell, string reason)
return ret;
}
bool SpellProcess::DeleteCasterSpell(LuaSpell* spell, string reason, bool removing_all_spells, bool lock_spell_process, Spawn* remove_target){
if(lock_spell_process)
MSpellProcess.lock();
bool SpellProcess::DeleteCasterSpell(LuaSpell* spell, string reason, bool removing_all_spells, Spawn* remove_target){
std::shared_lock lock(MSpellProcess);
bool ret = false;
Spawn* target = 0;
@ -394,9 +393,6 @@ bool SpellProcess::DeleteCasterSpell(LuaSpell* spell, string reason, bool removi
}
}
spell->MSpellTargets.releasewritelock(__FUNCTION__, __LINE__);
if(lock_spell_process) {
MSpellProcess.unlock();
}
return target_valid;
}
spell->MSpellTargets.releasewritelock(__FUNCTION__, __LINE__);
@ -490,10 +486,7 @@ bool SpellProcess::DeleteCasterSpell(LuaSpell* spell, string reason, bool removi
}
if(lua_interface)
lua_interface->RemoveSpell(spell, true, SpellScriptTimersHasSpell(spell), reason, removing_all_spells);
}
if(lock_spell_process)
MSpellProcess.unlock();
}
return ret;
}

View file

@ -265,7 +265,7 @@ public:
/// <summary>Remove the given spell from the ZpellProcess</summary>
/// <param name='spell'>LuaSpell to remove</param>
bool DeleteCasterSpell(LuaSpell* spell, string reason="", bool removing_all_spells = false, bool lock_spell_process = false, Spawn* remove_target = nullptr);
bool DeleteCasterSpell(LuaSpell* spell, string reason="", bool removing_all_spells = false, Spawn* remove_target = nullptr);
/// <summary>Interrupt the spell</summary>
/// <param name='interrupt'>InterruptStruct that contains all the info</param>