diff options
| author | MrSmite <mrsmite@att.net> | 2012-12-14 00:46:36 -0500 |
|---|---|---|
| committer | MrSmite <mrsmite@att.net> | 2012-12-15 00:06:32 -0500 |
| commit | 04f08d26a72ab29b11fc2aaef65bc54078cc2086 (patch) | |
| tree | 23beab0b3ebbdb661fec8c7015d0acd1cb6f8b50 /src/server/game/Handlers/LootHandler.cpp | |
| parent | 1f869ce3a52f2df27b004386d2aaf989254276ff (diff) | |
Implements saving of loot (items / money) contained inside lootable inventory items.
* Unlooted items / money persist across player sessions
* Loot inside items is tied to the item rather than the player so if trading
partially looted items becomes possible, this implementation will still work
* New tables added:
characters_database.sql (first time users)
characters_create_item_loot.sql (existing users)
Implementation Can be tested with:
Watertight Trunk [21113]
Bulging Sack of Gems [25422]
Fat Sack of Coins [11937]
Closes #2048
Diffstat (limited to 'src/server/game/Handlers/LootHandler.cpp')
| -rw-r--r-- | src/server/game/Handlers/LootHandler.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp index 752eace536b..b15636e75d2 100644 --- a/src/server/game/Handlers/LootHandler.cpp +++ b/src/server/game/Handlers/LootHandler.cpp @@ -93,6 +93,10 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recvData) } player->StoreLootItem(lootSlot, loot); + + // If player is removing the last LootItem, delete the empty container. + if (loot->isLooted() && IS_ITEM_GUID(lguid)) + player->GetSession()->DoLootRelease(lguid); } void WorldSession::HandleLootMoneyOpcode(WorldPacket & /*recvData*/) @@ -200,6 +204,14 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket & /*recvData*/) } loot->gold = 0; + + // Delete the money loot record from the DB + if (loot->containerID > 0) + loot->DeleteLootMoneyFromContainerItemDB(); + + // Delete container if empty + if (loot->isLooted() && IS_ITEM_GUID(guid)) + player->GetSession()->DoLootRelease(guid); } } @@ -381,8 +393,8 @@ void WorldSession::DoLootRelease(uint64 lguid) player->DestroyItemCount(pItem, count, true); } else - // FIXME: item must not be deleted in case not fully looted state. But this pre-request implement loot saving in DB at item save. Or cheating possible. - player->DestroyItem(pItem->GetBagSlot(), pItem->GetSlot(), true); + if (pItem->loot.isLooted()) // Only delete item if no loot or money (unlooted loot is saved to db) + player->DestroyItem(pItem->GetBagSlot(), pItem->GetSlot(), true); return; // item can be looted only single player } else |
