mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 15:09:39 +00:00
Use enums in place of magic numbers. Ensure Creature and NPC cell references are always saved as persistent.
This commit is contained in:
parent
f8aefc7f0b
commit
4b3de46bfa
6 changed files with 17 additions and 8 deletions
|
@ -342,8 +342,12 @@ void CSMDoc::WriteCellCollectionStage::perform (int stage, Messages& messages)
|
||||||
|
|
||||||
CSMWorld::CellRef refRecord = ref.get();
|
CSMWorld::CellRef refRecord = ref.get();
|
||||||
|
|
||||||
|
CSMWorld::RefIdData::LocalIndex localIndex = refIdData.searchId(refRecord.mRefID);
|
||||||
unsigned int recordFlags = refIdData.getRecordFlags(refRecord.mRefID);
|
unsigned int recordFlags = refIdData.getRecordFlags(refRecord.mRefID);
|
||||||
bool isPersistent = ((recordFlags & 0x00000400) != 0) || refRecord.mTeleport;
|
bool isPersistent = ((recordFlags & ESM::FLAG_Persistent) != 0)
|
||||||
|
|| refRecord.mTeleport
|
||||||
|
|| localIndex.second == CSMWorld::UniversalId::Type_Creature
|
||||||
|
|| localIndex.second == CSMWorld::UniversalId::Type_Npc;
|
||||||
|
|
||||||
if (isPersistent)
|
if (isPersistent)
|
||||||
persistentRefs.push_back(*iter);
|
persistentRefs.push_back(*iter);
|
||||||
|
|
|
@ -153,7 +153,7 @@ namespace CSMWorld
|
||||||
return QString::fromUtf8 (record.get().mModel.c_str());
|
return QString::fromUtf8 (record.get().mModel.c_str());
|
||||||
|
|
||||||
if (column==mModel.mPersistence)
|
if (column==mModel.mPersistence)
|
||||||
return (record.get().mRecordFlags & 0x00000400) != 0;
|
return (record.get().mRecordFlags & ESM::FLAG_Persistent) != 0;
|
||||||
|
|
||||||
return BaseRefIdAdapter<RecordT>::getData (column, data, index);
|
return BaseRefIdAdapter<RecordT>::getData (column, data, index);
|
||||||
}
|
}
|
||||||
|
@ -171,9 +171,9 @@ namespace CSMWorld
|
||||||
else if (column==mModel.mPersistence)
|
else if (column==mModel.mPersistence)
|
||||||
{
|
{
|
||||||
if (value.toInt() != 0)
|
if (value.toInt() != 0)
|
||||||
record2.mRecordFlags |= 0x00000400;
|
record2.mRecordFlags |= ESM::FLAG_Persistent;
|
||||||
else
|
else
|
||||||
record2.mRecordFlags &= ~0x00000400;
|
record2.mRecordFlags &= ~ESM::FLAG_Persistent;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -588,7 +588,7 @@ namespace MWClass
|
||||||
bool Creature::isPersistent(const MWWorld::ConstPtr &actor) const
|
bool Creature::isPersistent(const MWWorld::ConstPtr &actor) const
|
||||||
{
|
{
|
||||||
const MWWorld::LiveCellRef<ESM::Creature>* ref = actor.get<ESM::Creature>();
|
const MWWorld::LiveCellRef<ESM::Creature>* ref = actor.get<ESM::Creature>();
|
||||||
return (ref->mBase->mRecordFlags & 0x0400) != 0;
|
return (ref->mBase->mRecordFlags & ESM::FLAG_Persistent) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Creature::getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const
|
std::string Creature::getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const
|
||||||
|
|
|
@ -403,7 +403,7 @@ namespace MWClass
|
||||||
bool Npc::isPersistent(const MWWorld::ConstPtr &actor) const
|
bool Npc::isPersistent(const MWWorld::ConstPtr &actor) const
|
||||||
{
|
{
|
||||||
const MWWorld::LiveCellRef<ESM::NPC>* ref = actor.get<ESM::NPC>();
|
const MWWorld::LiveCellRef<ESM::NPC>* ref = actor.get<ESM::NPC>();
|
||||||
return (ref->mBase->mRecordFlags & 0x0400) != 0;
|
return (ref->mBase->mRecordFlags & ESM::FLAG_Persistent) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Npc::getModel(const MWWorld::ConstPtr &ptr) const
|
std::string Npc::getModel(const MWWorld::ConstPtr &ptr) const
|
||||||
|
|
|
@ -16,6 +16,11 @@ enum Version
|
||||||
VER_13 = 0x3fa66666
|
VER_13 = 0x3fa66666
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum RecordFlag
|
||||||
|
{
|
||||||
|
FLAG_Persistent = 0x00000400,
|
||||||
|
FLAG_Blocked = 0x00002000
|
||||||
|
};
|
||||||
|
|
||||||
// CRTP for FIXED_STRING class, a structure used for holding fixed-length strings
|
// CRTP for FIXED_STRING class, a structure used for holding fixed-length strings
|
||||||
template< template<size_t> class DERIVED, size_t SIZE>
|
template< template<size_t> class DERIVED, size_t SIZE>
|
||||||
|
|
|
@ -12,8 +12,8 @@ namespace ESM
|
||||||
{
|
{
|
||||||
isDeleted = false;
|
isDeleted = false;
|
||||||
mRecordFlags = esm.getRecordFlags();
|
mRecordFlags = esm.getRecordFlags();
|
||||||
//bool isBlocked = (mRecordFlags & 0x00002000) != 0;
|
//bool isBlocked = (mRecordFlags & ESM::FLAG_Blocked) != 0;
|
||||||
//bool isPersistent = (mRecordFlags & 0x00000400) != 0;
|
//bool isPersistent = (mRecordFlags & ESM::FLAG_Persistent) != 0;
|
||||||
|
|
||||||
bool hasName = false;
|
bool hasName = false;
|
||||||
while (esm.hasMoreSubs())
|
while (esm.hasMoreSubs())
|
||||||
|
|
Loading…
Reference in a new issue