1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 20:53:53 +00:00
openmw/apps/opencs/model/tools/spellcheck.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.5 KiB
C++
Raw Normal View History

2013-04-09 10:44:49 +00:00
#include "spellcheck.hpp"
2022-10-19 17:02:00 +00:00
#include <string>
#include <apps/opencs/model/doc/messages.hpp>
#include <apps/opencs/model/prefs/category.hpp>
#include <apps/opencs/model/prefs/setting.hpp>
#include <apps/opencs/model/world/idcollection.hpp>
#include <apps/opencs/model/world/record.hpp>
#include <apps/opencs/model/world/universalid.hpp>
#include <components/esm3/loadspel.hpp>
2013-04-09 10:44:49 +00:00
#include "../prefs/state.hpp"
2013-04-09 10:44:49 +00:00
CSMTools::SpellCheckStage::SpellCheckStage(const CSMWorld::IdCollection<ESM::Spell>& spells)
: mSpells(spells)
{
mIgnoreBaseRecords = false;
}
2013-04-09 10:44:49 +00:00
int CSMTools::SpellCheckStage::setup()
{
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
2013-04-09 10:44:49 +00:00
return mSpells.getSize();
}
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);
// Skip "Base" records (setting!) and "Deleted" records
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
2013-04-09 10:44:49 +00:00
if (spell.mName.empty())
messages.add(id, "Name is missing", "", CSMDoc::Message::Severity_Error);
2013-04-09 10:44:49 +00:00
// test for invalid cost values
if (spell.mData.mCost < 0)
messages.add(id, "Spell cost is negative", "", CSMDoc::Message::Severity_Error);
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
}