Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 30 additions & 18 deletions ProfileService.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,7 @@ local ProfileStore = {
}
ProfileStore.__index = ProfileStore


function ProfileStore:LoadProfileAsync(profile_key, not_released_handler, _use_mock) --> [Profile / nil] not_released_handler(place_id, game_job_id)

not_released_handler = not_released_handler or "ForceLoad"
Expand Down Expand Up @@ -1899,9 +1900,10 @@ function ProfileStore:LoadProfileAsync(profile_key, not_released_handler, _use_m
-- Adding profile to AutoSaveList;
AddProfileToAutoSave(profile)
-- Special case - finished loading profile, but session is shutting down:
if ProfileService.ServiceLocked == true then
if (ProfileService.ServiceLocked::boolean) == true then
SaveProfileAsync(profile, true) -- Release profile and yield until the DataStore call is finished
profile = nil -- nil will be returned by this call
profile = nil::any -- nil will be returned by this call
-- Moved to ::any to prevent type error
end
-- Return Profile object:
ActiveProfileLoadJobs = ActiveProfileLoadJobs - 1
Expand Down Expand Up @@ -1931,26 +1933,36 @@ function ProfileStore:LoadProfileAsync(profile_key, not_released_handler, _use_m
elseif aggressive_steal == true then
task.wait() -- Overload prevention
else
local handler_result = not_released_handler(active_session[1], active_session[2])
if handler_result == "Repeat" then
task.wait() -- Overload prevention
elseif handler_result == "Cancel" then
ActiveProfileLoadJobs = ActiveProfileLoadJobs - 1
return nil
elseif handler_result == "ForceLoad" then
force_load = true
request_force_load = true
task.wait() -- Overload prevention
elseif handler_result == "Steal" then
aggressive_steal = true
task.wait() -- Overload prevention
else
error(
local handler_result = (not_released_handler::any)(active_session[1], active_session[2])

local ProfileActionIndex = {
["Repeat"] = function()
task.wait()
end;
["Cancel"] = function()
ActiveProfileLoadJobs = ActiveProfileLoadJobs - 1
return nil
end;
["ForceLoad"] = function()
force_load = true
request_force_load = true
task.wait() -- Overload prevention
end;
["Steal"] = function()
aggressive_steal = true
task.wait() -- Overload prevention
end;
default = function(self:any)
error(
"[ProfileService]: Invalid return from not_released_handler (\"" .. tostring(handler_result) .. "\")(" .. type(handler_result) .. ");" ..
"\n" .. IdentifyProfile(self._profile_store_name, self._profile_store_scope, profile_key) ..
" Traceback:\n" .. debug.traceback()
)
end
end}

local res = ProfileActionIndex[handler_result] and ProfileActionIndex[handler_result](self) or ProfileActionIndex.default(self)
ProfileActionIndex = nil::any
if res ~= nil then return res end
end
end
else
Expand Down