fixes and little changes

This commit is contained in:
m
2022-10-26 22:22:45 -05:00
parent 11260db99e
commit da59ed854c
5 changed files with 51 additions and 47 deletions

View File

@ -33,11 +33,6 @@ namespace gsc
namespace
{
struct gsc_error : public std::runtime_error
{
using std::runtime_error::runtime_error;
};
std::unordered_map<std::uint32_t, script_function> functions;
std::unordered_map<std::uint32_t, script_method> methods;
@ -264,6 +259,11 @@ namespace gsc
}
console::info("%s\n", buffer.data());
}
scripting::script_value typeof(const function_args& args)
{
return args[0].type_name();
}
}
namespace function
@ -365,6 +365,15 @@ namespace gsc
utils::hook::call(SELECT_VALUE(0x3CC9F3_b, 0x513A53_b), vm_error_stub);
if (game::environment::is_dedi())
{
function::add("isusingmatchrulesdata", [](const function_args& args)
{
// return 0 so the game doesn't override the cfg
return 0;
});
}
function::add("print", [](const function_args& args)
{
print(args);
@ -457,12 +466,6 @@ namespace gsc
return scripting::script_value{};
});
function::add("isusingmatchrulesdata", [](const function_args& args)
{
// return 0 so the game doesn't override the cfg
return 0;
});
function::add("say", [](const function_args& args)
{
const auto message = args[0].as<std::string>();
@ -471,6 +474,9 @@ namespace gsc
return scripting::script_value{};
});
function::add("typeof", typeof);
function::add("type", typeof);
method::add("tell", [](const game::scr_entref_t ent, const function_args& args)
{
if (ent.classnum != 0)

View File

@ -20,7 +20,7 @@ namespace io
{
namespace
{
bool use_root_folder = false;
bool allow_root_io = false;
void check_path(const std::filesystem::path& path)
{
@ -34,7 +34,7 @@ namespace io
{
check_path(path);
if (use_root_folder)
if (allow_root_io)
{
static const auto fs_base_game = game::Dvar_FindVar("fs_basepath");
const std::filesystem::path fs_base_game_path(fs_base_game->current.string);
@ -69,10 +69,10 @@ namespace io
public:
void post_unpack() override
{
use_root_folder = utils::flags::has_flag("io_game_dir");
if (use_root_folder)
allow_root_io = utils::flags::has_flag("allow_root_io");
if (allow_root_io)
{
console::warn("GSC has access to your game folder. To prevent possible malicious code, remove the '-io_game_dir' launch flag.");
console::warn("GSC has access to your game folder. Remove the '-allow_root_io' launch parameter to disable this feature.");
}
gsc::function::add("fileexists", [](const gsc::function_args& args)

View File

@ -94,7 +94,7 @@ namespace json
case (game::SCRIPT_FUNCTION):
return _value.as<scripting::function>().get_name();
default:
return "[unknown type]";
return utils::string::va("[%s]", _value.type_name().data());
};
}