From 43c19f115a8a3b60d87286acacf7142f5870c411 Mon Sep 17 00:00:00 2001 From: thekingofspace <37231416+thekingofspace@users.noreply.github.com> Date: Wed, 14 Jan 2026 00:05:57 -0800 Subject: [PATCH] Changed ProfileService.lua Moved some types so they do not cause type errors, switched the large elseif block to a ghetto case switch. --- ProfileService.lua | 48 +++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/ProfileService.lua b/ProfileService.lua index 47bcb4c..966a7eb 100644 --- a/ProfileService.lua +++ b/ProfileService.lua @@ -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" @@ -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 @@ -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