1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 11:53:53 +00:00

Add a separate method to check whether a record is deleted or not for IdCollection

This commit is contained in:
Stanislav Bas 2015-07-18 15:55:24 +03:00
parent 5fd48efd28
commit a4d3e59e5c
6 changed files with 52 additions and 22 deletions

View file

@ -0,0 +1,3 @@
#include "idcollection.hpp"

View file

@ -2,9 +2,9 @@
#define CSM_WOLRD_IDCOLLECTION_H
#include <components/esm/esmreader.hpp>
#include <components/esm/util.hpp>
#include "collection.hpp"
#include "record.hpp"
namespace CSMWorld
{
@ -48,7 +48,7 @@ namespace CSMWorld
std::string id = IdAccessorT().getId (record);
int index = searchId (id);
if (ESM::isRecordDeleted (record))
if (isRecordDeleted(record))
{
if (index==-1)
{

View file

@ -4,7 +4,6 @@
#include <string>
#include <boost/shared_ptr.hpp>
#include <components/esm/loadland.hpp>
#include <components/esm/util.hpp>
namespace CSMWorld
{
@ -27,13 +26,4 @@ namespace CSMWorld
};
}
namespace ESM
{
template <>
bool isRecordDeleted<CSMWorld::Land>(const CSMWorld::Land &land)
{
return false;
}
}
#endif

View file

@ -5,7 +5,6 @@
#include <string>
#include <components/esm/loadpgrd.hpp>
#include <components/esm/util.hpp>
namespace CSMWorld
{
@ -27,13 +26,4 @@ namespace CSMWorld
};
}
namespace ESM
{
template <>
bool isRecordDeleted<CSMWorld::Pathgrid>(const CSMWorld::Pathgrid &pgrd)
{
return false;
}
}
#endif

View file

@ -19,3 +19,27 @@ bool CSMWorld::RecordBase::isModified() const
{
return mState==State_Modified || mState==State_ModifiedOnly;
}
template<>
bool CSMWorld::isRecordDeleted(const CSMWorld::Land &land)
{
return land.mLand->mIsDeleted;
}
template<>
bool CSMWorld::isRecordDeleted(const ESM::GameSetting &setting)
{
return false;
}
template<>
bool CSMWorld::isRecordDeleted(const ESM::MagicEffect &effect)
{
return false;
}
template<>
bool CSMWorld::isRecordDeleted(const ESM::Skill &skill)
{
return false;
}

View file

@ -3,6 +3,12 @@
#include <stdexcept>
#include <components/esm/loadgmst.hpp>
#include <components/esm/loadmgef.hpp>
#include <components/esm/loadskil.hpp>
#include "land.hpp"
namespace CSMWorld
{
struct RecordBase
@ -154,6 +160,23 @@ namespace CSMWorld
mState = State_Erased;
}
}
// Not all records can be deleted (may be changed in the future),
// so we need to use a separate method to check whether a record is deleted or not.
template<typename ESXRecordT>
bool isRecordDeleted(const ESXRecordT &record)
{
return record.mIsDeleted;
}
template<>
bool isRecordDeleted(const Land &land);
template<>
bool isRecordDeleted(const ESM::GameSetting &setting);
template<>
bool isRecordDeleted(const ESM::MagicEffect &effect);
template<>
bool isRecordDeleted(const ESM::Skill &skill);
}
#endif