Removed hints from error messages and fixed naming to match conventions

coverity_scan
Aesylwinn 9 years ago
parent 1d86f705ba
commit bbda5fe634

@ -14,28 +14,28 @@
void CSMDoc::Document::addGmsts() void CSMDoc::Document::addGmsts()
{ {
for (size_t i=0; i < CSMWorld::DefaultGMSTs::FloatCount; ++i) for (size_t i=0; i < CSMWorld::DefaultGmsts::FloatCount; ++i)
{ {
ESM::GameSetting gmst; ESM::GameSetting gmst;
gmst.mId = CSMWorld::DefaultGMSTs::Floats[i]; gmst.mId = CSMWorld::DefaultGmsts::Floats[i];
gmst.mValue.setType (ESM::VT_Float); gmst.mValue.setType (ESM::VT_Float);
gmst.mValue.setFloat (CSMWorld::DefaultGMSTs::FloatsDefaultValues[i]); gmst.mValue.setFloat (CSMWorld::DefaultGmsts::FloatsDefaultValues[i]);
getData().getGmsts().add (gmst); getData().getGmsts().add (gmst);
} }
for (size_t i=0; i < CSMWorld::DefaultGMSTs::IntCount; ++i) for (size_t i=0; i < CSMWorld::DefaultGmsts::IntCount; ++i)
{ {
ESM::GameSetting gmst; ESM::GameSetting gmst;
gmst.mId = CSMWorld::DefaultGMSTs::Ints[i]; gmst.mId = CSMWorld::DefaultGmsts::Ints[i];
gmst.mValue.setType (ESM::VT_Int); gmst.mValue.setType (ESM::VT_Int);
gmst.mValue.setInteger (CSMWorld::DefaultGMSTs::IntsDefaultValues[i]); gmst.mValue.setInteger (CSMWorld::DefaultGmsts::IntsDefaultValues[i]);
getData().getGmsts().add (gmst); getData().getGmsts().add (gmst);
} }
for (size_t i=0; i < CSMWorld::DefaultGMSTs::StringCount; ++i) for (size_t i=0; i < CSMWorld::DefaultGmsts::StringCount; ++i)
{ {
ESM::GameSetting gmst; ESM::GameSetting gmst;
gmst.mId = CSMWorld::DefaultGMSTs::Strings[i]; gmst.mId = CSMWorld::DefaultGmsts::Strings[i];
gmst.mValue.setType (ESM::VT_String); gmst.mValue.setType (ESM::VT_String);
gmst.mValue.setString (""); gmst.mValue.setString ("");
getData().getGmsts().add (gmst); getData().getGmsts().add (gmst);
@ -44,28 +44,28 @@ void CSMDoc::Document::addGmsts()
void CSMDoc::Document::addOptionalGmsts() void CSMDoc::Document::addOptionalGmsts()
{ {
for (size_t i=0; i < CSMWorld::DefaultGMSTs::OptionalFloatCount; ++i) for (size_t i=0; i < CSMWorld::DefaultGmsts::OptionalFloatCount; ++i)
{ {
ESM::GameSetting gmst; ESM::GameSetting gmst;
gmst.mId = CSMWorld::DefaultGMSTs::OptionalFloats[i]; gmst.mId = CSMWorld::DefaultGmsts::OptionalFloats[i];
gmst.blank(); gmst.blank();
gmst.mValue.setType (ESM::VT_Float); gmst.mValue.setType (ESM::VT_Float);
addOptionalGmst (gmst); addOptionalGmst (gmst);
} }
for (size_t i=0; i < CSMWorld::DefaultGMSTs::OptionalIntCount; ++i) for (size_t i=0; i < CSMWorld::DefaultGmsts::OptionalIntCount; ++i)
{ {
ESM::GameSetting gmst; ESM::GameSetting gmst;
gmst.mId = CSMWorld::DefaultGMSTs::OptionalInts[i]; gmst.mId = CSMWorld::DefaultGmsts::OptionalInts[i];
gmst.blank(); gmst.blank();
gmst.mValue.setType (ESM::VT_Int); gmst.mValue.setType (ESM::VT_Int);
addOptionalGmst (gmst); addOptionalGmst (gmst);
} }
for (size_t i=0; i < CSMWorld::DefaultGMSTs::OptionalStringCount; ++i) for (size_t i=0; i < CSMWorld::DefaultGmsts::OptionalStringCount; ++i)
{ {
ESM::GameSetting gmst; ESM::GameSetting gmst;
gmst.mId = CSMWorld::DefaultGMSTs::OptionalStrings[i]; gmst.mId = CSMWorld::DefaultGmsts::OptionalStrings[i];
gmst.blank(); gmst.blank();
gmst.mValue.setType (ESM::VT_String); gmst.mValue.setType (ESM::VT_String);
gmst.mValue.setString ("<no text>"); gmst.mValue.setString ("<no text>");

@ -1,17 +1,19 @@
#include "gmstcheck.hpp" #include "gmstcheck.hpp"
#include <sstream>
#include "../world/defaultgmsts.hpp" #include "../world/defaultgmsts.hpp"
CSMTools::GMSTCheckStage::GMSTCheckStage(const CSMWorld::IdCollection<ESM::GameSetting>& gameSettings) CSMTools::GmstCheckStage::GmstCheckStage(const CSMWorld::IdCollection<ESM::GameSetting>& gameSettings)
: mGameSettings(gameSettings) : mGameSettings(gameSettings)
{} {}
int CSMTools::GMSTCheckStage::setup() int CSMTools::GmstCheckStage::setup()
{ {
return mGameSettings.getSize(); 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); 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) // optimization - compare it to lists based on naming convention (f-float,i-int,s-string)
if (gmst.mId[0] == 'f') 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) 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]) if (gmst.mValue.getFloat() < CSMWorld::DefaultGmsts::FloatLimits[i*2])
messages.add(id, gmst.mId + " is less than the suggested range", "Change the value", messages.add(id, gmst.mId + " is less than the suggested range", "",
CSMDoc::Message::Severity_Warning); CSMDoc::Message::Severity_Warning);
if (gmst.mValue.getFloat() > CSMWorld::DefaultGMSTs::FloatLimits[i*2+1]) if (gmst.mValue.getFloat() > CSMWorld::DefaultGmsts::FloatLimits[i*2+1])
messages.add(id, gmst.mId + " is more than the suggested range", "Change the value", messages.add(id, gmst.mId + " is more than the suggested range", "",
CSMDoc::Message::Severity_Warning); CSMDoc::Message::Severity_Warning);
break; // for loop break; // for loop
@ -52,20 +59,25 @@ void CSMTools::GMSTCheckStage::perform(int stage, CSMDoc::Messages& messages)
} }
else if (gmst.mId[0] == 'i') 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) 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]) if (gmst.mValue.getInteger() < CSMWorld::DefaultGmsts::IntLimits[i*2])
messages.add(id, gmst.mId + " is less than the suggested range", "Change the value", messages.add(id, gmst.mId + " is less than the suggested range", "",
CSMDoc::Message::Severity_Warning); CSMDoc::Message::Severity_Warning);
if (gmst.mValue.getInteger() > CSMWorld::DefaultGMSTs::IntLimits[i*2+1]) if (gmst.mValue.getInteger() > CSMWorld::DefaultGmsts::IntLimits[i*2+1])
messages.add(id, gmst.mId + " is more than the suggested range", "Change the value", messages.add(id, gmst.mId + " is more than the suggested range", "",
CSMDoc::Message::Severity_Warning); CSMDoc::Message::Severity_Warning);
break; // for loop break; // for loop
@ -74,18 +86,38 @@ void CSMTools::GMSTCheckStage::perform(int stage, CSMDoc::Messages& messages)
} }
else if (gmst.mId[0] == 's') 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(); ESM::VarType type = gmst.mValue.getType();
if (type != ESM::VT_String && type != ESM::VT_None) 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 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";
}
}

