mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-09-30 23:37:23 -04:00
CLOSES #788, CLOSES #795, CLOSES #796, CLOSES #797, CLOSES #805, CLOSES #826, CLOSES #833, CLOSES #835, CLOSES #837, CLOSES #844, CLOSES #845, CLOSES #846, CLOSES #847
This commit is contained in:
+17
-2
@@ -368,11 +368,26 @@ function SaveData.saveOptions(opts, fs)
|
||||
end
|
||||
opts.modOptions = merged
|
||||
end
|
||||
local ok, err = fs.write(OPTIONS_FILENAME, SaveSerializer.encode(opts))
|
||||
local encoded = SaveSerializer.encode(opts)
|
||||
local ok, err = fs.write(OPTIONS_FILENAME, encoded)
|
||||
if not ok then
|
||||
Logger.error("options save failed: %s", tostring(err))
|
||||
return nil
|
||||
end
|
||||
return ok and opts or nil
|
||||
-- #828: settings "reset" on Android and Steam Deck with nothing in the log.
|
||||
-- Every options write is a WHOLE-FILE rewrite, so a write that reports
|
||||
-- success without the bytes landing (an external-storage volume that went
|
||||
-- away mid-session, a read-only or full save dir) is indistinguishable from
|
||||
-- "the launcher never saved". Read the file back and fail loudly instead:
|
||||
-- callers already treat nil as a failed write, and the log line is what the
|
||||
-- next report from those platforms needs to carry.
|
||||
local wrote = fs.getInfo(OPTIONS_FILENAME) and fs.read(OPTIONS_FILENAME)
|
||||
if wrote ~= encoded then
|
||||
Logger.error("options save did not land (%d bytes written, %s on disk)",
|
||||
#encoded, type(wrote) == "string" and tostring(#wrote) or "nothing")
|
||||
return nil
|
||||
end
|
||||
return opts
|
||||
end
|
||||
|
||||
function SaveData.loadOptions(fs)
|
||||
|
||||
Reference in New Issue
Block a user