1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 07:53:53 +00:00

Use messages::add in object record verifiers

Add NPC head and hair body part existence checks and expand creature record verifier, update playable class checks in class record verifier
This commit is contained in:
Capostrophic 2018-08-26 13:00:39 +03:00
parent 85dc1e4ef2
commit d1b2fc11ef
4 changed files with 147 additions and 130 deletions

View file

@ -36,7 +36,12 @@ 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.add(id, "Name is missing", "", CSMDoc::Message::Severity_Warning); {
if (class_.mData.mIsPlayable != 0)
messages.add(id, "Name of a playable class is missing", "", CSMDoc::Message::Severity_Error);
else
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())

View file

@ -14,7 +14,8 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(
const CSMWorld::IdCollection<ESM::Faction>& faction, const CSMWorld::IdCollection<ESM::Faction>& faction,
const CSMWorld::IdCollection<ESM::Script>& scripts, const CSMWorld::IdCollection<ESM::Script>& scripts,
const CSMWorld::Resources& models, const CSMWorld::Resources& models,
const CSMWorld::Resources& icons) const CSMWorld::Resources& icons,
const CSMWorld::IdCollection<ESM::BodyPart>& bodyparts)
:mObjects(referenceable), :mObjects(referenceable),
mRaces(races), mRaces(races),
mClasses(classes), mClasses(classes),
@ -22,6 +23,7 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(
mScripts(scripts), mScripts(scripts),
mModels(models), mModels(models),
mIcons(icons), mIcons(icons),
mBodyParts(bodyparts),
mPlayerPresent(false) mPlayerPresent(false)
{ {
mIgnoreBaseRecords = false; mIgnoreBaseRecords = false;
@ -274,11 +276,10 @@ void CSMTools::ReferenceableCheckStage::activatorCheck(
const ESM::Activator& activator = (dynamic_cast<const CSMWorld::Record<ESM::Activator>& >(baseRecord)).get(); const ESM::Activator& activator = (dynamic_cast<const CSMWorld::Record<ESM::Activator>& >(baseRecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Activator, activator.mId); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Activator, activator.mId);
//Checking for model, IIRC all activators should have a model
if (activator.mModel.empty()) if (activator.mModel.empty())
messages.push_back (std::make_pair (id, "Model is missing")); messages.add(id, "Model is missing", "", CSMDoc::Message::Severity_Error);
else if (mModels.searchId(activator.mModel) == -1) else if (mModels.searchId(activator.mModel) == -1)
messages.push_back (std::make_pair (id, "Model '" + activator.mModel + "' does not exist")); messages.add(id, "Model '" + activator.mModel + "' does not exist", "", CSMDoc::Message::Severity_Error);
// Check that mentioned scripts exist // Check that mentioned scripts exist
scriptCheck<ESM::Activator>(activator, messages, id.toString()); scriptCheck<ESM::Activator>(activator, messages, id.toString());
@ -299,7 +300,6 @@ void CSMTools::ReferenceableCheckStage::potionCheck(
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Potion, potion.mId); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Potion, potion.mId);
inventoryItemCheck<ESM::Potion>(potion, messages, id.toString()); inventoryItemCheck<ESM::Potion>(potion, messages, id.toString());
//IIRC potion can have empty effects list just fine.
// Check that mentioned scripts exist // Check that mentioned scripts exist
scriptCheck<ESM::Potion>(potion, messages, id.toString()); scriptCheck<ESM::Potion>(potion, messages, id.toString());
@ -344,13 +344,13 @@ void CSMTools::ReferenceableCheckStage::armorCheck(
inventoryItemCheck<ESM::Armor>(armor, messages, id.toString(), true); inventoryItemCheck<ESM::Armor>(armor, messages, id.toString(), true);
//checking for armor class, armor should have poistive armor class, but 0 is considered legal // Armor should have positive armor class, but 0 class is not an error
if (armor.mData.mArmor < 0) if (armor.mData.mArmor < 0)
messages.push_back (std::make_pair (id, "Armor class is negative")); messages.add(id, "Armor class is negative", "", CSMDoc::Message::Severity_Error);
//checking for health. Only positive numbers are allowed, or 0 is illegal // Armor durability must be a positive number
if (armor.mData.mHealth <= 0) if (armor.mData.mHealth <= 0)
messages.push_back (std::make_pair (id, "Durability is non-positive")); messages.add(id, "Durability is non-positive", "", CSMDoc::Message::Severity_Error);
// Check that mentioned scripts exist // Check that mentioned scripts exist
scriptCheck<ESM::Armor>(armor, messages, id.toString()); scriptCheck<ESM::Armor>(armor, messages, id.toString());
@ -389,19 +389,19 @@ void CSMTools::ReferenceableCheckStage::containerCheck(
const ESM::Container& container = (dynamic_cast<const CSMWorld::Record<ESM::Container>& >(baseRecord)).get(); const ESM::Container& container = (dynamic_cast<const CSMWorld::Record<ESM::Container>& >(baseRecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Container, container.mId); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Container, container.mId);
//checking for name
if (container.mName.empty())
messages.add(id, "Name is missing", "", CSMDoc::Message::Severity_Error);
//Checking for model //Checking for model
if (container.mModel.empty()) if (container.mModel.empty())
messages.push_back (std::make_pair (id, "Model is missing")); messages.add(id, "Model is missing", "", CSMDoc::Message::Severity_Error);
else if (mModels.searchId(container.mModel) == -1) else if (mModels.searchId(container.mModel) == -1)
messages.push_back (std::make_pair (id, "Model '" + container.mModel + "' does not exist")); messages.add(id, "Model '" + container.mModel + "' does not exist", "", CSMDoc::Message::Severity_Error);
//Checking for capacity (weight) //Checking for capacity (weight)
if (container.mWeight < 0) //0 is allowed if (container.mWeight < 0) //0 is allowed
messages.push_back (std::make_pair (id, "Capacity is negative")); messages.add(id, "Capacity is negative", "", CSMDoc::Message::Severity_Error);
//checking for name
if (container.mName.empty())
messages.push_back (std::make_pair (id, "Name is missing"));
//checking contained items //checking contained items
inventoryListCheck(container.mInventory.mList, messages, id.toString()); inventoryListCheck(container.mInventory.mList, messages, id.toString());
@ -423,69 +423,81 @@ void CSMTools::ReferenceableCheckStage::creatureCheck (
const ESM::Creature& creature = (dynamic_cast<const CSMWorld::Record<ESM::Creature>&>(baseRecord)).get(); const ESM::Creature& creature = (dynamic_cast<const CSMWorld::Record<ESM::Creature>&>(baseRecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Creature, creature.mId); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Creature, creature.mId);
if (creature.mModel.empty())
messages.push_back (std::make_pair (id, "Model is missing"));
else if (mModels.searchId(creature.mModel) == -1)
messages.push_back (std::make_pair (id, "Model '" + creature.mModel + "' does not exist"));
if (creature.mName.empty()) if (creature.mName.empty())
messages.push_back (std::make_pair (id, "Name is missing")); messages.add(id, "Name is missing", "", CSMDoc::Message::Severity_Error);
if (creature.mModel.empty())
messages.add(id, "Model is missing", "", CSMDoc::Message::Severity_Error);
else if (mModels.searchId(creature.mModel) == -1)
messages.add(id, "Model '" + creature.mModel + "' does not exist", "", CSMDoc::Message::Severity_Error);
//stats checks //stats checks
if (creature.mData.mLevel < 1) if (creature.mData.mLevel <= 0)
messages.push_back (std::make_pair (id, "Level is non-positive")); messages.add(id, "Level is non-positive", "", CSMDoc::Message::Severity_Warning);
if (creature.mData.mStrength < 0) if (creature.mData.mStrength < 0)
messages.push_back (std::make_pair (id, "Strength is negative")); messages.add(id, "Strength is negative", "", CSMDoc::Message::Severity_Warning);
if (creature.mData.mIntelligence < 0) if (creature.mData.mIntelligence < 0)
messages.push_back (std::make_pair (id, "Intelligence is negative")); messages.add(id, "Intelligence is negative", "", CSMDoc::Message::Severity_Warning);
if (creature.mData.mWillpower < 0) if (creature.mData.mWillpower < 0)
messages.push_back (std::make_pair (id, "Willpower is negative")); messages.add(id, "Willpower is negative", "", CSMDoc::Message::Severity_Warning);
if (creature.mData.mAgility < 0) if (creature.mData.mAgility < 0)
messages.push_back (std::make_pair (id, "Agility is negative")); messages.add(id, "Agility is negative", "", CSMDoc::Message::Severity_Warning);
if (creature.mData.mSpeed < 0) if (creature.mData.mSpeed < 0)
messages.push_back (std::make_pair (id, "Speed is negative")); messages.add(id, "Speed is negative", "", CSMDoc::Message::Severity_Warning);
if (creature.mData.mEndurance < 0) if (creature.mData.mEndurance < 0)
messages.push_back (std::make_pair (id, "Endurance is negative")); messages.add(id, "Endurance is negative", "", CSMDoc::Message::Severity_Warning);
if (creature.mData.mPersonality < 0) if (creature.mData.mPersonality < 0)
messages.push_back (std::make_pair (id, "Personality is negative")); messages.add(id, "Personality is negative", "", CSMDoc::Message::Severity_Warning);
if (creature.mData.mLuck < 0) if (creature.mData.mLuck < 0)
messages.push_back (std::make_pair (id, "Luck is negative")); messages.add(id, "Luck is negative", "", CSMDoc::Message::Severity_Warning);
if (creature.mData.mCombat < 0)
messages.add(id, "Combat is negative", "", CSMDoc::Message::Severity_Warning);
if (creature.mData.mMagic < 0)
messages.add(id, "Magic is negative", "", CSMDoc::Message::Severity_Warning);
if (creature.mData.mStealth < 0)
messages.add(id, "Stealth is negative", "", CSMDoc::Message::Severity_Warning);
if (creature.mData.mHealth < 0) if (creature.mData.mHealth < 0)
messages.push_back (std::make_pair (id, "Health is negative")); messages.add(id, "Health is negative", "", CSMDoc::Message::Severity_Error);
if (creature.mData.mMana < 0)
messages.add(id, "Magicka is negative", "", CSMDoc::Message::Severity_Error);
if (creature.mData.mFatigue < 0)
messages.add(id, "Fatigue is negative", "", CSMDoc::Message::Severity_Error);
if (creature.mData.mSoul < 0) if (creature.mData.mSoul < 0)
messages.push_back (std::make_pair (id, "Soul value is negative")); messages.add(id, "Soul value is negative", "", CSMDoc::Message::Severity_Error);
for (int i = 0; i < 6; ++i) for (int i = 0; i < 6; ++i)
{ {
if (creature.mData.mAttack[i] < 0) if (creature.mData.mAttack[i] < 0)
{ messages.add(id, "Attack " + std::to_string(i/2 + 1) + " has negative" + (i % 2 == 0 ? " minimum " : " maximum ") + "damage", "", CSMDoc::Message::Severity_Error);
messages.push_back (std::make_pair (id, "One of attacks has negative damage")); if (i % 2 == 0 && creature.mData.mAttack[i] > creature.mData.mAttack[i+1])
break; messages.add(id, "Attack " + std::to_string(i/2 + 1) + " has minimum damage higher than maximum damage", "", CSMDoc::Message::Severity_Warning);
}
} }
//TODO, find meaning of other values
if (creature.mData.mGold < 0) if (creature.mData.mGold < 0)
messages.push_back (std::make_pair (id, "Gold count is negative")); messages.add(id, "Gold count is negative", "", CSMDoc::Message::Severity_Error);
if (creature.mScale == 0) if (creature.mScale == 0)
messages.push_back (std::make_pair (id, "Scale is equal to zero")); messages.add(id, "Scale is equal to zero", "", CSMDoc::Message::Severity_Error);
if (!creature.mOriginal.empty())
{
CSMWorld::RefIdData::LocalIndex index = mObjects.searchId(creature.mOriginal);
if (index.first == -1)
messages.add(id, "Parent creature '" + creature.mOriginal + "' does not exist", "", CSMDoc::Message::Severity_Error);
else if (index.second != CSMWorld::UniversalId::Type_Creature)
messages.add(id, "'" + creature.mOriginal + "' is not a creature", "", CSMDoc::Message::Severity_Error);
}
// Check inventory // Check inventory
inventoryListCheck(creature.mInventory.mList, messages, id.toString()); inventoryListCheck(creature.mInventory.mList, messages, id.toString());
// Check that mentioned scripts exist // Check that mentioned scripts exist
scriptCheck<ESM::Creature>(creature, messages, id.toString()); scriptCheck<ESM::Creature>(creature, messages, id.toString());
/// \todo Check spells, teleport table, AI data and AI packages for validity
} }
void CSMTools::ReferenceableCheckStage::doorCheck( void CSMTools::ReferenceableCheckStage::doorCheck(
@ -503,12 +515,12 @@ void CSMTools::ReferenceableCheckStage::doorCheck(
//usual, name or model //usual, name or model
if (door.mName.empty()) if (door.mName.empty())
messages.push_back (std::make_pair (id, "Name is missing")); messages.add(id, "Name is missing", "", CSMDoc::Message::Severity_Error);
if (door.mModel.empty()) if (door.mModel.empty())
messages.push_back (std::make_pair (id, "Model is missing")); messages.add(id, "Model is missing", "", CSMDoc::Message::Severity_Error);
else if (mModels.searchId(door.mModel) == -1) else if (mModels.searchId(door.mModel) == -1)
messages.push_back (std::make_pair (id, "Model '" + door.mModel + "' does not exist")); messages.add(id, "Model '" + door.mModel + "' does not exist", "", CSMDoc::Message::Severity_Error);
// Check that mentioned scripts exist // Check that mentioned scripts exist
scriptCheck<ESM::Door>(door, messages, id.toString()); scriptCheck<ESM::Door>(door, messages, id.toString());
@ -582,7 +594,7 @@ void CSMTools::ReferenceableCheckStage::lightCheck(
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Light, light.mId); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Light, light.mId);
if (light.mData.mRadius < 0) if (light.mData.mRadius < 0)
messages.push_back (std::make_pair (id, "Light radius is negative")); messages.add(id, "Light radius is negative", "", CSMDoc::Message::Severity_Error);
if (light.mData.mFlags & ESM::Light::Carry) if (light.mData.mFlags & ESM::Light::Carry)
inventoryItemCheck<ESM::Light>(light, messages, id.toString()); inventoryItemCheck<ESM::Light>(light, messages, id.toString());
@ -657,89 +669,87 @@ void CSMTools::ReferenceableCheckStage::npcCheck (
char disposition(npc.mNpdt.mDisposition); char disposition(npc.mNpdt.mDisposition);
char reputation(npc.mNpdt.mReputation); char reputation(npc.mNpdt.mReputation);
char rank(npc.mNpdt.mRank); char rank(npc.mNpdt.mRank);
//Don't know what unknown is for
int gold(npc.mNpdt.mGold); int gold(npc.mNpdt.mGold);
if (npc.mNpdtType == ESM::NPC::NPC_WITH_AUTOCALCULATED_STATS) //12 = autocalculated if (npc.mNpdtType == ESM::NPC::NPC_WITH_AUTOCALCULATED_STATS) //12 = autocalculated
{ {
if ((npc.mFlags & ESM::NPC::Autocalc) == 0) //0x0010 = autocalculated flag if ((npc.mFlags & ESM::NPC::Autocalc) == 0) //0x0010 = autocalculated flag
{ {
messages.push_back (std::make_pair (id, npc.mId + " mNpdtType or flags mismatch!")); //should not happen? messages.add(id, "NPC with autocalculated stats doesn't have autocalc flag turned on", "", CSMDoc::Message::Severity_Error); //should not happen?
return; return;
} }
level = npc.mNpdt.mLevel;
disposition = npc.mNpdt.mDisposition;
reputation = npc.mNpdt.mReputation;
rank = npc.mNpdt.mRank;
gold = npc.mNpdt.mGold;
} }
else else
{ {
if (npc.mNpdt.mAgility == 0)
messages.push_back (std::make_pair (id, "Agility is equal to zero"));
if (npc.mNpdt.mEndurance == 0)
messages.push_back (std::make_pair (id, "Endurance is equal to zero"));
if (npc.mNpdt.mIntelligence == 0)
messages.push_back (std::make_pair (id, "Intelligence is equal to zero"));
if (npc.mNpdt.mLuck == 0)
messages.push_back (std::make_pair (id, "Luck is equal to zero"));
if (npc.mNpdt.mPersonality == 0)
messages.push_back (std::make_pair (id, "Personality is equal to zero"));
if (npc.mNpdt.mStrength == 0) if (npc.mNpdt.mStrength == 0)
messages.push_back (std::make_pair (id, "Strength is equal to zero")); messages.add(id, "Strength is equal to zero", "", CSMDoc::Message::Severity_Warning);
if (npc.mNpdt.mIntelligence == 0)
if (npc.mNpdt.mSpeed == 0) messages.add(id, "Intelligence is equal to zero", "", CSMDoc::Message::Severity_Warning);
messages.push_back (std::make_pair (id, "Speed is equal to zero"));
if (npc.mNpdt.mWillpower == 0) if (npc.mNpdt.mWillpower == 0)
messages.push_back (std::make_pair (id, "Willpower is equal to zero")); messages.add(id, "Willpower is equal to zero", "", CSMDoc::Message::Severity_Warning);
if (npc.mNpdt.mAgility == 0)
messages.add(id, "Agility is equal to zero", "", CSMDoc::Message::Severity_Warning);
if (npc.mNpdt.mSpeed == 0)
messages.add(id, "Speed is equal to zero", "", CSMDoc::Message::Severity_Warning);
if (npc.mNpdt.mEndurance == 0)
messages.add(id, "Endurance is equal to zero", "", CSMDoc::Message::Severity_Warning);
if (npc.mNpdt.mPersonality == 0)
messages.add(id, "Personality is equal to zero", "", CSMDoc::Message::Severity_Warning);
if (npc.mNpdt.mLuck == 0)
messages.add(id, "Luck is equal to zero", "", CSMDoc::Message::Severity_Warning);
} }
if (level <= 0) if (level <= 0)
messages.push_back (std::make_pair (id, "Level is non-positive")); messages.add(id, "Level is non-positive", "", CSMDoc::Message::Severity_Warning);
if (gold < 0) if (gold < 0)
messages.push_back (std::make_pair (id, "Gold count is negative")); messages.add(id, "Gold count is negative", "", CSMDoc::Message::Severity_Error);
if (npc.mName.empty()) if (npc.mName.empty())
messages.push_back (std::make_pair (id, "Name is missing")); messages.add(id, "Name is missing", "", CSMDoc::Message::Severity_Error);
if (npc.mClass.empty()) if (npc.mClass.empty())
messages.push_back (std::make_pair (id, "Class is missing")); messages.add(id, "Class is missing", "", CSMDoc::Message::Severity_Error);
else if (mClasses.searchId (npc.mClass) == -1) else if (mClasses.searchId (npc.mClass) == -1)
messages.push_back (std::make_pair (id, "Class '" + npc.mClass + "' does not exist")); messages.add(id, "Class '" + npc.mClass + "' does not exist", "", CSMDoc::Message::Severity_Error);
if (npc.mRace.empty()) if (npc.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 (npc.mRace) == -1) else if (mRaces.searchId (npc.mRace) == -1)
messages.push_back (std::make_pair (id, "Race '" + npc.mRace + "' does not exist")); messages.add(id, "Race '" + npc.mRace + "' does not exist", "", CSMDoc::Message::Severity_Error);
if (disposition < 0) if (disposition < 0)
messages.push_back (std::make_pair (id, "Disposition is negative")); messages.add(id, "Disposition is negative", "", CSMDoc::Message::Severity_Warning);
if (reputation < 0) if (reputation < 0)
messages.push_back (std::make_pair (id, "Reputation is negative")); messages.add(id, "Reputation is negative", "", CSMDoc::Message::Severity_Warning);
if (!npc.mFaction.empty()) if (!npc.mFaction.empty())
{ {
if (rank < 0) if (rank < 0)
messages.push_back (std::make_pair (id, "Faction rank is negative")); messages.add(id, "Faction rank is negative", "", CSMDoc::Message::Severity_Warning);
if (mFactions.searchId(npc.mFaction) == -1) if (mFactions.searchId(npc.mFaction) == -1)
messages.push_back (std::make_pair (id, "Faction '" + npc.mFaction + "' does not exist")); messages.add(id, "Faction '" + npc.mFaction + "' does not exist", "", CSMDoc::Message::Severity_Error);
} }
if (npc.mHead.empty()) if (npc.mHead.empty())
messages.push_back (std::make_pair (id, "Head is missing")); // ADD CHECK HERE messages.push_back (std::make_pair (id, "Head is missing"));
else
{
if (mBodyParts.searchId(npc.mHead) == -1)
messages.add(id, "Head body part '" + npc.mHead + "' does not exist", "", CSMDoc::Message::Severity_Error);
/// \todo Check gender, race and other body parts stuff validity for the specific NPC
}
if (npc.mHair.empty()) if (npc.mHair.empty())
messages.push_back (std::make_pair (id, "Hair is missing")); // ADD CHECK HERE messages.push_back (std::make_pair (id, "Hair is missing"));
else
{
if (mBodyParts.searchId(npc.mHair) == -1)
messages.add(id, "Hair body part '" + npc.mHair + "' does not exist", "", CSMDoc::Message::Severity_Error);
/// \todo Check gender, race and other body part stuff validity for the specific NPC
}
// Check inventory // Check inventory
inventoryListCheck(npc.mInventory.mList, messages, id.toString()); inventoryListCheck(npc.mInventory.mList, messages, id.toString());
@ -799,14 +809,14 @@ void CSMTools::ReferenceableCheckStage::weaponCheck(
weapon.mData.mType == ESM::Weapon::Bolt)) weapon.mData.mType == ESM::Weapon::Bolt))
{ {
if (weapon.mData.mSlash[0] > weapon.mData.mSlash[1]) if (weapon.mData.mSlash[0] > weapon.mData.mSlash[1])
messages.push_back (std::make_pair (id, "Minimum slash damage higher than maximum")); messages.add(id, "Minimum slash damage higher than maximum", "", CSMDoc::Message::Severity_Warning);
if (weapon.mData.mThrust[0] > weapon.mData.mThrust[1]) if (weapon.mData.mThrust[0] > weapon.mData.mThrust[1])
messages.push_back (std::make_pair (id, "Minimum thrust damage is higher than maximum")); messages.add(id, "Minimum thrust damage higher than maximum", "", CSMDoc::Message::Severity_Warning);
} }
if (weapon.mData.mChop[0] > weapon.mData.mChop[1]) if (weapon.mData.mChop[0] > weapon.mData.mChop[1])
messages.push_back (std::make_pair (id, "Minimum chop damage is higher than maximum")); messages.add(id, "Minimum chop damage higher than maximum", "", CSMDoc::Message::Severity_Warning);
if (!(weapon.mData.mType == ESM::Weapon::Arrow || if (!(weapon.mData.mType == ESM::Weapon::Arrow ||
weapon.mData.mType == ESM::Weapon::Bolt || weapon.mData.mType == ESM::Weapon::Bolt ||
@ -814,10 +824,10 @@ void CSMTools::ReferenceableCheckStage::weaponCheck(
{ {
//checking of health //checking of health
if (weapon.mData.mHealth == 0) if (weapon.mData.mHealth == 0)
messages.push_back (std::make_pair (id, "Durability is equal to zero")); messages.add(id, "Durability is equal to zero", "", CSMDoc::Message::Severity_Warning);
if (weapon.mData.mReach < 0) if (weapon.mData.mReach < 0)
messages.push_back (std::make_pair (id, "Reach is negative")); messages.add(id, "Reach is negative", "", CSMDoc::Message::Severity_Error);
} }
} }
@ -880,9 +890,9 @@ void CSMTools::ReferenceableCheckStage::staticCheck (
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Static, staticElement.mId); CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Static, staticElement.mId);
if (staticElement.mModel.empty()) if (staticElement.mModel.empty())
messages.push_back (std::make_pair (id, "Model is missing")); messages.add(id, "Model is missing", "", CSMDoc::Message::Severity_Error);
else if (mModels.searchId(staticElement.mModel) == -1) else if (mModels.searchId(staticElement.mModel) == -1)
messages.push_back (std::make_pair (id, "Model '" + staticElement.mModel + "' does not exist")); messages.add(id, "Model '" + staticElement.mModel + "' does not exist", "", CSMDoc::Message::Severity_Error);
} }
//final check //final check
@ -890,8 +900,7 @@ void CSMTools::ReferenceableCheckStage::staticCheck (
void CSMTools::ReferenceableCheckStage::finalCheck (CSMDoc::Messages& messages) void CSMTools::ReferenceableCheckStage::finalCheck (CSMDoc::Messages& messages)
{ {
if (!mPlayerPresent) if (!mPlayerPresent)
messages.push_back (std::make_pair (CSMWorld::UniversalId::Type_Referenceables, messages.add(CSMWorld::UniversalId::Type_Referenceables, "Player record is missing", "", CSMDoc::Message::Severity_SeriousError);
"Player record is missing"));
} }
void CSMTools::ReferenceableCheckStage::inventoryListCheck( void CSMTools::ReferenceableCheckStage::inventoryListCheck(
@ -905,7 +914,7 @@ void CSMTools::ReferenceableCheckStage::inventoryListCheck(
CSMWorld::RefIdData::LocalIndex localIndex = mObjects.searchId(itemName); CSMWorld::RefIdData::LocalIndex localIndex = mObjects.searchId(itemName);
if (localIndex.first == -1) if (localIndex.first == -1)
messages.push_back (std::make_pair (id, "Item '" + itemName + "' does not exist")); messages.add(id, "Item '" + itemName + "' does not exist", "", CSMDoc::Message::Severity_Error);
else else
{ {
// Needs to accommodate containers, creatures, and NPCs // Needs to accommodate containers, creatures, and NPCs
@ -926,7 +935,7 @@ void CSMTools::ReferenceableCheckStage::inventoryListCheck(
case CSMWorld::UniversalId::Type_ItemLevelledList: case CSMWorld::UniversalId::Type_ItemLevelledList:
break; break;
default: default:
messages.push_back (std::make_pair(id, "'" + itemName + "' is not an item")); messages.add(id, "'" + itemName + "' is not an item", "", CSMDoc::Message::Severity_Error);
} }
} }
} }
@ -938,64 +947,64 @@ template<typename Item> void CSMTools::ReferenceableCheckStage::inventoryItemChe
const Item& someItem, CSMDoc::Messages& messages, const std::string& someID, bool enchantable) const Item& someItem, CSMDoc::Messages& messages, const std::string& someID, bool enchantable)
{ {
if (someItem.mName.empty()) if (someItem.mName.empty())
messages.push_back (std::make_pair (someID, "Name is missing")); messages.add(someID, "Name is missing", "", CSMDoc::Message::Severity_Error);
//Checking for weight //Checking for weight
if (someItem.mData.mWeight < 0) if (someItem.mData.mWeight < 0)
messages.push_back (std::make_pair (someID, "Weight is negative")); messages.add(someID, "Weight is negative", "", CSMDoc::Message::Severity_Error);
//Checking for value //Checking for value
if (someItem.mData.mValue < 0) if (someItem.mData.mValue < 0)
messages.push_back (std::make_pair (someID, "Value is negative")); messages.add(someID, "Value is negative", "", CSMDoc::Message::Severity_Error);
//checking for model //checking for model
if (someItem.mModel.empty()) if (someItem.mModel.empty())
messages.push_back (std::make_pair (someID, "Model is missing")); messages.add(someID, "Model is missing", "", CSMDoc::Message::Severity_Error);
else if (mModels.searchId(someItem.mModel) == -1) else if (mModels.searchId(someItem.mModel) == -1)
messages.push_back(std::make_pair(someID, "Model '" + someItem.mModel + "' does not exist")); messages.add(someID, "Model '" + someItem.mModel + "' does not exist", "", CSMDoc::Message::Severity_Error);
//checking for icon //checking for icon
if (someItem.mIcon.empty()) if (someItem.mIcon.empty())
messages.push_back (std::make_pair (someID, "Icon is missing")); messages.add(someID, "Icon is missing", "", CSMDoc::Message::Severity_Error);
else if (mIcons.searchId(someItem.mIcon) == -1) else if (mIcons.searchId(someItem.mIcon) == -1)
{ {
std::string ddsIcon = someItem.mIcon; std::string ddsIcon = someItem.mIcon;
if (!(Misc::ResourceHelpers::changeExtensionToDds(ddsIcon) && mIcons.searchId(ddsIcon) != -1)) if (!(Misc::ResourceHelpers::changeExtensionToDds(ddsIcon) && mIcons.searchId(ddsIcon) != -1))
messages.push_back(std::make_pair(someID, "Icon '" + someItem.mIcon + "' does not exist")); messages.add(someID, "Icon '" + someItem.mIcon + "' does not exist", "", CSMDoc::Message::Severity_Error);
} }
if (enchantable && someItem.mData.mEnchant < 0) if (enchantable && someItem.mData.mEnchant < 0)
messages.push_back (std::make_pair (someID, "Enchantment points number is negative")); messages.add(someID, "Enchantment points number is negative", "", CSMDoc::Message::Severity_Error);
} }
template<typename Item> void CSMTools::ReferenceableCheckStage::inventoryItemCheck ( template<typename Item> void CSMTools::ReferenceableCheckStage::inventoryItemCheck (
const Item& someItem, CSMDoc::Messages& messages, const std::string& someID) const Item& someItem, CSMDoc::Messages& messages, const std::string& someID)
{ {
if (someItem.mName.empty()) if (someItem.mName.empty())
messages.push_back (std::make_pair (someID, "Name is missing")); messages.add(someID, "Name is missing", "", CSMDoc::Message::Severity_Error);
//Checking for weight //Checking for weight
if (someItem.mData.mWeight < 0) if (someItem.mData.mWeight < 0)
messages.push_back (std::make_pair (someID, "Weight is negative")); messages.add(someID, "Weight is negative", "", CSMDoc::Message::Severity_Error);
//Checking for value //Checking for value
if (someItem.mData.mValue < 0) if (someItem.mData.mValue < 0)
messages.push_back (std::make_pair (someID, "Value is negative")); messages.add(someID, "Value is negative", "", CSMDoc::Message::Severity_Error);
//checking for model //checking for model
if (someItem.mModel.empty()) if (someItem.mModel.empty())
messages.push_back (std::make_pair (someID, "Model is missing")); messages.add(someID, "Model is missing", "", CSMDoc::Message::Severity_Error);
else if (mModels.searchId(someItem.mModel) == -1) else if (mModels.searchId(someItem.mModel) == -1)
messages.push_back (std::make_pair (someID, "Model '" + someItem.mModel + "' does not exist")); messages.add(someID, "Model '" + someItem.mModel + "' does not exist", "", CSMDoc::Message::Severity_Error);
//checking for icon //checking for icon
if (someItem.mIcon.empty()) if (someItem.mIcon.empty())
messages.push_back (std::make_pair (someID, "Icon is missing")); messages.add(someID, "Icon is missing", "", CSMDoc::Message::Severity_Error);
else if (mIcons.searchId(someItem.mIcon) == -1) else if (mIcons.searchId(someItem.mIcon) == -1)
{ {
std::string ddsIcon = someItem.mIcon; std::string ddsIcon = someItem.mIcon;
if (!(Misc::ResourceHelpers::changeExtensionToDds(ddsIcon) && mIcons.searchId(ddsIcon) != -1)) if (!(Misc::ResourceHelpers::changeExtensionToDds(ddsIcon) && mIcons.searchId(ddsIcon) != -1))
messages.push_back(std::make_pair(someID, "Icon '" + someItem.mIcon + "' does not exist")); messages.add(someID, "Icon '" + someItem.mIcon + "' does not exist", "", CSMDoc::Message::Severity_Error);
} }
} }
@ -1003,17 +1012,17 @@ template<typename Tool> void CSMTools::ReferenceableCheckStage::toolCheck (
const Tool& someTool, CSMDoc::Messages& messages, const std::string& someID, bool canBeBroken) const Tool& someTool, CSMDoc::Messages& messages, const std::string& someID, bool canBeBroken)
{ {
if (someTool.mData.mQuality <= 0) if (someTool.mData.mQuality <= 0)
messages.push_back (std::make_pair (someID, "Quality is non-positive")); messages.add(someID, "Quality is non-positive", "", CSMDoc::Message::Severity_Error);
if (canBeBroken && someTool.mData.mUses<=0) if (canBeBroken && someTool.mData.mUses<=0)
messages.push_back (std::make_pair (someID, "Number of uses is non-positive")); messages.add(someID, "Number of uses is non-positive", "", CSMDoc::Message::Severity_Error);
} }
template<typename Tool> void CSMTools::ReferenceableCheckStage::toolCheck ( template<typename Tool> void CSMTools::ReferenceableCheckStage::toolCheck (
const Tool& someTool, CSMDoc::Messages& messages, const std::string& someID) const Tool& someTool, CSMDoc::Messages& messages, const std::string& someID)
{ {
if (someTool.mData.mQuality <= 0) if (someTool.mData.mQuality <= 0)
messages.push_back (std::make_pair (someID, "Quality is non-positive")); messages.add(someID, "Quality is non-positive", "", CSMDoc::Message::Severity_Error);
} }
template<typename List> void CSMTools::ReferenceableCheckStage::listCheck ( template<typename List> void CSMTools::ReferenceableCheckStage::listCheck (
@ -1022,10 +1031,10 @@ template<typename List> void CSMTools::ReferenceableCheckStage::listCheck (
for (unsigned i = 0; i < someList.mList.size(); ++i) for (unsigned i = 0; i < someList.mList.size(); ++i)
{ {
if (mObjects.searchId(someList.mList[i].mId).first == -1) if (mObjects.searchId(someList.mList[i].mId).first == -1)
messages.push_back (std::make_pair (someID, "Object '" + someList.mList[i].mId + "' does not exist")); messages.add(someID, "Object '" + someList.mList[i].mId + "' does not exist", "", CSMDoc::Message::Severity_Error);
if (someList.mList[i].mLevel < 1) if (someList.mList[i].mLevel < 1)
messages.push_back (std::make_pair (someID, "Level of item '" + someList.mList[i].mId + "' is non-positive")); messages.add(someID, "Level of item '" + someList.mList[i].mId + "' is non-positive", "", CSMDoc::Message::Severity_Error);
} }
} }
@ -1035,6 +1044,6 @@ template<typename Tool> void CSMTools::ReferenceableCheckStage::scriptCheck (
if (!someTool.mScript.empty()) if (!someTool.mScript.empty())
{ {
if (mScripts.searchId(someTool.mScript) == -1) if (mScripts.searchId(someTool.mScript) == -1)
messages.push_back (std::make_pair (someID, "Script '"+someTool.mScript+"' does not exist")); messages.add(someID, "Script '" + someTool.mScript + "' does not exist", "", CSMDoc::Message::Severity_Error);
} }
} }

View file

@ -19,7 +19,8 @@ namespace CSMTools
const CSMWorld::IdCollection<ESM::Faction>& factions, const CSMWorld::IdCollection<ESM::Faction>& factions,
const CSMWorld::IdCollection<ESM::Script>& scripts, const CSMWorld::IdCollection<ESM::Script>& scripts,
const CSMWorld::Resources& models, const CSMWorld::Resources& models,
const CSMWorld::Resources& icons); const CSMWorld::Resources& icons,
const CSMWorld::IdCollection<ESM::BodyPart>& bodyparts);
virtual void perform(int stage, CSMDoc::Messages& messages); virtual void perform(int stage, CSMDoc::Messages& messages);
virtual int setup(); virtual int setup();
@ -86,6 +87,7 @@ namespace CSMTools
const CSMWorld::IdCollection<ESM::Script>& mScripts; const CSMWorld::IdCollection<ESM::Script>& mScripts;
const CSMWorld::Resources& mModels; const CSMWorld::Resources& mModels;
const CSMWorld::Resources& mIcons; const CSMWorld::Resources& mIcons;
const CSMWorld::IdCollection<ESM::BodyPart>& mBodyParts;
bool mPlayerPresent; bool mPlayerPresent;
bool mIgnoreBaseRecords; bool mIgnoreBaseRecords;
}; };

View file

@ -83,7 +83,8 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier()
mVerifierOperation->appendStage (new SpellCheckStage (mData.getSpells())); mVerifierOperation->appendStage (new SpellCheckStage (mData.getSpells()));
mVerifierOperation->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses(), mData.getFactions(), mData.getScripts(), mVerifierOperation->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses(), mData.getFactions(), mData.getScripts(),
mData.getResources (CSMWorld::UniversalId::Type_Meshes), mData.getResources (CSMWorld::UniversalId::Type_Icons))); mData.getResources (CSMWorld::UniversalId::Type_Meshes), mData.getResources (CSMWorld::UniversalId::Type_Icons),
mData.getBodyParts()));
mVerifierOperation->appendStage (new ReferenceCheckStage(mData.getReferences(), mData.getReferenceables(), mData.getCells(), mData.getFactions())); mVerifierOperation->appendStage (new ReferenceCheckStage(mData.getReferences(), mData.getReferenceables(), mData.getCells(), mData.getFactions()));