mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-25 03:40:40 +00:00
Use ranged for loop
This commit is contained in:
parent
a04eb9d26c
commit
b6cd6402cc
@ -334,14 +334,14 @@ MWWorld::CellStore& MWWorld::WorldModel::getCellByPosition(
|
||||
|
||||
MWWorld::Ptr MWWorld::WorldModel::getPtr(const ESM::RefId& name)
|
||||
{
|
||||
// First check the cache
|
||||
for (IdCache::iterator iter(mIdCache.begin()); iter != mIdCache.end(); ++iter)
|
||||
if (iter->first == name && iter->second)
|
||||
{
|
||||
Ptr ptr = iter->second->getPtr(name);
|
||||
if (!ptr.isEmpty())
|
||||
return ptr;
|
||||
}
|
||||
for (const auto& [cachedId, cellStore] : mIdCache)
|
||||
{
|
||||
if (cachedId != name || cellStore == nullptr)
|
||||
continue;
|
||||
Ptr ptr = cellStore->getPtr(name);
|
||||
if (!ptr.isEmpty())
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// Then check cells that are already listed
|
||||
// Search in reverse, this is a workaround for an ambiguous chargen_plank reference in the vanilla game.
|
||||
@ -423,10 +423,10 @@ int MWWorld::WorldModel::countSavedGameRecords() const
|
||||
|
||||
void MWWorld::WorldModel::write(ESM::ESMWriter& writer, Loading::Listener& progress) const
|
||||
{
|
||||
for (auto iter(mCells.begin()); iter != mCells.end(); ++iter)
|
||||
if (iter->second.hasState())
|
||||
for (auto& [id, cellStore] : mCells)
|
||||
if (cellStore.hasState())
|
||||
{
|
||||
writeCell(writer, iter->second);
|
||||
writeCell(writer, cellStore);
|
||||
progress.increaseProgress();
|
||||
}
|
||||
}
|
||||
|
@ -89,14 +89,12 @@ namespace MWWorld
|
||||
bool readRecord(ESM::ESMReader& reader, uint32_t type, const std::map<int, int>& contentFileMap);
|
||||
|
||||
private:
|
||||
using IdCache = std::vector<std::pair<ESM::RefId, CellStore*>>;
|
||||
|
||||
const MWWorld::ESMStore& mStore;
|
||||
ESM::ReadersCache& mReaders;
|
||||
mutable std::unordered_map<ESM::RefId, CellStore> mCells;
|
||||
mutable std::map<std::string, CellStore*, Misc::StringUtils::CiComp> mInteriors;
|
||||
mutable std::map<ESM::ExteriorCellLocation, CellStore*> mExteriors;
|
||||
IdCache mIdCache;
|
||||
std::vector<std::pair<ESM::RefId, CellStore*>> mIdCache;
|
||||
std::size_t mIdCacheIndex = 0;
|
||||
std::unordered_map<ESM::RefNum, Ptr> mPtrIndex;
|
||||
std::size_t mPtrIndexUpdateCounter = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user