diff --git a/ChaosMod/Components/LuaScripts.cpp b/ChaosMod/Components/LuaScripts.cpp index 3e917340a..fd5a43a05 100644 --- a/ChaosMod/Components/LuaScripts.cpp +++ b/ChaosMod/Components/LuaScripts.cpp @@ -193,8 +193,8 @@ enum class LuaNativeReturnType Vector3 }; -_LUAFUNC static sol::object LuaInvoke(const sol::environment &env, DWORD64 nativeHash, LuaNativeReturnType returnType, - const sol::variadic_args &args) +_LUAFUNC static sol::object LuaInvoke(const sol::environment &env, std::uint64_t nativeHash, + LuaNativeReturnType returnType, const sol::variadic_args &args) { if (nativeHash == 0x213AEB2B90CBA7AC || nativeHash == 0x5A5F40FE637EB584 || nativeHash == 0x933D6A9EEC1BACD0 || nativeHash == 0xE80492A9AC099A93 || nativeHash == 0x8EF07E15701D61ED) @@ -298,8 +298,6 @@ static const std::vector ms_Exposables { E("GET_HASH_KEY", GET_HASH_KEY), E("print", [](const sol::this_environment &curEnv, const std::string &text) { LuaPrint(curEnv.env->get("EnvInfo")["ScriptName"], text); }), - E("_invoke", [](const sol::this_environment &curEnv, DWORD64 hash, LuaNativeReturnType returnType, - const sol::variadic_args &args) { return LuaInvoke(curEnv, hash, returnType, args); }), E("WAIT", WAIT), E("IsKeyPressed", [](unsigned char key) @@ -461,6 +459,26 @@ LuaScripts::LuaScripts() ParseScript(fileName, path.string(), ParseScriptFlag_ScriptIsFilePath, userEffectSettings); }; + bool allowEvalNativeInvocations = DoesFeatureFlagExist("allowscriptevalnativeinvocations"); + + if (allowEvalNativeInvocations) + { + m_GlobalState["_invoke"] = [](const sol::this_environment &curEnv, std::uint64_t hash, + LuaNativeReturnType returnType, const sol::variadic_args &args) + { + return LuaInvoke(curEnv, hash, returnType, args); + }; + } + else + { + m_GlobalState["_invoke"] = [](const sol::this_environment &curEnv, std::uint64_t hash, + LuaNativeReturnType returnType, const sol::variadic_args &args) + { + LOG("WARNING: Blocked invocation of native 0x" << std::uppercase << std::hex << hash << std::setfill(' ') + << " during script evaluation!"); + }; + } + for (auto dir : ms_ScriptDirs) { if (!DoesFileExist(dir)) @@ -482,6 +500,15 @@ LuaScripts::LuaScripts() parseScript(entry); } } + + if (!allowEvalNativeInvocations) + { + m_GlobalState["_invoke"] = [](const sol::this_environment &curEnv, std::uint64_t hash, + LuaNativeReturnType returnType, const sol::variadic_args &args) + { + return LuaInvoke(curEnv, hash, returnType, args); + }; + } } void LuaScripts::OnModPauseCleanup() diff --git a/ChaosMod/Memory/Memory.cpp b/ChaosMod/Memory/Memory.cpp index 9a5afbba0..4bbf139bc 100644 --- a/ChaosMod/Memory/Memory.cpp +++ b/ChaosMod/Memory/Memory.cpp @@ -173,8 +173,8 @@ namespace Memory << (scanRange.StartAddr == 0 && scanRange.EndAddr == 0 ? "\"" : (std::stringstream() - << "\" within address range 0x" << std::uppercase << std::hex << std::setfill(' ') - << scanRange.StartAddr << " to 0x" << std::uppercase << std::hex << scanRange.EndAddr) + << "\" within address range 0x" << std::uppercase << std::hex << scanRange.StartAddr + << std::setfill(' ') << " to 0x" << std::uppercase << std::hex << scanRange.EndAddr) .str())); if ((scanRange.StartAddr != 0 || scanRange.EndAddr != 0) && scanRange.StartAddr >= scanRange.EndAddr)