Browse Source

reset function stack for LUA

image 1 year ago
parent
commit
d5f670fef2

+ 2 - 1
EQ2/source/WorldServer/LuaInterface.cpp

@@ -641,7 +641,8 @@ void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool
 		MSpells.lock();
 		current_spells[spell->state] = spell;
 		MSpells.unlock();
-		lua_pcall(spell->state, 3, 0, 0);
+		lua_pcall(spell->state, 3, 0, 0); 
+		ResetFunctionStack(spell->state);
 	}
 
 	spell->MSpellTargets.readlock(__FUNCTION__, __LINE__);

+ 6 - 0
EQ2/source/WorldServer/SpellProcess.cpp

@@ -486,9 +486,12 @@ bool SpellProcess::CastInstant(Spell* spell, Entity* caster, Entity* target, boo
 			lua_interface->AddSpawnPointers(lua_spell, false, false, "customspell",0,true);
 			if (lua_pcall(lua_spell->state, 3, 3, 0) != 0) {
 				lua_interface->RemoveCustomSpell(lua_spell->spell->GetSpellID());
+				lua_interface->ResetFunctionStack(lua_spell->state);
 				safe_delete(lua_spell->spell);
 				lua_spell->spell = tmpSpell;
 			}
+			else
+				lua_interface->ResetFunctionStack(lua_spell->state);
 		}
 	}
 
@@ -880,9 +883,12 @@ void SpellProcess::ProcessSpell(ZoneServer* zone, Spell* spell, Entity* caster,
 				lua_interface->AddSpawnPointers(lua_spell, false, false, "customspell", 0, true);
 				if (lua_pcall(lua_spell->state, 3, 3, 0) != 0) {
 					lua_interface->RemoveCustomSpell(lua_spell->spell->GetSpellID());
+					lua_interface->ResetFunctionStack(lua_spell->state);
 					safe_delete(lua_spell->spell);
 					lua_spell->spell = tmpSpell;
 				}
+				else
+					lua_interface->ResetFunctionStack(lua_spell->state);
 			}
 		}