From a27441720e20a119914d3ea512c1ff9298fac405 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 21 Dec 2013 12:07:40 +0100 Subject: [PATCH] Added enchantmnet check for books. --- .../opencs/model/tools/referenceablecheck.cpp | 85 ++++++++++++++++--- .../opencs/model/tools/referenceablecheck.hpp | 7 +- apps/opencs/model/world/refiddata.cpp | 5 ++ apps/opencs/model/world/refiddata.hpp | 1 + 4 files changed, 85 insertions(+), 13 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 59591ca02..b299744d6 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -12,11 +12,20 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefId mReferencables(referenceable), mBooksSize(0), mActivatorsSize(0), - mPotionsSize(0) + mPotionsSize(0), + mApparatiSize(0) { setSizeVariables(); } +void CSMTools::ReferenceableCheckStage::setSizeVariables() +{ + mBooksSize = mReferencables.getBooks().getSize(); + mActivatorsSize = mReferencables.getActivators().getSize(); + mPotionsSize = mReferencables.getPotions().getSize(); + mApparatiSize = mReferencables.getApparati().getSize(); +} + void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages) { //Checks for books, than, when stage is above mBooksSize goes to other checks, with (stage - PrevSum) as stage. @@ -24,6 +33,7 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str if (stage <= mBooksSize) { bookCheck(stage, mReferencables.getBooks(), messages); + std::cout<<"Book checking \n"; return; } @@ -39,11 +49,19 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str if (stage <= mPotionsSize) { - potionsCheck(stage, mReferencables.getPotions(), messages); + potionCheck(stage, mReferencables.getPotions(), messages); return; } stage -= mPotionsSize; + + if (stage <= mApparatiSize) + { + apparatusCheck(stage, mReferencables.getApparati(), messages); + return; + } + + stage -= mApparatiSize; } int CSMTools::ReferenceableCheckStage::setup() @@ -72,13 +90,13 @@ void CSMTools::ReferenceableCheckStage::bookCheck(int stage, const CSMWorld::Ref //Checking for weight if (Book.mData.mWeight < 0) { - messages.push_back(id.toString() + "|" + Book.mId + " has a negative weight"); + messages.push_back(id.toString() + "|" + Book.mId + " has negative weight"); } //Checking for value if (Book.mData.mValue < 0) { - messages.push_back(id.toString() + "|" + Book.mId + " has a negative value"); + messages.push_back(id.toString() + "|" + Book.mId + " has negative value"); } //checking for model @@ -92,6 +110,12 @@ 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"); + } } void CSMTools::ReferenceableCheckStage::activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, std::vector< std::string >& messages) @@ -113,7 +137,7 @@ void CSMTools::ReferenceableCheckStage::activatorCheck(int stage, const CSMWorld } } -void CSMTools::ReferenceableCheckStage::potionsCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Potion >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::potionCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Potion >& records, std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -134,13 +158,13 @@ void CSMTools::ReferenceableCheckStage::potionsCheck(int stage, const CSMWorld:: //Checking for weight if (Potion.mData.mWeight < 0) { - messages.push_back(id.toString() + "|" + Potion.mId + " has a negative weight"); + messages.push_back(id.toString() + "|" + Potion.mId + " has negative weight"); } //Checking for value if (Potion.mData.mValue < 0) { - messages.push_back(id.toString() + "|" + Potion.mId + " has a negative value"); + messages.push_back(id.toString() + "|" + Potion.mId + " has negative value"); } //checking for model @@ -157,9 +181,46 @@ void CSMTools::ReferenceableCheckStage::potionsCheck(int stage, const CSMWorld:: //IIRC potion can have empty effects list just fine. } -void CSMTools::ReferenceableCheckStage::setSizeVariables() + +void CSMTools::ReferenceableCheckStage::apparatusCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Apparatus >& records, std::vector< std::string >& messages) { - mBooksSize = mReferencables.getBooks().getSize(); - mActivatorsSize = mReferencables.getActivators().getSize(); - mPotionsSize = mReferencables.getPotions().getSize(); -} + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Apparatus& Apparatus = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Apparatus, Apparatus.mId); + + //Checking for name + if (Apparatus.mName.empty()) + { + messages.push_back(id.toString() + "|" + Apparatus.mId + " has an empty name"); + } + + //Checking for weight + if (Apparatus.mData.mWeight < 0) + { + messages.push_back(id.toString() + "|" + Apparatus.mId + " has negative weight"); + } + + //Checking for value + if (Apparatus.mData.mValue < 0) + { + messages.push_back(id.toString() + "|" + Apparatus.mId + " has negative value"); + } + +//checking for model + if (Apparatus.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Apparatus.mId + " has no model"); + } + + //checking for icon + if (Apparatus.mIcon.empty()) + { + messages.push_back(id.toString() + "|" + Apparatus.mId + " has no icon"); + } +} \ No newline at end of file diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 801a2232b..a40ca16a4 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -16,16 +16,21 @@ namespace CSMTools virtual int setup(); private: + //CONCRETE CHECKS void bookCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Book >& records, std::vector< std::string >& messages); void activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, std::vector< std::string >& messages); - void potionsCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void potionCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void apparatusCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void setSizeVariables(); const CSMWorld::RefIdData mReferencables; + + //SIZES OF CONCRETE TYPES int mBooksSize; int mActivatorsSize; int mPotionsSize; + int mApparatiSize; }; } #endif // REFERENCEABLECHECKSTAGE_H diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 3a9d82630..6f278cc02 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -246,3 +246,8 @@ const CSMWorld::RefIdDataContainer< ESM::Potion >& CSMWorld::RefIdData::getPotio { return mPotions; } + +const CSMWorld::RefIdDataContainer< ESM::Apparatus >& CSMWorld::RefIdData::getApparati() const +{ + return mApparati; +} diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 1a4a41638..b32b0347a 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -224,6 +224,7 @@ namespace CSMWorld const RefIdDataContainer& getBooks() const; const RefIdDataContainer& getActivators() const; const RefIdDataContainer& getPotions() const; + const RefIdDataContainer& getApparati() const; }; }