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);