diff --git a/apps/navmeshtool/worldspacedata.cpp b/apps/navmeshtool/worldspacedata.cpp index 8d2ac7382b..7f579f8fde 100644 --- a/apps/navmeshtool/worldspacedata.cpp +++ b/apps/navmeshtool/worldspacedata.cpp @@ -103,8 +103,7 @@ namespace NavMeshTool Log(Debug::Debug) << "Loaded " << cellRefs.size() << " cell refs"; - const auto getKey - = [](const EsmLoader::Record& v) -> const ESM::RefNum& { return v.mValue.mRefNum; }; + const auto getKey = [](const EsmLoader::Record& v) -> ESM::RefNum { return v.mValue.mRefNum; }; std::vector result = prepareRecords(cellRefs, getKey); Log(Debug::Debug) << "Prepared " << result.size() << " unique cell refs"; diff --git a/apps/openmw/mwlua/engineevents.cpp b/apps/openmw/mwlua/engineevents.cpp index c838ccfcba..0fbb13f1cf 100644 --- a/apps/openmw/mwlua/engineevents.cpp +++ b/apps/openmw/mwlua/engineevents.cpp @@ -87,7 +87,7 @@ namespace MWLua void operator()(const OnNewExterior& event) const { mGlobalScripts.onNewExterior(GCell{ &event.mCell }); } private: - MWWorld::Ptr getPtr(const ESM::RefNum& id) const + MWWorld::Ptr getPtr(ESM::RefNum id) const { MWWorld::Ptr res = mWorldModel->getPtr(id); if (res.isEmpty() && Settings::lua().mLuaDebug) @@ -103,7 +103,7 @@ namespace MWLua return ptr.getRefData().getLuaScripts(); } - LocalScripts* getLocalScripts(const ESM::RefNum& id) const { return getLocalScripts(getPtr(id)); } + LocalScripts* getLocalScripts(ESM::RefNum id) const { return getLocalScripts(getPtr(id)); } GlobalScripts& mGlobalScripts; MWWorld::WorldModel* mWorldModel = MWBase::Environment::get().getWorldModel(); diff --git a/apps/openmw/mwlua/luaevents.cpp b/apps/openmw/mwlua/luaevents.cpp index b036fea3b6..02ea3415d2 100644 --- a/apps/openmw/mwlua/luaevents.cpp +++ b/apps/openmw/mwlua/luaevents.cpp @@ -52,7 +52,7 @@ namespace MWLua } template - static void saveEvent(ESM::ESMWriter& esm, const ESM::RefNum& dest, const Event& event) + static void saveEvent(ESM::ESMWriter& esm, ESM::RefNum dest, const Event& event) { esm.writeHNString("LUAE", event.mEventName); esm.writeFormId(dest, true); diff --git a/apps/openmw/mwlua/object.hpp b/apps/openmw/mwlua/object.hpp index fcf225de85..b42b092302 100644 --- a/apps/openmw/mwlua/object.hpp +++ b/apps/openmw/mwlua/object.hpp @@ -16,7 +16,7 @@ namespace MWLua // ObjectId is a unique identifier of a game object. // It can change only if the order of content files was change. using ObjectId = ESM::RefNum; - inline const ObjectId& getId(const MWWorld::Ptr& ptr) + inline ObjectId getId(const MWWorld::Ptr& ptr) { return ptr.getCellRef().getRefNum(); } diff --git a/apps/openmw/mwlua/objectlists.cpp b/apps/openmw/mwlua/objectlists.cpp index 40b1ab93fa..e7b3bb2e06 100644 --- a/apps/openmw/mwlua/objectlists.cpp +++ b/apps/openmw/mwlua/objectlists.cpp @@ -75,7 +75,7 @@ namespace MWLua if (mChanged) { mList->clear(); - for (const ObjectId& id : mSet) + for (ObjectId id : mSet) mList->push_back(id); mChanged = false; } diff --git a/apps/openmw/mwlua/userdataserializer.cpp b/apps/openmw/mwlua/userdataserializer.cpp index 6565ee0bde..478f725d7c 100644 --- a/apps/openmw/mwlua/userdataserializer.cpp +++ b/apps/openmw/mwlua/userdataserializer.cpp @@ -52,7 +52,7 @@ namespace MWLua { std::vector buf; buf.reserve(objList->size()); - for (const ESM::RefNum& v : *objList) + for (ESM::RefNum v : *objList) buf.push_back({ Misc::toLittleEndian(v.mIndex), Misc::toLittleEndian(v.mContentFile) }); append(out, sObjListTypeName, buf.data(), buf.size() * sizeof(ESM::RefNum)); } diff --git a/apps/openmw/mwrender/objectpaging.cpp b/apps/openmw/mwrender/objectpaging.cpp index 3579badee2..385ce46fff 100644 --- a/apps/openmw/mwrender/objectpaging.cpp +++ b/apps/openmw/mwrender/objectpaging.cpp @@ -437,7 +437,7 @@ namespace MWRender class AddRefnumMarkerVisitor : public osg::NodeVisitor { public: - AddRefnumMarkerVisitor(const ESM::RefNum& refnum) + AddRefnumMarkerVisitor(ESM::RefNum refnum) : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN) , mRefnum(refnum) { @@ -896,7 +896,7 @@ namespace MWRender }; bool ObjectPaging::enableObject( - int type, const ESM::RefNum& refnum, const osg::Vec3f& pos, const osg::Vec2i& cell, bool enabled) + int type, ESM::RefNum refnum, const osg::Vec3f& pos, const osg::Vec2i& cell, bool enabled) { if (!typeFilter(type, false)) return false; @@ -923,8 +923,7 @@ namespace MWRender return true; } - bool ObjectPaging::blacklistObject( - int type, const ESM::RefNum& refnum, const osg::Vec3f& pos, const osg::Vec2i& cell) + bool ObjectPaging::blacklistObject(int type, ESM::RefNum refnum, const osg::Vec3f& pos, const osg::Vec2i& cell) { if (!typeFilter(type, false)) return false; diff --git a/apps/openmw/mwrender/objectpaging.hpp b/apps/openmw/mwrender/objectpaging.hpp index d677c172f2..6085887b9c 100644 --- a/apps/openmw/mwrender/objectpaging.hpp +++ b/apps/openmw/mwrender/objectpaging.hpp @@ -41,11 +41,10 @@ namespace MWRender unsigned int getNodeMask() override; /// @return true if view needs rebuild - bool enableObject( - int type, const ESM::RefNum& refnum, const osg::Vec3f& pos, const osg::Vec2i& cell, bool enabled); + bool enableObject(int type, ESM::RefNum refnum, const osg::Vec3f& pos, const osg::Vec2i& cell, bool enabled); /// @return true if view needs rebuild - bool blacklistObject(int type, const ESM::RefNum& refnum, const osg::Vec3f& pos, const osg::Vec2i& cell); + bool blacklistObject(int type, ESM::RefNum refnum, const osg::Vec3f& pos, const osg::Vec2i& cell); void clear(); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index c9750ec0b9..6155325410 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -1644,7 +1644,7 @@ namespace MWRender { if (!ptr.isInCell() || !ptr.getCell()->isExterior() || !mObjectPaging) return; - const ESM::RefNum& refnum = ptr.getCellRef().getRefNum(); + ESM::RefNum refnum = ptr.getCellRef().getRefNum(); if (!refnum.hasContentFile()) return; if (mObjectPaging->blacklistObject(type, refnum, ptr.getCellRef().getPosition().asVec3(), diff --git a/apps/openmw/mwworld/cellref.cpp b/apps/openmw/mwworld/cellref.cpp index 35a04574ee..d9a017fe68 100644 --- a/apps/openmw/mwworld/cellref.cpp +++ b/apps/openmw/mwworld/cellref.cpp @@ -30,17 +30,17 @@ namespace MWWorld { } - const ESM::RefNum& CellRef::getRefNum() const noexcept + ESM::RefNum CellRef::getRefNum() const noexcept { return std::visit(ESM::VisitOverload{ - [&](const ESM4::Reference& ref) -> const ESM::RefNum& { return ref.mId; }, - [&](const ESM4::ActorCharacter& ref) -> const ESM::RefNum& { return ref.mId; }, - [&](const ESM::CellRef& ref) -> const ESM::RefNum& { return ref.mRefNum; }, + [&](const ESM4::Reference& ref) -> ESM::RefNum { return ref.mId; }, + [&](const ESM4::ActorCharacter& ref) -> ESM::RefNum { return ref.mId; }, + [&](const ESM::CellRef& ref) -> ESM::RefNum { return ref.mRefNum; }, }, mCellRef.mVariant); } - const ESM::RefNum& CellRef::getOrAssignRefNum(ESM::RefNum& lastAssignedRefNum) + ESM::RefNum CellRef::getOrAssignRefNum(ESM::RefNum& lastAssignedRefNum) { ESM::RefNum& refNum = std::visit(ESM::VisitOverload{ [&](ESM4::Reference& ref) -> ESM::RefNum& { return ref.mId; }, diff --git a/apps/openmw/mwworld/cellref.hpp b/apps/openmw/mwworld/cellref.hpp index 1943fd9b54..954babe481 100644 --- a/apps/openmw/mwworld/cellref.hpp +++ b/apps/openmw/mwworld/cellref.hpp @@ -27,11 +27,11 @@ namespace MWWorld explicit CellRef(const ESM4::ActorCharacter& ref); // Note: Currently unused for items in containers - const ESM::RefNum& getRefNum() const noexcept; + ESM::RefNum getRefNum() const noexcept; // Returns RefNum. // If RefNum is not set, assigns a generated one and changes the "lastAssignedRefNum" counter. - const ESM::RefNum& getOrAssignRefNum(ESM::RefNum& lastAssignedRefNum); + ESM::RefNum getOrAssignRefNum(ESM::RefNum& lastAssignedRefNum); void setRefNum(ESM::RefNum refNum); diff --git a/apps/openmw/mwworld/cellreflist.hpp b/apps/openmw/mwworld/cellreflist.hpp index 12f086e15d..187fff4287 100644 --- a/apps/openmw/mwworld/cellreflist.hpp +++ b/apps/openmw/mwworld/cellreflist.hpp @@ -38,7 +38,7 @@ namespace MWWorld } /// Remove all references with the given refNum from this list. - void remove(const ESM::RefNum& refNum) + void remove(ESM::RefNum refNum) { for (typename List::iterator it = mList.begin(); it != mList.end();) { diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index 61de2ab90d..f7ec3ddcba 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -660,10 +660,10 @@ namespace MWWorld class RefNumSearchVisitor { - const ESM::RefNum& mRefNum; + ESM::RefNum mRefNum; public: - RefNumSearchVisitor(const ESM::RefNum& refNum) + RefNumSearchVisitor(ESM::RefNum refNum) : mRefNum(refNum) { } diff --git a/apps/openmw/mwworld/ptrregistry.hpp b/apps/openmw/mwworld/ptrregistry.hpp index b640a22bfe..c5ce371538 100644 --- a/apps/openmw/mwworld/ptrregistry.hpp +++ b/apps/openmw/mwworld/ptrregistry.hpp @@ -45,7 +45,7 @@ namespace MWWorld void remove(const LiveCellRefBase& ref) noexcept { - const ESM::RefNum& refNum = ref.mRef.getRefNum(); + ESM::RefNum refNum = ref.mRef.getRefNum(); if (!refNum.isSet()) return; auto it = mIndex.find(refNum); diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index b5aff875bd..3d96de6749 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -111,7 +111,7 @@ namespace std::string model = getModel(ptr); const auto rotation = makeDirectNodeRotation(ptr); - const ESM::RefNum& refnum = ptr.getCellRef().getRefNum(); + ESM::RefNum refnum = ptr.getCellRef().getRefNum(); if (!refnum.hasContentFile() || !std::binary_search(pagedRefs.begin(), pagedRefs.end(), refnum)) ptr.getClass().insertObjectRendering(ptr, model, rendering); else @@ -259,7 +259,7 @@ namespace return false; } - bool removeFromSorted(const ESM::RefNum& refNum, std::vector& pagedRefs) + bool removeFromSorted(ESM::RefNum refNum, std::vector& pagedRefs) { const auto it = std::lower_bound(pagedRefs.begin(), pagedRefs.end(), refNum); if (it == pagedRefs.end() || *it != refNum) @@ -274,7 +274,7 @@ namespace MWWorld void Scene::removeFromPagedRefs(const Ptr& ptr) { - const ESM::RefNum& refnum = ptr.getCellRef().getRefNum(); + ESM::RefNum refnum = ptr.getCellRef().getRefNum(); if (refnum.hasContentFile() && removeFromSorted(refnum, mPagedRefs)) { if (!ptr.getRefData().getBaseNode()) diff --git a/components/resource/foreachbulletobject.cpp b/components/resource/foreachbulletobject.cpp index dbad2aea62..b936e39a2a 100644 --- a/components/resource/foreachbulletobject.cpp +++ b/components/resource/foreachbulletobject.cpp @@ -79,8 +79,7 @@ namespace Resource Log(Debug::Debug) << "Loaded " << cellRefs.size() << " cell refs"; - const auto getKey - = [](const EsmLoader::Record& v) -> const ESM::RefNum& { return v.mValue.mRefNum; }; + const auto getKey = [](const EsmLoader::Record& v) -> ESM::RefNum { return v.mValue.mRefNum; }; std::vector result = prepareRecords(cellRefs, getKey); Log(Debug::Debug) << "Prepared " << result.size() << " unique cell refs";