Merge pull request #328 from diamante0018/gsc-include

Allow custom scripts to load other scripts
This commit is contained in:
fed 2022-09-06 17:31:23 +00:00 committed by GitHub
commit 2166df1e8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 7 deletions

View File

@ -537,6 +537,23 @@ namespace gsc
{
developer_script = dvars::register_bool("developer_script", false, 0, "Print GSC errors");
// Allow custom scripts to include other custom scripts
xsk::gsc::h2::resolver::init([](const auto& include_name)
{
const auto real_name = include_name + ".gsc";
std::string file_buffer;
if (!read_scriptfile(real_name, &file_buffer) || file_buffer.empty())
{
throw std::runtime_error(std::format("could not load gsc file '{}'", real_name));
}
std::vector<std::uint8_t> result;
result.assign(file_buffer.begin(), file_buffer.end());
return result;
});
utils::hook::call(0x1405C6177, find_script);
utils::hook::call(0x1405C6187, db_is_xasset_default);

View File

@ -36,9 +36,9 @@ namespace utils::string
std::string to_lower(std::string text)
{
std::transform(text.begin(), text.end(), text.begin(), [](const char input)
std::transform(text.begin(), text.end(), text.begin(), [](const unsigned char input)
{
return static_cast<char>(tolower(input));
return static_cast<char>(std::tolower(input));
});
return text;
@ -46,9 +46,9 @@ namespace utils::string
std::string to_upper(std::string text)
{
std::transform(text.begin(), text.end(), text.begin(), [](const char input)
std::transform(text.begin(), text.end(), text.begin(), [](const unsigned char input)
{
return static_cast<char>(toupper(input));
return static_cast<char>(std::toupper(input));
});
return text;
@ -147,8 +147,6 @@ namespace utils::string
*out = '\0';
}
#pragma warning(push)
#pragma warning(disable: 4100)
std::string convert(const std::wstring& wstr)
{
std::string result;
@ -174,7 +172,6 @@ namespace utils::string
return result;
}
#pragma warning(pop)
std::string replace(std::string str, const std::string& from, const std::string& to)
{