diff --git a/src/CET.cpp b/src/CET.cpp index db2b02a8..9ec5caf6 100644 --- a/src/CET.cpp +++ b/src/CET.cpp @@ -71,7 +71,7 @@ CET::CET() , m_bindings(m_paths, m_options) , m_window(&m_bindings, &m_d3d12) , m_d3d12(m_window, m_paths, m_options) - , m_vm(m_paths, m_bindings, m_d3d12) + , m_vm(m_paths, m_options, m_bindings, m_d3d12) , m_overlay(m_bindings, m_options, m_persistentState, m_vm) { } diff --git a/src/scripting/LuaVM.h b/src/scripting/LuaVM.h index c0881ac6..be8d4291 100644 --- a/src/scripting/LuaVM.h +++ b/src/scripting/LuaVM.h @@ -25,7 +25,7 @@ struct TDBIDLookupEntry struct Image; struct LuaVM { - LuaVM(const Paths& aPaths, VKBindings& aBindings, D3D12& aD3D12); + LuaVM(const Paths& aPaths, const Options& aOptions, VKBindings& aBindings, D3D12& aD3D12); ~LuaVM() = default; [[nodiscard]] const VKBind* GetBind(const VKModBind& acModBind) const; diff --git a/src/scripting/LuaVM_Hooks.cpp b/src/scripting/LuaVM_Hooks.cpp index 088dd305..a7bb3693 100644 --- a/src/scripting/LuaVM_Hooks.cpp +++ b/src/scripting/LuaVM_Hooks.cpp @@ -258,8 +258,8 @@ void LuaVM::HookLogChannel(RED4ext::IScriptable*, RED4ext::CStackFrame* apStack, } } -LuaVM::LuaVM(const Paths& aPaths, VKBindings& aBindings, D3D12& aD3D12) - : m_scripting(aPaths, aBindings, aD3D12) +LuaVM::LuaVM(const Paths& aPaths, const Options& aOptions, VKBindings& aBindings, D3D12& aD3D12) + : m_scripting(aPaths, aOptions, aBindings, aD3D12) , m_d3d12(aD3D12) { Hook(); diff --git a/src/scripting/Scripting.cpp b/src/scripting/Scripting.cpp index ddf27d01..89a92b40 100644 --- a/src/scripting/Scripting.cpp +++ b/src/scripting/Scripting.cpp @@ -32,12 +32,13 @@ static constexpr bool s_cThrowLuaErrors = true; static RTTILocator s_stringType{RED4ext::FNV1a64("String")}; static RTTILocator s_resRefType{RED4ext::FNV1a64("redResourceReferenceScriptToken")}; -Scripting::Scripting(const Paths& aPaths, VKBindings& aBindings, D3D12& aD3D12) +Scripting::Scripting(const Paths& aPaths, const Options& aOptions, VKBindings& aBindings, D3D12& aD3D12) : m_sandbox(this, aBindings) , m_mapper(m_lua.AsRef(), m_sandbox) , m_store(m_sandbox, aPaths, aBindings) , m_override(this) , m_paths(aPaths) + , m_options(aOptions) , m_d3d12(aD3D12) { CreateLogger(aPaths.CETRoot() / "scripting.log", "scripting"); @@ -49,7 +50,11 @@ void Scripting::Initialize() auto lua = m_lua.Lock(); auto& luaVm = lua.Get(); - luaVm.open_libraries(sol::lib::base, sol::lib::string, sol::lib::io, sol::lib::math, sol::lib::package, sol::lib::os, sol::lib::table, sol::lib::bit32, sol::lib::jit); + luaVm.open_libraries(sol::lib::base, sol::lib::string, sol::lib::io, sol::lib::math, sol::lib::package, sol::lib::os, sol::lib::table, sol::lib::bit32); + + if (m_options.Developer.EnableJIT) + luaVm.open_libraries(sol::lib::jit); + luaVm.require("sqlite3", luaopen_lsqlite3); // make sure to set package path to current directory scope diff --git a/src/scripting/Scripting.h b/src/scripting/Scripting.h index 23938306..b6d25600 100644 --- a/src/scripting/Scripting.h +++ b/src/scripting/Scripting.h @@ -11,7 +11,7 @@ struct Scripting { using LockedState = TiltedPhoques::Locked; - Scripting(const Paths& aPaths, VKBindings& aBindings, D3D12& aD3D12); + Scripting(const Paths& aPaths, const Options& aOptions, VKBindings& aBindings, D3D12& aD3D12); ~Scripting() = default; void Initialize(); @@ -61,5 +61,6 @@ struct Scripting ScriptStore m_store; FunctionOverride m_override; const Paths& m_paths; + const Options& m_options; D3D12& m_d3d12; };