Implement basic enchantment record verifier (feature #1617)
parent
dabdb0bfaf
commit
015cd6064f
@ -0,0 +1,42 @@
|
||||
#include "enchantmentcheck.hpp"
|
||||
|
||||
#include "../prefs/state.hpp"
|
||||
|
||||
#include "../world/universalid.hpp"
|
||||
|
||||
CSMTools::EnchantmentCheckStage::EnchantmentCheckStage (const CSMWorld::IdCollection<ESM::Enchantment>& enchantments)
|
||||
: mEnchantments (enchantments)
|
||||
{
|
||||
mIgnoreBaseRecords = false;
|
||||
}
|
||||
|
||||
int CSMTools::EnchantmentCheckStage::setup()
|
||||
{
|
||||
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
|
||||
|
||||
return mEnchantments.getSize();
|
||||
}
|
||||
|
||||
void CSMTools::EnchantmentCheckStage::perform (int stage, CSMDoc::Messages& messages)
|
||||
{
|
||||
const CSMWorld::Record<ESM::Enchantment>& record = mEnchantments.getRecord (stage);
|
||||
|
||||
// Skip "Base" records (setting!) and "Deleted" records
|
||||
if ((mIgnoreBaseRecords && record.mState == CSMWorld::RecordBase::State_BaseOnly) || record.isDeleted())
|
||||
return;
|
||||
|
||||
const ESM::Enchantment& enchantment = record.get();
|
||||
|
||||
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Enchantment, enchantment.mId);
|
||||
|
||||
if (enchantment.mData.mType < 0 || enchantment.mData.mType > 3)
|
||||
messages.add(id, "Invalid type", "", CSMDoc::Message::Severity_Error);
|
||||
|
||||
if (enchantment.mData.mCost < 0)
|
||||
messages.add(id, "Cost is negative", "", CSMDoc::Message::Severity_Error);
|
||||
|
||||
if (enchantment.mData.mCharge < 0)
|
||||
messages.add(id, "Charge is negative", "", CSMDoc::Message::Severity_Error);
|
||||
|
||||
/// \todo Check effects list for validity
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
#ifndef CSM_TOOLS_ENCHANTMENTCHECK_H
|
||||
#define CSM_TOOLS_ENCHANTMENTCHECK_H
|
||||
|
||||
#include <components/esm/loadench.hpp>
|
||||
|
||||
#include "../world/idcollection.hpp"
|
||||
|
||||
#include "../doc/stage.hpp"
|
||||
|
||||
namespace CSMTools
|
||||
{
|
||||
/// \brief Make sure that enchantment records are correct
|
||||
class EnchantmentCheckStage : public CSMDoc::Stage
|
||||
{
|
||||
const CSMWorld::IdCollection<ESM::Enchantment>& mEnchantments;
|
||||
bool mIgnoreBaseRecords;
|
||||
|
||||
public:
|
||||
|
||||
EnchantmentCheckStage (const CSMWorld::IdCollection<ESM::Enchantment>& enchantments);
|
||||
|
||||
virtual int setup();
|
||||
///< \return number of steps
|
||||
|
||||
virtual void perform (int stage, CSMDoc::Messages& messages);
|
||||
///< Messages resulting from this tage will be appended to \a messages.
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue