Removed iter_inst and iter_contents typedefs

This commit is contained in:
Uleat 2015-02-06 08:52:41 -05:00
parent 2bf2485b4c
commit 5d64012d74
3 changed files with 15 additions and 22 deletions

View File

@ -2,6 +2,7 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50)
------------------------------------------------------- -------------------------------------------------------
== 02/06/2015 == == 02/06/2015 ==
Uleat: Updated returns for Inventory and ItemInst const iterators. (const == const) 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 == == 02/03/2015 ==
Trevius: Crashfix for TempName() when numbers are passed at the end of the name. Trevius: Crashfix for TempName() when numbers are passed at the end of the name.

View File

@ -1071,13 +1071,10 @@ int Inventory::GetSlotByItemInstCollection(const std::map<int16, ItemInst*> &col
return -1; return -1;
} }
void Inventory::dumpItemCollection(const std::map<int16, ItemInst*> &collection) { void Inventory::dumpItemCollection(const std::map<int16, ItemInst*> &collection)
iter_inst it; {
iter_contents itb; for (auto it = collection.cbegin(); it != collection.cend(); ++it) {
ItemInst* inst = nullptr; auto inst = it->second;
for (it = collection.begin(); it != collection.end(); ++it) {
inst = it->second;
if (!inst || !inst->GetItem()) if (!inst || !inst->GetItem())
continue; continue;
@ -1088,14 +1085,13 @@ void Inventory::dumpItemCollection(const std::map<int16, ItemInst*> &collection)
} }
} }
void Inventory::dumpBagContents(ItemInst *inst, iter_inst *it) { void Inventory::dumpBagContents(ItemInst *inst, std::map<int16, ItemInst*>::const_iterator *it)
iter_contents itb; {
if (!inst || !inst->IsType(ItemClassContainer)) if (!inst || !inst->IsType(ItemClassContainer))
return; return;
// Go through bag, if bag // 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; ItemInst* baginst = itb->second;
if (!baginst || !baginst->GetItem()) if (!baginst || !baginst->GetItem())
continue; continue;
@ -1110,7 +1106,7 @@ void Inventory::dumpBagContents(ItemInst *inst, iter_inst *it) {
// Internal Method: Retrieves item within an inventory bucket // Internal Method: Retrieves item within an inventory bucket
ItemInst* Inventory::_GetItem(const std::map<int16, ItemInst*>& bucket, int16 slot_id) const ItemInst* Inventory::_GetItem(const std::map<int16, ItemInst*>& bucket, int16 slot_id) const
{ {
iter_inst it = bucket.find(slot_id); auto it = bucket.find(slot_id);
if (it != bucket.end()) { if (it != bucket.end()) {
return it->second; return it->second;
} }
@ -1505,8 +1501,7 @@ ItemInst::ItemInst(const ItemInst& copy)
m_attuned=copy.m_attuned; m_attuned=copy.m_attuned;
m_merchantcount=copy.m_merchantcount; m_merchantcount=copy.m_merchantcount;
// Copy container contents // Copy container contents
iter_contents it; for (auto it = copy.m_contents.begin(); it != copy.m_contents.end(); ++it) {
for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); ++it) {
ItemInst* inst_old = it->second; ItemInst* inst_old = it->second;
ItemInst* inst_new = nullptr; ItemInst* inst_new = nullptr;
@ -1676,7 +1671,7 @@ bool ItemInst::IsAugmentSlotAvailable(int32 augtype, uint8 slot) const
// Retrieve item inside container // Retrieve item inside container
ItemInst* ItemInst::GetItem(uint8 index) const ItemInst* ItemInst::GetItem(uint8 index) const
{ {
iter_contents it = m_contents.find(index); auto it = m_contents.find(index);
if (it != m_contents.end()) { if (it != m_contents.end()) {
return it->second; return it->second;
} }
@ -1739,7 +1734,7 @@ void ItemInst::ClearByFlags(byFlagSetting is_nodrop, byFlagSetting is_norent)
// TODO: This needs work... // TODO: This needs work...
// Destroy container contents // Destroy container contents
iter_contents cur, end, del; std::map<uint8, ItemInst*>::const_iterator cur, end, del;
cur = m_contents.begin(); cur = m_contents.begin();
end = m_contents.end(); end = m_contents.end();
for (; cur != end;) { for (; cur != end;) {

View File

@ -33,9 +33,6 @@ class EvolveInfo; // Stores information about an evolving item family
#include <list> #include <list>
#include <map> #include <map>
// Helper typedefs
typedef std::map<int16, ItemInst*>::const_iterator iter_inst;
typedef std::map<uint8, ItemInst*>::const_iterator iter_contents;
namespace ItemField namespace ItemField
{ {
@ -227,7 +224,7 @@ protected:
int GetSlotByItemInstCollection(const std::map<int16, ItemInst*> &collection, ItemInst *inst); int GetSlotByItemInstCollection(const std::map<int16, ItemInst*> &collection, ItemInst *inst);
void dumpItemCollection(const std::map<int16, ItemInst*> &collection); void dumpItemCollection(const std::map<int16, ItemInst*> &collection);
void dumpBagContents(ItemInst *inst, iter_inst *it); void dumpBagContents(ItemInst *inst, std::map<int16, ItemInst*>::const_iterator *it);
// Retrieves item within an inventory bucket // Retrieves item within an inventory bucket
ItemInst* _GetItem(const std::map<int16, ItemInst*>& bucket, int16 slot_id) const; ItemInst* _GetItem(const std::map<int16, ItemInst*>& bucket, int16 slot_id) const;
@ -425,8 +422,8 @@ protected:
////////////////////////// //////////////////////////
// Protected Members // Protected Members
////////////////////////// //////////////////////////
iter_contents _cbegin() { return m_contents.cbegin(); } std::map<uint8, ItemInst*>::const_iterator _cbegin() { return m_contents.cbegin(); }
iter_contents _cend() { return m_contents.cend(); } std::map<uint8, ItemInst*>::const_iterator _cend() { return m_contents.cend(); }
friend class Inventory; friend class Inventory;