Skip to content

Commit

Permalink
Fix non-host reserves on random suffix items
Browse files Browse the repository at this point in the history
Fixes #25.
  • Loading branch information
Anonomit committed Jun 3, 2024
1 parent 1202d4c commit b71bcec
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
5 changes: 3 additions & 2 deletions Client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,9 @@ function LootReserve.Client:StartSession(server, starting, startTime, acceptingR
if category.Children and (not self.LootCategories or LootReserve:Contains(self.LootCategories, id)) and LootReserve.Data:IsCategoryVisible(category) then
for _, child in ipairs(category.Children) do
if child.Loot then
for _, itemID in ipairs(child.Loot) do
if itemID ~= 0 then
for _, item in ipairs(child.Loot) do
if item ~= 0 then
local itemID = LootReserve.ItemCache(item):GetID();
if LootReserve.ItemConditions:TestServer(itemID) then
if LootReserve.Data:IsTokenReward(itemID) then
table.insert(rewardIDs, itemID);
Expand Down
5 changes: 3 additions & 2 deletions Data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12322,15 +12322,16 @@ end


function LootReserve.Data:IsItemInCategories(itemID, categories)
if itemID == 0 then return false; end
for _, category in ipairs(categories) do
if itemID == 0 or category <= 0 then return false; end
if category <= 0 then return false; end

category = self.Categories[category];
if category and category.Children and self:IsCategoryVisible(category) then
for _, child in ipairs(category.Children) do
if child.Loot then
for _, lootItem in ipairs(child.Loot) do
if lootItem == itemID then
if LootReserve.ItemCache(lootItem):GetID() == itemID then
return true;
end
end
Expand Down
3 changes: 2 additions & 1 deletion ItemSearch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ function LootReserve.ItemSearch:Load()
for id, category in pairs(LootReserve.Data.Categories) do
if not category.Expansion or category.Expansion <= expansion then
for _, child in ipairs(category.Children or { }) do
for _, itemID in ipairs(child.Loot or { }) do
for _, item in ipairs(child.Loot or { }) do
local itemID = LootReserve.ItemCache(item):GetID();
if not alreadyAddedIDs[itemID] then
itemsToCache[#itemsToCache+1] = itemID;
alreadyAddedIDs[itemID] = true;
Expand Down
5 changes: 3 additions & 2 deletions Server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1779,8 +1779,9 @@ function LootReserve.Server:PrepareSession()
if category.Children and (not self.CurrentSession.Settings.LootCategories or LootReserve:Contains(self.CurrentSession.Settings.LootCategories, id)) and LootReserve.Data:IsCategoryVisible(category) then
for _, child in ipairs(category.Children) do
if child.Loot then
for _, itemID in ipairs(child.Loot) do
if itemID ~= 0 then
for _, item in ipairs(child.Loot) do
if item ~= 0 then
local itemID = LootReserve.ItemCache(item):GetID();
if LootReserve.ItemConditions:TestServer(itemID) then
if LootReserve.Data:IsTokenReward(itemID) then
table.insert(rewardIDs, itemID);
Expand Down
6 changes: 3 additions & 3 deletions Windows/ClientWindow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ function LootReserve.Client:UpdateLootList()
for childIndex, child in ipairs(category.Children) do
if child.Loot then
for lootIndex, loot in ipairs(child.Loot) do
if loot == item:GetID() then
if LootReserve.ItemCache(loot):GetID() == item:GetID() then
return id * 10000 + childIndex * 100 + lootIndex;
end
end
Expand Down Expand Up @@ -384,10 +384,10 @@ function LootReserve.Client:UpdateLootList()
parentCategoryName = child.Name;
end
if child.Loot then
for _, itemID in ipairs(child.Loot) do
for _, item in ipairs(child.Loot) do
local itemID = LootReserve.ItemCache(item):GetID();
if itemID ~= 0 and not alreadyFoundIDs[itemID] then
local match = false;
local item = LootReserve.ItemCache:Item(itemID);
if item:IsCached() then
if matchesFilter(item, self.ItemReserves[itemID], filter, category.Name, child.Name) and LootReserve.ItemConditions:IsItemVisibleOnClient(itemID) then
createFrame(item, child.IndentType == 1 and format("%s > %s > %s", category.NameShort, parentCategoryName, child.Name) or format("%s > %s", category.NameShort, child.Name));
Expand Down
4 changes: 2 additions & 2 deletions Windows/ServerLootEditWindow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ function LootReserve.Server.LootEdit:UpdateLootList()
parentCategoryName = child.Name;
end
if child.Loot then
for _, itemID in ipairs(child.Loot) do
for _, item in ipairs(child.Loot) do
local itemID = LootReserve.ItemCache(item):GetID();
if itemID ~= 0 and not alreadyFoundIDs[itemID] then
local match = false;
local item = LootReserve.ItemCache:Item(itemID);
if item:IsCached() then
if matchesFilter(item, filter, category.Name, child.Name) then
createFrame(item, child.IndentType == 1 and format("%s > %s > %s", category.NameShort, parentCategoryName, child.Name) or format("%s > %s", category.NameShort, child.Name));
Expand Down
3 changes: 2 additions & 1 deletion Windows/ServerWindow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,13 @@ function LootReserve.Server:UpdateReserveList(lockdown)
end
end
end
local item = LootReserve.ItemCache(item);
for id, category in LootReserve:Ordered(LootReserve.Data.Categories, LootReserve.Data.CategorySorter) do
if category.Children and (not self.CurrentSession or LootReserve:Contains(self.CurrentSession.Settings.LootCategories, id)) and LootReserve.Data:IsCategoryVisible(category) then
for childIndex, child in ipairs(category.Children) do
if child.Loot then
for lootIndex, loot in ipairs(child.Loot) do
if loot == item then
if LootReserve.ItemCache(loot) == item then
return id * 10000 + childIndex * 100 + lootIndex;
end
end
Expand Down

0 comments on commit b71bcec

Please sign in to comment.