gmst verifier

This commit is contained in:
Aesylwinn 2016-01-17 21:55:03 -05:00
parent ed242d8151
commit 1d86f705ba
7 changed files with 2514 additions and 1994 deletions

View file

@ -26,7 +26,7 @@ opencs_units_noqt (model/world
universalid record commands columnbase columnimp scriptcontext cell refidcollection
refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection tablemimedata cellcoordinates cellselection resources resourcesmanager scope
pathgrid landtexture land nestedtablewrapper nestedcollection nestedcoladapterimp nestedinfocollection
idcompletionmanager metadata
idcompletionmanager metadata defaultgmsts
)
opencs_hdrs_noqt (model/world
@ -42,7 +42,7 @@ opencs_units_noqt (model/tools
mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck
birthsigncheck spellcheck referencecheck referenceablecheck scriptcheck bodypartcheck
startscriptcheck search searchoperation searchstage pathgridcheck soundgencheck magiceffectcheck
mergestages
mergestages gmstcheck
)
opencs_hdrs_noqt (model/tools

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,91 @@
#include "gmstcheck.hpp"
#include "../world/defaultgmsts.hpp"
CSMTools::GMSTCheckStage::GMSTCheckStage(const CSMWorld::IdCollection<ESM::GameSetting>& gameSettings)
: mGameSettings(gameSettings)
{}
int CSMTools::GMSTCheckStage::setup()
{
return mGameSettings.getSize();
}
void CSMTools::GMSTCheckStage::perform(int stage, CSMDoc::Messages& messages)
{
const CSMWorld::Record<ESM::GameSetting>& record = mGameSettings.getRecord (stage);
if (record.isDeleted())
return;
const ESM::GameSetting& gmst = record.get();
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Gmst, gmst.mId);
// Test for empty string
if (gmst.mValue.getType() == ESM::VT_String && gmst.mValue.getString().empty())
messages.add(id, gmst.mId + " is an empty string", "", CSMDoc::Message::Severity_Warning);
// Checking type and limits
// optimization - compare it to lists based on naming convention (f-float,i-int,s-string)
if (gmst.mId[0] == 'f')
{
for (size_t i = 0; i < CSMWorld::DefaultGMSTs::FloatCount; ++i)
{
if (gmst.mId == CSMWorld::DefaultGMSTs::Floats[i])
{
if (gmst.mValue.getType() != ESM::VT_Float)
messages.add(id, "The type of " + gmst.mId + " is incorrect",
"Change the GMST type to a float", CSMDoc::Message::Severity_Error);
if (gmst.mValue.getFloat() < CSMWorld::DefaultGMSTs::FloatLimits[i*2])
messages.add(id, gmst.mId + " is less than the suggested range", "Change the value",
CSMDoc::Message::Severity_Warning);
if (gmst.mValue.getFloat() > CSMWorld::DefaultGMSTs::FloatLimits[i*2+1])
messages.add(id, gmst.mId + " is more than the suggested range", "Change the value",
CSMDoc::Message::Severity_Warning);
break; // for loop
}
}
}
else if (gmst.mId[0] == 'i')
{
for (size_t i = 0; i < CSMWorld::DefaultGMSTs::IntCount; ++i)
{
if (gmst.mId == CSMWorld::DefaultGMSTs::Ints[i])
{
if (gmst.mValue.getType() != ESM::VT_Int)
messages.add(id, "The type of " + gmst.mId + " is incorrect",
"Change the GMST type to an int", CSMDoc::Message::Severity_Error);
if (gmst.mValue.getInteger() < CSMWorld::DefaultGMSTs::IntLimits[i*2])
messages.add(id, gmst.mId + " is less than the suggested range", "Change the value",
CSMDoc::Message::Severity_Warning);
if (gmst.mValue.getInteger() > CSMWorld::DefaultGMSTs::IntLimits[i*2+1])
messages.add(id, gmst.mId + " is more than the suggested range", "Change the value",
CSMDoc::Message::Severity_Warning);
break; // for loop
}
}
}
else if (gmst.mId[0] == 's')
{
for (size_t i = 0; i < CSMWorld::DefaultGMSTs::StringCount; ++i)
{
if (gmst.mId == CSMWorld::DefaultGMSTs::Strings[i])
{
ESM::VarType type = gmst.mValue.getType();
if (type != ESM::VT_String && type != ESM::VT_None)
messages.add(id, "The type of " + gmst.mId + " is incorrect",
"Change the GMST type to a string", CSMDoc::Message::Severity_Error);
break; // for loop
}
}
}
}

View file

@ -0,0 +1,32 @@
#ifndef CSM_TOOLS_GMSTCHECK_H
#define CSM_TOOLS_GMSTCHECK_H
#include <components/esm/loadgmst.hpp>
#include "../world/idcollection.hpp"
#include "../doc/stage.hpp"
namespace CSMTools
{
/// \brief VerifyStage: make sure that GMSTs are alright
class GMSTCheckStage : public CSMDoc::Stage
{
public:
GMSTCheckStage(const CSMWorld::IdCollection<ESM::GameSetting>& gameSettings);
virtual int setup();
///< \return number of steps
virtual void perform(int stage, CSMDoc::Messages& messages);
///< Messages resulting from this stage will be appended to \a messages
private:
const CSMWorld::IdCollection<ESM::GameSetting>& mGameSettings;
};
}
#endif

View file

@ -29,6 +29,7 @@
#include "soundgencheck.hpp"
#include "magiceffectcheck.hpp"
#include "mergeoperation.hpp"
#include "gmstcheck.hpp"
CSMDoc::OperationHolder *CSMTools::Tools::get (int type)
{
@ -110,6 +111,8 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier()
mData.getReferenceables(),
mData.getResources (CSMWorld::UniversalId::Type_Icons),
mData.getResources (CSMWorld::UniversalId::Type_Textures)));
mVerifierOperation->appendStage (new GMSTCheckStage (mData.getGmsts()));
mVerifier.setOperation (mVerifierOperation);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,34 @@
#ifndef CSM_WORLD_DEFAULTGMSTS_H
#define CSM_WORLD_DEFAULTGMSTS_H
#include <cstddef>
namespace CSMWorld {
namespace DefaultGMSTs {
const size_t FloatCount = 258;
const size_t IntCount = 89;
const size_t StringCount = 1174;
const size_t OptionalFloatCount = 42;
const size_t OptionalIntCount = 4;
const size_t OptionalStringCount = 26;
extern const char* Floats[];
extern const char * Ints[];
extern const char * Strings[];
extern const char * OptionalFloats[];
extern const char * OptionalInts[];
extern const char * OptionalStrings[];
extern const float FloatsDefaultValues[];
extern const int IntsDefaultValues[];
extern const float FloatLimits[];
extern const int IntLimits[];
}
}
#endif