From 5d64012d74df20e26ce25f481f9b3ce1055c54e6 Mon Sep 17 00:00:00 2001 From: Uleat Date: Fri, 6 Feb 2015 08:52:41 -0500 Subject: [PATCH] Removed iter_inst and iter_contents typedefs --- changelog.txt | 1 + common/item.cpp | 27 +++++++++++---------------- common/item.h | 9 +++------ 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/changelog.txt b/changelog.txt index 8d28ad3de..47aa7016f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- == 02/06/2015 == Uleat: Updated returns for Inventory and ItemInst const iterators. (const == const) +Uleat: Replaced 'iter_inst' and 'iter_contents' typedefs with their stl definitions == 02/03/2015 == Trevius: Crashfix for TempName() when numbers are passed at the end of the name. diff --git a/common/item.cpp b/common/item.cpp index 4119c7058..40fc98474 100644 --- a/common/item.cpp +++ b/common/item.cpp @@ -1071,13 +1071,10 @@ int Inventory::GetSlotByItemInstCollection(const std::map &col return -1; } -void Inventory::dumpItemCollection(const std::map &collection) { - iter_inst it; - iter_contents itb; - ItemInst* inst = nullptr; - - for (it = collection.begin(); it != collection.end(); ++it) { - inst = it->second; +void Inventory::dumpItemCollection(const std::map &collection) +{ + for (auto it = collection.cbegin(); it != collection.cend(); ++it) { + auto inst = it->second; if (!inst || !inst->GetItem()) continue; @@ -1088,14 +1085,13 @@ void Inventory::dumpItemCollection(const std::map &collection) } } -void Inventory::dumpBagContents(ItemInst *inst, iter_inst *it) { - iter_contents itb; - +void Inventory::dumpBagContents(ItemInst *inst, std::map::const_iterator *it) +{ if (!inst || !inst->IsType(ItemClassContainer)) return; // Go through bag, if bag - for (itb = inst->_cbegin(); itb != inst->_cend(); ++itb) { + for (auto itb = inst->_cbegin(); itb != inst->_cend(); ++itb) { ItemInst* baginst = itb->second; if (!baginst || !baginst->GetItem()) continue; @@ -1110,7 +1106,7 @@ void Inventory::dumpBagContents(ItemInst *inst, iter_inst *it) { // Internal Method: Retrieves item within an inventory bucket ItemInst* Inventory::_GetItem(const std::map& bucket, int16 slot_id) const { - iter_inst it = bucket.find(slot_id); + auto it = bucket.find(slot_id); if (it != bucket.end()) { return it->second; } @@ -1505,8 +1501,7 @@ ItemInst::ItemInst(const ItemInst& copy) m_attuned=copy.m_attuned; m_merchantcount=copy.m_merchantcount; // Copy container contents - iter_contents it; - for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); ++it) { + for (auto it = copy.m_contents.begin(); it != copy.m_contents.end(); ++it) { ItemInst* inst_old = it->second; ItemInst* inst_new = nullptr; @@ -1676,7 +1671,7 @@ bool ItemInst::IsAugmentSlotAvailable(int32 augtype, uint8 slot) const // Retrieve item inside container ItemInst* ItemInst::GetItem(uint8 index) const { - iter_contents it = m_contents.find(index); + auto it = m_contents.find(index); if (it != m_contents.end()) { return it->second; } @@ -1739,7 +1734,7 @@ void ItemInst::ClearByFlags(byFlagSetting is_nodrop, byFlagSetting is_norent) // TODO: This needs work... // Destroy container contents - iter_contents cur, end, del; + std::map::const_iterator cur, end, del; cur = m_contents.begin(); end = m_contents.end(); for (; cur != end;) { diff --git a/common/item.h b/common/item.h index 8554d1c55..906e00313 100644 --- a/common/item.h +++ b/common/item.h @@ -33,9 +33,6 @@ class EvolveInfo; // Stores information about an evolving item family #include #include -// Helper typedefs -typedef std::map::const_iterator iter_inst; -typedef std::map::const_iterator iter_contents; namespace ItemField { @@ -227,7 +224,7 @@ protected: int GetSlotByItemInstCollection(const std::map &collection, ItemInst *inst); void dumpItemCollection(const std::map &collection); - void dumpBagContents(ItemInst *inst, iter_inst *it); + void dumpBagContents(ItemInst *inst, std::map::const_iterator *it); // Retrieves item within an inventory bucket ItemInst* _GetItem(const std::map& bucket, int16 slot_id) const; @@ -425,8 +422,8 @@ protected: ////////////////////////// // Protected Members ////////////////////////// - iter_contents _cbegin() { return m_contents.cbegin(); } - iter_contents _cend() { return m_contents.cend(); } + std::map::const_iterator _cbegin() { return m_contents.cbegin(); } + std::map::const_iterator _cend() { return m_contents.cend(); } friend class Inventory;