From ac6303a83a471e4f26c0f63609d2da63ce91305f Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Tue, 6 Dec 2022 00:11:19 +0100 Subject: [PATCH 1/2] Rename MWWorld::Cells -> WorldModel --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwbase/environment.hpp | 8 ++-- apps/openmw/mwgui/mapwindow.cpp | 4 +- apps/openmw/mwgui/travelwindow.cpp | 2 +- apps/openmw/mwlua/worldview.cpp | 6 +-- .../mwscript/transformationextensions.cpp | 2 +- apps/openmw/mwstate/statemanagerimp.cpp | 2 +- apps/openmw/mwworld/actionteleport.cpp | 4 +- apps/openmw/mwworld/player.cpp | 2 +- apps/openmw/mwworld/worldimp.hpp | 6 +-- .../mwworld/{cells.cpp => worldmodel.cpp} | 46 +++++++++---------- .../mwworld/{cells.hpp => worldmodel.hpp} | 12 ++--- 12 files changed, 48 insertions(+), 48 deletions(-) rename apps/openmw/mwworld/{cells.cpp => worldmodel.cpp} (87%) rename apps/openmw/mwworld/{cells.hpp => worldmodel.hpp} (90%) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index a51df711f3..ced1060ce9 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -74,7 +74,7 @@ add_openmw_dir (mwsound add_openmw_dir (mwworld refdata worldimp scene globals class action nullaction actionteleport containerstore actiontalk actiontake manualref player cellvisitors failedaction - cells localscripts customdata inventorystore ptr actionopen actionread actionharvest + worldmodel localscripts customdata inventorystore ptr actionopen actionread actionharvest actionequip timestamp actionalchemy cellstore actionapply actioneat store esmstore fallback actionrepair actionsoulgem livecellref actiondoor contentloader esmloader actiontrap cellreflist cellref weather projectilemanager diff --git a/apps/openmw/mwbase/environment.hpp b/apps/openmw/mwbase/environment.hpp index 581b587d00..bb0257bd97 100644 --- a/apps/openmw/mwbase/environment.hpp +++ b/apps/openmw/mwbase/environment.hpp @@ -17,7 +17,7 @@ namespace l10n namespace MWWorld { - class Cells; + class WorldModel; class Scene; } @@ -43,7 +43,7 @@ namespace MWBase static Environment* sThis; World* mWorld = nullptr; - MWWorld::Cells* mWorldModel = nullptr; // TODO: rename Cells -> WorldModel + MWWorld::WorldModel* mWorldModel = nullptr; MWWorld::Scene* mWorldScene = nullptr; SoundManager* mSoundManager = nullptr; ScriptManager* mScriptManager = nullptr; @@ -69,7 +69,7 @@ namespace MWBase Environment& operator=(const Environment&) = delete; void setWorld(World& value) { mWorld = &value; } - void setWorldModel(MWWorld::Cells& value) { mWorldModel = &value; } + void setWorldModel(MWWorld::WorldModel& value) { mWorldModel = &value; } void setWorldScene(MWWorld::Scene& value) { mWorldScene = &value; } void setSoundManager(SoundManager& value) { mSoundManager = &value; } @@ -95,7 +95,7 @@ namespace MWBase void setL10nManager(l10n::Manager& value) { mL10nManager = &value; } Misc::NotNullPtr getWorld() const { return mWorld; } - Misc::NotNullPtr getWorldModel() const { return mWorldModel; } + Misc::NotNullPtr getWorldModel() const { return mWorldModel; } Misc::NotNullPtr getWorldScene() const { return mWorldScene; } Misc::NotNullPtr getSoundManager() const { return mSoundManager; } diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 83ec58d43e..58c36a7cff 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -22,11 +22,11 @@ #include "../mwbase/windowmanager.hpp" #include "../mwbase/world.hpp" -#include "../mwworld/cells.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/cellutils.hpp" #include "../mwworld/esmstore.hpp" #include "../mwworld/player.hpp" +#include "../mwworld/worldmodel.hpp" #include "../mwrender/globalmap.hpp" #include "../mwrender/localmap.hpp" @@ -626,7 +626,7 @@ namespace MWGui { std::vector doors; MWBase::World* world = MWBase::Environment::get().getWorld(); - MWWorld::Cells* worldModel = MWBase::Environment::get().getWorldModel(); + MWWorld::WorldModel* worldModel = MWBase::Environment::get().getWorldModel(); mDoorMarkersToRecycle.insert( mDoorMarkersToRecycle.end(), mInteriorDoorMarkerWidgets.begin(), mInteriorDoorMarkerWidgets.end()); diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 0df14b7801..541440e016 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -13,13 +13,13 @@ #include "../mwbase/world.hpp" #include "../mwworld/actionteleport.hpp" -#include "../mwworld/cells.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/cellutils.hpp" #include "../mwworld/class.hpp" #include "../mwworld/containerstore.hpp" #include "../mwworld/esmstore.hpp" #include "../mwworld/store.hpp" +#include "../mwworld/worldmodel.hpp" #include "../mwmechanics/actorutil.hpp" #include "../mwmechanics/creaturestats.hpp" diff --git a/apps/openmw/mwlua/worldview.cpp b/apps/openmw/mwlua/worldview.cpp index 6435c35415..99fa47e4d9 100644 --- a/apps/openmw/mwlua/worldview.cpp +++ b/apps/openmw/mwlua/worldview.cpp @@ -8,10 +8,10 @@ #include "../mwclass/container.hpp" -#include "../mwworld/cells.hpp" #include "../mwworld/cellutils.hpp" #include "../mwworld/class.hpp" #include "../mwworld/timestamp.hpp" +#include "../mwworld/worldmodel.hpp" namespace MWLua { @@ -127,7 +127,7 @@ namespace MWLua // sections. MWWorld::CellStore* WorldView::findCell(const std::string& name, osg::Vec3f position) { - MWWorld::Cells* cells = MWBase::Environment::get().getWorldModel(); + MWWorld::WorldModel* cells = MWBase::Environment::get().getWorldModel(); bool exterior = name.empty() || MWBase::Environment::get().getWorld()->getExterior(name); if (exterior) { @@ -140,7 +140,7 @@ namespace MWLua MWWorld::CellStore* WorldView::findNamedCell(const std::string& name) { - MWWorld::Cells* cells = MWBase::Environment::get().getWorldModel(); + MWWorld::WorldModel* cells = MWBase::Environment::get().getWorldModel(); const ESM::Cell* esmCell = MWBase::Environment::get().getWorld()->getExterior(name); if (esmCell) return cells->getExterior(esmCell->getGridX(), esmCell->getGridY()); diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 518de3a3a2..1dc84022df 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -13,13 +13,13 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" -#include "../mwworld/cells.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/cellutils.hpp" #include "../mwworld/class.hpp" #include "../mwworld/manualref.hpp" #include "../mwworld/player.hpp" #include "../mwworld/scene.hpp" +#include "../mwworld/worldmodel.hpp" #include "../mwmechanics/actorutil.hpp" diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index 8d13526fb6..51a7c1f68a 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -30,11 +30,11 @@ #include "../mwbase/windowmanager.hpp" #include "../mwbase/world.hpp" -#include "../mwworld/cells.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/class.hpp" #include "../mwworld/esmstore.hpp" #include "../mwworld/scene.hpp" +#include "../mwworld/worldmodel.hpp" #include "../mwmechanics/actorutil.hpp" #include "../mwmechanics/npcstats.hpp" diff --git a/apps/openmw/mwworld/actionteleport.cpp b/apps/openmw/mwworld/actionteleport.cpp index 19c6ec65b6..613fa631a6 100644 --- a/apps/openmw/mwworld/actionteleport.cpp +++ b/apps/openmw/mwworld/actionteleport.cpp @@ -8,10 +8,10 @@ #include "../mwmechanics/creaturestats.hpp" -#include "../mwworld/cells.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/cellutils.hpp" #include "../mwworld/class.hpp" +#include "../mwworld/worldmodel.hpp" #include "player.hpp" @@ -43,7 +43,7 @@ namespace MWWorld void ActionTeleport::teleport(const Ptr& actor) { MWBase::World* world = MWBase::Environment::get().getWorld(); - MWWorld::Cells* worldModel = MWBase::Environment::get().getWorldModel(); + MWWorld::WorldModel* worldModel = MWBase::Environment::get().getWorldModel(); actor.getClass().getCreatureStats(actor).land(actor == world->getPlayerPtr()); if (actor == world->getPlayerPtr()) { diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 819ddd9538..2aed081d91 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -12,10 +12,10 @@ #include #include -#include "../mwworld/cells.hpp" #include "../mwworld/esmstore.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwworld/magiceffects.hpp" +#include "../mwworld/worldmodel.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/mechanicsmanager.hpp" diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 6ebf90ea46..31ca9e3983 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -10,7 +10,6 @@ #include "../mwbase/world.hpp" -#include "cells.hpp" #include "contentloader.hpp" #include "esmstore.hpp" #include "globals.hpp" @@ -19,6 +18,7 @@ #include "ptr.hpp" #include "scene.hpp" #include "timestamp.hpp" +#include "worldmodel.hpp" namespace osg { @@ -90,7 +90,7 @@ namespace MWWorld LocalScripts mLocalScripts; MWWorld::Globals mGlobalVariables; Misc::Rng::Generator mPrng; - Cells mCells; + WorldModel mCells; std::vector mESMVersions; // the versions of esm files std::string mCurrentWorldSpace; @@ -188,7 +188,7 @@ namespace MWWorld MWWorld::ConstPtr getClosestMarkerFromExteriorPosition(const osg::Vec3f& worldPos, std::string_view id); public: - Cells& getWorldModel() { return mCells; } + WorldModel& getWorldModel() { return mCells; } Scene& getWorldScene() { return *mWorldScene; } // FIXME diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/worldmodel.cpp similarity index 87% rename from apps/openmw/mwworld/cells.cpp rename to apps/openmw/mwworld/worldmodel.cpp index 7fd7cc149d..014f61af73 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/worldmodel.cpp @@ -1,4 +1,4 @@ -#include "cells.hpp" +#include "worldmodel.hpp" #include #include @@ -58,7 +58,7 @@ namespace }; } -MWWorld::CellStore* MWWorld::Cells::getCellStore(const ESM::Cell* cell) +MWWorld::CellStore* MWWorld::WorldModel::getCellStore(const ESM::Cell* cell) { if (cell->mData.mFlags & ESM::Cell::Interior) { @@ -84,7 +84,7 @@ MWWorld::CellStore* MWWorld::Cells::getCellStore(const ESM::Cell* cell) } } -void MWWorld::Cells::clear() +void MWWorld::WorldModel::clear() { mInteriors.clear(); mExteriors.clear(); @@ -92,7 +92,7 @@ void MWWorld::Cells::clear() mIdCacheIndex = 0; } -MWWorld::Ptr MWWorld::Cells::getPtrAndCache(std::string_view name, CellStore& cellStore) +MWWorld::Ptr MWWorld::WorldModel::getPtrAndCache(std::string_view name, CellStore& cellStore) { Ptr ptr = getPtr(name, cellStore); @@ -107,7 +107,7 @@ MWWorld::Ptr MWWorld::Cells::getPtrAndCache(std::string_view name, CellStore& ce return ptr; } -void MWWorld::Cells::writeCell(ESM::ESMWriter& writer, CellStore& cell) const +void MWWorld::WorldModel::writeCell(ESM::ESMWriter& writer, CellStore& cell) const { if (cell.getState() != CellStore::State_Loaded) cell.load(); @@ -124,7 +124,7 @@ void MWWorld::Cells::writeCell(ESM::ESMWriter& writer, CellStore& cell) const writer.endRecord(ESM::REC_CSTA); } -MWWorld::Cells::Cells(const MWWorld::ESMStore& store, ESM::ReadersCache& readers) +MWWorld::WorldModel::WorldModel(const MWWorld::ESMStore& store, ESM::ReadersCache& readers) : mStore(store) , mReaders(readers) , mIdCacheIndex(0) @@ -133,7 +133,7 @@ MWWorld::Cells::Cells(const MWWorld::ESMStore& store, ESM::ReadersCache& readers mIdCache = IdCache(cacheSize, std::pair("", (CellStore*)nullptr)); } -MWWorld::CellStore* MWWorld::Cells::getExterior(int x, int y) +MWWorld::CellStore* MWWorld::WorldModel::getExterior(int x, int y) { std::map, CellStore>::iterator result = mExteriors.find(std::make_pair(x, y)); @@ -170,7 +170,7 @@ MWWorld::CellStore* MWWorld::Cells::getExterior(int x, int y) return &result->second; } -MWWorld::CellStore* MWWorld::Cells::getInterior(std::string_view name) +MWWorld::CellStore* MWWorld::WorldModel::getInterior(std::string_view name) { std::string lowerName = Misc::StringUtils::lowerCase(name); std::map::iterator result = mInteriors.find(lowerName); @@ -190,7 +190,7 @@ MWWorld::CellStore* MWWorld::Cells::getInterior(std::string_view name) return &result->second; } -void MWWorld::Cells::rest(double hours) +void MWWorld::WorldModel::rest(double hours) { for (auto& interior : mInteriors) { @@ -203,7 +203,7 @@ void MWWorld::Cells::rest(double hours) } } -void MWWorld::Cells::recharge(float duration) +void MWWorld::WorldModel::recharge(float duration) { for (auto& interior : mInteriors) { @@ -216,7 +216,7 @@ void MWWorld::Cells::recharge(float duration) } } -MWWorld::CellStore* MWWorld::Cells::getCell(const ESM::CellId& id) +MWWorld::CellStore* MWWorld::WorldModel::getCell(const ESM::CellId& id) { if (id.mPaged) return getExterior(id.mIndex.mX, id.mIndex.mY); @@ -224,7 +224,7 @@ MWWorld::CellStore* MWWorld::Cells::getCell(const ESM::CellId& id) return getInterior(id.mWorldspace); } -MWWorld::Ptr MWWorld::Cells::getPtr(std::string_view name, CellStore& cell, bool searchInContainers) +MWWorld::Ptr MWWorld::WorldModel::getPtr(std::string_view name, CellStore& cell, bool searchInContainers) { if (cell.getState() == CellStore::State_Unloaded) cell.preload(); @@ -250,7 +250,7 @@ MWWorld::Ptr MWWorld::Cells::getPtr(std::string_view name, CellStore& cell, bool return Ptr(); } -MWWorld::Ptr MWWorld::Cells::getPtr(const std::string& name) +MWWorld::Ptr MWWorld::WorldModel::getPtr(const std::string& name) { // First check the cache for (IdCache::iterator iter(mIdCache.begin()); iter != mIdCache.end(); ++iter) @@ -307,7 +307,7 @@ MWWorld::Ptr MWWorld::Cells::getPtr(const std::string& name) return Ptr(); } -MWWorld::Ptr MWWorld::Cells::getPtr(const std::string& id, const ESM::RefNum& refNum) +MWWorld::Ptr MWWorld::WorldModel::getPtr(const std::string& id, const ESM::RefNum& refNum) { for (auto& pair : mInteriors) { @@ -324,7 +324,7 @@ MWWorld::Ptr MWWorld::Cells::getPtr(const std::string& id, const ESM::RefNum& re return Ptr(); } -MWWorld::Ptr MWWorld::Cells::getPtr(CellStore& cellStore, const std::string& id, const ESM::RefNum& refNum) +MWWorld::Ptr MWWorld::WorldModel::getPtr(CellStore& cellStore, const std::string& id, const ESM::RefNum& refNum) { if (cellStore.getState() == CellStore::State_Unloaded) cellStore.preload(); @@ -338,7 +338,7 @@ MWWorld::Ptr MWWorld::Cells::getPtr(CellStore& cellStore, const std::string& id, return cellStore.searchViaRefNum(refNum); } -void MWWorld::Cells::getExteriorPtrs(std::string_view name, std::vector& out) +void MWWorld::WorldModel::getExteriorPtrs(std::string_view name, std::vector& out) { const MWWorld::Store& cells = mStore.get(); for (MWWorld::Store::iterator iter = cells.extBegin(); iter != cells.extEnd(); ++iter) @@ -352,7 +352,7 @@ void MWWorld::Cells::getExteriorPtrs(std::string_view name, std::vector& out) +void MWWorld::WorldModel::getInteriorPtrs(const std::string& name, std::vector& out) { const MWWorld::Store& cells = mStore.get(); for (MWWorld::Store::iterator iter = cells.intBegin(); iter != cells.intEnd(); ++iter) @@ -366,7 +366,7 @@ void MWWorld::Cells::getInteriorPtrs(const std::string& name, std::vector MWWorld::Cells::getAll(const std::string& id) +std::vector MWWorld::WorldModel::getAll(const std::string& id) { PtrCollector visitor; if (forEachInStore(id, visitor, mInteriors)) @@ -374,7 +374,7 @@ std::vector MWWorld::Cells::getAll(const std::string& id) return visitor.mPtrs; } -int MWWorld::Cells::countSavedGameRecords() const +int MWWorld::WorldModel::countSavedGameRecords() const { int count = 0; @@ -390,7 +390,7 @@ int MWWorld::Cells::countSavedGameRecords() const return count; } -void MWWorld::Cells::write(ESM::ESMWriter& writer, Loading::Listener& progress) const +void MWWorld::WorldModel::write(ESM::ESMWriter& writer, Loading::Listener& progress) const { for (std::map, CellStore>::iterator iter(mExteriors.begin()); iter != mExteriors.end(); ++iter) if (iter->second.hasState()) @@ -410,12 +410,12 @@ void MWWorld::Cells::write(ESM::ESMWriter& writer, Loading::Listener& progress) struct GetCellStoreCallback : public MWWorld::CellStore::GetCellStoreCallback { public: - GetCellStoreCallback(MWWorld::Cells& cells) + GetCellStoreCallback(MWWorld::WorldModel& cells) : mCells(cells) { } - MWWorld::Cells& mCells; + MWWorld::WorldModel& mCells; MWWorld::CellStore* getCellStore(const ESM::CellId& cellId) override { @@ -430,7 +430,7 @@ public: } }; -bool MWWorld::Cells::readRecord(ESM::ESMReader& reader, uint32_t type, const std::map& contentFileMap) +bool MWWorld::WorldModel::readRecord(ESM::ESMReader& reader, uint32_t type, const std::map& contentFileMap) { if (type == ESM::REC_CSTA) { diff --git a/apps/openmw/mwworld/cells.hpp b/apps/openmw/mwworld/worldmodel.hpp similarity index 90% rename from apps/openmw/mwworld/cells.hpp rename to apps/openmw/mwworld/worldmodel.hpp index d35ecc9b79..ce36cbd9e1 100644 --- a/apps/openmw/mwworld/cells.hpp +++ b/apps/openmw/mwworld/worldmodel.hpp @@ -1,5 +1,5 @@ -#ifndef GAME_MWWORLD_CELLS_H -#define GAME_MWWORLD_CELLS_H +#ifndef GAME_MWWORLD_WORLDMODEL_H +#define GAME_MWWORLD_WORLDMODEL_H #include #include @@ -27,7 +27,7 @@ namespace MWWorld class ESMStore; /// \brief Cell container - class Cells + class WorldModel { typedef std::vector> IdCache; const MWWorld::ESMStore& mStore; @@ -37,8 +37,8 @@ namespace MWWorld IdCache mIdCache; std::size_t mIdCacheIndex; - Cells(const Cells&); - Cells& operator=(const Cells&); + WorldModel(const WorldModel&); + WorldModel& operator=(const WorldModel&); CellStore* getCellStore(const ESM::Cell* cell); @@ -51,7 +51,7 @@ namespace MWWorld public: void clear(); - explicit Cells(const MWWorld::ESMStore& store, ESM::ReadersCache& reader); + explicit WorldModel(const MWWorld::ESMStore& store, ESM::ReadersCache& reader); CellStore* getExterior(int x, int y); From de57a95c9dc8d5d7f2631e9d16edaac3bc16b0e8 Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Thu, 15 Dec 2022 20:56:17 +0100 Subject: [PATCH 2/2] Rename mCells -> mWorldModel --- apps/openmw/mwlua/worldview.cpp | 12 ++++---- apps/openmw/mwworld/worldimp.cpp | 45 +++++++++++++++--------------- apps/openmw/mwworld/worldimp.hpp | 4 +-- apps/openmw/mwworld/worldmodel.cpp | 8 +++--- 4 files changed, 35 insertions(+), 34 deletions(-) diff --git a/apps/openmw/mwlua/worldview.cpp b/apps/openmw/mwlua/worldview.cpp index 99fa47e4d9..f53741adbb 100644 --- a/apps/openmw/mwlua/worldview.cpp +++ b/apps/openmw/mwlua/worldview.cpp @@ -127,25 +127,25 @@ namespace MWLua // sections. 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); if (exterior) { 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 - return cells->getInterior(name); + return worldModel->getInterior(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); if (esmCell) - return cells->getExterior(esmCell->getGridX(), esmCell->getGridY()); + return worldModel->getExterior(esmCell->getGridX(), esmCell->getGridY()); else - return cells->getInterior(name); + return worldModel->getInterior(name); } MWWorld::CellStore* WorldView::findExteriorCell(int x, int y) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index e8959d70ff..8800199e48 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -160,7 +160,7 @@ namespace MWWorld const std::filesystem::path& userDataPath) : mResourceSystem(resourceSystem) , mLocalScripts(mStore) - , mCells(mStore, mReaders) + , mWorldModel(mStore, mReaders) , mSky(true) , mGodMode(false) , mScriptsEnabled(true) @@ -328,7 +328,7 @@ namespace MWWorld mPlayer->set(mStore.get().find("player")); } - mCells.clear(); + mWorldModel.clear(); mDoorStates.clear(); @@ -343,7 +343,7 @@ namespace MWWorld int World::countSavedGameRecords() const { - return mCells.countSavedGameRecords() + mStore.countSavedGameRecords() + return mWorldModel.countSavedGameRecords() + mStore.countSavedGameRecords() + mGlobalVariables.countSavedGameRecords() + mProjectileManager->countSavedGameRecords() + 1 // player record + 1 // weather record @@ -355,7 +355,7 @@ namespace MWWorld int World::countSavedGameCells() const { - return mCells.countSavedGameRecords(); + return mWorldModel.countSavedGameRecords(); } 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 // references to custom made records will be recognized mPlayer->write(writer, progress); - mCells.write(writer, progress); + mWorldModel.write(writer, progress); mGlobalVariables.write(writer, progress); mWeatherManager->write(writer, progress); mProjectileManager->write(writer, progress); @@ -419,7 +419,8 @@ namespace MWWorld break; default: 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)) { 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 // in) - Ptr ptr = mCells.getPtr(lowerCaseName, *cellstore, false); + Ptr ptr = mWorldModel.getPtr(lowerCaseName, *cellstore, false); if (!ptr.isEmpty()) return ptr; @@ -703,7 +704,7 @@ namespace MWWorld if (!activeOnly) { - ret = mCells.getPtr(lowerCaseName); + ret = mWorldModel.getPtr(lowerCaseName); if (!ret.isEmpty()) return ret; } @@ -745,7 +746,7 @@ namespace MWWorld Ptr World::searchPtrViaRefNum(const std::string& id, const ESM::RefNum& refNum) { - return mCells.getPtr(id, refNum); + return mWorldModel.getPtr(id, refNum); } struct FindContainerVisitor @@ -1262,7 +1263,7 @@ namespace MWWorld const osg::Vec2i index = positionToCellIndex(position.x(), position.y()); 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() && mWorldScene->isCellActive(*newCell); @@ -2200,7 +2201,7 @@ namespace MWWorld if (cell->isExterior()) { 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); @@ -2789,7 +2790,7 @@ namespace MWWorld pos.rot[0] = pos.rot[1] = pos.rot[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) return false; @@ -2820,12 +2821,12 @@ namespace MWWorld { ESM::Position doorDest = door->getDoorDest(); 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 else { - source = mCells.getInterior(door->getDestCell()); + source = mWorldModel.getInterior(door->getDestCell()); } 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) throw std::runtime_error("Cell coordinates out of range."); 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 // instead of comma separated coordinates } @@ -3291,7 +3292,7 @@ namespace MWWorld nextCells.clear(); for (const std::string& currentCell : currentCells) { - MWWorld::CellStore* next = mCells.getInterior(currentCell); + MWWorld::CellStore* next = mWorldModel.getInterior(currentCell); if (!next) continue; @@ -3345,7 +3346,7 @@ namespace MWWorld nextCells.clear(); for (const std::string& cell : currentCells) { - MWWorld::CellStore* next = mCells.getInterior(cell); + MWWorld::CellStore* next = mWorldModel.getInterior(cell); checkedCells.insert(cell); if (!next) continue; @@ -3385,7 +3386,7 @@ namespace MWWorld float closestDistance = std::numeric_limits::max(); std::vector markers; - mCells.getExteriorPtrs(id, markers); + mWorldModel.getExteriorPtrs(id, markers); for (const Ptr& marker : markers) { osg::Vec3f markerPos = marker.getRefData().getPosition().asVec3(); @@ -3402,7 +3403,7 @@ namespace MWWorld void World::rest(double hours) { - mCells.rest(hours); + mWorldModel.rest(hours); } void World::rechargeItems(double duration, bool activeOnly) @@ -3418,7 +3419,7 @@ namespace MWWorld } } else - mCells.recharge(duration); + mWorldModel.recharge(duration); } 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"; return; } - MWWorld::CellStore* prison = mCells.getInterior(prisonName); + MWWorld::CellStore* prison = mWorldModel.getInterior(prisonName); if (!prison) { Log(Debug::Warning) << "Failed to confiscate items: failed to load cell " << prisonName; @@ -3958,7 +3959,7 @@ namespace MWWorld std::vector World::getAll(const std::string& id) { - return mCells.getAll(id); + return mWorldModel.getAll(id); } Misc::Rng::Generator& World::getPrng() diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 31ca9e3983..d68b17d37e 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -90,7 +90,7 @@ namespace MWWorld LocalScripts mLocalScripts; MWWorld::Globals mGlobalVariables; Misc::Rng::Generator mPrng; - WorldModel mCells; + WorldModel mWorldModel; std::vector mESMVersions; // the versions of esm files std::string mCurrentWorldSpace; @@ -188,7 +188,7 @@ namespace MWWorld MWWorld::ConstPtr getClosestMarkerFromExteriorPosition(const osg::Vec3f& worldPos, std::string_view id); public: - WorldModel& getWorldModel() { return mCells; } + WorldModel& getWorldModel() { return mWorldModel; } Scene& getWorldScene() { return *mWorldScene; } // FIXME diff --git a/apps/openmw/mwworld/worldmodel.cpp b/apps/openmw/mwworld/worldmodel.cpp index 014f61af73..2da2d76c8f 100644 --- a/apps/openmw/mwworld/worldmodel.cpp +++ b/apps/openmw/mwworld/worldmodel.cpp @@ -410,18 +410,18 @@ void MWWorld::WorldModel::write(ESM::ESMWriter& writer, Loading::Listener& progr struct GetCellStoreCallback : public MWWorld::CellStore::GetCellStoreCallback { public: - GetCellStoreCallback(MWWorld::WorldModel& cells) - : mCells(cells) + GetCellStoreCallback(MWWorld::WorldModel& worldModel) + : mWorldModel(worldModel) { } - MWWorld::WorldModel& mCells; + MWWorld::WorldModel& mWorldModel; MWWorld::CellStore* getCellStore(const ESM::CellId& cellId) override { try { - return mCells.getCell(cellId); + return mWorldModel.getCell(cellId); } catch (...) {