diff --git a/apps/openmw/mwrender/characterpreview.cpp b/apps/openmw/mwrender/characterpreview.cpp index a4c0181d35..123eadfdec 100644 --- a/apps/openmw/mwrender/characterpreview.cpp +++ b/apps/openmw/mwrender/characterpreview.cpp @@ -533,7 +533,7 @@ namespace MWRender : CharacterPreview( parent, resourceSystem, MWMechanics::getPlayer(), 512, 512, osg::Vec3f(0, 125, 8), osg::Vec3f(0, 0, 8)) , mBase(*mCharacter.get()->mBase) - , mRef(&mBase) + , mRef(ESM::makeBlankCellRef(), &mBase) , mPitchRadians(osg::DegreesToRadians(6.f)) { mCharacter = MWWorld::Ptr(&mRef, nullptr); diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index c22f873fe9..4cd189bb20 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -317,7 +317,7 @@ namespace } // new reference - MWWorld::LiveCellRef ref(record); + MWWorld::LiveCellRef ref(ESM::makeBlankCellRef(), record); ref.load(state); collection.mList.push_back(std::move(ref)); diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 5e020ac886..5a7c5b5333 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -101,7 +101,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::getState( if (!record) return ContainerStoreIterator(this); - LiveCellRef ref(record); + LiveCellRef ref(ESM::makeBlankCellRef(), record); ref.load(state); collection.mList.push_back(std::move(ref)); auto it = ContainerStoreIterator(this, --collection.mList.end()); diff --git a/apps/openmw/mwworld/livecellref.hpp b/apps/openmw/mwworld/livecellref.hpp index f3b48c0ff1..026d3edefd 100644 --- a/apps/openmw/mwworld/livecellref.hpp +++ b/apps/openmw/mwworld/livecellref.hpp @@ -37,7 +37,7 @@ namespace MWWorld WorldModel* mWorldModel = nullptr; - LiveCellRefBase(unsigned int type, const ESM::CellRef& cref = ESM::CellRef()); + LiveCellRefBase(unsigned int type, const ESM::CellRef& cref); LiveCellRefBase(unsigned int type, const ESM4::Reference& cref); LiveCellRefBase(unsigned int type, const ESM4::ActorCharacter& cref); @@ -144,12 +144,6 @@ namespace MWWorld { } - LiveCellRef(const X* b = nullptr) - : LiveCellRefBase(X::sRecordId) - , mBase(b) - { - } - // The object that this instance is based on. const X* mBase; diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index f5d38e8686..b776f27f06 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -36,8 +36,20 @@ namespace MWWorld { + namespace + { + ESM::CellRef makePlayerCellRef() + { + ESM::CellRef result; + result.blank(); + result.mRefID = ESM::RefId::stringRefId("Player"); + return result; + } + } + Player::Player(const ESM::NPC* player) - : mCellStore(nullptr) + : mPlayer(makePlayerCellRef(), player) + , mCellStore(nullptr) , mLastKnownExteriorPosition(0, 0, 0) , mMarkedPosition(ESM::Position()) , mMarkedCell(nullptr) @@ -46,11 +58,6 @@ namespace MWWorld , mPaidCrimeId(-1) , mJumping(false) { - ESM::CellRef cellRef; - cellRef.blank(); - cellRef.mRefID = ESM::RefId::stringRefId("Player"); - mPlayer = LiveCellRef(cellRef, player); - ESM::Position playerPos = mPlayer.mData.getPosition(); playerPos.pos[0] = playerPos.pos[1] = playerPos.pos[2] = 0; mPlayer.mData.setPosition(playerPos); diff --git a/components/esm3/cellref.cpp b/components/esm3/cellref.cpp index 97ccfb730a..927f517495 100644 --- a/components/esm3/cellref.cpp +++ b/components/esm3/cellref.cpp @@ -287,4 +287,10 @@ namespace ESM loadDataImpl(esm, isDeleted, cellRef); } + CellRef makeBlankCellRef() + { + CellRef result; + result.blank(); + return result; + } } diff --git a/components/esm3/cellref.hpp b/components/esm3/cellref.hpp index 8b23cc5c34..683bde200d 100644 --- a/components/esm3/cellref.hpp +++ b/components/esm3/cellref.hpp @@ -105,6 +105,8 @@ namespace ESM }; void skipLoadCellRef(ESMReader& esm, bool wideRefNum = false); + + CellRef makeBlankCellRef(); } #endif