diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index da63dce9f..b6c99960d 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -13,7 +13,8 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefId mBooksSize(0), mActivatorsSize(0), mPotionsSize(0), - mApparatiSize(0) + mApparatiSize(0), + mArmorsSzie(0) { setSizeVariables(); } @@ -24,6 +25,7 @@ void CSMTools::ReferenceableCheckStage::setSizeVariables() mActivatorsSize = mReferencables.getActivators().getSize(); mPotionsSize = mReferencables.getPotions().getSize(); mApparatiSize = mReferencables.getApparati().getSize(); + mArmorsSzie = mReferencables.getArmors().getSize(); } void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages) @@ -52,14 +54,22 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str } stage -= mPotionsSize; - + if (stage < mApparatiSize) { - apparatusCheck(stage, mReferencables.getApparati(), messages); - return; + apparatusCheck(stage, mReferencables.getApparati(), messages); + return; + } + + stage -= mApparatiSize; + + if (stage < mArmorsSzie) + { + armorCheck(stage, mReferencables.getArmors(), messages); + return; } - stage -= mApparatiSize; + stage -= mArmorsSzie; } int CSMTools::ReferenceableCheckStage::setup() @@ -108,11 +118,11 @@ void CSMTools::ReferenceableCheckStage::bookCheck(int stage, const CSMWorld::Ref { messages.push_back(id.toString() + "|" + Book.mId + " has no icon"); } - + //checking for enchantment points if (Book.mData.mEnchant < 0) { - messages.push_back(id.toString() + "|" + Book.mId + " has negative enchantment"); + messages.push_back(id.toString() + "|" + Book.mId + " has negative enchantment"); } } @@ -176,6 +186,7 @@ void CSMTools::ReferenceableCheckStage::potionCheck(int stage, const CSMWorld::R { messages.push_back(id.toString() + "|" + Potion.mId + " has no icon"); } + //IIRC potion can have empty effects list just fine. } @@ -221,10 +232,71 @@ void CSMTools::ReferenceableCheckStage::apparatusCheck(int stage, const CSMWorld { messages.push_back(id.toString() + "|" + Apparatus.mId + " has no icon"); } - + //checking for quality, 0 → apparatus is basicly useless, any negative → apparatus is harmfull instead of helpfull if (Apparatus.mData.mQuality <= 0) { - messages.push_back(id.toString() + "|" + Apparatus.mId + " has non-positive quality"); + messages.push_back(id.toString() + "|" + Apparatus.mId + " has non-positive quality"); + } +} + +void CSMTools::ReferenceableCheckStage::armorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Armor >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Armor& Armor = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Armor, Armor.mId); + + //Checking for name + if (Armor.mName.empty()) + { + messages.push_back(id.toString() + "|" + Armor.mId + " has an empty name"); + } + + //Checking for weight + if (Armor.mData.mWeight < 0) + { + messages.push_back(id.toString() + "|" + Armor.mId + " has negative weight"); + } + + //Checking for value + if (Armor.mData.mValue < 0) + { + messages.push_back(id.toString() + "|" + Armor.mId + " has negative value"); + } + +//checking for model + if (Armor.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Armor.mId + " has no model"); + } + + //checking for icon + if (Armor.mIcon.empty()) + { + messages.push_back(id.toString() + "|" + Armor.mId + " has no icon"); + } + + //checking for enchantment points + if (Armor.mData.mEnchant < 0) + { + messages.push_back(id.toString() + "|" + Armor.mId + " has negative enchantment"); + } + + //checking for armor class, armor should have poistive armor class, but 0 is considered legal + if (Armor.mData.mArmor < 0) + { + messages.push_back(id.toString() + "|" + Armor.mId + " has negative armor class"); + } + + //checking for health. Only positive numbers are allowed, and 0 is illegal + if (Armor.mData.mHealth <= 0) + { + messages.push_back(id.toString() + "|" + Armor.mId + " has non positive health"); } } diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index a40ca16a4..7e5b761af 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -21,6 +21,7 @@ namespace CSMTools void activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, std::vector< std::string >& messages); void potionCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void apparatusCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void armorCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void setSizeVariables(); @@ -31,6 +32,7 @@ namespace CSMTools int mActivatorsSize; int mPotionsSize; int mApparatiSize; + int mArmorsSzie; }; } #endif // REFERENCEABLECHECKSTAGE_H diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 6f278cc02..98a81c784 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -251,3 +251,8 @@ const CSMWorld::RefIdDataContainer< ESM::Apparatus >& CSMWorld::RefIdData::getAp { return mApparati; } + +const CSMWorld::RefIdDataContainer< ESM::Armor >& CSMWorld::RefIdData::getArmors() const +{ + return mArmors; +} diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index b32b0347a..f03da9588 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -225,6 +225,7 @@ namespace CSMWorld const RefIdDataContainer& getActivators() const; const RefIdDataContainer& getPotions() const; const RefIdDataContainer& getApparati() const; + const RefIdDataContainer& getArmors() const; }; }