1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-10 12:39:53 +00:00

Rename mCells -> mWorldModel

This commit is contained in:
Petr Mikheev 2022-12-15 20:56:17 +01:00
parent ac6303a83a
commit de57a95c9d
4 changed files with 35 additions and 34 deletions

View File

@ -127,25 +127,25 @@ namespace MWLua
// sections. // sections.
MWWorld::CellStore* WorldView::findCell(const std::string& name, osg::Vec3f position) MWWorld::CellStore* WorldView::findCell(const std::string& name, osg::Vec3f position)
{ {
MWWorld::WorldModel* cells = MWBase::Environment::get().getWorldModel(); MWWorld::WorldModel* worldModel = MWBase::Environment::get().getWorldModel();
bool exterior = name.empty() || MWBase::Environment::get().getWorld()->getExterior(name); bool exterior = name.empty() || MWBase::Environment::get().getWorld()->getExterior(name);
if (exterior) if (exterior)
{ {
const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(position.x(), position.y()); const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(position.x(), position.y());
return cells->getExterior(cellIndex.x(), cellIndex.y()); return worldModel->getExterior(cellIndex.x(), cellIndex.y());
} }
else else
return cells->getInterior(name); return worldModel->getInterior(name);
} }
MWWorld::CellStore* WorldView::findNamedCell(const std::string& name) MWWorld::CellStore* WorldView::findNamedCell(const std::string& name)
{ {
MWWorld::WorldModel* cells = MWBase::Environment::get().getWorldModel(); MWWorld::WorldModel* worldModel = MWBase::Environment::get().getWorldModel();
const ESM::Cell* esmCell = MWBase::Environment::get().getWorld()->getExterior(name); const ESM::Cell* esmCell = MWBase::Environment::get().getWorld()->getExterior(name);
if (esmCell) if (esmCell)
return cells->getExterior(esmCell->getGridX(), esmCell->getGridY()); return worldModel->getExterior(esmCell->getGridX(), esmCell->getGridY());
else else
return cells->getInterior(name); return worldModel->getInterior(name);
} }
MWWorld::CellStore* WorldView::findExteriorCell(int x, int y) MWWorld::CellStore* WorldView::findExteriorCell(int x, int y)

View File

