mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Merge branch 'fix_coc_to_interior' into 'master'
Avoid using findCellPosition for coc command implementation (#7312) Closes #7312 See merge request OpenMW/openmw!2910
This commit is contained in:
commit
a90815e8ed
@ -519,9 +519,6 @@ namespace MWBase
|
||||
/// \return empty RefId if interior with given name not exists, the cell's RefId otherwise
|
||||
virtual ESM::RefId findInteriorPosition(std::string_view name, ESM::Position& pos) = 0;
|
||||
|
||||
/// Find default position inside interior or exterior cell specified by name
|
||||
/// \return empty RefId if interior with given name not exists, the cell's RefId otherwise
|
||||
virtual ESM::RefId findCellPosition(std::string_view cellName, ESM::Position& pos) = 0;
|
||||
/// Enables or disables use of teleport spell effects (recall, intervention, etc).
|
||||
virtual void enableTeleporting(bool enable) = 0;
|
||||
|
||||
|
@ -92,11 +92,19 @@ namespace MWScript
|
||||
ESM::Position pos;
|
||||
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);
|
||||
|
||||
if (const ESM::RefId refId = world->findExteriorPosition(cell, pos); !refId.empty())
|
||||
{
|
||||
MWWorld::ActionTeleport(refId, pos, false).execute(playerPtr);
|
||||
world->adjustPosition(playerPtr, false);
|
||||
return;
|
||||
}
|
||||
if (const ESM::RefId refId = world->findInteriorPosition(cell, pos); !refId.empty())
|
||||
{
|
||||
MWWorld::ActionTeleport(refId, pos, false).execute(playerPtr);
|
||||
return;
|
||||
}
|
||||
throw std::runtime_error("Cell " + std::string(cell) + " is not found");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2841,25 +2841,6 @@ namespace MWWorld
|
||||
return ESM::RefId::sEmpty;
|
||||
}
|
||||
|
||||
ESM::RefId World::findCellPosition(std::string_view cellName, ESM::Position& pos)
|
||||
{
|
||||
ESM::RefId foundCell;
|
||||
try
|
||||
{
|
||||
foundCell = findInteriorPosition(cellName, pos);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
Log(Debug::Error) << e.what();
|
||||
}
|
||||
if (foundCell.empty())
|
||||
{
|
||||
return findExteriorPosition(cellName, pos);
|
||||
}
|
||||
|
||||
return foundCell;
|
||||
}
|
||||
|
||||
ESM::RefId World::findExteriorPosition(std::string_view nameId, ESM::Position& pos)
|
||||
{
|
||||
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
|
||||
|
@ -606,7 +606,7 @@ namespace MWWorld
|
||||
/// Find position in interior cell near door entrance
|
||||
/// \return false if interior with given name not exists, true otherwise
|
||||
ESM::RefId findInteriorPosition(std::string_view name, ESM::Position& pos) override;
|
||||
ESM::RefId findCellPosition(std::string_view cellName, ESM::Position& pos) override;
|
||||
|
||||
/// Enables or disables use of teleport spell effects (recall, intervention, etc).
|
||||
void enableTeleporting(bool enable) override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user