Use default initializers for ESM::RefNum members

Instead of unset function that is removed now and assignments all over the code.
7220-lua-add-a-general-purpose-lexical-parser
elsid 2 years ago
parent 42a3b3ca49
commit c173348cbe
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -11,7 +11,7 @@ namespace ESSImport
{ {
out.mId = ESM::RefId::stringRefId(scpt.mSCHD.mName.toString()); out.mId = ESM::RefId::stringRefId(scpt.mSCHD.mName.toString());
out.mRunning = scpt.mRunning; out.mRunning = scpt.mRunning;
out.mTargetRef.unset(); // TODO: convert target reference of global script out.mTargetRef = ESM::RefNum{}; // TODO: convert target reference of global script
convertSCRI(scpt.mSCRI, out.mLocals); convertSCRI(scpt.mSCRI, out.mLocals);
} }

@ -19,7 +19,6 @@ namespace ESSImport
item.mCount = contItem.mCount; item.mCount = contItem.mCount;
item.mRelativeEquipmentSlot = -1; item.mRelativeEquipmentSlot = -1;
item.mLockLevel = 0; item.mLockLevel = 0;
item.mRefNum.unset();
unsigned int itemCount = std::abs(item.mCount); unsigned int itemCount = std::abs(item.mCount);
bool separateStacks = false; bool separateStacks = false;

