Use Messages::add in Faction, Sound, Bodypart and Class record verifiers

This commit is contained in:
Capostrophic 2018-08-25 03:49:10 +03:00
parent d433929194
commit 8dcb58d745
4 changed files with 24 additions and 27 deletions

View File

@ -34,24 +34,23 @@ void CSMTools::BodyPartCheckStage::perform (int stage, CSMDoc::Messages &message
// Check BYDT // Check BYDT
if (bodyPart.mData.mPart > 14 ) if (bodyPart.mData.mPart > 14 )
messages.push_back(std::make_pair(id, "Invalid mesh part")); messages.add(id, "Invalid part", "", CSMDoc::Message::Severity_Error);
if (bodyPart.mData.mFlags > 3 ) if (bodyPart.mData.mFlags > 3 )
messages.push_back(std::make_pair(id, "Invalid flags")); messages.add(id, "Invalid flags", "", CSMDoc::Message::Severity_Error);
if (bodyPart.mData.mType > 2 ) if (bodyPart.mData.mType > 2 )
messages.push_back(std::make_pair(id, "Invalid type")); messages.add(id, "Invalid type", "", CSMDoc::Message::Severity_Error);
// Check MODL // Check MODL
if ( bodyPart.mModel.empty() ) if ( bodyPart.mModel.empty() )
messages.push_back(std::make_pair(id, "Model is missing" )); messages.add(id, "Model is missing", "", CSMDoc::Message::Severity_Error);
else if ( mMeshes.searchId( bodyPart.mModel ) == -1 ) else if ( mMeshes.searchId( bodyPart.mModel ) == -1 )
messages.push_back(std::make_pair(id, "Model '" + bodyPart.mModel + "' does not exist")); messages.add(id, "Model '" + bodyPart.mModel + "' does not exist", "", CSMDoc::Message::Severity_Error);
// Check FNAM // Check FNAM
if ( bodyPart.mRace.empty() ) if ( bodyPart.mRace.empty() )
messages.push_back(std::make_pair(id, "Race is missing" )); messages.add(id, "Race is missing", "", CSMDoc::Message::Severity_Error);
else if ( mRaces.searchId( bodyPart.mRace ) == -1 ) else if ( mRaces.searchId( bodyPart.mRace ) == -1 )
messages.push_back(std::make_pair(id, "Race '" + bodyPart.mRace + " does not exist")); messages.add(id, "Race '" + bodyPart.mRace + " does not exist", "", CSMDoc::Message::Severity_Error);
} }

View File

@ -1,6 +1,5 @@
#include "classcheck.hpp" #include "classcheck.hpp"
#include <sstream>
#include <map> #include <map>
#include <components/esm/loadclas.hpp> #include <components/esm/loadclas.hpp>
@ -37,26 +36,24 @@ void CSMTools::ClassCheckStage::perform (int stage, CSMDoc::Messages& messages)
// A class should have a name // A class should have a name
if (class_.mName.empty()) if (class_.mName.empty())
messages.push_back (std::make_pair (id, "Name is missing")); messages.add(id, "Name is missing", "", CSMDoc::Message::Severity_Warning);
// A playable class should have a description // A playable class should have a description
if (class_.mData.mIsPlayable != 0 && class_.mDescription.empty()) if (class_.mData.mIsPlayable != 0 && class_.mDescription.empty())
messages.push_back (std::make_pair (id, "Description of a playable class is missing")); messages.add(id, "Description of a playable class is missing", "", CSMDoc::Message::Severity_Warning);
// test for invalid attributes // test for invalid attributes
for (int i=0; i<2; ++i) for (int i=0; i<2; ++i)
{
if (class_.mData.mAttribute[i]==-1) if (class_.mData.mAttribute[i]==-1)
{ {
std::ostringstream stream; messages.add(id, "Attribute #" + std::to_string(i) + " is not set", "", CSMDoc::Message::Severity_Error);
}
stream << "Attribute #" << i << " is not set";
messages.push_back (std::make_pair (id, stream.str()));
} }
if (class_.mData.mAttribute[0]==class_.mData.mAttribute[1] && class_.mData.mAttribute[0]!=-1) if (class_.mData.mAttribute[0]==class_.mData.mAttribute[1] && class_.mData.mAttribute[0]!=-1)
{ {
messages.push_back (std::make_pair (id, "Same attribute is listed twice")); messages.add(id, "Same attribute is listed twice", "", CSMDoc::Message::Severity_Warning);
} }
// test for non-unique skill // test for non-unique skill
@ -67,8 +64,10 @@ void CSMTools::ClassCheckStage::perform (int stage, CSMDoc::Messages& messages)
++skills[class_.mData.mSkills[i][i2]]; ++skills[class_.mData.mSkills[i][i2]];
for (auto &skill : skills) for (auto &skill : skills)
{
if (skill.second>1) if (skill.second>1)
{ {
messages.push_back (std::make_pair (id, "Skill " + ESM::Skill::indexToId (skill.first) + " is listed more than once")); messages.add(id, "Skill " + ESM::Skill::indexToId (skill.first) + " is listed more than once", "", CSMDoc::Message::Severity_Warning);
}
} }
} }

