Skip to content

Commit

Permalink
io.open use unsafedata
Browse files Browse the repository at this point in the history
  • Loading branch information
fesily committed Feb 6, 2025
1 parent 1d35c7a commit df0ca64
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ else ()
message(FATAL_ERROR "Not supported platform")
endif ()

project(DontStarveLuaJIT VERSION 0.5.11)
project(DontStarveLuaJIT VERSION 0.5.12)

set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/Mod)
if (UNIX AND APPLE)
Expand Down
14 changes: 7 additions & 7 deletions Mod/modmain.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
local hasluajit, jit = _G.pcall(require, 'jit')
if not hasluajit then
return
end

_G = GLOBAL

if not _G.TheNet:IsDedicated() then
local fp = _G.io.open("luajit_config.json", "w");
local fp = _G.io.open("unsafedata/luajit_config.json", "w");
if fp then
local config = {
modmain_path = _G.debug.getinfo(1).source,
Expand All @@ -11,13 +16,8 @@ if not _G.TheNet:IsDedicated() then
end
end



if GetModConfigData("EnabledJIT") then
local hasluajit, jit = _G.pcall(require, 'jit')
if not hasluajit then
return
end

local TEMPLATES = require "widgets/redux/templates"
local old_getbuildstring = TEMPLATES.GetBuildString
TEMPLATES.GetBuildString = function()
Expand Down
5 changes: 5 additions & 0 deletions src/DontStarveInjector/DontStarveInjector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ extern "C" DONTSTARVEINJECTOR_API void Inject(bool isClient) {
#if USE_LISTENER
interceptor = gum_interceptor_obtain();
#endif

spdlog::set_level(spdlog::level::err);
#ifdef DEBUG
spdlog::set_level(spdlog::level::trace);
#endif

if (!function_relocation::init_ctx()) {
showError("can't init signature");
Expand Down
5 changes: 5 additions & 0 deletions src/DontStarveInjector/loader/winmm_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ void DontStarveInjectorStart() {
std::initializer_list<std::shared_ptr<spdlog::sinks::sink>> sinks = {
std::make_shared<spdlog::sinks::msvc_sink_st>(), std::make_shared<spdlog::sinks::stdout_color_sink_st>()};
spdlog::set_default_logger(std::make_shared<spdlog::logger>("", sinks.begin(), sinks.end()));

spdlog::set_level(spdlog::level::err);
#ifdef DEBUG
spdlog::set_level(spdlog::level::trace);
#endif
auto dir = getGameDir();

bool isClientMod = !getExePath().filename().string().contains("server");
Expand Down
9 changes: 7 additions & 2 deletions src/DontStarveInjector/luajit_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ std::filesystem::path getGameDir() {
#endif
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(luajit_config, modmain_path, server_disable_luajit);
std::optional<luajit_config> luajit_config::read_from_file(std::filesystem::path path) {
if (path.empty())
path = getGameDir() / "data" / "luajit_config.json";
if (path.empty()) {
path = getGameDir() / "data" / "unsafedata";
if (!std::filesystem::exists(path)) {
std::filesystem::create_directories(path);
}
path = path / "luajit_config.json";
}
std::ifstream sf(path.string().c_str());
if (!sf.is_open())
return std::nullopt;
Expand Down

0 comments on commit df0ca64

Please sign in to comment.