1
0

more /reload spells junk

This commit is contained in:
Emagi 2025-02-09 16:37:16 -05:00
parent 9250118b05
commit 8b4a623f42
4 changed files with 22 additions and 20 deletions

View File

@ -120,8 +120,8 @@ 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);
lua_interface->RemoveSpell(GetInfoStruct()->maintained_effects[i].spell, false, removeClient, "", removeClient);
if (IsPlayer())
GetInfoStruct()->maintained_effects[i].icon = 0xFFFF;
}
@ -136,8 +136,8 @@ 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);
lua_interface->RemoveSpell(GetInfoStruct()->spell_effects[i].spell, false, removeClient, "", removeClient);
}
}
GetInfoStruct()->spell_effects[i].spell_id = 0xFFFFFFFF;

View File

@ -143,24 +143,26 @@ void LuaInterface::Process() {
}
void LuaInterface::DestroySpells() {
MSpells.lock();
MSpellDelete.lock();
MSpellScripts.writelock(__FUNCTION__, __LINE__);
map<string, map<lua_State*, LuaSpell*> >::iterator spell_script_itr;
for(spell_script_itr = spell_scripts.begin(); spell_script_itr != spell_scripts.end(); spell_script_itr++) {
map<lua_State*, LuaSpell*>::iterator inner_itr;
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();
SetLuaUserDataStale(cur_spell);
RemoveCurrentSpell(inner_itr->first, inner_itr->second, false, true, false);
lua_close(inner_itr->first);
safe_delete(cur_spell);
MSpellDelete.unlock();
}
}
current_spells.clear();
spell_scripts.clear();
MSpellScripts.releasewritelock(__FUNCTION__, __LINE__);
MSpellDelete.unlock();
MSpells.unlock();
}
void LuaInterface::DestroyQuests(bool reload) {
@ -895,6 +897,7 @@ void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool
((Entity*)overrideTarget)->RemoveProc(0, spell);
((Entity*)overrideTarget)->RemoveSpellEffect(spell);
((Entity*)overrideTarget)->RemoveSpellBonus(spell);
((Entity*)overrideTarget)->RemoveEffectsFromLuaSpell(spell);
}
return;
}
@ -911,6 +914,7 @@ void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool
((Entity*)target)->RemoveProc(0, spell);
((Entity*)target)->RemoveSpellEffect(spell);
((Entity*)target)->RemoveSpellBonus(spell);
((Entity*)target)->RemoveEffectsFromLuaSpell(spell);
}
multimap<int32,int8>::iterator entries;
@ -922,6 +926,7 @@ void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool
tmpClient->GetPlayer()->RemoveProc(0, spell);
tmpClient->GetPlayer()->RemoveSpellEffect(spell);
tmpClient->GetPlayer()->RemoveSpellBonus(spell);
tmpClient->GetPlayer()->RemoveEffectsFromLuaSpell(spell);
}
}
spell->char_id_targets.clear(); // TODO: reach out to those clients in different
@ -931,21 +936,21 @@ void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool
spell->MSpellTargets.releasereadlock(__FUNCTION__, __LINE__);
if(removing_all_spells) {
if(spell->caster && spell->caster->GetZone()) {
spell->caster->GetZone()->GetSpellProcess()->RemoveSpellScriptTimerBySpell(spell);
spell->caster->GetZone()->GetSpellProcess()->DeleteSpell(spell);
if(spell->zone && spell->zone->GetSpellProcess()) {
spell->zone->GetSpellProcess()->RemoveSpellScriptTimerBySpell(spell);
spell->zone->GetSpellProcess()->DeleteSpell(spell);
}
}
else {
AddPendingSpellDelete(spell);
if (spell->caster)
{
if(spell->caster->GetZone()) {
spell->caster->GetZone()->GetSpellProcess()->RemoveSpellScriptTimerBySpell(spell, false);
if(spell->zone && spell->zone->GetSpellProcess()) {
spell->zone->GetSpellProcess()->RemoveSpellScriptTimerBySpell(spell, false);
}
spell->caster->RemoveProc(0, spell);
spell->caster->RemoveSpellEffect(spell);
spell->caster->RemoveMaintainedSpell(spell);
spell->caster->RemoveEffectsFromLuaSpell(spell);
if(spell->spell && spell->spell->GetSpellData() && spell->caster->IsPlayer() && !removing_all_spells)
{
@ -986,6 +991,7 @@ void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool
}
}
}
AddPendingSpellDelete(spell);
}
}
@ -1683,7 +1689,7 @@ void LuaInterface::DeletePendingSpells(bool all) {
if (!target || !target->IsEntity())
continue;
if(!spellDeleted)
if(!spellDeleted && spell->zone && spell->zone->GetSpellProcess())
spell->zone->GetSpellProcess()->DeleteActiveSpell(spell, true);
spellDeleted = true;
@ -1691,7 +1697,7 @@ void LuaInterface::DeletePendingSpells(bool all) {
spell->MSpellTargets.releasereadlock(__FUNCTION__, __LINE__);
}
if(!spellDeleted && spell->zone != nullptr) {
if(!spellDeleted && spell->zone && spell->zone->GetSpellProcess()) {
spell->zone->GetSpellProcess()->DeleteActiveSpell(spell, true);
}
}

View File

@ -2886,7 +2886,6 @@ void SpellProcess::CheckRemoveTargetFromSpell(LuaSpell* spell, bool allow_delete
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) {

View File

@ -467,9 +467,6 @@ 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;
@ -484,13 +481,13 @@ void ZoneServer::DeleteSpellProcess(){
if(spawn->IsEntity()) {
((Entity*)spawn)->RemoveSpellBonus(nullptr, true);
((Entity*)spawn)->DeleteSpellEffects();
((Entity*)spawn)->DeleteSpellEffects(true);
}
}
MSpawnList.releasereadlock(__FUNCTION__, __LINE__);
MMasterZoneLock->unlock();
MMasterSpawnLock.releasewritelock(__FUNCTION__, __LINE__);
DismissAllPets();
spellProcess->RemoveAllSpells(true);
safe_delete(spellProcess);