diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index ea002c5ed..ea75fd6d9 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -264,6 +264,13 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() monoFont->setToolTip ("Whether to use monospaced fonts on script edit subview."); } + declareSection ("verifier", "Verifier"); + { + Setting *extraPathgrid = createSetting (Type_CheckBox, "pathgrid-extra-check", "Pathgrid: Extra Check"); + extraPathgrid->setDefaultValue ("false"); + extraPathgrid->setToolTip ("Additional checks for orphaned or duplicated pathgrid points"); + } + { /****************************************************************** * There are three types of values: diff --git a/apps/opencs/model/tools/pathgridcheck.cpp b/apps/opencs/model/tools/pathgridcheck.cpp index 8f22cc8cd..c436cfe04 100644 --- a/apps/opencs/model/tools/pathgridcheck.cpp +++ b/apps/opencs/model/tools/pathgridcheck.cpp @@ -8,15 +8,7 @@ #include "../world/subcellcollection.hpp" #include "../world/pathgrid.hpp" -namespace -{ - struct Point - { - unsigned char mConnectionNum; - std::vector mOtherIndex; - Point() : mConnectionNum(0), mOtherIndex(0) {} - }; -} +#include "../settings/usersettings.hpp" CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection& pathgrids) : mPathgrids (pathgrids) @@ -29,6 +21,12 @@ int CSMTools::PathgridCheckStage::setup() void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& messages) { + // NOTE: This is horribly inefficient but in order to use signals the entire Stage class + // hierarchy needs to be braught under Qt which seems like an overkill for a small + // performance gain during verify operations + CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); + bool extraCheck = userSettings.setting ("verifier/pathgrid-extra-check", QString ("false"))=="true"; + const CSMWorld::Record& record = mPathgrids.getRecord (stage); if (record.isDeleted()) @@ -44,7 +42,7 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message else if (pathgrid.mData.mS2 > static_cast(pathgrid.mPoints.size())) messages.push_back (std::make_pair (id, pathgrid.mId + " has more points than expected")); - std::vector pointList(pathgrid.mPoints.size()); + std::vector pointList(pathgrid.mPoints.size()); std::vector duplList; for (unsigned int i = 0; i < pathgrid.mEdges.size(); ++i) @@ -115,6 +113,9 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message } } + if (!extraCheck) + continue; + // check duplicate points // FIXME: how to do this efficiently? for (unsigned int j = 0; j < pathgrid.mPoints.size(); ++j) @@ -143,6 +144,9 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message } } + if (!extraCheck) + return; + // check pathgrid points that are not connected to anything for (unsigned int i = 0; i < pointList.size(); ++i) { diff --git a/apps/opencs/model/tools/pathgridcheck.hpp b/apps/opencs/model/tools/pathgridcheck.hpp index c90dbc8ed..603235552 100644 --- a/apps/opencs/model/tools/pathgridcheck.hpp +++ b/apps/opencs/model/tools/pathgridcheck.hpp @@ -14,13 +14,23 @@ namespace CSMWorld namespace CSMTools { + + struct Point + { + unsigned char mConnectionNum; + std::vector mOtherIndex; + Point() : mConnectionNum(0), mOtherIndex(0) {} + }; + class PathgridCheckStage : public CSMDoc::Stage { - const CSMWorld::SubCellCollection >& mPathgrids; + const CSMWorld::SubCellCollection >& mPathgrids; public: - PathgridCheckStage (const CSMWorld::SubCellCollection >& pathgrids); + PathgridCheckStage (const CSMWorld::SubCellCollection >& pathgrids); virtual int setup();