Skip to content

Commit

Permalink
Fix writing ITL file during ProfileSave
Browse files Browse the repository at this point in the history
  • Loading branch information
teejusb committed Mar 21, 2023
1 parent 263002c commit 07db196
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
7 changes: 2 additions & 5 deletions Scripts/SL-PlayerProfiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,8 @@ SaveProfileCustom = function(profile, dir)
IniFile.WriteFile( path, {[theme_name]=output} )

-- Write to the ITL file if we need to.
-- The ITLData table will only contain data for memory cards.
if #SL[pn].ITLData ~= 0 then
WriteItlFile(dir, table.concat(SL[pn].ITLData, ""))
end

-- This is relevant for memory cards.
WriteItlFile(player)
break
end
end
Expand Down
16 changes: 15 additions & 1 deletion Scripts/SL_ITL.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,30 @@ end
-- Note that songs resynced for ITL but played outside of the pack will not be covered in the pathMap.
local itlFilePath = "itl2023.json"

local TableContainsData = function(t)
if t == nil then return false end

for _, _ in pairs(t) do
return true
end
return false
end

-- Takes the ITLData loaded in memory and writes it to the local profile.
WriteItlFile = function(player)
local pn = ToEnumShortString(player)
-- No data to write, return early.
if (not TableContainsData(SL[pn].ITLData["pathMap"]) and
not TableContainsData(SL[pn].ITLData["hashMap"])) then
return
end

local profile_slot = {
[PLAYER_1] = "ProfileSlot_Player1",
[PLAYER_2] = "ProfileSlot_Player2"
}

local dir = PROFILEMAN:GetProfileDir(profile_slot[player])
local pn = ToEnumShortString(player)
-- We require an explicit profile to be loaded.
if not dir or #dir == 0 then return end

Expand Down

0 comments on commit 07db196

Please sign in to comment.