From 8c36a218deb6298375654437a82d5a59482a3168 Mon Sep 17 00:00:00 2001 From: ineed bots Date: Fri, 1 Sep 2023 14:57:46 -0600 Subject: [PATCH] Added pluto code --- src/codsrc/clientscript/cscr_main.cpp | 7 +++++- src/codsrc/clientscript/cscr_parser.cpp | 5 ++++- src/codsrc/clientscript/cscr_vm.cpp | 29 +++++++++++++++++++++++-- src/component/signatures.cpp | 6 +++++ src/game/symbols.hpp | 5 +++++ 5 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/codsrc/clientscript/cscr_main.cpp b/src/codsrc/clientscript/cscr_main.cpp index d708fc1..6525813 100644 --- a/src/codsrc/clientscript/cscr_main.cpp +++ b/src/codsrc/clientscript/cscr_main.cpp @@ -298,7 +298,12 @@ namespace codsrc game::gScrParserPub[inst].scriptfilename = extFilename; game:: gScrCompilePub[inst].in_ptr = "+"; game::gScrCompilePub[inst].parseBuf = sourceBuffer; - game::ScriptParse(inst, &parseData); + + // pluto + game::plutonium::script_preprocess(sourceBuffer, inst, &parseData); // the pluto hook will call ScriptParse, so we dont have to + // game::ScriptParse(inst, &parseData); + // + scriptPosVar = game::GetVariable(inst, game::gScrCompilePub[inst].scriptsPos, name); filePosId = game::GetObject(inst, scriptPosVar); scriptCountVar = game::GetVariable(inst, game::gScrCompilePub[inst].scriptsCount, name); diff --git a/src/codsrc/clientscript/cscr_parser.cpp b/src/codsrc/clientscript/cscr_parser.cpp index 65f6496..e6f1d24 100644 --- a/src/codsrc/clientscript/cscr_parser.cpp +++ b/src/codsrc/clientscript/cscr_parser.cpp @@ -437,7 +437,10 @@ namespace codsrc char* buffer; int fh; - if (*(*game::fs_game)->current.string || (*game::com_developer)->current.enabled) + // pluto + if (true) + // if (*(*game::fs_game)->current.string || (*game::com_developer)->current.enabled) + // { *game::statmon_related_bool = 1; if (game::FS_FOpenFileByMode(filename, &fh, game::FS_READ) < 0) diff --git a/src/codsrc/clientscript/cscr_vm.cpp b/src/codsrc/clientscript/cscr_vm.cpp index a6ff8ad..566d439 100644 --- a/src/codsrc/clientscript/cscr_vm.cpp +++ b/src/codsrc/clientscript/cscr_vm.cpp @@ -1274,9 +1274,12 @@ namespace codsrc ++game::gScrVmPub[inst].function_frame; game::gScrVmPub[inst].function_frame->fs.localId = game::gFs[inst].localId; + // pluto + game::plutonium::vm_execute_update_codepos(inst); + // + assert(game::gFs[inst].pos); - // replace func } void OP_ScriptFunctionCall(game::scriptInstance_t inst) @@ -4207,7 +4210,17 @@ namespace codsrc game::Scr_ClearOutParams(inst); startTop = &game::gScrVmPub[inst].top[-paramcount]; paramcounta = game::gScrVmPub[inst].inparamcount - paramcount; - id = game::FindEntityId(classnum, entnum, inst); + + // pluto + if (classnum == -1) + { + id = entnum; // this is for level notify + } + // + else + { + id = game::FindEntityId(classnum, entnum, inst); + } if ( id ) { @@ -4496,6 +4509,10 @@ namespace codsrc unsigned short threadId; const char* pos; + // pluto + game::plutonium::scr_execthread_update_codepos_func(inst, inst, &handle, &handle); + // + pos = &game::gScrVarPub[inst].programBuffer[handle]; if ( !game::gScrVmPub[inst].function_count ) @@ -4537,6 +4554,10 @@ namespace codsrc const char* pos; game::classNum_e classnum = game::CLASS_NUM_ENTITY; + // pluto + game::plutonium::scr_execentthread_update_codepos_func(inst, &handle); + // + pos = &game::gScrVarPub[inst].programBuffer[handle]; if ( !game::gScrVmPub[inst].function_count ) @@ -4576,6 +4597,10 @@ namespace codsrc unsigned int thread; unsigned int paramcount = 0; + // pluto + game::plutonium::scr_addexecthread_update_codepos_func(inst, &handle); + // + if ( !game::gScrVmPub[inst].function_count ) { assert(game::gScrVmPub[inst].localVars == game::gScrVmGlob[inst].localVarsStack - 1); diff --git a/src/component/signatures.cpp b/src/component/signatures.cpp index 531cd68..343d3d6 100644 --- a/src/component/signatures.cpp +++ b/src/component/signatures.cpp @@ -147,6 +147,12 @@ namespace signatures bool handle_funcs() { game::plutonium::load_custom_script_func.set(reinterpret_cast(utils::hook::get_displacement_addr(reinterpret_cast(utils::hook::get_displacement_addr(0x689C80)) + 0x6))); + game::plutonium::script_preprocess.set(reinterpret_cast(utils::hook::get_displacement_addr(reinterpret_cast(utils::hook::get_displacement_addr(0x689BCF)) + 0x2))); + + game::plutonium::vm_execute_update_codepos.set(reinterpret_cast(utils::hook::get_displacement_addr(reinterpret_cast(utils::hook::get_displacement_addr(0x69608C)) + 0x2))); + game::plutonium::scr_execthread_update_codepos_func.set(reinterpret_cast(utils::hook::get_displacement_addr(reinterpret_cast(utils::hook::get_displacement_addr(0x699560)) + 0x11))); + game::plutonium::scr_execentthread_update_codepos_func.set(reinterpret_cast(utils::hook::get_displacement_addr(reinterpret_cast(utils::hook::get_displacement_addr(0x699640)) + 0x7))); + game::plutonium::scr_addexecthread_update_codepos_func.set(reinterpret_cast(utils::hook::get_displacement_addr(reinterpret_cast(utils::hook::get_displacement_addr(0x699730)) + 0x7))); return true; } diff --git a/src/game/symbols.hpp b/src/game/symbols.hpp index f41b592..229ba97 100644 --- a/src/game/symbols.hpp +++ b/src/game/symbols.hpp @@ -73,5 +73,10 @@ namespace game WEAK symbol printf{0x0, 0x0}; WEAK symbol load_custom_script_func{0x0, 0x0}; + WEAK symbol script_preprocess{0x0, 0x0}; + WEAK symbol vm_execute_update_codepos{0x0, 0x0}; + WEAK symbol scr_execthread_update_codepos_func{0x0, 0x0}; + WEAK symbol scr_execentthread_update_codepos_func{ 0x0, 0x0 }; + WEAK symbol scr_addexecthread_update_codepos_func{ 0x0, 0x0 }; } }