mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
Load existing exterior CellStore when required
This commit is contained in:
parent
01775dd6f0
commit
457fa16e37
@ -160,16 +160,26 @@ namespace MWWorld
|
|||||||
{
|
{
|
||||||
CellStore& WorldModel::getExterior(ESM::ExteriorCellLocation location, bool forceLoad) const
|
CellStore& WorldModel::getExterior(ESM::ExteriorCellLocation location, bool forceLoad) const
|
||||||
{
|
{
|
||||||
auto it = mExteriors.find(location);
|
const auto it = mExteriors.find(location);
|
||||||
if (it != mExteriors.end())
|
CellStore* cellStore = nullptr;
|
||||||
return *it->second;
|
|
||||||
Cell cell = createExteriorCell(location, mStore);
|
if (it == mExteriors.end())
|
||||||
const ESM::RefId id = cell.getId();
|
{
|
||||||
CellStore& cellStore = emplaceCellStore(id, std::move(cell), mStore, mReaders, mCells);
|
Cell cell = createExteriorCell(location, mStore);
|
||||||
mExteriors.emplace(location, &cellStore);
|
const ESM::RefId id = cell.getId();
|
||||||
if (forceLoad && cellStore.getState() != CellStore::State_Loaded)
|
cellStore = &emplaceCellStore(id, std::move(cell), mStore, mReaders, mCells);
|
||||||
cellStore.load();
|
mExteriors.emplace(location, cellStore);
|
||||||
return cellStore;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
assert(it->second != nullptr);
|
||||||
|
cellStore = it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forceLoad && cellStore->getState() != CellStore::State_Loaded)
|
||||||
|
cellStore->load();
|
||||||
|
|
||||||
|
return *cellStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
CellStore* WorldModel::findInterior(std::string_view name, bool forceLoad) const
|
CellStore* WorldModel::findInterior(std::string_view name, bool forceLoad) const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user