aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Loot
diff options
context:
space:
mode:
authorSubv <s.v.h21@hotmail.com>2012-12-23 08:33:13 -0500
committerSubv <s.v.h21@hotmail.com>2012-12-23 08:33:13 -0500
commit3869bb7b3a96751b463ecec2d9ac663b792a0703 (patch)
tree330d7e96fa4021f6301d488d64ac6eed717172ab /src/server/game/Loot
parentd40cbe0113329de96723e8fe015651c919760a15 (diff)
parent143340b38c857b2cc50ee9f8577abf9248b6317a (diff)
Merge branch 'master' of https://github.com/TrinityCore/TrinityCore into 4.3.4
Conflicts: src/server/game/Entities/Item/Item.cpp src/server/game/Entities/Player/Player.cpp src/server/game/Entities/Player/Player.h
Diffstat (limited to 'src/server/game/Loot')
-rw-r--r--src/server/game/Loot/LootMgr.cpp41
-rw-r--r--src/server/game/Loot/LootMgr.h16
2 files changed, 55 insertions, 2 deletions
diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp
index 68f6626b3b1..62fd1a416d9 100644
--- a/src/server/game/Loot/LootMgr.cpp
+++ b/src/server/game/Loot/LootMgr.cpp
@@ -334,6 +334,7 @@ LootItem::LootItem(LootStoreItem const& li)
is_blocked = 0;
is_underthreshold = 0;
is_counted = 0;
+ canSave = true;
}
// Basic checks for player/item compatibility - if false no chance to see the item in the loot
@@ -654,6 +655,33 @@ void Loot::generateMoneyLoot(uint32 minAmount, uint32 maxAmount)
}
}
+void Loot::DeleteLootItemFromContainerItemDB(uint32 itemID)
+{
+ // Deletes a single item associated with an openable item from the DB
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEM);
+ stmt->setUInt32(0, containerID);
+ stmt->setUInt32(1, itemID);
+ CharacterDatabase.Execute(stmt);
+
+ // Mark the item looted to prevent resaving
+ for (LootItemList::iterator _itr = items.begin(); _itr != items.end(); _itr++)
+ {
+ if (!_itr->itemid == itemID)
+ continue;
+
+ _itr->canSave = true;
+ break;
+ }
+}
+
+void Loot::DeleteLootMoneyFromContainerItemDB()
+{
+ // Deletes money loot associated with an openable item from the DB
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_MONEY);
+ stmt->setUInt32(0, containerID);
+ CharacterDatabase.Execute(stmt);
+}
+
LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem* *qitem, QuestItem* *ffaitem, QuestItem* *conditem)
{
LootItem* item = NULL;
@@ -1243,6 +1271,19 @@ void LootTemplate::CopyConditions(ConditionList conditions)
i->CopyConditions(conditions);
}
+void LootTemplate::CopyConditions(LootItem* li) const
+{
+ // Copies the conditions list from a template item to a LootItem
+ for (LootStoreItemList::const_iterator _iter = Entries.begin(); _iter != Entries.end(); ++_iter)
+ {
+ if (!_iter->itemid == li->itemid)
+ continue;
+
+ li->conditions = _iter->conditions;
+ break;
+ }
+}
+
// Rolls for every item in the template and adds the rolled items the the loot
void LootTemplate::Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId) const
{
diff --git a/src/server/game/Loot/LootMgr.h b/src/server/game/Loot/LootMgr.h
index 72243cd98f6..e7824f61f92 100644
--- a/src/server/game/Loot/LootMgr.h
+++ b/src/server/game/Loot/LootMgr.h
@@ -140,14 +140,17 @@ struct LootItem
bool is_counted : 1;
bool needs_quest : 1; // quest drop
bool follow_loot_rules : 1;
+ bool canSave;
// Constructor, copies most fields from LootStoreItem, generates random count and random suffixes/properties
// Should be called for non-reference LootStoreItem entries only (mincountOrRef > 0)
explicit LootItem(LootStoreItem const& li);
+ // Empty constructor for creating an empty LootItem to be filled in with DB data
+ LootItem() : canSave(true){};
+
// Basic checks for player/item compatibility - if false no chance to see the item in the loot
bool AllowedForPlayer(Player const* player) const;
-
void AddAllowedLooter(Player const* player);
const AllowedLooterSet & GetAllowedLooters() const { return allowedGUIDs; }
};
@@ -222,6 +225,7 @@ class LootTemplate
// Rolls for every item in the template and adds the rolled items the the loot
void Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId = 0) const;
void CopyConditions(ConditionList conditions);
+ void CopyConditions(LootItem* li) const;
// True if template includes at least 1 quest drop entry
bool HasQuestDrop(LootTemplateMap const& store, uint8 groupId = 0) const;
@@ -286,9 +290,17 @@ struct Loot
uint64 roundRobinPlayer; // GUID of the player having the Round-Robin ownership for the loot. If 0, round robin owner has released.
LootType loot_type; // required for achievement system
- Loot(uint32 _gold = 0) : gold(_gold), unlootedCount(0), loot_type(LOOT_CORPSE) {}
+ // GUIDLow of container that holds this loot (item_instance.entry)
+ // Only set for inventory items that can be right-click looted
+ uint32 containerID;
+
+ Loot(uint32 _gold = 0) : gold(_gold), unlootedCount(0), loot_type(LOOT_CORPSE), containerID(0) {}
~Loot() { clear(); }
+ // For deleting items at loot removal since there is no backward interface to the Item()
+ void DeleteLootItemFromContainerItemDB(uint32 itemID);
+ void DeleteLootMoneyFromContainerItemDB();
+
// if loot becomes invalid this reference is used to inform the listener
void addLootValidatorRef(LootValidatorRef* pLootValidatorRef)
{