gsc: allow scripts with both handles to load, assert gsc funcs
This commit is contained in:
parent
94ce2e4dac
commit
375f4499ec
@ -146,7 +146,8 @@ namespace gsc
|
|||||||
console::info("Loaded '%s::main'\n", name.data());
|
console::info("Loaded '%s::main'\n", name.data());
|
||||||
main_handles[name] = main_handle;
|
main_handles[name] = main_handle;
|
||||||
}
|
}
|
||||||
else if (init_handle)
|
|
||||||
|
if (init_handle)
|
||||||
{
|
{
|
||||||
console::info("Loaded '%s::init'\n", name.data());
|
console::info("Loaded '%s::init'\n", name.data());
|
||||||
init_handles[name] = init_handle;
|
init_handles[name] = init_handle;
|
||||||
@ -388,6 +389,24 @@ namespace gsc
|
|||||||
gsc_error = error;
|
gsc_error = error;
|
||||||
game::Scr_ErrorInternal();
|
game::Scr_ErrorInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void assert_cmd()
|
||||||
|
{
|
||||||
|
const auto expr = get_argument(0).as<int>();
|
||||||
|
if (!expr)
|
||||||
|
{
|
||||||
|
set_gsc_error("assert fail");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void assertex_cmd()
|
||||||
|
{
|
||||||
|
const auto expr = get_argument(0).as<int>();
|
||||||
|
if (!expr)
|
||||||
|
{
|
||||||
|
set_gsc_error(get_argument(1).as<std::string>());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
game::ScriptFile* find_script(game::XAssetType /*type*/, const char* name, int /*allow_create_default*/)
|
game::ScriptFile* find_script(game::XAssetType /*type*/, const char* name, int /*allow_create_default*/)
|
||||||
@ -450,6 +469,10 @@ namespace gsc
|
|||||||
// replace builtin print function
|
// replace builtin print function
|
||||||
utils::hook::jump(0x1404EC640, gscr_print_stub);
|
utils::hook::jump(0x1404EC640, gscr_print_stub);
|
||||||
|
|
||||||
|
// restore assert
|
||||||
|
utils::hook::jump(0x1404EC890, assert_cmd);
|
||||||
|
utils::hook::jump(0x1404EC920, assertex_cmd);
|
||||||
|
|
||||||
utils::hook::call(0x1405CB94F, vm_error_stub);
|
utils::hook::call(0x1405CB94F, vm_error_stub);
|
||||||
|
|
||||||
utils::hook::call(0x1405BC583, unknown_function_stub);
|
utils::hook::call(0x1405BC583, unknown_function_stub);
|
||||||
@ -479,7 +502,7 @@ namespace gsc
|
|||||||
|
|
||||||
if (with.type != game::SCRIPT_FUNCTION)
|
if (with.type != game::SCRIPT_FUNCTION)
|
||||||
{
|
{
|
||||||
set_gsc_error("replaceFunc: parameter 0 must be a function");
|
set_gsc_error("replaceFunc: parameter 1 must be a function");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user