1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-10 12:39:53 +00:00

Try create CellStore for interior cell when not found

This commit is contained in:
elsid 2023-06-04 22:27:33 +02:00
parent 1843345510
commit 01775dd6f0
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

View File

@ -175,12 +175,27 @@ namespace MWWorld
CellStore* WorldModel::findInterior(std::string_view name, bool forceLoad) const
{
const auto it = mInteriors.find(name);
CellStore* cellStore = nullptr;
if (it == mInteriors.end())
return nullptr;
assert(it->second != nullptr);
if (forceLoad && it->second->getState() != CellStore::State_Loaded)
it->second->load();
return it->second;
{
if (const ESM::Cell* cell = mStore.get<ESM::Cell>().search(name))
cellStore = &emplaceCellStore(cell->mId, *cell, mStore, mReaders, mCells);
else if (const ESM4::Cell* cell4 = mStore.get<ESM4::Cell>().searchCellName(name))
cellStore = &emplaceCellStore(cell4->mId, *cell4, mStore, mReaders, mCells);
else
return nullptr;
}
else
{
assert(it->second != nullptr);
cellStore = it->second;
}
if (forceLoad && cellStore->getState() != CellStore::State_Loaded)
cellStore->load();
return cellStore;
}
CellStore& WorldModel::getInterior(std::string_view name, bool forceLoad) const