Skip to content

Commit 2dcc815

Browse files
committed
bugfix #66
1 parent b79ec3b commit 2dcc815

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/lualib/initsetting.lua

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,27 @@ local function patch(s, k, v)
4141
end
4242
end
4343

44-
local function settings_filename(filename)
44+
local function settings_filename(filename, change_root)
4545
if filename then
4646
local realname = assert(lfs.realpath(filename))
47-
local curpath, name = realname:match "(.*)[/\\]([^/\\]+)$"
48-
if curpath and name then
49-
lfs.chdir(curpath)
47+
if change_root then
48+
local curpath, name = realname:match "(.*)[/\\]([^/\\]+)$"
49+
if curpath and name then
50+
lfs.chdir(curpath)
51+
end
52+
return name
53+
else
54+
return realname
5055
end
51-
return name
5256
end
5357
if file.exist "main.game" then
5458
return "main.game"
5559
end
5660
end
5761

58-
function S.init(args)
62+
function S.init(args, change_root)
5963
local default_settings = datalist.parse(source.data.settingdefault)
60-
local realname = settings_filename(args[1])
64+
local realname = settings_filename(args[1], change_root)
6165
if realname then
6266
local data = file.load(realname) or error ("Can't open " .. realname)
6367
local game_settings = datalist.parse(data)

src/service/settings.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local setting
88

99
function S.init(args)
1010
assert(setting == nil)
11-
setting = initsetting.init(args)
11+
setting = initsetting.init(args, true)
1212
end
1313

1414
function S.get()

0 commit comments

Comments
 (0)