Skip to content

Commit 8eff473

Browse files
committed
Replace iterator for cycles with range-based for
Add XXX in xrGame/UIDragDropListEx.cpp
1 parent 2748b74 commit 8eff473

File tree

5 files changed

+27
-34
lines changed

5 files changed

+27
-34
lines changed

src/xrGame/AmebaZone.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ bool CAmebaZone::BlowoutState()
2727
if (!result)
2828
UpdateBlowout();
2929

30-
// XXX: use range-based for
31-
for (OBJECT_INFO_VEC::iterator it = m_ObjectInfoMap.begin(); m_ObjectInfoMap.end() != it; ++it)
32-
Affect(&(*it));
30+
for (auto& it : m_ObjectInfoMap)
31+
Affect(&it);
3332

3433
return result;
3534
}
@@ -66,10 +65,9 @@ void CAmebaZone::Affect(SZoneObjectInfo* O)
6665

6766
void CAmebaZone::PhTune(float step)
6867
{
69-
// XXX: use range-based for
70-
for (OBJECT_INFO_VEC::iterator it = m_ObjectInfoMap.begin(); m_ObjectInfoMap.end() != it; ++it)
68+
for (auto& it : m_ObjectInfoMap)
7169
{
72-
CEntityAlive* EA = smart_cast<CEntityAlive*>((*it).object);
70+
auto EA = smart_cast<CEntityAlive*>(it.object);
7371
if (EA)
7472
{
7573
CPHMovementControl* mc = EA->character_physics_support()->movement();

src/xrGame/alife_storage_manager.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,21 @@ void CALifeStorageManager::load(void* buffer, const u32& buffer_size, LPCSTR fil
129129

130130
VERIFY(can_register_objects());
131131
can_register_objects(false);
132-
// XXX: Replace with range-based for
133-
CALifeObjectRegistry::OBJECT_REGISTRY::iterator B = objects().objects().begin();
134-
CALifeObjectRegistry::OBJECT_REGISTRY::iterator E = objects().objects().end();
135-
CALifeObjectRegistry::OBJECT_REGISTRY::iterator I;
136-
for (I = B; I != E; ++I)
132+
133+
for (auto& object : objects().objects())
137134
{
138-
ALife::_OBJECT_ID id = (*I).second->ID;
139-
(*I).second->ID = server().PerformIDgen(id);
140-
VERIFY(id == (*I).second->ID);
141-
register_object((*I).second, false);
135+
ALife::_OBJECT_ID id = object.second->ID;
136+
object.second->ID = server().PerformIDgen(id);
137+
VERIFY(id == object.second->ID);
138+
register_object(object.second, false);
142139
}
143140

144141
registry().load(source);
145142

146143
can_register_objects(true);
147144

148-
for (I = B; I != E; ++I)
149-
(*I).second->on_register();
145+
for (auto& object : objects().objects())
146+
object.second->on_register();
150147

151148
if (!g_pGameLevel)
152149
return;

src/xrGame/alife_trader_abstract.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,14 @@ void add_online_impl(CSE_ALifeDynamicObject* object, const bool& update_registri
160160
clientID.set(
161161
object->alife().server().GetServerClient() ? object->alife().server().GetServerClient()->ID.value() : 0);
162162

163-
// XXX: Replace with range-based for
164-
ALife::OBJECT_IT I = object->children.begin();
165-
ALife::OBJECT_IT E = object->children.end();
166-
for (; I != E; ++I)
163+
for (auto& it : object->children)
167164
{
168165
//Alundaio:
169-
if (*I == ai().alife().graph().actor()->ID)
166+
if (it == ai().alife().graph().actor()->ID)
170167
continue;
171168
//-Alundaio
172169

173-
CSE_ALifeDynamicObject* l_tpALifeDynamicObject = ai().alife().objects().object(*I);
170+
CSE_ALifeDynamicObject* l_tpALifeDynamicObject = ai().alife().objects().object(it);
174171
if (!l_tpALifeDynamicObject)
175172
continue;
176173

src/xrGame/ui/UIActorMenuInventory.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -589,12 +589,11 @@ bool CUIActorMenu::ToSlot(CUICellItem* itm, bool force_place, u16 slot_id)
589589
else
590590
{
591591
//Alundaio: Since the player's inventory is being used as a slot we need to search for cell with matching m_pData
592-
CUICellContainer* c = slot_list->GetContainer();
593-
WINDOW_LIST child_list = c->GetChildWndList();
594-
// XXX: try to replace with range-based for
595-
for (WINDOW_LIST::iterator it = child_list.begin(); child_list.end() != it; ++it)
592+
auto container = slot_list->GetContainer();
593+
auto child_list = container->GetChildWndList();
594+
for (auto& it : child_list)
596595
{
597-
CUICellItem* i = static_cast<CUICellItem*>(*it);
596+
CUICellItem* i = static_cast<CUICellItem*>(it);
598597
const PIItem pitm = static_cast<PIItem>(i->m_pData);
599598
if (pitm == _iitem)
600599
{

src/xrGame/ui/UIDragDropListEx.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -499,16 +499,17 @@ bool CUICellContainer::AddSimilar(CUICellItem* itm)
499499

500500
CUICellItem* CUICellContainer::FindSimilar(CUICellItem* itm)
501501
{
502-
// XXX: try to replace with range-based for
503-
for (auto it = m_ChildWndList.begin(); m_ChildWndList.end() != it; ++it)
502+
for (auto& it : m_ChildWndList)
504503
{
504+
// XXX: Xottab_DUTY: find out why different casts used for different configurations
505+
// and maybe use only one cast
505506
#ifdef DEBUG
506-
CUICellItem* i = smart_cast<CUICellItem*>(*it);
507+
auto i = smart_cast<CUICellItem*>(it);
507508
#else
508-
CUICellItem* i = (CUICellItem*)(*it);
509+
auto i = (CUICellItem*)it;
509510
#endif
510511
//Alundaio: Don't stack equipped items
511-
PIItem iitem = static_cast<PIItem>(i->m_pData);
512+
auto iitem = static_cast<PIItem>(i->m_pData);
512513
if (iitem && iitem->m_pInventory && iitem->m_pInventory->ItemFromSlot(iitem->BaseSlot()) == iitem)
513514
continue;
514515
//-Alundaio
@@ -519,7 +520,8 @@ CUICellItem* CUICellContainer::FindSimilar(CUICellItem* itm)
519520
if (i->EqualTo(itm))
520521
return i;
521522
}
522-
return NULL;
523+
524+
return nullptr;
523525
}
524526

525527
void CUICellContainer::PlaceItemAtPos(CUICellItem* itm, Ivector2& cell_pos)

0 commit comments

Comments
 (0)