More work for /reload spells when multiple zones / players are on
This commit is contained in:
parent
764be385ad
commit
9250118b05
@ -1954,9 +1954,6 @@ void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* clie
|
||||
else {
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Spells & NPC Spell Lists (Note: Must Reload Spawns/Repop to reset npc spells)...");
|
||||
world.SetReloadingSubsystem("Spells");
|
||||
if (lua_interface)
|
||||
lua_interface->DestroySpells();
|
||||
|
||||
zone_list.DeleteSpellProcess();
|
||||
master_spell_list.Reload();
|
||||
zone_list.LoadSpellProcess();
|
||||
|
@ -120,6 +120,7 @@ void Entity::DeleteSpellEffects(bool removeClient)
|
||||
if(deletedPtrs.find(GetInfoStruct()->maintained_effects[i].spell) == deletedPtrs.end())
|
||||
{
|
||||
deletedPtrs[GetInfoStruct()->maintained_effects[i].spell] = true;
|
||||
if(removeClient)
|
||||
lua_interface->RemoveSpell(GetInfoStruct()->maintained_effects[i].spell, false, removeClient, "", removeClient);
|
||||
if (IsPlayer())
|
||||
GetInfoStruct()->maintained_effects[i].icon = 0xFFFF;
|
||||
@ -135,6 +136,7 @@ void Entity::DeleteSpellEffects(bool removeClient)
|
||||
if(GetInfoStruct()->spell_effects[i].spell && GetInfoStruct()->spell_effects[i].spell->spell &&
|
||||
GetInfoStruct()->spell_effects[i].spell->spell->GetSpellData()->spell_book_type == SPELL_BOOK_TYPE_NOT_SHOWN) {
|
||||
deletedPtrs[GetInfoStruct()->spell_effects[i].spell] = true;
|
||||
if(removeClient)
|
||||
lua_interface->RemoveSpell(GetInfoStruct()->spell_effects[i].spell, false, removeClient, "", removeClient);
|
||||
}
|
||||
}
|
||||
|
@ -150,34 +150,15 @@ void LuaInterface::DestroySpells() {
|
||||
for(inner_itr = spell_script_itr->second.begin(); inner_itr != spell_script_itr->second.end(); inner_itr++) {
|
||||
LuaSpell* cur_spell = inner_itr->second;
|
||||
MSpellDelete.lock();
|
||||
|
||||
ZoneServer* zone = nullptr;
|
||||
if(cur_spell && cur_spell->zone) {
|
||||
zone = cur_spell->zone;
|
||||
cur_spell->MSpellTargets.readlock(__FUNCTION__, __LINE__);
|
||||
for (int8 i = 0; i < cur_spell->targets.size(); i++) {
|
||||
Spawn* target = cur_spell->zone->GetSpawnByID(cur_spell->targets.at(i));
|
||||
if (!target || !target->IsEntity())
|
||||
continue;
|
||||
|
||||
cur_spell->zone->RemoveTargetFromSpell(cur_spell, target);
|
||||
}
|
||||
cur_spell->MSpellTargets.releasereadlock(__FUNCTION__, __LINE__);
|
||||
zone->GetSpellProcess()->CheckRemoveTargetFromSpell(cur_spell, false, true);
|
||||
}
|
||||
SetLuaUserDataStale(cur_spell);
|
||||
RemoveCurrentSpell(inner_itr->first, inner_itr->second, false, true, false);
|
||||
lua_close(inner_itr->first);
|
||||
safe_delete(cur_spell);
|
||||
MSpellDelete.unlock();
|
||||
}
|
||||
|
||||
Mutex* mutex = GetSpellScriptMutex(spell_script_itr->first.c_str());
|
||||
safe_delete(mutex);
|
||||
}
|
||||
current_spells.clear();
|
||||
|
||||
spell_scripts_mutex.clear();
|
||||
spell_scripts.clear();
|
||||
MSpellScripts.releasewritelock(__FUNCTION__, __LINE__);
|
||||
}
|
||||
@ -919,12 +900,11 @@ void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool
|
||||
}
|
||||
|
||||
spell->MSpellTargets.readlock(__FUNCTION__, __LINE__);
|
||||
if(spell->caster) {
|
||||
for (int8 i = 0; i < spell->targets.size(); i++) {
|
||||
if(!spell->caster->GetZone())
|
||||
continue;
|
||||
if(!spell->zone)
|
||||
break;
|
||||
|
||||
Spawn* target = spell->caster->GetZone()->GetSpawnByID(spell->targets.at(i));
|
||||
Spawn* target = spell->zone->GetSpawnByID(spell->targets.at(i));
|
||||
if (!target || !target->IsEntity())
|
||||
continue;
|
||||
|
||||
@ -932,7 +912,6 @@ void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool
|
||||
((Entity*)target)->RemoveSpellEffect(spell);
|
||||
((Entity*)target)->RemoveSpellBonus(spell);
|
||||
}
|
||||
}
|
||||
|
||||
multimap<int32,int8>::iterator entries;
|
||||
for(entries = spell->char_id_targets.begin(); entries != spell->char_id_targets.end(); entries++)
|
||||
|
@ -40,7 +40,7 @@ SpellProcess::SpellProcess(){
|
||||
}
|
||||
|
||||
SpellProcess::~SpellProcess(){
|
||||
RemoveAllSpells();
|
||||
|
||||
}
|
||||
|
||||
void SpellProcess::RemoveCaster(Spawn* caster, bool lock_spell_process){
|
||||
@ -2881,7 +2881,12 @@ void SpellProcess::CheckRemoveTargetFromSpell(LuaSpell* spell, bool allow_delete
|
||||
}
|
||||
}
|
||||
|
||||
remove_target_list.erase(spell);
|
||||
if (remove_targets)
|
||||
remove_targets->clear();
|
||||
safe_delete(remove_targets);
|
||||
MRemoveTargetList.releasewritelock(__FUNCTION__, __LINE__);
|
||||
|
||||
for(int s=0;s<spawnsToRemove.size();s++) {
|
||||
Spawn* target = spawnsToRemove.at(s);
|
||||
if(target) {
|
||||
@ -2896,13 +2901,6 @@ void SpellProcess::CheckRemoveTargetFromSpell(LuaSpell* spell, bool allow_delete
|
||||
}
|
||||
}
|
||||
|
||||
MRemoveTargetList.writelock(__FUNCTION__, __LINE__);
|
||||
|
||||
remove_target_list.erase(spell);
|
||||
if (remove_targets)
|
||||
remove_targets->clear();
|
||||
safe_delete(remove_targets);
|
||||
MRemoveTargetList.releasewritelock(__FUNCTION__, __LINE__);
|
||||
if (should_delete)
|
||||
DeleteCasterSpell(spell, "purged");
|
||||
}
|
||||
|
@ -215,9 +215,6 @@ ZoneServer::~ZoneServer() {
|
||||
Sleep(10);
|
||||
}
|
||||
|
||||
if(spellProcess)
|
||||
spellProcess->RemoveAllSpells(true);
|
||||
|
||||
MChangedSpawns.lock();
|
||||
changed_spawns.clear();
|
||||
MChangedSpawns.unlock();
|
||||
@ -233,6 +230,9 @@ ZoneServer::~ZoneServer() {
|
||||
|
||||
DeleteGlobalSpawns();
|
||||
|
||||
if(spellProcess)
|
||||
spellProcess->RemoveAllSpells();
|
||||
|
||||
DeleteFlightPaths();
|
||||
|
||||
MMasterSpawnLock.releasewritelock(__FUNCTION__, __LINE__);
|
||||
@ -467,6 +467,9 @@ void ZoneServer::InitWeather()
|
||||
}
|
||||
void ZoneServer::DeleteSpellProcess(){
|
||||
//Just get a lock to make sure we aren't already looping the spawnprocess or clientprocess if this is different than the calling thread
|
||||
if (lua_interface)
|
||||
lua_interface->DestroySpells();
|
||||
|
||||
MMasterSpawnLock.writelock(__FUNCTION__, __LINE__);
|
||||
MMasterZoneLock->lock();
|
||||
reloading_spellprocess = true;
|
||||
@ -481,7 +484,7 @@ void ZoneServer::DeleteSpellProcess(){
|
||||
|
||||
if(spawn->IsEntity()) {
|
||||
((Entity*)spawn)->RemoveSpellBonus(nullptr, true);
|
||||
((Entity*)spawn)->DeleteSpellEffects(true);
|
||||
((Entity*)spawn)->DeleteSpellEffects();
|
||||
}
|
||||
}
|
||||
MSpawnList.releasereadlock(__FUNCTION__, __LINE__);
|
||||
|
Loading…
x
Reference in New Issue
Block a user