mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 13:23:52 +00:00
added verifier stage for skill records
This commit is contained in:
parent
739e7e7298
commit
dc67ddf39b
4 changed files with 70 additions and 1 deletions
|
@ -35,7 +35,7 @@ opencs_units (model/tools
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (model/tools
|
opencs_units_noqt (model/tools
|
||||||
stage verifier mandatoryid
|
stage verifier mandatoryid skillcheck
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
37
apps/opencs/model/tools/skillcheck.cpp
Normal file
37
apps/opencs/model/tools/skillcheck.cpp
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
|
||||||
|
#include "skillcheck.hpp"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include <components/esm/loadskil.hpp>
|
||||||
|
|
||||||
|
#include "../world/universalid.hpp"
|
||||||
|
|
||||||
|
CSMTools::SkillCheckStage::SkillCheckStage (const CSMWorld::IdCollection<ESM::Skill>& skills)
|
||||||
|
: mSkills (skills)
|
||||||
|
{}
|
||||||
|
|
||||||
|
int CSMTools::SkillCheckStage::setup()
|
||||||
|
{
|
||||||
|
return mSkills.getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMTools::SkillCheckStage::perform (int stage, std::vector<std::string>& messages)
|
||||||
|
{
|
||||||
|
const ESM::Skill& skill = mSkills.getRecord (stage).get();
|
||||||
|
|
||||||
|
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Skill, skill.mId);
|
||||||
|
|
||||||
|
for (int i=0; i<4; ++i)
|
||||||
|
if (skill.mData.mUseValue[i]<0)
|
||||||
|
{
|
||||||
|
std::ostringstream stream;
|
||||||
|
|
||||||
|
stream << id.toString() << "|Use value #" << i << " of " << skill.mId << " is negative";
|
||||||
|
|
||||||
|
messages.push_back (stream.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skill.mDescription.empty())
|
||||||
|
messages.push_back (id.toString() + "|" + skill.mId + " has an empty description");
|
||||||
|
}
|
29
apps/opencs/model/tools/skillcheck.hpp
Normal file
29
apps/opencs/model/tools/skillcheck.hpp
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef CSM_TOOLS_SKILLCHECK_H
|
||||||
|
#define CSM_TOOLS_SKILLCHECK_H
|
||||||
|
|
||||||
|
#include <components/esm/loadskil.hpp>
|
||||||
|
|
||||||
|
#include "../world/idcollection.hpp"
|
||||||
|
|
||||||
|
#include "stage.hpp"
|
||||||
|
|
||||||
|
namespace CSMTools
|
||||||
|
{
|
||||||
|
/// \brief VerifyStage: make sure that skill records are internally consistent
|
||||||
|
class SkillCheckStage : public Stage
|
||||||
|
{
|
||||||
|
const CSMWorld::IdCollection<ESM::Skill>& mSkills;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SkillCheckStage (const CSMWorld::IdCollection<ESM::Skill>& skills);
|
||||||
|
|
||||||
|
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
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include "reportmodel.hpp"
|
#include "reportmodel.hpp"
|
||||||
#include "mandatoryid.hpp"
|
#include "mandatoryid.hpp"
|
||||||
|
#include "skillcheck.hpp"
|
||||||
|
|
||||||
CSMTools::Operation *CSMTools::Tools::get (int type)
|
CSMTools::Operation *CSMTools::Tools::get (int type)
|
||||||
{
|
{
|
||||||
|
@ -51,6 +52,8 @@ CSMTools::Verifier *CSMTools::Tools::getVerifier()
|
||||||
|
|
||||||
mVerifier->appendStage (new MandatoryIdStage (mData.getGlobals(),
|
mVerifier->appendStage (new MandatoryIdStage (mData.getGlobals(),
|
||||||
CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Globals), mandatoryIds));
|
CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Globals), mandatoryIds));
|
||||||
|
|
||||||
|
mVerifier->appendStage (new SkillCheckStage (mData.getSkills()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return mVerifier;
|
return mVerifier;
|
||||||
|
|
Loading…
Reference in a new issue