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

Treat ESM4 exterior cells as exterior

Prevent adding exterior cells to WorldModel::mInteriors. Otherwise CellStore
might be created twice because it's not present in mExteriors but present in
mCells. This happens on teleport to a cell using its name (e.g. --start
"AnvilMainGate" flag).
This commit is contained in:
elsid 2023-07-26 21:26:37 +02:00
parent 488657d9b4
commit d59a993351
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

View File

@ -38,6 +38,19 @@ namespace MWWorld
return it->second;
}
CellStore* emplaceInteriorCellStore(std::string_view name, ESMStore& store, ESM::ReadersCache& readers,
std::unordered_map<ESM::RefId, CellStore>& cells)
{
if (const ESM::Cell* cell = store.get<ESM::Cell>().search(name))
return &emplaceCellStore(cell->mId, *cell, store, readers, cells);
if (const ESM4::Cell* cell = store.get<ESM4::Cell>().searchCellName(name);
cell != nullptr && !cell->isExterior())
{
return &emplaceCellStore(cell->mId, *cell, store, readers, cells);
}
return nullptr;
}
const ESM::Cell* createEsmCell(ESM::ExteriorCellLocation location, ESMStore& store)
{
ESM::Cell record;
@ -199,12 +212,9 @@ namespace MWWorld
if (it == mInteriors.end())
{
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;
cellStore = emplaceInteriorCellStore(name, mStore, mReaders, mCells);
if (cellStore == nullptr)
return cellStore;
mInteriors.emplace(name, cellStore);
}
else
@ -309,11 +319,18 @@ namespace MWWorld
cell = mStore.get<ESM::Cell>().searchExtByRegion(region->mId);
}
if (cell == nullptr)
return nullptr;
if (cell != nullptr)
return &getExterior(
ESM::ExteriorCellLocation(cell->getGridX(), cell->getGridY(), ESM::Cell::sDefaultWorldspaceId),
forceLoad);
return &getExterior(
ESM::ExteriorCellLocation(cell->getGridX(), cell->getGridY(), ESM::Cell::sDefaultWorldspaceId), forceLoad);
if (const ESM4::Cell* cell4 = mStore.get<ESM4::Cell>().searchCellName(name);
cell4 != nullptr && cell4->isExterior())
{
return &getExterior(cell4->getExteriorCellLocation(), forceLoad);
}
return nullptr;
}
CellStore& WorldModel::getCell(std::string_view name, bool forceLoad) const