1
0

lua function call protection

This commit is contained in:
Emagi 2024-09-02 09:45:36 -04:00
parent 950b8e1564
commit 184bc94aa1
2 changed files with 24 additions and 26 deletions

View File

@ -584,9 +584,6 @@ std::string LuaInterface::AddSpawnPointers(LuaSpell* spell, bool first_cast, boo
lua_pop(spell->state, 1);
return string("");
}
else {
lua_getglobal(spell->state, functionCalled.c_str());
}
if(passLuaSpell)
SetSpellValue(spell->state, spell);
@ -858,7 +855,6 @@ void LuaInterface::RemoveSpell(LuaSpell* spell, bool call_remove_function, bool
lua_pop(spell->state, 1);
}
else {
lua_getglobal(spell->state, "remove");
LUASpawnWrapper* spawn_wrapper = new LUASpawnWrapper();
spawn_wrapper->spawn = spell->caster;
AddUserDataPtr(spawn_wrapper, spawn_wrapper->spawn);

View File

@ -582,28 +582,30 @@ bool SpellProcess::ProcessSpell(LuaSpell* spell, bool first_cast, const char* fu
std::string SpellProcess::ApplyLuaFunction(LuaSpell* spell, bool first_cast, const char* function, SpellScriptTimer* timer, Spawn* altTarget)
{
std::string functionCall = lua_interface->AddSpawnPointers(spell, first_cast, false, function, timer, false, altTarget);
vector<LUAData*>* data = spell->spell->GetLUAData();
for(int32 i=0;i<data->size();i++){
switch(data->at(i)->type){
case 0:{
lua_interface->SetSInt32Value(spell->state, data->at(i)->int_value);
break;
}
case 1:{
lua_interface->SetFloatValue(spell->state, data->at(i)->float_value);
break;
}
case 2:{
lua_interface->SetBooleanValue(spell->state, data->at(i)->bool_value);
break;
}
case 3:{
lua_interface->SetStringValue(spell->state, data->at(i)->string_value.c_str());
break;
}
default:{
LogWrite(SPELL__ERROR, 0, "Spell", "Error: Unknown LUA Type '%i' in SpellProcess::ProcessSpell for Spell '%s'", (int)data->at(i)->type, spell->spell->GetName());
return string("");
if(functionCall.length() > 0) {
vector<LUAData*>* data = spell->spell->GetLUAData();
for(int32 i=0;i<data->size();i++){
switch(data->at(i)->type){
case 0:{
lua_interface->SetSInt32Value(spell->state, data->at(i)->int_value);
break;
}
case 1:{
lua_interface->SetFloatValue(spell->state, data->at(i)->float_value);
break;
}
case 2:{
lua_interface->SetBooleanValue(spell->state, data->at(i)->bool_value);
break;
}
case 3:{
lua_interface->SetStringValue(spell->state, data->at(i)->string_value.c_str());
break;
}
default:{
LogWrite(SPELL__ERROR, 0, "Spell", "Error: Unknown LUA Type '%i' in SpellProcess::ProcessSpell for Spell '%s'", (int)data->at(i)->type, spell->spell->GetName());
return string("");
}
}
}
}