mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-25 12:41:01 +00:00
Try return existing CellStore from WorldModel::getCellStore first
This commit is contained in:
parent
05555947c3
commit
1b116240a3
@ -64,26 +64,18 @@ namespace
|
|||||||
|
|
||||||
MWWorld::CellStore& MWWorld::WorldModel::getCellStore(const ESM::Cell* cell)
|
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)
|
if (cell->mData.mFlags & ESM::Cell::Interior)
|
||||||
{
|
mInteriors.emplace(cell->mName, &cellStore);
|
||||||
auto result = mInteriors.find(cell->mName);
|
|
||||||
|
|
||||||
if (result == mInteriors.end())
|
|
||||||
result = mInteriors.emplace(cell->mName, cellStore).first;
|
|
||||||
|
|
||||||
return *result->second;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
mExteriors.emplace(
|
||||||
ESM::ExteriorCellLocation extIndex(cell->getGridX(), cell->getGridY(), ESM::Cell::sDefaultWorldspaceId);
|
ESM::ExteriorCellLocation(cell->getGridX(), cell->getGridY(), ESM::Cell::sDefaultWorldspaceId), &cellStore);
|
||||||
std::map<ESM::ExteriorCellLocation, CellStore*>::iterator result = mExteriors.find(extIndex);
|
|
||||||
|
|
||||||
if (result == mExteriors.end())
|
return cellStore;
|
||||||
result = mExteriors.emplace(extIndex, cellStore).first;
|
|
||||||
|
|
||||||
return *result->second;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWWorld::WorldModel::clear()
|
void MWWorld::WorldModel::clear()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user