Safe pluto hooks

This commit is contained in:
ineed bots
2023-09-01 17:10:57 -06:00
parent 8c36a218de
commit ca306d785b
5 changed files with 86 additions and 19 deletions

View File

@ -300,9 +300,16 @@ namespace codsrc
game::gScrCompilePub[inst].parseBuf = sourceBuffer;
// pluto
game::plutonium::script_preprocess(sourceBuffer, inst, &parseData); // the pluto hook will call ScriptParse, so we dont have to
// game::ScriptParse(inst, &parseData);
if (game::plutonium::script_preprocess != nullptr)
{
game::plutonium::script_preprocess(sourceBuffer, inst, &parseData); // the pluto hook will call ScriptParse, so we dont have to
}
//
else
{
game::ScriptParse(inst, &parseData);
}
scriptPosVar = game::GetVariable(inst, game::gScrCompilePub[inst].scriptsPos, name);
filePosId = game::GetObject(inst, scriptPosVar);
@ -330,7 +337,10 @@ namespace codsrc
void Scr_EndLoadScripts(game::scriptInstance_t inst)
{
// pluto
game::plutonium::load_custom_script_func(inst);
if (game::plutonium::load_custom_script_func != nullptr)
{
game::plutonium::load_custom_script_func(inst);
}
//
game::SL_ShutdownSystem(inst, 2u);

View File

@ -1275,7 +1275,10 @@ namespace codsrc
game::gScrVmPub[inst].function_frame->fs.localId = game::gFs[inst].localId;
// pluto
game::plutonium::vm_execute_update_codepos(inst);
if (game::plutonium::vm_execute_update_codepos != nullptr)
{
game::plutonium::vm_execute_update_codepos(inst);
}
//
assert(game::gFs[inst].pos);
@ -4510,7 +4513,10 @@ namespace codsrc
const char* pos;
// pluto
game::plutonium::scr_execthread_update_codepos_func(inst, inst, &handle, &handle);
if (game::plutonium::scr_execthread_update_codepos_func != nullptr)
{
game::plutonium::scr_execthread_update_codepos_func(inst, inst, &handle, &handle);
}
//
pos = &game::gScrVarPub[inst].programBuffer[handle];
@ -4555,7 +4561,10 @@ namespace codsrc
game::classNum_e classnum = game::CLASS_NUM_ENTITY;
// pluto
game::plutonium::scr_execentthread_update_codepos_func(inst, &handle);
if (game::plutonium::scr_execentthread_update_codepos_func != nullptr)
{
game::plutonium::scr_execentthread_update_codepos_func(inst, &handle);
}
//
pos = &game::gScrVarPub[inst].programBuffer[handle];
@ -4598,7 +4607,10 @@ namespace codsrc
unsigned int paramcount = 0;
// pluto
game::plutonium::scr_addexecthread_update_codepos_func(inst, &handle);
if (game::plutonium::scr_addexecthread_update_codepos_func != nullptr)
{
game::plutonium::scr_addexecthread_update_codepos_func(inst, &handle);
}
//
if ( !game::gScrVmPub[inst].function_count )