Try return existing CellStore from WorldModel::getCellStore first

macos_ci
elsid 2 years ago
parent 05555947c3
commit 1b116240a3
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -64,26 +64,18 @@ namespace
MWWorld::CellStore& MWWorld::WorldModel::getCellStore(const ESM::Cell* cell)
{
CellStore* cellStore = &mCells.emplace(cell->mId, CellStore(MWWorld::Cell(*cell), mStore, mReaders)).first->second;
if (cell->mData.mFlags & ESM::Cell::Interior)
{
auto result = mInteriors.find(cell->mName);
if (result == mInteriors.end())
result = mInteriors.emplace(cell->mName, cellStore).first;
const auto it = mCells.find(cell->mId);
if (it != mCells.end())
return it->second;
return *result->second;
}
CellStore& cellStore = mCells.emplace_hint(it, cell->mId, CellStore(Cell(*cell), mStore, mReaders))->second;
if (cell->mData.mFlags & ESM::Cell::Interior)
mInteriors.emplace(cell->mName, &cellStore);
else
{
ESM::ExteriorCellLocation extIndex(cell->getGridX(), cell->getGridY(), ESM::Cell::sDefaultWorldspaceId);
std::map<ESM::ExteriorCellLocation, CellStore*>::iterator result = mExteriors.find(extIndex);
mExteriors.emplace(
ESM::ExteriorCellLocation(cell->getGridX(), cell->getGridY(), ESM::Cell::sDefaultWorldspaceId), &cellStore);
if (result == mExteriors.end())
result = mExteriors.emplace(extIndex, cellStore).first;
return *result->second;
}
return cellStore;
}
void MWWorld::WorldModel::clear()

Loading…
Cancel
Save