mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-31 14:15:35 +00:00
Try return existing CellStore from WorldModel::getCellStore first
This commit is contained in:
parent
05555947c3
commit
1b116240a3
1 changed files with 9 additions and 17 deletions
|
@ -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;
|
||||
const auto it = mCells.find(cell->mId);
|
||||
if (it != mCells.end())
|
||||
return it->second;
|
||||
|
||||
CellStore& cellStore = mCells.emplace_hint(it, cell->mId, CellStore(Cell(*cell), mStore, mReaders))->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;
|
||||
|
||||
return *result->second;
|
||||
}
|
||||
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…
Reference in a new issue