[Exploit/Dupe] Container item

Port From (https://github.com/TrinityCore/TrinityCore/commit/0910bca34cd36ae17652daef9621c318772270d1)
This commit is contained in:
hondacrx
2022-05-29 16:00:04 -04:00
parent 5d30388365
commit 5e6dfb61ac
4 changed files with 30 additions and 25 deletions
@@ -678,10 +678,10 @@ namespace Framework.Database
PrepareStatement(CharStatements.DEL_CHAR_CUF_PROFILES, "DELETE FROM character_cuf_profiles WHERE guid = ?"); PrepareStatement(CharStatements.DEL_CHAR_CUF_PROFILES, "DELETE FROM character_cuf_profiles WHERE guid = ?");
// Items that hold loot or money // Items that hold loot or money
PrepareStatement(CharStatements.SEL_ITEMCONTAINER_ITEMS, "SELECT container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_bonus, context, bonus_list_ids FROM item_loot_items"); PrepareStatement(CharStatements.SEL_ITEMCONTAINER_ITEMS, "SELECT container_id, item_id, item_count, item_index, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_bonus, context, bonus_list_ids FROM item_loot_items");
PrepareStatement(CharStatements.DEL_ITEMCONTAINER_ITEMS, "DELETE FROM item_loot_items WHERE container_id = ?"); PrepareStatement(CharStatements.DEL_ITEMCONTAINER_ITEMS, "DELETE FROM item_loot_items WHERE container_id = ?");
PrepareStatement(CharStatements.DEL_ITEMCONTAINER_ITEM, "DELETE FROM item_loot_items WHERE container_id = ? AND item_id = ? AND item_count = ?"); PrepareStatement(CharStatements.DEL_ITEMCONTAINER_ITEM, "DELETE FROM item_loot_items WHERE container_id = ? AND item_id = ? AND item_count = ? AND item_index = ?");
PrepareStatement(CharStatements.INS_ITEMCONTAINER_ITEMS, "INSERT INTO item_loot_items (container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_bonus, context, bonus_list_ids) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); PrepareStatement(CharStatements.INS_ITEMCONTAINER_ITEMS, "INSERT INTO item_loot_items (container_id, item_id, item_count, item_index, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_bonus, context, bonus_list_ids) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
PrepareStatement(CharStatements.SEL_ITEMCONTAINER_MONEY, "SELECT container_id, money FROM item_loot_money"); PrepareStatement(CharStatements.SEL_ITEMCONTAINER_MONEY, "SELECT container_id, money FROM item_loot_money");
PrepareStatement(CharStatements.DEL_ITEMCONTAINER_MONEY, "DELETE FROM item_loot_money WHERE container_id = ?"); PrepareStatement(CharStatements.DEL_ITEMCONTAINER_MONEY, "DELETE FROM item_loot_money WHERE container_id = ?");
PrepareStatement(CharStatements.INS_ITEMCONTAINER_MONEY, "INSERT INTO item_loot_money (container_id, money) VALUES (?, ?)"); PrepareStatement(CharStatements.INS_ITEMCONTAINER_MONEY, "INSERT INTO item_loot_money (container_id, money) VALUES (?, ?)");
+1 -1
View File
@@ -6018,7 +6018,7 @@ namespace Game.Entities
// LootItem is being removed (looted) from the container, delete it from the DB. // LootItem is being removed (looted) from the container, delete it from the DB.
if (!loot.containerID.IsEmpty()) if (!loot.containerID.IsEmpty())
Global.LootItemStorage.RemoveStoredLootItemForContainer(loot.containerID.GetCounter(), item.itemid, item.count); Global.LootItemStorage.RemoveStoredLootItemForContainer(loot.containerID.GetCounter(), item.itemid, item.count, item.itemIndex);
} }
else else
+2
View File
@@ -109,6 +109,7 @@ namespace Game.Loots
public List<ObjectGuid> GetAllowedLooters() { return allowedGUIDs; } public List<ObjectGuid> GetAllowedLooters() { return allowedGUIDs; }
public uint itemid; public uint itemid;
public uint itemIndex;
public uint randomBonusListId; public uint randomBonusListId;
public List<uint> BonusListIDs = new(); public List<uint> BonusListIDs = new();
public ItemContext context; public ItemContext context;
@@ -191,6 +192,7 @@ namespace Game.Loots
LootItem generatedLoot = new(item); LootItem generatedLoot = new(item);
generatedLoot.context = _itemContext; generatedLoot.context = _itemContext;
generatedLoot.count = (byte)Math.Min(count, proto.GetMaxStackSize()); generatedLoot.count = (byte)Math.Min(count, proto.GetMaxStackSize());
generatedLoot.itemIndex = lootItems.Count;
if (_itemContext != 0) if (_itemContext != 0)
{ {
List<uint> bonusListIDs = Global.DB2Mgr.GetDefaultItemBonusTree(generatedLoot.itemid, _itemContext); List<uint> bonusListIDs = Global.DB2Mgr.GetDefaultItemBonusTree(generatedLoot.itemid, _itemContext);
+24 -21
View File
@@ -50,15 +50,16 @@ namespace Game.Loots
LootItem lootItem = new(); LootItem lootItem = new();
lootItem.itemid = result.Read<uint>(1); lootItem.itemid = result.Read<uint>(1);
lootItem.count = result.Read<byte>(2); lootItem.count = result.Read<byte>(2);
lootItem.follow_loot_rules = result.Read<bool>(3); lootItem.itemIndex = result.Read<uint>(3);
lootItem.freeforall = result.Read<bool>(4); lootItem.follow_loot_rules = result.Read<bool>(4);
lootItem.is_blocked = result.Read<bool>(5); lootItem.freeforall = result.Read<bool>(5);
lootItem.is_counted = result.Read<bool>(6); lootItem.is_blocked = result.Read<bool>(6);
lootItem.is_underthreshold = result.Read<bool>(7); lootItem.is_counted = result.Read<bool>(7);
lootItem.needs_quest = result.Read<bool>(8); lootItem.is_underthreshold = result.Read<bool>(8);
lootItem.randomBonusListId = result.Read<uint>(9); lootItem.needs_quest = result.Read<bool>(9);
lootItem.context = (ItemContext)result.Read<byte>(10); lootItem.randomBonusListId = result.Read<uint>(10);
StringArray bonusLists = new(result.Read<string>(11), ' '); lootItem.context = (ItemContext)result.Read<byte>(11);
StringArray bonusLists = new(result.Read<string>(12), ' ');
foreach (string str in bonusLists) foreach (string str in bonusLists)
lootItem.BonusListIDs.Add(uint.Parse(str)); lootItem.BonusListIDs.Add(uint.Parse(str));
@@ -167,12 +168,12 @@ namespace Game.Loots
DB.Characters.CommitTransaction(trans); DB.Characters.CommitTransaction(trans);
} }
public void RemoveStoredLootItemForContainer(ulong containerId, uint itemId, uint count) public void RemoveStoredLootItemForContainer(ulong containerId, uint itemId, uint count, uint itemIndex)
{ {
if (!_lootItemStorage.ContainsKey(containerId)) if (!_lootItemStorage.ContainsKey(containerId))
return; return;
_lootItemStorage[containerId].RemoveItem(itemId, count); _lootItemStorage[containerId].RemoveItem(itemId, count, itemIndex);
} }
public void AddNewStoredLoot(Loot loot, Player player) public void AddNewStoredLoot(Loot loot, Player player)
@@ -242,20 +243,21 @@ namespace Game.Loots
stmt.AddValue(0, _containerId); stmt.AddValue(0, _containerId);
stmt.AddValue(1, lootItem.itemid); stmt.AddValue(1, lootItem.itemid);
stmt.AddValue(2, lootItem.count); stmt.AddValue(2, lootItem.count);
stmt.AddValue(3, lootItem.follow_loot_rules); stmt.AddValue(3, lootItem.itemIndex);
stmt.AddValue(4, lootItem.freeforall); stmt.AddValue(4, lootItem.follow_loot_rules);
stmt.AddValue(5, lootItem.is_blocked); stmt.AddValue(5, lootItem.freeforall);
stmt.AddValue(6, lootItem.is_counted); stmt.AddValue(6, lootItem.is_blocked);
stmt.AddValue(7, lootItem.is_underthreshold); stmt.AddValue(7, lootItem.is_counted);
stmt.AddValue(8, lootItem.needs_quest); stmt.AddValue(8, lootItem.is_underthreshold);
stmt.AddValue(9, lootItem.randomBonusListId); stmt.AddValue(9, lootItem.needs_quest);
stmt.AddValue(10, (uint)lootItem.context); stmt.AddValue(10, lootItem.randomBonusListId);
stmt.AddValue(11, (uint)lootItem.context);
StringBuilder bonusListIDs = new(); StringBuilder bonusListIDs = new();
foreach (int bonusListID in lootItem.BonusListIDs) foreach (int bonusListID in lootItem.BonusListIDs)
bonusListIDs.Append(bonusListID + ' '); bonusListIDs.Append(bonusListID + ' ');
stmt.AddValue(11, bonusListIDs.ToString()); stmt.AddValue(12, bonusListIDs.ToString());
trans.Append(stmt); trans.Append(stmt);
} }
@@ -284,7 +286,7 @@ namespace Game.Loots
DB.Characters.Execute(stmt); DB.Characters.Execute(stmt);
} }
public void RemoveItem(uint itemId, uint count) public void RemoveItem(uint itemId, uint count, uint itemIndex)
{ {
var bounds = _lootItems.LookupByKey(itemId); var bounds = _lootItems.LookupByKey(itemId);
foreach (var itr in bounds) foreach (var itr in bounds)
@@ -301,6 +303,7 @@ namespace Game.Loots
stmt.AddValue(0, _containerId); stmt.AddValue(0, _containerId);
stmt.AddValue(1, itemId); stmt.AddValue(1, itemId);
stmt.AddValue(2, count); stmt.AddValue(2, count);
stmt.AddValue(3, itemIndex);
DB.Characters.Execute(stmt); DB.Characters.Execute(stmt);
} }