Use blank CellRef as default

Default constructed CellRef has some fields uninitialized.
pull/3236/head
elsid 7 months ago
parent d998faec1b
commit 1cdbbef7ee
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -533,7 +533,7 @@ namespace MWRender
: CharacterPreview( : CharacterPreview(
parent, resourceSystem, MWMechanics::getPlayer(), 512, 512, osg::Vec3f(0, 125, 8), osg::Vec3f(0, 0, 8)) parent, resourceSystem, MWMechanics::getPlayer(), 512, 512, osg::Vec3f(0, 125, 8), osg::Vec3f(0, 0, 8))
, mBase(*mCharacter.get<ESM::NPC>()->mBase) , mBase(*mCharacter.get<ESM::NPC>()->mBase)
, mRef(&mBase) , mRef(ESM::makeBlankCellRef(), &mBase)
, mPitchRadians(osg::DegreesToRadians(6.f)) , mPitchRadians(osg::DegreesToRadians(6.f))
{ {
mCharacter = MWWorld::Ptr(&mRef, nullptr); mCharacter = MWWorld::Ptr(&mRef, nullptr);

@ -317,7 +317,7 @@ namespace
} }
// new reference // new reference
MWWorld::LiveCellRef<T> ref(record); MWWorld::LiveCellRef<T> ref(ESM::makeBlankCellRef(), record);
ref.load(state); ref.load(state);
collection.mList.push_back(std::move(ref)); collection.mList.push_back(std::move(ref));

@ -101,7 +101,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::getState(
if (!record) if (!record)
return ContainerStoreIterator(this); return ContainerStoreIterator(this);
LiveCellRef<T> ref(record); LiveCellRef<T> ref(ESM::makeBlankCellRef(), record);
ref.load(state); ref.load(state);
collection.mList.push_back(std::move(ref)); collection.mList.push_back(std::move(ref));
auto it = ContainerStoreIterator(this, --collection.mList.end()); auto it = ContainerStoreIterator(this, --collection.mList.end());

@ -37,7 +37,7 @@ namespace MWWorld
WorldModel* mWorldModel = nullptr; 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::Reference& cref);
LiveCellRefBase(unsigned int type, const ESM4::ActorCharacter& 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. // The object that this instance is based on.
const X* mBase; const X* mBase;

@ -36,8 +36,20 @@
namespace MWWorld 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) Player::Player(const ESM::NPC* player)
: mCellStore(nullptr) : mPlayer(makePlayerCellRef(), player)
, mCellStore(nullptr)
, mLastKnownExteriorPosition(0, 0, 0) , mLastKnownExteriorPosition(0, 0, 0)
, mMarkedPosition(ESM::Position()) , mMarkedPosition(ESM::Position())
, mMarkedCell(nullptr) , mMarkedCell(nullptr)
@ -46,11 +58,6 @@ namespace MWWorld
, mPaidCrimeId(-1) , mPaidCrimeId(-1)
, mJumping(false) , mJumping(false)
{ {
ESM::CellRef cellRef;
cellRef.blank();
cellRef.mRefID = ESM::RefId::stringRefId("Player");
mPlayer = LiveCellRef<ESM::NPC>(cellRef, player);
ESM::Position playerPos = mPlayer.mData.getPosition(); ESM::Position playerPos = mPlayer.mData.getPosition();
playerPos.pos[0] = playerPos.pos[1] = playerPos.pos[2] = 0; playerPos.pos[0] = playerPos.pos[1] = playerPos.pos[2] = 0;
mPlayer.mData.setPosition(playerPos); mPlayer.mData.setPosition(playerPos);

@ -287,4 +287,10 @@ namespace ESM
loadDataImpl<false>(esm, isDeleted, cellRef); loadDataImpl<false>(esm, isDeleted, cellRef);
} }
CellRef makeBlankCellRef()
{
CellRef result;
result.blank();
return result;
}
} }

@ -105,6 +105,8 @@ namespace ESM
}; };
void skipLoadCellRef(ESMReader& esm, bool wideRefNum = false); void skipLoadCellRef(ESMReader& esm, bool wideRefNum = false);
CellRef makeBlankCellRef();
} }
#endif #endif

Loading…
Cancel
Save