1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-04 03:40:14 +00:00

Remove WorldModel::getCellByPosition function

It's used in a single place. Move the code there.
This commit is contained in:
elsid 2023-05-27 01:25:35 +02:00
parent 235eb65c97
commit 183202cd65
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625
3 changed files with 5 additions and 20 deletions

View File

@ -67,7 +67,11 @@ namespace MWLua
else
cell = &wm->getCell(name);
}
return &wm->getCellByPosition(pos, cell);
if (cell != nullptr && !cell->isExterior())
return cell;
const ESM::RefId worldspace
= cell == nullptr ? ESM::Cell::sDefaultWorldspaceId : cell->getCell()->getWorldSpace();
return &wm->getExterior(ESM::positionToExteriorCellLocation(pos.x(), pos.y(), worldspace));
}
void teleportPlayer(

View File

@ -319,19 +319,6 @@ MWWorld::CellStore& MWWorld::WorldModel::getCell(std::string_view name, bool for
ESM::ExteriorCellLocation(cell->getGridX(), cell->getGridY(), ESM::Cell::sDefaultWorldspaceId), forceLoad);
}
MWWorld::CellStore& MWWorld::WorldModel::getCellByPosition(
const osg::Vec3f& pos, MWWorld::CellStore* cellInSameWorldSpace)
{
if (cellInSameWorldSpace && !cellInSameWorldSpace->isExterior())
return *cellInSameWorldSpace;
ESM::RefId exteriorWorldspace
= cellInSameWorldSpace ? cellInSameWorldSpace->getCell()->getWorldSpace() : ESM::Cell::sDefaultWorldspaceId;
const ESM::ExteriorCellLocation cellIndex
= ESM::positionToExteriorCellLocation(pos.x(), pos.y(), exteriorWorldspace);
return getExterior(cellIndex);
}
MWWorld::Ptr MWWorld::WorldModel::getPtr(const ESM::RefId& name)
{
for (const auto& [cachedId, cellStore] : mIdCache)

View File

@ -51,12 +51,6 @@ namespace MWWorld
CellStore& getCell(std::string_view name, bool forceLoad = true); // interior or named exterior
CellStore& getCell(const ESM::RefId& Id, bool forceLoad = true);
// Returns the cell that is in the same worldspace as `cellInSameWorldSpace`
// (in case of nullptr - default exterior worldspace) and contains given position.
// Interiors are single-cell worldspaces, so in case of an interior it just returns
// the same cell.
CellStore& getCellByPosition(const osg::Vec3f& pos, CellStore* cellInSameWorldSpace = nullptr);
void registerPtr(const MWWorld::Ptr& ptr);
void deregisterPtr(const MWWorld::Ptr& ptr);
ESM::RefNum getLastGeneratedRefNum() const { return mLastGeneratedRefnum; }