From 8085fcc792a72087d9402ae570623d2842d16b1b Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 20 Dec 2013 20:02:42 +0100 Subject: [PATCH 01/74] Added Referencable checks class, added method to get refidcontainer, added method to get mBooks. Currently only books are checked, and only if name is present. --- apps/opencs/CMakeLists.txt | 2 +- .../opencs/model/tools/referenceablecheck.cpp | 63 +++++++++++++++++++ .../opencs/model/tools/referenceablecheck.hpp | 26 ++++++++ apps/opencs/model/tools/tools.cpp | 5 +- apps/opencs/model/world/refidcollection.cpp | 6 ++ apps/opencs/model/world/refidcollection.hpp | 2 + apps/opencs/model/world/refiddata.cpp | 7 ++- apps/opencs/model/world/refiddata.hpp | 3 + 8 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 apps/opencs/model/tools/referenceablecheck.cpp create mode 100644 apps/opencs/model/tools/referenceablecheck.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 1197e2014..baf677f8d 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -38,7 +38,7 @@ opencs_units (model/tools opencs_units_noqt (model/tools mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck - birthsigncheck spellcheck + birthsigncheck spellcheck referenceablecheck ) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp new file mode 100644 index 000000000..01c8d30a7 --- /dev/null +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -0,0 +1,63 @@ +#include "referenceablecheck.hpp" + +#include +#include +#include + +#include +#include "../world/record.hpp" + +#include "../world/universalid.hpp" + +CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable) : + mReferencables(referenceable), + mBooksSize(0) +{ + setSizeVariables(); +} + +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 - minus prev sizes as stage. + bool CheckPerformed = false; + + if (stage <= mBooksSize) + { + bookCheck(stage, mReferencables.getBooks(), messages); + CheckPerformed = true; + } + + if (CheckPerformed) + { + return; + } +} + +int CSMTools::ReferenceableCheckStage::setup() +{ + return mReferencables.getSize(); +} + +void CSMTools::ReferenceableCheckStage::bookCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Book >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Book& Book = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Book, Book.mId); + + //Checking for name + if (Book.mName.empty()) + { + messages.push_back(id.toString() + "|" + Book.mId + " has an empty name"); + } +} + +void CSMTools::ReferenceableCheckStage::setSizeVariables() +{ + mBooksSize = mReferencables.getBooks().getSize(); +} diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp new file mode 100644 index 000000000..509e8d8c0 --- /dev/null +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -0,0 +1,26 @@ +#ifndef REFERENCEABLECHECKSTAGE_H +#define REFERENCEABLECHECKSTAGE_H + +#include "../world/universalid.hpp" +#include "../doc/stage.hpp" +#include "../world/data.hpp" +#include "../world/refiddata.hpp" + +namespace CSMTools +{ + class ReferenceableCheckStage : public CSMDoc::Stage + { + public: + ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable); + virtual void perform(int stage, std::vector< std::string >& messages); + virtual int setup(); + + private: + void bookCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Book >& records, std::vector< std::string >& messages); + void setSizeVariables(); + + const CSMWorld::RefIdData mReferencables; + int mBooksSize; + }; +} +#endif // REFERENCEABLECHECKSTAGE_H diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index cd4653280..bca9f6fb7 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -19,6 +19,7 @@ #include "regioncheck.hpp" #include "birthsigncheck.hpp" #include "spellcheck.hpp" +#include "referenceablecheck.hpp" CSMDoc::Operation *CSMTools::Tools::get (int type) { @@ -74,6 +75,8 @@ CSMDoc::Operation *CSMTools::Tools::getVerifier() mVerifier->appendStage (new BirthsignCheckStage (mData.getBirthsigns())); mVerifier->appendStage (new SpellCheckStage (mData.getSpells())); + + mVerifier->appendStage( new ReferenceableCheckStage (mData.getReferenceables().getDataSet())); } return mVerifier; @@ -138,4 +141,4 @@ void CSMTools::Tools::verifierMessage (const QString& message, int type) if (iter!=mActiveReports.end()) mReports[iter->second]->add (message.toStdString()); -} \ No newline at end of file +} diff --git a/apps/opencs/model/world/refidcollection.cpp b/apps/opencs/model/world/refidcollection.cpp index 86a542c5c..9ed526818 100644 --- a/apps/opencs/model/world/refidcollection.cpp +++ b/apps/opencs/model/world/refidcollection.cpp @@ -549,3 +549,9 @@ void CSMWorld::RefIdCollection::save (int index, ESM::ESMWriter& writer) const { mData.save (index, writer); } + +const CSMWorld::RefIdData& CSMWorld::RefIdCollection::getDataSet() const +{ + return mData; +} + diff --git a/apps/opencs/model/world/refidcollection.hpp b/apps/opencs/model/world/refidcollection.hpp index 5ff4a70bf..70cae53c8 100644 --- a/apps/opencs/model/world/refidcollection.hpp +++ b/apps/opencs/model/world/refidcollection.hpp @@ -107,6 +107,8 @@ namespace CSMWorld /// \return Success? void save (int index, ESM::ESMWriter& writer) const; + + const RefIdData& getDataSet() const; //I can't figure out a better name for this one :( }; } diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 8f59b0fe7..0fbfef4f1 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -230,4 +230,9 @@ void CSMWorld::RefIdData::save (int index, ESM::ESMWriter& writer) const throw std::logic_error ("invalid local index type"); iter->second->save (localIndex.first, writer); -} \ No newline at end of file +} + +const CSMWorld::RefIdDataContainer< ESM::Book >& CSMWorld::RefIdData::getBooks() const +{ + return mBooks; +} diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 9595ab23b..1590b58df 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -219,6 +219,9 @@ namespace CSMWorld /// \param listDeleted include deleted record in the list void save (int index, ESM::ESMWriter& writer) const; + + //RECORD CONTAINERS ACCESS METHODS + const RefIdDataContainer& getBooks() const; }; } From f69465d7e0ca6a24f445825d6e0768463699fc1f Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 20 Dec 2013 22:31:17 +0100 Subject: [PATCH 02/74] Added aditional checks for books. Activator check. --- .../opencs/model/tools/referenceablecheck.cpp | 72 +++++++++++++++++-- .../opencs/model/tools/referenceablecheck.hpp | 2 + apps/opencs/model/world/refiddata.cpp | 5 ++ apps/opencs/model/world/refiddata.hpp | 1 + 4 files changed, 74 insertions(+), 6 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 01c8d30a7..f8dcd86a4 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -4,26 +4,27 @@ #include #include -#include #include "../world/record.hpp" #include "../world/universalid.hpp" CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable) : mReferencables(referenceable), - mBooksSize(0) + mBooksSize(0), + mActivatorsSize(0) { setSizeVariables(); } 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 - minus prev sizes as stage. + //Checks for books, than, when stage is above mBooksSize goes to other checks, with (stage - PrevSum) as stage. bool CheckPerformed = false; - + int PrevSum(0); + if (stage <= mBooksSize) - { - bookCheck(stage, mReferencables.getBooks(), messages); + { + bookCheck(stage, mReferencables.getBooks(), messages); CheckPerformed = true; } @@ -31,6 +32,21 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str { return; } + + PrevSum += mBooksSize; + + if ((stage - PrevSum) <= mActivatorsSize) + { + activatorCheck(stage - PrevSum, mReferencables.getActivator(), messages); + CheckPerformed = true; + } + + if (CheckPerformed) + { + return; + } + + PrevSum += mActivatorsSize; } int CSMTools::ReferenceableCheckStage::setup() @@ -55,9 +71,53 @@ void CSMTools::ReferenceableCheckStage::bookCheck(int stage, const CSMWorld::Ref { messages.push_back(id.toString() + "|" + Book.mId + " has an empty name"); } + + //Checking for weight + if (Book.mData.mWeight < 0) + { + messages.push_back(id.toString() + "|" + Book.mId + " has a negative weight"); + } + + //Checking for value + if (Book.mData.mValue < 0) + { + messages.push_back(id.toString() + "|" + Book.mId + " has a negative value"); + } + +//checking for model + if (Book.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Book.mId + " has no model"); + } + + //checking for icon + if (Book.mIcon.empty()) + { + messages.push_back(id.toString() + "|" + Book.mId + " has no icon"); + } +} + +void CSMTools::ReferenceableCheckStage::activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Activator& Activator = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Activator, Activator.mId); + + //Checking for model, IIRC all activators should have a model + if (Activator.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Activator.mId + " has no model"); + } } void CSMTools::ReferenceableCheckStage::setSizeVariables() { mBooksSize = mReferencables.getBooks().getSize(); + mActivatorsSize = mReferencables.getActivator().getSize(); } diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 509e8d8c0..dc2913c22 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -17,10 +17,12 @@ namespace CSMTools private: 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 setSizeVariables(); const CSMWorld::RefIdData mReferencables; int mBooksSize; + int mActivatorsSize; }; } #endif // REFERENCEABLECHECKSTAGE_H diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 0fbfef4f1..2285790be 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -236,3 +236,8 @@ const CSMWorld::RefIdDataContainer< ESM::Book >& CSMWorld::RefIdData::getBooks() { return mBooks; } + +const CSMWorld::RefIdDataContainer< ESM::Activator >& CSMWorld::RefIdData::getActivator() const +{ + return mActivators; +} diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 1590b58df..4a8e1e6f5 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -222,6 +222,7 @@ namespace CSMWorld //RECORD CONTAINERS ACCESS METHODS const RefIdDataContainer& getBooks() const; + const RefIdDataContainer& getActivator() const; }; } From 4842c56cb5849f6634a29f065064cd9704d70f37 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 21 Dec 2013 10:58:05 +0100 Subject: [PATCH 03/74] added getpotions --- apps/opencs/model/world/refiddata.cpp | 5 +++++ apps/opencs/model/world/refiddata.hpp | 1 + 2 files changed, 6 insertions(+) diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 2285790be..ddbde099e 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -241,3 +241,8 @@ const CSMWorld::RefIdDataContainer< ESM::Activator >& CSMWorld::RefIdData::getAc { return mActivators; } + +const CSMWorld::RefIdDataContainer< ESM::Potion >& CSMWorld::RefIdData::getPotions() const +{ + return mPotions; +} diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 4a8e1e6f5..9f5cf9f9a 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -223,6 +223,7 @@ namespace CSMWorld //RECORD CONTAINERS ACCESS METHODS const RefIdDataContainer& getBooks() const; const RefIdDataContainer& getActivator() const; + const RefIdDataContainer& getPotions() const; }; } From 385824aee0194d9ecf04c74303e7b225b880e687 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 21 Dec 2013 10:59:13 +0100 Subject: [PATCH 04/74] Renamed getActivator to getActivators. --- apps/opencs/model/tools/referenceablecheck.cpp | 2 +- apps/opencs/model/world/refiddata.cpp | 2 +- apps/opencs/model/world/refiddata.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index f8dcd86a4..eceaf999b 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -37,7 +37,7 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str if ((stage - PrevSum) <= mActivatorsSize) { - activatorCheck(stage - PrevSum, mReferencables.getActivator(), messages); + activatorCheck(stage - PrevSum, mReferencables.getActivators(), messages); CheckPerformed = true; } diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index ddbde099e..3a9d82630 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -237,7 +237,7 @@ const CSMWorld::RefIdDataContainer< ESM::Book >& CSMWorld::RefIdData::getBooks() return mBooks; } -const CSMWorld::RefIdDataContainer< ESM::Activator >& CSMWorld::RefIdData::getActivator() const +const CSMWorld::RefIdDataContainer< ESM::Activator >& CSMWorld::RefIdData::getActivators() const { return mActivators; } diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 9f5cf9f9a..1a4a41638 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -222,7 +222,7 @@ namespace CSMWorld //RECORD CONTAINERS ACCESS METHODS const RefIdDataContainer& getBooks() const; - const RefIdDataContainer& getActivator() const; + const RefIdDataContainer& getActivators() const; const RefIdDataContainer& getPotions() const; }; } From a6c36e23779251ad652312fe06742fa122880380 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 21 Dec 2013 11:01:40 +0100 Subject: [PATCH 05/74] Small optimization. --- apps/opencs/model/tools/referenceablecheck.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index eceaf999b..8eff6ed0b 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -20,7 +20,6 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str { //Checks for books, than, when stage is above mBooksSize goes to other checks, with (stage - PrevSum) as stage. bool CheckPerformed = false; - int PrevSum(0); if (stage <= mBooksSize) { @@ -32,12 +31,11 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str { return; } - - PrevSum += mBooksSize; - - if ((stage - PrevSum) <= mActivatorsSize) + stage -= mBooksSize; + + if ((stage) <= mActivatorsSize) { - activatorCheck(stage - PrevSum, mReferencables.getActivators(), messages); + activatorCheck(stage, mReferencables.getActivators(), messages); CheckPerformed = true; } @@ -45,8 +43,7 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str { return; } - - PrevSum += mActivatorsSize; + stage -= mActivatorsSize; } int CSMTools::ReferenceableCheckStage::setup() From 21ee2a6d2e6384b794210b67215ae71dad51c62b Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 21 Dec 2013 11:02:58 +0100 Subject: [PATCH 06/74] Getting size of potions. --- apps/opencs/model/tools/referenceablecheck.cpp | 6 ++++-- apps/opencs/model/tools/referenceablecheck.hpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 8eff6ed0b..ff2d6e713 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -11,7 +11,8 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable) : mReferencables(referenceable), mBooksSize(0), - mActivatorsSize(0) + mActivatorsSize(0), + mPotionsSize(0) { setSizeVariables(); } @@ -116,5 +117,6 @@ void CSMTools::ReferenceableCheckStage::activatorCheck(int stage, const CSMWorld void CSMTools::ReferenceableCheckStage::setSizeVariables() { mBooksSize = mReferencables.getBooks().getSize(); - mActivatorsSize = mReferencables.getActivator().getSize(); + mActivatorsSize = mReferencables.getActivators().getSize(); + mPotionsSize = mReferencables.getPotions().getSize(); } diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index dc2913c22..fed662e27 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -23,6 +23,7 @@ namespace CSMTools const CSMWorld::RefIdData mReferencables; int mBooksSize; int mActivatorsSize; + int mPotionsSize; }; } #endif // REFERENCEABLECHECKSTAGE_H From ee5dfd1cc8d0b40b806391ced7b36641ade4241f Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 21 Dec 2013 11:15:46 +0100 Subject: [PATCH 07/74] Adde potionCheck method --- .../opencs/model/tools/referenceablecheck.cpp | 69 +++++++++++++++---- .../opencs/model/tools/referenceablecheck.hpp | 10 +-- 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index ff2d6e713..59591ca02 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -20,31 +20,30 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefId 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. - bool CheckPerformed = false; if (stage <= mBooksSize) { bookCheck(stage, mReferencables.getBooks(), messages); - CheckPerformed = true; - } - - if (CheckPerformed) - { return; } + stage -= mBooksSize; - - if ((stage) <= mActivatorsSize) + + if (stage <= mActivatorsSize) { activatorCheck(stage, mReferencables.getActivators(), messages); - CheckPerformed = true; - } - - if (CheckPerformed) - { return; } + stage -= mActivatorsSize; + + if (stage <= mPotionsSize) + { + potionsCheck(stage, mReferencables.getPotions(), messages); + return; + } + + stage -= mPotionsSize; } int CSMTools::ReferenceableCheckStage::setup() @@ -114,6 +113,50 @@ 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) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Potion& Potion = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Potion, Potion.mId); + + //Checking for name + if (Potion.mName.empty()) + { + messages.push_back(id.toString() + "|" + Potion.mId + " has an empty name"); + } + + //Checking for weight + if (Potion.mData.mWeight < 0) + { + messages.push_back(id.toString() + "|" + Potion.mId + " has a negative weight"); + } + + //Checking for value + if (Potion.mData.mValue < 0) + { + messages.push_back(id.toString() + "|" + Potion.mId + " has a negative value"); + } + +//checking for model + if (Potion.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Potion.mId + " has no model"); + } + + //checking for icon + if (Potion.mIcon.empty()) + { + messages.push_back(id.toString() + "|" + Potion.mId + " has no icon"); + } + //IIRC potion can have empty effects list just fine. +} + void CSMTools::ReferenceableCheckStage::setSizeVariables() { mBooksSize = mReferencables.getBooks().getSize(); diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index fed662e27..801a2232b 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -18,12 +18,14 @@ namespace CSMTools private: 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 setSizeVariables(); + void potionsCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + + void setSizeVariables(); const CSMWorld::RefIdData mReferencables; - int mBooksSize; - int mActivatorsSize; - int mPotionsSize; + int mBooksSize; + int mActivatorsSize; + int mPotionsSize; }; } #endif // REFERENCEABLECHECKSTAGE_H From a27441720e20a119914d3ea512c1ff9298fac405 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 21 Dec 2013 12:07:40 +0100 Subject: [PATCH 08/74] 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; }; } From 1811f0a71b8b0695f7b510dd36288133c9876fc8 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 21 Dec 2013 15:40:39 +0100 Subject: [PATCH 09/74] Works, but it seems that I miss something in referencables. I will write post on the forum. --- apps/opencs/model/tools/referenceablecheck.cpp | 11 +++++------ apps/opencs/model/tools/reportmodel.cpp | 2 +- apps/opencs/model/tools/tools.cpp | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index b299744d6..e86e8db54 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -30,16 +30,15 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str { //Checks for books, than, when stage is above mBooksSize goes to other checks, with (stage - PrevSum) as stage. - if (stage <= mBooksSize) + if (stage < mBooksSize) { bookCheck(stage, mReferencables.getBooks(), messages); - std::cout<<"Book checking \n"; return; } stage -= mBooksSize; - if (stage <= mActivatorsSize) + if (stage < mActivatorsSize) { activatorCheck(stage, mReferencables.getActivators(), messages); return; @@ -47,7 +46,7 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str stage -= mActivatorsSize; - if (stage <= mPotionsSize) + if (stage < mPotionsSize) { potionCheck(stage, mReferencables.getPotions(), messages); return; @@ -55,7 +54,7 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str stage -= mPotionsSize; - if (stage <= mApparatiSize) + if (stage < mApparatiSize) { apparatusCheck(stage, mReferencables.getApparati(), messages); return; @@ -223,4 +222,4 @@ void CSMTools::ReferenceableCheckStage::apparatusCheck(int stage, const CSMWorld { messages.push_back(id.toString() + "|" + Apparatus.mId + " has no icon"); } -} \ No newline at end of file +} diff --git a/apps/opencs/model/tools/reportmodel.cpp b/apps/opencs/model/tools/reportmodel.cpp index b12531875..d88361746 100644 --- a/apps/opencs/model/tools/reportmodel.cpp +++ b/apps/opencs/model/tools/reportmodel.cpp @@ -68,4 +68,4 @@ void CSMTools::ReportModel::add (const std::string& row) const CSMWorld::UniversalId& CSMTools::ReportModel::getUniversalId (int row) const { return mRows.at (row).first; -} \ No newline at end of file +} diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index bca9f6fb7..d8cbb2fc1 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -76,7 +76,7 @@ CSMDoc::Operation *CSMTools::Tools::getVerifier() mVerifier->appendStage (new SpellCheckStage (mData.getSpells())); - mVerifier->appendStage( new ReferenceableCheckStage (mData.getReferenceables().getDataSet())); + mVerifier->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet())); } return mVerifier; From 955fe3e8cf627977477542e96c25199c1844b3ec Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 22 Dec 2013 10:00:04 +0100 Subject: [PATCH 10/74] Added check for non-positive quality of alchemical apparatus --- apps/opencs/model/tools/referenceablecheck.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index e86e8db54..da63dce9f 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -29,7 +29,6 @@ void CSMTools::ReferenceableCheckStage::setSizeVariables() 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. - if (stage < mBooksSize) { bookCheck(stage, mReferencables.getBooks(), messages); @@ -222,4 +221,10 @@ 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"); + } } From 97fc8acbdb207cdfb301df7c1f32a52aa04e840d Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 22 Dec 2013 14:22:03 +0100 Subject: [PATCH 11/74] Added armor check --- .../opencs/model/tools/referenceablecheck.cpp | 90 +++++++++++++++++-- .../opencs/model/tools/referenceablecheck.hpp | 2 + apps/opencs/model/world/refiddata.cpp | 5 ++ apps/opencs/model/world/refiddata.hpp | 1 + 4 files changed, 89 insertions(+), 9 deletions(-) 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; }; } From bbcaef8e42be9decd6d082fd3981e1b4e2da6b27 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 22 Dec 2013 14:32:42 +0100 Subject: [PATCH 12/74] Added armor check and related stuff. --- .../opencs/model/tools/referenceablecheck.cpp | 75 +++++++++++++++++-- .../opencs/model/tools/referenceablecheck.hpp | 2 + apps/opencs/model/world/refiddata.cpp | 5 ++ apps/opencs/model/world/refiddata.hpp | 1 + 4 files changed, 75 insertions(+), 8 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index b6c99960d..8f871fca2 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -14,7 +14,8 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefId mActivatorsSize(0), mPotionsSize(0), mApparatiSize(0), - mArmorsSzie(0) + mArmorsSzie(0), + mClothingSize(0) { setSizeVariables(); } @@ -26,6 +27,7 @@ void CSMTools::ReferenceableCheckStage::setSizeVariables() mPotionsSize = mReferencables.getPotions().getSize(); mApparatiSize = mReferencables.getApparati().getSize(); mArmorsSzie = mReferencables.getArmors().getSize(); + mClothingSize = mReferencables.getClothing().getSize(); } void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages) @@ -68,8 +70,16 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str armorCheck(stage, mReferencables.getArmors(), messages); return; } - + stage -= mArmorsSzie; + + if (stage < mClothingSize) + { + clothingCheck(stage, mReferencables.getClothing(), messages); + return; + } + + stage -= mClothingSize; } int CSMTools::ReferenceableCheckStage::setup() @@ -281,22 +291,71 @@ void CSMTools::ReferenceableCheckStage::armorCheck(int stage, const CSMWorld::Re { messages.push_back(id.toString() + "|" + Armor.mId + " has no icon"); } - - //checking for enchantment points + + //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"); + 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"); + messages.push_back(id.toString() + "|" + Armor.mId + " has non positive health"); + } +} + +void CSMTools::ReferenceableCheckStage::clothingCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Clothing >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Clothing& Clothing = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Clothing, Clothing.mId); + + //Checking for name + if (Clothing.mName.empty()) + { + messages.push_back(id.toString() + "|" + Clothing.mId + " has an empty name"); + } + + //Checking for weight + if (Clothing.mData.mWeight < 0) + { + messages.push_back(id.toString() + "|" + Clothing.mId + " has negative weight"); + } + + //Checking for value + if (Clothing.mData.mValue < 0) + { + messages.push_back(id.toString() + "|" + Clothing.mId + " has negative value"); + } + +//checking for model + if (Clothing.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Clothing.mId + " has no model"); + } + + //checking for icon + if (Clothing.mIcon.empty()) + { + messages.push_back(id.toString() + "|" + Clothing.mId + " has no icon"); + } + + //checking for enchantment points + if (Clothing.mData.mEnchant < 0) + { + messages.push_back(id.toString() + "|" + Clothing.mId + " has negative enchantment"); } } diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 7e5b761af..a4146c4d2 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -22,6 +22,7 @@ namespace CSMTools 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 clothingCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void setSizeVariables(); @@ -33,6 +34,7 @@ namespace CSMTools int mPotionsSize; int mApparatiSize; int mArmorsSzie; + int mClothingSize; }; } #endif // REFERENCEABLECHECKSTAGE_H diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 98a81c784..28cf28565 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -256,3 +256,8 @@ const CSMWorld::RefIdDataContainer< ESM::Armor >& CSMWorld::RefIdData::getArmors { return mArmors; } + +const CSMWorld::RefIdDataContainer< ESM::Clothing >& CSMWorld::RefIdData::getClothing() const +{ + return mClothing; +} diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index f03da9588..237c2f30b 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -226,6 +226,7 @@ namespace CSMWorld const RefIdDataContainer& getPotions() const; const RefIdDataContainer& getApparati() const; const RefIdDataContainer& getArmors() const; + const RefIdDataContainer& getClothing() const; }; } From dc594da0ded4049c2d84e93c33f827c5894624a4 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 22 Dec 2013 14:34:29 +0100 Subject: [PATCH 13/74] added getContainers --- apps/opencs/model/world/refiddata.cpp | 5 +++++ apps/opencs/model/world/refiddata.hpp | 1 + 2 files changed, 6 insertions(+) diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 28cf28565..0a93d93ec 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -261,3 +261,8 @@ const CSMWorld::RefIdDataContainer< ESM::Clothing >& CSMWorld::RefIdData::getClo { return mClothing; } + +const CSMWorld::RefIdDataContainer< ESM::Container >& CSMWorld::RefIdData::getContainers() const +{ + return mContainers; +} diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 237c2f30b..2f6ea187e 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -227,6 +227,7 @@ namespace CSMWorld const RefIdDataContainer& getApparati() const; const RefIdDataContainer& getArmors() const; const RefIdDataContainer& getClothing() const; + const RefIdDataContainer& getContainers() const; }; } From 1a7f023237b8210b257dd2a1d0cc14bc091af7b4 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 22 Dec 2013 14:35:40 +0100 Subject: [PATCH 14/74] added mContainersSize. --- apps/opencs/model/tools/referenceablecheck.cpp | 4 +++- apps/opencs/model/tools/referenceablecheck.hpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 8f871fca2..055244cab 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -15,7 +15,8 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefId mPotionsSize(0), mApparatiSize(0), mArmorsSzie(0), - mClothingSize(0) + mClothingSize(0), + mContainersSize(0) { setSizeVariables(); } @@ -28,6 +29,7 @@ void CSMTools::ReferenceableCheckStage::setSizeVariables() mApparatiSize = mReferencables.getApparati().getSize(); mArmorsSzie = mReferencables.getArmors().getSize(); mClothingSize = mReferencables.getClothing().getSize(); + mContainersSize = mReferencables.getContainers().getSize(); } void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages) diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index a4146c4d2..1c88c8cfe 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -35,6 +35,7 @@ namespace CSMTools int mApparatiSize; int mArmorsSzie; int mClothingSize; + int mContainersSize; }; } #endif // REFERENCEABLECHECKSTAGE_H From 16af9e69865632a88036ab32c70e6a6e3387ce40 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 22 Dec 2013 14:42:17 +0100 Subject: [PATCH 15/74] added container check --- .../opencs/model/tools/referenceablecheck.cpp | 39 +++++++++++++++++++ .../opencs/model/tools/referenceablecheck.hpp | 1 + 2 files changed, 40 insertions(+) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 055244cab..f08aadf86 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -82,6 +82,14 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str } stage -= mClothingSize; + + if (stage < mContainersSize) + { + containerCheck(stage, mReferencables.getContainers(), messages); + return; + } + + stage -= mContainersSize; } int CSMTools::ReferenceableCheckStage::setup() @@ -361,3 +369,34 @@ void CSMTools::ReferenceableCheckStage::clothingCheck(int stage, const CSMWorld: messages.push_back(id.toString() + "|" + Clothing.mId + " has negative enchantment"); } } + +void CSMTools::ReferenceableCheckStage::containerCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Container >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Container& Container = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Container, Container.mId); + + //Checking for model, IIRC all containers should have a model + if (Container.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Container.mId + " has no model"); + } + + //Checking for capacity (weight) + if (Container.mWeight < 0) //0 is allowed + { + messages.push_back(id.toString() + "|" + Container.mId + " has negative weight (capacity)"); + } + + //checking for name + if (Container.mName.empty()) + { + messages.push_back(id.toString() + "|" + Container.mId + " has an empty name"); + } +} diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 1c88c8cfe..b55db38c6 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -23,6 +23,7 @@ namespace CSMTools void apparatusCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void armorCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void clothingCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void containerCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void setSizeVariables(); From 32046070d54d8231681c0e4b6efb1985c3ac6ba8 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 22 Dec 2013 14:44:22 +0100 Subject: [PATCH 16/74] Added getCreatures --- apps/opencs/model/world/refiddata.cpp | 5 +++++ apps/opencs/model/world/refiddata.hpp | 1 + 2 files changed, 6 insertions(+) diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 0a93d93ec..266741155 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -266,3 +266,8 @@ const CSMWorld::RefIdDataContainer< ESM::Container >& CSMWorld::RefIdData::getCo { return mContainers; } + +const CSMWorld::RefIdDataContainer< ESM::Creature >& CSMWorld::RefIdData::getCreatures() const +{ + return mCreatures; +} diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 2f6ea187e..6af433be2 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -228,6 +228,7 @@ namespace CSMWorld const RefIdDataContainer& getArmors() const; const RefIdDataContainer& getClothing() const; const RefIdDataContainer& getContainers() const; + const RefIdDataContainer& getCreatures() const; }; } From 94fcea4d4df7cea66629fefdea5b368269697e97 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 22 Dec 2013 14:46:07 +0100 Subject: [PATCH 17/74] added mCreaturesSize --- apps/opencs/model/tools/referenceablecheck.cpp | 4 +++- apps/opencs/model/tools/referenceablecheck.hpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index f08aadf86..750ef6448 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -16,7 +16,8 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefId mApparatiSize(0), mArmorsSzie(0), mClothingSize(0), - mContainersSize(0) + mContainersSize(0), + mCreaturesSize(0) { setSizeVariables(); } @@ -30,6 +31,7 @@ void CSMTools::ReferenceableCheckStage::setSizeVariables() mArmorsSzie = mReferencables.getArmors().getSize(); mClothingSize = mReferencables.getClothing().getSize(); mContainersSize = mReferencables.getContainers().getSize(); + mCreaturesSize = mReferencables.getCreatures().getSize(); } void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages) diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index b55db38c6..17897fe34 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -37,6 +37,7 @@ namespace CSMTools int mArmorsSzie; int mClothingSize; int mContainersSize; + int mCreaturesSize; }; } #endif // REFERENCEABLECHECKSTAGE_H From e4e7d5062369570077172f1545c37e0c026253f7 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Mon, 23 Dec 2013 12:32:35 +0100 Subject: [PATCH 18/74] Added creatureCheck. I don't know meaning of all data fields here. --- .../opencs/model/tools/referenceablecheck.cpp | 104 +++++++++++++++++- .../opencs/model/tools/referenceablecheck.hpp | 1 + components/esm/loadcrea.hpp | 2 +- 3 files changed, 102 insertions(+), 5 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 750ef6448..c8a310e9f 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -84,13 +84,13 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str } stage -= mClothingSize; - + if (stage < mContainersSize) { - containerCheck(stage, mReferencables.getContainers(), messages); - return; + containerCheck(stage, mReferencables.getContainers(), messages); + return; } - + stage -= mContainersSize; } @@ -402,3 +402,99 @@ void CSMTools::ReferenceableCheckStage::containerCheck(int stage, const CSMWorld messages.push_back(id.toString() + "|" + Container.mId + " has an empty name"); } } + +void CSMTools::ReferenceableCheckStage::creatureCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Creature >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Creature& Creature = (static_cast&>(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Creature, Creature.mId); + + if (Creature.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Creature.mId + " has no model"); + } + + if (Creature.mName.empty()) + { + messages.push_back(id.toString() + "|" + Creature.mId + " has an empty name"); + } + + //stats checks + if (Creature.mData.mLevel < 1) + { + messages.push_back(id.toString() + "|" + Creature.mId + " has non-postive level"); + } + + if (Creature.mData.mStrength < 0) + { + messages.push_back(id.toString() + "|" + Creature.mId + " has negative strength"); + } + + if (Creature.mData.mIntelligence < 0) + { + messages.push_back(id.toString() + "|" + Creature.mId + " has negative intelligence"); + } + + if (Creature.mData.mWillpower < 0) + { + messages.push_back(id.toString() + "|" + Creature.mId + " has negative willpower"); + } + + if (Creature.mData.mAgility < 0) + { + messages.push_back(id.toString() + "|" + Creature.mId + " has negative agility"); + } + + if (Creature.mData.mSpeed < 0) + { + messages.push_back(id.toString() + "|" + Creature.mId + " has negative speed"); + } + + if (Creature.mData.mEndurance < 0) + { + messages.push_back(id.toString() + "|" + Creature.mId + " has negative endurance"); + } + + if (Creature.mData.mPersonality < 0) + { + messages.push_back(id.toString() + "|" + Creature.mId + " has negative personality"); + } + + if (Creature.mData.mLuck < 0) + { + messages.push_back(id.toString() + "|" + Creature.mId + " has negative luck"); + } + + if (Creature.mData.mHealth < 0) + { + messages.push_back(id.toString() + "|" + Creature.mId + " has negative health"); + } + + if (Creature.mData.mSoul < 0) + { + messages.push_back(id.toString() + "|" + Creature.mId + " has negative soul value"); + } + + for (int i = 0; i < 6; ++i) + { + if (Creature.mData.mAttack[i] < 0) + { + messages.push_back(id.toString() + "|" + Creature.mId + " has negative attack strength"); + break; + } + } + + //TODO, find meaning of other values + /* + if (Creature.mData.mGold < 0) + { + messages.push_back(id.toString() + "|" + Creature.mId + " has negative gold "); + } + */ +} diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 17897fe34..72af4e0ff 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -24,6 +24,7 @@ namespace CSMTools void armorCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void clothingCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void containerCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void creatureCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void setSizeVariables(); diff --git a/components/esm/loadcrea.hpp b/components/esm/loadcrea.hpp index 99c4f5225..a39a7ebe1 100644 --- a/components/esm/loadcrea.hpp +++ b/components/esm/loadcrea.hpp @@ -66,7 +66,7 @@ struct Creature int mCombat, mMagic, mStealth; // Don't know yet. int mAttack[6]; // AttackMin1, AttackMax1, ditto2, ditto3 int mGold; - }; // 96 bytes + }; // 96 byte NPDTstruct mData; From c1715779fa626c2d28a944019c14df690128b22f Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 26 Dec 2013 12:59:43 +0100 Subject: [PATCH 19/74] Added door check with related methods. --- .../opencs/model/tools/referenceablecheck.cpp | 40 +++++++++++++++++-- .../opencs/model/tools/referenceablecheck.hpp | 2 + apps/opencs/model/world/refiddata.cpp | 6 +++ apps/opencs/model/world/refiddata.hpp | 1 + 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index c8a310e9f..03efb59cc 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -17,7 +17,8 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefId mArmorsSzie(0), mClothingSize(0), mContainersSize(0), - mCreaturesSize(0) + mCreaturesSize(0), + mDoorsSize(0) { setSizeVariables(); } @@ -32,6 +33,7 @@ void CSMTools::ReferenceableCheckStage::setSizeVariables() mClothingSize = mReferencables.getClothing().getSize(); mContainersSize = mReferencables.getContainers().getSize(); mCreaturesSize = mReferencables.getCreatures().getSize(); + mDoorsSize = mReferencables.getDoors().getSize(); } void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages) @@ -92,6 +94,14 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str } stage -= mContainersSize; + + if (stage < mDoorsSize) + { + doorCheck(stage, mReferencables.getDoors(), messages); + return; + } + + stage -= mDoorsSize; } int CSMTools::ReferenceableCheckStage::setup() @@ -491,10 +501,32 @@ void CSMTools::ReferenceableCheckStage::creatureCheck(int stage, const CSMWorld: } //TODO, find meaning of other values - /* - if (Creature.mData.mGold < 0) + if (Creature.mData.mGold < 0) //It seems that this is for gold in merchant creatures { messages.push_back(id.toString() + "|" + Creature.mId + " has negative gold "); } - */ +} + +void CSMTools::ReferenceableCheckStage::doorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Door >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Door& Door= (static_cast&>(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Door, Door.mId); + + //usual, name and model + if (Door.mName.empty()) + { + messages.push_back(id.toString() + "|" + Door.mId + " has an empty name"); + } + + if (Door.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Door.mId + " has no model"); + } } diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 72af4e0ff..3a0b2a4b8 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -25,6 +25,7 @@ namespace CSMTools void clothingCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void containerCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void creatureCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void doorCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void setSizeVariables(); @@ -39,6 +40,7 @@ namespace CSMTools int mClothingSize; int mContainersSize; int mCreaturesSize; + int mDoorsSize; }; } #endif // REFERENCEABLECHECKSTAGE_H diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 266741155..83ff79cc8 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -271,3 +271,9 @@ const CSMWorld::RefIdDataContainer< ESM::Creature >& CSMWorld::RefIdData::getCre { return mCreatures; } + +const CSMWorld::RefIdDataContainer< ESM::Door >& CSMWorld::RefIdData::getDoors() const +{ + return mDoors; +} + diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 6af433be2..87818c9c9 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -229,6 +229,7 @@ namespace CSMWorld const RefIdDataContainer& getClothing() const; const RefIdDataContainer& getContainers() const; const RefIdDataContainer& getCreatures() const; + const RefIdDataContainer& getDoors() const; }; } From 6c95cea4c48c1e2dcde5819481715070b5289a65 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 26 Dec 2013 15:24:52 +0100 Subject: [PATCH 20/74] Added ingredient check --- .../opencs/model/tools/referenceablecheck.cpp | 61 ++++++++++++++++--- .../opencs/model/tools/referenceablecheck.hpp | 2 + apps/opencs/model/world/refiddata.cpp | 4 ++ apps/opencs/model/world/refiddata.hpp | 1 + 4 files changed, 61 insertions(+), 7 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 03efb59cc..589372f8a 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -18,7 +18,8 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefId mClothingSize(0), mContainersSize(0), mCreaturesSize(0), - mDoorsSize(0) + mDoorsSize(0), + mIngredientsSize(0) { setSizeVariables(); } @@ -34,6 +35,7 @@ void CSMTools::ReferenceableCheckStage::setSizeVariables() mContainersSize = mReferencables.getContainers().getSize(); mCreaturesSize = mReferencables.getCreatures().getSize(); mDoorsSize = mReferencables.getDoors().getSize(); + mIngredientsSize = mReferencables.getIngredients().getSize(); } void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages) @@ -94,13 +96,13 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str } stage -= mContainersSize; - + if (stage < mDoorsSize) { - doorCheck(stage, mReferencables.getDoors(), messages); - return; + doorCheck(stage, mReferencables.getDoors(), messages); + return; } - + stage -= mDoorsSize; } @@ -516,9 +518,9 @@ void CSMTools::ReferenceableCheckStage::doorCheck(int stage, const CSMWorld::Ref return; } - const ESM::Door& Door= (static_cast&>(baserecord)).get(); + const ESM::Door& Door = (static_cast&>(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Door, Door.mId); - + //usual, name and model if (Door.mName.empty()) { @@ -529,4 +531,49 @@ void CSMTools::ReferenceableCheckStage::doorCheck(int stage, const CSMWorld::Ref { messages.push_back(id.toString() + "|" + Door.mId + " has no model"); } + + //TODO, check what static unsigned int sRecordId; is for +} + +void CSMTools::ReferenceableCheckStage::ingredientCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Ingredient >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Ingredient& Ingredient = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Ingredient, Ingredient.mId); + + //Checking for name + if (Ingredient.mName.empty()) + { + messages.push_back(id.toString() + "|" + Ingredient.mId + " has an empty name"); + } + + //Checking for weight + if (Ingredient.mData.mWeight < 0) + { + messages.push_back(id.toString() + "|" + Ingredient.mId + " has negative weight"); + } + + //Checking for value + if (Ingredient.mData.mValue < 0) + { + messages.push_back(id.toString() + "|" + Ingredient.mId + " has negative value"); + } + +//checking for model + if (Ingredient.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Ingredient.mId + " has no model"); + } + + //checking for icon + if (Ingredient.mIcon.empty()) + { + messages.push_back(id.toString() + "|" + Ingredient.mId + " has no icon"); + } } diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 3a0b2a4b8..c7c418ff6 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -26,6 +26,7 @@ namespace CSMTools void containerCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void creatureCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void doorCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void ingredientCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void setSizeVariables(); @@ -41,6 +42,7 @@ namespace CSMTools int mContainersSize; int mCreaturesSize; int mDoorsSize; + int mIngredientsSize; }; } #endif // REFERENCEABLECHECKSTAGE_H diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 83ff79cc8..8af42703e 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -277,3 +277,7 @@ const CSMWorld::RefIdDataContainer< ESM::Door >& CSMWorld::RefIdData::getDoors() return mDoors; } +const CSMWorld::RefIdDataContainer< ESM::Ingredient >& CSMWorld::RefIdData::getIngredients() const +{ + return mIngredients; +} diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 87818c9c9..6a67ed1c8 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -230,6 +230,7 @@ namespace CSMWorld const RefIdDataContainer& getContainers() const; const RefIdDataContainer& getCreatures() const; const RefIdDataContainer& getDoors() const; + const RefIdDataContainer& getIngredients() const; }; } From 360a939aa0f224c7870b1193f6916f75c0eb253e Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 26 Dec 2013 15:35:58 +0100 Subject: [PATCH 21/74] Working on leveled lists now. --- .../opencs/model/tools/referenceablecheck.cpp | 27 ++++++++++++++++++- .../opencs/model/tools/referenceablecheck.hpp | 2 ++ apps/opencs/model/world/refiddata.cpp | 5 ++++ apps/opencs/model/world/refiddata.hpp | 1 + 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 589372f8a..12727d49c 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -19,7 +19,8 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefId mContainersSize(0), mCreaturesSize(0), mDoorsSize(0), - mIngredientsSize(0) + mIngredientsSize(0), + mCreaturesLevListsSize(0) { setSizeVariables(); } @@ -36,6 +37,7 @@ void CSMTools::ReferenceableCheckStage::setSizeVariables() mCreaturesSize = mReferencables.getCreatures().getSize(); mDoorsSize = mReferencables.getDoors().getSize(); mIngredientsSize = mReferencables.getIngredients().getSize(); + mCreaturesLevListsSize = mReferencables.getCreatureLevelledLists().getSize(); } void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages) @@ -104,6 +106,14 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str } stage -= mDoorsSize; + + if (stage < mIngredientsSize) + { + ingredientCheck(stage, mReferencables.getIngredients(), messages); + return; + } + + stage -= mIngredientsSize; } int CSMTools::ReferenceableCheckStage::setup() @@ -577,3 +587,18 @@ void CSMTools::ReferenceableCheckStage::ingredientCheck(int stage, const CSMWorl messages.push_back(id.toString() + "|" + Ingredient.mId + " has no icon"); } } + +void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::CreatureLevList >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::CreatureLevList& CreatureLevList = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_CreatureLevList, CreatureLevList.mId); + + //TODO(!) +} \ No newline at end of file diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index c7c418ff6..8fd123b06 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -27,6 +27,7 @@ namespace CSMTools void creatureCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void doorCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void ingredientCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void setSizeVariables(); @@ -43,6 +44,7 @@ namespace CSMTools int mCreaturesSize; int mDoorsSize; int mIngredientsSize; + int mCreaturesLevListsSize; }; } #endif // REFERENCEABLECHECKSTAGE_H diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 8af42703e..aec20b188 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -281,3 +281,8 @@ const CSMWorld::RefIdDataContainer< ESM::Ingredient >& CSMWorld::RefIdData::getI { return mIngredients; } + +const CSMWorld::RefIdDataContainer< ESM::CreatureLevList >& CSMWorld::RefIdData::getCreatureLevelledLists() const +{ + return mCreatureLevelledLists; +} diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 6a67ed1c8..02ca53953 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -231,6 +231,7 @@ namespace CSMWorld const RefIdDataContainer& getCreatures() const; const RefIdDataContainer& getDoors() const; const RefIdDataContainer& getIngredients() const; + const RefIdDataContainer& getCreatureLevelledLists() const; }; } From c2993909cf0efce9850557d6b9519cefe0c533a0 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 26 Dec 2013 18:16:54 +0100 Subject: [PATCH 22/74] added creature leveled list check --- .../opencs/model/tools/referenceablecheck.cpp | 42 +++++++++++++++---- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 12727d49c..0abebc709 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -106,14 +106,22 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str } stage -= mDoorsSize; - + if (stage < mIngredientsSize) { - ingredientCheck(stage, mReferencables.getIngredients(), messages); - return; + ingredientCheck(stage, mReferencables.getIngredients(), messages); + return; } - + stage -= mIngredientsSize; + + if (stage < mCreaturesLevListsSize) + { + creaturesLevListCheck(stage, mReferencables.getCreatureLevelledLists(), messages); + return; + } + + stage -= mCreaturesLevListsSize; } int CSMTools::ReferenceableCheckStage::setup() @@ -590,7 +598,7 @@ void CSMTools::ReferenceableCheckStage::ingredientCheck(int stage, const CSMWorl void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::CreatureLevList >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); if (baserecord.isDeleted()) { @@ -598,7 +606,25 @@ void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(int stage, const C } const ESM::CreatureLevList& CreatureLevList = (static_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_CreatureLevList, CreatureLevList.mId); - + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_CreatureLevelledList, CreatureLevList.mId); //CreatureLevList but Type_CreatureLevelledList :/ + + for (int i = 0; i < CreatureLevList.mList.size(); ++i) + { + if (CreatureLevList.mList[i].mId.empty()) + { + messages.push_back(id.toString() + "|" + CreatureLevList.mId + " contains item with empty Id"); + } + + if (CreatureLevList.mList[i].mLevel < 1) + { + messages.push_back(id.toString() + "|" + CreatureLevList.mId + " contains item with non-positive level"); + } + } + + if (CreatureLevList.mChanceNone < 0 or CreatureLevList.mChanceNone > 100) + { + messages.push_back(id.toString() + "|" + CreatureLevList.mId + " chance to be empty is not beetween 0 and 100"); + } + //TODO(!) -} \ No newline at end of file +} From 1da56e1790f084d267f802e32a746d4f61c1f2a7 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 26 Dec 2013 18:28:24 +0100 Subject: [PATCH 23/74] checkin leveled items lists --- .../opencs/model/tools/referenceablecheck.cpp | 45 +++++++++++++++++-- .../opencs/model/tools/referenceablecheck.hpp | 2 + apps/opencs/model/world/refiddata.cpp | 5 +++ apps/opencs/model/world/refiddata.hpp | 1 + 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 0abebc709..e2091de2e 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -20,7 +20,8 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefId mCreaturesSize(0), mDoorsSize(0), mIngredientsSize(0), - mCreaturesLevListsSize(0) + mCreaturesLevListsSize(0), + mItemLevelledListsSize(0) { setSizeVariables(); } @@ -38,6 +39,7 @@ void CSMTools::ReferenceableCheckStage::setSizeVariables() mDoorsSize = mReferencables.getDoors().getSize(); mIngredientsSize = mReferencables.getIngredients().getSize(); mCreaturesLevListsSize = mReferencables.getCreatureLevelledLists().getSize(); + mItemLevelledListsSize = mReferencables.getItemLevelledList().getSize(); } void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages) @@ -122,6 +124,14 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str } stage -= mCreaturesLevListsSize; + + if (stage < mItemLevelledListsSize) + { + mItemLevelledListCheck(stage, mReferencables.getItemLevelledList(), messages); + return; + } + + stage -= mItemLevelledListsSize; } int CSMTools::ReferenceableCheckStage::setup() @@ -625,6 +635,35 @@ void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(int stage, const C { messages.push_back(id.toString() + "|" + CreatureLevList.mId + " chance to be empty is not beetween 0 and 100"); } - - //TODO(!) +} + +void CSMTools::ReferenceableCheckStage::mItemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::ItemLevList >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::ItemLevList& ItemLevList = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_ItemLevelledList, CreatureLevList.mId); + + for (int i = 0; i < ItemLevList.mList.size(); ++i) + { + if (ItemLevList.mList[i].mId.empty()) + { + messages.push_back(id.toString() + "|" + ItemLevList.mId + " contains item with empty Id"); + } + + if (ItemLevList.mList[i].mLevel < 1) + { + messages.push_back(id.toString() + "|" + ItemLevList.mId + " contains item with non-positive level"); + } + } + + if (ItemLevList.mChanceNone < 0 or ItemLevList.mChanceNone > 100) + { + messages.push_back(id.toString() + "|" + ItemLevList.mId + " chance to be empty is not beetween 0 and 100"); + } } diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 8fd123b06..5a0d39ec5 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -28,6 +28,7 @@ namespace CSMTools void doorCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void ingredientCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void mItemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void setSizeVariables(); @@ -45,6 +46,7 @@ namespace CSMTools int mDoorsSize; int mIngredientsSize; int mCreaturesLevListsSize; + int mItemLevelledListsSize; }; } #endif // REFERENCEABLECHECKSTAGE_H diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index aec20b188..7f3e6506b 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -286,3 +286,8 @@ const CSMWorld::RefIdDataContainer< ESM::CreatureLevList >& CSMWorld::RefIdData: { return mCreatureLevelledLists; } + +const CSMWorld::RefIdDataContainer< ESM::ItemLevList >& CSMWorld::RefIdData::getItemLevelledList() const +{ + return mItemLevelledLists; +} diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 02ca53953..6e7231a24 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -232,6 +232,7 @@ namespace CSMWorld const RefIdDataContainer& getDoors() const; const RefIdDataContainer& getIngredients() const; const RefIdDataContainer& getCreatureLevelledLists() const; + const RefIdDataContainer& getItemLevelledList() const; }; } From f04a727af67cd8bb1240f201a42fbb68837a7160 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 26 Dec 2013 18:40:47 +0100 Subject: [PATCH 24/74] removed set sizes, consted sizes, added itemleveledlist check --- .../opencs/model/tools/referenceablecheck.cpp | 52 +++++++------------ .../opencs/model/tools/referenceablecheck.hpp | 27 +++++----- apps/opencs/model/world/refiddata.cpp | 5 ++ apps/opencs/model/world/refiddata.hpp | 1 + 4 files changed, 37 insertions(+), 48 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index e2091de2e..d37808810 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -10,36 +10,20 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable) : mReferencables(referenceable), - mBooksSize(0), - mActivatorsSize(0), - mPotionsSize(0), - mApparatiSize(0), - mArmorsSzie(0), - mClothingSize(0), - mContainersSize(0), - mCreaturesSize(0), - mDoorsSize(0), - mIngredientsSize(0), - mCreaturesLevListsSize(0), - mItemLevelledListsSize(0) + mBooksSize(mReferencables.getBooks().getSize()), + mActivatorsSize(mReferencables.getActivators().getSize()), + mPotionsSize(mReferencables.getPotions().getSize()), + mApparatiSize(mReferencables.getApparati().getSize()), + mArmorsSzie(mReferencables.getArmors().getSize()), + mClothingSize(mReferencables.getClothing().getSize()), + mContainersSize(mReferencables.getContainers().getSize()), + mCreaturesSize(mReferencables.getCreatures().getSize()), + mDoorsSize(mReferencables.getDoors().getSize()), + mIngredientsSize(mReferencables.getIngredients().getSize()), + mCreaturesLevListsSize(mReferencables.getCreatureLevelledLists().getSize()), + mItemLevelledListsSize(mReferencables.getItemLevelledList().getSize()), + mLightsSize(mReferencables.getLights().getSize()) { - setSizeVariables(); -} - -void CSMTools::ReferenceableCheckStage::setSizeVariables() -{ - mBooksSize = mReferencables.getBooks().getSize(); - mActivatorsSize = mReferencables.getActivators().getSize(); - mPotionsSize = mReferencables.getPotions().getSize(); - mApparatiSize = mReferencables.getApparati().getSize(); - mArmorsSzie = mReferencables.getArmors().getSize(); - mClothingSize = mReferencables.getClothing().getSize(); - mContainersSize = mReferencables.getContainers().getSize(); - mCreaturesSize = mReferencables.getCreatures().getSize(); - mDoorsSize = mReferencables.getDoors().getSize(); - mIngredientsSize = mReferencables.getIngredients().getSize(); - mCreaturesLevListsSize = mReferencables.getCreatureLevelledLists().getSize(); - mItemLevelledListsSize = mReferencables.getItemLevelledList().getSize(); } void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages) @@ -124,13 +108,13 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str } stage -= mCreaturesLevListsSize; - + if (stage < mItemLevelledListsSize) { - mItemLevelledListCheck(stage, mReferencables.getItemLevelledList(), messages); - return; + mItemLevelledListCheck(stage, mReferencables.getItemLevelledList(), messages); + return; } - + stage -= mItemLevelledListsSize; } @@ -647,7 +631,7 @@ void CSMTools::ReferenceableCheckStage::mItemLevelledListCheck(int stage, const } const ESM::ItemLevList& ItemLevList = (static_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_ItemLevelledList, CreatureLevList.mId); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_ItemLevelledList, ItemLevList.mId); for (int i = 0; i < ItemLevList.mList.size(); ++i) { diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 5a0d39ec5..6bffc2b25 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -30,23 +30,22 @@ namespace CSMTools void creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void mItemLevelledListCheck(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; - int mArmorsSzie; - int mClothingSize; - int mContainersSize; - int mCreaturesSize; - int mDoorsSize; - int mIngredientsSize; - int mCreaturesLevListsSize; - int mItemLevelledListsSize; + const int mBooksSize; + const int mActivatorsSize; + const int mPotionsSize; + const int mApparatiSize; + const int mArmorsSzie; + const int mClothingSize; + const int mContainersSize; + const int mCreaturesSize; + const int mDoorsSize; + const int mIngredientsSize; + const int mCreaturesLevListsSize; + const int mItemLevelledListsSize; + const int mLightsSize; }; } #endif // REFERENCEABLECHECKSTAGE_H diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 7f3e6506b..54e2cd12f 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -291,3 +291,8 @@ const CSMWorld::RefIdDataContainer< ESM::ItemLevList >& CSMWorld::RefIdData::get { return mItemLevelledLists; } + +const CSMWorld::RefIdDataContainer< ESM::Light >& CSMWorld::RefIdData::getLights() const +{ + return mLights; +} diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 6e7231a24..6b6e01e01 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -233,6 +233,7 @@ namespace CSMWorld const RefIdDataContainer& getIngredients() const; const RefIdDataContainer& getCreatureLevelledLists() const; const RefIdDataContainer& getItemLevelledList() const; + const RefIdDataContainer& getLights() const; }; } From 03235bf0a274b7dfd1e95a1a58f2662ffbbececc Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 27 Dec 2013 22:13:55 +0100 Subject: [PATCH 25/74] NPC. Still WIP. --- .../opencs/model/tools/referenceablecheck.cpp | 260 +++++++++++++++++- .../opencs/model/tools/referenceablecheck.hpp | 9 +- apps/opencs/model/world/refiddata.cpp | 229 ++++++++------- apps/opencs/model/world/refiddata.hpp | 4 + components/esm/loadnpc.hpp | 2 +- 5 files changed, 383 insertions(+), 121 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index d37808810..6d06d6151 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "../world/record.hpp" @@ -22,7 +23,10 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefId mIngredientsSize(mReferencables.getIngredients().getSize()), mCreaturesLevListsSize(mReferencables.getCreatureLevelledLists().getSize()), mItemLevelledListsSize(mReferencables.getItemLevelledList().getSize()), - mLightsSize(mReferencables.getLights().getSize()) + mLightsSize(mReferencables.getLights().getSize()), + mLockpicksSize(mReferencables.getLocpicks().getSize()), + mMiscellaneousSize(mReferencables.getMiscellaneous().getSize()), + mNPCsSize(mReferencables.getNPCs().getSize()) { } @@ -111,11 +115,35 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str if (stage < mItemLevelledListsSize) { - mItemLevelledListCheck(stage, mReferencables.getItemLevelledList(), messages); + itemLevelledListCheck(stage, mReferencables.getItemLevelledList(), messages); return; } stage -= mItemLevelledListsSize; + + if (stage < mLightsSize) + { + lightCheck(stage, mReferencables.getLights(), messages); + return; + } + + stage -= mLightsSize; + + if (stage < mLockpicksSize) + { + lockpickCheck(stage, mReferencables.getLocpicks(), messages); + return; + } + + stage -= mLockpicksSize; + + if (stage < mMiscellaneousSize) + { + miscCheck(stage, mReferencables.getMiscellaneous(), messages); + return; + } + + stage -= mMiscellaneousSize; } int CSMTools::ReferenceableCheckStage::setup() @@ -602,7 +630,7 @@ void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(int stage, const C const ESM::CreatureLevList& CreatureLevList = (static_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_CreatureLevelledList, CreatureLevList.mId); //CreatureLevList but Type_CreatureLevelledList :/ - for (int i = 0; i < CreatureLevList.mList.size(); ++i) + for (unsigned i = 0; i < CreatureLevList.mList.size(); ++i) { if (CreatureLevList.mList[i].mId.empty()) { @@ -614,14 +642,9 @@ void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(int stage, const C messages.push_back(id.toString() + "|" + CreatureLevList.mId + " contains item with non-positive level"); } } - - if (CreatureLevList.mChanceNone < 0 or CreatureLevList.mChanceNone > 100) - { - messages.push_back(id.toString() + "|" + CreatureLevList.mId + " chance to be empty is not beetween 0 and 100"); - } } -void CSMTools::ReferenceableCheckStage::mItemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::ItemLevList >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::itemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::ItemLevList >& records, std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -633,7 +656,7 @@ void CSMTools::ReferenceableCheckStage::mItemLevelledListCheck(int stage, const const ESM::ItemLevList& ItemLevList = (static_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_ItemLevelledList, ItemLevList.mId); - for (int i = 0; i < ItemLevList.mList.size(); ++i) + for (unsigned i = 0; i < ItemLevList.mList.size(); ++i) { if (ItemLevList.mList[i].mId.empty()) { @@ -645,9 +668,222 @@ void CSMTools::ReferenceableCheckStage::mItemLevelledListCheck(int stage, const messages.push_back(id.toString() + "|" + ItemLevList.mId + " contains item with non-positive level"); } } +} - if (ItemLevList.mChanceNone < 0 or ItemLevList.mChanceNone > 100) +void CSMTools::ReferenceableCheckStage::lightCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Light >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) { - messages.push_back(id.toString() + "|" + ItemLevList.mId + " chance to be empty is not beetween 0 and 100"); + return; + } + + const ESM::Light& Light = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Light, Light.mId); + + if (Light.mData.mRadius < 0) + { + messages.push_back(id.toString() + "|" + Light.mId + " has negative light radius"); + } + + if (Light.mData.mFlags & ESM::Light::Carry) + { + if (Light.mIcon.empty()) //Needs to be checked with carrable flag + { + messages.push_back(id.toString() + "|" + Light.mId + " has no icon"); + } + + if (Light.mData.mWeight < 0) //probabbly needs to be checked only for carrable lights TODO + { + messages.push_back(id.toString() + "|" + Light.mId + " has negative weight"); + } + + if (Light.mData.mValue < 0) //probabbly needs to be checked only for carrable lights TODO + { + messages.push_back(id.toString() + "|" + Light.mId + " has negative value"); + } + + if (Light.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Light.mId + " has no model"); + } + + if (Light.mData.mTime < 0) + { + messages.push_back(id.toString() + "|" + Light.mId + " has negative duration"); + } } } + +void CSMTools::ReferenceableCheckStage::lockpickCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Lockpick >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Lockpick& Lockpick = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Lockpick, Lockpick.mId); + + //Checking for name + if (Lockpick.mName.empty()) + { + messages.push_back(id.toString() + "|" + Lockpick.mId + " has an empty name"); + } + + //Checking for weight + if (Lockpick.mData.mWeight < 0) + { + messages.push_back(id.toString() + "|" + Lockpick.mId + " has negative weight"); + } + + //Checking for value + if (Lockpick.mData.mValue < 0) + { + messages.push_back(id.toString() + "|" + Lockpick.mId + " has negative value"); + } + +//checking for model + if (Lockpick.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Lockpick.mId + " has no model"); + } + + //checking for icon + if (Lockpick.mIcon.empty()) + { + messages.push_back(id.toString() + "|" + Lockpick.mId + " has no icon"); + } + + if (Lockpick.mData.mQuality <= 0) + { + messages.push_back(id.toString() + "|" + Lockpick.mId + " has non-positive quality"); + } + + if (Lockpick.mData.mUses <= 0) + { + messages.push_back(id.toString() + "|" + Lockpick.mId + " has no uses left"); + } +} + +void CSMTools::ReferenceableCheckStage::miscCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Miscellaneous >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Miscellaneous& Miscellaneous = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Miscellaneous, Miscellaneous.mId); + + //Checking for name + if (Miscellaneous.mName.empty()) + { + messages.push_back(id.toString() + "|" + Miscellaneous.mId + " has an empty name"); + } + + //Checking for weight + if (Miscellaneous.mData.mWeight < 0) + { + messages.push_back(id.toString() + "|" + Miscellaneous.mId + " has negative weight"); + } + + //Checking for value + if (Miscellaneous.mData.mValue < 0) + { + messages.push_back(id.toString() + "|" + Miscellaneous.mId + " has negative value"); + } + +//checking for model + if (Miscellaneous.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Miscellaneous.mId + " has no model"); + } + + //checking for icon + if (Miscellaneous.mIcon.empty()) + { + messages.push_back(id.toString() + "|" + Miscellaneous.mId + " has no icon"); + } +} + +void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::NPC >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::NPC& NPC = (static_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Npc, NPC.mId); + + + + short level(NPC.mNpdt52.mLevel); + char Disposition(NPC.mNpdt52.mDisposition); + char Reputation(NPC.mNpdt52.mReputation); + char Rank(NPC.mNpdt52.mRank); + //Don't know what unknown is for + int Gold(NPC.mNpdt52.mGold); + + if (NPC.mNpdtType == 12) + { + if (NPC.mFlags ^ ESM::NPC::Flags::Autocalc) + { + messages.push_back(id.toString() + "|" + NPC.mId + " mNpdtType and flags mismatch!"); //should not happend? + return; + } + + level = NPC.mNpdt12.mLevel; + Disposition = NPC.mNpdt12.mDisposition; + Reputation = NPC.mNpdt12.mReputation; + Rank = NPC.mNpdt12.mRank; + Gold = NPC.mNpdt12.mGold; + } + else + { + if (NPC.mNpdt52.mHealth < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " health is negative value"); + } + + if (NPC.mNpdt52.mMana < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " mana is negative value"); + } + + if (NPC.mNpdt52.mFatigue < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " fatigue is negative value"); + } + } + + if (level < 1) + { + messages.push_back(id.toString() + "|" + NPC.mId + " level is non positive"); + } + + if (Gold < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " gold is negative value"); + } + + if (NPC.mName.empty()) + { + messages.push_back(id.toString() + "|" + NPC.mId + " has any empty name"); + } + + if (NPC.mClass.empty()) + { + messages.push_back(id.toString() + "|" + NPC.mId + " has any empty class"); + } + + //TODO: reputation, Disposition, rank, everything else +} diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 6bffc2b25..d4f7697ae 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -28,7 +28,11 @@ namespace CSMTools void doorCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void ingredientCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); - void mItemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void itemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void lightCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void lockpickCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void miscCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void npcCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); const CSMWorld::RefIdData mReferencables; @@ -46,6 +50,9 @@ namespace CSMTools const int mCreaturesLevListsSize; const int mItemLevelledListsSize; const int mLightsSize; + const int mLockpicksSize; + const int mMiscellaneousSize; + const int mNPCsSize; }; } #endif // REFERENCEABLECHECKSTAGE_H diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 54e2cd12f..9c0a857a5 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -9,187 +9,187 @@ CSMWorld::RefIdDataContainerBase::~RefIdDataContainerBase() {} CSMWorld::RefIdData::RefIdData() { - mRecordContainers.insert (std::make_pair (UniversalId::Type_Activator, &mActivators)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Potion, &mPotions)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Apparatus, &mApparati)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Armor, &mArmors)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Book, &mBooks)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Clothing, &mClothing)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Container, &mContainers)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Creature, &mCreatures)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Door, &mDoors)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Ingredient, &mIngredients)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_CreatureLevelledList, - &mCreatureLevelledLists)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_ItemLevelledList, &mItemLevelledLists)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Light, &mLights)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Lockpick, &mLockpicks)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Miscellaneous, &mMiscellaneous)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Npc, &mNpcs)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Probe, &mProbes)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Repair, &mRepairs)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Static, &mStatics)); - mRecordContainers.insert (std::make_pair (UniversalId::Type_Weapon, &mWeapons)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Activator, &mActivators)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Potion, &mPotions)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Apparatus, &mApparati)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Armor, &mArmors)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Book, &mBooks)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Clothing, &mClothing)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Container, &mContainers)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Creature, &mCreatures)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Door, &mDoors)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Ingredient, &mIngredients)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_CreatureLevelledList, + &mCreatureLevelledLists)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_ItemLevelledList, &mItemLevelledLists)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Light, &mLights)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Lockpick, &mLockpicks)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Miscellaneous, &mMiscellaneous)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Npc, &mNpcs)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Probe, &mProbes)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Repair, &mRepairs)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Static, &mStatics)); + mRecordContainers.insert(std::make_pair(UniversalId::Type_Weapon, &mWeapons)); } -CSMWorld::RefIdData::LocalIndex CSMWorld::RefIdData::globalToLocalIndex (int index) const +CSMWorld::RefIdData::LocalIndex CSMWorld::RefIdData::globalToLocalIndex(int index) const { - for (std::map::const_iterator iter ( - mRecordContainers.begin()); iter!=mRecordContainers.end(); ++iter) + for (std::map::const_iterator iter( + mRecordContainers.begin()); iter != mRecordContainers.end(); ++iter) { - if (indexsecond->getSize()) - return LocalIndex (index, iter->first); + if (index < iter->second->getSize()) + return LocalIndex(index, iter->first); index -= iter->second->getSize(); } - throw std::runtime_error ("RefIdData index out of range"); + throw std::runtime_error("RefIdData index out of range"); } -int CSMWorld::RefIdData::localToGlobalIndex (const LocalIndex& index) - const +int CSMWorld::RefIdData::localToGlobalIndex(const LocalIndex& index) +const { - std::map::const_iterator end = - mRecordContainers.find (index.second); + std::map::const_iterator end = + mRecordContainers.find(index.second); - if (end==mRecordContainers.end()) - throw std::logic_error ("invalid local index type"); + if (end == mRecordContainers.end()) + throw std::logic_error("invalid local index type"); int globalIndex = index.first; - for (std::map::const_iterator iter ( - mRecordContainers.begin()); iter!=end; ++iter) + for (std::map::const_iterator iter( + mRecordContainers.begin()); iter != end; ++iter) globalIndex += iter->second->getSize(); return globalIndex; } -CSMWorld::RefIdData::LocalIndex CSMWorld::RefIdData::searchId ( +CSMWorld::RefIdData::LocalIndex CSMWorld::RefIdData::searchId( const std::string& id) const { - std::string id2 = Misc::StringUtils::lowerCase (id); + std::string id2 = Misc::StringUtils::lowerCase(id); - std::map >::const_iterator iter = mIndex.find (id2); + std::map >::const_iterator iter = mIndex.find(id2); - if (iter==mIndex.end()) - return std::make_pair (-1, CSMWorld::UniversalId::Type_None); + if (iter == mIndex.end()) + return std::make_pair(-1, CSMWorld::UniversalId::Type_None); return iter->second; } -void CSMWorld::RefIdData::erase (int index, int count) +void CSMWorld::RefIdData::erase(int index, int count) { - LocalIndex localIndex = globalToLocalIndex (index); + LocalIndex localIndex = globalToLocalIndex(index); - std::map::const_iterator iter = - mRecordContainers.find (localIndex.second); + std::map::const_iterator iter = + mRecordContainers.find(localIndex.second); - while (count>0 && iter!=mRecordContainers.end()) + while (count > 0 && iter != mRecordContainers.end()) { int size = iter->second->getSize(); - if (localIndex.first+count>size) + if (localIndex.first + count > size) { - erase (localIndex, size-localIndex.first); - count -= size-localIndex.first; + erase(localIndex, size - localIndex.first); + count -= size - localIndex.first; ++iter; - if (iter==mRecordContainers.end()) - throw std::runtime_error ("invalid count value for erase operation"); + if (iter == mRecordContainers.end()) + throw std::runtime_error("invalid count value for erase operation"); localIndex.first = 0; localIndex.second = iter->first; } else { - erase (localIndex, count); + erase(localIndex, count); count = 0; } } } -const CSMWorld::RecordBase& CSMWorld::RefIdData::getRecord (const LocalIndex& index) const +const CSMWorld::RecordBase& CSMWorld::RefIdData::getRecord(const LocalIndex& index) const { - std::map::const_iterator iter = - mRecordContainers.find (index.second); + std::map::const_iterator iter = + mRecordContainers.find(index.second); - if (iter==mRecordContainers.end()) - throw std::logic_error ("invalid local index type"); + if (iter == mRecordContainers.end()) + throw std::logic_error("invalid local index type"); - return iter->second->getRecord (index.first); + return iter->second->getRecord(index.first); } -CSMWorld::RecordBase& CSMWorld::RefIdData::getRecord (const LocalIndex& index) +CSMWorld::RecordBase& CSMWorld::RefIdData::getRecord(const LocalIndex& index) { - std::map::iterator iter = - mRecordContainers.find (index.second); + std::map::iterator iter = + mRecordContainers.find(index.second); - if (iter==mRecordContainers.end()) - throw std::logic_error ("invalid local index type"); + if (iter == mRecordContainers.end()) + throw std::logic_error("invalid local index type"); - return iter->second->getRecord (index.first); + return iter->second->getRecord(index.first); } -void CSMWorld::RefIdData::appendRecord (UniversalId::Type type, const std::string& id) +void CSMWorld::RefIdData::appendRecord(UniversalId::Type type, const std::string& id) { - std::map::iterator iter = - mRecordContainers.find (type); + std::map::iterator iter = + mRecordContainers.find(type); - if (iter==mRecordContainers.end()) - throw std::logic_error ("invalid local index type"); + if (iter == mRecordContainers.end()) + throw std::logic_error("invalid local index type"); - iter->second->appendRecord (id); + iter->second->appendRecord(id); - mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (id), - LocalIndex (iter->second->getSize()-1, type))); + mIndex.insert(std::make_pair(Misc::StringUtils::lowerCase(id), + LocalIndex(iter->second->getSize() - 1, type))); } -int CSMWorld::RefIdData::getAppendIndex (UniversalId::Type type) const +int CSMWorld::RefIdData::getAppendIndex(UniversalId::Type type) const { int index = 0; - for (std::map::const_iterator iter ( - mRecordContainers.begin()); iter!=mRecordContainers.end(); ++iter) + for (std::map::const_iterator iter( + mRecordContainers.begin()); iter != mRecordContainers.end(); ++iter) { index += iter->second->getSize(); - if (type==iter->first) + if (type == iter->first) break; } return index; } -void CSMWorld::RefIdData::load (const LocalIndex& index, ESM::ESMReader& reader, bool base) +void CSMWorld::RefIdData::load(const LocalIndex& index, ESM::ESMReader& reader, bool base) { - std::map::iterator iter = - mRecordContainers.find (index.second); + std::map::iterator iter = + mRecordContainers.find(index.second); - if (iter==mRecordContainers.end()) - throw std::logic_error ("invalid local index type"); + if (iter == mRecordContainers.end()) + throw std::logic_error("invalid local index type"); - iter->second->load (index.first, reader, base); + iter->second->load(index.first, reader, base); } -void CSMWorld::RefIdData::erase (const LocalIndex& index, int count) +void CSMWorld::RefIdData::erase(const LocalIndex& index, int count) { - std::map::iterator iter = - mRecordContainers.find (index.second); + std::map::iterator iter = + mRecordContainers.find(index.second); - if (iter==mRecordContainers.end()) - throw std::logic_error ("invalid local index type"); + if (iter == mRecordContainers.end()) + throw std::logic_error("invalid local index type"); - for (int i=index.first; i::iterator result = - mIndex.find (Misc::StringUtils::lowerCase (iter->second->getId (i))); + mIndex.find(Misc::StringUtils::lowerCase(iter->second->getId(i))); - if (result!=mIndex.end()) - mIndex.erase (result); + if (result != mIndex.end()) + mIndex.erase(result); } - iter->second->erase (index.first, count); + iter->second->erase(index.first, count); } int CSMWorld::RefIdData::getSize() const @@ -197,39 +197,39 @@ int CSMWorld::RefIdData::getSize() const return mIndex.size(); } -std::vector CSMWorld::RefIdData::getIds (bool listDeleted) const +std::vector CSMWorld::RefIdData::getIds(bool listDeleted) const { std::vector ids; - for (std::map::const_iterator iter (mIndex.begin()); iter!=mIndex.end(); - ++iter) + for (std::map::const_iterator iter(mIndex.begin()); iter != mIndex.end(); + ++iter) { - if (listDeleted || !getRecord (iter->second).isDeleted()) + if (listDeleted || !getRecord(iter->second).isDeleted()) { - std::map::const_iterator container = - mRecordContainers.find (iter->second.second); + std::map::const_iterator container = + mRecordContainers.find(iter->second.second); - if (container==mRecordContainers.end()) - throw std::logic_error ("Invalid referenceable ID type"); + if (container == mRecordContainers.end()) + throw std::logic_error("Invalid referenceable ID type"); - ids.push_back (container->second->getId (iter->second.first)); + ids.push_back(container->second->getId(iter->second.first)); } } return ids; } -void CSMWorld::RefIdData::save (int index, ESM::ESMWriter& writer) const +void CSMWorld::RefIdData::save(int index, ESM::ESMWriter& writer) const { - LocalIndex localIndex = globalToLocalIndex (index); + LocalIndex localIndex = globalToLocalIndex(index); - std::map::const_iterator iter = - mRecordContainers.find (localIndex.second); + std::map::const_iterator iter = + mRecordContainers.find(localIndex.second); - if (iter==mRecordContainers.end()) - throw std::logic_error ("invalid local index type"); + if (iter == mRecordContainers.end()) + throw std::logic_error("invalid local index type"); - iter->second->save (localIndex.first, writer); + iter->second->save(localIndex.first, writer); } const CSMWorld::RefIdDataContainer< ESM::Book >& CSMWorld::RefIdData::getBooks() const @@ -296,3 +296,18 @@ const CSMWorld::RefIdDataContainer< ESM::Light >& CSMWorld::RefIdData::getLights { return mLights; } + +const CSMWorld::RefIdDataContainer< ESM::Lockpick >& CSMWorld::RefIdData::getLocpicks() const +{ + return mLockpicks; +} + +const CSMWorld::RefIdDataContainer< ESM::Miscellaneous >& CSMWorld::RefIdData::getMiscellaneous() const +{ + return mMiscellaneous; +} + +const CSMWorld::RefIdDataContainer< ESM::NPC >& CSMWorld::RefIdData::getNPCs() const +{ + return mNpcs; +} diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 6b6e01e01..8aa3c2522 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -234,7 +234,11 @@ namespace CSMWorld const RefIdDataContainer& getCreatureLevelledLists() const; const RefIdDataContainer& getItemLevelledList() const; const RefIdDataContainer& getLights() const; + const RefIdDataContainer& getLocpicks() const; + const RefIdDataContainer& getMiscellaneous() const; + const RefIdDataContainer& getNPCs() const; }; } #endif + diff --git a/components/esm/loadnpc.hpp b/components/esm/loadnpc.hpp index 1eac8d64f..08f678b45 100644 --- a/components/esm/loadnpc.hpp +++ b/components/esm/loadnpc.hpp @@ -105,7 +105,7 @@ struct NPC char mNpdtType; NPDTstruct52 mNpdt52; - NPDTstruct12 mNpdt12; // Use this if npdt52.gold == -10 + NPDTstruct12 mNpdt12; //for autocalculated characters int mFlags; From da3dda896ac2ad02f2ef8ad40f42c8fc4e0e3cd0 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 27 Dec 2013 22:57:36 +0100 Subject: [PATCH 26/74] Code compiles now --- apps/opencs/model/tools/referenceablecheck.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 6d06d6151..40f7c26d2 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -835,7 +835,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI if (NPC.mNpdtType == 12) { - if (NPC.mFlags ^ ESM::NPC::Flags::Autocalc) + if (NPC.mFlags ^ 0x0008) { messages.push_back(id.toString() + "|" + NPC.mId + " mNpdtType and flags mismatch!"); //should not happend? return; From 5406a70fdd7337d1aad3b4d86d9fae2eac2301f4 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 28 Dec 2013 11:34:51 +0100 Subject: [PATCH 27/74] still working on npc check --- .../opencs/model/tools/referenceablecheck.cpp | 62 +++++++++++++++++-- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 40f7c26d2..8ab163fc5 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -833,9 +833,9 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI //Don't know what unknown is for int Gold(NPC.mNpdt52.mGold); - if (NPC.mNpdtType == 12) + if (NPC.mNpdtType == 12) //12 = autocalculated { - if (NPC.mFlags ^ 0x0008) + if (NPC.mFlags ^ 0x0008) //0x0008 = autocalculated flag { messages.push_back(id.toString() + "|" + NPC.mId + " mNpdtType and flags mismatch!"); //should not happend? return; @@ -851,18 +851,64 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI { if (NPC.mNpdt52.mHealth < 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " health is negative value"); + messages.push_back(id.toString() + "|" + NPC.mId + " health has negative value"); } if (NPC.mNpdt52.mMana < 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " mana is negative value"); + messages.push_back(id.toString() + "|" + NPC.mId + " mana has negative value"); } if (NPC.mNpdt52.mFatigue < 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " fatigue is negative value"); + messages.push_back(id.toString() + "|" + NPC.mId + " fatigue has negative value"); } + + if (NPC.mNpdt52.mAgility < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " agility has negative value"); + } + + if (NPC.mNpdt52.mEndurance < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " endurance has negative value"); + } + + if (NPC.mNpdt52.mIntelligence < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " intelligence has negative value"); + } + + if (NPC.mNpdt52.mLuck < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " luck has negative value"); + } + + if (NPC.mNpdt52.mPersonality < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " personality has negative value"); + } + + if (NPC.mNpdt52.mStrength < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " strength has negative value"); + } + + if (NPC.mNpdt52.mSpeed < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " speed has negative value"); + } + + if (NPC.mNpdt52.mAgility < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " agility has negative value"); + } + + if (NPC.mNpdt52.mWillpower < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " willpower has negative value"); + } + } if (level < 1) @@ -884,6 +930,10 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI { messages.push_back(id.toString() + "|" + NPC.mId + " has any empty class"); } - + + if (NPC.mRace.empty()) + { + messages.push_back(id.toString() + "|" + NPC.mId + " has any empty race"); + } //TODO: reputation, Disposition, rank, everything else } From be6e47bcb6f40427a42bad1ec5f967be7cddbcfa Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 28 Dec 2013 15:51:38 +0100 Subject: [PATCH 28/74] Corrections --- .../opencs/model/tools/referenceablecheck.cpp | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 8ab163fc5..44dfbbef7 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -864,49 +864,44 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI messages.push_back(id.toString() + "|" + NPC.mId + " fatigue has negative value"); } - if (NPC.mNpdt52.mAgility < 0) + if (NPC.mNpdt52.mAgility == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " agility has negative value"); + messages.push_back(id.toString() + "|" + NPC.mId + " agility has zero value"); } - if (NPC.mNpdt52.mEndurance < 0) + if (NPC.mNpdt52.mEndurance == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " endurance has negative value"); + messages.push_back(id.toString() + "|" + NPC.mId + " endurance has zero value"); } - if (NPC.mNpdt52.mIntelligence < 0) + if (NPC.mNpdt52.mIntelligence == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " intelligence has negative value"); + messages.push_back(id.toString() + "|" + NPC.mId + " intelligence has zero value"); } - if (NPC.mNpdt52.mLuck < 0) + if (NPC.mNpdt52.mLuck == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " luck has negative value"); + messages.push_back(id.toString() + "|" + NPC.mId + " luck has zero value"); } - if (NPC.mNpdt52.mPersonality < 0) + if (NPC.mNpdt52.mPersonality == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " personality has negative value"); + messages.push_back(id.toString() + "|" + NPC.mId + " personality has zero value"); } - if (NPC.mNpdt52.mStrength < 0) + if (NPC.mNpdt52.mStrength == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " strength has negative value"); + messages.push_back(id.toString() + "|" + NPC.mId + " strength has zero value"); } - if (NPC.mNpdt52.mSpeed < 0) + if (NPC.mNpdt52.mSpeed == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " speed has negative value"); + messages.push_back(id.toString() + "|" + NPC.mId + " speed has zero value"); } - if (NPC.mNpdt52.mAgility < 0) + if (NPC.mNpdt52.mWillpower == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " agility has negative value"); - } - - if (NPC.mNpdt52.mWillpower < 0) - { - messages.push_back(id.toString() + "|" + NPC.mId + " willpower has negative value"); + messages.push_back(id.toString() + "|" + NPC.mId + " willpower has zero value"); } } From b9d1047ad640bb4a7b3c45d09f9a39fa36b3210f Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 28 Dec 2013 16:18:16 +0100 Subject: [PATCH 29/74] Small fix for lights. --- apps/opencs/model/tools/referenceablecheck.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 44dfbbef7..752a57f3e 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -694,12 +694,12 @@ void CSMTools::ReferenceableCheckStage::lightCheck(int stage, const CSMWorld::Re messages.push_back(id.toString() + "|" + Light.mId + " has no icon"); } - if (Light.mData.mWeight < 0) //probabbly needs to be checked only for carrable lights TODO + if (Light.mData.mWeight < 0) { messages.push_back(id.toString() + "|" + Light.mId + " has negative weight"); } - if (Light.mData.mValue < 0) //probabbly needs to be checked only for carrable lights TODO + if (Light.mData.mValue < 0) { messages.push_back(id.toString() + "|" + Light.mId + " has negative value"); } @@ -709,9 +709,9 @@ void CSMTools::ReferenceableCheckStage::lightCheck(int stage, const CSMWorld::Re messages.push_back(id.toString() + "|" + Light.mId + " has no model"); } - if (Light.mData.mTime < 0) + if (Light.mData.mTime == 0) { - messages.push_back(id.toString() + "|" + Light.mId + " has negative duration"); + messages.push_back(id.toString() + "|" + Light.mId + " has zero duration"); } } } @@ -930,5 +930,6 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI { messages.push_back(id.toString() + "|" + NPC.mId + " has any empty race"); } + //TODO: reputation, Disposition, rank, everything else } From 147ee0ace306f2dbfb452f95ab9727aa634cac98 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 28 Dec 2013 17:35:04 +0100 Subject: [PATCH 30/74] small oops + added new variables to the constructor --- apps/opencs/model/tools/referenceablecheck.cpp | 6 ++++-- apps/opencs/model/tools/referenceablecheck.hpp | 6 ++++-- apps/opencs/model/tools/tools.cpp | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 752a57f3e..abf13ced9 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -9,8 +9,10 @@ #include "../world/universalid.hpp" -CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable) : +CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, const CSMWorld::IdCollection& classes) : mReferencables(referenceable), + mClasses(classes), + mRaces(races), mBooksSize(mReferencables.getBooks().getSize()), mActivatorsSize(mReferencables.getActivators().getSize()), mPotionsSize(mReferencables.getPotions().getSize()), @@ -913,7 +915,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI if (Gold < 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " gold is negative value"); + messages.push_back(id.toString() + "|" + NPC.mId + " gold has negative value"); } if (NPC.mName.empty()) diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index d4f7697ae..9e53f2b19 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -11,7 +11,7 @@ namespace CSMTools class ReferenceableCheckStage : public CSMDoc::Stage { public: - ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable); + ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, const CSMWorld::IdCollection& classes); virtual void perform(int stage, std::vector< std::string >& messages); virtual int setup(); @@ -34,7 +34,9 @@ namespace CSMTools void miscCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void npcCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); - const CSMWorld::RefIdData mReferencables; + const CSMWorld::RefIdData& mReferencables; + const CSMWorld::IdCollection mRaces; + const CSMWorld::IdCollection mClasses; //SIZES OF CONCRETE TYPES const int mBooksSize; diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index d8cbb2fc1..945fa191f 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -76,7 +76,7 @@ CSMDoc::Operation *CSMTools::Tools::getVerifier() mVerifier->appendStage (new SpellCheckStage (mData.getSpells())); - mVerifier->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet())); + mVerifier->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet()), mData.getRaces(), mData.getClasses()); } return mVerifier; From bf0383fe056472442228e4cc4518dc2f47ee2d69 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 28 Dec 2013 18:07:01 +0100 Subject: [PATCH 31/74] Last fixes. --- .../opencs/model/tools/referenceablecheck.cpp | 54 +++++++++++++++---- .../opencs/model/tools/referenceablecheck.hpp | 4 +- apps/opencs/model/tools/tools.cpp | 2 +- 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index abf13ced9..a6fbe7f80 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -9,7 +9,7 @@ #include "../world/universalid.hpp" -CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, const CSMWorld::IdCollection& classes) : +CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, const CSMWorld::IdCollection& classes) : mReferencables(referenceable), mClasses(classes), mRaces(races), @@ -146,6 +146,12 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str } stage -= mMiscellaneousSize; + + if (stage < mNPCsSize) + { + npcCheck(stage, mReferencables.getNPCs(), messages); + return; + } } int CSMTools::ReferenceableCheckStage::setup() @@ -837,7 +843,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI if (NPC.mNpdtType == 12) //12 = autocalculated { - if (NPC.mFlags ^ 0x0008) //0x0008 = autocalculated flag + if (! NPC.mFlags & 0x0008) //0x0008 = autocalculated flag { messages.push_back(id.toString() + "|" + NPC.mId + " mNpdtType and flags mismatch!"); //should not happend? return; @@ -851,11 +857,6 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI } else { - if (NPC.mNpdt52.mHealth < 0) - { - messages.push_back(id.toString() + "|" + NPC.mId + " health has negative value"); - } - if (NPC.mNpdt52.mMana < 0) { messages.push_back(id.toString() + "|" + NPC.mId + " mana has negative value"); @@ -927,11 +928,46 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI { messages.push_back(id.toString() + "|" + NPC.mId + " has any empty class"); } - + else //checking if there is such class + { + bool nosuchclass(true); + + for (int i = 0; i < mClasses.getSize(); ++i) + { + if (mClasses.getRecord(i).get().mName == NPC.mClass) + { + nosuchclass = false; + break; + } + } + + if (nosuchclass) + { + messages.push_back(id.toString() + "|" + NPC.mId + " has invalid class"); + } + } + if (NPC.mRace.empty()) { messages.push_back(id.toString() + "|" + NPC.mId + " has any empty race"); } - + else //checking if there is a such race + { + bool nosuchrace(true); + + for (int i = 0; i < mRaces.getSize(); ++i) + { + if (mRaces.getRecord(i).get().mName == NPC.mRace) + { + nosuchrace = false; + break; + } + } + if (nosuchrace) + { + messages.push_back(id.toString() + "|" + NPC.mId + " has invalid race"); + } + } + //TODO: reputation, Disposition, rank, everything else } diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 9e53f2b19..c87d80b0f 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -35,8 +35,8 @@ namespace CSMTools void npcCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); const CSMWorld::RefIdData& mReferencables; - const CSMWorld::IdCollection mRaces; - const CSMWorld::IdCollection mClasses; + const CSMWorld::IdCollection& mRaces; + const CSMWorld::IdCollection& mClasses; //SIZES OF CONCRETE TYPES const int mBooksSize; diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index 945fa191f..15a7bd181 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -76,7 +76,7 @@ CSMDoc::Operation *CSMTools::Tools::getVerifier() mVerifier->appendStage (new SpellCheckStage (mData.getSpells())); - mVerifier->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet()), mData.getRaces(), mData.getClasses()); + mVerifier->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses())); } return mVerifier; From 9df6d23afcc929bd93368a9e553d45dea611050d Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 29 Dec 2013 20:15:00 +0100 Subject: [PATCH 32/74] removing member size values, since this does not work properly. --- .../opencs/model/tools/referenceablecheck.cpp | 113 ++++++++++-------- .../opencs/model/tools/referenceablecheck.hpp | 18 --- 2 files changed, 64 insertions(+), 67 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index a6fbe7f80..79f6009da 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -12,145 +12,159 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, const CSMWorld::IdCollection& classes) : mReferencables(referenceable), mClasses(classes), - mRaces(races), - mBooksSize(mReferencables.getBooks().getSize()), - mActivatorsSize(mReferencables.getActivators().getSize()), - mPotionsSize(mReferencables.getPotions().getSize()), - mApparatiSize(mReferencables.getApparati().getSize()), - mArmorsSzie(mReferencables.getArmors().getSize()), - mClothingSize(mReferencables.getClothing().getSize()), - mContainersSize(mReferencables.getContainers().getSize()), - mCreaturesSize(mReferencables.getCreatures().getSize()), - mDoorsSize(mReferencables.getDoors().getSize()), - mIngredientsSize(mReferencables.getIngredients().getSize()), - mCreaturesLevListsSize(mReferencables.getCreatureLevelledLists().getSize()), - mItemLevelledListsSize(mReferencables.getItemLevelledList().getSize()), - mLightsSize(mReferencables.getLights().getSize()), - mLockpicksSize(mReferencables.getLocpicks().getSize()), - mMiscellaneousSize(mReferencables.getMiscellaneous().getSize()), - mNPCsSize(mReferencables.getNPCs().getSize()) + mRaces(races) { } 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. - if (stage < mBooksSize) + const int BookSize(mReferencables.getBooks().getSize()); + + if (stage < BookSize) { bookCheck(stage, mReferencables.getBooks(), messages); return; } - stage -= mBooksSize; + stage -= BookSize; - if (stage < mActivatorsSize) + const int ActivatorSize(mReferencables.getActivators().getSize()); + + if (stage < ActivatorSize) { activatorCheck(stage, mReferencables.getActivators(), messages); return; } - stage -= mActivatorsSize; + stage -= ActivatorSize; - if (stage < mPotionsSize) + const int PotionSize(mReferencables.getActivators().getSize()); + + if (stage < PotionSize) { potionCheck(stage, mReferencables.getPotions(), messages); return; } - stage -= mPotionsSize; + stage -= PotionSize; - if (stage < mApparatiSize) + const int ApparatusSize(mReferencables.getApparati().getSize()); + + if (stage < ApparatusSize) { apparatusCheck(stage, mReferencables.getApparati(), messages); return; } - stage -= mApparatiSize; + stage -= ApparatusSize; - if (stage < mArmorsSzie) + const int ArmorSize(mReferencables.getArmors().getSize()); + + if (stage < ArmorSize) { armorCheck(stage, mReferencables.getArmors(), messages); return; } - stage -= mArmorsSzie; + stage -= ArmorSize; - if (stage < mClothingSize) + const int ClothingSize(mReferencables.getClothing().getSize()); + + if (stage < ClothingSize) { clothingCheck(stage, mReferencables.getClothing(), messages); return; } - stage -= mClothingSize; + stage -= ClothingSize; - if (stage < mContainersSize) + const int ContainerSize(mReferencables.getContainers().getSize()); + + if (stage < ContainerSize) { containerCheck(stage, mReferencables.getContainers(), messages); return; } - stage -= mContainersSize; + stage -= ContainerSize; - if (stage < mDoorsSize) + const int DoorSize(mReferencables.getDoors().getSize()); + + if (stage < DoorSize) { doorCheck(stage, mReferencables.getDoors(), messages); return; } - stage -= mDoorsSize; + stage -= DoorSize; - if (stage < mIngredientsSize) + const int IngredientSize(mReferencables.getIngredients().getSize()); + + if (stage < IngredientSize) { ingredientCheck(stage, mReferencables.getIngredients(), messages); return; } - stage -= mIngredientsSize; + stage -= IngredientSize; - if (stage < mCreaturesLevListsSize) + const int CreatureLevListSize(mReferencables.getCreatureLevelledLists().getSize()); + + if (stage < CreatureLevListSize) { creaturesLevListCheck(stage, mReferencables.getCreatureLevelledLists(), messages); return; } - stage -= mCreaturesLevListsSize; + stage -= CreatureLevListSize; - if (stage < mItemLevelledListsSize) + const int ItemLevelledListSize(mReferencables.getItemLevelledList().getSize()); + + if (stage < ItemLevelledListSize) { itemLevelledListCheck(stage, mReferencables.getItemLevelledList(), messages); return; } - stage -= mItemLevelledListsSize; + stage -= ItemLevelledListSize; - if (stage < mLightsSize) + const int LightSize(mReferencables.getLights().getSize()); + + if (stage < LightSize) { lightCheck(stage, mReferencables.getLights(), messages); return; } - stage -= mLightsSize; + stage -= LightSize; - if (stage < mLockpicksSize) + const int LockpickSize(mReferencables.getLocpicks().getSize()); + + if (stage < LockpickSize) { lockpickCheck(stage, mReferencables.getLocpicks(), messages); return; } - stage -= mLockpicksSize; + stage -= LockpickSize; - if (stage < mMiscellaneousSize) + const int MiscSize(mReferencables.getMiscellaneous().getSize()); + + if (stage < MiscSize) { miscCheck(stage, mReferencables.getMiscellaneous(), messages); return; } - stage -= mMiscellaneousSize; - - if (stage < mNPCsSize) + stage -= MiscSize; + + const int NPCSize(mReferencables.getNPCs().getSize()); + + if (stage < NPCSize) { - npcCheck(stage, mReferencables.getNPCs(), messages); - return; + npcCheck(stage, mReferencables.getNPCs(), messages); + return; } } @@ -963,6 +977,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI break; } } + if (nosuchrace) { messages.push_back(id.toString() + "|" + NPC.mId + " has invalid race"); diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index c87d80b0f..1d85dc310 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -37,24 +37,6 @@ namespace CSMTools const CSMWorld::RefIdData& mReferencables; const CSMWorld::IdCollection& mRaces; const CSMWorld::IdCollection& mClasses; - - //SIZES OF CONCRETE TYPES - const int mBooksSize; - const int mActivatorsSize; - const int mPotionsSize; - const int mApparatiSize; - const int mArmorsSzie; - const int mClothingSize; - const int mContainersSize; - const int mCreaturesSize; - const int mDoorsSize; - const int mIngredientsSize; - const int mCreaturesLevListsSize; - const int mItemLevelledListsSize; - const int mLightsSize; - const int mLockpicksSize; - const int mMiscellaneousSize; - const int mNPCsSize; }; } #endif // REFERENCEABLECHECKSTAGE_H From e321d571e1ff72456aab8a78907489022576a248 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 29 Dec 2013 21:02:53 +0100 Subject: [PATCH 33/74] Added faction check. --- .../opencs/model/tools/referenceablecheck.cpp | 35 +++++++++++++++++-- .../opencs/model/tools/referenceablecheck.hpp | 3 +- apps/opencs/model/tools/tools.cpp | 2 +- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 79f6009da..5406ca08e 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -9,10 +9,11 @@ #include "../world/universalid.hpp" -CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, const CSMWorld::IdCollection& classes) : +CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, const CSMWorld::IdCollection& classes, const CSMWorld::IdCollection& faction) : mReferencables(referenceable), mClasses(classes), - mRaces(races) + mRaces(races), + mFactions(faction) { } @@ -857,7 +858,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI if (NPC.mNpdtType == 12) //12 = autocalculated { - if (! NPC.mFlags & 0x0008) //0x0008 = autocalculated flag + if (NPC.mFlags & 0x0008 == 0) //0x0008 = autocalculated flag { messages.push_back(id.toString() + "|" + NPC.mId + " mNpdtType and flags mismatch!"); //should not happend? return; @@ -984,5 +985,33 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI } } + if (Disposition < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " has negative disposition"); + } + + if (Reputation < 0) + { + messages.push_back(id.toString() + "|" + NPC.mId + " has negative reputation"); + } + + if(!NPC.mFaction.empty()) + { + bool nosuchfaction(true); + + for (int i = 0; i < mRaces.getSize(); ++i) + { + if (mFactions.getRecord(i).get().mName == NPC.mFaction) + { + nosuchfaction = false; + break; + } + } + + if (nosuchfaction) + { + messages.push_back(id.toString() + "|" + NPC.mId + " has invalid faction"); + } + } //TODO: reputation, Disposition, rank, everything else } diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 1d85dc310..591e3d335 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -11,7 +11,7 @@ namespace CSMTools class ReferenceableCheckStage : public CSMDoc::Stage { public: - ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, const CSMWorld::IdCollection& classes); + ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, const CSMWorld::IdCollection& classes, const CSMWorld::IdCollection& factions); virtual void perform(int stage, std::vector< std::string >& messages); virtual int setup(); @@ -37,6 +37,7 @@ namespace CSMTools const CSMWorld::RefIdData& mReferencables; const CSMWorld::IdCollection& mRaces; const CSMWorld::IdCollection& mClasses; + const CSMWorld::IdCollection& mFactions; }; } #endif // REFERENCEABLECHECKSTAGE_H diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index 15a7bd181..b5320ff9f 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -76,7 +76,7 @@ CSMDoc::Operation *CSMTools::Tools::getVerifier() mVerifier->appendStage (new SpellCheckStage (mData.getSpells())); - mVerifier->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses())); + mVerifier->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses(), mData.getFactions())); } return mVerifier; From 13637e7166825a1c9dce6f06614b7b5e214b0ea0 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 29 Dec 2013 21:45:09 +0100 Subject: [PATCH 34/74] Dynamic_casting, checking rank. Commented out faction check, since it will not work. --- .../opencs/model/tools/referenceablecheck.cpp | 72 ++++++++++--------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 5406ca08e..010fb868c 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -183,7 +183,7 @@ void CSMTools::ReferenceableCheckStage::bookCheck(int stage, const CSMWorld::Ref return; } - const ESM::Book& Book = (static_cast& >(baserecord)).get(); + const ESM::Book& Book = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Book, Book.mId); //Checking for name @@ -232,7 +232,7 @@ void CSMTools::ReferenceableCheckStage::activatorCheck(int stage, const CSMWorld return; } - const ESM::Activator& Activator = (static_cast& >(baserecord)).get(); + const ESM::Activator& Activator = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Activator, Activator.mId); //Checking for model, IIRC all activators should have a model @@ -251,7 +251,7 @@ void CSMTools::ReferenceableCheckStage::potionCheck(int stage, const CSMWorld::R return; } - const ESM::Potion& Potion = (static_cast& >(baserecord)).get(); + const ESM::Potion& Potion = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Potion, Potion.mId); //Checking for name @@ -297,7 +297,7 @@ void CSMTools::ReferenceableCheckStage::apparatusCheck(int stage, const CSMWorld return; } - const ESM::Apparatus& Apparatus = (static_cast& >(baserecord)).get(); + const ESM::Apparatus& Apparatus = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Apparatus, Apparatus.mId); //Checking for name @@ -346,7 +346,7 @@ void CSMTools::ReferenceableCheckStage::armorCheck(int stage, const CSMWorld::Re return; } - const ESM::Armor& Armor = (static_cast& >(baserecord)).get(); + const ESM::Armor& Armor = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Armor, Armor.mId); //Checking for name @@ -407,7 +407,7 @@ void CSMTools::ReferenceableCheckStage::clothingCheck(int stage, const CSMWorld: return; } - const ESM::Clothing& Clothing = (static_cast& >(baserecord)).get(); + const ESM::Clothing& Clothing = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Clothing, Clothing.mId); //Checking for name @@ -456,7 +456,7 @@ void CSMTools::ReferenceableCheckStage::containerCheck(int stage, const CSMWorld return; } - const ESM::Container& Container = (static_cast& >(baserecord)).get(); + const ESM::Container& Container = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Container, Container.mId); //Checking for model, IIRC all containers should have a model @@ -487,7 +487,7 @@ void CSMTools::ReferenceableCheckStage::creatureCheck(int stage, const CSMWorld: return; } - const ESM::Creature& Creature = (static_cast&>(baserecord)).get(); + const ESM::Creature& Creature = (dynamic_cast&>(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Creature, Creature.mId); if (Creature.mModel.empty()) @@ -581,7 +581,7 @@ void CSMTools::ReferenceableCheckStage::doorCheck(int stage, const CSMWorld::Ref return; } - const ESM::Door& Door = (static_cast&>(baserecord)).get(); + const ESM::Door& Door = (dynamic_cast&>(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Door, Door.mId); //usual, name and model @@ -607,7 +607,7 @@ void CSMTools::ReferenceableCheckStage::ingredientCheck(int stage, const CSMWorl return; } - const ESM::Ingredient& Ingredient = (static_cast& >(baserecord)).get(); + const ESM::Ingredient& Ingredient = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Ingredient, Ingredient.mId); //Checking for name @@ -650,7 +650,7 @@ void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(int stage, const C return; } - const ESM::CreatureLevList& CreatureLevList = (static_cast& >(baserecord)).get(); + const ESM::CreatureLevList& CreatureLevList = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_CreatureLevelledList, CreatureLevList.mId); //CreatureLevList but Type_CreatureLevelledList :/ for (unsigned i = 0; i < CreatureLevList.mList.size(); ++i) @@ -676,7 +676,7 @@ void CSMTools::ReferenceableCheckStage::itemLevelledListCheck(int stage, const C return; } - const ESM::ItemLevList& ItemLevList = (static_cast& >(baserecord)).get(); + const ESM::ItemLevList& ItemLevList = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_ItemLevelledList, ItemLevList.mId); for (unsigned i = 0; i < ItemLevList.mList.size(); ++i) @@ -702,7 +702,7 @@ void CSMTools::ReferenceableCheckStage::lightCheck(int stage, const CSMWorld::Re return; } - const ESM::Light& Light = (static_cast& >(baserecord)).get(); + const ESM::Light& Light = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Light, Light.mId); if (Light.mData.mRadius < 0) @@ -748,7 +748,7 @@ void CSMTools::ReferenceableCheckStage::lockpickCheck(int stage, const CSMWorld: return; } - const ESM::Lockpick& Lockpick = (static_cast& >(baserecord)).get(); + const ESM::Lockpick& Lockpick = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Lockpick, Lockpick.mId); //Checking for name @@ -801,7 +801,7 @@ void CSMTools::ReferenceableCheckStage::miscCheck(int stage, const CSMWorld::Ref return; } - const ESM::Miscellaneous& Miscellaneous = (static_cast& >(baserecord)).get(); + const ESM::Miscellaneous& Miscellaneous = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Miscellaneous, Miscellaneous.mId); //Checking for name @@ -844,7 +844,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI return; } - const ESM::NPC& NPC = (static_cast& >(baserecord)).get(); + const ESM::NPC& NPC = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Npc, NPC.mId); @@ -858,7 +858,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI if (NPC.mNpdtType == 12) //12 = autocalculated { - if (NPC.mFlags & 0x0008 == 0) //0x0008 = autocalculated flag + if ((NPC.mFlags & 0x0008) == 0) //0x0008 = autocalculated flag { messages.push_back(id.toString() + "|" + NPC.mId + " mNpdtType and flags mismatch!"); //should not happend? return; @@ -949,7 +949,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI for (int i = 0; i < mClasses.getSize(); ++i) { - if (mClasses.getRecord(i).get().mName == NPC.mClass) + if (dynamic_cast(mClasses.getRecord(i).get()).mId == NPC.mClass) { nosuchclass = false; break; @@ -972,7 +972,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI for (int i = 0; i < mRaces.getSize(); ++i) { - if (mRaces.getRecord(i).get().mName == NPC.mRace) + if (dynamic_cast(mRaces.getRecord(i).get()).mName == NPC.mRace) { nosuchrace = false; break; @@ -995,23 +995,31 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI messages.push_back(id.toString() + "|" + NPC.mId + " has negative reputation"); } - if(!NPC.mFaction.empty()) + if (!NPC.mFaction.empty()) { - bool nosuchfaction(true); - - for (int i = 0; i < mRaces.getSize(); ++i) + if (Rank < 0) { - if (mFactions.getRecord(i).get().mName == NPC.mFaction) - { - nosuchfaction = false; - break; - } + messages.push_back(id.toString() + "|" + NPC.mId + " has negative rank"); } - if (nosuchfaction) - { - messages.push_back(id.toString() + "|" + NPC.mId + " has invalid faction"); - } + //This code does not work at the moment. nosuchfaction is true for every npc record + /* + bool nosuchfaction(true); + for (int i = 0; i < mRaces.getSize(); ++i) + { + if (dynamic_cast(mFactions.getRecord(i).get()).mName == NPC.mFaction) + { + nosuchfaction = false; + break; + } + } + + if (nosuchfaction) + { + messages.push_back(id.toString() + "|" + NPC.mId + " has invalid faction"); + } + */ } + //TODO: reputation, Disposition, rank, everything else } From 842e26b8e5bb17a76298308ac3c4565964b3c891 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 29 Dec 2013 21:53:33 +0100 Subject: [PATCH 35/74] added comment --- apps/opencs/model/tools/referenceablecheck.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 010fb868c..d2053c1a6 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -972,7 +972,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI for (int i = 0; i < mRaces.getSize(); ++i) { - if (dynamic_cast(mRaces.getRecord(i).get()).mName == NPC.mRace) + if (dynamic_cast(mRaces.getRecord(i).get()).mName == NPC.mRace) //mId in class, mName for race. Stupid. { nosuchrace = false; break; @@ -990,7 +990,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI messages.push_back(id.toString() + "|" + NPC.mId + " has negative disposition"); } - if (Reputation < 0) + if (Reputation < 0) //It seems that no character in Morrowind.esm have negative reputation. I'm assuming that negative reputation is invalid { messages.push_back(id.toString() + "|" + NPC.mId + " has negative reputation"); } From c89608f390c1d82a749aef448240481bc80afaff Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Mon, 30 Dec 2013 11:39:03 +0100 Subject: [PATCH 36/74] Check for head and hair. Correct faction check. --- .../opencs/model/tools/referenceablecheck.cpp | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index d2053c1a6..ad52c5962 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -995,30 +995,38 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI messages.push_back(id.toString() + "|" + NPC.mId + " has negative reputation"); } - if (!NPC.mFaction.empty()) + if (NPC.mFaction.empty() == false) { if (Rank < 0) { messages.push_back(id.toString() + "|" + NPC.mId + " has negative rank"); } - //This code does not work at the moment. nosuchfaction is true for every npc record - /* - bool nosuchfaction(true); - for (int i = 0; i < mRaces.getSize(); ++i) - { - if (dynamic_cast(mFactions.getRecord(i).get()).mName == NPC.mFaction) - { - nosuchfaction = false; - break; - } - } + bool nosuchfaction(true); - if (nosuchfaction) - { - messages.push_back(id.toString() + "|" + NPC.mId + " has invalid faction"); - } - */ + for (int i = 0; i < mFactions.getSize(); ++i) + { + if (dynamic_cast(mFactions.getRecord(i).get()).mId == NPC.mFaction) + { + nosuchfaction = false; + break; + } + } + + if (nosuchfaction) + { + messages.push_back(id.toString() + "|" + NPC.mId + " has invalid faction"); + } + } + + if (NPC.mHead.empty()) + { + messages.push_back(id.toString() + "|" + NPC.mId + " has no head"); + } + + if (NPC.mHair.empty()) + { + messages.push_back(id.toString() + "|" + NPC.mId + " has no har"); } //TODO: reputation, Disposition, rank, everything else From 3758fe38340ed147e0d73a2b8f8df0d886e8624e Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Mon, 30 Dec 2013 13:23:16 +0100 Subject: [PATCH 37/74] reformatted --- .../opencs/model/tools/referenceablecheck.hpp | 22 +-- apps/opencs/model/tools/tools.cpp | 94 +++++------ apps/opencs/model/world/refidcollection.hpp | 48 +++--- apps/opencs/model/world/refiddata.hpp | 147 +++++++++--------- 4 files changed, 157 insertions(+), 154 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 591e3d335..fcf774f14 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -16,7 +16,7 @@ namespace CSMTools virtual int setup(); private: - //CONCRETE CHECKS + //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 potionCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); @@ -26,18 +26,18 @@ namespace CSMTools void containerCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void creatureCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void doorCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); - void ingredientCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); - void creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); - void itemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); - void lightCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); - void lockpickCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); - void miscCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); - void npcCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void ingredientCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void itemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void lightCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void lockpickCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void miscCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void npcCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); const CSMWorld::RefIdData& mReferencables; - const CSMWorld::IdCollection& mRaces; - const CSMWorld::IdCollection& mClasses; - const CSMWorld::IdCollection& mFactions; + const CSMWorld::IdCollection& mRaces; + const CSMWorld::IdCollection& mClasses; + const CSMWorld::IdCollection& mFactions; }; } #endif // REFERENCEABLECHECKSTAGE_H diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index b5320ff9f..c25811ea4 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -21,7 +21,7 @@ #include "spellcheck.hpp" #include "referenceablecheck.hpp" -CSMDoc::Operation *CSMTools::Tools::get (int type) +CSMDoc::Operation* CSMTools::Tools::get(int type) { switch (type) { @@ -31,60 +31,60 @@ CSMDoc::Operation *CSMTools::Tools::get (int type) return 0; } -const CSMDoc::Operation *CSMTools::Tools::get (int type) const +const CSMDoc::Operation* CSMTools::Tools::get(int type) const { - return const_cast (this)->get (type); + return const_cast(this)->get(type); } -CSMDoc::Operation *CSMTools::Tools::getVerifier() +CSMDoc::Operation* CSMTools::Tools::getVerifier() { if (!mVerifier) { - mVerifier = new CSMDoc::Operation (CSMDoc::State_Verifying, false); + mVerifier = new CSMDoc::Operation(CSMDoc::State_Verifying, false); - connect (mVerifier, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int))); - connect (mVerifier, SIGNAL (done (int)), this, SIGNAL (done (int))); - connect (mVerifier, SIGNAL (reportMessage (const QString&, int)), - this, SLOT (verifierMessage (const QString&, int))); + connect(mVerifier, SIGNAL(progress(int, int, int)), this, SIGNAL(progress(int, int, int))); + connect(mVerifier, SIGNAL(done(int)), this, SIGNAL(done(int))); + connect(mVerifier, SIGNAL(reportMessage(const QString&, int)), + this, SLOT(verifierMessage(const QString&, int))); std::vector mandatoryIds; // I want C++11, damn it! - mandatoryIds.push_back ("Day"); - mandatoryIds.push_back ("DaysPassed"); - mandatoryIds.push_back ("GameHour"); - mandatoryIds.push_back ("Month"); - mandatoryIds.push_back ("PCRace"); - mandatoryIds.push_back ("PCVampire"); - mandatoryIds.push_back ("PCWerewolf"); - mandatoryIds.push_back ("PCYear"); + mandatoryIds.push_back("Day"); + mandatoryIds.push_back("DaysPassed"); + mandatoryIds.push_back("GameHour"); + mandatoryIds.push_back("Month"); + mandatoryIds.push_back("PCRace"); + mandatoryIds.push_back("PCVampire"); + mandatoryIds.push_back("PCWerewolf"); + mandatoryIds.push_back("PCYear"); - mVerifier->appendStage (new MandatoryIdStage (mData.getGlobals(), - CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Globals), mandatoryIds)); + mVerifier->appendStage(new MandatoryIdStage(mData.getGlobals(), + CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Globals), mandatoryIds)); - mVerifier->appendStage (new SkillCheckStage (mData.getSkills())); + mVerifier->appendStage(new SkillCheckStage(mData.getSkills())); - mVerifier->appendStage (new ClassCheckStage (mData.getClasses())); + mVerifier->appendStage(new ClassCheckStage(mData.getClasses())); - mVerifier->appendStage (new FactionCheckStage (mData.getFactions())); + mVerifier->appendStage(new FactionCheckStage(mData.getFactions())); - mVerifier->appendStage (new RaceCheckStage (mData.getRaces())); + mVerifier->appendStage(new RaceCheckStage(mData.getRaces())); - mVerifier->appendStage (new SoundCheckStage (mData.getSounds())); + mVerifier->appendStage(new SoundCheckStage(mData.getSounds())); - mVerifier->appendStage (new RegionCheckStage (mData.getRegions())); + mVerifier->appendStage(new RegionCheckStage(mData.getRegions())); - mVerifier->appendStage (new BirthsignCheckStage (mData.getBirthsigns())); + mVerifier->appendStage(new BirthsignCheckStage(mData.getBirthsigns())); - mVerifier->appendStage (new SpellCheckStage (mData.getSpells())); - - mVerifier->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses(), mData.getFactions())); + mVerifier->appendStage(new SpellCheckStage(mData.getSpells())); + + mVerifier->appendStage(new ReferenceableCheckStage(mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses(), mData.getFactions())); } return mVerifier; } -CSMTools::Tools::Tools (CSMWorld::Data& data) : mData (data), mVerifier (0), mNextReportNumber (0) +CSMTools::Tools::Tools(CSMWorld::Data& data) : mData(data), mVerifier(0), mNextReportNumber(0) { - for (std::map::iterator iter (mReports.begin()); iter!=mReports.end(); ++iter) + for (std::map::iterator iter(mReports.begin()); iter != mReports.end(); ++iter) delete iter->second; } @@ -95,17 +95,17 @@ CSMTools::Tools::~Tools() CSMWorld::UniversalId CSMTools::Tools::runVerifier() { - mReports.insert (std::make_pair (mNextReportNumber++, new ReportModel)); - mActiveReports[CSMDoc::State_Verifying] = mNextReportNumber-1; + mReports.insert(std::make_pair(mNextReportNumber++, new ReportModel)); + mActiveReports[CSMDoc::State_Verifying] = mNextReportNumber - 1; getVerifier()->start(); - return CSMWorld::UniversalId (CSMWorld::UniversalId::Type_VerificationResults, mNextReportNumber-1); + return CSMWorld::UniversalId(CSMWorld::UniversalId::Type_VerificationResults, mNextReportNumber - 1); } -void CSMTools::Tools::abortOperation (int type) +void CSMTools::Tools::abortOperation(int type) { - if (CSMDoc::Operation *operation = get (type)) + if (CSMDoc::Operation* operation = get(type)) operation->abort(); } @@ -113,32 +113,32 @@ int CSMTools::Tools::getRunningOperations() const { static const int sOperations[] = { - CSMDoc::State_Verifying, + CSMDoc::State_Verifying, -1 }; int result = 0; - for (int i=0; sOperations[i]!=-1; ++i) - if (const CSMDoc::Operation *operation = get (sOperations[i])) + for (int i = 0; sOperations[i] != -1; ++i) + if (const CSMDoc::Operation* operation = get(sOperations[i])) if (operation->isRunning()) result |= sOperations[i]; return result; } -CSMTools::ReportModel *CSMTools::Tools::getReport (const CSMWorld::UniversalId& id) +CSMTools::ReportModel* CSMTools::Tools::getReport(const CSMWorld::UniversalId& id) { - if (id.getType()!=CSMWorld::UniversalId::Type_VerificationResults) - throw std::logic_error ("invalid request for report model: " + id.toString()); + if (id.getType() != CSMWorld::UniversalId::Type_VerificationResults) + throw std::logic_error("invalid request for report model: " + id.toString()); - return mReports.at (id.getIndex()); + return mReports.at(id.getIndex()); } -void CSMTools::Tools::verifierMessage (const QString& message, int type) +void CSMTools::Tools::verifierMessage(const QString& message, int type) { - std::map::iterator iter = mActiveReports.find (type); + std::map::iterator iter = mActiveReports.find(type); - if (iter!=mActiveReports.end()) - mReports[iter->second]->add (message.toStdString()); + if (iter != mActiveReports.end()) + mReports[iter->second]->add(message.toStdString()); } diff --git a/apps/opencs/model/world/refidcollection.hpp b/apps/opencs/model/world/refidcollection.hpp index 70cae53c8..1a21de8f4 100644 --- a/apps/opencs/model/world/refidcollection.hpp +++ b/apps/opencs/model/world/refidcollection.hpp @@ -25,9 +25,9 @@ namespace CSMWorld public: - RefIdColumn (int columnId, Display displayType, - int flag = Flag_Table | Flag_Dialogue, bool editable = true, - bool userEditable = true); + RefIdColumn(int columnId, Display displayType, + int flag = Flag_Table | Flag_Dialogue, bool editable = true, + bool userEditable = true); virtual bool isEditable() const; @@ -40,11 +40,11 @@ namespace CSMWorld RefIdData mData; std::deque mColumns; - std::map mAdapters; + std::map mAdapters; private: - const RefIdAdapter& findAdaptor (UniversalId::Type) const; + const RefIdAdapter& findAdaptor(UniversalId::Type) const; ///< Throws an exception if no adaptor for \a Type can be found. public: @@ -55,60 +55,60 @@ namespace CSMWorld virtual int getSize() const; - virtual std::string getId (int index) const; + virtual std::string getId(int index) const; - virtual int getIndex (const std::string& id) const; + virtual int getIndex(const std::string& id) const; virtual int getColumns() const; - virtual const ColumnBase& getColumn (int column) const; + virtual const ColumnBase& getColumn(int column) const; - virtual QVariant getData (int index, int column) const; + virtual QVariant getData(int index, int column) const; - virtual void setData (int index, int column, const QVariant& data); + virtual void setData(int index, int column, const QVariant& data); - virtual void removeRows (int index, int count); + virtual void removeRows(int index, int count); - virtual void appendBlankRecord (const std::string& id, UniversalId::Type type); + virtual void appendBlankRecord(const std::string& id, UniversalId::Type type); ///< \param type Will be ignored, unless the collection supports multiple record types - virtual int searchId (const std::string& id) const; + virtual int searchId(const std::string& id) const; ////< Search record with \a id. /// \return index of record (if found) or -1 (not found) - virtual void replace (int index, const RecordBase& record); + virtual void replace(int index, const RecordBase& record); ///< If the record type does not match, an exception is thrown. /// /// \attention \a record must not change the ID. - virtual void appendRecord (const RecordBase& record, UniversalId::Type type); + virtual void appendRecord(const RecordBase& record, UniversalId::Type type); ///< If the record type does not match, an exception is thrown. /// ///< \param type Will be ignored, unless the collection supports multiple record types - virtual const RecordBase& getRecord (const std::string& id) const; + virtual const RecordBase& getRecord(const std::string& id) const; - virtual const RecordBase& getRecord (int index) const; + virtual const RecordBase& getRecord(int index) const; - void load (ESM::ESMReader& reader, bool base, UniversalId::Type type); + void load(ESM::ESMReader& reader, bool base, UniversalId::Type type); - virtual int getAppendIndex (const std::string& id, UniversalId::Type type) const; + virtual int getAppendIndex(const std::string& id, UniversalId::Type type) const; ///< \param type Will be ignored, unless the collection supports multiple record types - virtual std::vector getIds (bool listDeleted) const; + virtual std::vector getIds(bool listDeleted) const; ///< Return a sorted collection of all IDs /// /// \param listDeleted include deleted record in the list - virtual bool reorderRows (int baseIndex, const std::vector& newOrder); + virtual bool reorderRows(int baseIndex, const std::vector& newOrder); ///< Reorder the rows [baseIndex, baseIndex+newOrder.size()) according to the indices /// given in \a newOrder (baseIndex+newOrder[0] specifies the new index of row baseIndex). /// /// \return Success? - void save (int index, ESM::ESMWriter& writer) const; - - const RefIdData& getDataSet() const; //I can't figure out a better name for this one :( + void save(int index, ESM::ESMWriter& writer) const; + + const RefIdData& getDataSet() const; //I can't figure out a better name for this one :( }; } diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 8aa3c2522..719b4b922 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -41,19 +41,19 @@ namespace CSMWorld virtual int getSize() const = 0; - virtual const RecordBase& getRecord (int index) const = 0; + virtual const RecordBase& getRecord(int index) const = 0; - virtual RecordBase& getRecord (int index)= 0; + virtual RecordBase& getRecord(int index) = 0; - virtual void appendRecord (const std::string& id) = 0; + virtual void appendRecord(const std::string& id) = 0; - virtual void load (int index, ESM::ESMReader& reader, bool base) = 0; + virtual void load(int index, ESM::ESMReader& reader, bool base) = 0; - virtual void erase (int index, int count) = 0; + virtual void erase(int index, int count) = 0; - virtual std::string getId (int index) const = 0; + virtual std::string getId(int index) const = 0; - virtual void save (int index, ESM::ESMWriter& writer) const = 0; + virtual void save(int index, ESM::ESMWriter& writer) const = 0; }; template @@ -63,90 +63,91 @@ namespace CSMWorld virtual int getSize() const; - virtual const RecordBase& getRecord (int index) const; + virtual const RecordBase& getRecord(int index) const; - virtual RecordBase& getRecord (int index); + virtual RecordBase& getRecord(int index); - virtual void appendRecord (const std::string& id); + virtual void appendRecord(const std::string& id); - virtual void load (int index, ESM::ESMReader& reader, bool base); + virtual void load(int index, ESM::ESMReader& reader, bool base); - virtual void erase (int index, int count); + virtual void erase(int index, int count); - virtual std::string getId (int index) const; + virtual std::string getId(int index) const; - virtual void save (int index, ESM::ESMWriter& writer) const; + virtual void save(int index, ESM::ESMWriter& writer) const; }; template int RefIdDataContainer::getSize() const { - return static_cast (mContainer.size()); + return static_cast(mContainer.size()); } template - const RecordBase& RefIdDataContainer::getRecord (int index) const + const RecordBase& RefIdDataContainer::getRecord(int index) const { - return mContainer.at (index); + return mContainer.at(index); } template - RecordBase& RefIdDataContainer::getRecord (int index) + RecordBase& RefIdDataContainer::getRecord(int index) { - return mContainer.at (index); + return mContainer.at(index); } template - void RefIdDataContainer::appendRecord (const std::string& id) + void RefIdDataContainer::appendRecord(const std::string& id) { Record record; record.mModified.mId = id; record.mModified.blank(); record.mState = RecordBase::State_ModifiedOnly; - mContainer.push_back (record); + mContainer.push_back(record); } template - void RefIdDataContainer::load (int index, ESM::ESMReader& reader, bool base) + void RefIdDataContainer::load(int index, ESM::ESMReader& reader, bool base) { - (base ? mContainer.at (index).mBase : mContainer.at (index).mModified).load (reader); + (base ? mContainer.at(index).mBase : mContainer.at(index).mModified).load(reader); } template - void RefIdDataContainer::erase (int index, int count) + void RefIdDataContainer::erase(int index, int count) { - if (index<0 || index+count>=getSize()) - throw std::runtime_error ("invalid RefIdDataContainer index"); + if (index < 0 || index + count >= getSize()) + throw std::runtime_error("invalid RefIdDataContainer index"); - mContainer.erase (mContainer.begin()+index, mContainer.begin()+index+count); + mContainer.erase(mContainer.begin() + index, mContainer.begin() + index + count); } template - std::string RefIdDataContainer::getId (int index) const + std::string RefIdDataContainer::getId(int index) const { - return mContainer.at (index).get().mId; + return mContainer.at(index).get().mId; } template - void RefIdDataContainer::save (int index, ESM::ESMWriter& writer) const + void RefIdDataContainer::save(int index, ESM::ESMWriter& writer) const { - CSMWorld::RecordBase::State state = mContainer.at (index).mState; + CSMWorld::RecordBase::State state = mContainer.at(index).mState; - if (state==CSMWorld::RecordBase::State_Modified || - state==CSMWorld::RecordBase::State_ModifiedOnly) + if (state == CSMWorld::RecordBase::State_Modified || + state == CSMWorld::RecordBase::State_ModifiedOnly) { std::string type; - for (int i=0; i<4; ++i) - /// \todo make endianess agnostic (change ESMWriter interface?) - type += reinterpret_cast (&mContainer.at (index).mModified.sRecordId)[i]; - writer.startRecord (type); - writer.writeHNCString ("NAME", getId (index)); - mContainer.at (index).mModified.save (writer); - writer.endRecord (type); + for (int i = 0; i < 4; ++i) + /// \todo make endianess agnostic (change ESMWriter interface?) + type += reinterpret_cast(&mContainer.at(index).mModified.sRecordId)[i]; + + writer.startRecord(type); + writer.writeHNCString("NAME", getId(index)); + mContainer.at(index).mModified.save(writer); + writer.endRecord(type); } - else if (state==CSMWorld::RecordBase::State_Deleted) + else if (state == CSMWorld::RecordBase::State_Deleted) { /// \todo write record with delete flag } @@ -184,61 +185,63 @@ namespace CSMWorld std::map mIndex; - std::map mRecordContainers; + std::map mRecordContainers; - void erase (const LocalIndex& index, int count); + void erase(const LocalIndex& index, int count); ///< Must not spill over into another type. public: RefIdData(); - LocalIndex globalToLocalIndex (int index) const; + LocalIndex globalToLocalIndex(int index) const; - int localToGlobalIndex (const LocalIndex& index) const; + int localToGlobalIndex(const LocalIndex& index) const; - LocalIndex searchId (const std::string& id) const; + LocalIndex searchId(const std::string& id) const; - void erase (int index, int count); + void erase(int index, int count); - const RecordBase& getRecord (const LocalIndex& index) const; + const RecordBase& getRecord(const LocalIndex& index) const; - RecordBase& getRecord (const LocalIndex& index); + RecordBase& getRecord(const LocalIndex& index); - void appendRecord (UniversalId::Type type, const std::string& id); + void appendRecord(UniversalId::Type type, const std::string& id); - int getAppendIndex (UniversalId::Type type) const; + int getAppendIndex(UniversalId::Type type) const; - void load (const LocalIndex& index, ESM::ESMReader& reader, bool base); + void load(const LocalIndex& index, ESM::ESMReader& reader, bool base); int getSize() const; - std::vector getIds (bool listDeleted = true) const; + std::vector getIds(bool listDeleted = true) const; ///< Return a sorted collection of all IDs /// /// \param listDeleted include deleted record in the list - void save (int index, ESM::ESMWriter& writer) const; - - //RECORD CONTAINERS ACCESS METHODS - const RefIdDataContainer& getBooks() const; - const RefIdDataContainer& getActivators() const; - const RefIdDataContainer& getPotions() const; - const RefIdDataContainer& getApparati() const; - const RefIdDataContainer& getArmors() const; - const RefIdDataContainer& getClothing() const; - const RefIdDataContainer& getContainers() const; - const RefIdDataContainer& getCreatures() const; - const RefIdDataContainer& getDoors() const; - const RefIdDataContainer& getIngredients() const; - const RefIdDataContainer& getCreatureLevelledLists() const; - const RefIdDataContainer& getItemLevelledList() const; - const RefIdDataContainer& getLights() const; - const RefIdDataContainer& getLocpicks() const; - const RefIdDataContainer& getMiscellaneous() const; - const RefIdDataContainer& getNPCs() const; + void save(int index, ESM::ESMWriter& writer) const; + + //RECORD CONTAINERS ACCESS METHODS + const RefIdDataContainer& getBooks() const; + const RefIdDataContainer& getActivators() const; + const RefIdDataContainer& getPotions() const; + const RefIdDataContainer& getApparati() const; + const RefIdDataContainer& getArmors() const; + const RefIdDataContainer& getClothing() const; + const RefIdDataContainer& getContainers() const; + const RefIdDataContainer& getCreatures() const; + const RefIdDataContainer& getDoors() const; + const RefIdDataContainer& getIngredients() const; + const RefIdDataContainer& getCreatureLevelledLists() const; + const RefIdDataContainer& getItemLevelledList() const; + const RefIdDataContainer& getLights() const; + const RefIdDataContainer& getLocpicks() const; + const RefIdDataContainer& getMiscellaneous() const; + const RefIdDataContainer& getNPCs() const; }; } #endif + + From 4a1987ddecb6385db2b26402e066d9d79f851f7b Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Mon, 30 Dec 2013 18:41:16 +0100 Subject: [PATCH 38/74] correcting --- .../opencs/model/tools/referenceablecheck.cpp | 28 +----- apps/opencs/model/tools/tools.cpp | 93 ++++++++++--------- apps/opencs/model/world/refidcollection.hpp | 47 +++++----- 3 files changed, 74 insertions(+), 94 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index ad52c5962..3ca203bdf 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -945,18 +945,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI } else //checking if there is such class { - bool nosuchclass(true); - - for (int i = 0; i < mClasses.getSize(); ++i) - { - if (dynamic_cast(mClasses.getRecord(i).get()).mId == NPC.mClass) - { - nosuchclass = false; - break; - } - } - - if (nosuchclass) + if (mClasses.searchId(NPC.mClass)) { messages.push_back(id.toString() + "|" + NPC.mId + " has invalid class"); } @@ -1002,18 +991,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI messages.push_back(id.toString() + "|" + NPC.mId + " has negative rank"); } - bool nosuchfaction(true); - - for (int i = 0; i < mFactions.getSize(); ++i) - { - if (dynamic_cast(mFactions.getRecord(i).get()).mId == NPC.mFaction) - { - nosuchfaction = false; - break; - } - } - - if (nosuchfaction) + if (mFactions.searchId(NPC.mFaction) == -1) { messages.push_back(id.toString() + "|" + NPC.mId + " has invalid faction"); } @@ -1026,7 +1004,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI if (NPC.mHair.empty()) { - messages.push_back(id.toString() + "|" + NPC.mId + " has no har"); + messages.push_back(id.toString() + "|" + NPC.mId + " has no hair"); } //TODO: reputation, Disposition, rank, everything else diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index c25811ea4..64e39ad2f 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -21,7 +21,7 @@ #include "spellcheck.hpp" #include "referenceablecheck.hpp" -CSMDoc::Operation* CSMTools::Tools::get(int type) +CSMDoc::Operation *CSMTools::Tools::get (int type) { switch (type) { @@ -31,60 +31,60 @@ CSMDoc::Operation* CSMTools::Tools::get(int type) return 0; } -const CSMDoc::Operation* CSMTools::Tools::get(int type) const +const CSMDoc::Operation *CSMTools::Tools::get (int type) const { - return const_cast(this)->get(type); + return const_cast (this)->get (type); } -CSMDoc::Operation* CSMTools::Tools::getVerifier() +CSMDoc::Operation *CSMTools::Tools::getVerifier() { if (!mVerifier) { - mVerifier = new CSMDoc::Operation(CSMDoc::State_Verifying, false); + mVerifier = new CSMDoc::Operation (CSMDoc::State_Verifying, false); - connect(mVerifier, SIGNAL(progress(int, int, int)), this, SIGNAL(progress(int, int, int))); - connect(mVerifier, SIGNAL(done(int)), this, SIGNAL(done(int))); - connect(mVerifier, SIGNAL(reportMessage(const QString&, int)), - this, SLOT(verifierMessage(const QString&, int))); + connect (mVerifier, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int))); + connect (mVerifier, SIGNAL (done (int)), this, SIGNAL (done (int))); + connect (mVerifier, SIGNAL (reportMessage (const QString&, int)), + this, SLOT (verifierMessage (const QString&, int))); std::vector mandatoryIds; // I want C++11, damn it! - mandatoryIds.push_back("Day"); - mandatoryIds.push_back("DaysPassed"); - mandatoryIds.push_back("GameHour"); - mandatoryIds.push_back("Month"); - mandatoryIds.push_back("PCRace"); - mandatoryIds.push_back("PCVampire"); - mandatoryIds.push_back("PCWerewolf"); - mandatoryIds.push_back("PCYear"); + mandatoryIds.push_back ("Day"); + mandatoryIds.push_back ("DaysPassed"); + mandatoryIds.push_back ("GameHour"); + mandatoryIds.push_back ("Month"); + mandatoryIds.push_back ("PCRace"); + mandatoryIds.push_back ("PCVampire"); + mandatoryIds.push_back ("PCWerewolf"); + mandatoryIds.push_back ("PCYear"); - mVerifier->appendStage(new MandatoryIdStage(mData.getGlobals(), - CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Globals), mandatoryIds)); + mVerifier->appendStage (new MandatoryIdStage (mData.getGlobals(), + CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Globals), mandatoryIds)); - mVerifier->appendStage(new SkillCheckStage(mData.getSkills())); + mVerifier->appendStage (new SkillCheckStage (mData.getSkills())); - mVerifier->appendStage(new ClassCheckStage(mData.getClasses())); + mVerifier->appendStage (new ClassCheckStage (mData.getClasses())); - mVerifier->appendStage(new FactionCheckStage(mData.getFactions())); + mVerifier->appendStage (new FactionCheckStage (mData.getFactions())); - mVerifier->appendStage(new RaceCheckStage(mData.getRaces())); + mVerifier->appendStage (new RaceCheckStage (mData.getRaces())); - mVerifier->appendStage(new SoundCheckStage(mData.getSounds())); + mVerifier->appendStage (new SoundCheckStage (mData.getSounds())); - mVerifier->appendStage(new RegionCheckStage(mData.getRegions())); + mVerifier->appendStage (new RegionCheckStage (mData.getRegions())); - mVerifier->appendStage(new BirthsignCheckStage(mData.getBirthsigns())); + mVerifier->appendStage (new BirthsignCheckStage (mData.getBirthsigns())); - mVerifier->appendStage(new SpellCheckStage(mData.getSpells())); + mVerifier->appendStage (new SpellCheckStage (mData.getSpells())); - mVerifier->appendStage(new ReferenceableCheckStage(mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses(), mData.getFactions())); + mVerifier->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses(), mData.getFactions())); } return mVerifier; } -CSMTools::Tools::Tools(CSMWorld::Data& data) : mData(data), mVerifier(0), mNextReportNumber(0) +CSMTools::Tools::Tools (CSMWorld::Data& data) : mData (data), mVerifier (0), mNextReportNumber (0) { - for (std::map::iterator iter(mReports.begin()); iter != mReports.end(); ++iter) + for (std::map::iterator iter (mReports.begin()); iter!=mReports.end(); ++iter) delete iter->second; } @@ -95,17 +95,17 @@ CSMTools::Tools::~Tools() CSMWorld::UniversalId CSMTools::Tools::runVerifier() { - mReports.insert(std::make_pair(mNextReportNumber++, new ReportModel)); - mActiveReports[CSMDoc::State_Verifying] = mNextReportNumber - 1; + mReports.insert (std::make_pair (mNextReportNumber++, new ReportModel)); + mActiveReports[CSMDoc::State_Verifying] = mNextReportNumber-1; getVerifier()->start(); - return CSMWorld::UniversalId(CSMWorld::UniversalId::Type_VerificationResults, mNextReportNumber - 1); + return CSMWorld::UniversalId (CSMWorld::UniversalId::Type_VerificationResults, mNextReportNumber-1); } -void CSMTools::Tools::abortOperation(int type) +void CSMTools::Tools::abortOperation (int type) { - if (CSMDoc::Operation* operation = get(type)) + if (CSMDoc::Operation *operation = get (type)) operation->abort(); } @@ -113,32 +113,33 @@ int CSMTools::Tools::getRunningOperations() const { static const int sOperations[] = { - CSMDoc::State_Verifying, + CSMDoc::State_Verifying, -1 }; int result = 0; - for (int i = 0; sOperations[i] != -1; ++i) - if (const CSMDoc::Operation* operation = get(sOperations[i])) + for (int i=0; sOperations[i]!=-1; ++i) + if (const CSMDoc::Operation *operation = get (sOperations[i])) if (operation->isRunning()) result |= sOperations[i]; return result; } -CSMTools::ReportModel* CSMTools::Tools::getReport(const CSMWorld::UniversalId& id) +CSMTools::ReportModel *CSMTools::Tools::getReport (const CSMWorld::UniversalId& id) { - if (id.getType() != CSMWorld::UniversalId::Type_VerificationResults) - throw std::logic_error("invalid request for report model: " + id.toString()); + if (id.getType()!=CSMWorld::UniversalId::Type_VerificationResults) + throw std::logic_error ("invalid request for report model: " + id.toString()); - return mReports.at(id.getIndex()); + return mReports.at (id.getIndex()); } -void CSMTools::Tools::verifierMessage(const QString& message, int type) +void CSMTools::Tools::verifierMessage (const QString& message, int type) { - std::map::iterator iter = mActiveReports.find(type); + std::map::iterator iter = mActiveReports.find (type); - if (iter != mActiveReports.end()) - mReports[iter->second]->add(message.toStdString()); + if (iter!=mActiveReports.end()) + mReports[iter->second]->add (message.toStdString()); } + diff --git a/apps/opencs/model/world/refidcollection.hpp b/apps/opencs/model/world/refidcollection.hpp index 1a21de8f4..328680d85 100644 --- a/apps/opencs/model/world/refidcollection.hpp +++ b/apps/opencs/model/world/refidcollection.hpp @@ -25,9 +25,9 @@ namespace CSMWorld public: - RefIdColumn(int columnId, Display displayType, - int flag = Flag_Table | Flag_Dialogue, bool editable = true, - bool userEditable = true); + RefIdColumn (int columnId, Display displayType, + int flag = Flag_Table | Flag_Dialogue, bool editable = true, + bool userEditable = true); virtual bool isEditable() const; @@ -40,11 +40,11 @@ namespace CSMWorld RefIdData mData; std::deque mColumns; - std::map mAdapters; + std::map mAdapters; private: - const RefIdAdapter& findAdaptor(UniversalId::Type) const; + const RefIdAdapter& findAdaptor (UniversalId::Type) const; ///< Throws an exception if no adaptor for \a Type can be found. public: @@ -55,61 +55,62 @@ namespace CSMWorld virtual int getSize() const; - virtual std::string getId(int index) const; + virtual std::string getId (int index) const; - virtual int getIndex(const std::string& id) const; + virtual int getIndex (const std::string& id) const; virtual int getColumns() const; - virtual const ColumnBase& getColumn(int column) const; + virtual const ColumnBase& getColumn (int column) const; - virtual QVariant getData(int index, int column) const; + virtual QVariant getData (int index, int column) const; - virtual void setData(int index, int column, const QVariant& data); + virtual void setData (int index, int column, const QVariant& data); - virtual void removeRows(int index, int count); + virtual void removeRows (int index, int count); - virtual void appendBlankRecord(const std::string& id, UniversalId::Type type); + virtual void appendBlankRecord (const std::string& id, UniversalId::Type type); ///< \param type Will be ignored, unless the collection supports multiple record types - virtual int searchId(const std::string& id) const; + virtual int searchId (const std::string& id) const; ////< Search record with \a id. /// \return index of record (if found) or -1 (not found) - virtual void replace(int index, const RecordBase& record); + virtual void replace (int index, const RecordBase& record); ///< If the record type does not match, an exception is thrown. /// /// \attention \a record must not change the ID. - virtual void appendRecord(const RecordBase& record, UniversalId::Type type); + virtual void appendRecord (const RecordBase& record, UniversalId::Type type); ///< If the record type does not match, an exception is thrown. /// ///< \param type Will be ignored, unless the collection supports multiple record types - virtual const RecordBase& getRecord(const std::string& id) const; + virtual const RecordBase& getRecord (const std::string& id) const; - virtual const RecordBase& getRecord(int index) const; + virtual const RecordBase& getRecord (int index) const; - void load(ESM::ESMReader& reader, bool base, UniversalId::Type type); + void load (ESM::ESMReader& reader, bool base, UniversalId::Type type); - virtual int getAppendIndex(const std::string& id, UniversalId::Type type) const; + virtual int getAppendIndex (const std::string& id, UniversalId::Type type) const; ///< \param type Will be ignored, unless the collection supports multiple record types - virtual std::vector getIds(bool listDeleted) const; + virtual std::vector getIds (bool listDeleted) const; ///< Return a sorted collection of all IDs /// /// \param listDeleted include deleted record in the list - virtual bool reorderRows(int baseIndex, const std::vector& newOrder); + virtual bool reorderRows (int baseIndex, const std::vector& newOrder); ///< Reorder the rows [baseIndex, baseIndex+newOrder.size()) according to the indices /// given in \a newOrder (baseIndex+newOrder[0] specifies the new index of row baseIndex). /// /// \return Success? - void save(int index, ESM::ESMWriter& writer) const; + void save (int index, ESM::ESMWriter& writer) const; - const RefIdData& getDataSet() const; //I can't figure out a better name for this one :( + const RefIdData& getDataSet() const; //I can't figure out a better name for this one :( }; } #endif + From a7de04d0a4acd27555ebeebc84a3ffd4182896fc Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Mon, 30 Dec 2013 18:46:18 +0100 Subject: [PATCH 39/74] reverting refiddata.cpp --- apps/opencs/model/world/refiddata.cpp | 214 +++++++++++++------------- 1 file changed, 107 insertions(+), 107 deletions(-) diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 9c0a857a5..5af215989 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -9,187 +9,187 @@ CSMWorld::RefIdDataContainerBase::~RefIdDataContainerBase() {} CSMWorld::RefIdData::RefIdData() { - mRecordContainers.insert(std::make_pair(UniversalId::Type_Activator, &mActivators)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Potion, &mPotions)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Apparatus, &mApparati)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Armor, &mArmors)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Book, &mBooks)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Clothing, &mClothing)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Container, &mContainers)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Creature, &mCreatures)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Door, &mDoors)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Ingredient, &mIngredients)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_CreatureLevelledList, - &mCreatureLevelledLists)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_ItemLevelledList, &mItemLevelledLists)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Light, &mLights)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Lockpick, &mLockpicks)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Miscellaneous, &mMiscellaneous)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Npc, &mNpcs)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Probe, &mProbes)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Repair, &mRepairs)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Static, &mStatics)); - mRecordContainers.insert(std::make_pair(UniversalId::Type_Weapon, &mWeapons)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Activator, &mActivators)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Potion, &mPotions)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Apparatus, &mApparati)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Armor, &mArmors)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Book, &mBooks)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Clothing, &mClothing)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Container, &mContainers)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Creature, &mCreatures)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Door, &mDoors)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Ingredient, &mIngredients)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_CreatureLevelledList, + &mCreatureLevelledLists)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_ItemLevelledList, &mItemLevelledLists)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Light, &mLights)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Lockpick, &mLockpicks)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Miscellaneous, &mMiscellaneous)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Npc, &mNpcs)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Probe, &mProbes)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Repair, &mRepairs)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Static, &mStatics)); + mRecordContainers.insert (std::make_pair (UniversalId::Type_Weapon, &mWeapons)); } -CSMWorld::RefIdData::LocalIndex CSMWorld::RefIdData::globalToLocalIndex(int index) const +CSMWorld::RefIdData::LocalIndex CSMWorld::RefIdData::globalToLocalIndex (int index) const { - for (std::map::const_iterator iter( - mRecordContainers.begin()); iter != mRecordContainers.end(); ++iter) + for (std::map::const_iterator iter ( + mRecordContainers.begin()); iter!=mRecordContainers.end(); ++iter) { - if (index < iter->second->getSize()) - return LocalIndex(index, iter->first); + if (indexsecond->getSize()) + return LocalIndex (index, iter->first); index -= iter->second->getSize(); } - throw std::runtime_error("RefIdData index out of range"); + throw std::runtime_error ("RefIdData index out of range"); } -int CSMWorld::RefIdData::localToGlobalIndex(const LocalIndex& index) -const +int CSMWorld::RefIdData::localToGlobalIndex (const LocalIndex& index) + const { - std::map::const_iterator end = - mRecordContainers.find(index.second); + std::map::const_iterator end = + mRecordContainers.find (index.second); - if (end == mRecordContainers.end()) - throw std::logic_error("invalid local index type"); + if (end==mRecordContainers.end()) + throw std::logic_error ("invalid local index type"); int globalIndex = index.first; - for (std::map::const_iterator iter( - mRecordContainers.begin()); iter != end; ++iter) + for (std::map::const_iterator iter ( + mRecordContainers.begin()); iter!=end; ++iter) globalIndex += iter->second->getSize(); return globalIndex; } -CSMWorld::RefIdData::LocalIndex CSMWorld::RefIdData::searchId( +CSMWorld::RefIdData::LocalIndex CSMWorld::RefIdData::searchId ( const std::string& id) const { - std::string id2 = Misc::StringUtils::lowerCase(id); + std::string id2 = Misc::StringUtils::lowerCase (id); - std::map >::const_iterator iter = mIndex.find(id2); + std::map >::const_iterator iter = mIndex.find (id2); - if (iter == mIndex.end()) - return std::make_pair(-1, CSMWorld::UniversalId::Type_None); + if (iter==mIndex.end()) + return std::make_pair (-1, CSMWorld::UniversalId::Type_None); return iter->second; } -void CSMWorld::RefIdData::erase(int index, int count) +void CSMWorld::RefIdData::erase (int index, int count) { - LocalIndex localIndex = globalToLocalIndex(index); + LocalIndex localIndex = globalToLocalIndex (index); - std::map::const_iterator iter = - mRecordContainers.find(localIndex.second); + std::map::const_iterator iter = + mRecordContainers.find (localIndex.second); - while (count > 0 && iter != mRecordContainers.end()) + while (count>0 && iter!=mRecordContainers.end()) { int size = iter->second->getSize(); - if (localIndex.first + count > size) + if (localIndex.first+count>size) { - erase(localIndex, size - localIndex.first); - count -= size - localIndex.first; + erase (localIndex, size-localIndex.first); + count -= size-localIndex.first; ++iter; - if (iter == mRecordContainers.end()) - throw std::runtime_error("invalid count value for erase operation"); + if (iter==mRecordContainers.end()) + throw std::runtime_error ("invalid count value for erase operation"); localIndex.first = 0; localIndex.second = iter->first; } else { - erase(localIndex, count); + erase (localIndex, count); count = 0; } } } -const CSMWorld::RecordBase& CSMWorld::RefIdData::getRecord(const LocalIndex& index) const +const CSMWorld::RecordBase& CSMWorld::RefIdData::getRecord (const LocalIndex& index) const { - std::map::const_iterator iter = - mRecordContainers.find(index.second); + std::map::const_iterator iter = + mRecordContainers.find (index.second); - if (iter == mRecordContainers.end()) - throw std::logic_error("invalid local index type"); + if (iter==mRecordContainers.end()) + throw std::logic_error ("invalid local index type"); - return iter->second->getRecord(index.first); + return iter->second->getRecord (index.first); } -CSMWorld::RecordBase& CSMWorld::RefIdData::getRecord(const LocalIndex& index) +CSMWorld::RecordBase& CSMWorld::RefIdData::getRecord (const LocalIndex& index) { - std::map::iterator iter = - mRecordContainers.find(index.second); + std::map::iterator iter = + mRecordContainers.find (index.second); - if (iter == mRecordContainers.end()) - throw std::logic_error("invalid local index type"); + if (iter==mRecordContainers.end()) + throw std::logic_error ("invalid local index type"); - return iter->second->getRecord(index.first); + return iter->second->getRecord (index.first); } -void CSMWorld::RefIdData::appendRecord(UniversalId::Type type, const std::string& id) +void CSMWorld::RefIdData::appendRecord (UniversalId::Type type, const std::string& id) { - std::map::iterator iter = - mRecordContainers.find(type); + std::map::iterator iter = + mRecordContainers.find (type); - if (iter == mRecordContainers.end()) - throw std::logic_error("invalid local index type"); + if (iter==mRecordContainers.end()) + throw std::logic_error ("invalid local index type"); - iter->second->appendRecord(id); + iter->second->appendRecord (id); - mIndex.insert(std::make_pair(Misc::StringUtils::lowerCase(id), - LocalIndex(iter->second->getSize() - 1, type))); + mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (id), + LocalIndex (iter->second->getSize()-1, type))); } -int CSMWorld::RefIdData::getAppendIndex(UniversalId::Type type) const +int CSMWorld::RefIdData::getAppendIndex (UniversalId::Type type) const { int index = 0; - for (std::map::const_iterator iter( - mRecordContainers.begin()); iter != mRecordContainers.end(); ++iter) + for (std::map::const_iterator iter ( + mRecordContainers.begin()); iter!=mRecordContainers.end(); ++iter) { index += iter->second->getSize(); - if (type == iter->first) + if (type==iter->first) break; } return index; } -void CSMWorld::RefIdData::load(const LocalIndex& index, ESM::ESMReader& reader, bool base) +void CSMWorld::RefIdData::load (const LocalIndex& index, ESM::ESMReader& reader, bool base) { - std::map::iterator iter = - mRecordContainers.find(index.second); + std::map::iterator iter = + mRecordContainers.find (index.second); - if (iter == mRecordContainers.end()) - throw std::logic_error("invalid local index type"); + if (iter==mRecordContainers.end()) + throw std::logic_error ("invalid local index type"); - iter->second->load(index.first, reader, base); + iter->second->load (index.first, reader, base); } -void CSMWorld::RefIdData::erase(const LocalIndex& index, int count) +void CSMWorld::RefIdData::erase (const LocalIndex& index, int count) { - std::map::iterator iter = - mRecordContainers.find(index.second); + std::map::iterator iter = + mRecordContainers.find (index.second); - if (iter == mRecordContainers.end()) - throw std::logic_error("invalid local index type"); + if (iter==mRecordContainers.end()) + throw std::logic_error ("invalid local index type"); - for (int i = index.first; i < index.first + count; ++i) + for (int i=index.first; i::iterator result = - mIndex.find(Misc::StringUtils::lowerCase(iter->second->getId(i))); + mIndex.find (Misc::StringUtils::lowerCase (iter->second->getId (i))); - if (result != mIndex.end()) - mIndex.erase(result); + if (result!=mIndex.end()) + mIndex.erase (result); } - iter->second->erase(index.first, count); + iter->second->erase (index.first, count); } int CSMWorld::RefIdData::getSize() const @@ -197,39 +197,39 @@ int CSMWorld::RefIdData::getSize() const return mIndex.size(); } -std::vector CSMWorld::RefIdData::getIds(bool listDeleted) const +std::vector CSMWorld::RefIdData::getIds (bool listDeleted) const { std::vector ids; - for (std::map::const_iterator iter(mIndex.begin()); iter != mIndex.end(); - ++iter) + for (std::map::const_iterator iter (mIndex.begin()); iter!=mIndex.end(); + ++iter) { - if (listDeleted || !getRecord(iter->second).isDeleted()) + if (listDeleted || !getRecord (iter->second).isDeleted()) { - std::map::const_iterator container = - mRecordContainers.find(iter->second.second); + std::map::const_iterator container = + mRecordContainers.find (iter->second.second); - if (container == mRecordContainers.end()) - throw std::logic_error("Invalid referenceable ID type"); + if (container==mRecordContainers.end()) + throw std::logic_error ("Invalid referenceable ID type"); - ids.push_back(container->second->getId(iter->second.first)); + ids.push_back (container->second->getId (iter->second.first)); } } return ids; } -void CSMWorld::RefIdData::save(int index, ESM::ESMWriter& writer) const +void CSMWorld::RefIdData::save (int index, ESM::ESMWriter& writer) const { - LocalIndex localIndex = globalToLocalIndex(index); + LocalIndex localIndex = globalToLocalIndex (index); - std::map::const_iterator iter = - mRecordContainers.find(localIndex.second); + std::map::const_iterator iter = + mRecordContainers.find (localIndex.second); - if (iter == mRecordContainers.end()) - throw std::logic_error("invalid local index type"); + if (iter==mRecordContainers.end()) + throw std::logic_error ("invalid local index type"); - iter->second->save(localIndex.first, writer); + iter->second->save (localIndex.first, writer); } const CSMWorld::RefIdDataContainer< ESM::Book >& CSMWorld::RefIdData::getBooks() const From 79bc149c73f529a80f02b829a57da2581382d839 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Mon, 30 Dec 2013 18:47:19 +0100 Subject: [PATCH 40/74] reverting refidata.hpp --- apps/opencs/model/world/refiddata.hpp | 142 +++++++++++++------------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 719b4b922..51f548499 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -41,19 +41,19 @@ namespace CSMWorld virtual int getSize() const = 0; - virtual const RecordBase& getRecord(int index) const = 0; + virtual const RecordBase& getRecord (int index) const = 0; - virtual RecordBase& getRecord(int index) = 0; + virtual RecordBase& getRecord (int index)= 0; - virtual void appendRecord(const std::string& id) = 0; + virtual void appendRecord (const std::string& id) = 0; - virtual void load(int index, ESM::ESMReader& reader, bool base) = 0; + virtual void load (int index, ESM::ESMReader& reader, bool base) = 0; - virtual void erase(int index, int count) = 0; + virtual void erase (int index, int count) = 0; - virtual std::string getId(int index) const = 0; + virtual std::string getId (int index) const = 0; - virtual void save(int index, ESM::ESMWriter& writer) const = 0; + virtual void save (int index, ESM::ESMWriter& writer) const = 0; }; template @@ -63,91 +63,90 @@ namespace CSMWorld virtual int getSize() const; - virtual const RecordBase& getRecord(int index) const; + virtual const RecordBase& getRecord (int index) const; - virtual RecordBase& getRecord(int index); + virtual RecordBase& getRecord (int index); - virtual void appendRecord(const std::string& id); + virtual void appendRecord (const std::string& id); - virtual void load(int index, ESM::ESMReader& reader, bool base); + virtual void load (int index, ESM::ESMReader& reader, bool base); - virtual void erase(int index, int count); + virtual void erase (int index, int count); - virtual std::string getId(int index) const; + virtual std::string getId (int index) const; - virtual void save(int index, ESM::ESMWriter& writer) const; + virtual void save (int index, ESM::ESMWriter& writer) const; }; template int RefIdDataContainer::getSize() const { - return static_cast(mContainer.size()); + return static_cast (mContainer.size()); } template - const RecordBase& RefIdDataContainer::getRecord(int index) const + const RecordBase& RefIdDataContainer::getRecord (int index) const { - return mContainer.at(index); + return mContainer.at (index); } template - RecordBase& RefIdDataContainer::getRecord(int index) + RecordBase& RefIdDataContainer::getRecord (int index) { - return mContainer.at(index); + return mContainer.at (index); } template - void RefIdDataContainer::appendRecord(const std::string& id) + void RefIdDataContainer::appendRecord (const std::string& id) { Record record; record.mModified.mId = id; record.mModified.blank(); record.mState = RecordBase::State_ModifiedOnly; - mContainer.push_back(record); + mContainer.push_back (record); } template - void RefIdDataContainer::load(int index, ESM::ESMReader& reader, bool base) + void RefIdDataContainer::load (int index, ESM::ESMReader& reader, bool base) { - (base ? mContainer.at(index).mBase : mContainer.at(index).mModified).load(reader); + (base ? mContainer.at (index).mBase : mContainer.at (index).mModified).load (reader); } template - void RefIdDataContainer::erase(int index, int count) + void RefIdDataContainer::erase (int index, int count) { - if (index < 0 || index + count >= getSize()) - throw std::runtime_error("invalid RefIdDataContainer index"); + if (index<0 || index+count>=getSize()) + throw std::runtime_error ("invalid RefIdDataContainer index"); - mContainer.erase(mContainer.begin() + index, mContainer.begin() + index + count); + mContainer.erase (mContainer.begin()+index, mContainer.begin()+index+count); } template - std::string RefIdDataContainer::getId(int index) const + std::string RefIdDataContainer::getId (int index) const { - return mContainer.at(index).get().mId; + return mContainer.at (index).get().mId; } template - void RefIdDataContainer::save(int index, ESM::ESMWriter& writer) const + void RefIdDataContainer::save (int index, ESM::ESMWriter& writer) const { - CSMWorld::RecordBase::State state = mContainer.at(index).mState; + CSMWorld::RecordBase::State state = mContainer.at (index).mState; - if (state == CSMWorld::RecordBase::State_Modified || - state == CSMWorld::RecordBase::State_ModifiedOnly) + if (state==CSMWorld::RecordBase::State_Modified || + state==CSMWorld::RecordBase::State_ModifiedOnly) { std::string type; - - for (int i = 0; i < 4; ++i) + for (int i=0; i<4; ++i) /// \todo make endianess agnostic (change ESMWriter interface?) - type += reinterpret_cast(&mContainer.at(index).mModified.sRecordId)[i]; + type += reinterpret_cast (&mContainer.at (index).mModified.sRecordId)[i]; - writer.startRecord(type); - writer.writeHNCString("NAME", getId(index)); - mContainer.at(index).mModified.save(writer); - writer.endRecord(type); + writer.startRecord (type); + writer.writeHNCString ("NAME", getId (index)); + mContainer.at (index).mModified.save (writer); + writer.endRecord (type); } - else if (state == CSMWorld::RecordBase::State_Deleted) + else if (state==CSMWorld::RecordBase::State_Deleted) { /// \todo write record with delete flag } @@ -185,59 +184,59 @@ namespace CSMWorld std::map mIndex; - std::map mRecordContainers; + std::map mRecordContainers; - void erase(const LocalIndex& index, int count); + void erase (const LocalIndex& index, int count); ///< Must not spill over into another type. public: RefIdData(); - LocalIndex globalToLocalIndex(int index) const; + LocalIndex globalToLocalIndex (int index) const; - int localToGlobalIndex(const LocalIndex& index) const; + int localToGlobalIndex (const LocalIndex& index) const; - LocalIndex searchId(const std::string& id) const; + LocalIndex searchId (const std::string& id) const; - void erase(int index, int count); + void erase (int index, int count); - const RecordBase& getRecord(const LocalIndex& index) const; + const RecordBase& getRecord (const LocalIndex& index) const; - RecordBase& getRecord(const LocalIndex& index); + RecordBase& getRecord (const LocalIndex& index); - void appendRecord(UniversalId::Type type, const std::string& id); + void appendRecord (UniversalId::Type type, const std::string& id); - int getAppendIndex(UniversalId::Type type) const; + int getAppendIndex (UniversalId::Type type) const; - void load(const LocalIndex& index, ESM::ESMReader& reader, bool base); + void load (const LocalIndex& index, ESM::ESMReader& reader, bool base); int getSize() const; - std::vector getIds(bool listDeleted = true) const; + std::vector getIds (bool listDeleted = true) const; ///< Return a sorted collection of all IDs /// /// \param listDeleted include deleted record in the list - void save(int index, ESM::ESMWriter& writer) const; + void save (int index, ESM::ESMWriter& writer) const; - //RECORD CONTAINERS ACCESS METHODS - const RefIdDataContainer& getBooks() const; - const RefIdDataContainer& getActivators() const; - const RefIdDataContainer& getPotions() const; - const RefIdDataContainer& getApparati() const; - const RefIdDataContainer& getArmors() const; - const RefIdDataContainer& getClothing() const; - const RefIdDataContainer& getContainers() const; - const RefIdDataContainer& getCreatures() const; - const RefIdDataContainer& getDoors() const; - const RefIdDataContainer& getIngredients() const; - const RefIdDataContainer& getCreatureLevelledLists() const; - const RefIdDataContainer& getItemLevelledList() const; - const RefIdDataContainer& getLights() const; - const RefIdDataContainer& getLocpicks() const; - const RefIdDataContainer& getMiscellaneous() const; - const RefIdDataContainer& getNPCs() const; + //RECORD CONTAINERS ACCESS METHODS + const RefIdDataContainer& getBooks() const; + const RefIdDataContainer& getActivators() const; + const RefIdDataContainer& getPotions() const; + const RefIdDataContainer& getApparati() const; + const RefIdDataContainer& getArmors() const; + const RefIdDataContainer& getClothing() const; + const RefIdDataContainer& getContainers() const; + const RefIdDataContainer& getCreatures() const; + const RefIdDataContainer& getDoors() const; + const RefIdDataContainer& getIngredients() const; + const RefIdDataContainer& getCreatureLevelledLists() const; + const RefIdDataContainer& getItemLevelledList() const; + const RefIdDataContainer& getLights() const; + const RefIdDataContainer& getLocpicks() const; + const RefIdDataContainer& getMiscellaneous() const; + const RefIdDataContainer& getNPCs() const; }; } @@ -245,3 +244,4 @@ namespace CSMWorld + From cb723710fefd35f8b4b83550ecc06878c37812e5 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Mon, 30 Dec 2013 19:24:53 +0100 Subject: [PATCH 41/74] Corrected stupid typo. --- apps/opencs/model/tools/referenceablecheck.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 3ca203bdf..2b796ccc0 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -945,7 +945,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI } else //checking if there is such class { - if (mClasses.searchId(NPC.mClass)) + if (mClasses.searchId(NPC.mClass) == -1) { messages.push_back(id.toString() + "|" + NPC.mId + " has invalid class"); } From 8201c97abf3a62f662790e556c44877541ad587b Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 2 Jan 2014 20:20:18 +0100 Subject: [PATCH 42/74] Inventory item template. --- .../opencs/model/tools/referenceablecheck.cpp | 64 ++++++++++--------- .../opencs/model/tools/referenceablecheck.hpp | 3 + 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 2b796ccc0..0b09f1f5d 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -186,35 +186,7 @@ void CSMTools::ReferenceableCheckStage::bookCheck(int stage, const CSMWorld::Ref const ESM::Book& Book = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Book, Book.mId); - //Checking for name - if (Book.mName.empty()) - { - messages.push_back(id.toString() + "|" + Book.mId + " has an empty name"); - } - - //Checking for weight - if (Book.mData.mWeight < 0) - { - 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 negative value"); - } - -//checking for model - if (Book.mModel.empty()) - { - messages.push_back(id.toString() + "|" + Book.mId + " has no model"); - } - - //checking for icon - if (Book.mIcon.empty()) - { - messages.push_back(id.toString() + "|" + Book.mId + " has no icon"); - } + inventoryItemCheck(Book, messages); //checking for enchantment points if (Book.mData.mEnchant < 0) @@ -1009,3 +981,37 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI //TODO: reputation, Disposition, rank, everything else } + +//Templates begins here + +void CSMTools::ReferenceableCheckStage::inventoryItemCheck(const item& item, std::vector< std::string >& messages) +{ + if (item.mName.empty()) + { + messages.push_back(id.toString() + "|" + item.mId + " has an empty name"); + } + + //Checking for weight + if (item.mData.mWeight < 0) + { + messages.push_back(id.toString() + "|" + item.mId + " has negative weight"); + } + + //Checking for value + if (item.mData.mValue < 0) + { + messages.push_back(id.toString() + "|" + item.mId + " has negative value"); + } + +//checking for model + if (item.mModel.empty()) + { + messages.push_back(id.toString() + "|" + item.mId + " has no model"); + } + + //checking for icon + if (item.mIcon.empty()) + { + messages.push_back(id.toString() + "|" + item.mId + " has no icon"); + } +} diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index fcf774f14..43bb54fa7 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -34,6 +34,9 @@ namespace CSMTools void miscCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void npcCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + //TEMPLATE CHECKS + template void inventoryItemCheck(const item& item, std::vector& messages); //for all inventory items. + const CSMWorld::RefIdData& mReferencables; const CSMWorld::IdCollection& mRaces; const CSMWorld::IdCollection& mClasses; From 24f090ca985643f488f49457b3e45e22ce726b67 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 3 Jan 2014 11:31:54 +0100 Subject: [PATCH 43/74] Finishing stuff. --- .../opencs/model/tools/referenceablecheck.cpp | 565 +++++++++--------- .../opencs/model/tools/referenceablecheck.hpp | 10 +- apps/opencs/model/world/refiddata.cpp | 20 + apps/opencs/model/world/refiddata.hpp | 4 + 4 files changed, 301 insertions(+), 298 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 0b09f1f5d..65bee314c 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -167,6 +167,46 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str npcCheck(stage, mReferencables.getNPCs(), messages); return; } + + stage -= NPCSize; + + const int WeaponSize(mReferencables.getWeapons().getSize()); + + if (stage < WeaponSize) + { + weaponCheck(stage, mReferencables.getWeapons(), messages); + return; + } + + stage -= WeaponSize; + + const int ProbeSize(mReferencables.getProbes().getSize()); + + if (stage < ProbeSize) + { + probeCheck(stage, mReferencables.getProbes(), messages); + return; + } + + stage -= ProbeSize; + + const int RepairSize(mReferencables.getRepairs().getSize()); + + if (stage < RepairSize) + { + repairCheck(stage, mReferencables.getRepairs(), messages); + return; + } + + stage -= RepairSize; + + const int StaticSize(mReferencables.getStatics().getSize()); + + if (stage < StaticSize) + { + staticCheck(stage, mReferencables.getStatics(), messages); + return; + } } int CSMTools::ReferenceableCheckStage::setup() @@ -186,13 +226,7 @@ void CSMTools::ReferenceableCheckStage::bookCheck(int stage, const CSMWorld::Ref const ESM::Book& Book = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Book, Book.mId); - inventoryItemCheck(Book, messages); - - //checking for enchantment points - if (Book.mData.mEnchant < 0) - { - messages.push_back(id.toString() + "|" + Book.mId + " has negative enchantment"); - } + inventoryItemCheck(Book, messages, id.toString(), true); } void CSMTools::ReferenceableCheckStage::activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, std::vector< std::string >& messages) @@ -226,36 +260,7 @@ void CSMTools::ReferenceableCheckStage::potionCheck(int stage, const CSMWorld::R const ESM::Potion& Potion = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Potion, Potion.mId); - //Checking for name - if (Potion.mName.empty()) - { - messages.push_back(id.toString() + "|" + Potion.mId + " has an empty name"); - } - - //Checking for weight - if (Potion.mData.mWeight < 0) - { - 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 negative value"); - } - -//checking for model - if (Potion.mModel.empty()) - { - messages.push_back(id.toString() + "|" + Potion.mId + " has no model"); - } - - //checking for icon - if (Potion.mIcon.empty()) - { - messages.push_back(id.toString() + "|" + Potion.mId + " has no icon"); - } - + inventoryItemCheck(Potion, messages, id.toString()); //IIRC potion can have empty effects list just fine. } @@ -272,41 +277,10 @@ void CSMTools::ReferenceableCheckStage::apparatusCheck(int stage, const CSMWorld const ESM::Apparatus& Apparatus = (dynamic_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"); - } + inventoryItemCheck(Apparatus, messages, id.toString()); //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"); - } + toolCheck(Apparatus, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::armorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Armor >& records, std::vector< std::string >& messages) @@ -321,41 +295,7 @@ void CSMTools::ReferenceableCheckStage::armorCheck(int stage, const CSMWorld::Re const ESM::Armor& Armor = (dynamic_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"); - } + inventoryItemCheck(Armor, messages, id.toString(), true); //checking for armor class, armor should have poistive armor class, but 0 is considered legal if (Armor.mData.mArmor < 0) @@ -363,7 +303,7 @@ void CSMTools::ReferenceableCheckStage::armorCheck(int stage, const CSMWorld::Re messages.push_back(id.toString() + "|" + Armor.mId + " has negative armor class"); } - //checking for health. Only positive numbers are allowed, and 0 is illegal + //checking for health. Only positive numbers are allowed, or 0 is illegal if (Armor.mData.mHealth <= 0) { messages.push_back(id.toString() + "|" + Armor.mId + " has non positive health"); @@ -381,42 +321,7 @@ void CSMTools::ReferenceableCheckStage::clothingCheck(int stage, const CSMWorld: const ESM::Clothing& Clothing = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Clothing, Clothing.mId); - - //Checking for name - if (Clothing.mName.empty()) - { - messages.push_back(id.toString() + "|" + Clothing.mId + " has an empty name"); - } - - //Checking for weight - if (Clothing.mData.mWeight < 0) - { - messages.push_back(id.toString() + "|" + Clothing.mId + " has negative weight"); - } - - //Checking for value - if (Clothing.mData.mValue < 0) - { - messages.push_back(id.toString() + "|" + Clothing.mId + " has negative value"); - } - -//checking for model - if (Clothing.mModel.empty()) - { - messages.push_back(id.toString() + "|" + Clothing.mId + " has no model"); - } - - //checking for icon - if (Clothing.mIcon.empty()) - { - messages.push_back(id.toString() + "|" + Clothing.mId + " has no icon"); - } - - //checking for enchantment points - if (Clothing.mData.mEnchant < 0) - { - messages.push_back(id.toString() + "|" + Clothing.mId + " has negative enchantment"); - } + inventoryItemCheck(Clothing, messages, id.toString(), true); } void CSMTools::ReferenceableCheckStage::containerCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Container >& records, std::vector< std::string >& messages) @@ -556,7 +461,7 @@ void CSMTools::ReferenceableCheckStage::doorCheck(int stage, const CSMWorld::Ref const ESM::Door& Door = (dynamic_cast&>(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Door, Door.mId); - //usual, name and model + //usual, name or model if (Door.mName.empty()) { messages.push_back(id.toString() + "|" + Door.mId + " has an empty name"); @@ -582,35 +487,7 @@ void CSMTools::ReferenceableCheckStage::ingredientCheck(int stage, const CSMWorl const ESM::Ingredient& Ingredient = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Ingredient, Ingredient.mId); - //Checking for name - if (Ingredient.mName.empty()) - { - messages.push_back(id.toString() + "|" + Ingredient.mId + " has an empty name"); - } - - //Checking for weight - if (Ingredient.mData.mWeight < 0) - { - messages.push_back(id.toString() + "|" + Ingredient.mId + " has negative weight"); - } - - //Checking for value - if (Ingredient.mData.mValue < 0) - { - messages.push_back(id.toString() + "|" + Ingredient.mId + " has negative value"); - } - -//checking for model - if (Ingredient.mModel.empty()) - { - messages.push_back(id.toString() + "|" + Ingredient.mId + " has no model"); - } - - //checking for icon - if (Ingredient.mIcon.empty()) - { - messages.push_back(id.toString() + "|" + Ingredient.mId + " has no icon"); - } + inventoryItemCheck(Ingredient, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::CreatureLevList >& records, std::vector< std::string >& messages) @@ -625,18 +502,8 @@ void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(int stage, const C const ESM::CreatureLevList& CreatureLevList = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_CreatureLevelledList, CreatureLevList.mId); //CreatureLevList but Type_CreatureLevelledList :/ - for (unsigned i = 0; i < CreatureLevList.mList.size(); ++i) - { - if (CreatureLevList.mList[i].mId.empty()) - { - messages.push_back(id.toString() + "|" + CreatureLevList.mId + " contains item with empty Id"); - } - if (CreatureLevList.mList[i].mLevel < 1) - { - messages.push_back(id.toString() + "|" + CreatureLevList.mId + " contains item with non-positive level"); - } - } + listCheck(CreatureLevList, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::itemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::ItemLevList >& records, std::vector< std::string >& messages) @@ -651,18 +518,7 @@ void CSMTools::ReferenceableCheckStage::itemLevelledListCheck(int stage, const C const ESM::ItemLevList& ItemLevList = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_ItemLevelledList, ItemLevList.mId); - for (unsigned i = 0; i < ItemLevList.mList.size(); ++i) - { - if (ItemLevList.mList[i].mId.empty()) - { - messages.push_back(id.toString() + "|" + ItemLevList.mId + " contains item with empty Id"); - } - - if (ItemLevList.mList[i].mLevel < 1) - { - messages.push_back(id.toString() + "|" + ItemLevList.mId + " contains item with non-positive level"); - } - } + listCheck(ItemLevList, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::lightCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Light >& records, std::vector< std::string >& messages) @@ -686,31 +542,15 @@ void CSMTools::ReferenceableCheckStage::lightCheck(int stage, const CSMWorld::Re { if (Light.mIcon.empty()) //Needs to be checked with carrable flag { - messages.push_back(id.toString() + "|" + Light.mId + " has no icon"); - } + inventoryItemCheck(Light, messages, id.toString()); - if (Light.mData.mWeight < 0) - { - messages.push_back(id.toString() + "|" + Light.mId + " has negative weight"); - } - - if (Light.mData.mValue < 0) - { - messages.push_back(id.toString() + "|" + Light.mId + " has negative value"); - } - - if (Light.mModel.empty()) - { - messages.push_back(id.toString() + "|" + Light.mId + " has no model"); - } - - if (Light.mData.mTime == 0) - { - messages.push_back(id.toString() + "|" + Light.mId + " has zero duration"); + if (Light.mData.mTime == 0) + { + messages.push_back(id.toString() + "|" + Light.mId + " has zero duration"); + } } } } - void CSMTools::ReferenceableCheckStage::lockpickCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Lockpick >& records, std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -723,45 +563,9 @@ void CSMTools::ReferenceableCheckStage::lockpickCheck(int stage, const CSMWorld: const ESM::Lockpick& Lockpick = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Lockpick, Lockpick.mId); - //Checking for name - if (Lockpick.mName.empty()) - { - messages.push_back(id.toString() + "|" + Lockpick.mId + " has an empty name"); - } + inventoryItemCheck(Lockpick, messages, id.toString()); - //Checking for weight - if (Lockpick.mData.mWeight < 0) - { - messages.push_back(id.toString() + "|" + Lockpick.mId + " has negative weight"); - } - - //Checking for value - if (Lockpick.mData.mValue < 0) - { - messages.push_back(id.toString() + "|" + Lockpick.mId + " has negative value"); - } - -//checking for model - if (Lockpick.mModel.empty()) - { - messages.push_back(id.toString() + "|" + Lockpick.mId + " has no model"); - } - - //checking for icon - if (Lockpick.mIcon.empty()) - { - messages.push_back(id.toString() + "|" + Lockpick.mId + " has no icon"); - } - - if (Lockpick.mData.mQuality <= 0) - { - messages.push_back(id.toString() + "|" + Lockpick.mId + " has non-positive quality"); - } - - if (Lockpick.mData.mUses <= 0) - { - messages.push_back(id.toString() + "|" + Lockpick.mId + " has no uses left"); - } + toolCheck(Lockpick, messages, id.toString(), true); } void CSMTools::ReferenceableCheckStage::miscCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Miscellaneous >& records, std::vector< std::string >& messages) @@ -776,35 +580,7 @@ void CSMTools::ReferenceableCheckStage::miscCheck(int stage, const CSMWorld::Ref const ESM::Miscellaneous& Miscellaneous = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Miscellaneous, Miscellaneous.mId); - //Checking for name - if (Miscellaneous.mName.empty()) - { - messages.push_back(id.toString() + "|" + Miscellaneous.mId + " has an empty name"); - } - - //Checking for weight - if (Miscellaneous.mData.mWeight < 0) - { - messages.push_back(id.toString() + "|" + Miscellaneous.mId + " has negative weight"); - } - - //Checking for value - if (Miscellaneous.mData.mValue < 0) - { - messages.push_back(id.toString() + "|" + Miscellaneous.mId + " has negative value"); - } - -//checking for model - if (Miscellaneous.mModel.empty()) - { - messages.push_back(id.toString() + "|" + Miscellaneous.mId + " has no model"); - } - - //checking for icon - if (Miscellaneous.mIcon.empty()) - { - messages.push_back(id.toString() + "|" + Miscellaneous.mId + " has no icon"); - } + inventoryItemCheck(Miscellaneous, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::NPC >& records, std::vector< std::string >& messages) @@ -819,8 +595,6 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI const ESM::NPC& NPC = (dynamic_cast& >(baserecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Npc, NPC.mId); - - short level(NPC.mNpdt52.mLevel); char Disposition(NPC.mNpdt52.mDisposition); char Reputation(NPC.mNpdt52.mReputation); @@ -832,7 +606,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI { if ((NPC.mFlags & 0x0008) == 0) //0x0008 = autocalculated flag { - messages.push_back(id.toString() + "|" + NPC.mId + " mNpdtType and flags mismatch!"); //should not happend? + messages.push_back(id.toString() + "|" + NPC.mId + " mNpdtType or flags mismatch!"); //should not happend? return; } @@ -982,36 +756,233 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI //TODO: reputation, Disposition, rank, everything else } +void CSMTools::ReferenceableCheckStage::weaponCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Weapon >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Weapon& Weapon = (dynamic_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Weapon, Weapon.mId); + + //TODO, It seems that this stuff for spellcasting is obligatory and In fact We should check if records are present + if + ( + Weapon.mId.find("VFX_") == std::string::npos + and Weapon.mId != "magic_bolt" + and Weapon.mId != "shield_bolt" + and Weapon.mId != "shock_bolt" + ) + { + inventoryItemCheck(Weapon, messages, id.toString(), true); + + if (Weapon.mData.mType == ESM::Weapon::MarksmanBow or Weapon.mData.mType == ESM::Weapon::MarksmanCrossbow or Weapon.mData.mType == ESM::Weapon::MarksmanThrown or Weapon.mData.mType == ESM::Weapon::Arrow or Weapon.mData.mType == ESM::Weapon::Bolt) + { + if (Weapon.mData.mChop[0] > Weapon.mData.mChop[1]) + { + messages.push_back(id.toString() + "|" + Weapon.mId + " has minimum chop damage higher than maximum"); + } + } + else + { + if (Weapon.mData.mSlash[0] > Weapon.mData.mSlash[1]) + { + messages.push_back(id.toString() + "|" + Weapon.mId + " has minimum slash damage higher than maximum"); + } + + if (Weapon.mData.mChop[0] > Weapon.mData.mChop[1]) + { + messages.push_back(id.toString() + "|" + Weapon.mId + " has minimum chop damage higher than maximum"); + } + + if (Weapon.mData.mThrust[0] > Weapon.mData.mThrust[1]) + { + messages.push_back(id.toString() + "|" + Weapon.mId + " has minimum thrust damage higher than maximum"); + } + } + + if (!(Weapon.mData.mType == ESM::Weapon::Arrow or Weapon.mData.mType == ESM::Weapon::Bolt or Weapon.mData.mType == ESM::Weapon::MarksmanThrown)) + { + //checking of health + if (Weapon.mData.mHealth <= 0) + { + messages.push_back(id.toString() + "|" + Weapon.mId + " has non-positivie health"); + } + + if (Weapon.mData.mReach < 0) + { + messages.push_back(id.toString() + "|" + Weapon.mId + " has negative reach"); + } + } + } +} + +void CSMTools::ReferenceableCheckStage::probeCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Probe >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Probe& Probe = (dynamic_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Probe, Probe.mId); + + inventoryItemCheck(Probe, messages, id.toString()); + toolCheck(Probe, messages, id.toString(), true); +} + +void CSMTools::ReferenceableCheckStage::repairCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Repair >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Repair& Repair = (dynamic_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Repair, Repair.mId); + + inventoryItemCheck(Repair, messages, id.toString()); + toolCheck(Repair, messages, id.toString(), true); +} + +void CSMTools::ReferenceableCheckStage::staticCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Static >& records, std::vector< std::string >& messages) +{ + const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + + if (baserecord.isDeleted()) + { + return; + } + + const ESM::Static& Static = (dynamic_cast& >(baserecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Static, Static.mId); + + if (Static.mModel.empty()) + { + messages.push_back(id.toString() + "|" + Static.mId + " has no model"); + } +} + + //Templates begins here -void CSMTools::ReferenceableCheckStage::inventoryItemCheck(const item& item, std::vector< std::string >& messages) +template void CSMTools::ReferenceableCheckStage::inventoryItemCheck(const ITEM& someitem, std::vector< std::string >& messages, const std::string& someid, bool enchantable) { - if (item.mName.empty()) + if (someitem.mName.empty()) { - messages.push_back(id.toString() + "|" + item.mId + " has an empty name"); + messages.push_back(someid + "|" + someitem.mId + " has an empty name"); } //Checking for weight - if (item.mData.mWeight < 0) + if (someitem.mData.mWeight < 0) { - messages.push_back(id.toString() + "|" + item.mId + " has negative weight"); + messages.push_back(someid + "|" + someitem.mId + " has negative weight"); } //Checking for value - if (item.mData.mValue < 0) + if (someitem.mData.mValue < 0) { - messages.push_back(id.toString() + "|" + item.mId + " has negative value"); + messages.push_back(someid + "|" + someitem.mId + " has negative value"); } //checking for model - if (item.mModel.empty()) + if (someitem.mModel.empty()) { - messages.push_back(id.toString() + "|" + item.mId + " has no model"); + messages.push_back(someid + "|" + someitem.mId + " has no model"); } //checking for icon - if (item.mIcon.empty()) + if (someitem.mIcon.empty()) { - messages.push_back(id.toString() + "|" + item.mId + " has no icon"); + messages.push_back(someid + "|" + someitem.mId + " has no icon"); + } + + if (enchantable) + { + if (someitem.mData.mEnchant < 0) + { + messages.push_back(someid + "|" + someitem.mId + " has negative enchantment"); + } } } + +template void CSMTools::ReferenceableCheckStage::inventoryItemCheck(const ITEM& someitem, std::vector< std::string >& messages, const std::string& someid) +{ + if (someitem.mName.empty()) + { + messages.push_back(someid + "|" + someitem.mId + " has an empty name"); + } + + //Checking for weight + if (someitem.mData.mWeight < 0) + { + messages.push_back(someid + "|" + someitem.mId + " has negative weight"); + } + + //Checking for value + if (someitem.mData.mValue < 0) + { + messages.push_back(someid + "|" + someitem.mId + " has negative value"); + } + +//checking for model + if (someitem.mModel.empty()) + { + messages.push_back(someid + "|" + someitem.mId + " has no model"); + } + + //checking for icon + if (someitem.mIcon.empty()) + { + messages.push_back(someid + "|" + someitem.mId + " has no icon"); + } +} + +template void CSMTools::ReferenceableCheckStage::toolCheck(const TOOL& sometool, std::vector< std::string >& messages, const std::string& someid, bool canbebroken) +{ + if (sometool.mData.mQuality <= 0) + { + messages.push_back(someid + "|" + sometool.mId + " has non-positive quality"); + } + + if (canbebroken) + { + if (sometool.mData.mUses <= 0) + { + messages.push_back(someid + "|" + sometool.mId + " has non-positive uses count"); + } + } +} + +template void CSMTools::ReferenceableCheckStage::toolCheck(const TOOL& sometool, std::vector< std::string >& messages, const std::string& someid) +{ + if (sometool.mData.mQuality <= 0) + { + messages.push_back(someid + "|" + sometool.mId + " has non-positive quality"); + } + +} + +template void CSMTools::ReferenceableCheckStage::listCheck(const LIST& somelist, std::vector< std::string >& messages, const std::string& someid) +{ + for (unsigned i = 0; i < somelist.mList.size(); ++i) + { + if (somelist.mList[i].mId.empty()) + { + messages.push_back(someid + "|" + somelist.mId + " contains item with empty Id"); + } + + if (somelist.mList[i].mLevel < 1) + { + messages.push_back(someid + "|" + somelist.mId + " contains item with non-positive level"); + } + } +} + diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 43bb54fa7..feeb32e6a 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -33,9 +33,17 @@ namespace CSMTools void lockpickCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void miscCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void npcCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void weaponCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void probeCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void repairCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); + void staticCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); //TEMPLATE CHECKS - template void inventoryItemCheck(const item& item, std::vector& messages); //for all inventory items. + template void inventoryItemCheck(const ITEM& someitem, std::vector& messages, const std::string& someid, bool enchantable); //for all enchantable items. + template void inventoryItemCheck(const ITEM& someitem, std::vector& messages, const std::string& someid); //for non-enchantable items. + template void toolCheck(const TOOL& sometool, std::vector& messages, const std::string& someid, bool canbebroken); //for tools with uses. + template void toolCheck(const TOOL& sometool, std::vector& messages, const std::string& someid); //for tools without uses. + template void listCheck(const LIST& some, std::vector< std::string >& messages, const std::string& someid); const CSMWorld::RefIdData& mReferencables; const CSMWorld::IdCollection& mRaces; diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 5af215989..65990c1d4 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -311,3 +311,23 @@ const CSMWorld::RefIdDataContainer< ESM::NPC >& CSMWorld::RefIdData::getNPCs() c { return mNpcs; } + +const CSMWorld::RefIdDataContainer< ESM::Weapon >& CSMWorld::RefIdData::getWeapons() const +{ + return mWeapons; +} + +const CSMWorld::RefIdDataContainer< ESM::Probe >& CSMWorld::RefIdData::getProbes() const +{ + return mProbes; +} + +const CSMWorld::RefIdDataContainer< ESM::Repair >& CSMWorld::RefIdData::getRepairs() const +{ + return mRepairs; +} + +const CSMWorld::RefIdDataContainer< ESM::Static >& CSMWorld::RefIdData::getStatics() const +{ + return mStatics; +} \ No newline at end of file diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index 51f548499..f82d151b4 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -237,6 +237,10 @@ namespace CSMWorld const RefIdDataContainer& getLocpicks() const; const RefIdDataContainer& getMiscellaneous() const; const RefIdDataContainer& getNPCs() const; + const RefIdDataContainer< ESM::Weapon >& getWeapons() const; + const RefIdDataContainer< ESM::Probe >& getProbes() const; + const RefIdDataContainer< ESM::Repair>& getRepairs() const; + const RefIdDataContainer< ESM::Static>& getStatics() const; }; } From 7b63e1942c3cae9e4bcf6b5b0a522d49a9728ee7 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 3 Jan 2014 11:42:49 +0100 Subject: [PATCH 44/74] style corrections --- .../opencs/model/tools/referenceablecheck.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 65bee314c..3f4d80db8 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -779,31 +779,24 @@ void CSMTools::ReferenceableCheckStage::weaponCheck(int stage, const CSMWorld::R { inventoryItemCheck(Weapon, messages, id.toString(), true); - if (Weapon.mData.mType == ESM::Weapon::MarksmanBow or Weapon.mData.mType == ESM::Weapon::MarksmanCrossbow or Weapon.mData.mType == ESM::Weapon::MarksmanThrown or Weapon.mData.mType == ESM::Weapon::Arrow or Weapon.mData.mType == ESM::Weapon::Bolt) - { - if (Weapon.mData.mChop[0] > Weapon.mData.mChop[1]) - { - messages.push_back(id.toString() + "|" + Weapon.mId + " has minimum chop damage higher than maximum"); - } - } - else + if (!(Weapon.mData.mType == ESM::Weapon::MarksmanBow or Weapon.mData.mType == ESM::Weapon::MarksmanCrossbow or Weapon.mData.mType == ESM::Weapon::MarksmanThrown or Weapon.mData.mType == ESM::Weapon::Arrow or Weapon.mData.mType == ESM::Weapon::Bolt)) { if (Weapon.mData.mSlash[0] > Weapon.mData.mSlash[1]) { messages.push_back(id.toString() + "|" + Weapon.mId + " has minimum slash damage higher than maximum"); } - if (Weapon.mData.mChop[0] > Weapon.mData.mChop[1]) - { - messages.push_back(id.toString() + "|" + Weapon.mId + " has minimum chop damage higher than maximum"); - } - if (Weapon.mData.mThrust[0] > Weapon.mData.mThrust[1]) { messages.push_back(id.toString() + "|" + Weapon.mId + " has minimum thrust damage higher than maximum"); } } + if (Weapon.mData.mChop[0] > Weapon.mData.mChop[1]) + { + messages.push_back(id.toString() + "|" + Weapon.mId + " has minimum chop damage higher than maximum"); + } + if (!(Weapon.mData.mType == ESM::Weapon::Arrow or Weapon.mData.mType == ESM::Weapon::Bolt or Weapon.mData.mType == ESM::Weapon::MarksmanThrown)) { //checking of health From 1c3296fb64e4dd792681a9d8756be9451930f079 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 3 Jan 2014 18:23:11 +0100 Subject: [PATCH 45/74] Some changes in weapons check. --- apps/opencs/model/tools/referenceablecheck.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 3f4d80db8..73f316677 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -8,6 +8,7 @@ #include "../world/record.hpp" #include "../world/universalid.hpp" +#include CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, const CSMWorld::IdCollection& classes, const CSMWorld::IdCollection& faction) : mReferencables(referenceable), @@ -551,6 +552,7 @@ void CSMTools::ReferenceableCheckStage::lightCheck(int stage, const CSMWorld::Re } } } + void CSMTools::ReferenceableCheckStage::lockpickCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Lockpick >& records, std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -667,7 +669,6 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI { messages.push_back(id.toString() + "|" + NPC.mId + " willpower has zero value"); } - } if (level < 1) @@ -771,10 +772,13 @@ void CSMTools::ReferenceableCheckStage::weaponCheck(int stage, const CSMWorld::R //TODO, It seems that this stuff for spellcasting is obligatory and In fact We should check if records are present if ( - Weapon.mId.find("VFX_") == std::string::npos - and Weapon.mId != "magic_bolt" - and Weapon.mId != "shield_bolt" - and Weapon.mId != "shock_bolt" + //THOSE ARE HARDCODED! + Weapon.mId != "VFX_Hands" + and Weapon.mId != "VFX_Absorb" + and Weapon.mId != "VFX_Reflect" + and Weapon.mId != "VFX_DefaultBolt" + //THIS ONE IS NOT, but it thas to be ignored as well + //TODO I don't know how to get full list of effects :/ ) { inventoryItemCheck(Weapon, messages, id.toString(), true); @@ -977,5 +981,4 @@ template void CSMTools::ReferenceableCheckStage::listCheck(const messages.push_back(someid + "|" + somelist.mId + " contains item with non-positive level"); } } -} - +} \ No newline at end of file From aa05ffcf60831c2bd020502b8433820d75e982e4 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 4 Jan 2014 13:05:19 +0100 Subject: [PATCH 46/74] Splited some long argument lists to the multiple lines. --- .../opencs/model/tools/referenceablecheck.cpp | 136 +++++++++++++----- apps/opencs/model/world/refiddata.hpp | 8 +- 2 files changed, 108 insertions(+), 36 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 73f316677..4b610d5d2 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -10,7 +10,11 @@ #include "../world/universalid.hpp" #include -CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, const CSMWorld::IdCollection& classes, const CSMWorld::IdCollection& faction) : +CSMTools::ReferenceableCheckStage::ReferenceableCheckStage( + const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, + const CSMWorld::IdCollection& classes, + const CSMWorld::IdCollection& faction) + : mReferencables(referenceable), mClasses(classes), mRaces(races), @@ -215,7 +219,10 @@ int CSMTools::ReferenceableCheckStage::setup() return mReferencables.getSize(); } -void CSMTools::ReferenceableCheckStage::bookCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Book >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::bookCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Book >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -230,7 +237,10 @@ void CSMTools::ReferenceableCheckStage::bookCheck(int stage, const CSMWorld::Ref inventoryItemCheck(Book, messages, id.toString(), true); } -void CSMTools::ReferenceableCheckStage::activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::activatorCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Activator >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -249,7 +259,10 @@ void CSMTools::ReferenceableCheckStage::activatorCheck(int stage, const CSMWorld } } -void CSMTools::ReferenceableCheckStage::potionCheck(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); @@ -266,7 +279,10 @@ void CSMTools::ReferenceableCheckStage::potionCheck(int stage, const CSMWorld::R } -void CSMTools::ReferenceableCheckStage::apparatusCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Apparatus >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::apparatusCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Apparatus >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -284,7 +300,10 @@ void CSMTools::ReferenceableCheckStage::apparatusCheck(int stage, const CSMWorld toolCheck(Apparatus, messages, id.toString()); } -void CSMTools::ReferenceableCheckStage::armorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Armor >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::armorCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Armor >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -311,7 +330,10 @@ void CSMTools::ReferenceableCheckStage::armorCheck(int stage, const CSMWorld::Re } } -void CSMTools::ReferenceableCheckStage::clothingCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Clothing >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::clothingCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Clothing >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -325,7 +347,10 @@ void CSMTools::ReferenceableCheckStage::clothingCheck(int stage, const CSMWorld: inventoryItemCheck(Clothing, messages, id.toString(), true); } -void CSMTools::ReferenceableCheckStage::containerCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Container >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::containerCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Container >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -356,7 +381,10 @@ void CSMTools::ReferenceableCheckStage::containerCheck(int stage, const CSMWorld } } -void CSMTools::ReferenceableCheckStage::creatureCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Creature >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::creatureCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Creature >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -450,7 +478,10 @@ void CSMTools::ReferenceableCheckStage::creatureCheck(int stage, const CSMWorld: } } -void CSMTools::ReferenceableCheckStage::doorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Door >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::doorCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Door >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -476,7 +507,10 @@ void CSMTools::ReferenceableCheckStage::doorCheck(int stage, const CSMWorld::Ref //TODO, check what static unsigned int sRecordId; is for } -void CSMTools::ReferenceableCheckStage::ingredientCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Ingredient >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::ingredientCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Ingredient >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -491,7 +525,10 @@ void CSMTools::ReferenceableCheckStage::ingredientCheck(int stage, const CSMWorl inventoryItemCheck(Ingredient, messages, id.toString()); } -void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::CreatureLevList >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::creaturesLevListCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::CreatureLevList >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -507,7 +544,10 @@ void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(int stage, const C listCheck(CreatureLevList, messages, id.toString()); } -void CSMTools::ReferenceableCheckStage::itemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::ItemLevList >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::itemLevelledListCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::ItemLevList >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -522,7 +562,10 @@ void CSMTools::ReferenceableCheckStage::itemLevelledListCheck(int stage, const C listCheck(ItemLevList, messages, id.toString()); } -void CSMTools::ReferenceableCheckStage::lightCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Light >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::lightCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Light >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -553,7 +596,10 @@ void CSMTools::ReferenceableCheckStage::lightCheck(int stage, const CSMWorld::Re } } -void CSMTools::ReferenceableCheckStage::lockpickCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Lockpick >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::lockpickCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Lockpick >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -570,7 +616,10 @@ void CSMTools::ReferenceableCheckStage::lockpickCheck(int stage, const CSMWorld: toolCheck(Lockpick, messages, id.toString(), true); } -void CSMTools::ReferenceableCheckStage::miscCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Miscellaneous >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::miscCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Miscellaneous >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -585,7 +634,10 @@ void CSMTools::ReferenceableCheckStage::miscCheck(int stage, const CSMWorld::Ref inventoryItemCheck(Miscellaneous, messages, id.toString()); } -void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::NPC >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::npcCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::NPC >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -757,7 +809,10 @@ void CSMTools::ReferenceableCheckStage::npcCheck(int stage, const CSMWorld::RefI //TODO: reputation, Disposition, rank, everything else } -void CSMTools::ReferenceableCheckStage::weaponCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Weapon >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::weaponCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Weapon >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -772,13 +827,12 @@ void CSMTools::ReferenceableCheckStage::weaponCheck(int stage, const CSMWorld::R //TODO, It seems that this stuff for spellcasting is obligatory and In fact We should check if records are present if ( - //THOSE ARE HARDCODED! + //THOSE ARE HARDCODED! Weapon.mId != "VFX_Hands" - and Weapon.mId != "VFX_Absorb" - and Weapon.mId != "VFX_Reflect" - and Weapon.mId != "VFX_DefaultBolt" - //THIS ONE IS NOT, but it thas to be ignored as well - //TODO I don't know how to get full list of effects :/ + && Weapon.mId != "VFX_Absorb" + && Weapon.mId != "VFX_Reflect" + && Weapon.mId != "VFX_DefaultBolt" + //TODO I don't know how to get full list of effects :/ ) { inventoryItemCheck(Weapon, messages, id.toString(), true); @@ -817,7 +871,10 @@ void CSMTools::ReferenceableCheckStage::weaponCheck(int stage, const CSMWorld::R } } -void CSMTools::ReferenceableCheckStage::probeCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Probe >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::probeCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Probe >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -870,7 +927,10 @@ void CSMTools::ReferenceableCheckStage::staticCheck(int stage, const CSMWorld::R //Templates begins here -template void CSMTools::ReferenceableCheckStage::inventoryItemCheck(const ITEM& someitem, std::vector< std::string >& messages, const std::string& someid, bool enchantable) +template void CSMTools::ReferenceableCheckStage::inventoryItemCheck( + const ITEM& someitem, + std::vector< std::string >& messages, + const std::string& someid, bool enchantable) { if (someitem.mName.empty()) { @@ -910,7 +970,10 @@ template void CSMTools::ReferenceableCheckStage::inventoryItemChe } } -template void CSMTools::ReferenceableCheckStage::inventoryItemCheck(const ITEM& someitem, std::vector< std::string >& messages, const std::string& someid) +template void CSMTools::ReferenceableCheckStage::inventoryItemCheck( + const ITEM& someitem, + std::vector< std::string >& messages, + const std::string& someid) { if (someitem.mName.empty()) { @@ -942,7 +1005,10 @@ template void CSMTools::ReferenceableCheckStage::inventoryItemChe } } -template void CSMTools::ReferenceableCheckStage::toolCheck(const TOOL& sometool, std::vector< std::string >& messages, const std::string& someid, bool canbebroken) +template void CSMTools::ReferenceableCheckStage::toolCheck( + const TOOL& sometool, + std::vector< std::string >& messages, + const std::string& someid, bool canbebroken) { if (sometool.mData.mQuality <= 0) { @@ -958,16 +1024,21 @@ template void CSMTools::ReferenceableCheckStage::toolCheck(const } } -template void CSMTools::ReferenceableCheckStage::toolCheck(const TOOL& sometool, std::vector< std::string >& messages, const std::string& someid) +template void CSMTools::ReferenceableCheckStage::toolCheck( + const TOOL& sometool, + std::vector< std::string >& messages, + const std::string& someid) { if (sometool.mData.mQuality <= 0) { messages.push_back(someid + "|" + sometool.mId + " has non-positive quality"); } - } -template void CSMTools::ReferenceableCheckStage::listCheck(const LIST& somelist, std::vector< std::string >& messages, const std::string& someid) +template void CSMTools::ReferenceableCheckStage::listCheck( + const LIST& somelist, + std::vector< std::string >& messages, + const std::string& someid) { for (unsigned i = 0; i < somelist.mList.size(); ++i) { @@ -981,4 +1052,5 @@ template void CSMTools::ReferenceableCheckStage::listCheck(const messages.push_back(someid + "|" + somelist.mId + " contains item with non-positive level"); } } -} \ No newline at end of file +} +// kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index f82d151b4..a204334b3 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -237,10 +237,10 @@ namespace CSMWorld const RefIdDataContainer& getLocpicks() const; const RefIdDataContainer& getMiscellaneous() const; const RefIdDataContainer& getNPCs() const; - const RefIdDataContainer< ESM::Weapon >& getWeapons() const; - const RefIdDataContainer< ESM::Probe >& getProbes() const; - const RefIdDataContainer< ESM::Repair>& getRepairs() const; - const RefIdDataContainer< ESM::Static>& getStatics() const; + const RefIdDataContainer& getWeapons() const; + const RefIdDataContainer& getProbes() const; + const RefIdDataContainer& getRepairs() const; + const RefIdDataContainer& getStatics() const; }; } From dfd1058551ecfdaf34bf621670904f1029ad55e1 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 4 Jan 2014 13:09:53 +0100 Subject: [PATCH 47/74] Various style corrections. --- apps/opencs/model/tools/referenceablecheck.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 4b610d5d2..6c90af694 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -837,7 +837,11 @@ void CSMTools::ReferenceableCheckStage::weaponCheck( { inventoryItemCheck(Weapon, messages, id.toString(), true); - if (!(Weapon.mData.mType == ESM::Weapon::MarksmanBow or Weapon.mData.mType == ESM::Weapon::MarksmanCrossbow or Weapon.mData.mType == ESM::Weapon::MarksmanThrown or Weapon.mData.mType == ESM::Weapon::Arrow or Weapon.mData.mType == ESM::Weapon::Bolt)) + if ( !(Weapon.mData.mType == ESM::Weapon::MarksmanBow || + Weapon.mData.mType == ESM::Weapon::MarksmanCrossbow || + Weapon.mData.mType == ESM::Weapon::MarksmanThrown || + Weapon.mData.mType == ESM::Weapon::Arrow || + Weapon.mData.mType == ESM::Weapon::Bolt) ) { if (Weapon.mData.mSlash[0] > Weapon.mData.mSlash[1]) { From 558690b571f22b02df849046cb5401d5b2f009c2 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 4 Jan 2014 15:19:17 +0100 Subject: [PATCH 48/74] implemented list of magical bolts for skipping. --- .../opencs/model/tools/referenceablecheck.cpp | 58 ++++++++++++++----- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 6c90af694..b9adf81ea 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -826,22 +826,40 @@ void CSMTools::ReferenceableCheckStage::weaponCheck( //TODO, It seems that this stuff for spellcasting is obligatory and In fact We should check if records are present if - ( - //THOSE ARE HARDCODED! - Weapon.mId != "VFX_Hands" - && Weapon.mId != "VFX_Absorb" - && Weapon.mId != "VFX_Reflect" - && Weapon.mId != "VFX_DefaultBolt" - //TODO I don't know how to get full list of effects :/ - ) + ( //THOSE ARE HARDCODED! + !(Weapon.mId == "VFX_Hands" || + Weapon.mId == "VFX_Absorb" || + Weapon.mId == "VFX_Reflect" || + Weapon.mId == "VFX_DefaultBolt" || + //TODO I don't know how to get full list of effects :/ + //DANGER!, ACHTUNG! FIXME! The following is the list of the magical bolts, valid for Morrowind.esm. However those are not hardcoded. + Weapon.mId == "magic_bolt" || + Weapon.mId == "shock_bolt" || + Weapon.mId == "shield_bolt" || + Weapon.mId == "VFX_DestructBolt" || + Weapon.mId == "VFX_PoisonBolt" || + Weapon.mId == "VFX_RestoreBolt" || + Weapon.mId == "VFX_AlterationBolt" || + Weapon.mId == "VFX_ConjureBolt" || + Weapon.mId == "VFX_FrostBolt" || + Weapon.mId == "VFX_MysticismBolt" || + Weapon.mId == "VFX_IllusionBolt" || + Weapon.mId == "VFX_Multiple2" || + Weapon.mId == "VFX_Multiple3" || + Weapon.mId == "VFX_Multiple4" || + Weapon.mId == "VFX_Multiple5" || + Weapon.mId == "VFX_Multiple6" || + Weapon.mId == "VFX_Multiple7" || + Weapon.mId == "VFX_Multiple8" || + Weapon.mId == "VFX_Multiple9")) { inventoryItemCheck(Weapon, messages, id.toString(), true); - if ( !(Weapon.mData.mType == ESM::Weapon::MarksmanBow || - Weapon.mData.mType == ESM::Weapon::MarksmanCrossbow || - Weapon.mData.mType == ESM::Weapon::MarksmanThrown || - Weapon.mData.mType == ESM::Weapon::Arrow || - Weapon.mData.mType == ESM::Weapon::Bolt) ) + if (!(Weapon.mData.mType == ESM::Weapon::MarksmanBow || + Weapon.mData.mType == ESM::Weapon::MarksmanCrossbow || + Weapon.mData.mType == ESM::Weapon::MarksmanThrown || + Weapon.mData.mType == ESM::Weapon::Arrow || + Weapon.mData.mType == ESM::Weapon::Bolt)) { if (Weapon.mData.mSlash[0] > Weapon.mData.mSlash[1]) { @@ -859,7 +877,9 @@ void CSMTools::ReferenceableCheckStage::weaponCheck( messages.push_back(id.toString() + "|" + Weapon.mId + " has minimum chop damage higher than maximum"); } - if (!(Weapon.mData.mType == ESM::Weapon::Arrow or Weapon.mData.mType == ESM::Weapon::Bolt or Weapon.mData.mType == ESM::Weapon::MarksmanThrown)) + if (!(Weapon.mData.mType == ESM::Weapon::Arrow || + Weapon.mData.mType == ESM::Weapon::Bolt || + Weapon.mData.mType == ESM::Weapon::MarksmanThrown)) { //checking of health if (Weapon.mData.mHealth <= 0) @@ -894,7 +914,10 @@ void CSMTools::ReferenceableCheckStage::probeCheck( toolCheck(Probe, messages, id.toString(), true); } -void CSMTools::ReferenceableCheckStage::repairCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Repair >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::repairCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Repair >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); @@ -910,7 +933,10 @@ void CSMTools::ReferenceableCheckStage::repairCheck(int stage, const CSMWorld::R toolCheck(Repair, messages, id.toString(), true); } -void CSMTools::ReferenceableCheckStage::staticCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Static >& records, std::vector< std::string >& messages) +void CSMTools::ReferenceableCheckStage::staticCheck( + int stage, + const CSMWorld::RefIdDataContainer< ESM::Static >& records, + std::vector< std::string >& messages) { const CSMWorld::RecordBase& baserecord = records.getRecord(stage); From e8607171058e3f026b6b89fe0b30164bc58b7451 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 4 Jan 2014 15:28:08 +0100 Subject: [PATCH 49/74] replaced raw values with enums. --- apps/opencs/model/tools/referenceablecheck.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index b9adf81ea..e94f0a401 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -656,9 +656,9 @@ void CSMTools::ReferenceableCheckStage::npcCheck( //Don't know what unknown is for int Gold(NPC.mNpdt52.mGold); - if (NPC.mNpdtType == 12) //12 = autocalculated + if (NPC.mNpdtType == ESM::NPC::NPC_WITH_AUTOCALCULATED_STATS) //12 = autocalculated { - if ((NPC.mFlags & 0x0008) == 0) //0x0008 = autocalculated flag + if ((NPC.mFlags & ESM::NPC::Autocalc) == 0) //0x0008 = autocalculated flag { messages.push_back(id.toString() + "|" + NPC.mId + " mNpdtType or flags mismatch!"); //should not happend? return; From 220d92f865fdf094616d60e3edeb1aa993132e88 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 5 Jan 2014 11:30:03 +0100 Subject: [PATCH 50/74] changed ID check in leveled list to name. --- apps/opencs/model/tools/referenceablecheck.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index e94f0a401..0460444c5 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -1072,9 +1072,9 @@ template void CSMTools::ReferenceableCheckStage::listCheck( { for (unsigned i = 0; i < somelist.mList.size(); ++i) { - if (somelist.mList[i].mId.empty()) + if (somelist.mList[i].mName.empty()) { - messages.push_back(someid + "|" + somelist.mId + " contains item with empty Id"); + messages.push_back(someid + "|" + somelist.mId + " contains item with empty name"); } if (somelist.mList[i].mLevel < 1) From 89d8ee62fac1eb01ceb3a4401eb06826b7dfda8a Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 5 Jan 2014 12:12:36 +0100 Subject: [PATCH 51/74] Removing name check from listCheck. Id can't be empty to be sure. --- apps/opencs/model/tools/referenceablecheck.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 0460444c5..187a74627 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -1072,11 +1072,6 @@ template void CSMTools::ReferenceableCheckStage::listCheck( { for (unsigned i = 0; i < somelist.mList.size(); ++i) { - if (somelist.mList[i].mName.empty()) - { - messages.push_back(someid + "|" + somelist.mId + " contains item with empty name"); - } - if (somelist.mList[i].mLevel < 1) { messages.push_back(someid + "|" + somelist.mId + " contains item with non-positive level"); From c1f4a9cb0e45ce8fb6adf55ad43a9c947884d119 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 5 Jan 2014 12:16:25 +0100 Subject: [PATCH 52/74] Added proper id check. --- apps/opencs/model/tools/referenceablecheck.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 187a74627..424f29820 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -1072,6 +1072,11 @@ template void CSMTools::ReferenceableCheckStage::listCheck( { for (unsigned i = 0; i < somelist.mList.size(); ++i) { + if (mReferencables.searchId(somelist.mList[i].mId).first == -1) + { + messages.push_back(someid + "|" + somelist.mId + " contains item without referencable"); + } + if (somelist.mList[i].mLevel < 1) { messages.push_back(someid + "|" + somelist.mId + " contains item with non-positive level"); From 873870c7cefee09a36693a0e2f8c18d78eda1084 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 5 Jan 2014 16:52:11 +0100 Subject: [PATCH 53/74] Chainging names to comply our policy. --- .../opencs/model/tools/referenceablecheck.cpp | 106 +++++++++--------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 424f29820..74a7dbb7f 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -25,145 +25,145 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage( 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. - const int BookSize(mReferencables.getBooks().getSize()); + const int bookSize(mReferencables.getBooks().getSize()); - if (stage < BookSize) + if (stage < bookSize) { bookCheck(stage, mReferencables.getBooks(), messages); return; } - stage -= BookSize; + stage -= bookSize; - const int ActivatorSize(mReferencables.getActivators().getSize()); + const int activatorSize(mReferencables.getActivators().getSize()); - if (stage < ActivatorSize) + if (stage < activatorSize) { activatorCheck(stage, mReferencables.getActivators(), messages); return; } - stage -= ActivatorSize; + stage -= activatorSize; - const int PotionSize(mReferencables.getActivators().getSize()); + const int potionSize(mReferencables.getActivators().getSize()); - if (stage < PotionSize) + if (stage < potionSize) { potionCheck(stage, mReferencables.getPotions(), messages); return; } - stage -= PotionSize; + stage -= potionSize; - const int ApparatusSize(mReferencables.getApparati().getSize()); + const int apparatusSize(mReferencables.getApparati().getSize()); - if (stage < ApparatusSize) + if (stage < apparatusSize) { apparatusCheck(stage, mReferencables.getApparati(), messages); return; } - stage -= ApparatusSize; + stage -= apparatusSize; - const int ArmorSize(mReferencables.getArmors().getSize()); + const int armorSize(mReferencables.getArmors().getSize()); - if (stage < ArmorSize) + if (stage < armorSize) { armorCheck(stage, mReferencables.getArmors(), messages); return; } - stage -= ArmorSize; + stage -= armorSize; - const int ClothingSize(mReferencables.getClothing().getSize()); + const int clothingSize(mReferencables.getClothing().getSize()); - if (stage < ClothingSize) + if (stage < clothingSize) { clothingCheck(stage, mReferencables.getClothing(), messages); return; } - stage -= ClothingSize; + stage -= clothingSize; - const int ContainerSize(mReferencables.getContainers().getSize()); + const int containerSize(mReferencables.getContainers().getSize()); - if (stage < ContainerSize) + if (stage < containerSize) { containerCheck(stage, mReferencables.getContainers(), messages); return; } - stage -= ContainerSize; + stage -= containerSize; - const int DoorSize(mReferencables.getDoors().getSize()); + const int doorSize(mReferencables.getDoors().getSize()); - if (stage < DoorSize) + if (stage < doorSize) { doorCheck(stage, mReferencables.getDoors(), messages); return; } - stage -= DoorSize; + stage -= doorSize; - const int IngredientSize(mReferencables.getIngredients().getSize()); + const int ingredientSize(mReferencables.getIngredients().getSize()); - if (stage < IngredientSize) + if (stage < ingredientSize) { ingredientCheck(stage, mReferencables.getIngredients(), messages); return; } - stage -= IngredientSize; + stage -= ingredientSize; - const int CreatureLevListSize(mReferencables.getCreatureLevelledLists().getSize()); + const int creatureLevListSize(mReferencables.getCreatureLevelledLists().getSize()); - if (stage < CreatureLevListSize) + if (stage < creatureLevListSize) { creaturesLevListCheck(stage, mReferencables.getCreatureLevelledLists(), messages); return; } - stage -= CreatureLevListSize; + stage -= creatureLevListSize; - const int ItemLevelledListSize(mReferencables.getItemLevelledList().getSize()); + const int itemLevelledListSize(mReferencables.getItemLevelledList().getSize()); - if (stage < ItemLevelledListSize) + if (stage < itemLevelledListSize) { itemLevelledListCheck(stage, mReferencables.getItemLevelledList(), messages); return; } - stage -= ItemLevelledListSize; + stage -= itemLevelledListSize; - const int LightSize(mReferencables.getLights().getSize()); + const int lightSize(mReferencables.getLights().getSize()); - if (stage < LightSize) + if (stage < lightSize) { lightCheck(stage, mReferencables.getLights(), messages); return; } - stage -= LightSize; + stage -= lightSize; - const int LockpickSize(mReferencables.getLocpicks().getSize()); + const int lockpickSize(mReferencables.getLocpicks().getSize()); - if (stage < LockpickSize) + if (stage < lockpickSize) { lockpickCheck(stage, mReferencables.getLocpicks(), messages); return; } - stage -= LockpickSize; + stage -= lockpickSize; - const int MiscSize(mReferencables.getMiscellaneous().getSize()); + const int miscSize(mReferencables.getMiscellaneous().getSize()); - if (stage < MiscSize) + if (stage < miscSize) { miscCheck(stage, mReferencables.getMiscellaneous(), messages); return; } - stage -= MiscSize; + stage -= miscSize; const int NPCSize(mReferencables.getNPCs().getSize()); @@ -175,39 +175,39 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str stage -= NPCSize; - const int WeaponSize(mReferencables.getWeapons().getSize()); + const int weaponSize(mReferencables.getWeapons().getSize()); - if (stage < WeaponSize) + if (stage < weaponSize) { weaponCheck(stage, mReferencables.getWeapons(), messages); return; } - stage -= WeaponSize; + stage -= weaponSize; - const int ProbeSize(mReferencables.getProbes().getSize()); + const int probeSize(mReferencables.getProbes().getSize()); - if (stage < ProbeSize) + if (stage < probeSize) { probeCheck(stage, mReferencables.getProbes(), messages); return; } - stage -= ProbeSize; + stage -= probeSize; - const int RepairSize(mReferencables.getRepairs().getSize()); + const int repairSize(mReferencables.getRepairs().getSize()); - if (stage < RepairSize) + if (stage < repairSize) { repairCheck(stage, mReferencables.getRepairs(), messages); return; } - stage -= RepairSize; + stage -= repairSize; - const int StaticSize(mReferencables.getStatics().getSize()); + const int staticSize(mReferencables.getStatics().getSize()); - if (stage < StaticSize) + if (stage < staticSize) { staticCheck(stage, mReferencables.getStatics(), messages); return; From 693c39820472ce5b9320f82f645bb2e632a2034d Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 5 Jan 2014 17:05:57 +0100 Subject: [PATCH 54/74] forgot to save the file before comit -_-' --- .../opencs/model/tools/referenceablecheck.cpp | 474 +++++++++--------- 1 file changed, 237 insertions(+), 237 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 74a7dbb7f..7d9210593 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -224,17 +224,17 @@ void CSMTools::ReferenceableCheckStage::bookCheck( const CSMWorld::RefIdDataContainer< ESM::Book >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Book& Book = (dynamic_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Book, Book.mId); + const ESM::Book& book = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Book, book.mId); - inventoryItemCheck(Book, messages, id.toString(), true); + inventoryItemCheck(book, messages, id.toString(), true); } void CSMTools::ReferenceableCheckStage::activatorCheck( @@ -242,20 +242,20 @@ void CSMTools::ReferenceableCheckStage::activatorCheck( const CSMWorld::RefIdDataContainer< ESM::Activator >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Activator& Activator = (dynamic_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Activator, Activator.mId); + const ESM::Activator& activator = (dynamic_cast& >(baseRecord)).get(); + 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(id.toString() + "|" + Activator.mId + " has no model"); + messages.push_back(id.toString() + "|" + activator.mId + " has no model"); } } @@ -264,17 +264,17 @@ void CSMTools::ReferenceableCheckStage::potionCheck( const CSMWorld::RefIdDataContainer< ESM::Potion >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Potion& Potion = (dynamic_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Potion, Potion.mId); + const ESM::Potion& potion = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Potion, potion.mId); - inventoryItemCheck(Potion, messages, id.toString()); + inventoryItemCheck(potion, messages, id.toString()); //IIRC potion can have empty effects list just fine. } @@ -284,20 +284,20 @@ void CSMTools::ReferenceableCheckStage::apparatusCheck( const CSMWorld::RefIdDataContainer< ESM::Apparatus >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Apparatus& Apparatus = (dynamic_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Apparatus, Apparatus.mId); + const ESM::Apparatus& apparatus = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Apparatus, apparatus.mId); - inventoryItemCheck(Apparatus, messages, id.toString()); + inventoryItemCheck(apparatus, messages, id.toString()); //checking for quality, 0 → apparatus is basicly useless, any negative → apparatus is harmfull instead of helpfull - toolCheck(Apparatus, messages, id.toString()); + toolCheck(apparatus, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::armorCheck( @@ -305,28 +305,28 @@ void CSMTools::ReferenceableCheckStage::armorCheck( const CSMWorld::RefIdDataContainer< ESM::Armor >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Armor& Armor = (dynamic_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Armor, Armor.mId); + const ESM::Armor& armor = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Armor, armor.mId); - inventoryItemCheck(Armor, messages, id.toString(), true); + inventoryItemCheck(armor, messages, id.toString(), true); //checking for armor class, armor should have poistive armor class, but 0 is considered legal - if (Armor.mData.mArmor < 0) + if (armor.mData.mArmor < 0) { - messages.push_back(id.toString() + "|" + Armor.mId + " has negative armor class"); + messages.push_back(id.toString() + "|" + armor.mId + " has negative armor class"); } //checking for health. Only positive numbers are allowed, or 0 is illegal - if (Armor.mData.mHealth <= 0) + if (armor.mData.mHealth <= 0) { - messages.push_back(id.toString() + "|" + Armor.mId + " has non positive health"); + messages.push_back(id.toString() + "|" + armor.mId + " has non positive health"); } } @@ -335,16 +335,16 @@ void CSMTools::ReferenceableCheckStage::clothingCheck( const CSMWorld::RefIdDataContainer< ESM::Clothing >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Clothing& Clothing = (dynamic_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Clothing, Clothing.mId); - inventoryItemCheck(Clothing, messages, id.toString(), true); + const ESM::Clothing& clothing = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Clothing, clothing.mId); + inventoryItemCheck(clothing, messages, id.toString(), true); } void CSMTools::ReferenceableCheckStage::containerCheck( @@ -352,32 +352,32 @@ void CSMTools::ReferenceableCheckStage::containerCheck( const CSMWorld::RefIdDataContainer< ESM::Container >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Container& Container = (dynamic_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Container, Container.mId); + const ESM::Container& container = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Container, container.mId); //Checking for model, IIRC all containers should have a model - if (Container.mModel.empty()) + if (container.mModel.empty()) { - messages.push_back(id.toString() + "|" + Container.mId + " has no model"); + messages.push_back(id.toString() + "|" + container.mId + " has no model"); } //Checking for capacity (weight) - if (Container.mWeight < 0) //0 is allowed + if (container.mWeight < 0) //0 is allowed { - messages.push_back(id.toString() + "|" + Container.mId + " has negative weight (capacity)"); + messages.push_back(id.toString() + "|" + container.mId + " has negative weight (capacity)"); } //checking for name - if (Container.mName.empty()) + if (container.mName.empty()) { - messages.push_back(id.toString() + "|" + Container.mId + " has an empty name"); + messages.push_back(id.toString() + "|" + container.mId + " has an empty name"); } } @@ -386,95 +386,95 @@ void CSMTools::ReferenceableCheckStage::creatureCheck( const CSMWorld::RefIdDataContainer< ESM::Creature >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Creature& Creature = (dynamic_cast&>(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Creature, Creature.mId); + const ESM::Creature& creature = (dynamic_cast&>(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Creature, creature.mId); - if (Creature.mModel.empty()) + if (creature.mModel.empty()) { - messages.push_back(id.toString() + "|" + Creature.mId + " has no model"); + messages.push_back(id.toString() + "|" + creature.mId + " has no model"); } - if (Creature.mName.empty()) + if (creature.mName.empty()) { - messages.push_back(id.toString() + "|" + Creature.mId + " has an empty name"); + messages.push_back(id.toString() + "|" + creature.mId + " has an empty name"); } //stats checks - if (Creature.mData.mLevel < 1) + if (creature.mData.mLevel < 1) { - messages.push_back(id.toString() + "|" + Creature.mId + " has non-postive level"); + messages.push_back(id.toString() + "|" + creature.mId + " has non-postive level"); } - if (Creature.mData.mStrength < 0) + if (creature.mData.mStrength < 0) { - messages.push_back(id.toString() + "|" + Creature.mId + " has negative strength"); + messages.push_back(id.toString() + "|" + creature.mId + " has negative strength"); } - if (Creature.mData.mIntelligence < 0) + if (creature.mData.mIntelligence < 0) { - messages.push_back(id.toString() + "|" + Creature.mId + " has negative intelligence"); + messages.push_back(id.toString() + "|" + creature.mId + " has negative intelligence"); } - if (Creature.mData.mWillpower < 0) + if (creature.mData.mWillpower < 0) { - messages.push_back(id.toString() + "|" + Creature.mId + " has negative willpower"); + messages.push_back(id.toString() + "|" + creature.mId + " has negative willpower"); } - if (Creature.mData.mAgility < 0) + if (creature.mData.mAgility < 0) { - messages.push_back(id.toString() + "|" + Creature.mId + " has negative agility"); + messages.push_back(id.toString() + "|" + creature.mId + " has negative agility"); } - if (Creature.mData.mSpeed < 0) + if (creature.mData.mSpeed < 0) { - messages.push_back(id.toString() + "|" + Creature.mId + " has negative speed"); + messages.push_back(id.toString() + "|" + creature.mId + " has negative speed"); } - if (Creature.mData.mEndurance < 0) + if (creature.mData.mEndurance < 0) { - messages.push_back(id.toString() + "|" + Creature.mId + " has negative endurance"); + messages.push_back(id.toString() + "|" + creature.mId + " has negative endurance"); } - if (Creature.mData.mPersonality < 0) + if (creature.mData.mPersonality < 0) { - messages.push_back(id.toString() + "|" + Creature.mId + " has negative personality"); + messages.push_back(id.toString() + "|" + creature.mId + " has negative personality"); } - if (Creature.mData.mLuck < 0) + if (creature.mData.mLuck < 0) { - messages.push_back(id.toString() + "|" + Creature.mId + " has negative luck"); + messages.push_back(id.toString() + "|" + creature.mId + " has negative luck"); } - if (Creature.mData.mHealth < 0) + if (creature.mData.mHealth < 0) { - messages.push_back(id.toString() + "|" + Creature.mId + " has negative health"); + messages.push_back(id.toString() + "|" + creature.mId + " has negative health"); } - if (Creature.mData.mSoul < 0) + if (creature.mData.mSoul < 0) { - messages.push_back(id.toString() + "|" + Creature.mId + " has negative soul value"); + messages.push_back(id.toString() + "|" + creature.mId + " has negative soul value"); } for (int i = 0; i < 6; ++i) { - if (Creature.mData.mAttack[i] < 0) + if (creature.mData.mAttack[i] < 0) { - messages.push_back(id.toString() + "|" + Creature.mId + " has negative attack strength"); + messages.push_back(id.toString() + "|" + creature.mId + " has negative attack strength"); break; } } //TODO, find meaning of other values - if (Creature.mData.mGold < 0) //It seems that this is for gold in merchant creatures + if (creature.mData.mGold < 0) //It seems that this is for gold in merchant creatures { - messages.push_back(id.toString() + "|" + Creature.mId + " has negative gold "); + messages.push_back(id.toString() + "|" + creature.mId + " has negative gold "); } } @@ -483,14 +483,14 @@ void CSMTools::ReferenceableCheckStage::doorCheck( const CSMWorld::RefIdDataContainer< ESM::Door >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Door& Door = (dynamic_cast&>(baserecord)).get(); + const ESM::Door& Door = (dynamic_cast&>(baseRecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Door, Door.mId); //usual, name or model @@ -512,14 +512,14 @@ void CSMTools::ReferenceableCheckStage::ingredientCheck( const CSMWorld::RefIdDataContainer< ESM::Ingredient >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Ingredient& Ingredient = (dynamic_cast& >(baserecord)).get(); + const ESM::Ingredient& Ingredient = (dynamic_cast& >(baseRecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Ingredient, Ingredient.mId); inventoryItemCheck(Ingredient, messages, id.toString()); @@ -530,14 +530,14 @@ void CSMTools::ReferenceableCheckStage::creaturesLevListCheck( const CSMWorld::RefIdDataContainer< ESM::CreatureLevList >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::CreatureLevList& CreatureLevList = (dynamic_cast& >(baserecord)).get(); + const ESM::CreatureLevList& CreatureLevList = (dynamic_cast& >(baseRecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_CreatureLevelledList, CreatureLevList.mId); //CreatureLevList but Type_CreatureLevelledList :/ @@ -549,14 +549,14 @@ void CSMTools::ReferenceableCheckStage::itemLevelledListCheck( const CSMWorld::RefIdDataContainer< ESM::ItemLevList >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::ItemLevList& ItemLevList = (dynamic_cast& >(baserecord)).get(); + const ESM::ItemLevList& ItemLevList = (dynamic_cast& >(baseRecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_ItemLevelledList, ItemLevList.mId); listCheck(ItemLevList, messages, id.toString()); @@ -567,30 +567,30 @@ void CSMTools::ReferenceableCheckStage::lightCheck( const CSMWorld::RefIdDataContainer< ESM::Light >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Light& Light = (dynamic_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Light, Light.mId); + const ESM::Light& light = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Light, light.mId); - if (Light.mData.mRadius < 0) + if (light.mData.mRadius < 0) { - messages.push_back(id.toString() + "|" + Light.mId + " has negative light radius"); + messages.push_back(id.toString() + "|" + light.mId + " has negative light radius"); } - if (Light.mData.mFlags & ESM::Light::Carry) + if (light.mData.mFlags & ESM::Light::Carry) { - if (Light.mIcon.empty()) //Needs to be checked with carrable flag + if (light.mIcon.empty()) //Needs to be checked with carrable flag { - inventoryItemCheck(Light, messages, id.toString()); + inventoryItemCheck(light, messages, id.toString()); - if (Light.mData.mTime == 0) + if (light.mData.mTime == 0) { - messages.push_back(id.toString() + "|" + Light.mId + " has zero duration"); + messages.push_back(id.toString() + "|" + light.mId + " has zero duration"); } } } @@ -601,19 +601,19 @@ void CSMTools::ReferenceableCheckStage::lockpickCheck( const CSMWorld::RefIdDataContainer< ESM::Lockpick >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Lockpick& Lockpick = (dynamic_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Lockpick, Lockpick.mId); + const ESM::Lockpick& lockpick = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Lockpick, lockpick.mId); - inventoryItemCheck(Lockpick, messages, id.toString()); + inventoryItemCheck(lockpick, messages, id.toString()); - toolCheck(Lockpick, messages, id.toString(), true); + toolCheck(lockpick, messages, id.toString(), true); } void CSMTools::ReferenceableCheckStage::miscCheck( @@ -621,17 +621,17 @@ void CSMTools::ReferenceableCheckStage::miscCheck( const CSMWorld::RefIdDataContainer< ESM::Miscellaneous >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Miscellaneous& Miscellaneous = (dynamic_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Miscellaneous, Miscellaneous.mId); + const ESM::Miscellaneous& miscellaneous = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Miscellaneous, miscellaneous.mId); - inventoryItemCheck(Miscellaneous, messages, id.toString()); + inventoryItemCheck(miscellaneous, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::npcCheck( @@ -639,22 +639,22 @@ void CSMTools::ReferenceableCheckStage::npcCheck( const CSMWorld::RefIdDataContainer< ESM::NPC >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::NPC& NPC = (dynamic_cast& >(baserecord)).get(); + const ESM::NPC& NPC = (dynamic_cast& >(baseRecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Npc, NPC.mId); short level(NPC.mNpdt52.mLevel); - char Disposition(NPC.mNpdt52.mDisposition); - char Reputation(NPC.mNpdt52.mReputation); - char Rank(NPC.mNpdt52.mRank); + char disposition(NPC.mNpdt52.mDisposition); + char reputation(NPC.mNpdt52.mReputation); + char rank(NPC.mNpdt52.mRank); //Don't know what unknown is for - int Gold(NPC.mNpdt52.mGold); + int gold(NPC.mNpdt52.mGold); if (NPC.mNpdtType == ESM::NPC::NPC_WITH_AUTOCALCULATED_STATS) //12 = autocalculated { @@ -665,10 +665,10 @@ void CSMTools::ReferenceableCheckStage::npcCheck( } level = NPC.mNpdt12.mLevel; - Disposition = NPC.mNpdt12.mDisposition; - Reputation = NPC.mNpdt12.mReputation; - Rank = NPC.mNpdt12.mRank; - Gold = NPC.mNpdt12.mGold; + disposition = NPC.mNpdt12.mDisposition; + reputation = NPC.mNpdt12.mReputation; + rank = NPC.mNpdt12.mRank; + gold = NPC.mNpdt12.mGold; } else { @@ -728,7 +728,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck( messages.push_back(id.toString() + "|" + NPC.mId + " level is non positive"); } - if (Gold < 0) + if (gold < 0) { messages.push_back(id.toString() + "|" + NPC.mId + " gold has negative value"); } @@ -773,19 +773,19 @@ void CSMTools::ReferenceableCheckStage::npcCheck( } } - if (Disposition < 0) + if (disposition < 0) { messages.push_back(id.toString() + "|" + NPC.mId + " has negative disposition"); } - if (Reputation < 0) //It seems that no character in Morrowind.esm have negative reputation. I'm assuming that negative reputation is invalid + if (reputation < 0) //It seems that no character in Morrowind.esm have negative reputation. I'm assuming that negative reputation is invalid { messages.push_back(id.toString() + "|" + NPC.mId + " has negative reputation"); } if (NPC.mFaction.empty() == false) { - if (Rank < 0) + if (rank < 0) { messages.push_back(id.toString() + "|" + NPC.mId + " has negative rank"); } @@ -814,82 +814,82 @@ void CSMTools::ReferenceableCheckStage::weaponCheck( const CSMWorld::RefIdDataContainer< ESM::Weapon >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Weapon& Weapon = (dynamic_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Weapon, Weapon.mId); + const ESM::Weapon& weapon = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Weapon, weapon.mId); //TODO, It seems that this stuff for spellcasting is obligatory and In fact We should check if records are present if ( //THOSE ARE HARDCODED! - !(Weapon.mId == "VFX_Hands" || - Weapon.mId == "VFX_Absorb" || - Weapon.mId == "VFX_Reflect" || - Weapon.mId == "VFX_DefaultBolt" || + !(weapon.mId == "VFX_Hands" || + weapon.mId == "VFX_Absorb" || + weapon.mId == "VFX_Reflect" || + weapon.mId == "VFX_DefaultBolt" || //TODO I don't know how to get full list of effects :/ //DANGER!, ACHTUNG! FIXME! The following is the list of the magical bolts, valid for Morrowind.esm. However those are not hardcoded. - Weapon.mId == "magic_bolt" || - Weapon.mId == "shock_bolt" || - Weapon.mId == "shield_bolt" || - Weapon.mId == "VFX_DestructBolt" || - Weapon.mId == "VFX_PoisonBolt" || - Weapon.mId == "VFX_RestoreBolt" || - Weapon.mId == "VFX_AlterationBolt" || - Weapon.mId == "VFX_ConjureBolt" || - Weapon.mId == "VFX_FrostBolt" || - Weapon.mId == "VFX_MysticismBolt" || - Weapon.mId == "VFX_IllusionBolt" || - Weapon.mId == "VFX_Multiple2" || - Weapon.mId == "VFX_Multiple3" || - Weapon.mId == "VFX_Multiple4" || - Weapon.mId == "VFX_Multiple5" || - Weapon.mId == "VFX_Multiple6" || - Weapon.mId == "VFX_Multiple7" || - Weapon.mId == "VFX_Multiple8" || - Weapon.mId == "VFX_Multiple9")) + weapon.mId == "magic_bolt" || + weapon.mId == "shock_bolt" || + weapon.mId == "shield_bolt" || + weapon.mId == "VFX_DestructBolt" || + weapon.mId == "VFX_PoisonBolt" || + weapon.mId == "VFX_RestoreBolt" || + weapon.mId == "VFX_AlterationBolt" || + weapon.mId == "VFX_ConjureBolt" || + weapon.mId == "VFX_FrostBolt" || + weapon.mId == "VFX_MysticismBolt" || + weapon.mId == "VFX_IllusionBolt" || + weapon.mId == "VFX_Multiple2" || + weapon.mId == "VFX_Multiple3" || + weapon.mId == "VFX_Multiple4" || + weapon.mId == "VFX_Multiple5" || + weapon.mId == "VFX_Multiple6" || + weapon.mId == "VFX_Multiple7" || + weapon.mId == "VFX_Multiple8" || + weapon.mId == "VFX_Multiple9")) { - inventoryItemCheck(Weapon, messages, id.toString(), true); + inventoryItemCheck(weapon, messages, id.toString(), true); - if (!(Weapon.mData.mType == ESM::Weapon::MarksmanBow || - Weapon.mData.mType == ESM::Weapon::MarksmanCrossbow || - Weapon.mData.mType == ESM::Weapon::MarksmanThrown || - Weapon.mData.mType == ESM::Weapon::Arrow || - Weapon.mData.mType == ESM::Weapon::Bolt)) + if (!(weapon.mData.mType == ESM::Weapon::MarksmanBow || + weapon.mData.mType == ESM::Weapon::MarksmanCrossbow || + weapon.mData.mType == ESM::Weapon::MarksmanThrown || + weapon.mData.mType == ESM::Weapon::Arrow || + 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(id.toString() + "|" + Weapon.mId + " has minimum slash damage higher than maximum"); + messages.push_back(id.toString() + "|" + weapon.mId + " has minimum slash damage higher than maximum"); } - if (Weapon.mData.mThrust[0] > Weapon.mData.mThrust[1]) + if (weapon.mData.mThrust[0] > weapon.mData.mThrust[1]) { - messages.push_back(id.toString() + "|" + Weapon.mId + " has minimum thrust damage higher than maximum"); + messages.push_back(id.toString() + "|" + weapon.mId + " has minimum thrust damage higher than maximum"); } } - if (Weapon.mData.mChop[0] > Weapon.mData.mChop[1]) + if (weapon.mData.mChop[0] > weapon.mData.mChop[1]) { - messages.push_back(id.toString() + "|" + Weapon.mId + " has minimum chop damage higher than maximum"); + messages.push_back(id.toString() + "|" + weapon.mId + " has minimum chop damage higher than maximum"); } - if (!(Weapon.mData.mType == ESM::Weapon::Arrow || - Weapon.mData.mType == ESM::Weapon::Bolt || - Weapon.mData.mType == ESM::Weapon::MarksmanThrown)) + if (!(weapon.mData.mType == ESM::Weapon::Arrow || + weapon.mData.mType == ESM::Weapon::Bolt || + weapon.mData.mType == ESM::Weapon::MarksmanThrown)) { //checking of health - if (Weapon.mData.mHealth <= 0) + if (weapon.mData.mHealth <= 0) { - messages.push_back(id.toString() + "|" + Weapon.mId + " has non-positivie health"); + messages.push_back(id.toString() + "|" + weapon.mId + " has non-positivie health"); } - if (Weapon.mData.mReach < 0) + if (weapon.mData.mReach < 0) { - messages.push_back(id.toString() + "|" + Weapon.mId + " has negative reach"); + messages.push_back(id.toString() + "|" + weapon.mId + " has negative reach"); } } } @@ -900,18 +900,18 @@ void CSMTools::ReferenceableCheckStage::probeCheck( const CSMWorld::RefIdDataContainer< ESM::Probe >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Probe& Probe = (dynamic_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Probe, Probe.mId); + const ESM::Probe& probe = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Probe, probe.mId); - inventoryItemCheck(Probe, messages, id.toString()); - toolCheck(Probe, messages, id.toString(), true); + inventoryItemCheck(probe, messages, id.toString()); + toolCheck(probe, messages, id.toString(), true); } void CSMTools::ReferenceableCheckStage::repairCheck( @@ -919,18 +919,18 @@ void CSMTools::ReferenceableCheckStage::repairCheck( const CSMWorld::RefIdDataContainer< ESM::Repair >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Repair& Repair = (dynamic_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Repair, Repair.mId); + const ESM::Repair& repair = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Repair, repair.mId); - inventoryItemCheck(Repair, messages, id.toString()); - toolCheck(Repair, messages, id.toString(), true); + inventoryItemCheck(repair, messages, id.toString()); + toolCheck(repair, messages, id.toString(), true); } void CSMTools::ReferenceableCheckStage::staticCheck( @@ -938,19 +938,19 @@ void CSMTools::ReferenceableCheckStage::staticCheck( const CSMWorld::RefIdDataContainer< ESM::Static >& records, std::vector< std::string >& messages) { - const CSMWorld::RecordBase& baserecord = records.getRecord(stage); + const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); - if (baserecord.isDeleted()) + if (baseRecord.isDeleted()) { return; } - const ESM::Static& Static = (dynamic_cast& >(baserecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Static, Static.mId); + const ESM::Static& static = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Static, static.mId); - if (Static.mModel.empty()) + if (static.mModel.empty()) { - messages.push_back(id.toString() + "|" + Static.mId + " has no model"); + messages.push_back(id.toString() + "|" + static.mId + " has no model"); } } @@ -958,128 +958,128 @@ void CSMTools::ReferenceableCheckStage::staticCheck( //Templates begins here template void CSMTools::ReferenceableCheckStage::inventoryItemCheck( - const ITEM& someitem, + const ITEM& someItem, std::vector< std::string >& messages, - const std::string& someid, bool enchantable) + const std::string& someID, bool enchantable) { - if (someitem.mName.empty()) + if (someItem.mName.empty()) { - messages.push_back(someid + "|" + someitem.mId + " has an empty name"); + messages.push_back(someID + "|" + someItem.mId + " has an empty name"); } //Checking for weight - if (someitem.mData.mWeight < 0) + if (someItem.mData.mWeight < 0) { - messages.push_back(someid + "|" + someitem.mId + " has negative weight"); + messages.push_back(someID + "|" + someItem.mId + " has negative weight"); } //Checking for value - if (someitem.mData.mValue < 0) + if (someItem.mData.mValue < 0) { - messages.push_back(someid + "|" + someitem.mId + " has negative value"); + messages.push_back(someID + "|" + someItem.mId + " has negative value"); } //checking for model - if (someitem.mModel.empty()) + if (someItem.mModel.empty()) { - messages.push_back(someid + "|" + someitem.mId + " has no model"); + messages.push_back(someID + "|" + someItem.mId + " has no model"); } //checking for icon - if (someitem.mIcon.empty()) + if (someItem.mIcon.empty()) { - messages.push_back(someid + "|" + someitem.mId + " has no icon"); + messages.push_back(someID + "|" + someItem.mId + " has no icon"); } if (enchantable) { - if (someitem.mData.mEnchant < 0) + if (someItem.mData.mEnchant < 0) { - messages.push_back(someid + "|" + someitem.mId + " has negative enchantment"); + messages.push_back(someID + "|" + someItem.mId + " has negative enchantment"); } } } template void CSMTools::ReferenceableCheckStage::inventoryItemCheck( - const ITEM& someitem, + const ITEM& someItem, std::vector< std::string >& messages, - const std::string& someid) + const std::string& someID) { - if (someitem.mName.empty()) + if (someItem.mName.empty()) { - messages.push_back(someid + "|" + someitem.mId + " has an empty name"); + messages.push_back(someID + "|" + someItem.mId + " has an empty name"); } //Checking for weight - if (someitem.mData.mWeight < 0) + if (someItem.mData.mWeight < 0) { - messages.push_back(someid + "|" + someitem.mId + " has negative weight"); + messages.push_back(someID + "|" + someItem.mId + " has negative weight"); } //Checking for value - if (someitem.mData.mValue < 0) + if (someItem.mData.mValue < 0) { - messages.push_back(someid + "|" + someitem.mId + " has negative value"); + messages.push_back(someID + "|" + someItem.mId + " has negative value"); } //checking for model - if (someitem.mModel.empty()) + if (someItem.mModel.empty()) { - messages.push_back(someid + "|" + someitem.mId + " has no model"); + messages.push_back(someID + "|" + someItem.mId + " has no model"); } //checking for icon - if (someitem.mIcon.empty()) + if (someItem.mIcon.empty()) { - messages.push_back(someid + "|" + someitem.mId + " has no icon"); + messages.push_back(someID + "|" + someItem.mId + " has no icon"); } } template void CSMTools::ReferenceableCheckStage::toolCheck( - const TOOL& sometool, + const TOOL& someTool, std::vector< std::string >& messages, - const std::string& someid, bool canbebroken) + const std::string& someID, bool canBeBroken) { - if (sometool.mData.mQuality <= 0) + if (someTool.mData.mQuality <= 0) { - messages.push_back(someid + "|" + sometool.mId + " has non-positive quality"); + messages.push_back(someID + "|" + someTool.mId + " has non-positive quality"); } - if (canbebroken) + if (canBeBroken) { - if (sometool.mData.mUses <= 0) + if (someTool.mData.mUses <= 0) { - messages.push_back(someid + "|" + sometool.mId + " has non-positive uses count"); + messages.push_back(someID + "|" + someTool.mId + " has non-positive uses count"); } } } template void CSMTools::ReferenceableCheckStage::toolCheck( - const TOOL& sometool, + const TOOL& someTool, std::vector< std::string >& messages, - const std::string& someid) + const std::string& someID) { - if (sometool.mData.mQuality <= 0) + if (someTool.mData.mQuality <= 0) { - messages.push_back(someid + "|" + sometool.mId + " has non-positive quality"); + messages.push_back(someID + "|" + someTool.mId + " has non-positive quality"); } } template void CSMTools::ReferenceableCheckStage::listCheck( - const LIST& somelist, + const LIST& someList, std::vector< std::string >& messages, - const std::string& someid) + const std::string& someID) { - for (unsigned i = 0; i < somelist.mList.size(); ++i) + for (unsigned i = 0; i < someList.mList.size(); ++i) { - if (mReferencables.searchId(somelist.mList[i].mId).first == -1) + if (mReferencables.searchId(someList.mList[i].mId).first == -1) { - messages.push_back(someid + "|" + somelist.mId + " contains item without referencable"); + messages.push_back(someid + "|" + someList.mId + " contains item without referencable"); } - if (somelist.mList[i].mLevel < 1) + if (someList.mList[i].mLevel < 1) { - messages.push_back(someid + "|" + somelist.mId + " contains item with non-positive level"); + messages.push_back(someid + "|" + someList.mId + " contains item with non-positive level"); } } } From 80d424591f2ba3b0093d02a631285878eb0655e7 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 5 Jan 2014 17:28:47 +0100 Subject: [PATCH 55/74] npc instead of NPC. --- .../opencs/model/tools/referenceablecheck.cpp | 120 +++++++++--------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 7d9210593..64260e0a2 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -165,15 +165,15 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str stage -= miscSize; - const int NPCSize(mReferencables.getNPCs().getSize()); + const int npcSize(mReferencables.getNPCs().getSize()); - if (stage < NPCSize) + if (stage < npcSize) { npcCheck(stage, mReferencables.getNPCs(), messages); return; } - stage -= NPCSize; + stage -= npcSize; const int weaponSize(mReferencables.getWeapons().getSize()); @@ -646,113 +646,113 @@ void CSMTools::ReferenceableCheckStage::npcCheck( return; } - const ESM::NPC& NPC = (dynamic_cast& >(baseRecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Npc, NPC.mId); + const ESM::NPC& npc = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Npc, npc.mId); - short level(NPC.mNpdt52.mLevel); - char disposition(NPC.mNpdt52.mDisposition); - char reputation(NPC.mNpdt52.mReputation); - char rank(NPC.mNpdt52.mRank); + short level(npc.mNpdt52.mLevel); + char disposition(npc.mNpdt52.mDisposition); + char reputation(npc.mNpdt52.mReputation); + char rank(npc.mNpdt52.mRank); //Don't know what unknown is for - int gold(NPC.mNpdt52.mGold); + int gold(npc.mNpdt52.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) //0x0008 = autocalculated flag + if ((npc.mFlags & ESM::NPC::Autocalc) == 0) //0x0008 = autocalculated flag { - messages.push_back(id.toString() + "|" + NPC.mId + " mNpdtType or flags mismatch!"); //should not happend? + messages.push_back(id.toString() + "|" + npc.mId + " mNpdtType or flags mismatch!"); //should not happend? return; } - level = NPC.mNpdt12.mLevel; - disposition = NPC.mNpdt12.mDisposition; - reputation = NPC.mNpdt12.mReputation; - rank = NPC.mNpdt12.mRank; - gold = NPC.mNpdt12.mGold; + level = npc.mNpdt12.mLevel; + disposition = npc.mNpdt12.mDisposition; + reputation = npc.mNpdt12.mReputation; + rank = npc.mNpdt12.mRank; + gold = npc.mNpdt12.mGold; } else { - if (NPC.mNpdt52.mMana < 0) + if (npc.mNpdt52.mMana < 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " mana has negative value"); + messages.push_back(id.toString() + "|" + npc.mId + " mana has negative value"); } - if (NPC.mNpdt52.mFatigue < 0) + if (npc.mNpdt52.mFatigue < 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " fatigue has negative value"); + messages.push_back(id.toString() + "|" + npc.mId + " fatigue has negative value"); } - if (NPC.mNpdt52.mAgility == 0) + if (npc.mNpdt52.mAgility == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " agility has zero value"); + messages.push_back(id.toString() + "|" + npc.mId + " agility has zero value"); } - if (NPC.mNpdt52.mEndurance == 0) + if (npc.mNpdt52.mEndurance == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " endurance has zero value"); + messages.push_back(id.toString() + "|" + npc.mId + " endurance has zero value"); } - if (NPC.mNpdt52.mIntelligence == 0) + if (npc.mNpdt52.mIntelligence == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " intelligence has zero value"); + messages.push_back(id.toString() + "|" + npc.mId + " intelligence has zero value"); } - if (NPC.mNpdt52.mLuck == 0) + if (npc.mNpdt52.mLuck == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " luck has zero value"); + messages.push_back(id.toString() + "|" + npc.mId + " luck has zero value"); } - if (NPC.mNpdt52.mPersonality == 0) + if (npc.mNpdt52.mPersonality == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " personality has zero value"); + messages.push_back(id.toString() + "|" + npc.mId + " personality has zero value"); } - if (NPC.mNpdt52.mStrength == 0) + if (npc.mNpdt52.mStrength == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " strength has zero value"); + messages.push_back(id.toString() + "|" + npc.mId + " strength has zero value"); } - if (NPC.mNpdt52.mSpeed == 0) + if (npc.mNpdt52.mSpeed == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " speed has zero value"); + messages.push_back(id.toString() + "|" + npc.mId + " speed has zero value"); } - if (NPC.mNpdt52.mWillpower == 0) + if (npc.mNpdt52.mWillpower == 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " willpower has zero value"); + messages.push_back(id.toString() + "|" + npc.mId + " willpower has zero value"); } } if (level < 1) { - messages.push_back(id.toString() + "|" + NPC.mId + " level is non positive"); + messages.push_back(id.toString() + "|" + npc.mId + " level is non positive"); } if (gold < 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " gold has negative value"); + messages.push_back(id.toString() + "|" + npc.mId + " gold has negative value"); } - if (NPC.mName.empty()) + if (npc.mName.empty()) { - messages.push_back(id.toString() + "|" + NPC.mId + " has any empty name"); + messages.push_back(id.toString() + "|" + npc.mId + " has any empty name"); } - if (NPC.mClass.empty()) + if (npc.mClass.empty()) { - messages.push_back(id.toString() + "|" + NPC.mId + " has any empty class"); + messages.push_back(id.toString() + "|" + npc.mId + " has any empty class"); } else //checking if there is such class { - if (mClasses.searchId(NPC.mClass) == -1) + if (mClasses.searchId(npc.mClass) == -1) { - messages.push_back(id.toString() + "|" + NPC.mId + " has invalid class"); + messages.push_back(id.toString() + "|" + npc.mId + " has invalid class"); } } - if (NPC.mRace.empty()) + if (npc.mRace.empty()) { - messages.push_back(id.toString() + "|" + NPC.mId + " has any empty race"); + messages.push_back(id.toString() + "|" + npc.mId + " has any empty race"); } else //checking if there is a such race { @@ -760,7 +760,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck( for (int i = 0; i < mRaces.getSize(); ++i) { - if (dynamic_cast(mRaces.getRecord(i).get()).mName == NPC.mRace) //mId in class, mName for race. Stupid. + if (dynamic_cast(mRaces.getRecord(i).get()).mName == npc.mRace) //mId in class, mName for race. Stupid. { nosuchrace = false; break; @@ -769,41 +769,41 @@ void CSMTools::ReferenceableCheckStage::npcCheck( if (nosuchrace) { - messages.push_back(id.toString() + "|" + NPC.mId + " has invalid race"); + messages.push_back(id.toString() + "|" + npc.mId + " has invalid race"); } } if (disposition < 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " has negative disposition"); + messages.push_back(id.toString() + "|" + npc.mId + " has negative disposition"); } if (reputation < 0) //It seems that no character in Morrowind.esm have negative reputation. I'm assuming that negative reputation is invalid { - messages.push_back(id.toString() + "|" + NPC.mId + " has negative reputation"); + messages.push_back(id.toString() + "|" + npc.mId + " has negative reputation"); } - if (NPC.mFaction.empty() == false) + if (npc.mFaction.empty() == false) { if (rank < 0) { - messages.push_back(id.toString() + "|" + NPC.mId + " has negative rank"); + messages.push_back(id.toString() + "|" + npc.mId + " has negative rank"); } - if (mFactions.searchId(NPC.mFaction) == -1) + if (mFactions.searchId(npc.mFaction) == -1) { - messages.push_back(id.toString() + "|" + NPC.mId + " has invalid faction"); + messages.push_back(id.toString() + "|" + npc.mId + " has invalid faction"); } } - if (NPC.mHead.empty()) + if (npc.mHead.empty()) { - messages.push_back(id.toString() + "|" + NPC.mId + " has no head"); + messages.push_back(id.toString() + "|" + npc.mId + " has no head"); } - if (NPC.mHair.empty()) + if (npc.mHair.empty()) { - messages.push_back(id.toString() + "|" + NPC.mId + " has no hair"); + messages.push_back(id.toString() + "|" + npc.mId + " has no hair"); } //TODO: reputation, Disposition, rank, everything else From 43387063079d446429e916260b4fc70559e7ae0d Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 5 Jan 2014 17:31:54 +0100 Subject: [PATCH 56/74] static is a keyword. renamed static to staticElement --- apps/opencs/model/tools/referenceablecheck.cpp | 12 ++++++------ apps/opencs/model/tools/referenceablecheck.hpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 64260e0a2..73c88a507 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -945,12 +945,12 @@ void CSMTools::ReferenceableCheckStage::staticCheck( return; } - const ESM::Static& static = (dynamic_cast& >(baseRecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Static, static.mId); + const ESM::Static& staticElement = (dynamic_cast& >(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Static, staticElement.mId); - if (static.mModel.empty()) + if (staticElement.mModel.empty()) { - messages.push_back(id.toString() + "|" + static.mId + " has no model"); + messages.push_back(id.toString() + "|" + staticElement.mId + " has no model"); } } @@ -1074,12 +1074,12 @@ template void CSMTools::ReferenceableCheckStage::listCheck( { if (mReferencables.searchId(someList.mList[i].mId).first == -1) { - messages.push_back(someid + "|" + someList.mId + " contains item without referencable"); + messages.push_back(someID + "|" + someList.mId + " contains item without referencable"); } if (someList.mList[i].mLevel < 1) { - messages.push_back(someid + "|" + someList.mId + " contains item with non-positive level"); + messages.push_back(someID + "|" + someList.mId + " contains item with non-positive level"); } } } diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index feeb32e6a..217e77a05 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -43,7 +43,7 @@ namespace CSMTools template void inventoryItemCheck(const ITEM& someitem, std::vector& messages, const std::string& someid); //for non-enchantable items. template void toolCheck(const TOOL& sometool, std::vector& messages, const std::string& someid, bool canbebroken); //for tools with uses. template void toolCheck(const TOOL& sometool, std::vector& messages, const std::string& someid); //for tools without uses. - template void listCheck(const LIST& some, std::vector< std::string >& messages, const std::string& someid); + template void listCheck(const LIST& somelist, std::vector< std::string >& messages, const std::string& Som); const CSMWorld::RefIdData& mReferencables; const CSMWorld::IdCollection& mRaces; From c69814ed14f0fa386847c28f012e728d34063bfb Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sun, 5 Jan 2014 18:00:49 +0100 Subject: [PATCH 57/74] corrected one, additional name to follow policy --- apps/opencs/model/tools/referenceablecheck.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 73c88a507..92d116244 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -756,18 +756,18 @@ void CSMTools::ReferenceableCheckStage::npcCheck( } else //checking if there is a such race { - bool nosuchrace(true); + bool noSuchRace(true); for (int i = 0; i < mRaces.getSize(); ++i) { if (dynamic_cast(mRaces.getRecord(i).get()).mName == npc.mRace) //mId in class, mName for race. Stupid. { - nosuchrace = false; + noSuchRace = false; break; } } - if (nosuchrace) + if (noSuchRace) { messages.push_back(id.toString() + "|" + npc.mId + " has invalid race"); } From 06f85370878c8876cec2a1e93d87eae55a395cf6 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Mon, 6 Jan 2014 18:43:44 +0100 Subject: [PATCH 58/74] added final check for player npc. Removed useless includes. However, this code spams exceptions and I can't figure out why. --- .../opencs/model/tools/referenceablecheck.cpp | 41 +++++++++++++------ .../opencs/model/tools/referenceablecheck.hpp | 6 ++- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 92d116244..12f347afb 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -1,14 +1,6 @@ #include "referenceablecheck.hpp" - -#include -#include -#include -#include - #include "../world/record.hpp" - #include "../world/universalid.hpp" -#include CSMTools::ReferenceableCheckStage::ReferenceableCheckStage( const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, @@ -18,12 +10,18 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage( mReferencables(referenceable), mClasses(classes), mRaces(races), - mFactions(faction) + mFactions(faction), + mPlayerPresent(false) { } void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages) { + if (stage == mReferencables.getSize() - 1) + { + finalCheck(messages); + } + //Checks for books, than, when stage is above mBooksSize goes to other checks, with (stage - PrevSum) as stage. const int bookSize(mReferencables.getBooks().getSize()); @@ -104,7 +102,6 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str } stage -= doorSize; - const int ingredientSize(mReferencables.getIngredients().getSize()); if (stage < ingredientSize) @@ -296,7 +293,6 @@ void CSMTools::ReferenceableCheckStage::apparatusCheck( inventoryItemCheck(apparatus, messages, id.toString()); - //checking for quality, 0 → apparatus is basicly useless, any negative → apparatus is harmfull instead of helpfull toolCheck(apparatus, messages, id.toString()); } @@ -656,6 +652,12 @@ void CSMTools::ReferenceableCheckStage::npcCheck( //Don't know what unknown is for int gold(npc.mNpdt52.mGold); + //Detect if player is present + if (npc.mId == "player") + { + mPlayerPresent = true; + } + if (npc.mNpdtType == ESM::NPC::NPC_WITH_AUTOCALCULATED_STATS) //12 = autocalculated { if ((npc.mFlags & ESM::NPC::Autocalc) == 0) //0x0008 = autocalculated flag @@ -954,6 +956,19 @@ void CSMTools::ReferenceableCheckStage::staticCheck( } } +//final check + +void CSMTools::ReferenceableCheckStage::finalCheck(std::vector< std::string >& messages) +{ + if (!mPlayerPresent) + { + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Npc); + messages.push_back(id.toString() + "| There is no player record"); + } + + mPlayerPresent = false; +} + //Templates begins here @@ -1022,7 +1037,7 @@ template void CSMTools::ReferenceableCheckStage::inventoryItemChe messages.push_back(someID + "|" + someItem.mId + " has negative value"); } -//checking for model + //checking for model if (someItem.mModel.empty()) { messages.push_back(someID + "|" + someItem.mId + " has no model"); @@ -1076,7 +1091,7 @@ template void CSMTools::ReferenceableCheckStage::listCheck( { messages.push_back(someID + "|" + someList.mId + " contains item without referencable"); } - + if (someList.mList[i].mLevel < 1) { messages.push_back(someID + "|" + someList.mId + " contains item with non-positive level"); diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 217e77a05..bc31ad537 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -37,7 +37,10 @@ namespace CSMTools void probeCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void repairCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); void staticCheck(int stage, const CSMWorld::RefIdDataContainer& records, std::vector& messages); - + + //FINAL CHECK + void finalCheck(std::vector& messages); + //TEMPLATE CHECKS template void inventoryItemCheck(const ITEM& someitem, std::vector& messages, const std::string& someid, bool enchantable); //for all enchantable items. template void inventoryItemCheck(const ITEM& someitem, std::vector& messages, const std::string& someid); //for non-enchantable items. @@ -49,6 +52,7 @@ namespace CSMTools const CSMWorld::IdCollection& mRaces; const CSMWorld::IdCollection& mClasses; const CSMWorld::IdCollection& mFactions; + bool mPlayerPresent; }; } #endif // REFERENCEABLECHECKSTAGE_H From b85fe2becf57f7c377a0ea66438bfe4bb2c9693c Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Mon, 6 Jan 2014 23:37:18 +0100 Subject: [PATCH 59/74] Changes according to the comment. --- apps/opencs/model/tools/referenceablecheck.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 12f347afb..6132b3407 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -1,6 +1,7 @@ #include "referenceablecheck.hpp" #include "../world/record.hpp" #include "../world/universalid.hpp" +#include CSMTools::ReferenceableCheckStage::ReferenceableCheckStage( const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, @@ -17,11 +18,6 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage( void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages) { - if (stage == mReferencables.getSize() - 1) - { - finalCheck(messages); - } - //Checks for books, than, when stage is above mBooksSize goes to other checks, with (stage - PrevSum) as stage. const int bookSize(mReferencables.getBooks().getSize()); @@ -102,6 +98,7 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str } stage -= doorSize; + const int ingredientSize(mReferencables.getIngredients().getSize()); if (stage < ingredientSize) @@ -209,11 +206,15 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str staticCheck(stage, mReferencables.getStatics(), messages); return; } +// if we come that far, we are about to perform our last, final check. + finalCheck(messages); + return; } int CSMTools::ReferenceableCheckStage::setup() { - return mReferencables.getSize(); + mPlayerPresent = false; + return mReferencables.getSize() + 1; } void CSMTools::ReferenceableCheckStage::bookCheck( @@ -965,8 +966,6 @@ void CSMTools::ReferenceableCheckStage::finalCheck(std::vector< std::string >& m CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Npc); messages.push_back(id.toString() + "| There is no player record"); } - - mPlayerPresent = false; } From b98cdabe899e15b731ad4cad022d93cb7e2def1a Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 10 Jan 2014 09:42:36 +0100 Subject: [PATCH 60/74] Shameful bug fixed. --- apps/opencs/model/tools/referenceablecheck.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 6132b3407..940a251e3 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -206,6 +206,7 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str staticCheck(stage, mReferencables.getStatics(), messages); return; } + // if we come that far, we are about to perform our last, final check. finalCheck(messages); return; @@ -581,14 +582,11 @@ void CSMTools::ReferenceableCheckStage::lightCheck( if (light.mData.mFlags & ESM::Light::Carry) { - if (light.mIcon.empty()) //Needs to be checked with carrable flag - { - inventoryItemCheck(light, messages, id.toString()); + inventoryItemCheck(light, messages, id.toString()); - if (light.mData.mTime == 0) - { - messages.push_back(id.toString() + "|" + light.mId + " has zero duration"); - } + if (light.mData.mTime == 0) + { + messages.push_back(id.toString() + "|" + light.mId + " has zero duration"); } } } From e4d637fd6404c8b6c9a9282f3812df2ebda58289 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 10 Jan 2014 09:49:05 +0100 Subject: [PATCH 61/74] splited long lines in the header. --- .../opencs/model/tools/referenceablecheck.cpp | 1 - .../opencs/model/tools/referenceablecheck.hpp | 26 +++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 940a251e3..44bb7d302 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -538,7 +538,6 @@ void CSMTools::ReferenceableCheckStage::creaturesLevListCheck( const ESM::CreatureLevList& CreatureLevList = (dynamic_cast& >(baseRecord)).get(); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_CreatureLevelledList, CreatureLevList.mId); //CreatureLevList but Type_CreatureLevelledList :/ - listCheck(CreatureLevList, messages, id.toString()); } diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index bc31ad537..56a85c8fd 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -42,11 +42,27 @@ namespace CSMTools void finalCheck(std::vector& messages); //TEMPLATE CHECKS - template void inventoryItemCheck(const ITEM& someitem, std::vector& messages, const std::string& someid, bool enchantable); //for all enchantable items. - template void inventoryItemCheck(const ITEM& someitem, std::vector& messages, const std::string& someid); //for non-enchantable items. - template void toolCheck(const TOOL& sometool, std::vector& messages, const std::string& someid, bool canbebroken); //for tools with uses. - template void toolCheck(const TOOL& sometool, std::vector& messages, const std::string& someid); //for tools without uses. - template void listCheck(const LIST& somelist, std::vector< std::string >& messages, const std::string& Som); + template void inventoryItemCheck(const ITEM& someitem, + std::vector& messages, + const std::string& someID, + bool enchantable); //for all enchantable items. + + template void inventoryItemCheck(const ITEM& someitem, + std::vector& messages, + const std::string& someID); //for non-enchantable items. + + template void toolCheck(const TOOL& sometool, + std::vector& messages, + const std::string& someID, + bool canbebroken); //for tools with uses. + + template void toolCheck(const TOOL& sometool, + std::vector& messages, + const std::string& someID); //for tools without uses. + + template void listCheck(const LIST& somelist, + std::vector< std::string >& messages, + const std::string& someID); const CSMWorld::RefIdData& mReferencables; const CSMWorld::IdCollection& mRaces; From 468b9d734030fb63415559c8eb4ccd556a953bee Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 10 Jan 2014 09:50:56 +0100 Subject: [PATCH 62/74] camel case in the header --- apps/opencs/model/tools/referenceablecheck.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index 56a85c8fd..dbfcd7574 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -42,25 +42,25 @@ namespace CSMTools void finalCheck(std::vector& messages); //TEMPLATE CHECKS - template void inventoryItemCheck(const ITEM& someitem, + template void inventoryItemCheck(const ITEM& someItem, std::vector& messages, const std::string& someID, bool enchantable); //for all enchantable items. - template void inventoryItemCheck(const ITEM& someitem, + template void inventoryItemCheck(const ITEM& someItem, std::vector& messages, const std::string& someID); //for non-enchantable items. - template void toolCheck(const TOOL& sometool, + template void toolCheck(const TOOL& someTool, std::vector& messages, const std::string& someID, bool canbebroken); //for tools with uses. - template void toolCheck(const TOOL& sometool, + template void toolCheck(const TOOL& someTool, std::vector& messages, const std::string& someID); //for tools without uses. - template void listCheck(const LIST& somelist, + template void listCheck(const LIST& someList, std::vector< std::string >& messages, const std::string& someID); From 31c59db71cbc779a0f92ced726150c210b3e7b8f Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 10 Jan 2014 10:22:18 +0100 Subject: [PATCH 63/74] Splited another long line in the header. --- apps/opencs/model/tools/referenceablecheck.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/referenceablecheck.hpp b/apps/opencs/model/tools/referenceablecheck.hpp index dbfcd7574..338983cc7 100644 --- a/apps/opencs/model/tools/referenceablecheck.hpp +++ b/apps/opencs/model/tools/referenceablecheck.hpp @@ -11,7 +11,11 @@ namespace CSMTools class ReferenceableCheckStage : public CSMDoc::Stage { public: - ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, const CSMWorld::IdCollection& classes, const CSMWorld::IdCollection& factions); + ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, + const CSMWorld::IdCollection& races, + const CSMWorld::IdCollection& classes, + const CSMWorld::IdCollection& factions); + virtual void perform(int stage, std::vector< std::string >& messages); virtual int setup(); From 688488de6243f0765766fc08b991b5d49b1d3214 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 10 Jan 2014 10:43:03 +0100 Subject: [PATCH 64/74] replaced == operator for string comparsion in npc check with boost algorithm to get case insensitive check. --- apps/opencs/model/tools/referenceablecheck.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 44bb7d302..fccc5218b 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -1,7 +1,7 @@ #include "referenceablecheck.hpp" #include "../world/record.hpp" #include "../world/universalid.hpp" -#include +#include CSMTools::ReferenceableCheckStage::ReferenceableCheckStage( const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, @@ -651,7 +651,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck( int gold(npc.mNpdt52.mGold); //Detect if player is present - if (npc.mId == "player") + if ( boost::algorithm::iequals(npc.mId, "player") ) { mPlayerPresent = true; } From cb0d3794f7c0247291f3b5d1db4b537cc43cd211 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 10 Jan 2014 10:57:54 +0100 Subject: [PATCH 65/74] Final check is not performed with just +1! Something is not right. --- apps/opencs/model/tools/referenceablecheck.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index fccc5218b..36878d44b 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -215,7 +215,7 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str int CSMTools::ReferenceableCheckStage::setup() { mPlayerPresent = false; - return mReferencables.getSize() + 1; + return mReferencables.getSize() + 2; //DANGER, final check is not performed if it is just +1 } void CSMTools::ReferenceableCheckStage::bookCheck( From 17cc6a695cb2adbbb2cd2c6e41a0651d7bd87c11 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Mon, 13 Jan 2014 18:34:28 +0100 Subject: [PATCH 66/74] fixed bug resposnsible for exception throwed. --- apps/opencs/model/tools/referenceablecheck.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 36878d44b..d5064d272 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -39,7 +39,7 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str stage -= activatorSize; - const int potionSize(mReferencables.getActivators().getSize()); + const int potionSize(mReferencables.getPotions().getSize()); if (stage < potionSize) { From 59de794e58023edeaf218b739bb578fe80cd8150 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Mon, 13 Jan 2014 19:02:23 +0100 Subject: [PATCH 67/74] Creature check was not invoked. --- apps/opencs/model/tools/referenceablecheck.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index d5064d272..f89c641d4 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -206,7 +206,16 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str staticCheck(stage, mReferencables.getStatics(), messages); return; } + + stage -= staticSize; + const int creatureSize(mReferencables.getCreatures().getSize()); + + if (stage < creatureSize) + { + creatureCheck(stage, mReferencables.getCreatures(), messages); + return; + } // if we come that far, we are about to perform our last, final check. finalCheck(messages); return; @@ -215,7 +224,7 @@ void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::str int CSMTools::ReferenceableCheckStage::setup() { mPlayerPresent = false; - return mReferencables.getSize() + 2; //DANGER, final check is not performed if it is just +1 + return mReferencables.getSize() + 1; } void CSMTools::ReferenceableCheckStage::bookCheck( From e34cb9e93196745519aa2e5340a04a698d1af680 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Mon, 13 Jan 2014 19:17:03 +0100 Subject: [PATCH 68/74] changed according to the scrawl sugestion --- apps/opencs/model/tools/referenceablecheck.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index f89c641d4..3be594d3e 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -2,6 +2,7 @@ #include "../world/record.hpp" #include "../world/universalid.hpp" #include +#include "../../../../openmw/apps/openmw/mwclass/misc.hpp" CSMTools::ReferenceableCheckStage::ReferenceableCheckStage( const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, @@ -660,7 +661,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck( int gold(npc.mNpdt52.mGold); //Detect if player is present - if ( boost::algorithm::iequals(npc.mId, "player") ) + if (Misc::StringUtils::ciEqual(npc.mId, "player")) { mPlayerPresent = true; } From 2c1ef610b9251fa40cc0a4a6e08813ed886865b8 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 14 Jan 2014 09:16:59 +0100 Subject: [PATCH 69/74] Moving back to boost for case insensitive comparsion. --- apps/opencs/model/tools/referenceablecheck.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 3be594d3e..f89c641d4 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -2,7 +2,6 @@ #include "../world/record.hpp" #include "../world/universalid.hpp" #include -#include "../../../../openmw/apps/openmw/mwclass/misc.hpp" CSMTools::ReferenceableCheckStage::ReferenceableCheckStage( const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, @@ -661,7 +660,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck( int gold(npc.mNpdt52.mGold); //Detect if player is present - if (Misc::StringUtils::ciEqual(npc.mId, "player")) + if ( boost::algorithm::iequals(npc.mId, "player") ) { mPlayerPresent = true; } From c981a2a6f86c2a5938bcba902cae4c8abf417925 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 14 Jan 2014 09:25:03 +0100 Subject: [PATCH 70/74] Removed boost in favor of #include . Hopefully this will make scrawl happy. :P --- apps/opencs/model/tools/referenceablecheck.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index f89c641d4..5624480af 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -1,7 +1,7 @@ #include "referenceablecheck.hpp" #include "../world/record.hpp" #include "../world/universalid.hpp" -#include +#include CSMTools::ReferenceableCheckStage::ReferenceableCheckStage( const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection& races, @@ -660,7 +660,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck( int gold(npc.mNpdt52.mGold); //Detect if player is present - if ( boost::algorithm::iequals(npc.mId, "player") ) + if (Misc::StringUtils::ciEqual(npc.mId, "player")) //Happy now, scrawl? { mPlayerPresent = true; } From 89d4a90c063bcc90acf1bfe085ad924e81622246 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 15 Jan 2014 10:30:43 +0100 Subject: [PATCH 71/74] Localised version of morrowind will no longer spam false positives. Don't check diff, please. --- apps/opencs/model/tools/referenceablecheck.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 5624480af..ed0fec1da 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -769,7 +769,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck( for (int i = 0; i < mRaces.getSize(); ++i) { - if (dynamic_cast(mRaces.getRecord(i).get()).mName == npc.mRace) //mId in class, mName for race. Stupid. + if (Misc::StringUtils::ciEqual(dynamic_cast(mRaces.getRecord(i).get()).mId, npc.mRace)) { noSuchRace = false; break; From fbcb1a14fc1db7ec495f9cba0970c807dd53bf15 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 15 Jan 2014 11:12:56 +0100 Subject: [PATCH 72/74] ooops, using search id --- apps/opencs/model/tools/referenceablecheck.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index ed0fec1da..62b2a5172 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -765,18 +765,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck( } else //checking if there is a such race { - bool noSuchRace(true); - - for (int i = 0; i < mRaces.getSize(); ++i) - { - if (Misc::StringUtils::ciEqual(dynamic_cast(mRaces.getRecord(i).get()).mId, npc.mRace)) - { - noSuchRace = false; - break; - } - } - - if (noSuchRace) + if ((!mRaces.searchId(npc.mRace))) { messages.push_back(id.toString() + "|" + npc.mId + " has invalid race"); } From 3d722ba1043fa400e578a7688714cf84aa3c5842 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 15 Jan 2014 11:59:11 +0100 Subject: [PATCH 73/74] Corrected brackets. --- apps/opencs/model/tools/referenceablecheck.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 62b2a5172..6615d0a57 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -765,7 +765,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck( } else //checking if there is a such race { - if ((!mRaces.searchId(npc.mRace))) + if (!mRaces.searchId(npc.mRace)) { messages.push_back(id.toString() + "|" + npc.mId + " has invalid race"); } From 6224344957f1c5eff6f88cd94166ffc8491272e6 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 15 Jan 2014 12:52:38 +0100 Subject: [PATCH 74/74] Being any idiot is hard. --- apps/opencs/model/tools/referenceablecheck.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 6615d0a57..dab61bfff 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -765,7 +765,7 @@ void CSMTools::ReferenceableCheckStage::npcCheck( } else //checking if there is a such race { - if (!mRaces.searchId(npc.mRace)) + if (mRaces.searchId(npc.mRace) == -1) { messages.push_back(id.toString() + "|" + npc.mId + " has invalid race"); }