@ -160,7 +160,7 @@ namespace MWWorld
const std::filesystem::path& userDataPath) const std::filesystem::path& userDataPath)
: mResourceSystem(resourceSystem) : mResourceSystem(resourceSystem)
, mLocalScripts(mStore) , mLocalScripts(mStore)
, mCells(mStore, mReaders) , mWorldModel(mStore, mReaders)
, mSky(true) , mSky(true)
, mGodMode(false) , mGodMode(false)
, mScriptsEnabled(true) , mScriptsEnabled(true)
@ -328,7 +328,7 @@ namespace MWWorld
mPlayer->set(mStore.get<ESM::NPC>().find("player")); mPlayer->set(mStore.get<ESM::NPC>().find("player"));
} }
mCells.clear(); mWorldModel.clear();
mDoorStates.clear(); mDoorStates.clear();
@ -343,7 +343,7 @@ namespace MWWorld
int World::countSavedGameRecords() const int World::countSavedGameRecords() const
{ {
return mCells.countSavedGameRecords() + mStore.countSavedGameRecords() return mWorldModel.countSavedGameRecords() + mStore.countSavedGameRecords()
+ mGlobalVariables.countSavedGameRecords() + mProjectileManager->countSavedGameRecords() + mGlobalVariables.countSavedGameRecords() + mProjectileManager->countSavedGameRecords()
+ 1 // player record + 1 // player record
+ 1 // weather record + 1 // weather record
@ -355,7 +355,7 @@ namespace MWWorld
int World::countSavedGameCells() const int World::countSavedGameCells() const
{ {
return mCells.countSavedGameRecords(); return mWorldModel.countSavedGameRecords();
} }
void World::write(ESM::ESMWriter& writer, Loading::Listener& progress) const void World::write(ESM::ESMWriter& writer, Loading::Listener& progress) const
@ -375,7 +375,7 @@ namespace MWWorld
mStore.write(writer, progress); // dynamic Store must be written (and read) before Cells, so that mStore.write(writer, progress); // dynamic Store must be written (and read) before Cells, so that
// references to custom made records will be recognized // references to custom made records will be recognized
mPlayer->write(writer, progress); mPlayer->write(writer, progress);
mCells.write(writer, progress); mWorldModel.write(writer, progress);
mGlobalVariables.write(writer, progress); mGlobalVariables.write(writer, progress);
mWeatherManager->write(writer, progress); mWeatherManager->write(writer, progress);
mProjectileManager->write(writer, progress); mProjectileManager->write(writer, progress);
@ -419,7 +419,8 @@ namespace MWWorld
break; break;
default: default:
if (!mStore.readRecord(reader, type) && !mGlobalVariables.readRecord(reader, type) if (!mStore.readRecord(reader, type) && !mGlobalVariables.readRecord(reader, type)
&& !mWeatherManager->readRecord(reader, type) && !mCells.readRecord(reader, type, contentFileMap) && !mWeatherManager->readRecord(reader, type)
&& !mWorldModel.readRecord(reader, type, contentFileMap)
&& !mProjectileManager->readRecord(reader, type)) && !mProjectileManager->readRecord(reader, type))
{ {
throw std::runtime_error("unknown record in saved game"); throw std::runtime_error("unknown record in saved game");
@ -695,7 +696,7 @@ namespace MWWorld
{ {
// TODO: caching still doesn't work efficiently here (only works for the one CellStore that the reference is // TODO: caching still doesn't work efficiently here (only works for the one CellStore that the reference is
// in) // in)
Ptr ptr = mCells.getPtr(lowerCaseName, *cellstore, false); Ptr ptr = mWorldModel.getPtr(lowerCaseName, *cellstore, false);
if (!ptr.isEmpty()) if (!ptr.isEmpty())
return ptr; return ptr;
@ -703,7 +704,7 @@ namespace MWWorld
if (!activeOnly) if (!activeOnly)
{ {
ret = mCells.getPtr(lowerCaseName); ret = mWorldModel.getPtr(lowerCaseName);
if (!ret.isEmpty()) if (!ret.isEmpty())
return ret; return ret;
} }
@ -745,7 +746,7 @@ namespace MWWorld
Ptr World::searchPtrViaRefNum(const std::string& id, const ESM::RefNum& refNum) Ptr World::searchPtrViaRefNum(const std::string& id, const ESM::RefNum& refNum)
{ {
return mCells.getPtr(id, refNum); return mWorldModel.getPtr(id, refNum);
} }
struct FindContainerVisitor struct FindContainerVisitor
@ -1262,7 +1263,7 @@ 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 = mCells.getExterior(index.x(), index.y()); CellStore* newCell = mWorldModel.getExterior(index.x(), index.y());
bool isCellActive = getPlayerPtr().isInCell() && getPlayerPtr().getCell()->isExterior() bool isCellActive = getPlayerPtr().isInCell() && getPlayerPtr().getCell()->isExterior()
&& mWorldScene->isCellActive(*newCell); && mWorldScene->isCellActive(*newCell);
@ -2200,7 +2201,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 = mCells.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);
@ -2789,7 +2790,7 @@ 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 = mCells.getInterior(name); MWWorld::CellStore* cellStore = mWorldModel.getInterior(name);
if (!cellStore) if (!cellStore)
return false; return false;
@ -2820,12 +2821,12 @@ namespace MWWorld
{ {
ESM::Position doorDest = door->getDoorDest(); ESM::Position doorDest = door->getDoorDest();
const osg::Vec2i index = positionToCellIndex(doorDest.pos[0], doorDest.pos[1]); const osg::Vec2i index = positionToCellIndex(doorDest.pos[0], doorDest.pos[1]);
source = mCells.getExterior(index.x(), index.y()); source = mWorldModel.getExterior(index.x(), index.y());
} }
// door to interior // door to interior
else else
{ {
source = mCells.getInterior(door->getDestCell()); source = mWorldModel.getInterior(door->getDestCell());
} }
if (source) if (source)
{ {
@ -2872,7 +2873,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 = mCells.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
} }
@ -3291,7 +3292,7 @@ namespace MWWorld
nextCells.clear(); nextCells.clear();
for (const std::string& currentCell : currentCells) for (const std::string& currentCell : currentCells)
{ {
MWWorld::CellStore* next = mCells.getInterior(currentCell); MWWorld::CellStore* next = mWorldModel.getInterior(currentCell);
if (!next) if (!next)
continue; continue;
@ -3345,7 +3346,7 @@ namespace MWWorld
nextCells.clear(); nextCells.clear();
for (const std::string& cell : currentCells) for (const std::string& cell : currentCells)
{ {
MWWorld::CellStore* next = mCells.getInterior(cell); MWWorld::CellStore* next = mWorldModel.getInterior(cell);
checkedCells.insert(cell); checkedCells.insert(cell);
if (!next) if (!next)
continue; continue;
@ -3385,7 +3386,7 @@ namespace MWWorld
float closestDistance = std::numeric_limits<float>::max(); float closestDistance = std::numeric_limits<float>::max();
std::vector<MWWorld::Ptr> markers; std::vector<MWWorld::Ptr> markers;
mCells.getExteriorPtrs(id, markers); mWorldModel.getExteriorPtrs(id, markers);
for (const Ptr& marker : markers) for (const Ptr& marker : markers)
{ {
osg::Vec3f markerPos = marker.getRefData().getPosition().asVec3(); osg::Vec3f markerPos = marker.getRefData().getPosition().asVec3();
@ -3402,7 +3403,7 @@ namespace MWWorld
void World::rest(double hours) void World::rest(double hours)
{ {
mCells.rest(hours); mWorldModel.rest(hours);
} }
void World::rechargeItems(double duration, bool activeOnly) void World::rechargeItems(double duration, bool activeOnly)
@ -3418,7 +3419,7 @@ namespace MWWorld
} }
} }
else else
mCells.recharge(duration); mWorldModel.recharge(duration);
} }
void World::teleportToClosestMarker(const MWWorld::Ptr& ptr, std::string_view id) void World::teleportToClosestMarker(const MWWorld::Ptr& ptr, std::string_view id)
@ -3643,7 +3644,7 @@ 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 = mCells.getInterior(prisonName); MWWorld::CellStore* prison = mWorldModel.getInterior(prisonName);
if (!prison) if (!prison)
{ {
Log(Debug::Warning) << "Failed to confiscate items: failed to load cell " << prisonName; Log(Debug::Warning) << "Failed to confiscate items: failed to load cell " << prisonName;
@ -3958,7 +3959,7 @@ namespace MWWorld
std::vector<MWWorld::Ptr> World::getAll(const std::string& id) std::vector<MWWorld::Ptr> World::getAll(const std::string& id)
{ {
return mCells.getAll(id); return mWorldModel.getAll(id);
} }
Misc::Rng::Generator& World::getPrng() Misc::Rng::Generator& World::getPrng()

View File

@ -90,7 +90,7 @@ namespace MWWorld
LocalScripts mLocalScripts; LocalScripts mLocalScripts;
MWWorld::Globals mGlobalVariables; MWWorld::Globals mGlobalVariables;
Misc::Rng::Generator mPrng; Misc::Rng::Generator mPrng;
WorldModel mCells; WorldModel mWorldModel;
std::vector<int> mESMVersions; // the versions of esm files std::vector<int> mESMVersions; // the versions of esm files
std::string mCurrentWorldSpace; std::string mCurrentWorldSpace;
@ -188,7 +188,7 @@ namespace MWWorld
MWWorld::ConstPtr getClosestMarkerFromExteriorPosition(const osg::Vec3f& worldPos, std::string_view id); MWWorld::ConstPtr getClosestMarkerFromExteriorPosition(const osg::Vec3f& worldPos, std::string_view id);
public: public:
WorldModel& getWorldModel() { return mCells; } WorldModel& getWorldModel() { return mWorldModel; }
Scene& getWorldScene() { return *mWorldScene; } Scene& getWorldScene() { return *mWorldScene; }
// FIXME // FIXME

View File

@ -410,18 +410,18 @@ void MWWorld::WorldModel::write(ESM::ESMWriter& writer, Loading::Listener& progr
struct GetCellStoreCallback : public MWWorld::CellStore::GetCellStoreCallback struct GetCellStoreCallback : public MWWorld::CellStore::GetCellStoreCallback
{ {
public: public:
GetCellStoreCallback(MWWorld::WorldModel& cells) GetCellStoreCallback(MWWorld::WorldModel& worldModel)
: mCells(cells) : mWorldModel(worldModel)
{ {
} }
MWWorld::WorldModel& mCells; MWWorld::WorldModel& mWorldModel;
MWWorld::CellStore* getCellStore(const ESM::CellId& cellId) override MWWorld::CellStore* getCellStore(const ESM::CellId& cellId) override
{ {
try try
{ {
return mCells.getCell(cellId); return mWorldModel.getCell(cellId);
} }
catch (...) catch (...)
{ {