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;