Added faction check.

This commit is contained in:
Marek Kochanowicz 2013-12-29 21:02:53 +01:00
parent 9df6d23afc
commit e321d571e1
3 changed files with 35 additions and 5 deletions

View file

@ -9,10 +9,11 @@
#include "../world/universalid.hpp" #include "../world/universalid.hpp"
CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection<ESM::Race >& races, const CSMWorld::IdCollection<ESM::Class>& classes) : CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection<ESM::Race >& races, const CSMWorld::IdCollection<ESM::Class>& classes, const CSMWorld::IdCollection<ESM::Faction>& faction) :
mReferencables(referenceable), mReferencables(referenceable),
mClasses(classes), 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.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? messages.push_back(id.toString() + "|" + NPC.mId + " mNpdtType and flags mismatch!"); //should not happend?
return; 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 //TODO: reputation, Disposition, rank, everything else
} }

View file

@ -11,7 +11,7 @@ namespace CSMTools
class ReferenceableCheckStage : public CSMDoc::Stage class ReferenceableCheckStage : public CSMDoc::Stage
{ {
public: public:
ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection<ESM::Race>& races, const CSMWorld::IdCollection<ESM::Class>& classes); ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection<ESM::Race>& races, const CSMWorld::IdCollection<ESM::Class>& classes, const CSMWorld::IdCollection<ESM::Faction>& factions);
virtual void perform(int stage, std::vector< std::string >& messages); virtual void perform(int stage, std::vector< std::string >& messages);
virtual int setup(); virtual int setup();
@ -37,6 +37,7 @@ namespace CSMTools
const CSMWorld::RefIdData& mReferencables; const CSMWorld::RefIdData& mReferencables;
const CSMWorld::IdCollection<ESM::Race>& mRaces; const CSMWorld::IdCollection<ESM::Race>& mRaces;
const CSMWorld::IdCollection<ESM::Class>& mClasses; const CSMWorld::IdCollection<ESM::Class>& mClasses;
const CSMWorld::IdCollection<ESM::Faction>& mFactions;
}; };
} }
#endif // REFERENCEABLECHECKSTAGE_H #endif // REFERENCEABLECHECKSTAGE_H

View file

@ -76,7 +76,7 @@ CSMDoc::Operation *CSMTools::Tools::getVerifier()
mVerifier->appendStage (new SpellCheckStage (mData.getSpells())); 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; return mVerifier;