feat: restore scr_print
This commit is contained in:
parent
ee4efc778c
commit
4782470e85
45
src/module/gsc/script_extension.cpp
Normal file
45
src/module/gsc/script_extension.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include <std_include.hpp>
|
||||
#include <loader/module_loader.hpp>
|
||||
#include "game/game.hpp"
|
||||
|
||||
#include "script_error.hpp"
|
||||
|
||||
#include "module/console.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
namespace gsc
|
||||
{
|
||||
namespace
|
||||
{
|
||||
void scr_print()
|
||||
{
|
||||
for (std::size_t i = 0; i < game::native::Scr_GetNumParam(); ++i)
|
||||
{
|
||||
console::info("%s", game::native::Scr_GetString(i));
|
||||
}
|
||||
}
|
||||
|
||||
void scr_print_ln()
|
||||
{
|
||||
for (std::size_t i = 0; i < game::native::Scr_GetNumParam(); ++i)
|
||||
{
|
||||
console::info("%s", game::native::Scr_GetString(i));
|
||||
}
|
||||
|
||||
console::info("\n");
|
||||
}
|
||||
}
|
||||
|
||||
class script_extension final : public module
|
||||
{
|
||||
public:
|
||||
void post_load() override
|
||||
{
|
||||
utils::hook::set<game::native::BuiltinFunction>(SELECT_VALUE(0x92B8DC, 0x8ABDC4), scr_print);
|
||||
utils::hook::set<game::native::BuiltinFunction>(SELECT_VALUE(0x92B8E8, 0x8ABDD0), scr_print_ln);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
REGISTER_MODULE(gsc::script_extension)
|
@ -158,7 +158,7 @@ namespace gsc
|
||||
return game::native::DB_IsXAssetDefault(type, name);
|
||||
}
|
||||
|
||||
void g_scr_load_scripts_stub()
|
||||
void load_scripts()
|
||||
{
|
||||
char path[game::native::MAX_OSPATH]{};
|
||||
|
||||
@ -201,10 +201,30 @@ namespace gsc
|
||||
init_handles[path] = init_handle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void g_scr_load_scripts_mp_stub()
|
||||
{
|
||||
load_scripts();
|
||||
utils::hook::invoke<void>(0x523DA0);
|
||||
}
|
||||
|
||||
__declspec(naked) void g_scr_load_script_and_label_stub()
|
||||
{
|
||||
static const DWORD GScr_LoadScriptAndLabel_t = 0x5D9900;
|
||||
|
||||
__asm
|
||||
{
|
||||
call GScr_LoadScriptAndLabel_t
|
||||
|
||||
pushad
|
||||
call load_scripts
|
||||
popad
|
||||
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
void scr_load_level_stub()
|
||||
{
|
||||
for (const auto& handle : main_handles)
|
||||
@ -214,7 +234,7 @@ namespace gsc
|
||||
game::native::Scr_FreeThread(static_cast<std::uint16_t>(id));
|
||||
}
|
||||
|
||||
utils::hook::invoke<void>(0x517410); // Scr_LoadLevel
|
||||
utils::hook::invoke<void>(SELECT_VALUE(0x50AF70, 0x517410)); // Scr_LoadLevel
|
||||
|
||||
for (const auto& handle : init_handles)
|
||||
{
|
||||
@ -292,7 +312,10 @@ namespace gsc
|
||||
|
||||
void post_load() override
|
||||
{
|
||||
if (game::is_mp()) this->patch_mp();
|
||||
if (game::is_sp()) this->patch_sp();
|
||||
else this->patch_mp();
|
||||
|
||||
utils::hook(SELECT_VALUE(0x50C575, 0x50D4ED), scr_load_level_stub, HOOK_CALL).install()->quick();
|
||||
|
||||
// ProcessScript
|
||||
utils::hook(SELECT_VALUE(0x44685E, 0x56B13E), find_script, HOOK_CALL).install()->quick();
|
||||
@ -312,10 +335,14 @@ namespace gsc
|
||||
});
|
||||
}
|
||||
|
||||
static void patch_sp()
|
||||
{
|
||||
utils::hook(0x4BE6A5, g_scr_load_script_and_label_stub, HOOK_CALL).install()->quick();
|
||||
}
|
||||
|
||||
static void patch_mp()
|
||||
{
|
||||
utils::hook(0x523F3E, g_scr_load_scripts_stub, HOOK_CALL).install()->quick();
|
||||
utils::hook(0x50D4ED, scr_load_level_stub, HOOK_CALL).install()->quick();
|
||||
utils::hook(0x523F3E, g_scr_load_scripts_mp_stub, HOOK_CALL).install()->quick();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user