diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Item.cpp | 2 | ||||
-rw-r--r-- | src/game/Player.cpp | 19 | ||||
-rw-r--r-- | src/game/Player.h | 6 |
3 files changed, 16 insertions, 11 deletions
diff --git a/src/game/Item.cpp b/src/game/Item.cpp index cc19585fcde..024e7138c13 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -1084,7 +1084,7 @@ void Item::SetNotRefundable(Player *owner, bool changestate) SetPaidExtendedCost(0); DeleteRefundDataFromDB(); - owner->DeleteRefundReference(this); + owner->DeleteRefundReference(GetGUID()); } void Item::UpdatePlayedTime(Player *owner) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 7fcc5559a1b..8def5f05d35 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -16412,7 +16412,7 @@ void Player::_LoadInventory(QueryResult_AutoPtr result, uint32 timediff) item->SetRefundRecipient(fields[0].GetUInt32()); item->SetPaidMoney(fields[1].GetUInt32()); item->SetPaidExtendedCost(fields[2].GetUInt32()); - AddRefundReference(item); + AddRefundReference(item->GetGUID()); } } } @@ -17499,9 +17499,14 @@ void Player::_SaveInventory() // the client auto counts down in real time after having received the initial played time on the first // SMSG_ITEM_REFUND_INFO_RESPONSE packet. // Item::UpdatePlayedTime is only called when needed, which is in DB saves, and item refund info requests. - for (std::set<Item*>::iterator itr = m_refundableItems.begin(); itr!= m_refundableItems.end(); ++itr) + std::set<uint64>::iterator i_next; + for (std::set<uint64>::iterator itr = m_refundableItems.begin(); itr!= m_refundableItems.end(); itr = i_next) { - Item* iPtr = *itr; + // use copy iterator because UpdatePlayedTime may invalidate itr + i_next = itr; + ++i_next; + + Item* iPtr = GetItemByGuid(*itr); ASSERT(iPtr); // Sanity check, if this assertion is hit then the item wasn't removed from the set correctly./ iPtr->UpdatePlayedTime(this); } @@ -19362,7 +19367,7 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint it->SetPaidMoney(price); it->SetPaidExtendedCost(crItem->ExtendedCost); it->SaveRefundDataToDB(); - AddRefundReference(it); + AddRefundReference(it->GetGUID()); } } } @@ -19420,7 +19425,7 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint it->SetPaidMoney(price); it->SetPaidExtendedCost(crItem->ExtendedCost); it->SaveRefundDataToDB(); - AddRefundReference(it); + AddRefundReference(it->GetGUID()); } } } @@ -23347,12 +23352,12 @@ void Player::SendDuelCountdown(uint32 counter) GetSession()->SendPacket(&data); } -void Player::AddRefundReference(Item* it) +void Player::AddRefundReference(uint64 it) { m_refundableItems.insert(it); } -void Player::DeleteRefundReference(Item* it) +void Player::DeleteRefundReference(uint64 it) { m_refundableItems.erase(it); }
\ No newline at end of file diff --git a/src/game/Player.h b/src/game/Player.h index fda3525f2c7..b1b32ce9008 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1190,8 +1190,8 @@ class Player : public Unit, public GridObject<Player> uint8 _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const; uint8 _CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item *pItem = NULL, bool swap = false, uint32* no_space_count = NULL ) const; - void AddRefundReference(Item* it); - void DeleteRefundReference(Item* it); + void AddRefundReference(uint64 it); + void DeleteRefundReference(uint64 it); void ApplyEquipCooldown( Item * pItem ); void SetAmmo( uint32 item ); @@ -2558,7 +2558,7 @@ class Player : public Unit, public GridObject<Player> uint8 _CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot ) const; Item* _StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update ); - std::set<Item*> m_refundableItems; + std::set<uint64> m_refundableItems; void UpdateKnownCurrencies(uint32 itemId, bool apply); int32 CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool for_quest); |