mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 18:39:40 +00:00
Add user preference option to check unused or redundant pathgrid points. Also resolve namespace clash issue in osx.
This commit is contained in:
parent
b6878c2e0c
commit
00c165d3a5
3 changed files with 33 additions and 12 deletions
|
@ -264,6 +264,13 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
monoFont->setToolTip ("Whether to use monospaced fonts on script edit subview.");
|
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:
|
* There are three types of values:
|
||||||
|
|
|
@ -8,15 +8,7 @@
|
||||||
#include "../world/subcellcollection.hpp"
|
#include "../world/subcellcollection.hpp"
|
||||||
#include "../world/pathgrid.hpp"
|
#include "../world/pathgrid.hpp"
|
||||||
|
|
||||||
namespace
|
#include "../settings/usersettings.hpp"
|
||||||
{
|
|
||||||
struct Point
|
|
||||||
{
|
|
||||||
unsigned char mConnectionNum;
|
|
||||||
std::vector<int> mOtherIndex;
|
|
||||||
Point() : mConnectionNum(0), mOtherIndex(0) {}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids)
|
CSMTools::PathgridCheckStage::PathgridCheckStage (const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids)
|
||||||
: mPathgrids (pathgrids)
|
: mPathgrids (pathgrids)
|
||||||
|
@ -29,6 +21,12 @@ int CSMTools::PathgridCheckStage::setup()
|
||||||
|
|
||||||
void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& messages)
|
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<CSMWorld::Pathgrid>& record = mPathgrids.getRecord (stage);
|
const CSMWorld::Record<CSMWorld::Pathgrid>& record = mPathgrids.getRecord (stage);
|
||||||
|
|
||||||
if (record.isDeleted())
|
if (record.isDeleted())
|
||||||
|
@ -44,7 +42,7 @@ void CSMTools::PathgridCheckStage::perform (int stage, CSMDoc::Messages& message
|
||||||
else if (pathgrid.mData.mS2 > static_cast<int>(pathgrid.mPoints.size()))
|
else if (pathgrid.mData.mS2 > static_cast<int>(pathgrid.mPoints.size()))
|
||||||
messages.push_back (std::make_pair (id, pathgrid.mId + " has more points than expected"));
|
messages.push_back (std::make_pair (id, pathgrid.mId + " has more points than expected"));
|
||||||
|
|
||||||
std::vector<Point> pointList(pathgrid.mPoints.size());
|
std::vector<CSMTools::Point> pointList(pathgrid.mPoints.size());
|
||||||
std::vector<int> duplList;
|
std::vector<int> duplList;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < pathgrid.mEdges.size(); ++i)
|
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
|
// check duplicate points
|
||||||
// FIXME: how to do this efficiently?
|
// FIXME: how to do this efficiently?
|
||||||
for (unsigned int j = 0; j < pathgrid.mPoints.size(); ++j)
|
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
|
// check pathgrid points that are not connected to anything
|
||||||
for (unsigned int i = 0; i < pointList.size(); ++i)
|
for (unsigned int i = 0; i < pointList.size(); ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,13 +14,23 @@ namespace CSMWorld
|
||||||
|
|
||||||
namespace CSMTools
|
namespace CSMTools
|
||||||
{
|
{
|
||||||
|
|
||||||
|
struct Point
|
||||||
|
{
|
||||||
|
unsigned char mConnectionNum;
|
||||||
|
std::vector<int> mOtherIndex;
|
||||||
|
Point() : mConnectionNum(0), mOtherIndex(0) {}
|
||||||
|
};
|
||||||
|
|
||||||
class PathgridCheckStage : public CSMDoc::Stage
|
class PathgridCheckStage : public CSMDoc::Stage
|
||||||
{
|
{
|
||||||
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid, CSMWorld::IdAccessor<CSMWorld::Pathgrid> >& mPathgrids;
|
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid,
|
||||||
|
CSMWorld::IdAccessor<CSMWorld::Pathgrid> >& mPathgrids;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PathgridCheckStage (const CSMWorld::SubCellCollection<CSMWorld::Pathgrid, CSMWorld::IdAccessor<CSMWorld::Pathgrid> >& pathgrids);
|
PathgridCheckStage (const CSMWorld::SubCellCollection<CSMWorld::Pathgrid,
|
||||||
|
CSMWorld::IdAccessor<CSMWorld::Pathgrid> >& pathgrids);
|
||||||
|
|
||||||
virtual int setup();
|
virtual int setup();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue