1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 18:59:57 +00:00

Merge branch 'cellfallout' into 'master'

Fix cell refid issues

See merge request OpenMW/openmw!2899
This commit is contained in:
psi29a 2023-04-06 14:36:28 +00:00
commit 24a241352f
5 changed files with 17 additions and 4 deletions

View file

@ -299,8 +299,8 @@ namespace MWClass
std::string Door::getDestination(const MWWorld::LiveCellRef<ESM::Door>& 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 } + "}";
}

View file

@ -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);
}
};

View file

@ -581,6 +581,16 @@ namespace MWWorld
return mExt.insert(std::make_pair(key, newCellInserted)).first->second;
}
const ESM::Cell* Store<ESM::Cell>::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<ESM::Cell>::find(std::string_view id) const
{
const ESM::Cell* ptr = search(id);

View file

@ -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;

View file

@ -259,7 +259,7 @@ MWWorld::CellStore* MWWorld::WorldModel::getCell(const ESM::RefId& id)
CellStore* newCellStore = nullptr;
if (!cell4)
{
const ESM::Cell* cell = mStore.get<ESM::Cell>().search(id);
const ESM::Cell* cell = mStore.get<ESM::Cell>().find(id);
newCellStore = &mCells.emplace(cell->mId, CellStore(MWWorld::Cell(*cell), mStore, mReaders)).first->second;
}
else