mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
added verifier for spell record
This commit is contained in:
parent
ae0a7d5bcd
commit
40bb772e34
4 changed files with 68 additions and 1 deletions
|
@ -36,7 +36,7 @@ opencs_units (model/tools
|
||||||
|
|
||||||
opencs_units_noqt (model/tools
|
opencs_units_noqt (model/tools
|
||||||
stage verifier mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck
|
stage verifier mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck
|
||||||
birthsigncheck
|
birthsigncheck spellcheck
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
35
apps/opencs/model/tools/spellcheck.cpp
Normal file
35
apps/opencs/model/tools/spellcheck.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
|
||||||
|
#include "spellcheck.hpp"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include <components/esm/loadspel.hpp>
|
||||||
|
|
||||||
|
#include "../world/universalid.hpp"
|
||||||
|
|
||||||
|
CSMTools::SpellCheckStage::SpellCheckStage (const CSMWorld::IdCollection<ESM::Spell>& spells)
|
||||||
|
: mSpells (spells)
|
||||||
|
{}
|
||||||
|
|
||||||
|
int CSMTools::SpellCheckStage::setup()
|
||||||
|
{
|
||||||
|
return mSpells.getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMTools::SpellCheckStage::perform (int stage, std::vector<std::string>& messages)
|
||||||
|
{
|
||||||
|
const ESM::Spell& spell = mSpells.getRecord (stage).get();
|
||||||
|
|
||||||
|
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Spell, spell.mId);
|
||||||
|
|
||||||
|
// test for empty name and description
|
||||||
|
if (spell.mName.empty())
|
||||||
|
messages.push_back (id.toString() + "|" + spell.mId + " has an empty name");
|
||||||
|
|
||||||
|
// test for invalid cost values
|
||||||
|
if (spell.mData.mCost<0)
|
||||||
|
messages.push_back (id.toString() + "|" + spell.mId + " has a negative spell costs");
|
||||||
|
|
||||||
|
/// \todo check data members that can't be edited in the table view
|
||||||
|
}
|
29
apps/opencs/model/tools/spellcheck.hpp
Normal file
29
apps/opencs/model/tools/spellcheck.hpp
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef CSM_TOOLS_SPELLCHECK_H
|
||||||
|
#define CSM_TOOLS_SPELLCHECK_H
|
||||||
|
|
||||||
|
#include <components/esm/loadspel.hpp>
|
||||||
|
|
||||||
|
#include "../world/idcollection.hpp"
|
||||||
|
|
||||||
|
#include "stage.hpp"
|
||||||
|
|
||||||
|
namespace CSMTools
|
||||||
|
{
|
||||||
|
/// \brief VerifyStage: make sure that spell records are internally consistent
|
||||||
|
class SpellCheckStage : public Stage
|
||||||
|
{
|
||||||
|
const CSMWorld::IdCollection<ESM::Spell>& mSpells;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SpellCheckStage (const CSMWorld::IdCollection<ESM::Spell>& spells);
|
||||||
|
|
||||||
|
virtual int setup();
|
||||||
|
///< \return number of steps
|
||||||
|
|
||||||
|
virtual void perform (int stage, std::vector<std::string>& messages);
|
||||||
|
///< Messages resulting from this tage will be appended to \a messages.
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -19,6 +19,7 @@
|
||||||
#include "soundcheck.hpp"
|
#include "soundcheck.hpp"
|
||||||
#include "regioncheck.hpp"
|
#include "regioncheck.hpp"
|
||||||
#include "birthsigncheck.hpp"
|
#include "birthsigncheck.hpp"
|
||||||
|
#include "spellcheck.hpp"
|
||||||
|
|
||||||
CSMTools::Operation *CSMTools::Tools::get (int type)
|
CSMTools::Operation *CSMTools::Tools::get (int type)
|
||||||
{
|
{
|
||||||
|
@ -72,6 +73,8 @@ CSMTools::Verifier *CSMTools::Tools::getVerifier()
|
||||||
mVerifier->appendStage (new RegionCheckStage (mData.getRegions()));
|
mVerifier->appendStage (new RegionCheckStage (mData.getRegions()));
|
||||||
|
|
||||||
mVerifier->appendStage (new BirthsignCheckStage (mData.getBirthsigns()));
|
mVerifier->appendStage (new BirthsignCheckStage (mData.getBirthsigns()));
|
||||||
|
|
||||||
|
mVerifier->appendStage (new SpellCheckStage (mData.getSpells()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return mVerifier;
|
return mVerifier;
|
||||||
|
|
Loading…
Reference in a new issue