aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/base/characters_database.sql4
-rw-r--r--sql/updates/characters/3.3.5/2021_07_18_00_characters.sql2
-rw-r--r--src/server/database/Database/Implementation/CharacterDatabase.cpp6
-rw-r--r--src/server/game/Entities/Player/Player.cpp2
-rw-r--r--src/server/game/Loot/Loot.cpp1
-rw-r--r--src/server/game/Loot/Loot.h3
-rw-r--r--src/server/game/Loot/LootItemStorage.cpp44
-rw-r--r--src/server/game/Loot/LootItemStorage.h4
8 files changed, 38 insertions, 28 deletions
diff --git a/sql/base/characters_database.sql b/sql/base/characters_database.sql
index 1dbed596dcf..5e64f98b1db 100644
--- a/sql/base/characters_database.sql
+++ b/sql/base/characters_database.sql
@@ -2065,6 +2065,7 @@ CREATE TABLE `item_loot_items` (
`container_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'guid of container (item_instance.guid)',
`item_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'loot item entry (item_instance.itemEntry)',
`item_count` int(10) NOT NULL DEFAULT '0' COMMENT 'stack size',
+ `item_index` int(10) unsigned NOT NULL DEFAULT '0',
`follow_rules` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'follow loot rules',
`ffa` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'free-for-all',
`blocked` tinyint(1) NOT NULL DEFAULT '0',
@@ -2663,7 +2664,8 @@ INSERT INTO `updates` VALUES
('2021_04_16_00_characters.sql','0EBBF50CE3EB1197973E403C2F1D60881BB497FD','ARCHIVED','2021-04-16 21:23:03',0),
('2021_05_14_00_characters.sql','9834A657E1E1F650E9A7E4E793BAB3E2AFF65293','ARCHIVED','2021-05-14 12:20:33',0),
('2021_06_15_00_characters.sql','4432846E2B0769C01E2B333EEDD90ABA44BF2BC1','ARCHIVED','2021-06-15 11:53:33',0),
-('2021_07_15_00_characters.sql','2ACFF71253DEA0F059476AEA52A55196E6D5DCFE','ARCHIVED','2021-07-15 07:32:48',0);
+('2021_07_15_00_characters.sql','2ACFF71253DEA0F059476AEA52A55196E6D5DCFE','RELEASED','2021-07-15 07:32:48',0),
+('2021_07_18_00_characters.sql','0BA579ED21F4E75AC2B4797421B5029568B3F6E2','ARCHIVED','2021-07-18 11:55:00',0);
/*!40000 ALTER TABLE `updates` ENABLE KEYS */;
UNLOCK TABLES;
diff --git a/sql/updates/characters/3.3.5/2021_07_18_00_characters.sql b/sql/updates/characters/3.3.5/2021_07_18_00_characters.sql
new file mode 100644
index 00000000000..e3ad3e1131b
--- /dev/null
+++ b/sql/updates/characters/3.3.5/2021_07_18_00_characters.sql
@@ -0,0 +1,2 @@
+--
+ALTER TABLE `item_loot_items` ADD COLUMN `item_index` int(10) unsigned NOT NULL DEFAULT '0' AFTER `item_count`;
diff --git a/src/server/database/Database/Implementation/CharacterDatabase.cpp b/src/server/database/Database/Implementation/CharacterDatabase.cpp
index 2109f964f1a..00210cc626c 100644
--- a/src/server/database/Database/Implementation/CharacterDatabase.cpp
+++ b/src/server/database/Database/Implementation/CharacterDatabase.cpp
@@ -540,10 +540,10 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_DEL_CHAR_FISHINGSTEPS, "DELETE FROM character_fishingsteps WHERE guid = ?", CONNECTION_ASYNC);
// Items that hold loot or money
- PrepareStatement(CHAR_SEL_ITEMCONTAINER_ITEMS, "SELECT container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_prop, rnd_suffix FROM item_loot_items", CONNECTION_SYNCH);
+ PrepareStatement(CHAR_SEL_ITEMCONTAINER_ITEMS, "SELECT container_id, item_id, item_count, item_index, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_prop, rnd_suffix FROM item_loot_items", CONNECTION_SYNCH);
PrepareStatement(CHAR_DEL_ITEMCONTAINER_ITEMS, "DELETE FROM item_loot_items WHERE container_id = ?", CONNECTION_ASYNC);
- PrepareStatement(CHAR_DEL_ITEMCONTAINER_ITEM, "DELETE FROM item_loot_items WHERE container_id = ? AND item_id = ? AND item_count = ?", CONNECTION_ASYNC);
- PrepareStatement(CHAR_INS_ITEMCONTAINER_ITEMS, "INSERT INTO item_loot_items (container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_prop, rnd_suffix) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
+ PrepareStatement(CHAR_DEL_ITEMCONTAINER_ITEM, "DELETE FROM item_loot_items WHERE container_id = ? AND item_id = ? AND item_count = ? AND item_index = ?", CONNECTION_ASYNC);
+ PrepareStatement(CHAR_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_prop, rnd_suffix) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_ITEMCONTAINER_MONEY, "SELECT container_id, money FROM item_loot_money", CONNECTION_SYNCH);
PrepareStatement(CHAR_DEL_ITEMCONTAINER_MONEY, "DELETE FROM item_loot_money WHERE container_id = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_INS_ITEMCONTAINER_MONEY, "INSERT INTO item_loot_money (container_id, money) VALUES (?, ?)", CONNECTION_ASYNC);
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 0d82a489ad8..e1be438e018 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -24909,7 +24909,7 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot)
// LootItem is being removed (looted) from the container, delete it from the DB.
if (loot->containerID > 0)
- sLootItemStorage->RemoveStoredLootItemForContainer(loot->containerID, item->itemid, item->count);
+ sLootItemStorage->RemoveStoredLootItemForContainer(loot->containerID, item->itemid, item->count, item->itemIndex);
}
else
diff --git a/src/server/game/Loot/Loot.cpp b/src/server/game/Loot/Loot.cpp
index ffd28eace61..4138936385a 100644
--- a/src/server/game/Loot/Loot.cpp
+++ b/src/server/game/Loot/Loot.cpp
@@ -151,6 +151,7 @@ void Loot::AddItem(LootStoreItem const& item)
{
LootItem generatedLoot(item);
generatedLoot.count = std::min(count, proto->GetMaxStackSize());
+ generatedLoot.itemIndex = lootItems.size();
lootItems.push_back(generatedLoot);
count -= proto->GetMaxStackSize();
diff --git a/src/server/game/Loot/Loot.h b/src/server/game/Loot/Loot.h
index 8012b01866f..2b618b97287 100644
--- a/src/server/game/Loot/Loot.h
+++ b/src/server/game/Loot/Loot.h
@@ -125,6 +125,7 @@ enum LootSlotType
struct TC_GAME_API LootItem
{
uint32 itemid;
+ uint32 itemIndex;
uint32 randomSuffix;
int32 randomPropertyId;
ConditionContainer conditions; // additional loot condition
@@ -144,7 +145,7 @@ struct TC_GAME_API LootItem
explicit LootItem(LootStoreItem const& li);
// Empty constructor for creating an empty LootItem to be filled in with DB data
- LootItem() : itemid(0), randomSuffix(0), randomPropertyId(0), count(0), is_looted(false), is_blocked(false),
+ LootItem() : itemid(0), itemIndex(0), randomSuffix(0), randomPropertyId(0), count(0), is_looted(false), is_blocked(false),
freeforall(false), is_underthreshold(false), is_counted(false), needs_quest(false), follow_loot_rules(false)
{ };
diff --git a/src/server/game/Loot/LootItemStorage.cpp b/src/server/game/Loot/LootItemStorage.cpp
index e3b1979cf65..36f3c3a12ad 100644
--- a/src/server/game/Loot/LootItemStorage.cpp
+++ b/src/server/game/Loot/LootItemStorage.cpp
@@ -80,14 +80,15 @@ void LootItemStorage::LoadStorageFromDB()
LootItem lootItem;
lootItem.itemid = fields[1].GetUInt32();
lootItem.count = fields[2].GetUInt32();
- lootItem.follow_loot_rules = fields[3].GetBool();
- lootItem.freeforall = fields[4].GetBool();
- lootItem.is_blocked = fields[5].GetBool();
- lootItem.is_counted = fields[6].GetBool();
- lootItem.is_underthreshold = fields[7].GetBool();
- lootItem.needs_quest = fields[8].GetBool();
- lootItem.randomPropertyId = fields[9].GetInt32();
- lootItem.randomSuffix = fields[10].GetUInt32();
+ lootItem.itemIndex = fields[3].GetUInt32();
+ lootItem.follow_loot_rules = fields[4].GetBool();
+ lootItem.freeforall = fields[5].GetBool();
+ lootItem.is_blocked = fields[6].GetBool();
+ lootItem.is_counted = fields[7].GetBool();
+ lootItem.is_underthreshold = fields[8].GetBool();
+ lootItem.needs_quest = fields[9].GetBool();
+ lootItem.randomPropertyId = fields[10].GetInt32();
+ lootItem.randomSuffix = fields[11].GetUInt32();
storedContainer.AddLootItem(lootItem, trans);
@@ -217,7 +218,7 @@ void LootItemStorage::RemoveStoredLootForContainer(uint32 containerId)
CharacterDatabase.CommitTransaction(trans);
}
-void LootItemStorage::RemoveStoredLootItemForContainer(uint32 containerId, uint32 itemId, uint32 count)
+void LootItemStorage::RemoveStoredLootItemForContainer(uint32 containerId, uint32 itemId, uint32 count, uint32 itemIndex)
{
// write
std::unique_lock<std::shared_mutex> lock(*GetLock());
@@ -226,7 +227,7 @@ void LootItemStorage::RemoveStoredLootItemForContainer(uint32 containerId, uint3
if (itr == _lootItemStore.end())
return;
- itr->second.RemoveItem(itemId, count);
+ itr->second.RemoveItem(itemId, count, itemIndex);
}
void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* player)
@@ -292,18 +293,20 @@ void StoredLootContainer::AddLootItem(LootItem const& lootItem, CharacterDatabas
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_ITEMS);
- // container_id, item_id, item_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_prop, rnd_suffix
+ // container_id, item_id, item_count, item_index, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_prop, rnd_suffix
stmt->setUInt32(0, _containerId);
stmt->setUInt32(1, lootItem.itemid);
stmt->setUInt32(2, lootItem.count);
- stmt->setBool(3, lootItem.follow_loot_rules);
- stmt->setBool(4, lootItem.freeforall);
- stmt->setBool(5, lootItem.is_blocked);
- stmt->setBool(6, lootItem.is_counted);
- stmt->setBool(7, lootItem.is_underthreshold);
- stmt->setBool(8, lootItem.needs_quest);
- stmt->setInt32(9, lootItem.randomPropertyId);
- stmt->setUInt32(10, lootItem.randomSuffix);
+ stmt->setUInt32(3, lootItem.itemIndex);
+ stmt->setBool(4, lootItem.follow_loot_rules);
+ stmt->setBool(5, lootItem.freeforall);
+ stmt->setBool(6, lootItem.is_blocked);
+ stmt->setBool(7, lootItem.is_counted);
+ stmt->setBool(8, lootItem.is_underthreshold);
+ stmt->setBool(9, lootItem.needs_quest);
+ stmt->setInt32(10, lootItem.randomPropertyId);
+ stmt->setUInt32(11, lootItem.randomSuffix);
+
trans->Append(stmt);
}
@@ -332,7 +335,7 @@ void StoredLootContainer::RemoveMoney()
CharacterDatabase.Execute(stmt);
}
-void StoredLootContainer::RemoveItem(uint32 itemId, uint32 count)
+void StoredLootContainer::RemoveItem(uint32 itemId, uint32 count, uint32 itemIndex)
{
auto bounds = _lootItems.equal_range(itemId);
for (auto itr = bounds.first; itr != bounds.second; ++itr)
@@ -349,5 +352,6 @@ void StoredLootContainer::RemoveItem(uint32 itemId, uint32 count)
stmt->setUInt32(0, _containerId);
stmt->setUInt32(1, itemId);
stmt->setUInt32(2, count);
+ stmt->setUInt32(3, itemIndex);
CharacterDatabase.Execute(stmt);
}
diff --git a/src/server/game/Loot/LootItemStorage.h b/src/server/game/Loot/LootItemStorage.h
index 13e0e3e6cdc..d3903721e4c 100644
--- a/src/server/game/Loot/LootItemStorage.h
+++ b/src/server/game/Loot/LootItemStorage.h
@@ -56,7 +56,7 @@ class StoredLootContainer
void AddMoney(uint32 money, CharacterDatabaseTransaction trans);
void RemoveMoney();
- void RemoveItem(uint32 itemId, uint32 count);
+ void RemoveItem(uint32 itemId, uint32 count, uint32 itemIndex);
uint32 GetContainer() const { return _containerId; }
uint32 GetMoney() const { return _money; }
@@ -78,7 +78,7 @@ class LootItemStorage
bool LoadStoredLoot(Item* item, Player* player);
void RemoveStoredMoneyForContainer(uint32 containerId);
void RemoveStoredLootForContainer(uint32 containerId);
- void RemoveStoredLootItemForContainer(uint32 containerId, uint32 itemId, uint32 count);
+ void RemoveStoredLootItemForContainer(uint32 containerId, uint32 itemId, uint32 count, uint32 itemIndex);
void AddNewStoredLoot(Loot* loot, Player* player);
private: