Merge pull request #647 from JariKCoding/main

fix: only load the gsc files with the right magic
This commit is contained in:
Maurice Heumann 2023-05-07 11:42:12 +02:00 committed by GitHub
commit 01ebbd9b3e

View File

@ -12,6 +12,8 @@ namespace script
{ {
namespace namespace
{ {
constexpr size_t GSC_MAGIC = 0x1C000A0D43534780;
utils::hook::detour db_findxassetheader_hook; utils::hook::detour db_findxassetheader_hook;
utils::hook::detour gscr_get_bgb_remaining_hook; utils::hook::detour gscr_get_bgb_remaining_hook;
@ -71,8 +73,11 @@ namespace script
auto script_file = script.generic_string(); auto script_file = script.generic_string();
if (!std::filesystem::is_directory(script) && utils::io::read_file(script_file, &data)) if (!std::filesystem::is_directory(script) && utils::io::read_file(script_file, &data))
{ {
print_loading_script(script_file); if (data.size() >= sizeof(GSC_MAGIC) && !std::memcmp(data.data(), &GSC_MAGIC, sizeof(GSC_MAGIC)))
load_script(script_file, data); {
print_loading_script(script_file);
load_script(script_file, data);
}
} }
else if (std::filesystem::is_directory(script)) else if (std::filesystem::is_directory(script))
{ {