throw error on getfunction + cleanup

This commit is contained in:
m 2022-10-24 16:00:40 -05:00
parent 00dedaf641
commit 9bd419a7cb
3 changed files with 9 additions and 12 deletions

View File

@ -134,9 +134,8 @@ namespace gsc
void vm_call_builtin_function_stub(builtin_function function)
{
const auto function_id = get_function_id();
const auto is_custom_function = functions.find(function_id) != functions.end();
if (!is_custom_function)
if (!functions.contains(function_id))
{
function();
}
@ -156,9 +155,8 @@ namespace gsc
void vm_call_builtin_method_stub(builtin_method method)
{
const auto function_id = get_function_id();
const auto is_custom_function = methods.find(function_id) != methods.end();
if (!is_custom_function)
if (!methods.contains(function_id))
{
method(saved_ent_ref);
}
@ -402,17 +400,17 @@ namespace gsc
return scripting::script_value{};
});
function::add("getfunction", [](const function_args& args) -> scripting::script_value
function::add("getfunction", [](const function_args& args)
{
const auto filename = args[0].as<std::string>();
const auto function = args[1].as<std::string>();
if (scripting::script_function_table[filename].find(function) != scripting::script_function_table[filename].end())
if (!scripting::script_function_table[filename].contains(function))
{
return scripting::function{scripting::script_function_table[filename][function]};
throw std::runtime_error("function not found");
}
return {};
return scripting::function{scripting::script_function_table[filename][function]};
});
function::add("replacefunc", [](const function_args& args)

View File

@ -29,7 +29,6 @@ namespace logfile
utils::hook::detour scr_player_damage_hook;
utils::hook::detour client_command_hook;
utils::hook::detour g_shutdown_game_hook;
utils::hook::detour g_log_printf_hook;
@ -328,8 +327,8 @@ namespace logfile
const scripting::entity level{*game::levelEntityId};
const scripting::entity player{game::Scr_GetEntityId(self->s.number, 0)};
scripting::notify(level, cmd, {player, message, hidden});
scripting::notify(player, cmd, {message, hidden});
notify(level, cmd, {player, message, hidden});
notify(player, cmd, {message, hidden});
game::G_LogPrintf("%s;%s;%i;%s;%s\n",
cmd,

View File

@ -30,7 +30,7 @@ namespace scripting
{11, "builtin method"},
{12, "stack"},
{13, "animation"},
{14, "developer codepos"}, // this exists on H1 but not IW6
{14, "developer codepos"}, // this exists on H1 but not IW6 (also not sure if past here may be correct)
{15, "pre animation"},
{16, "thread"},
{17, "notify thread"},