1
0

Attempt to fix deleting spells more than once if short durations

This commit is contained in:
Emagi 2024-09-02 08:15:41 -04:00
parent 053a9abc14
commit 727040d2dd
3 changed files with 8 additions and 4 deletions

View File

@ -288,6 +288,7 @@ bool LuaInterface::LoadLuaSpell(const char* name) {
spell->restored = false;
spell->initial_caster_char_id = 0;
spell->initial_target_char_id = 0;
spell->spell_deleting = false;
MSpells.lock();
if (spells.count(lua_script) > 0) {
@ -2078,6 +2079,7 @@ LuaSpell* LuaInterface::GetSpell(const char* name) {
new_spell->restored = false;
new_spell->initial_caster_char_id = 0;
new_spell->initial_target_char_id = 0;
new_spell->spell_deleting = false;
return new_spell;
}
else{

View File

@ -22,6 +22,7 @@
#include <mutex>
#include <shared_mutex>
#include <atomic>
#include "Spawn.h"
#include "Spells.h"
@ -102,7 +103,7 @@ struct LuaSpell{
Mutex MSpellTargets;
int32 effect_bitmask;
bool restored; // restored spell cross zone
std::atomic<bool> spell_deleting;
};
class LUAUserData{

View File

@ -418,7 +418,8 @@ bool SpellProcess::DeleteCasterSpell(LuaSpell* spell, string reason, bool removi
bool ret = false;
Spawn* target = 0;
bool target_valid = false;
if(spell) {
if(spell && !spell->spell_deleting) {
spell->spell_deleting = true;
spell->MSpellTargets.writelock(__FUNCTION__, __LINE__);
if(remove_target && spell->targets.size() > 1) {
for (int32 i = 0; i < spell->targets.size(); i++) {