1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 21:49:55 +00:00
openmw-tes3mp/apps/opencs/model/tools/spellcheck.cpp
Atahualpa c0fc615cd6 Adds the option to ignore "Base" records when running the verifier. (fixes #4466)
Improves previous commit:
1. Initialise mIgnoreBase boolean member with FALSE.
2. Remove isBaseOnly() function and replace with direct use of Record member.
2018-06-20 11:29:38 +02:00

46 lines
1.3 KiB
C++

#include "spellcheck.hpp"
#include <sstream>
#include <map>
#include <components/esm/loadspel.hpp>
#include "../prefs/state.hpp"
#include "../world/universalid.hpp"
CSMTools::SpellCheckStage::SpellCheckStage (const CSMWorld::IdCollection<ESM::Spell>& spells)
: mSpells (spells)
{
mIgnoreBaseRecords = false;
}
int CSMTools::SpellCheckStage::setup()
{
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
return mSpells.getSize();
}
void CSMTools::SpellCheckStage::perform (int stage, CSMDoc::Messages& messages)
{
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())
return;
const ESM::Spell& spell = record.get();
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Spell, spell.mId);
// test for empty name and description
if (spell.mName.empty())
messages.push_back (std::make_pair (id, spell.mId + " has an empty name"));
// test for invalid cost values
if (spell.mData.mCost<0)
messages.push_back (std::make_pair (id, spell.mId + " has a negative spell costs"));
/// \todo check data members that can't be edited in the table view
}