1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-04 03:40:14 +00:00

Use descriptive names for range elements

iter does not describe the nature of the object. Range-based for loop provides
elements of the iterator range, not iterators.
This commit is contained in:
elsid 2022-07-02 00:47:07 +02:00
parent cec7f1e7bc
commit 1b117af5e1
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625
2 changed files with 16 additions and 16 deletions

View File

@ -238,15 +238,15 @@ namespace MWScript
void GlobalScripts::write (ESM::ESMWriter& writer, Loading::Listener& progress) const void GlobalScripts::write (ESM::ESMWriter& writer, Loading::Listener& progress) const
{ {
for (const auto& iter : mScripts) for (const auto& [id, desc] : mScripts)
{ {
ESM::GlobalScript script = std::visit (ScriptCreatingVisitor {}, iter.second->mTarget); ESM::GlobalScript script = std::visit(ScriptCreatingVisitor {}, desc->mTarget);
script.mId = iter.first; script.mId = id;
iter.second->mLocals.write (script.mLocals, iter.first); desc->mLocals.write(script.mLocals, id);
script.mRunning = iter.second->mRunning ? 1 : 0; script.mRunning = desc->mRunning ? 1 : 0;
writer.startRecord (ESM::REC_GSCR); writer.startRecord (ESM::REC_GSCR);
script.save (writer); script.save (writer);

View File

@ -44,10 +44,10 @@ namespace
{ {
float sum = 0; float sum = 0;
for (const auto& iter : cellRefList.mList) for (const MWWorld::LiveCellRef<T>& liveCellRef : cellRefList.mList)
{ {
if (iter.mData.getCount()>0) if (const int count = liveCellRef.mData.getCount(); count > 0)
sum += iter.mData.getCount()*iter.mBase->mData.mWeight; sum += count * liveCellRef.mBase->mData.mWeight;
} }
return sum; return sum;
@ -60,11 +60,11 @@ namespace
store->resolve(); store->resolve();
std::string id2 = Misc::StringUtils::lowerCase (id); std::string id2 = Misc::StringUtils::lowerCase (id);
for (auto& iter : list.mList) for (MWWorld::LiveCellRef<T>& liveCellRef : list.mList)
{ {
if (Misc::StringUtils::ciEqual(iter.mBase->mId, id2) && iter.mData.getCount()) if (Misc::StringUtils::ciEqual(liveCellRef.mBase->mId, id2) && liveCellRef.mData.getCount())
{ {
MWWorld::Ptr ptr (&iter, nullptr); MWWorld::Ptr ptr(&liveCellRef, nullptr);
ptr.setContainerStore (store); ptr.setContainerStore (store);
return ptr; return ptr;
} }
@ -124,15 +124,15 @@ template<typename T>
void MWWorld::ContainerStore::storeStates (const CellRefList<T>& collection, void MWWorld::ContainerStore::storeStates (const CellRefList<T>& collection,
ESM::InventoryState& inventory, int& index, bool equipable) const ESM::InventoryState& inventory, int& index, bool equipable) const
{ {
for (const auto& iter : collection.mList) for (const LiveCellRef<T>& liveCellRef : collection.mList)
{ {
if (iter.mData.getCount() == 0) if (liveCellRef.mData.getCount() == 0)
continue; continue;
ESM::ObjectState state; ESM::ObjectState state;
storeState (iter, state); storeState(liveCellRef, state);
if (equipable) if (equipable)
storeEquipmentState(iter, index, inventory); storeEquipmentState(liveCellRef, index, inventory);
inventory.mItems.push_back (state); inventory.mItems.push_back(std::move(state));
++index; ++index;
} }
} }