mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-02 06:06:41 +00:00
Merge branch 'getcell-ref' into 'master'
WorldImp functions return reference instead of ptr when ptr is never nullptr. See merge request OpenMW/openmw!2946
This commit is contained in:
commit
0a9d937cfe
19 changed files with 141 additions and 159 deletions
|
@ -157,7 +157,7 @@ namespace MWBase
|
||||||
|
|
||||||
virtual bool isCellQuasiExterior() const = 0;
|
virtual bool isCellQuasiExterior() const = 0;
|
||||||
|
|
||||||
virtual void getDoorMarkers(MWWorld::CellStore* cell, std::vector<DoorMarker>& out) = 0;
|
virtual void getDoorMarkers(MWWorld::CellStore& cell, std::vector<DoorMarker>& out) = 0;
|
||||||
///< get a list of teleport door markers for a given cell, to be displayed on the local map
|
///< get a list of teleport door markers for a given cell, to be displayed on the local map
|
||||||
|
|
||||||
virtual void setGlobalInt(MWWorld::GlobalVariableName name, int value) = 0;
|
virtual void setGlobalInt(MWWorld::GlobalVariableName name, int value) = 0;
|
||||||
|
|
|
@ -300,7 +300,7 @@ namespace MWClass
|
||||||
std::string Door::getDestination(const MWWorld::LiveCellRef<ESM::Door>& door)
|
std::string Door::getDestination(const MWWorld::LiveCellRef<ESM::Door>& door)
|
||||||
{
|
{
|
||||||
std::string_view dest = MWBase::Environment::get().getWorld()->getCellName(
|
std::string_view dest = MWBase::Environment::get().getWorld()->getCellName(
|
||||||
MWBase::Environment::get().getWorldModel()->getCell(door.mRef.getDestCell()));
|
&MWBase::Environment::get().getWorldModel()->getCell(door.mRef.getDestCell()));
|
||||||
|
|
||||||
return "#{sCell=" + std::string{ dest } + "}";
|
return "#{sCell=" + std::string{ dest } + "}";
|
||||||
}
|
}
|
||||||
|
|
|
@ -584,7 +584,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
if (!mInterior)
|
if (!mInterior)
|
||||||
requestMapRender(
|
requestMapRender(
|
||||||
MWBase::Environment::get().getWorldModel()->getExterior(entry.mCellX, entry.mCellY));
|
&MWBase::Environment::get().getWorldModel()->getExterior(entry.mCellX, entry.mCellY));
|
||||||
|
|
||||||
osg::ref_ptr<osg::Texture2D> texture = mLocalMapRender->getMapTexture(entry.mCellX, entry.mCellY);
|
osg::ref_ptr<osg::Texture2D> texture = mLocalMapRender->getMapTexture(entry.mCellX, entry.mCellY);
|
||||||
if (texture)
|
if (texture)
|
||||||
|
@ -633,7 +633,7 @@ namespace MWGui
|
||||||
for (MyGUI::Widget* widget : mExteriorDoorMarkerWidgets)
|
for (MyGUI::Widget* widget : mExteriorDoorMarkerWidgets)
|
||||||
widget->setVisible(false);
|
widget->setVisible(false);
|
||||||
|
|
||||||
MWWorld::CellStore* cell = worldModel->getInterior(mPrefix);
|
MWWorld::CellStore& cell = worldModel->getInterior(mPrefix);
|
||||||
world->getDoorMarkers(cell, doors);
|
world->getDoorMarkers(cell, doors);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -130,9 +130,9 @@ namespace MWGui
|
||||||
= MWWorld::positionToCellIndex(transport[i].mPos.pos[0], transport[i].mPos.pos[1]);
|
= MWWorld::positionToCellIndex(transport[i].mPos.pos[0], transport[i].mPos.pos[1]);
|
||||||
if (cellname.empty())
|
if (cellname.empty())
|
||||||
{
|
{
|
||||||
MWWorld::CellStore* cell
|
MWWorld::CellStore& cell
|
||||||
= MWBase::Environment::get().getWorldModel()->getExterior(cellIndex.x(), cellIndex.y());
|
= MWBase::Environment::get().getWorldModel()->getExterior(cellIndex.x(), cellIndex.y());
|
||||||
cellname = MWBase::Environment::get().getWorld()->getCellName(cell);
|
cellname = MWBase::Environment::get().getWorld()->getCellName(&cell);
|
||||||
interior = false;
|
interior = false;
|
||||||
}
|
}
|
||||||
addDestination(ESM::RefId::stringRefId(cellname), transport[i].mPos, interior);
|
addDestination(ESM::RefId::stringRefId(cellname), transport[i].mPos, interior);
|
||||||
|
|
|
@ -84,9 +84,9 @@ namespace MWLua
|
||||||
WorldView* worldView = context.mWorldView;
|
WorldView* worldView = context.mWorldView;
|
||||||
addTimeBindings(api, context, true);
|
addTimeBindings(api, context, true);
|
||||||
api["getCellByName"]
|
api["getCellByName"]
|
||||||
= [](std::string_view name) { return GCell{ MWBase::Environment::get().getWorldModel()->getCell(name) }; };
|
= [](std::string_view name) { return GCell{ &MWBase::Environment::get().getWorldModel()->getCell(name) }; };
|
||||||
api["getExteriorCell"]
|
api["getExteriorCell"]
|
||||||
= [](int x, int y) { return GCell{ MWBase::Environment::get().getWorldModel()->getExterior(x, y) }; };
|
= [](int x, int y) { return GCell{ &MWBase::Environment::get().getWorldModel()->getExterior(x, y) }; };
|
||||||
api["activeActors"] = GObjectList{ worldView->getActorsInScene() };
|
api["activeActors"] = GObjectList{ worldView->getActorsInScene() };
|
||||||
api["createObject"] = [](std::string_view recordId, sol::optional<int> count) -> GObject {
|
api["createObject"] = [](std::string_view recordId, sol::optional<int> count) -> GObject {
|
||||||
// Doesn't matter which cell to use because the new object will be in disabled state.
|
// Doesn't matter which cell to use because the new object will be in disabled state.
|
||||||
|
|
|
@ -59,9 +59,9 @@ namespace MWLua
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
cell = nullptr; // default exterior worldspace
|
cell = nullptr; // default exterior worldspace
|
||||||
else
|
else
|
||||||
cell = wm->getCell(name);
|
cell = &wm->getCell(name);
|
||||||
}
|
}
|
||||||
return wm->getCellByPosition(pos, cell);
|
return &wm->getCellByPosition(pos, cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
void teleportPlayer(MWWorld::CellStore* destCell, const osg::Vec3f& pos, const osg::Vec3f& rot)
|
void teleportPlayer(MWWorld::CellStore* destCell, const osg::Vec3f& pos, const osg::Vec3f& rot)
|
||||||
|
|
|
@ -47,9 +47,8 @@ namespace MWLua
|
||||||
const MWWorld::CellRef& cellRef = doorPtr(o).getCellRef();
|
const MWWorld::CellRef& cellRef = doorPtr(o).getCellRef();
|
||||||
if (!cellRef.getTeleport())
|
if (!cellRef.getTeleport())
|
||||||
return sol::nil;
|
return sol::nil;
|
||||||
MWWorld::CellStore* cell = MWBase::Environment::get().getWorldModel()->getCell(cellRef.getDestCell());
|
MWWorld::CellStore& cell = MWBase::Environment::get().getWorldModel()->getCell(cellRef.getDestCell());
|
||||||
assert(cell);
|
return o.getCell(lua, &cell);
|
||||||
return o.getCell(lua, cell);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
@ -84,9 +83,8 @@ namespace MWLua
|
||||||
const MWWorld::CellRef& cellRef = door4Ptr(o).getCellRef();
|
const MWWorld::CellRef& cellRef = door4Ptr(o).getCellRef();
|
||||||
if (!cellRef.getTeleport())
|
if (!cellRef.getTeleport())
|
||||||
return sol::nil;
|
return sol::nil;
|
||||||
MWWorld::CellStore* cell = MWBase::Environment::get().getWorldModel()->getCell(cellRef.getDestCell());
|
MWWorld::CellStore& cell = MWBase::Environment::get().getWorldModel()->getCell(cellRef.getDestCell());
|
||||||
assert(cell);
|
return o.getCell(lua, &cell);
|
||||||
return o.getCell(lua, cell);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
|
@ -398,11 +398,11 @@ namespace MWScript
|
||||||
MWWorld::CellStore* store = nullptr;
|
MWWorld::CellStore* store = nullptr;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
store = worldModel->getCell(cellID);
|
store = &worldModel->getCell(cellID);
|
||||||
if (store->isExterior())
|
if (store->isExterior())
|
||||||
{
|
{
|
||||||
const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y);
|
const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y);
|
||||||
store = worldModel->getExterior(cellIndex.x(), cellIndex.y());
|
store = &worldModel->getExterior(cellIndex.x(), cellIndex.y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception&)
|
catch (std::exception&)
|
||||||
|
@ -417,7 +417,7 @@ namespace MWScript
|
||||||
if (!isPlayer)
|
if (!isPlayer)
|
||||||
return;
|
return;
|
||||||
const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y);
|
const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y);
|
||||||
store = worldModel->getExterior(cellIndex.x(), cellIndex.y());
|
store = &worldModel->getExterior(cellIndex.x(), cellIndex.y());
|
||||||
}
|
}
|
||||||
if (store)
|
if (store)
|
||||||
{
|
{
|
||||||
|
@ -474,7 +474,7 @@ namespace MWScript
|
||||||
if (isPlayer)
|
if (isPlayer)
|
||||||
{
|
{
|
||||||
MWWorld::CellStore* cell
|
MWWorld::CellStore* cell
|
||||||
= MWBase::Environment::get().getWorldModel()->getExterior(cellIndex.x(), cellIndex.y());
|
= &MWBase::Environment::get().getWorldModel()->getExterior(cellIndex.x(), cellIndex.y());
|
||||||
ptr = world->moveObject(ptr, cell, osg::Vec3(x, y, z));
|
ptr = world->moveObject(ptr, cell, osg::Vec3(x, y, z));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -518,7 +518,7 @@ namespace MWScript
|
||||||
MWWorld::CellStore* store = nullptr;
|
MWWorld::CellStore* store = nullptr;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
store = MWBase::Environment::get().getWorldModel()->getCell(cellName);
|
store = &MWBase::Environment::get().getWorldModel()->getCell(cellName);
|
||||||
}
|
}
|
||||||
catch (std::exception&)
|
catch (std::exception&)
|
||||||
{
|
{
|
||||||
|
@ -568,7 +568,7 @@ namespace MWScript
|
||||||
if (player.getCell()->isExterior())
|
if (player.getCell()->isExterior())
|
||||||
{
|
{
|
||||||
const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y);
|
const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(x, y);
|
||||||
store = MWBase::Environment::get().getWorldModel()->getExterior(cellIndex.x(), cellIndex.y());
|
store = &MWBase::Environment::get().getWorldModel()->getExterior(cellIndex.x(), cellIndex.y());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
store = player.getCell();
|
store = player.getCell();
|
||||||
|
|
|
@ -563,7 +563,7 @@ void MWState::StateManager::loadGame(const Character* character, const std::file
|
||||||
{
|
{
|
||||||
// Cell no longer exists (i.e. changed game files), choose a default cell
|
// Cell no longer exists (i.e. changed game files), choose a default cell
|
||||||
Log(Debug::Warning) << "Warning: Player character's cell no longer exists, changing to the default cell";
|
Log(Debug::Warning) << "Warning: Player character's cell no longer exists, changing to the default cell";
|
||||||
MWWorld::CellStore* cell = MWBase::Environment::get().getWorldModel()->getExterior(0, 0);
|
MWWorld::CellStore& cell = MWBase::Environment::get().getWorldModel()->getExterior(0, 0);
|
||||||
float x, y;
|
float x, y;
|
||||||
MWBase::Environment::get().getWorld()->indexToPosition(0, 0, x, y, false);
|
MWBase::Environment::get().getWorld()->indexToPosition(0, 0, x, y, false);
|
||||||
ESM::Position pos;
|
ESM::Position pos;
|
||||||
|
@ -573,7 +573,7 @@ void MWState::StateManager::loadGame(const Character* character, const std::file
|
||||||
pos.rot[0] = 0;
|
pos.rot[0] = 0;
|
||||||
pos.rot[1] = 0;
|
pos.rot[1] = 0;
|
||||||
pos.rot[2] = 0;
|
pos.rot[2] = 0;
|
||||||
MWBase::Environment::get().getWorld()->changeToCell(cell->getCell()->getId(), pos, true, false);
|
MWBase::Environment::get().getWorld()->changeToCell(cell.getCell()->getId(), pos, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
MWBase::Environment::get().getWorld()->updateProjectilesCasters();
|
MWBase::Environment::get().getWorld()->updateProjectilesCasters();
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace MWWorld
|
||||||
// Find any NPCs that are following the actor and teleport them with him
|
// Find any NPCs that are following the actor and teleport them with him
|
||||||
std::set<MWWorld::Ptr> followers;
|
std::set<MWWorld::Ptr> followers;
|
||||||
|
|
||||||
bool toExterior = MWBase::Environment::get().getWorldModel()->getCell(mCellId)->isExterior();
|
bool toExterior = MWBase::Environment::get().getWorldModel()->getCell(mCellId).isExterior();
|
||||||
getFollowers(actor, followers, toExterior, true);
|
getFollowers(actor, followers, toExterior, true);
|
||||||
|
|
||||||
for (std::set<MWWorld::Ptr>::iterator it = followers.begin(); it != followers.end(); ++it)
|
for (std::set<MWWorld::Ptr>::iterator it = followers.begin(); it != followers.end(); ++it)
|
||||||
|
@ -66,7 +66,7 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
teleported = world->moveObject(actor, worldModel->getCell(mCellId), mPosition.asVec3(), true, true);
|
teleported = world->moveObject(actor, &worldModel->getCell(mCellId), mPosition.asVec3(), true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!world->isWaterWalkingCastableOnTarget(teleported) && MWMechanics::hasWaterWalking(teleported))
|
if (!world->isWaterWalkingCastableOnTarget(teleported) && MWMechanics::hasWaterWalking(teleported))
|
||||||
|
|
|
@ -259,20 +259,20 @@ namespace MWWorld
|
||||||
mPreloadCells.clear();
|
mPreloadCells.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellPreloader::preload(CellStore* cell, double timestamp)
|
void CellPreloader::preload(CellStore& cell, double timestamp)
|
||||||
{
|
{
|
||||||
if (!mWorkQueue)
|
if (!mWorkQueue)
|
||||||
{
|
{
|
||||||
Log(Debug::Error) << "Error: can't preload, no work queue set";
|
Log(Debug::Error) << "Error: can't preload, no work queue set";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cell->getState() == CellStore::State_Unloaded)
|
if (cell.getState() == CellStore::State_Unloaded)
|
||||||
{
|
{
|
||||||
Log(Debug::Error) << "Error: can't preload objects for unloaded cell";
|
Log(Debug::Error) << "Error: can't preload objects for unloaded cell";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PreloadMap::iterator found = mPreloadCells.find(cell);
|
PreloadMap::iterator found = mPreloadCells.find(&cell);
|
||||||
if (found != mPreloadCells.end())
|
if (found != mPreloadCells.end())
|
||||||
{
|
{
|
||||||
// already preloaded, nothing to do other than updating the timestamp
|
// already preloaded, nothing to do other than updating the timestamp
|
||||||
|
@ -304,11 +304,11 @@ namespace MWWorld
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<PreloadItem> item(new PreloadItem(cell, mResourceSystem->getSceneManager(), mBulletShapeManager,
|
osg::ref_ptr<PreloadItem> item(new PreloadItem(&cell, mResourceSystem->getSceneManager(), mBulletShapeManager,
|
||||||
mResourceSystem->getKeyframeManager(), mTerrain, mLandManager, mPreloadInstances));
|
mResourceSystem->getKeyframeManager(), mTerrain, mLandManager, mPreloadInstances));
|
||||||
mWorkQueue->addWorkItem(item);
|
mWorkQueue->addWorkItem(item);
|
||||||
|
|
||||||
mPreloadCells[cell] = PreloadEntry(timestamp, item);
|
mPreloadCells[&cell] = PreloadEntry(timestamp, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellPreloader::notifyLoaded(CellStore* cell)
|
void CellPreloader::notifyLoaded(CellStore* cell)
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace MWWorld
|
||||||
|
|
||||||
/// Ask a background thread to preload rendering meshes and collision shapes for objects in this cell.
|
/// Ask a background thread to preload rendering meshes and collision shapes for objects in this cell.
|
||||||
/// @note The cell itself must be in State_Loaded or State_Preloaded.
|
/// @note The cell itself must be in State_Loaded or State_Preloaded.
|
||||||
void preload(MWWorld::CellStore* cell, double timestamp);
|
void preload(MWWorld::CellStore& cell, double timestamp);
|
||||||
|
|
||||||
void notifyLoaded(MWWorld::CellStore* cell);
|
void notifyLoaded(MWWorld::CellStore* cell);
|
||||||
|
|
||||||
|
|
|
@ -367,7 +367,7 @@ namespace MWWorld
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mCellStore = MWBase::Environment::get().getWorldModel()->getCell(player.mCellId);
|
mCellStore = &MWBase::Environment::get().getWorldModel()->getCell(player.mCellId);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
@ -401,7 +401,7 @@ namespace MWWorld
|
||||||
if (player.mHasMark)
|
if (player.mHasMark)
|
||||||
{
|
{
|
||||||
mMarkedPosition = player.mMarkedPosition;
|
mMarkedPosition = player.mMarkedPosition;
|
||||||
mMarkedCell = MWBase::Environment::get().getWorldModel()->getCell(player.mMarkedCell);
|
mMarkedCell = &MWBase::Environment::get().getWorldModel()->getCell(player.mMarkedCell);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -377,19 +377,19 @@ namespace MWWorld
|
||||||
mRendering.notifyWorldSpaceChanged();
|
mRendering.notifyWorldSpaceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::loadCell(CellStore* cell, Loading::Listener* loadingListener, bool respawn, const osg::Vec3f& position,
|
void Scene::loadCell(CellStore& cell, Loading::Listener* loadingListener, bool respawn, const osg::Vec3f& position,
|
||||||
const DetourNavigator::UpdateGuard* navigatorUpdateGuard)
|
const DetourNavigator::UpdateGuard* navigatorUpdateGuard)
|
||||||
{
|
{
|
||||||
using DetourNavigator::HeightfieldShape;
|
using DetourNavigator::HeightfieldShape;
|
||||||
|
|
||||||
assert(mActiveCells.find(cell) == mActiveCells.end());
|
assert(mActiveCells.find(&cell) == mActiveCells.end());
|
||||||
mActiveCells.insert(cell);
|
mActiveCells.insert(&cell);
|
||||||
|
|
||||||
Log(Debug::Info) << "Loading cell " << cell->getCell()->getDescription();
|
Log(Debug::Info) << "Loading cell " << cell.getCell()->getDescription();
|
||||||
|
|
||||||
const int cellX = cell->getCell()->getGridX();
|
const int cellX = cell.getCell()->getGridX();
|
||||||
const int cellY = cell->getCell()->getGridY();
|
const int cellY = cell.getCell()->getGridY();
|
||||||
const MWWorld::Cell& cellVariant = *cell->getCell();
|
const MWWorld::Cell& cellVariant = *cell.getCell();
|
||||||
|
|
||||||
if (cellVariant.isExterior())
|
if (cellVariant.isExterior())
|
||||||
{
|
{
|
||||||
|
@ -440,22 +440,22 @@ namespace MWWorld
|
||||||
},
|
},
|
||||||
[&](const ESM4::Cell& cell) {},
|
[&](const ESM4::Cell& cell) {},
|
||||||
},
|
},
|
||||||
*cell->getCell());
|
*cell.getCell());
|
||||||
|
|
||||||
// register local scripts
|
// register local scripts
|
||||||
// do this before insertCell, to make sure we don't add scripts from levelled creature spawning twice
|
// do this before insertCell, to make sure we don't add scripts from levelled creature spawning twice
|
||||||
mWorld.getLocalScripts().addCell(cell);
|
mWorld.getLocalScripts().addCell(&cell);
|
||||||
|
|
||||||
if (respawn)
|
if (respawn)
|
||||||
cell->respawn();
|
cell.respawn();
|
||||||
|
|
||||||
insertCell(*cell, loadingListener, navigatorUpdateGuard);
|
insertCell(cell, loadingListener, navigatorUpdateGuard);
|
||||||
|
|
||||||
mRendering.addCell(cell);
|
mRendering.addCell(&cell);
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->addCell(cell);
|
MWBase::Environment::get().getWindowManager()->addCell(&cell);
|
||||||
bool waterEnabled = cellVariant.hasWater() || cell->isExterior();
|
bool waterEnabled = cellVariant.hasWater() || cell.isExterior();
|
||||||
float waterLevel = cell->getWaterLevel();
|
float waterLevel = cell.getWaterLevel();
|
||||||
mRendering.setWaterEnabled(waterEnabled);
|
mRendering.setWaterEnabled(waterEnabled);
|
||||||
if (waterEnabled)
|
if (waterEnabled)
|
||||||
{
|
{
|
||||||
|
@ -477,10 +477,10 @@ namespace MWWorld
|
||||||
else
|
else
|
||||||
mPhysics->disableWater();
|
mPhysics->disableWater();
|
||||||
|
|
||||||
if (!cell->isExterior() && !cellVariant.isQuasiExterior())
|
if (!cell.isExterior() && !cellVariant.isQuasiExterior())
|
||||||
mRendering.configureAmbient(cellVariant);
|
mRendering.configureAmbient(cellVariant);
|
||||||
|
|
||||||
mPreloader->notifyLoaded(cell);
|
mPreloader->notifyLoaded(&cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::clear()
|
void Scene::clear()
|
||||||
|
@ -554,7 +554,7 @@ namespace MWWorld
|
||||||
|
|
||||||
mNavigator.setWorldspace(Misc::StringUtils::lowerCase(mWorld.getWorldModel()
|
mNavigator.setWorldspace(Misc::StringUtils::lowerCase(mWorld.getWorldModel()
|
||||||
.getExterior(playerCellX, playerCellY)
|
.getExterior(playerCellX, playerCellY)
|
||||||
->getCell()
|
.getCell()
|
||||||
->getWorldSpace()
|
->getWorldSpace()
|
||||||
.serializeText()),
|
.serializeText()),
|
||||||
navigatorUpdateGuard.get());
|
navigatorUpdateGuard.get());
|
||||||
|
@ -580,7 +580,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
if (!isCellInCollection(x, y, collection))
|
if (!isCellInCollection(x, y, collection))
|
||||||
{
|
{
|
||||||
refsToLoad += mWorld.getWorldModel().getExterior(x, y)->count();
|
refsToLoad += mWorld.getWorldModel().getExterior(x, y).count();
|
||||||
cellsPositionsToLoad.emplace_back(x, y);
|
cellsPositionsToLoad.emplace_back(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -614,7 +614,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
if (!isCellInCollection(x, y, mActiveCells))
|
if (!isCellInCollection(x, y, mActiveCells))
|
||||||
{
|
{
|
||||||
CellStore* cell = mWorld.getWorldModel().getExterior(x, y);
|
CellStore& cell = mWorld.getWorldModel().getExterior(x, y);
|
||||||
loadCell(cell, loadingListener, changeEvent, pos, navigatorUpdateGuard.get());
|
loadCell(cell, loadingListener, changeEvent, pos, navigatorUpdateGuard.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -623,8 +623,8 @@ namespace MWWorld
|
||||||
|
|
||||||
navigatorUpdateGuard.reset();
|
navigatorUpdateGuard.reset();
|
||||||
|
|
||||||
CellStore* current = mWorld.getWorldModel().getExterior(playerCellX, playerCellY);
|
CellStore& current = mWorld.getWorldModel().getExterior(playerCellX, playerCellY);
|
||||||
MWBase::Environment::get().getWindowManager()->changeCell(current);
|
MWBase::Environment::get().getWindowManager()->changeCell(¤t);
|
||||||
|
|
||||||
if (changeEvent)
|
if (changeEvent)
|
||||||
mCellChanged = true;
|
mCellChanged = true;
|
||||||
|
@ -676,8 +676,8 @@ namespace MWWorld
|
||||||
loadingListener->setLabel(
|
loadingListener->setLabel(
|
||||||
"Testing exterior cells (" + std::to_string(i) + "/" + std::to_string(cells.getExtSize()) + ")...");
|
"Testing exterior cells (" + std::to_string(i) + "/" + std::to_string(cells.getExtSize()) + ")...");
|
||||||
|
|
||||||
CellStore* cell = mWorld.getWorldModel().getExterior(it->mData.mX, it->mData.mY);
|
CellStore& cell = mWorld.getWorldModel().getExterior(it->mData.mX, it->mData.mY);
|
||||||
mNavigator.setWorldspace(Misc::StringUtils::lowerCase(cell->getCell()->getWorldSpace().serializeText()),
|
mNavigator.setWorldspace(Misc::StringUtils::lowerCase(cell.getCell()->getWorldSpace().serializeText()),
|
||||||
navigatorUpdateGuard.get());
|
navigatorUpdateGuard.get());
|
||||||
const osg::Vec3f position
|
const osg::Vec3f position
|
||||||
= osg::Vec3f(it->mData.mX + 0.5f, it->mData.mY + 0.5f, 0) * Constants::CellSizeInUnits;
|
= osg::Vec3f(it->mData.mX + 0.5f, it->mData.mY + 0.5f, 0) * Constants::CellSizeInUnits;
|
||||||
|
@ -734,8 +734,8 @@ namespace MWWorld
|
||||||
loadingListener->setLabel(
|
loadingListener->setLabel(
|
||||||
"Testing interior cells (" + std::to_string(i) + "/" + std::to_string(cells.getIntSize()) + ")...");
|
"Testing interior cells (" + std::to_string(i) + "/" + std::to_string(cells.getIntSize()) + ")...");
|
||||||
|
|
||||||
CellStore* cell = mWorld.getWorldModel().getInterior(it->mName);
|
CellStore& cell = mWorld.getWorldModel().getInterior(it->mName);
|
||||||
mNavigator.setWorldspace(Misc::StringUtils::lowerCase(cell->getCell()->getWorldSpace().serializeText()),
|
mNavigator.setWorldspace(Misc::StringUtils::lowerCase(cell.getCell()->getWorldSpace().serializeText()),
|
||||||
navigatorUpdateGuard.get());
|
navigatorUpdateGuard.get());
|
||||||
ESM::Position position;
|
ESM::Position position;
|
||||||
mWorld.findInteriorPosition(it->mName, position);
|
mWorld.findInteriorPosition(it->mName, position);
|
||||||
|
@ -772,21 +772,21 @@ namespace MWWorld
|
||||||
mRendering.getResourceSystem()->setExpiryDelay(Settings::Manager::getFloat("cache expiry delay", "Cells"));
|
mRendering.getResourceSystem()->setExpiryDelay(Settings::Manager::getFloat("cache expiry delay", "Cells"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::changePlayerCell(CellStore* cell, const ESM::Position& pos, bool adjustPlayerPos)
|
void Scene::changePlayerCell(CellStore& cell, const ESM::Position& pos, bool adjustPlayerPos)
|
||||||
{
|
{
|
||||||
mCurrentCell = cell;
|
mCurrentCell = &cell;
|
||||||
|
|
||||||
mRendering.enableTerrain(cell->isExterior());
|
mRendering.enableTerrain(cell.isExterior());
|
||||||
|
|
||||||
MWWorld::Ptr old = mWorld.getPlayerPtr();
|
MWWorld::Ptr old = mWorld.getPlayerPtr();
|
||||||
mWorld.getPlayer().setCell(cell);
|
mWorld.getPlayer().setCell(&cell);
|
||||||
|
|
||||||
MWWorld::Ptr player = mWorld.getPlayerPtr();
|
MWWorld::Ptr player = mWorld.getPlayerPtr();
|
||||||
mRendering.updatePlayerPtr(player);
|
mRendering.updatePlayerPtr(player);
|
||||||
|
|
||||||
// The player is loaded before the scene and by default it is grounded, with the scene fully loaded,
|
// The player is loaded before the scene and by default it is grounded, with the scene fully loaded,
|
||||||
// we validate and correct this. Only run once, during initial cell load.
|
// we validate and correct this. Only run once, during initial cell load.
|
||||||
if (old.mCell == cell)
|
if (old.mCell == &cell)
|
||||||
mPhysics->traceDown(player, player.getRefData().getPosition().asVec3(), 10.f);
|
mPhysics->traceDown(player, player.getRefData().getPosition().asVec3(), 10.f);
|
||||||
|
|
||||||
if (adjustPlayerPos)
|
if (adjustPlayerPos)
|
||||||
|
@ -857,7 +857,7 @@ namespace MWWorld
|
||||||
void Scene::changeToInteriorCell(
|
void Scene::changeToInteriorCell(
|
||||||
std::string_view cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent)
|
std::string_view cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent)
|
||||||
{
|
{
|
||||||
CellStore* cell = mWorld.getWorldModel().getInterior(cellName);
|
CellStore& cell = mWorld.getWorldModel().getInterior(cellName);
|
||||||
bool useFading = (mCurrentCell != nullptr);
|
bool useFading = (mCurrentCell != nullptr);
|
||||||
if (useFading)
|
if (useFading)
|
||||||
MWBase::Environment::get().getWindowManager()->fadeScreenOut(0.5);
|
MWBase::Environment::get().getWindowManager()->fadeScreenOut(0.5);
|
||||||
|
@ -866,7 +866,7 @@ namespace MWWorld
|
||||||
loadingListener->setLabel("#{OMWEngine:LoadingInterior}");
|
loadingListener->setLabel("#{OMWEngine:LoadingInterior}");
|
||||||
Loading::ScopedLoad load(loadingListener);
|
Loading::ScopedLoad load(loadingListener);
|
||||||
|
|
||||||
if (mCurrentCell != nullptr && *mCurrentCell == *cell)
|
if (mCurrentCell != nullptr && *mCurrentCell == cell)
|
||||||
{
|
{
|
||||||
mWorld.moveObject(mWorld.getPlayerPtr(), position.asVec3());
|
mWorld.moveObject(mWorld.getPlayerPtr(), position.asVec3());
|
||||||
mWorld.rotateObject(mWorld.getPlayerPtr(), position.asRotationVec3());
|
mWorld.rotateObject(mWorld.getPlayerPtr(), position.asRotationVec3());
|
||||||
|
@ -889,10 +889,10 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
assert(mActiveCells.empty());
|
assert(mActiveCells.empty());
|
||||||
|
|
||||||
loadingListener->setProgressRange(cell->count());
|
loadingListener->setProgressRange(cell.count());
|
||||||
|
|
||||||
mNavigator.setWorldspace(
|
mNavigator.setWorldspace(
|
||||||
Misc::StringUtils::lowerCase(cell->getCell()->getWorldSpace().serializeText()), navigatorUpdateGuard.get());
|
Misc::StringUtils::lowerCase(cell.getCell()->getWorldSpace().serializeText()), navigatorUpdateGuard.get());
|
||||||
mNavigator.updateBounds(position.asVec3(), navigatorUpdateGuard.get());
|
mNavigator.updateBounds(position.asVec3(), navigatorUpdateGuard.get());
|
||||||
|
|
||||||
// Load cell.
|
// Load cell.
|
||||||
|
@ -919,7 +919,7 @@ namespace MWWorld
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->changeCell(mCurrentCell);
|
MWBase::Environment::get().getWindowManager()->changeCell(mCurrentCell);
|
||||||
|
|
||||||
MWBase::Environment::get().getWorld()->getPostProcessor()->setExteriorFlag(cell->getCell()->isQuasiExterior());
|
MWBase::Environment::get().getWorld()->getPostProcessor()->setExteriorFlag(cell.getCell()->isQuasiExterior());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::changeToExteriorCell(
|
void Scene::changeToExteriorCell(
|
||||||
|
@ -928,9 +928,9 @@ namespace MWWorld
|
||||||
|
|
||||||
if (changeEvent)
|
if (changeEvent)
|
||||||
MWBase::Environment::get().getWindowManager()->fadeScreenOut(0.5);
|
MWBase::Environment::get().getWindowManager()->fadeScreenOut(0.5);
|
||||||
CellStore* current = mWorld.getWorldModel().getCell(extCellId);
|
CellStore& current = mWorld.getWorldModel().getCell(extCellId);
|
||||||
|
|
||||||
const osg::Vec2i cellIndex(current->getCell()->getGridX(), current->getCell()->getGridY());
|
const osg::Vec2i cellIndex(current.getCell()->getGridX(), current.getCell()->getGridY());
|
||||||
|
|
||||||
changeCellGrid(position.asVec3(), cellIndex.x(), cellIndex.y(), changeEvent);
|
changeCellGrid(position.asVec3(), cellIndex.x(), cellIndex.y(), changeEvent);
|
||||||
|
|
||||||
|
@ -1182,12 +1182,12 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::preloadCell(CellStore* cell, bool preloadSurrounding)
|
void Scene::preloadCell(CellStore& cell, bool preloadSurrounding)
|
||||||
{
|
{
|
||||||
if (preloadSurrounding && cell->isExterior())
|
if (preloadSurrounding && cell.isExterior())
|
||||||
{
|
{
|
||||||
int x = cell->getCell()->getGridX();
|
int x = cell.getCell()->getGridX();
|
||||||
int y = cell->getCell()->getGridY();
|
int y = cell.getCell()->getGridY();
|
||||||
unsigned int numpreloaded = 0;
|
unsigned int numpreloaded = 0;
|
||||||
for (int dx = -mHalfGridSize; dx <= mHalfGridSize; ++dx)
|
for (int dx = -mHalfGridSize; dx <= mHalfGridSize; ++dx)
|
||||||
{
|
{
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace MWWorld
|
||||||
osg::Vec2i getNewGridCenter(const osg::Vec3f& pos, const osg::Vec2i* currentGridCenter = nullptr) const;
|
osg::Vec2i getNewGridCenter(const osg::Vec3f& pos, const osg::Vec2i* currentGridCenter = nullptr) const;
|
||||||
|
|
||||||
void unloadCell(CellStore* cell, const DetourNavigator::UpdateGuard* navigatorUpdateGuard);
|
void unloadCell(CellStore* cell, const DetourNavigator::UpdateGuard* navigatorUpdateGuard);
|
||||||
void loadCell(CellStore* cell, Loading::Listener* loadingListener, bool respawn, const osg::Vec3f& position,
|
void loadCell(CellStore& cell, Loading::Listener* loadingListener, bool respawn, const osg::Vec3f& position,
|
||||||
const DetourNavigator::UpdateGuard* navigatorUpdateGuard);
|
const DetourNavigator::UpdateGuard* navigatorUpdateGuard);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -143,13 +143,13 @@ namespace MWWorld
|
||||||
|
|
||||||
~Scene();
|
~Scene();
|
||||||
|
|
||||||
void preloadCell(MWWorld::CellStore* cell, bool preloadSurrounding = false);
|
void preloadCell(MWWorld::CellStore& cell, bool preloadSurrounding = false);
|
||||||
void preloadTerrain(const osg::Vec3f& pos, bool sync = false);
|
void preloadTerrain(const osg::Vec3f& pos, bool sync = false);
|
||||||
void reloadTerrain();
|
void reloadTerrain();
|
||||||
|
|
||||||
void playerMoved(const osg::Vec3f& pos);
|
void playerMoved(const osg::Vec3f& pos);
|
||||||
|
|
||||||
void changePlayerCell(CellStore* newCell, const ESM::Position& position, bool adjustPlayerPos);
|
void changePlayerCell(CellStore& newCell, const ESM::Position& position, bool adjustPlayerPos);
|
||||||
|
|
||||||
CellStore* getCurrentCell();
|
CellStore* getCurrentCell();
|
||||||
|
|
||||||
|
|
|
@ -507,7 +507,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
if (getPlayerPtr().getCell()->isExterior())
|
if (getPlayerPtr().getCell()->isExterior())
|
||||||
mWorldScene->preloadTerrain(getPlayerPtr().getRefData().getPosition().asVec3());
|
mWorldScene->preloadTerrain(getPlayerPtr().getRefData().getPosition().asVec3());
|
||||||
mWorldScene->preloadCell(getPlayerPtr().getCell(), true);
|
mWorldScene->preloadCell(*getPlayerPtr().getCell(), true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -994,7 +994,7 @@ namespace MWWorld
|
||||||
void World::changeToCell(
|
void World::changeToCell(
|
||||||
const ESM::RefId& cellId, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent)
|
const ESM::RefId& cellId, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent)
|
||||||
{
|
{
|
||||||
const MWWorld::Cell* destinationCell = getWorldModel().getCell(cellId)->getCell();
|
const MWWorld::Cell* destinationCell = getWorldModel().getCell(cellId).getCell();
|
||||||
bool exteriorCell = destinationCell->isExterior();
|
bool exteriorCell = destinationCell->isExterior();
|
||||||
|
|
||||||
mPhysics->clearQueuedMovement();
|
mPhysics->clearQueuedMovement();
|
||||||
|
@ -1183,7 +1183,7 @@ namespace MWWorld
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mWorldScene->isCellActive(*newCell))
|
if (mWorldScene->isCellActive(*newCell))
|
||||||
mWorldScene->changePlayerCell(newCell, pos, false);
|
mWorldScene->changePlayerCell(*newCell, pos, false);
|
||||||
else
|
else
|
||||||
mWorldScene->changeToExteriorCell(newCell->getCell()->getId(), pos, false);
|
mWorldScene->changeToExteriorCell(newCell->getCell()->getId(), pos, false);
|
||||||
}
|
}
|
||||||
|
@ -1271,12 +1271,12 @@ namespace MWWorld
|
||||||
const osg::Vec2i index = positionToCellIndex(position.x(), position.y());
|
const osg::Vec2i index = positionToCellIndex(position.x(), position.y());
|
||||||
|
|
||||||
CellStore* cell = ptr.getCell();
|
CellStore* cell = ptr.getCell();
|
||||||
CellStore* newCell = mWorldModel.getExterior(index.x(), index.y());
|
CellStore& newCell = mWorldModel.getExterior(index.x(), index.y());
|
||||||
bool isCellActive = getPlayerPtr().isInCell() && getPlayerPtr().getCell()->isExterior()
|
bool isCellActive
|
||||||
&& mWorldScene->isCellActive(*newCell);
|
= getPlayerPtr().isInCell() && getPlayerPtr().getCell()->isExterior() && mWorldScene->isCellActive(newCell);
|
||||||
|
|
||||||
if (cell->isExterior() || (moveToActive && isCellActive && ptr.getClass().isActor()))
|
if (cell->isExterior() || (moveToActive && isCellActive && ptr.getClass().isActor()))
|
||||||
cell = newCell;
|
cell = &newCell;
|
||||||
|
|
||||||
return moveObject(ptr, cell, position, movePhysics);
|
return moveObject(ptr, cell, position, movePhysics);
|
||||||
}
|
}
|
||||||
|
@ -2086,10 +2086,10 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void World::getDoorMarkers(CellStore* cell, std::vector<World::DoorMarker>& out)
|
void World::getDoorMarkers(CellStore& cell, std::vector<World::DoorMarker>& out)
|
||||||
{
|
{
|
||||||
GetDoorMarkerVisitor visitor{ out };
|
GetDoorMarkerVisitor visitor{ out };
|
||||||
cell->forEachType<ESM::Door>(visitor);
|
cell.forEachType<ESM::Door>(visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::setWaterHeight(const float height)
|
void World::setWaterHeight(const float height)
|
||||||
|
@ -2177,7 +2177,7 @@ namespace MWWorld
|
||||||
if (cell->isExterior())
|
if (cell->isExterior())
|
||||||
{
|
{
|
||||||
const osg::Vec2i index = positionToCellIndex(pos.pos[0], pos.pos[1]);
|
const osg::Vec2i index = positionToCellIndex(pos.pos[0], pos.pos[1]);
|
||||||
cell = mWorldModel.getExterior(index.x(), index.y());
|
cell = &mWorldModel.getExterior(index.x(), index.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::Ptr dropped = object.getClass().copyToCell(object, *cell, pos, count);
|
MWWorld::Ptr dropped = object.getClass().copyToCell(object, *cell, pos, count);
|
||||||
|
@ -2767,14 +2767,11 @@ namespace MWWorld
|
||||||
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
|
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
|
||||||
pos.pos[0] = pos.pos[1] = pos.pos[2] = 0;
|
pos.pos[0] = pos.pos[1] = pos.pos[2] = 0;
|
||||||
|
|
||||||
MWWorld::CellStore* cellStore = mWorldModel.getInterior(name);
|
MWWorld::CellStore& cellStore = mWorldModel.getInterior(name);
|
||||||
|
|
||||||
if (!cellStore)
|
ESM::RefId cellId = cellStore.getCell()->getId();
|
||||||
return ESM::RefId::sEmpty;
|
|
||||||
|
|
||||||
ESM::RefId cellId = cellStore->getCell()->getId();
|
|
||||||
std::vector<const MWWorld::CellRef*> sortedDoors;
|
std::vector<const MWWorld::CellRef*> sortedDoors;
|
||||||
for (const MWWorld::LiveCellRef<ESM::Door>& door : cellStore->getReadOnlyDoors().mList)
|
for (const MWWorld::LiveCellRef<ESM::Door>& door : cellStore.getReadOnlyDoors().mList)
|
||||||
{
|
{
|
||||||
if (!door.mRef.getTeleport())
|
if (!door.mRef.getTeleport())
|
||||||
continue;
|
continue;
|
||||||
|
@ -2792,27 +2789,23 @@ namespace MWWorld
|
||||||
|
|
||||||
for (const MWWorld::CellRef* door : sortedDoors)
|
for (const MWWorld::CellRef* door : sortedDoors)
|
||||||
{
|
{
|
||||||
MWWorld::CellStore* source = nullptr;
|
MWWorld::CellStore& source = mWorldModel.getCell(door->getDestCell());
|
||||||
source = mWorldModel.getCell(door->getDestCell());
|
|
||||||
|
|
||||||
if (source)
|
// Find door leading to our current teleport door
|
||||||
|
// and use its destination to position inside cell.
|
||||||
|
for (const MWWorld::LiveCellRef<ESM::Door>& destDoor : source.getReadOnlyDoors().mList)
|
||||||
{
|
{
|
||||||
// Find door leading to our current teleport door
|
if (name == destDoor.mRef.getDestCell())
|
||||||
// and use its destination to position inside cell.
|
|
||||||
for (const MWWorld::LiveCellRef<ESM::Door>& destDoor : source->getReadOnlyDoors().mList)
|
|
||||||
{
|
{
|
||||||
if (name == destDoor.mRef.getDestCell())
|
/// \note Using _any_ door pointed to the interior,
|
||||||
{
|
/// not the one pointed to current door.
|
||||||
/// \note Using _any_ door pointed to the interior,
|
pos = destDoor.mRef.getDoorDest();
|
||||||
/// not the one pointed to current door.
|
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
|
||||||
pos = destDoor.mRef.getDoorDest();
|
return cellId;
|
||||||
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
|
|
||||||
return cellId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const MWWorld::LiveCellRef<ESM4::Static>& stat4 : cellStore->getReadOnlyEsm4Statics().mList)
|
for (const MWWorld::LiveCellRef<ESM4::Static>& stat4 : cellStore.getReadOnlyEsm4Statics().mList)
|
||||||
{
|
{
|
||||||
if (Misc::StringUtils::lowerCase(stat4.mBase->mEditorId) == "cocmarkerheading")
|
if (Misc::StringUtils::lowerCase(stat4.mBase->mEditorId) == "cocmarkerheading")
|
||||||
{
|
{
|
||||||
|
@ -2823,7 +2816,7 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Fall back to the first static location.
|
// Fall back to the first static location.
|
||||||
const MWWorld::CellRefList<ESM4::Static>::List& statics4 = cellStore->getReadOnlyEsm4Statics().mList;
|
const MWWorld::CellRefList<ESM4::Static>::List& statics4 = cellStore.getReadOnlyEsm4Statics().mList;
|
||||||
if (!statics4.empty())
|
if (!statics4.empty())
|
||||||
{
|
{
|
||||||
pos = statics4.begin()->mRef.getPosition();
|
pos = statics4.begin()->mRef.getPosition();
|
||||||
|
@ -2831,7 +2824,7 @@ namespace MWWorld
|
||||||
return cellId;
|
return cellId;
|
||||||
}
|
}
|
||||||
// Fall back to the first static location.
|
// Fall back to the first static location.
|
||||||
const MWWorld::CellRefList<ESM::Static>::List& statics = cellStore->getReadOnlyStatics().mList;
|
const MWWorld::CellRefList<ESM::Static>::List& statics = cellStore.getReadOnlyStatics().mList;
|
||||||
if (!statics.empty())
|
if (!statics.empty())
|
||||||
{
|
{
|
||||||
pos = statics.begin()->mRef.getPosition();
|
pos = statics.begin()->mRef.getPosition();
|
||||||
|
@ -2849,7 +2842,7 @@ namespace MWWorld
|
||||||
const MWWorld::Cell* ext = nullptr;
|
const MWWorld::Cell* ext = nullptr;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ext = mWorldModel.getCell(nameId)->getCell();
|
ext = mWorldModel.getCell(nameId).getCell();
|
||||||
if (!ext->isExterior())
|
if (!ext->isExterior())
|
||||||
return ESM::RefId();
|
return ESM::RefId();
|
||||||
}
|
}
|
||||||
|
@ -2868,7 +2861,7 @@ namespace MWWorld
|
||||||
if (xResult.ec == std::errc::result_out_of_range || yResult.ec == std::errc::result_out_of_range)
|
if (xResult.ec == std::errc::result_out_of_range || yResult.ec == std::errc::result_out_of_range)
|
||||||
throw std::runtime_error("Cell coordinates out of range.");
|
throw std::runtime_error("Cell coordinates out of range.");
|
||||||
else if (xResult.ec == std::errc{} && yResult.ec == std::errc{})
|
else if (xResult.ec == std::errc{} && yResult.ec == std::errc{})
|
||||||
ext = mWorldModel.getExterior(x, y)->getCell();
|
ext = mWorldModel.getExterior(x, y).getCell();
|
||||||
// ignore std::errc::invalid_argument, as this means that name probably refers to a interior cell
|
// ignore std::errc::invalid_argument, as this means that name probably refers to a interior cell
|
||||||
// instead of comma separated coordinates
|
// instead of comma separated coordinates
|
||||||
}
|
}
|
||||||
|
@ -3288,12 +3281,10 @@ namespace MWWorld
|
||||||
nextCells.clear();
|
nextCells.clear();
|
||||||
for (const auto& currentCell : currentCells)
|
for (const auto& currentCell : currentCells)
|
||||||
{
|
{
|
||||||
MWWorld::CellStore* next = mWorldModel.getCell(currentCell);
|
MWWorld::CellStore& next = mWorldModel.getCell(currentCell);
|
||||||
if (!next)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Check if any door in the cell leads to an exterior directly
|
// Check if any door in the cell leads to an exterior directly
|
||||||
for (const MWWorld::LiveCellRef<ESM::Door>& ref : next->getReadOnlyDoors().mList)
|
for (const MWWorld::LiveCellRef<ESM::Door>& ref : next.getReadOnlyDoors().mList)
|
||||||
{
|
{
|
||||||
if (!ref.mRef.getTeleport())
|
if (!ref.mRef.getTeleport())
|
||||||
continue;
|
continue;
|
||||||
|
@ -3342,19 +3333,17 @@ namespace MWWorld
|
||||||
std::swap(currentCells, nextCells);
|
std::swap(currentCells, nextCells);
|
||||||
for (const auto& cell : currentCells)
|
for (const auto& cell : currentCells)
|
||||||
{
|
{
|
||||||
MWWorld::CellStore* next = mWorldModel.getCell(cell);
|
MWWorld::CellStore& next = mWorldModel.getCell(cell);
|
||||||
checkedCells.insert(cell);
|
checkedCells.insert(cell);
|
||||||
if (!next)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
closestMarker = next->searchConst(id);
|
closestMarker = next.searchConst(id);
|
||||||
if (!closestMarker.isEmpty())
|
if (!closestMarker.isEmpty())
|
||||||
{
|
{
|
||||||
return closestMarker;
|
return closestMarker;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if any door in the cell leads to an exterior directly
|
// Check if any door in the cell leads to an exterior directly
|
||||||
for (const MWWorld::LiveCellRef<ESM::Door>& ref : next->getReadOnlyDoors().mList)
|
for (const MWWorld::LiveCellRef<ESM::Door>& ref : next.getReadOnlyDoors().mList)
|
||||||
{
|
{
|
||||||
if (!ref.mRef.getTeleport())
|
if (!ref.mRef.getTeleport())
|
||||||
continue;
|
continue;
|
||||||
|
@ -3638,14 +3627,9 @@ namespace MWWorld
|
||||||
Log(Debug::Warning) << "Failed to confiscate items: prison marker not linked to prison interior";
|
Log(Debug::Warning) << "Failed to confiscate items: prison marker not linked to prison interior";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MWWorld::CellStore* prison = mWorldModel.getCell(prisonName);
|
MWWorld::CellStore& prison = mWorldModel.getCell(prisonName);
|
||||||
if (!prison)
|
|
||||||
{
|
|
||||||
Log(Debug::Warning) << "Failed to confiscate items: failed to load cell " << prisonName;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MWWorld::Ptr closestChest = prison->search(ESM::RefId::stringRefId("stolen_goods"));
|
MWWorld::Ptr closestChest = prison.search(ESM::RefId::stringRefId("stolen_goods"));
|
||||||
if (!closestChest.isEmpty()) // Found a close chest
|
if (!closestChest.isEmpty()) // Found a close chest
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getMechanicsManager()->confiscateStolenItems(ptr, closestChest);
|
MWBase::Environment::get().getMechanicsManager()->confiscateStolenItems(ptr, closestChest);
|
||||||
|
|
|
@ -245,7 +245,7 @@ namespace MWWorld
|
||||||
|
|
||||||
bool isCellQuasiExterior() const override;
|
bool isCellQuasiExterior() const override;
|
||||||
|
|
||||||
void getDoorMarkers(MWWorld::CellStore* cell, std::vector<DoorMarker>& out) override;
|
void getDoorMarkers(MWWorld::CellStore& cell, std::vector<DoorMarker>& out) override;
|
||||||
///< get a list of teleport door markers for a given cell, to be displayed on the local map
|
///< get a list of teleport door markers for a given cell, to be displayed on the local map
|
||||||
|
|
||||||
void setGlobalInt(GlobalVariableName name, int value) override;
|
void setGlobalInt(GlobalVariableName name, int value) override;
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::CellStore* MWWorld::WorldModel::getCellStore(const ESM::Cell* cell)
|
MWWorld::CellStore& MWWorld::WorldModel::getCellStore(const ESM::Cell* cell)
|
||||||
{
|
{
|
||||||
CellStore* cellStore = &mCells.emplace(cell->mId, CellStore(MWWorld::Cell(*cell), mStore, mReaders)).first->second;
|
CellStore* cellStore = &mCells.emplace(cell->mId, CellStore(MWWorld::Cell(*cell), mStore, mReaders)).first->second;
|
||||||
if (cell->mData.mFlags & ESM::Cell::Interior)
|
if (cell->mData.mFlags & ESM::Cell::Interior)
|
||||||
|
@ -72,7 +72,7 @@ MWWorld::CellStore* MWWorld::WorldModel::getCellStore(const ESM::Cell* cell)
|
||||||
if (result == mInteriors.end())
|
if (result == mInteriors.end())
|
||||||
result = mInteriors.emplace(cell->mName, cellStore).first;
|
result = mInteriors.emplace(cell->mName, cellStore).first;
|
||||||
|
|
||||||
return result->second;
|
return *result->second;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,7 @@ MWWorld::CellStore* MWWorld::WorldModel::getCellStore(const ESM::Cell* cell)
|
||||||
if (result == mExteriors.end())
|
if (result == mExteriors.end())
|
||||||
result = mExteriors.emplace(std::make_pair(cell->getGridX(), cell->getGridY()), cellStore).first;
|
result = mExteriors.emplace(std::make_pair(cell->getGridX(), cell->getGridY()), cellStore).first;
|
||||||
|
|
||||||
return result->second;
|
return *result->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ MWWorld::WorldModel::WorldModel(const MWWorld::ESMStore& store, ESM::ReadersCach
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::CellStore* MWWorld::WorldModel::getExterior(int x, int y)
|
MWWorld::CellStore& MWWorld::WorldModel::getExterior(int x, int y)
|
||||||
{
|
{
|
||||||
std::map<std::pair<int, int>, CellStore*>::iterator result = mExteriors.find(std::make_pair(x, y));
|
std::map<std::pair<int, int>, CellStore*>::iterator result = mExteriors.find(std::make_pair(x, y));
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ MWWorld::CellStore* MWWorld::WorldModel::getExterior(int x, int y)
|
||||||
result->second->load();
|
result->second->load();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result->second;
|
return *result->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::CellStore* MWWorld::WorldModel::getInteriorOrNull(std::string_view name)
|
MWWorld::CellStore* MWWorld::WorldModel::getInteriorOrNull(std::string_view name)
|
||||||
|
@ -217,19 +217,19 @@ MWWorld::CellStore* MWWorld::WorldModel::getInteriorOrNull(std::string_view name
|
||||||
return result->second;
|
return result->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::CellStore* MWWorld::WorldModel::getInterior(std::string_view name)
|
MWWorld::CellStore& MWWorld::WorldModel::getInterior(std::string_view name)
|
||||||
{
|
{
|
||||||
CellStore* res = getInteriorOrNull(name);
|
CellStore* res = getInteriorOrNull(name);
|
||||||
if (res == nullptr)
|
if (res == nullptr)
|
||||||
throw std::runtime_error("Interior not found: '" + std::string(name) + "'");
|
throw std::runtime_error("Interior not found: '" + std::string(name) + "'");
|
||||||
return res;
|
return *res;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::CellStore* MWWorld::WorldModel::getCell(const ESM::RefId& id)
|
MWWorld::CellStore& MWWorld::WorldModel::getCell(const ESM::RefId& id)
|
||||||
{
|
{
|
||||||
auto result = mCells.find(id);
|
auto result = mCells.find(id);
|
||||||
if (result != mCells.end())
|
if (result != mCells.end())
|
||||||
return &result->second;
|
return result->second;
|
||||||
|
|
||||||
if (const auto* exteriorId = id.getIf<ESM::ESM3ExteriorCellRefId>())
|
if (const auto* exteriorId = id.getIf<ESM::ESM3ExteriorCellRefId>())
|
||||||
return getExterior(exteriorId->getX(), exteriorId->getY());
|
return getExterior(exteriorId->getX(), exteriorId->getY());
|
||||||
|
@ -259,13 +259,13 @@ MWWorld::CellStore* MWWorld::WorldModel::getCell(const ESM::RefId& id)
|
||||||
{
|
{
|
||||||
newCellStore->load();
|
newCellStore->load();
|
||||||
}
|
}
|
||||||
return newCellStore;
|
return *newCellStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::CellStore* MWWorld::WorldModel::getCell(std::string_view name)
|
MWWorld::CellStore& MWWorld::WorldModel::getCell(std::string_view name)
|
||||||
{
|
{
|
||||||
if (CellStore* res = getInteriorOrNull(name)) // first try interiors
|
if (CellStore* res = getInteriorOrNull(name)) // first try interiors
|
||||||
return res;
|
return *res;
|
||||||
|
|
||||||
// try named exteriors
|
// try named exteriors
|
||||||
const ESM::Cell* cell = mStore.get<ESM::Cell>().searchExtByName(name);
|
const ESM::Cell* cell = mStore.get<ESM::Cell>().searchExtByName(name);
|
||||||
|
@ -296,11 +296,11 @@ MWWorld::CellStore* MWWorld::WorldModel::getCell(std::string_view name)
|
||||||
return getExterior(cell->getGridX(), cell->getGridY());
|
return getExterior(cell->getGridX(), cell->getGridY());
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::CellStore* MWWorld::WorldModel::getCellByPosition(
|
MWWorld::CellStore& MWWorld::WorldModel::getCellByPosition(
|
||||||
const osg::Vec3f& pos, MWWorld::CellStore* cellInSameWorldSpace)
|
const osg::Vec3f& pos, MWWorld::CellStore* cellInSameWorldSpace)
|
||||||
{
|
{
|
||||||
if (cellInSameWorldSpace && !cellInSameWorldSpace->isExterior())
|
if (cellInSameWorldSpace && !cellInSameWorldSpace->isExterior())
|
||||||
return cellInSameWorldSpace;
|
return *cellInSameWorldSpace;
|
||||||
const osg::Vec2i cellIndex = positionToCellIndex(pos.x(), pos.y());
|
const osg::Vec2i cellIndex = positionToCellIndex(pos.x(), pos.y());
|
||||||
return getExterior(cellIndex.x(), cellIndex.y());
|
return getExterior(cellIndex.x(), cellIndex.y());
|
||||||
}
|
}
|
||||||
|
@ -363,9 +363,9 @@ MWWorld::Ptr MWWorld::WorldModel::getPtr(const ESM::RefId& name)
|
||||||
|
|
||||||
for (iter = cells.extBegin(); iter != cells.extEnd(); ++iter)
|
for (iter = cells.extBegin(); iter != cells.extEnd(); ++iter)
|
||||||
{
|
{
|
||||||
CellStore* cellStore = getCellStore(&(*iter));
|
CellStore& cellStore = getCellStore(&(*iter));
|
||||||
|
|
||||||
Ptr ptr = getPtrAndCache(name, *cellStore);
|
Ptr ptr = getPtrAndCache(name, cellStore);
|
||||||
|
|
||||||
if (!ptr.isEmpty())
|
if (!ptr.isEmpty())
|
||||||
return ptr;
|
return ptr;
|
||||||
|
@ -373,9 +373,9 @@ MWWorld::Ptr MWWorld::WorldModel::getPtr(const ESM::RefId& name)
|
||||||
|
|
||||||
for (iter = cells.intBegin(); iter != cells.intEnd(); ++iter)
|
for (iter = cells.intBegin(); iter != cells.intEnd(); ++iter)
|
||||||
{
|
{
|
||||||
CellStore* cellStore = getCellStore(&(*iter));
|
CellStore& cellStore = getCellStore(&(*iter));
|
||||||
|
|
||||||
Ptr ptr = getPtrAndCache(name, *cellStore);
|
Ptr ptr = getPtrAndCache(name, cellStore);
|
||||||
|
|
||||||
if (!ptr.isEmpty())
|
if (!ptr.isEmpty())
|
||||||
return ptr;
|
return ptr;
|
||||||
|
@ -390,9 +390,9 @@ void MWWorld::WorldModel::getExteriorPtrs(const ESM::RefId& name, std::vector<MW
|
||||||
const MWWorld::Store<ESM::Cell>& cells = mStore.get<ESM::Cell>();
|
const MWWorld::Store<ESM::Cell>& cells = mStore.get<ESM::Cell>();
|
||||||
for (MWWorld::Store<ESM::Cell>::iterator iter = cells.extBegin(); iter != cells.extEnd(); ++iter)
|
for (MWWorld::Store<ESM::Cell>::iterator iter = cells.extBegin(); iter != cells.extEnd(); ++iter)
|
||||||
{
|
{
|
||||||
CellStore* cellStore = getCellStore(&(*iter));
|
CellStore& cellStore = getCellStore(&(*iter));
|
||||||
|
|
||||||
Ptr ptr = getPtrAndCache(name, *cellStore);
|
Ptr ptr = getPtrAndCache(name, cellStore);
|
||||||
|
|
||||||
if (!ptr.isEmpty())
|
if (!ptr.isEmpty())
|
||||||
out.push_back(ptr);
|
out.push_back(ptr);
|
||||||
|
@ -441,7 +441,7 @@ public:
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return mWorldModel.getCell(cellId);
|
return &mWorldModel.getCell(cellId);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
@ -461,7 +461,7 @@ bool MWWorld::WorldModel::readRecord(ESM::ESMReader& reader, uint32_t type, cons
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cellStore = getCell(state.mId);
|
cellStore = &getCell(state.mId);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace MWWorld
|
||||||
std::size_t mPtrIndexUpdateCounter = 0;
|
std::size_t mPtrIndexUpdateCounter = 0;
|
||||||
ESM::RefNum mLastGeneratedRefnum;
|
ESM::RefNum mLastGeneratedRefnum;
|
||||||
|
|
||||||
CellStore* getCellStore(const ESM::Cell* cell);
|
CellStore& getCellStore(const ESM::Cell* cell);
|
||||||
CellStore* getInteriorOrNull(std::string_view name);
|
CellStore* getInteriorOrNull(std::string_view name);
|
||||||
Ptr getPtrAndCache(const ESM::RefId& name, CellStore& cellStore);
|
Ptr getPtrAndCache(const ESM::RefId& name, CellStore& cellStore);
|
||||||
|
|
||||||
|
@ -63,16 +63,16 @@ namespace MWWorld
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
CellStore* getExterior(int x, int y);
|
CellStore& getExterior(int x, int y);
|
||||||
CellStore* getInterior(std::string_view name);
|
CellStore& getInterior(std::string_view name);
|
||||||
CellStore* getCell(std::string_view name); // interior or named exterior
|
CellStore& getCell(std::string_view name); // interior or named exterior
|
||||||
CellStore* getCell(const ESM::RefId& Id);
|
CellStore& getCell(const ESM::RefId& Id);
|
||||||
|
|
||||||
// Returns the cell that is in the same worldspace as `cellInSameWorldSpace`
|
// Returns the cell that is in the same worldspace as `cellInSameWorldSpace`
|
||||||
// (in case of nullptr - default exterior worldspace) and contains given position.
|
// (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
|
// Interiors are single-cell worldspaces, so in case of an interior it just returns
|
||||||
// the same cell.
|
// the same cell.
|
||||||
CellStore* getCellByPosition(const osg::Vec3f& pos, CellStore* cellInSameWorldSpace = nullptr);
|
CellStore& getCellByPosition(const osg::Vec3f& pos, CellStore* cellInSameWorldSpace = nullptr);
|
||||||
|
|
||||||
void registerPtr(const MWWorld::Ptr& ptr);
|
void registerPtr(const MWWorld::Ptr& ptr);
|
||||||
void deregisterPtr(const MWWorld::Ptr& ptr);
|
void deregisterPtr(const MWWorld::Ptr& ptr);
|
||||||
|
|
Loading…
Reference in a new issue