1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

Merge branch 'fix_find_cell' into 'master'

Fix finding interior and load exterior cells

See merge request OpenMW/openmw!3107
This commit is contained in:
psi29a 2023-06-05 07:19:25 +00:00
commit ceea726a50

View File

@ -160,27 +160,52 @@ namespace MWWorld
{
CellStore& WorldModel::getExterior(ESM::ExteriorCellLocation location, bool forceLoad) const
{
auto it = mExteriors.find(location);
if (it != mExteriors.end())
return *it->second;
Cell cell = createExteriorCell(location, mStore);
const ESM::RefId id = cell.getId();
CellStore& cellStore = emplaceCellStore(id, std::move(cell), mStore, mReaders, mCells);
mExteriors.emplace(location, &cellStore);
if (forceLoad && cellStore.getState() != CellStore::State_Loaded)
cellStore.load();
return cellStore;
const auto it = mExteriors.find(location);
CellStore* cellStore = nullptr;
if (it == mExteriors.end())
{
Cell cell = createExteriorCell(location, mStore);
const ESM::RefId id = cell.getId();
cellStore = &emplaceCellStore(id, std::move(cell), mStore, mReaders, mCells);
mExteriors.emplace(location, 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
{
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