mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 07:23:54 +00:00
Implement basic enchantment record verifier (feature #1617)
This commit is contained in:
parent
dabdb0bfaf
commit
015cd6064f
5 changed files with 80 additions and 3 deletions
|
@ -42,7 +42,7 @@ opencs_units_noqt (model/tools
|
||||||
mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck
|
mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck
|
||||||
birthsigncheck spellcheck referencecheck referenceablecheck scriptcheck bodypartcheck
|
birthsigncheck spellcheck referencecheck referenceablecheck scriptcheck bodypartcheck
|
||||||
startscriptcheck search searchoperation searchstage pathgridcheck soundgencheck magiceffectcheck
|
startscriptcheck search searchoperation searchstage pathgridcheck soundgencheck magiceffectcheck
|
||||||
mergestages gmstcheck topicinfocheck journalcheck
|
mergestages gmstcheck topicinfocheck journalcheck enchantmentcheck
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_hdrs_noqt (model/tools
|
opencs_hdrs_noqt (model/tools
|
||||||
|
|
42
apps/opencs/model/tools/enchantmentcheck.cpp
Normal file
42
apps/opencs/model/tools/enchantmentcheck.cpp
Normal file
|
@ -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
|
||||||
|
}
|
30
apps/opencs/model/tools/enchantmentcheck.hpp
Normal file
30
apps/opencs/model/tools/enchantmentcheck.hpp
Normal file
|
@ -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
|
|
@ -9,8 +9,10 @@ std::string CSMTools::MagicEffectCheckStage::checkObject(const std::string &id,
|
||||||
const std::string &column) const
|
const std::string &column) const
|
||||||
{
|
{
|
||||||
CSMWorld::RefIdData::LocalIndex index = mObjects.getDataSet().searchId(id);
|
CSMWorld::RefIdData::LocalIndex index = mObjects.getDataSet().searchId(id);
|
||||||
if (index.first == -1) return (column + " '" + id + "' " + "does not exist");
|
if (index.first == -1)
|
||||||
else if (index.second != type.getType()) return (column + " '" + id + "' " + "does not have " + type.getTypeName() + " type");
|
return (column + " '" + id + "' does not exist");
|
||||||
|
else if (index.second != type.getType())
|
||||||
|
return (column + " '" + id + "' does not have " + type.getTypeName() + " type");
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "gmstcheck.hpp"
|
#include "gmstcheck.hpp"
|
||||||
#include "topicinfocheck.hpp"
|
#include "topicinfocheck.hpp"
|
||||||
#include "journalcheck.hpp"
|
#include "journalcheck.hpp"
|
||||||
|
#include "enchantmentcheck.hpp"
|
||||||
|
|
||||||
CSMDoc::OperationHolder *CSMTools::Tools::get (int type)
|
CSMDoc::OperationHolder *CSMTools::Tools::get (int type)
|
||||||
{
|
{
|
||||||
|
@ -128,6 +129,8 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier()
|
||||||
|
|
||||||
mVerifierOperation->appendStage (new JournalCheckStage(mData.getJournals(), mData.getJournalInfos()));
|
mVerifierOperation->appendStage (new JournalCheckStage(mData.getJournals(), mData.getJournalInfos()));
|
||||||
|
|
||||||
|
mVerifierOperation->appendStage (new EnchantmentCheckStage(mData.getEnchantments()));
|
||||||
|
|
||||||
mVerifier.setOperation (mVerifierOperation);
|
mVerifier.setOperation (mVerifierOperation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue