From bf0383fe056472442228e4cc4518dc2f47ee2d69 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 28 Dec 2013 18:07:01 +0100 Subject: [PATCH] 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;