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,7 +120,7 @@ void Entity::DeleteSpellEffects(bool removeClient)
if(deletedPtrs.find(GetInfoStruct()->maintained_effects[i].spell) == deletedPtrs.end()) if(deletedPtrs.find(GetInfoStruct()->maintained_effects[i].spell) == deletedPtrs.end())
{ {
deletedPtrs[GetInfoStruct()->maintained_effects[i].spell] = true; 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()) if (IsPlayer())
GetInfoStruct()->maintained_effects[i].icon = 0xFFFF; GetInfoStruct()->maintained_effects[i].icon = 0xFFFF;
@ -136,7 +136,7 @@ void Entity::DeleteSpellEffects(bool removeClient)
if(GetInfoStruct()->spell_effects[i].spell && GetInfoStruct()->spell_effects[i].spell->spell && 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) { GetInfoStruct()->spell_effects[i].spell->spell->GetSpellData()->spell_book_type == SPELL_BOOK_TYPE_NOT_SHOWN) {
deletedPtrs[GetInfoStruct()->spell_effects[i].spell] = true; 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);
} }
} }

View File

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

View File

@ -2886,7 +2886,6 @@ void SpellProcess::CheckRemoveTargetFromSpell(LuaSpell* spell, bool allow_delete
remove_targets->clear(); remove_targets->clear();
safe_delete(remove_targets); safe_delete(remove_targets);
MRemoveTargetList.releasewritelock(__FUNCTION__, __LINE__); MRemoveTargetList.releasewritelock(__FUNCTION__, __LINE__);
for(int s=0;s<spawnsToRemove.size();s++) { for(int s=0;s<spawnsToRemove.size();s++) {
Spawn* target = spawnsToRemove.at(s); Spawn* target = spawnsToRemove.at(s);
if(target) { if(target) {

View File

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