mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-12 13:37:08 +03: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:
parent
488657d9b4
commit
d59a993351
1 changed files with 27 additions and 10 deletions
|
@ -38,6 +38,19 @@ namespace MWWorld
|
||||||
return it->second;
|
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)
|
const ESM::Cell* createEsmCell(ESM::ExteriorCellLocation location, ESMStore& store)
|
||||||
{
|
{
|
||||||
ESM::Cell record;
|
ESM::Cell record;
|
||||||
|
@ -199,12 +212,9 @@ namespace MWWorld
|
||||||
|
|
||||||
if (it == mInteriors.end())
|
if (it == mInteriors.end())
|
||||||
{
|
{
|
||||||
if (const ESM::Cell* cell = mStore.get<ESM::Cell>().search(name))
|
cellStore = emplaceInteriorCellStore(name, mStore, mReaders, mCells);
|
||||||
cellStore = &emplaceCellStore(cell->mId, *cell, mStore, mReaders, mCells);
|
if (cellStore == nullptr)
|
||||||
else if (const ESM4::Cell* cell4 = mStore.get<ESM4::Cell>().searchCellName(name))
|
return cellStore;
|
||||||
cellStore = &emplaceCellStore(cell4->mId, *cell4, mStore, mReaders, mCells);
|
|
||||||
else
|
|
||||||
return nullptr;
|
|
||||||
mInteriors.emplace(name, cellStore);
|
mInteriors.emplace(name, cellStore);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -309,11 +319,18 @@ namespace MWWorld
|
||||||
cell = mStore.get<ESM::Cell>().searchExtByRegion(region->mId);
|
cell = mStore.get<ESM::Cell>().searchExtByRegion(region->mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cell == nullptr)
|
if (cell != nullptr)
|
||||||
return nullptr;
|
return &getExterior(
|
||||||
|
ESM::ExteriorCellLocation(cell->getGridX(), cell->getGridY(), ESM::Cell::sDefaultWorldspaceId),
|
||||||
|
forceLoad);
|
||||||
|
|
||||||
return &getExterior(
|
if (const ESM4::Cell* cell4 = mStore.get<ESM4::Cell>().searchCellName(name);
|
||||||
ESM::ExteriorCellLocation(cell->getGridX(), cell->getGridY(), ESM::Cell::sDefaultWorldspaceId), forceLoad);
|
cell4 != nullptr && cell4->isExterior())
|
||||||
|
{
|
||||||
|
return &getExterior(cell4->getExteriorCellLocation(), forceLoad);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CellStore& WorldModel::getCell(std::string_view name, bool forceLoad) const
|
CellStore& WorldModel::getCell(std::string_view name, bool forceLoad) const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue