Skip to content

Commit 273ef92

Browse files
FenikSRT4LocalIdentity
andcommitted
[ISSUE-9451] Loadout Management
Fix items getting deleted from shared loadouts If an item belonged to 2 loadouts and 1 of them was deleted, it would wipe the items without checking to see if another loadout used them Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent bf53fd4 commit 273ef92

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

spec/System/TestLoadouts_spec.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,26 @@ describe("TestLoadouts", function()
212212
assert.is_same(2, build.configTab.activeConfigSetId)
213213
assert.is_true(build.modFlag)
214214
end)
215+
216+
it("preserves singleton sets shared by the remaining loadout", function()
217+
build:NewLoadout("Second")
218+
build.itemsTab:DeleteItemSet(2, 2)
219+
build.skillsTab:DeleteSkillSet(2, 2)
220+
build.configTab:DeleteConfigSet(2, 2)
221+
build.itemsTab:SetActiveItemSet(1, true)
222+
build.skillsTab:SetActiveSkillSet(1, true)
223+
build.configTab:SetActiveConfigSet(1, false, true)
224+
build.itemsTab.itemSets[1]["Body Armour"].selItemId = 1
225+
build.skillsTab.skillSets[1].socketGroupList = { { gemList = { { nameSpec = "TestGem" } } } }
226+
build.configTab.configSets[1].input.testVar = 123
227+
build:SyncLoadouts()
228+
229+
build:DeleteLoadout("Second", "Default")
230+
231+
assert.are.equals(1, build.itemsTab.itemSets[1]["Body Armour"].selItemId)
232+
assert.are.equals("TestGem", build.skillsTab.skillSets[1].socketGroupList[1].gemList[1].nameSpec)
233+
assert.are.equals(123, build.configTab.configSets[1].input.testVar)
234+
end)
215235
end)
216236

217237
describe("RenameLoadout", function()

src/Modules/Build.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -876,15 +876,15 @@ function buildMode:DeleteLoadout(loadoutName, nextLoadoutName)
876876
if loadout.specId then
877877
t_remove(self.treeTab.specList, loadout.specId)
878878
end
879-
if loadout.itemSetId then
879+
if loadout.itemSetId and #self.itemsTab.itemSetOrderList > 1 then
880880
local index = reverseLookup(self.itemsTab.itemSetOrderList, loadout.itemSetId)
881881
self.itemsTab:DeleteItemSet(loadout.itemSetId, index)
882882
end
883-
if loadout.skillSetId then
883+
if loadout.skillSetId and #self.skillsTab.skillSetOrderList > 1 then
884884
local index = reverseLookup(self.skillsTab.skillSetOrderList, loadout.skillSetId)
885885
self.skillsTab:DeleteSkillSet(loadout.skillSetId, index)
886886
end
887-
if loadout.configSetId then
887+
if loadout.configSetId and #self.configTab.configSetOrderList > 1 then
888888
local index = reverseLookup(self.configTab.configSetOrderList, loadout.configSetId)
889889
self.configTab:DeleteConfigSet(loadout.configSetId, index)
890890
end

0 commit comments

Comments
 (0)