@@ -50,7 +50,7 @@ local function CreateCustomSaveData()
50
50
end
51
51
52
52
local nativeProfileSettings = ProfileSettings
53
- local CustomProfileSettings = {
53
+ CustomProfileSettings = {
54
54
customDataLoaded = false ,
55
55
data = CreateCustomSaveData ()
56
56
}
@@ -70,17 +70,18 @@ local function TryLoadProfileSettings()
70
70
end
71
71
72
72
-- load file
73
- if localPlayer == nil or localPlayer .name == nil or localPlayer .name :len () == 0 then
73
+ if DNGUserProfileName == nil then
74
+ error (" old Hook version used" )
74
75
return
75
76
end
76
77
77
78
CustomProfileSettings .data = CreateCustomSaveData ()
78
79
CustomProfileSettings .customDataLoaded = true
79
80
80
81
print (" --------- LOAD CUSTOM PROFILE SETTINGS ---------" )
81
- print (" player name " .. localPlayer . name )
82
+ print (" player name " .. DNGUserProfileName )
82
83
83
- local saveFileName = UserDocumentsPath .. localPlayer . name .. AUTOSAVE_CUSTOM_PATH
84
+ local saveFileName = UserDocumentsPath .. DNGUserProfileName .. AUTOSAVE_CUSTOM_PATH
84
85
local file = io.open (saveFileName , " rb" )
85
86
if file == nil then
86
87
print (" No custom profile save data found at " .. saveFileName )
@@ -91,6 +92,7 @@ local function TryLoadProfileSettings()
91
92
local sig , version = struct .unpack (' c4i' , file :read (8 ))
92
93
if sig ~= SAVE_SIGNATURE or version ~= SAVE_VERSION then
93
94
print (" Invalid save file " .. saveFileName )
95
+ file :close ()
94
96
return
95
97
end
96
98
@@ -115,14 +117,16 @@ local function TryLoadProfileSettings()
115
117
print (tostring (err ))
116
118
print (debug.traceback ())
117
119
end )
120
+
121
+ file :close ()
118
122
end
119
123
120
124
local function TrySaveProfileSettings ()
121
125
print (" --------- SAVE CUSTOM PROFILE SETTINGS ---------" )
122
126
123
127
CustomProfileSettings .customDataLoaded = true
124
128
125
- local saveFileName = UserDocumentsPath .. localPlayer . name .. AUTOSAVE_CUSTOM_PATH
129
+ local saveFileName = UserDocumentsPath .. DNGUserProfileName .. AUTOSAVE_CUSTOM_PATH
126
130
local file = io.open (saveFileName , " wb" )
127
131
if file == nil then
128
132
print (" Cannot store custom profile save data at " .. saveFileName )
@@ -148,6 +152,7 @@ local function TrySaveProfileSettings()
148
152
writeArray (file , data .challengeNew )
149
153
writeArray (file , data .collectableUnlocked )
150
154
writeArray (file , data .collectableOwned )
155
+ file :close ()
151
156
end
152
157
153
158
-- Triggers an autosave (if enabled)
223
228
224
229
-- PARAM<1,MissionID>Set mission completed
225
230
CustomProfileSettings .SetMissionCompleted = function (missionId )
226
- CustomProfileSettings .data .missionAttempted [missionId ] = true
231
+ CustomProfileSettings .data .missionCompleted [missionId ] = true
227
232
end
228
233
229
234
-- PARAM<1,MissionID>Get whether a mission is new or not
0 commit comments