@ -10,11 +10,11 @@
namespace CSMTools namespace CSMTools
{ {
/// \brief VerifyStage: make sure that GMSTs are alright /// \brief VerifyStage: make sure that GMSTs are alright
class GMSTCheckStage : public CSMDoc::Stage class GmstCheckStage : public CSMDoc::Stage
{ {
public: public:
GMSTCheckStage(const CSMWorld::IdCollection<ESM::GameSetting>& gameSettings); GmstCheckStage(const CSMWorld::IdCollection<ESM::GameSetting>& gameSettings);
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
@ -26,6 +26,8 @@ namespace CSMTools
const CSMWorld::IdCollection<ESM::GameSetting>& mGameSettings; const CSMWorld::IdCollection<ESM::GameSetting>& mGameSettings;
std::string varTypeToString(ESM::VarType);
}; };
} }

@ -112,7 +112,7 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier()
mData.getResources (CSMWorld::UniversalId::Type_Icons), mData.getResources (CSMWorld::UniversalId::Type_Icons),
mData.getResources (CSMWorld::UniversalId::Type_Textures))); mData.getResources (CSMWorld::UniversalId::Type_Textures)));
mVerifierOperation->appendStage (new GMSTCheckStage (mData.getGmsts())); mVerifierOperation->appendStage (new GmstCheckStage (mData.getGmsts()));
mVerifier.setOperation (mVerifierOperation); mVerifier.setOperation (mVerifierOperation);
} }