View File

@ -37,12 +37,12 @@ void CSMTools::FactionCheckStage::perform (int stage, CSMDoc::Messages& messages
// test for empty name // test for empty name
if (faction.mName.empty()) if (faction.mName.empty())
messages.push_back (std::make_pair (id, "Name is missing")); messages.add(id, "Name is missing", "", CSMDoc::Message::Severity_Warning);
// test for invalid attributes // test for invalid attributes
if (faction.mData.mAttribute[0]==faction.mData.mAttribute[1] && faction.mData.mAttribute[0]!=-1) if (faction.mData.mAttribute[0]==faction.mData.mAttribute[1] && faction.mData.mAttribute[0]!=-1)
{ {
messages.push_back (std::make_pair (id, "Same attribute is listed twice")); messages.add(id, "Same attribute is listed twice", "", CSMDoc::Message::Severity_Warning);
} }
// test for non-unique skill // test for non-unique skill
@ -55,7 +55,7 @@ void CSMTools::FactionCheckStage::perform (int stage, CSMDoc::Messages& messages
for (auto &skill : skills) for (auto &skill : skills)
if (skill.second>1) if (skill.second>1)
{ {
messages.push_back (std::make_pair (id, "Skill " + ESM::Skill::indexToId (skill.first) + " is listed more than once")); messages.add(id, "Skill " + ESM::Skill::indexToId (skill.first) + " is listed more than once", "", CSMDoc::Message::Severity_Warning);
} }
/// \todo check data members that can't be edited in the table view /// \todo check data members that can't be edited in the table view

View File

@ -1,12 +1,9 @@
#include "soundcheck.hpp" #include "soundcheck.hpp"
#include <sstream>
#include <components/esm/loadskil.hpp> #include <components/esm/loadskil.hpp>
#include "../prefs/state.hpp" #include "../prefs/state.hpp"
#include "../world/data.hpp"
#include "../world/resources.hpp" #include "../world/resources.hpp"
#include "../world/universalid.hpp" #include "../world/universalid.hpp"
@ -38,14 +35,16 @@ void CSMTools::SoundCheckStage::perform (int stage, CSMDoc::Messages& messages)
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Sound, sound.mId); CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Sound, sound.mId);
if (sound.mData.mMinRange>sound.mData.mMaxRange) if (sound.mData.mMinRange>sound.mData.mMaxRange)
messages.push_back (std::make_pair (id, "Minimum range larger than maximum range")); {
messages.add(id, "Minimum range larger than maximum range", "", CSMDoc::Message::Severity_Warning);
}
if (sound.mSound.empty()) if (sound.mSound.empty())
{ {
messages.push_back(std::make_pair(id, "Sound file is missing")); messages.add(id, "Sound file is missing", "", CSMDoc::Message::Severity_Error);
} }
else if (mSoundFiles.searchId(sound.mSound) == -1) else if (mSoundFiles.searchId(sound.mSound) == -1)
{ {
messages.push_back(std::make_pair(id, "Sound file '" + sound.mSound + "' does not exist")); messages.add(id, "Sound file '" + sound.mSound + "' does not exist", "", CSMDoc::Message::Severity_Error);
} }
} }