|
|
|
@ -1,17 +1,19 @@
|
|
|
|
|
#include "gmstcheck.hpp"
|
|
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
|
|
#include "../world/defaultgmsts.hpp"
|
|
|
|
|
|
|
|
|
|
CSMTools::GMSTCheckStage::GMSTCheckStage(const CSMWorld::IdCollection<ESM::GameSetting>& gameSettings)
|
|
|
|
|
CSMTools::GmstCheckStage::GmstCheckStage(const CSMWorld::IdCollection<ESM::GameSetting>& gameSettings)
|
|
|
|
|
: mGameSettings(gameSettings)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
int CSMTools::GMSTCheckStage::setup()
|
|
|
|
|
int CSMTools::GmstCheckStage::setup()
|
|
|
|
|
{
|
|
|
|
|
return mGameSettings.getSize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMTools::GMSTCheckStage::perform(int stage, CSMDoc::Messages& messages)
|
|
|
|
|
void CSMTools::GmstCheckStage::perform(int stage, CSMDoc::Messages& messages)
|
|
|
|
|
{
|
|
|
|
|
const CSMWorld::Record<ESM::GameSetting>& record = mGameSettings.getRecord (stage);
|
|
|
|
|
|
|
|
|
@ -30,20 +32,25 @@ void CSMTools::GMSTCheckStage::perform(int stage, CSMDoc::Messages& messages)
|
|
|
|
|
// 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)
|
|
|
|
|
for (size_t i = 0; i < CSMWorld::DefaultGmsts::FloatCount; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (gmst.mId == CSMWorld::DefaultGMSTs::Floats[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);
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream stream;
|
|
|
|
|
stream << "Expected float type for " << gmst.mId << " but found "
|
|
|
|
|
<< varTypeToString(gmst.mValue.getType()) << " type";
|
|
|
|
|
|
|
|
|
|
messages.add(id, stream.str(), "", 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",
|
|
|
|
|
if (gmst.mValue.getFloat() < CSMWorld::DefaultGmsts::FloatLimits[i*2])
|
|
|
|
|
messages.add(id, gmst.mId + " is less than the suggested range", "",
|
|
|
|
|
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",
|
|
|
|
|
if (gmst.mValue.getFloat() > CSMWorld::DefaultGmsts::FloatLimits[i*2+1])
|
|
|
|
|
messages.add(id, gmst.mId + " is more than the suggested range", "",
|
|
|
|
|
CSMDoc::Message::Severity_Warning);
|
|
|
|
|
|
|
|
|
|
break; // for loop
|
|
|
|
@ -52,20 +59,25 @@ void CSMTools::GMSTCheckStage::perform(int stage, CSMDoc::Messages& messages)
|
|
|
|
|
}
|
|
|
|
|
else if (gmst.mId[0] == 'i')
|
|
|
|
|
{
|
|
|
|
|
for (size_t i = 0; i < CSMWorld::DefaultGMSTs::IntCount; ++i)
|
|
|
|
|
for (size_t i = 0; i < CSMWorld::DefaultGmsts::IntCount; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (gmst.mId == CSMWorld::DefaultGMSTs::Ints[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);
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream stream;
|
|
|
|
|
stream << "Expected int type for " << gmst.mId << " but found "
|
|
|
|
|
<< varTypeToString(gmst.mValue.getType()) << " type";
|
|
|
|
|
|
|
|
|
|
messages.add(id, stream.str(), "", 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",
|
|
|
|
|
if (gmst.mValue.getInteger() < CSMWorld::DefaultGmsts::IntLimits[i*2])
|
|
|
|
|
messages.add(id, gmst.mId + " is less than the suggested range", "",
|
|
|
|
|
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",
|
|
|
|
|
if (gmst.mValue.getInteger() > CSMWorld::DefaultGmsts::IntLimits[i*2+1])
|
|
|
|
|
messages.add(id, gmst.mId + " is more than the suggested range", "",
|
|
|
|
|
CSMDoc::Message::Severity_Warning);
|
|
|
|
|
|
|
|
|
|
break; // for loop
|
|
|
|
@ -74,18 +86,38 @@ void CSMTools::GMSTCheckStage::perform(int stage, CSMDoc::Messages& messages)
|
|
|
|
|
}
|
|
|
|
|
else if (gmst.mId[0] == 's')
|
|
|
|
|
{
|
|
|
|
|
for (size_t i = 0; i < CSMWorld::DefaultGMSTs::StringCount; ++i)
|
|
|
|
|
for (size_t i = 0; i < CSMWorld::DefaultGmsts::StringCount; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (gmst.mId == CSMWorld::DefaultGMSTs::Strings[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);
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream stream;
|
|
|
|
|
stream << "Expected string or none type for " << gmst.mId << " but found "
|
|
|
|
|
<< varTypeToString(gmst.mValue.getType()) << " type";
|
|
|
|
|
|
|
|
|
|
messages.add(id, stream.str(), "", CSMDoc::Message::Severity_Error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break; // for loop
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string CSMTools::GmstCheckStage::varTypeToString(ESM::VarType type)
|
|
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case ESM::VT_Unknown: return "unknown";
|
|
|
|
|
case ESM::VT_None: return "none";
|
|
|
|
|
case ESM::VT_Short: return "short";
|
|
|
|
|
case ESM::VT_Int: return "int";
|
|
|
|
|
case ESM::VT_Long: return "long";
|
|
|
|
|
case ESM::VT_Float: return "float";
|
|
|
|
|
case ESM::VT_String: return "string";
|
|
|
|
|
default: return "unhandled";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|