@ -8,7 +8,7 @@ const float FEps = std::numeric_limits<float>::epsilon();
const int IMax = std::numeric_limits<int>::max(); const int IMax = std::numeric_limits<int>::max();
const int IMin = std::numeric_limits<int>::min(); const int IMin = std::numeric_limits<int>::min();
const char* CSMWorld::DefaultGMSTs::Floats[CSMWorld::DefaultGMSTs::FloatCount] = const char* CSMWorld::DefaultGmsts::Floats[CSMWorld::DefaultGmsts::FloatCount] =
{ {
"fAIFleeFleeMult", "fAIFleeFleeMult",
"fAIFleeHealthMult", "fAIFleeHealthMult",
@ -270,7 +270,7 @@ const char* CSMWorld::DefaultGMSTs::Floats[CSMWorld::DefaultGMSTs::FloatCount] =
"fWortChanceValue" "fWortChanceValue"
}; };
const char * CSMWorld::DefaultGMSTs::Ints[CSMWorld::DefaultGMSTs::IntCount] = const char * CSMWorld::DefaultGmsts::Ints[CSMWorld::DefaultGmsts::IntCount] =
{ {
"i1stPersonSneakDelta", "i1stPersonSneakDelta",
"iAlarmAttack", "iAlarmAttack",
@ -363,7 +363,7 @@ const char * CSMWorld::DefaultGMSTs::Ints[CSMWorld::DefaultGMSTs::IntCount] =
"iWereWolfLevelToAttack" "iWereWolfLevelToAttack"
}; };
const char * CSMWorld::DefaultGMSTs::Strings[CSMWorld::DefaultGMSTs::StringCount] = const char * CSMWorld::DefaultGmsts::Strings[CSMWorld::DefaultGmsts::StringCount] =
{ {
"s3dAudio", "s3dAudio",
"s3dHardware", "s3dHardware",
@ -1541,7 +1541,7 @@ const char * CSMWorld::DefaultGMSTs::Strings[CSMWorld::DefaultGMSTs::StringCount
"sYourGold" "sYourGold"
}; };
const char * CSMWorld::DefaultGMSTs::OptionalFloats[CSMWorld::DefaultGMSTs::OptionalFloatCount] = const char * CSMWorld::DefaultGmsts::OptionalFloats[CSMWorld::DefaultGmsts::OptionalFloatCount] =
{ {
"fCombatDistanceWerewolfMod", "fCombatDistanceWerewolfMod",
"fFleeDistance", "fFleeDistance",
@ -1587,7 +1587,7 @@ const char * CSMWorld::DefaultGMSTs::OptionalFloats[CSMWorld::DefaultGMSTs::Opti
"fWereWolfWillPower" "fWereWolfWillPower"
}; };
const char * CSMWorld::DefaultGMSTs::OptionalInts[CSMWorld::DefaultGMSTs::OptionalIntCount] = const char * CSMWorld::DefaultGmsts::OptionalInts[CSMWorld::DefaultGmsts::OptionalIntCount] =
{ {
"iWereWolfBounty", "iWereWolfBounty",
"iWereWolfFightMod", "iWereWolfFightMod",
@ -1595,7 +1595,7 @@ const char * CSMWorld::DefaultGMSTs::OptionalInts[CSMWorld::DefaultGMSTs::Option
"iWereWolfLevelToAttack" "iWereWolfLevelToAttack"
}; };
const char * CSMWorld::DefaultGMSTs::OptionalStrings[CSMWorld::DefaultGMSTs::OptionalStringCount] = const char * CSMWorld::DefaultGmsts::OptionalStrings[CSMWorld::DefaultGmsts::OptionalStringCount] =
{ {
"sCompanionShare", "sCompanionShare",
"sCompanionWarningButtonOne", "sCompanionWarningButtonOne",
@ -1625,7 +1625,7 @@ const char * CSMWorld::DefaultGMSTs::OptionalStrings[CSMWorld::DefaultGMSTs::Opt
"sWerewolfRestMessage" "sWerewolfRestMessage"
}; };
const float CSMWorld::DefaultGMSTs::FloatsDefaultValues[CSMWorld::DefaultGMSTs::FloatCount] = const float CSMWorld::DefaultGmsts::FloatsDefaultValues[CSMWorld::DefaultGmsts::FloatCount] =
{ {
0.3, // fAIFleeFleeMult 0.3, // fAIFleeFleeMult
7.0, // fAIFleeHealthMult 7.0, // fAIFleeHealthMult
@ -1887,7 +1887,7 @@ const float CSMWorld::DefaultGMSTs::FloatsDefaultValues[CSMWorld::DefaultGMSTs::
15.0 // fWortChanceValue 15.0 // fWortChanceValue
}; };
const int CSMWorld::DefaultGMSTs::IntsDefaultValues[CSMWorld::DefaultGMSTs::IntCount] = const int CSMWorld::DefaultGmsts::IntsDefaultValues[CSMWorld::DefaultGmsts::IntCount] =
{ {
10, // i1stPersonSneakDelta 10, // i1stPersonSneakDelta
50, // iAlarmAttack 50, // iAlarmAttack
@ -1980,7 +1980,7 @@ const int CSMWorld::DefaultGMSTs::IntsDefaultValues[CSMWorld::DefaultGMSTs::IntC
20 // iWereWolfLevelToAttack 20 // iWereWolfLevelToAttack
}; };
const float CSMWorld::DefaultGMSTs::FloatLimits[CSMWorld::DefaultGMSTs::FloatCount * 2] = const float CSMWorld::DefaultGmsts::FloatLimits[CSMWorld::DefaultGmsts::FloatCount * 2] =
{ {
-FInf, FInf, // fAIFleeFleeMult -FInf, FInf, // fAIFleeFleeMult
-FInf, FInf, // fAIFleeHealthMult -FInf, FInf, // fAIFleeHealthMult
@ -2242,7 +2242,7 @@ const float CSMWorld::DefaultGMSTs::FloatLimits[CSMWorld::DefaultGMSTs::FloatCou
0, FInf // fWortChanceValue 0, FInf // fWortChanceValue
}; };
const int CSMWorld::DefaultGMSTs::IntLimits[CSMWorld::DefaultGMSTs::IntCount * 2] = const int CSMWorld::DefaultGmsts::IntLimits[CSMWorld::DefaultGmsts::IntCount * 2] =
{ {
IMin, IMax, // i1stPersonSneakDelta IMin, IMax, // i1stPersonSneakDelta
IMin, IMax, // iAlarmAttack IMin, IMax, // iAlarmAttack

@ -4,7 +4,7 @@
#include <cstddef> #include <cstddef>
namespace CSMWorld { namespace CSMWorld {
namespace DefaultGMSTs { namespace DefaultGmsts {
const size_t FloatCount = 258; const size_t FloatCount = 258;
const size_t IntCount = 89; const size_t IntCount = 89;

Loading…
Cancel
Save