2013-04-09 10:44:49 +00:00
|
|
|
#include "spellcheck.hpp"
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include <components/esm/loadspel.hpp>
|
|
|
|
|
2018-06-19 22:20:03 +00:00
|
|
|
#include "../prefs/state.hpp"
|
|
|
|
|
2013-04-09 10:44:49 +00:00
|
|
|
#include "../world/universalid.hpp"
|
|
|
|
|
|
|
|
CSMTools::SpellCheckStage::SpellCheckStage (const CSMWorld::IdCollection<ESM::Spell>& spells)
|
|
|
|
: mSpells (spells)
|
2018-06-19 22:20:03 +00:00
|
|
|
{
|
2018-06-20 09:29:38 +00:00
|
|
|
mIgnoreBaseRecords = false;
|
2018-06-19 22:20:03 +00:00
|
|
|
}
|
2013-04-09 10:44:49 +00:00
|
|
|
|
|
|
|
int CSMTools::SpellCheckStage::setup()
|
|
|
|
{
|
2018-06-19 22:20:03 +00:00
|
|
|
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
|
|
|
|
|
2013-04-09 10:44:49 +00:00
|
|
|
return mSpells.getSize();
|
|
|
|
}
|
|
|
|
|
2014-12-07 17:57:47 +00:00
|
|
|
void CSMTools::SpellCheckStage::perform (int stage, CSMDoc::Messages& messages)
|
2013-04-09 10:44:49 +00:00
|
|
|
{
|
2013-09-27 08:08:09 +00:00
|
|
|
const CSMWorld::Record<ESM::Spell>& record = mSpells.getRecord (stage);
|
|
|
|
|
2018-06-19 22:20:03 +00:00
|
|
|
// Skip "Base" records (setting!) and "Deleted" records
|
2018-06-20 09:29:38 +00:00
|
|
|
if ((mIgnoreBaseRecords && record.mState == CSMWorld::RecordBase::State_BaseOnly) || record.isDeleted())
|
2013-09-27 08:08:09 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
const ESM::Spell& spell = record.get();
|
2013-04-09 10:44:49 +00:00
|
|
|
|
|
|
|
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Spell, spell.mId);
|
|
|
|
|
|
|
|
// test for empty name and description
|
|
|
|
if (spell.mName.empty())
|
2018-08-24 21:27:42 +00:00
|
|
|
messages.push_back (std::make_pair (id, "Name is missing"));
|
2013-04-09 10:44:49 +00:00
|
|
|
|
|
|
|
// test for invalid cost values
|
|
|
|
if (spell.mData.mCost<0)
|
2018-08-24 21:27:42 +00:00
|
|
|
messages.push_back (std::make_pair (id, "Spell cost is negative"));
|
2013-04-09 10:44:49 +00:00
|
|
|
|
|
|
|
/// \todo check data members that can't be edited in the table view
|
2015-03-11 14:54:45 +00:00
|
|
|
}
|