fixes and little changes
This commit is contained in:
parent
11260db99e
commit
da59ed854c
@ -33,11 +33,6 @@ namespace gsc
|
|||||||
|
|
||||||
namespace
|
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_function> functions;
|
||||||
std::unordered_map<std::uint32_t, script_method> methods;
|
std::unordered_map<std::uint32_t, script_method> methods;
|
||||||
|
|
||||||
@ -264,6 +259,11 @@ namespace gsc
|
|||||||
}
|
}
|
||||||
console::info("%s\n", buffer.data());
|
console::info("%s\n", buffer.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scripting::script_value typeof(const function_args& args)
|
||||||
|
{
|
||||||
|
return args[0].type_name();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace function
|
namespace function
|
||||||
@ -365,6 +365,15 @@ namespace gsc
|
|||||||
|
|
||||||
utils::hook::call(SELECT_VALUE(0x3CC9F3_b, 0x513A53_b), vm_error_stub);
|
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)
|
function::add("print", [](const function_args& args)
|
||||||
{
|
{
|
||||||
print(args);
|
print(args);
|
||||||
@ -457,12 +466,6 @@ namespace gsc
|
|||||||
return scripting::script_value{};
|
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)
|
function::add("say", [](const function_args& args)
|
||||||
{
|
{
|
||||||
const auto message = args[0].as<std::string>();
|
const auto message = args[0].as<std::string>();
|
||||||
@ -471,6 +474,9 @@ namespace gsc
|
|||||||
return scripting::script_value{};
|
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)
|
method::add("tell", [](const game::scr_entref_t ent, const function_args& args)
|
||||||
{
|
{
|
||||||
if (ent.classnum != 0)
|
if (ent.classnum != 0)
|
||||||
|
@ -20,7 +20,7 @@ namespace io
|
|||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
bool use_root_folder = false;
|
bool allow_root_io = false;
|
||||||
|
|
||||||
void check_path(const std::filesystem::path& path)
|
void check_path(const std::filesystem::path& path)
|
||||||
{
|
{
|
||||||
@ -34,7 +34,7 @@ namespace io
|
|||||||
{
|
{
|
||||||
check_path(path);
|
check_path(path);
|
||||||
|
|
||||||
if (use_root_folder)
|
if (allow_root_io)
|
||||||
{
|
{
|
||||||
static const auto fs_base_game = game::Dvar_FindVar("fs_basepath");
|
static const auto fs_base_game = game::Dvar_FindVar("fs_basepath");
|
||||||
const std::filesystem::path fs_base_game_path(fs_base_game->current.string);
|
const std::filesystem::path fs_base_game_path(fs_base_game->current.string);
|
||||||
@ -69,10 +69,10 @@ namespace io
|
|||||||
public:
|
public:
|
||||||
void post_unpack() override
|
void post_unpack() override
|
||||||
{
|
{
|
||||||
use_root_folder = utils::flags::has_flag("io_game_dir");
|
allow_root_io = utils::flags::has_flag("allow_root_io");
|
||||||
if (use_root_folder)
|
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)
|
gsc::function::add("fileexists", [](const gsc::function_args& args)
|
||||||
|
@ -94,7 +94,7 @@ namespace json
|
|||||||
case (game::SCRIPT_FUNCTION):
|
case (game::SCRIPT_FUNCTION):
|
||||||
return _value.as<scripting::function>().get_name();
|
return _value.as<scripting::function>().get_name();
|
||||||
default:
|
default:
|
||||||
return "[unknown type]";
|
return utils::string::va("[%s]", _value.type_name().data());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,20 +30,19 @@ namespace scripting
|
|||||||
{11, "builtin method"},
|
{11, "builtin method"},
|
||||||
{12, "stack"},
|
{12, "stack"},
|
||||||
{13, "animation"},
|
{13, "animation"},
|
||||||
{14, "developer codepos"}, // this exists on H1 but not IW6 (also not sure if past here may be correct)
|
{14, "pre animation"},
|
||||||
{15, "pre animation"},
|
{15, "thread"},
|
||||||
{16, "thread"},
|
{16, "notify thread"},
|
||||||
{17, "notify thread"},
|
{17, "time thread"},
|
||||||
{18, "time thread"},
|
{18, "child thread"},
|
||||||
{19, "child thread"},
|
{19, "struct"},
|
||||||
{20, "struct"},
|
{20, "removed entity"},
|
||||||
{21, "removed entity"},
|
{21, "entity"},
|
||||||
{22, "entity"},
|
{22, "array"},
|
||||||
{23, "array"},
|
{23, "removed thread"},
|
||||||
{24, "removed thread"},
|
{24, "<free>"},
|
||||||
{25, "<free>"}, // VAR_COUNT is 25 on H1, but 24 on IW6
|
{25, "thread list"},
|
||||||
{26, "thread list"},
|
{26, "endon list"},
|
||||||
{27, "endon list"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string get_typename(const game::VariableValue& value)
|
std::string get_typename(const game::VariableValue& value)
|
||||||
|
@ -56,22 +56,21 @@ namespace game
|
|||||||
VAR_BUILTIN_METHOD = 0xB,
|
VAR_BUILTIN_METHOD = 0xB,
|
||||||
VAR_STACK = 0xC,
|
VAR_STACK = 0xC,
|
||||||
VAR_ANIMATION = 0xD,
|
VAR_ANIMATION = 0xD,
|
||||||
VAR_DEVELOPER_CODEPOS = 0xE,
|
VAR_PRE_ANIMATION = 0xE,
|
||||||
VAR_PRE_ANIMATION = 0xF,
|
VAR_THREAD = 0xF,
|
||||||
VAR_THREAD = 0x10,
|
VAR_NOTIFY_THREAD = 0x10,
|
||||||
VAR_NOTIFY_THREAD = 0x11,
|
VAR_TIME_THREAD = 0x11,
|
||||||
VAR_TIME_THREAD = 0x12,
|
VAR_CHILD_THREAD = 0x12,
|
||||||
VAR_CHILD_THREAD = 0x13,
|
VAR_OBJECT = 0x13,
|
||||||
VAR_OBJECT = 0x14,
|
VAR_DEAD_ENTITY = 0x14,
|
||||||
VAR_DEAD_ENTITY = 0x15,
|
VAR_ENTITY = 0x15,
|
||||||
VAR_ENTITY = 0x16,
|
VAR_ARRAY = 0x16,
|
||||||
VAR_ARRAY = 0x17,
|
VAR_DEAD_THREAD = 0x17,
|
||||||
VAR_DEAD_THREAD = 0x18,
|
VAR_COUNT = 0x18,
|
||||||
VAR_COUNT = 0x19,
|
VAR_FREE = 0x18,
|
||||||
VAR_FREE = 0x19,
|
VAR_THREAD_LIST = 0x19,
|
||||||
VAR_THREAD_LIST = 0x1A,
|
VAR_ENDON_LIST = 0x1A,
|
||||||
VAR_ENDON_LIST = 0x1B,
|
VAR_TOTAL_COUNT = 0x1B,
|
||||||
VAR_TOTAL_COUNT = 0x1C,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VariableStackBuffer
|
struct VariableStackBuffer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user