1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-21 22:09:39 +00:00

Make finishing touches to object record verifiers

This commit is contained in:
Capostrophic 2018-08-26 21:18:17 +03:00
parent d1b2fc11ef
commit 34ffaa2fe2
2 changed files with 49 additions and 48 deletions

View file

@ -16,7 +16,7 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(
const CSMWorld::Resources& models, const CSMWorld::Resources& models,
const CSMWorld::Resources& icons, const CSMWorld::Resources& icons,
const CSMWorld::IdCollection<ESM::BodyPart>& bodyparts) const CSMWorld::IdCollection<ESM::BodyPart>& bodyparts)
:mObjects(referenceable), :mReferencables(referenceable),
mRaces(races), mRaces(races),
mClasses(classes), mClasses(classes),
mFactions(faction), mFactions(faction),
@ -32,201 +32,201 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(
void CSMTools::ReferenceableCheckStage::perform (int stage, CSMDoc::Messages& messages) void CSMTools::ReferenceableCheckStage::perform (int stage, CSMDoc::Messages& messages)
{ {
//Checks for books, than, when stage is above mBooksSize goes to other checks, with (stage - PrevSum) as stage. //Checks for books, than, when stage is above mBooksSize goes to other checks, with (stage - PrevSum) as stage.
const int bookSize(mObjects.getBooks().getSize()); const int bookSize(mReferencables.getBooks().getSize());
if (stage < bookSize) if (stage < bookSize)
{ {
bookCheck(stage, mObjects.getBooks(), messages); bookCheck(stage, mReferencables.getBooks(), messages);
return; return;
} }
stage -= bookSize; stage -= bookSize;
const int activatorSize(mObjects.getActivators().getSize()); const int activatorSize(mReferencables.getActivators().getSize());
if (stage < activatorSize) if (stage < activatorSize)
{ {
activatorCheck(stage, mObjects.getActivators(), messages); activatorCheck(stage, mReferencables.getActivators(), messages);
return; return;
} }
stage -= activatorSize; stage -= activatorSize;
const int potionSize(mObjects.getPotions().getSize()); const int potionSize(mReferencables.getPotions().getSize());
if (stage < potionSize) if (stage < potionSize)
{ {
potionCheck(stage, mObjects.getPotions(), messages); potionCheck(stage, mReferencables.getPotions(), messages);
return; return;
} }
stage -= potionSize; stage -= potionSize;
const int apparatusSize(mObjects.getApparati().getSize()); const int apparatusSize(mReferencables.getApparati().getSize());
if (stage < apparatusSize) if (stage < apparatusSize)
{ {
apparatusCheck(stage, mObjects.getApparati(), messages); apparatusCheck(stage, mReferencables.getApparati(), messages);
return; return;
} }
stage -= apparatusSize; stage -= apparatusSize;
const int armorSize(mObjects.getArmors().getSize()); const int armorSize(mReferencables.getArmors().getSize());
if (stage < armorSize) if (stage < armorSize)
{ {
armorCheck(stage, mObjects.getArmors(), messages); armorCheck(stage, mReferencables.getArmors(), messages);
return; return;
} }
stage -= armorSize; stage -= armorSize;
const int clothingSize(mObjects.getClothing().getSize()); const int clothingSize(mReferencables.getClothing().getSize());
if (stage < clothingSize) if (stage < clothingSize)
{ {
clothingCheck(stage, mObjects.getClothing(), messages); clothingCheck(stage, mReferencables.getClothing(), messages);
return; return;
} }
stage -= clothingSize; stage -= clothingSize;
const int containerSize(mObjects.getContainers().getSize()); const int containerSize(mReferencables.getContainers().getSize());
if (stage < containerSize) if (stage < containerSize)
{ {
containerCheck(stage, mObjects.getContainers(), messages); containerCheck(stage, mReferencables.getContainers(), messages);
return; return;
} }
stage -= containerSize; stage -= containerSize;
const int doorSize(mObjects.getDoors().getSize()); const int doorSize(mReferencables.getDoors().getSize());
if (stage < doorSize) if (stage < doorSize)
{ {
doorCheck(stage, mObjects.getDoors(), messages); doorCheck(stage, mReferencables.getDoors(), messages);
return; return;
} }
stage -= doorSize; stage -= doorSize;
const int ingredientSize(mObjects.getIngredients().getSize()); const int ingredientSize(mReferencables.getIngredients().getSize());
if (stage < ingredientSize) if (stage < ingredientSize)
{ {
ingredientCheck(stage, mObjects.getIngredients(), messages); ingredientCheck(stage, mReferencables.getIngredients(), messages);
return; return;
} }
stage -= ingredientSize; stage -= ingredientSize;
const int creatureLevListSize(mObjects.getCreatureLevelledLists().getSize()); const int creatureLevListSize(mReferencables.getCreatureLevelledLists().getSize());
if (stage < creatureLevListSize) if (stage < creatureLevListSize)
{ {
creaturesLevListCheck(stage, mObjects.getCreatureLevelledLists(), messages); creaturesLevListCheck(stage, mReferencables.getCreatureLevelledLists(), messages);
return; return;
} }
stage -= creatureLevListSize; stage -= creatureLevListSize;
const int itemLevelledListSize(mObjects.getItemLevelledList().getSize()); const int itemLevelledListSize(mReferencables.getItemLevelledList().getSize());
if (stage < itemLevelledListSize) if (stage < itemLevelledListSize)
{ {
itemLevelledListCheck(stage, mObjects.getItemLevelledList(), messages); itemLevelledListCheck(stage, mReferencables.getItemLevelledList(), messages);
return; return;
} }
stage -= itemLevelledListSize; stage -= itemLevelledListSize;
const int lightSize(mObjects.getLights().getSize()); const int lightSize(mReferencables.getLights().getSize());
if (stage < lightSize) if (stage < lightSize)
{ {
lightCheck(stage, mObjects.getLights(), messages); lightCheck(stage, mReferencables.getLights(), messages);
return; return;
} }
stage -= lightSize; stage -= lightSize;
const int lockpickSize(mObjects.getLocpicks().getSize()); const int lockpickSize(mReferencables.getLocpicks().getSize());
if (stage < lockpickSize) if (stage < lockpickSize)
{ {
lockpickCheck(stage, mObjects.getLocpicks(), messages); lockpickCheck(stage, mReferencables.getLocpicks(), messages);
return; return;
} }
stage -= lockpickSize; stage -= lockpickSize;
const int miscSize(mObjects.getMiscellaneous().getSize()); const int miscSize(mReferencables.getMiscellaneous().getSize());
if (stage < miscSize) if (stage < miscSize)
{ {
miscCheck(stage, mObjects.getMiscellaneous(), messages); miscCheck(stage, mReferencables.getMiscellaneous(), messages);
return; return;
} }
stage -= miscSize; stage -= miscSize;
const int npcSize(mObjects.getNPCs().getSize()); const int npcSize(mReferencables.getNPCs().getSize());
if (stage < npcSize) if (stage < npcSize)
{ {
npcCheck(stage, mObjects.getNPCs(), messages); npcCheck(stage, mReferencables.getNPCs(), messages);
return; return;
} }
stage -= npcSize; stage -= npcSize;
const int weaponSize(mObjects.getWeapons().getSize()); const int weaponSize(mReferencables.getWeapons().getSize());
if (stage < weaponSize) if (stage < weaponSize)
{ {
weaponCheck(stage, mObjects.getWeapons(), messages); weaponCheck(stage, mReferencables.getWeapons(), messages);
return; return;
} }
stage -= weaponSize; stage -= weaponSize;
const int probeSize(mObjects.getProbes().getSize()); const int probeSize(mReferencables.getProbes().getSize());
if (stage < probeSize) if (stage < probeSize)
{ {
probeCheck(stage, mObjects.getProbes(), messages); probeCheck(stage, mReferencables.getProbes(), messages);
return; return;
} }
stage -= probeSize; stage -= probeSize;
const int repairSize(mObjects.getRepairs().getSize()); const int repairSize(mReferencables.getRepairs().getSize());
if (stage < repairSize) if (stage < repairSize)
{ {
repairCheck(stage, mObjects.getRepairs(), messages); repairCheck(stage, mReferencables.getRepairs(), messages);
return; return;
} }
stage -= repairSize; stage -= repairSize;
const int staticSize(mObjects.getStatics().getSize()); const int staticSize(mReferencables.getStatics().getSize());
if (stage < staticSize) if (stage < staticSize)
{ {
staticCheck(stage, mObjects.getStatics(), messages); staticCheck(stage, mReferencables.getStatics(), messages);
return; return;
} }
stage -= staticSize; stage -= staticSize;
const int creatureSize(mObjects.getCreatures().getSize()); const int creatureSize(mReferencables.getCreatures().getSize());
if (stage < creatureSize) if (stage < creatureSize)
{ {
creatureCheck(stage, mObjects.getCreatures(), messages); creatureCheck(stage, mReferencables.getCreatures(), messages);
return; return;
} }
// if we come that far, we are about to perform our last, final check. // if we come that far, we are about to perform our last, final check.
@ -239,7 +239,7 @@ int CSMTools::ReferenceableCheckStage::setup()
mPlayerPresent = false; mPlayerPresent = false;
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue(); mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
return mObjects.getSize() + 1; return mReferencables.getSize() + 1;
} }
void CSMTools::ReferenceableCheckStage::bookCheck( void CSMTools::ReferenceableCheckStage::bookCheck(
@ -300,6 +300,7 @@ void CSMTools::ReferenceableCheckStage::potionCheck(
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Potion, potion.mId); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Potion, potion.mId);
inventoryItemCheck<ESM::Potion>(potion, messages, id.toString()); inventoryItemCheck<ESM::Potion>(potion, messages, id.toString());
/// \todo Check magic effects for validity
// Check that mentioned scripts exist // Check that mentioned scripts exist
scriptCheck<ESM::Potion>(potion, messages, id.toString()); scriptCheck<ESM::Potion>(potion, messages, id.toString());
@ -485,7 +486,7 @@ void CSMTools::ReferenceableCheckStage::creatureCheck (
if (!creature.mOriginal.empty()) if (!creature.mOriginal.empty())
{ {
CSMWorld::RefIdData::LocalIndex index = mObjects.searchId(creature.mOriginal); CSMWorld::RefIdData::LocalIndex index = mReferencables.searchId(creature.mOriginal);
if (index.first == -1) if (index.first == -1)
messages.add(id, "Parent creature '" + creature.mOriginal + "' does not exist", "", CSMDoc::Message::Severity_Error); messages.add(id, "Parent creature '" + creature.mOriginal + "' does not exist", "", CSMDoc::Message::Severity_Error);
else if (index.second != CSMWorld::UniversalId::Type_Creature) else if (index.second != CSMWorld::UniversalId::Type_Creature)
@ -892,7 +893,7 @@ void CSMTools::ReferenceableCheckStage::staticCheck (
if (staticElement.mModel.empty()) if (staticElement.mModel.empty())
messages.add(id, "Model is missing", "", CSMDoc::Message::Severity_Error); messages.add(id, "Model is missing", "", CSMDoc::Message::Severity_Error);
else if (mModels.searchId(staticElement.mModel) == -1) else if (mModels.searchId(staticElement.mModel) == -1)
messages.add(id, "Model '" + staticElement.mModel + "' does not exist", "", CSMDoc::Message::Severity_Error); messages.add(id, "Model '" + staticElement.mModel + "' does not exist", "", CSMDoc::Message::Severity_Error);
} }
//final check //final check
@ -911,7 +912,7 @@ void CSMTools::ReferenceableCheckStage::inventoryListCheck(
for (size_t i = 0; i < itemList.size(); ++i) for (size_t i = 0; i < itemList.size(); ++i)
{ {
std::string itemName = itemList[i].mItem.toString(); std::string itemName = itemList[i].mItem.toString();
CSMWorld::RefIdData::LocalIndex localIndex = mObjects.searchId(itemName); CSMWorld::RefIdData::LocalIndex localIndex = mReferencables.searchId(itemName);
if (localIndex.first == -1) if (localIndex.first == -1)
messages.add(id, "Item '" + itemName + "' does not exist", "", CSMDoc::Message::Severity_Error); messages.add(id, "Item '" + itemName + "' does not exist", "", CSMDoc::Message::Severity_Error);
@ -1020,7 +1021,7 @@ template<typename Tool> void CSMTools::ReferenceableCheckStage::toolCheck (
template<typename Tool> void CSMTools::ReferenceableCheckStage::toolCheck ( template<typename Tool> void CSMTools::ReferenceableCheckStage::toolCheck (
const Tool& someTool, CSMDoc::Messages& messages, const std::string& someID) const Tool& someTool, CSMDoc::Messages& messages, const std::string& someID)
{ {
if (someTool.mData.mQuality <= 0) if (someTool.mData.mQuality <= 0)
messages.add(someID, "Quality is non-positive", "", CSMDoc::Message::Severity_Error); messages.add(someID, "Quality is non-positive", "", CSMDoc::Message::Severity_Error);
} }
@ -1030,7 +1031,7 @@ template<typename List> void CSMTools::ReferenceableCheckStage::listCheck (
{ {
for (unsigned i = 0; i < someList.mList.size(); ++i) for (unsigned i = 0; i < someList.mList.size(); ++i)
{ {
if (mObjects.searchId(someList.mList[i].mId).first == -1) if (mReferencables.searchId(someList.mList[i].mId).first == -1)
messages.add(someID, "Object '" + someList.mList[i].mId + "' does not exist", "", CSMDoc::Message::Severity_Error); messages.add(someID, "Object '" + someList.mList[i].mId + "' does not exist", "", CSMDoc::Message::Severity_Error);
if (someList.mList[i].mLevel < 1) if (someList.mList[i].mLevel < 1)

View file

@ -80,7 +80,7 @@ namespace CSMTools
CSMDoc::Messages& messages, CSMDoc::Messages& messages,
const std::string& someID); const std::string& someID);
const CSMWorld::RefIdData& mObjects; 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; const CSMWorld::IdCollection<ESM::Faction>& mFactions;