From 3286187286caedb302b09b038468e5024a2d3978 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 29 May 2022 16:27:51 -0400 Subject: [PATCH] Core/Item: Fixed another possible container exploit due to invalid loading of stored loot items in DB Port From (https://github.com/TrinityCore/TrinityCore/commit/5f38fd2f2d4fc2f7caba8c6b9e0b3286d8d79339) --- Source/Game/Loot/LootItemStorage.cs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Source/Game/Loot/LootItemStorage.cs b/Source/Game/Loot/LootItemStorage.cs index 0cb5e743e..bf39865b2 100644 --- a/Source/Game/Loot/LootItemStorage.cs +++ b/Source/Game/Loot/LootItemStorage.cs @@ -109,20 +109,21 @@ namespace Game.Loots LootTemplate lt = LootStorage.Items.GetLootFor(item.GetEntry()); if (lt != null) { - foreach (var storedItemPair in container.GetLootItems()) + foreach (var (id, storedItem) in container.GetLootItems()) { LootItem li = new(); - li.itemid = storedItemPair.Key; - li.count = (byte)storedItemPair.Value.Count; - li.follow_loot_rules = storedItemPair.Value.FollowRules; - li.freeforall = storedItemPair.Value.FFA; - li.is_blocked = storedItemPair.Value.Blocked; - li.is_counted = storedItemPair.Value.Counted; - li.is_underthreshold = storedItemPair.Value.UnderThreshold; - li.needs_quest = storedItemPair.Value.NeedsQuest; - li.randomBonusListId = storedItemPair.Value.RandomBonusListId; - li.context = storedItemPair.Value.Context; - li.BonusListIDs = storedItemPair.Value.BonusListIDs; + li.itemid = id; + li.count = (byte)storedItem.Count; + li.itemIndex = storedItem.ItemIndex; + li.follow_loot_rules = storedItem.FollowRules; + li.freeforall = storedItem.FFA; + li.is_blocked = storedItem.Blocked; + li.is_counted = storedItem.Counted; + li.is_underthreshold = storedItem.UnderThreshold; + li.needs_quest = storedItem.NeedsQuest; + li.randomBonusListId = storedItem.RandomBonusListId; + li.context = storedItem.Context; + li.BonusListIDs = storedItem.BonusListIDs; // Copy the extra loot conditions from the item in the loot template lt.CopyConditions(li); @@ -324,6 +325,7 @@ namespace Game.Loots { ItemId = lootItem.itemid; Count = lootItem.count; + ItemIndex = lootItem.itemIndex; FollowRules = lootItem.follow_loot_rules; FFA = lootItem.freeforall; Blocked = lootItem.is_blocked; @@ -337,6 +339,7 @@ namespace Game.Loots public uint ItemId; public uint Count; + public uint ItemIndex; public bool FollowRules; public bool FFA; public bool Blocked;