diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 30a756de0b..5dca37a047 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -299,8 +299,8 @@ namespace MWClass std::string Door::getDestination(const MWWorld::LiveCellRef& door) { - std::string_view dest - = MWBase::Environment::get().getWorldModel()->getCell(door.mRef.getDestCell())->getCell()->getDisplayName(); + std::string_view dest = MWBase::Environment::get().getWorld()->getCellName( + MWBase::Environment::get().getWorldModel()->getCell(door.mRef.getDestCell())); return "#{sCell=" + std::string{ dest } + "}"; } diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index aafb98240f..1d012c0d0a 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -93,6 +93,8 @@ namespace MWScript MWBase::World* world = MWBase::Environment::get().getWorld(); const MWWorld::Ptr playerPtr = world->getPlayerPtr(); ESM::RefId cellId = world->findCellPosition(cell, pos); + if (cellId.empty()) + throw std::runtime_error("Cell '" + std::string{ cell } + "' not found"); MWWorld::ActionTeleport(cellId, pos, false).execute(playerPtr); world->adjustPosition(playerPtr, false); } @@ -118,7 +120,7 @@ namespace MWScript pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; - MWWorld::ActionTeleport({}, pos, false).execute(playerPtr); + MWWorld::ActionTeleport(ESM::RefId::esm3ExteriorCell(x, y), pos, false).execute(playerPtr); world->adjustPosition(playerPtr, false); } }; diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index d12e53eefe..39d022a393 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -581,6 +581,16 @@ namespace MWWorld return mExt.insert(std::make_pair(key, newCellInserted)).first->second; } + const ESM::Cell* Store::find(const ESM::RefId& id) const + { + const ESM::Cell* ptr = search(id); + if (ptr == nullptr) + { + const std::string msg = "Cell " + id.toDebugString() + " not found"; + throw std::runtime_error(msg); + } + return ptr; + } const ESM::Cell* Store::find(std::string_view id) const { const ESM::Cell* ptr = search(id); diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index b73aea0924..dbcf4c5a98 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -375,6 +375,7 @@ namespace MWWorld const ESM::Cell* searchStatic(int x, int y) const; const ESM::Cell* searchOrCreate(int x, int y); + const ESM::Cell* find(const ESM::RefId& id) const; const ESM::Cell* find(std::string_view id) const; const ESM::Cell* find(int x, int y) const; diff --git a/apps/openmw/mwworld/worldmodel.cpp b/apps/openmw/mwworld/worldmodel.cpp index f1e11e295d..d087c5cd57 100644 --- a/apps/openmw/mwworld/worldmodel.cpp +++ b/apps/openmw/mwworld/worldmodel.cpp @@ -259,7 +259,7 @@ MWWorld::CellStore* MWWorld::WorldModel::getCell(const ESM::RefId& id) CellStore* newCellStore = nullptr; if (!cell4) { - const ESM::Cell* cell = mStore.get().search(id); + const ESM::Cell* cell = mStore.get().find(id); newCellStore = &mCells.emplace(cell->mId, CellStore(MWWorld::Cell(*cell), mStore, mReaders)).first->second; } else