Protection around scenario with repop command overrunning the remove targets from spell and also when zone is not available for cast spell on a target or caster

This commit is contained in:
Emagi 2024-03-07 09:48:58 -05:00
parent 39ac029ffc
commit b6aac685a2

View file

@ -660,8 +660,6 @@ bool SpellProcess::CastInstant(Spell* spell, Entity* caster, Entity* target, boo
if(!remove) if(!remove)
return result; return result;
printf("%s: RemoveSpell %s\n", caster->GetName(), lua_spell->spell->GetName());
lua_interface->RemoveSpell(lua_spell, true, SpellScriptTimersHasSpell(lua_spell)); lua_interface->RemoveSpell(lua_spell, true, SpellScriptTimersHasSpell(lua_spell));
return true; return true;
} }
@ -1735,9 +1733,14 @@ bool SpellProcess::CastProcessedSpell(LuaSpell* spell, bool passive, bool in_her
effect_message.replace(effect_message.find("%C"), 2, spell->caster->GetName()); effect_message.replace(effect_message.find("%C"), 2, spell->caster->GetName());
send_to_sender = false; send_to_sender = false;
} }
spell->caster->GetZone()->SimpleMessage(CHANNEL_SPELLS_OTHER, effect_message.c_str(), target, 50, send_to_sender);
if(spell->caster->GetZone()) {
spell->caster->GetZone()->SimpleMessage(CHANNEL_SPELLS_OTHER, effect_message.c_str(), target, 50, send_to_sender);
}
}
if(target->GetZone()) {
target->GetZone()->CallSpawnScript(target, SPAWN_SCRIPT_CASTED_ON, spell->caster, spell->spell->GetName());
} }
target->GetZone()->CallSpawnScript(target, SPAWN_SCRIPT_CASTED_ON, spell->caster, spell->spell->GetName());
} }
} }
else{ else{
@ -2733,6 +2736,7 @@ void SpellProcess::CheckRemoveTargetFromSpell(LuaSpell* spell, bool allow_delete
if (!spell) if (!spell)
return; return;
MRemoveTargetList.writelock(__FUNCTION__, __LINE__);
if (remove_target_list.size() > 0){ if (remove_target_list.size() > 0){
map<LuaSpell*, vector<int32>*>::iterator remove_itr; map<LuaSpell*, vector<int32>*>::iterator remove_itr;
vector<int32>::iterator remove_target_itr; vector<int32>::iterator remove_target_itr;
@ -2742,7 +2746,6 @@ void SpellProcess::CheckRemoveTargetFromSpell(LuaSpell* spell, bool allow_delete
Spawn* remove_spawn = 0; Spawn* remove_spawn = 0;
bool should_delete = false; bool should_delete = false;
MRemoveTargetList.writelock(__FUNCTION__, __LINE__);
for (remove_itr = remove_target_list.begin(); remove_itr != remove_target_list.end(); remove_itr++){ for (remove_itr = remove_target_list.begin(); remove_itr != remove_target_list.end(); remove_itr++){
if (remove_itr->first == spell){ if (remove_itr->first == spell){
targets = &spell->targets; targets = &spell->targets;
@ -2807,6 +2810,9 @@ void SpellProcess::CheckRemoveTargetFromSpell(LuaSpell* spell, bool allow_delete
if (should_delete) if (should_delete)
DeleteCasterSpell(spell, "purged"); DeleteCasterSpell(spell, "purged");
} }
else {
MRemoveTargetList.releasewritelock(__FUNCTION__, __LINE__);
}
} }
bool SpellProcess::AddHO(Client* client, HeroicOP* ho) { bool SpellProcess::AddHO(Client* client, HeroicOP* ho) {