@ -56,7 +56,6 @@ void CSMWorld::RefCollection::load(ESM::ESMReader& reader, int cellIndex, bool b
CellRef ref; CellRef ref;
ref.mNew = false; ref.mNew = false;
ESM::MovedCellRef mref; ESM::MovedCellRef mref;
mref.mRefNum.mIndex = 0;
bool isDeleted = false; bool isDeleted = false;
bool isMoved = false; bool isMoved = false;

@ -52,8 +52,8 @@ namespace MWLua
void saveEvents(ESM::ESMWriter& esm, const GlobalEventQueue& globalEvents, const LocalEventQueue& localEvents) void saveEvents(ESM::ESMWriter& esm, const GlobalEventQueue& globalEvents, const LocalEventQueue& localEvents)
{ {
ObjectId globalId; // Used as a marker of a global event.
globalId.unset(); // Used as a marker of a global event. constexpr ObjectId globalId;
for (const GlobalEvent& e : globalEvents) for (const GlobalEvent& e : globalEvents)
saveEvent(esm, globalId, e); saveEvent(esm, globalId, e);

@ -149,7 +149,6 @@ namespace MWMechanics
params.mEffects = mEffects; params.mEffects = mEffects;
params.mDisplayName = mDisplayName; params.mDisplayName = mDisplayName;
params.mCasterActorId = mCasterActorId; params.mCasterActorId = mCasterActorId;
params.mItem.unset();
if (mSlot) if (mSlot)
{ {
// Note that we're storing the inventory slot as a RefNum instead of an int as a matter of future proofing // Note that we're storing the inventory slot as a RefNum instead of an int as a matter of future proofing

@ -211,7 +211,6 @@ namespace MWRender
const ESM::ReadersCache::BusyItem reader = readers.get(index); const ESM::ReadersCache::BusyItem reader = readers.get(index);
cell.restore(*reader, i); cell.restore(*reader, i);
ESM::CellRef ref; ESM::CellRef ref;
ref.mRefNum.unset();
bool deleted = false; bool deleted = false;
while (cell.getNextRef(*reader, ref, deleted)) while (cell.getNextRef(*reader, ref, deleted))
{ {

@ -494,9 +494,7 @@ namespace MWRender
const ESM::ReadersCache::BusyItem reader = readers.get(index); const ESM::ReadersCache::BusyItem reader = readers.get(index);
cell->restore(*reader, i); cell->restore(*reader, i);
ESM::CellRef ref; ESM::CellRef ref;
ref.mRefNum.unset();
ESM::MovedCellRef cMRef; ESM::MovedCellRef cMRef;
cMRef.mRefNum.mIndex = 0;
bool deleted = false; bool deleted = false;
bool moved = false; bool moved = false;
while (ESM::Cell::getNextRef( while (ESM::Cell::getNextRef(

@ -94,7 +94,6 @@ namespace MWRender
RefnumMarker() RefnumMarker()
: mNumVertices(0) : mNumVertices(0)
{ {
mRefnum.unset();
} }
RefnumMarker(const RefnumMarker& copy, osg::CopyOp co) RefnumMarker(const RefnumMarker& copy, osg::CopyOp co)
: mRefnum(copy.mRefnum) : mRefnum(copy.mRefnum)

@ -1078,7 +1078,6 @@ namespace MWRender
{ {
RenderingManager::RayResult result; RenderingManager::RayResult result;
result.mHit = false; result.mHit = false;
result.mHitRefnum.unset();
result.mRatio = 0; result.mRatio = 0;
if (intersector->containsIntersections()) if (intersector->containsIntersections())
{ {

@ -22,7 +22,6 @@ namespace
ESM::GlobalScript operator()(const MWWorld::Ptr& ptr) const ESM::GlobalScript operator()(const MWWorld::Ptr& ptr) const
{ {
ESM::GlobalScript script; ESM::GlobalScript script;
script.mTargetRef.unset();
script.mRunning = false; script.mRunning = false;
if (!ptr.isEmpty()) if (!ptr.isEmpty())
{ {

@ -30,7 +30,7 @@ namespace MWWorld
void CellRef::unsetRefNum() void CellRef::unsetRefNum()
{ {
mCellRef.mRefNum.unset(); mCellRef.mRefNum = ESM::RefNum{};
} }
void CellRef::setScale(float scale) void CellRef::setScale(float scale)

@ -693,7 +693,6 @@ namespace MWWorld
// Get each reference in turn // Get each reference in turn
ESM::MovedCellRef cMRef; ESM::MovedCellRef cMRef;
cMRef.mRefNum.mIndex = 0;
bool deleted = false; bool deleted = false;
bool moved = false; bool moved = false;
while (ESM::Cell::getNextRef( while (ESM::Cell::getNextRef(
@ -750,11 +749,8 @@ namespace MWWorld
mCell->restore(*reader, i); mCell->restore(*reader, i);
ESM::CellRef ref; ESM::CellRef ref;
ref.mRefNum.unset();
// Get each reference in turn // Get each reference in turn
ESM::MovedCellRef cMRef; ESM::MovedCellRef cMRef;
cMRef.mRefNum.mIndex = 0;
bool deleted = false; bool deleted = false;
bool moved = false; bool moved = false;
while (ESM::Cell::getNextRef( while (ESM::Cell::getNextRef(

@ -49,7 +49,6 @@ namespace
const ESM::ReadersCache::BusyItem reader = readers.get(index); const ESM::ReadersCache::BusyItem reader = readers.get(index);
cell.restore(*reader, i); cell.restore(*reader, i);
ESM::CellRef ref; ESM::CellRef ref;
ref.mRefNum.unset();
bool deleted = false; bool deleted = false;
while (cell.getNextRef(*reader, ref, deleted)) while (cell.getNextRef(*reader, ref, deleted))
{ {

@ -62,7 +62,6 @@ namespace MWWorld
ESM::ActiveSpells::ActiveSpellParams params; ESM::ActiveSpells::ActiveSpellParams params;
params.mId = id; params.mId = id;
params.mDisplayName = spell->mName; params.mDisplayName = spell->mName;
params.mItem.unset();
params.mCasterActorId = creatureStats.mActorId; params.mCasterActorId = creatureStats.mActorId;
if (spell->mData.mType == ESM::Spell::ST_Ability) if (spell->mData.mType == ESM::Spell::ST_Ability)
params.mType = ESM::ActiveSpells::Type_Ability; params.mType = ESM::ActiveSpells::Type_Ability;

@ -89,7 +89,7 @@ void MWWorld::WorldModel::clear()
{ {
mPtrIndex.clear(); mPtrIndex.clear();
mPtrIndexUpdateCounter = 0; mPtrIndexUpdateCounter = 0;
mLastGeneratedRefnum.unset(); mLastGeneratedRefnum = ESM::RefNum{};
mInteriors.clear(); mInteriors.clear();
mExteriors.clear(); mExteriors.clear();
std::fill(mIdCache.begin(), mIdCache.end(), std::make_pair(ESM::RefId::sEmpty, (MWWorld::CellStore*)nullptr)); std::fill(mIdCache.begin(), mIdCache.end(), std::make_pair(ESM::RefId::sEmpty, (MWWorld::CellStore*)nullptr));
@ -155,7 +155,6 @@ MWWorld::WorldModel::WorldModel(const MWWorld::ESMStore& store, ESM::ReadersCach
, mIdCacheIndex(0) , mIdCacheIndex(0)
, mPtrIndexUpdateCounter(0) , mPtrIndexUpdateCounter(0)
{ {
mLastGeneratedRefnum.unset();
int cacheSize = std::clamp(Settings::Manager::getInt("pointers cache size", "Cells"), 40, 1000); int cacheSize = std::clamp(Settings::Manager::getInt("pointers cache size", "Cells"), 40, 1000);
mIdCache = IdCache(cacheSize, std::pair<ESM::RefId, CellStore*>(ESM::RefId::sEmpty, (CellStore*)nullptr)); mIdCache = IdCache(cacheSize, std::pair<ESM::RefId, CellStore*>(ESM::RefId::sEmpty, (CellStore*)nullptr));
} }

@ -50,7 +50,6 @@ namespace ESM
params.mId = esm.getRefId(); params.mId = esm.getRefId();
esm.getHNT(params.mCasterActorId, "CAST"); esm.getHNT(params.mCasterActorId, "CAST");
params.mDisplayName = esm.getHNString("DISP"); params.mDisplayName = esm.getHNString("DISP");
params.mItem.unset();
if (format < 17) if (format < 17)
params.mType = ActiveSpells::Type_Temporary; params.mType = ActiveSpells::Type_Temporary;
else else

@ -258,7 +258,7 @@ namespace ESM
void CellRef::blank() void CellRef::blank()
{ {
mRefNum.unset(); mRefNum = RefNum{};
mRefID = ESM::RefId::sEmpty; mRefID = ESM::RefId::sEmpty;
mScale = 1; mScale = 1;
mOwner = ESM::RefId::sEmpty; mOwner = ESM::RefId::sEmpty;

@ -17,8 +17,8 @@ namespace ESM
struct RefNum struct RefNum
{ {
unsigned int mIndex; unsigned int mIndex = 0;
int mContentFile; int mContentFile = -1;
void load(ESMReader& esm, bool wide = false, NAME tag = "FRMR"); void load(ESMReader& esm, bool wide = false, NAME tag = "FRMR");
@ -27,7 +27,6 @@ namespace ESM
inline bool hasContentFile() const { return mContentFile >= 0; } inline bool hasContentFile() const { return mContentFile >= 0; }
inline bool isSet() const { return mIndex != 0 || mContentFile != -1; } inline bool isSet() const { return mIndex != 0 || mContentFile != -1; }
inline void unset() { *this = { 0, -1 }; }
}; };
/* Cell reference. This represents ONE object (of many) inside the /* Cell reference. This represents ONE object (of many) inside the

@ -15,7 +15,7 @@ namespace ESM
mRunning = 0; mRunning = 0;
esm.getHNOT(mRunning, "RUN_"); esm.getHNOT(mRunning, "RUN_");
mTargetRef.unset(); mTargetRef = RefNum{};
mTargetId = ESM::RefId::stringRefId(esm.getHNOString("TARG")); mTargetId = ESM::RefId::stringRefId(esm.getHNOString("TARG"));
if (esm.peekNextSub("FRMR")) if (esm.peekNextSub("FRMR"))
mTargetRef.load(esm, true, "FRMR"); mTargetRef.load(esm, true, "FRMR");

Loading…
Cancel
Save