diff options
| author | Spp <spp@jorge.gr> | 2011-10-18 10:44:45 +0200 |
|---|---|---|
| committer | Spp <spp@jorge.gr> | 2011-10-18 10:44:45 +0200 |
| commit | ee69fc940e8bccba0f61032e37bde77ccc10e27c (patch) | |
| tree | 2ef0d7831812aa7182fe2d336fa185d195496f70 /src/server/game/Entities | |
| parent | be34ae68bbf29ba326a2ad6f030253ff065da0a1 (diff) | |
Core/Items: Split SetSoulboundTradeable in two functions (Set and Clear)
Note: this is mostly for clarify action being done: ClearSoulboundTradeable better than SetSoulboundTradeable(..., ..., false)
Diffstat (limited to 'src/server/game/Entities')
| -rwxr-xr-x | src/server/game/Entities/Item/Item.cpp | 34 | ||||
| -rwxr-xr-x | src/server/game/Entities/Item/Item.h | 3 | ||||
| -rwxr-xr-x | src/server/game/Entities/Player/Player.cpp | 30 | ||||
| -rwxr-xr-x | src/server/game/Entities/Player/Player.h | 8 |
4 files changed, 41 insertions, 34 deletions
diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index d3832ad9151..07275166130 100755 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -1194,25 +1194,23 @@ bool Item::IsRefundExpired() return (GetPlayedTime() > 2*HOUR); } -void Item::SetSoulboundTradeable(AllowedLooterSet* allowedLooters, Player* currentOwner, bool apply) +void Item::SetSoulboundTradeable(AllowedLooterSet& allowedLooters) { - if (apply) - { - SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE); - allowedGUIDs = *allowedLooters; - } - else - { - RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE); - if (allowedGUIDs.empty()) - return; + SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE); + allowedGUIDs = allowedLooters; +} - allowedGUIDs.clear(); - SetState(ITEM_CHANGED, currentOwner); - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_BOP_TRADE); - stmt->setUInt32(0, GetGUIDLow()); - CharacterDatabase.Execute(stmt); - } +void Item::ClearSoulboundTradeable(Player* currentOwner) +{ + RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE); + if (allowedGUIDs.empty()) + return; + + allowedGUIDs.clear(); + SetState(ITEM_CHANGED, currentOwner); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_BOP_TRADE); + stmt->setUInt32(0, GetGUIDLow()); + CharacterDatabase.Execute(stmt); } bool Item::CheckSoulboundTradeExpire() @@ -1220,7 +1218,7 @@ bool Item::CheckSoulboundTradeExpire() // called from owner's update - GetOwner() MUST be valid if (GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME) + 2*HOUR < GetOwner()->GetTotalPlayedTime()) { - SetSoulboundTradeable(NULL, GetOwner(), false); + ClearSoulboundTradeable(GetOwner()); return true; // remove from tradeable list } diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index b872b354ea7..4a72e7fea2b 100755 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -352,7 +352,8 @@ class Item : public Object bool IsRefundExpired(); // Soulbound trade system - void SetSoulboundTradeable(AllowedLooterSet* allowedLooters, Player* currentOwner, bool apply); + void SetSoulboundTradeable(AllowedLooterSet& allowedLooters); + void ClearSoulboundTradeable(Player* currentOwner); bool CheckSoulboundTradeExpire(); void BuildUpdate(UpdateDataMapType&); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 203f52ca7c5..ec4e7eba4f8 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -11898,8 +11898,14 @@ void Player::RemoveAmmo() UpdateDamagePhysical(RANGED_ATTACK); } +Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, int32 randomPropertyId) +{ + AllowedLooterSet allowedLooters; + return StoreNewItem(dest, item, update, randomPropertyId, allowedLooters); +} + // Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case. -Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, int32 randomPropertyId, AllowedLooterSet* allowedLooters) +Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, int32 randomPropertyId, AllowedLooterSet& allowedLooters) { uint32 count = 0; for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) @@ -11919,16 +11925,18 @@ Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update if (proto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE && proto->Spells[i].SpellId > 0) // On obtain trigger CastSpell(this, proto->Spells[i].SpellId, true, pItem); - if (allowedLooters && pItem->GetTemplate()->GetMaxStackSize() == 1 && pItem->IsSoulBound()) + if (allowedLooters.size() > 1 && pItem->GetTemplate()->GetMaxStackSize() == 1 && pItem->IsSoulBound()) { - pItem->SetSoulboundTradeable(allowedLooters, this, true); + pItem->SetSoulboundTradeable(allowedLooters); pItem->SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, GetTotalPlayedTime()); m_itemSoulboundTradeable.push_back(pItem); // save data std::ostringstream ss; - for (AllowedLooterSet::iterator itr = allowedLooters->begin(); itr != allowedLooters->end(); ++itr) - ss << *itr << ' '; + AllowedLooterSet::const_iterator itr = allowedLooters.begin(); + ss << *itr; + for (++itr; itr != allowedLooters.end(); ++itr) + ss << ' ' << *itr; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_ITEM_BOP_TRADE); stmt->setUInt32(0, pItem->GetGUIDLow()); @@ -12051,7 +12059,7 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor pItem->SetNotRefundable(this); - pItem->SetSoulboundTradeable(NULL, this, false); + pItem->ClearSoulboundTradeable(this); RemoveTradeableItem(pItem); pItem->SetState(ITEM_REMOVED, this); } @@ -12168,7 +12176,7 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update) pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor pItem->SetNotRefundable(this); - pItem->SetSoulboundTradeable(NULL, this, false); + pItem->ClearSoulboundTradeable(this); RemoveTradeableItem(pItem); pItem->SetState(ITEM_REMOVED, this); pItem2->SetState(ITEM_CHANGED, this); @@ -12388,7 +12396,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) RemoveItemDurations(pItem); pItem->SetNotRefundable(this); - pItem->SetSoulboundTradeable(NULL, this, false); + pItem->ClearSoulboundTradeable(this); RemoveTradeableItem(pItem); const ItemTemplate* proto = pItem->GetTemplate(); @@ -17474,7 +17482,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F AllowedLooterSet looters; for (Tokens::iterator itr = GUIDlist.begin(); itr != GUIDlist.end(); ++itr) looters.insert(atol(*itr)); - item->SetSoulboundTradeable(&looters, this, true); + item->SetSoulboundTradeable(looters); m_itemSoulboundTradeable.push_back(item); } else @@ -23202,8 +23210,8 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot) InventoryResult msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item->itemid, item->count); if (msg == EQUIP_ERR_OK) { - AllowedLooterSet* looters = item->GetAllowedLooters(); - Item* newitem = StoreNewItem(dest, item->itemid, true, item->randomPropertyId, (looters->size() > 1) ? looters : NULL); + AllowedLooterSet looters = item->GetAllowedLooters(); + Item* newitem = StoreNewItem(dest, item->itemid, true, item->randomPropertyId, looters); if (qitem) { diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index a5067a66d55..7d0803a4c8a 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -743,8 +743,8 @@ enum RestType enum DuelCompleteType { DUEL_INTERRUPTED = 0, - DUEL_WON = 1, - DUEL_FLED = 2 + DUEL_WON = 1, + DUEL_FLED = 2 }; enum TeleportToOptions @@ -1269,8 +1269,8 @@ class Player : public Unit, public GridObject<Player> bool HasItemTotemCategory(uint32 TotemCategory) const; InventoryResult CanUseItem(ItemTemplate const* pItem) const; InventoryResult CanUseAmmo(uint32 item) const; - - Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId = 0, AllowedLooterSet* allowedLooters = NULL); + Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId = 0); + Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId, AllowedLooterSet &allowedLooters); Item* StoreItem(ItemPosCountVec const& pos, Item* pItem, bool update); Item* EquipNewItem(uint16 pos, uint32 item, bool update); Item* EquipItem(uint16 pos, Item* pItem, bool update); |
