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