From bbda5fe634aafc3104a47ee02d0f0bc236274cba Mon Sep 17 00:00:00 2001 From: Aesylwinn Date: Mon, 18 Jan 2016 12:34:33 -0500 Subject: [PATCH] Removed hints from error messages and fixed naming to match conventions --- apps/opencs/model/doc/document.cpp | 28 ++++----- apps/opencs/model/tools/gmstcheck.cpp | 78 +++++++++++++++++------- apps/opencs/model/tools/gmstcheck.hpp | 6 +- apps/opencs/model/tools/tools.cpp | 2 +- apps/opencs/model/world/defaultgmsts.cpp | 20 +++--- apps/opencs/model/world/defaultgmsts.hpp | 2 +- 6 files changed, 85 insertions(+), 51 deletions(-) diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index ea1fbb330..19891363f 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -14,28 +14,28 @@ 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; - gmst.mId = CSMWorld::DefaultGMSTs::Floats[i]; + gmst.mId = CSMWorld::DefaultGmsts::Floats[i]; gmst.mValue.setType (ESM::VT_Float); - gmst.mValue.setFloat (CSMWorld::DefaultGMSTs::FloatsDefaultValues[i]); + gmst.mValue.setFloat (CSMWorld::DefaultGmsts::FloatsDefaultValues[i]); 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; - gmst.mId = CSMWorld::DefaultGMSTs::Ints[i]; + gmst.mId = CSMWorld::DefaultGmsts::Ints[i]; gmst.mValue.setType (ESM::VT_Int); - gmst.mValue.setInteger (CSMWorld::DefaultGMSTs::IntsDefaultValues[i]); + gmst.mValue.setInteger (CSMWorld::DefaultGmsts::IntsDefaultValues[i]); 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; - gmst.mId = CSMWorld::DefaultGMSTs::Strings[i]; + gmst.mId = CSMWorld::DefaultGmsts::Strings[i]; gmst.mValue.setType (ESM::VT_String); gmst.mValue.setString (""); getData().getGmsts().add (gmst); @@ -44,28 +44,28 @@ void CSMDoc::Document::addGmsts() 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; - gmst.mId = CSMWorld::DefaultGMSTs::OptionalFloats[i]; + gmst.mId = CSMWorld::DefaultGmsts::OptionalFloats[i]; gmst.blank(); gmst.mValue.setType (ESM::VT_Float); 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; - gmst.mId = CSMWorld::DefaultGMSTs::OptionalInts[i]; + gmst.mId = CSMWorld::DefaultGmsts::OptionalInts[i]; gmst.blank(); gmst.mValue.setType (ESM::VT_Int); 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; - gmst.mId = CSMWorld::DefaultGMSTs::OptionalStrings[i]; + gmst.mId = CSMWorld::DefaultGmsts::OptionalStrings[i]; gmst.blank(); gmst.mValue.setType (ESM::VT_String); gmst.mValue.setString (""); diff --git a/apps/opencs/model/tools/gmstcheck.cpp b/apps/opencs/model/tools/gmstcheck.cpp index 6c17ff3a5..0c32c0056 100644 --- a/apps/opencs/model/tools/gmstcheck.cpp +++ b/apps/opencs/model/tools/gmstcheck.cpp @@ -1,17 +1,19 @@ #include "gmstcheck.hpp" +#include + #include "../world/defaultgmsts.hpp" -CSMTools::GMSTCheckStage::GMSTCheckStage(const CSMWorld::IdCollection& gameSettings) +CSMTools::GmstCheckStage::GmstCheckStage(const CSMWorld::IdCollection& 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& 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"; + } +} diff --git a/apps/opencs/model/tools/gmstcheck.hpp b/apps/opencs/model/tools/gmstcheck.hpp index ca1564d9e..0d4f7f204 100644 --- a/apps/opencs/model/tools/gmstcheck.hpp +++ b/apps/opencs/model/tools/gmstcheck.hpp @@ -10,11 +10,11 @@ namespace CSMTools { /// \brief VerifyStage: make sure that GMSTs are alright - class GMSTCheckStage : public CSMDoc::Stage + class GmstCheckStage : public CSMDoc::Stage { public: - GMSTCheckStage(const CSMWorld::IdCollection& gameSettings); + GmstCheckStage(const CSMWorld::IdCollection& gameSettings); virtual int setup(); ///< \return number of steps @@ -26,6 +26,8 @@ namespace CSMTools const CSMWorld::IdCollection& mGameSettings; + std::string varTypeToString(ESM::VarType); + }; } diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index 9f36193ef..e750092b9 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -112,7 +112,7 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier() mData.getResources (CSMWorld::UniversalId::Type_Icons), mData.getResources (CSMWorld::UniversalId::Type_Textures))); - mVerifierOperation->appendStage (new GMSTCheckStage (mData.getGmsts())); + mVerifierOperation->appendStage (new GmstCheckStage (mData.getGmsts())); mVerifier.setOperation (mVerifierOperation); } diff --git a/apps/opencs/model/world/defaultgmsts.cpp b/apps/opencs/model/world/defaultgmsts.cpp index ef3d536b1..f44e98411 100644 --- a/apps/opencs/model/world/defaultgmsts.cpp +++ b/apps/opencs/model/world/defaultgmsts.cpp @@ -8,7 +8,7 @@ const float FEps = std::numeric_limits::epsilon(); const int IMax = std::numeric_limits::max(); const int IMin = std::numeric_limits::min(); -const char* CSMWorld::DefaultGMSTs::Floats[CSMWorld::DefaultGMSTs::FloatCount] = +const char* CSMWorld::DefaultGmsts::Floats[CSMWorld::DefaultGmsts::FloatCount] = { "fAIFleeFleeMult", "fAIFleeHealthMult", @@ -270,7 +270,7 @@ const char* CSMWorld::DefaultGMSTs::Floats[CSMWorld::DefaultGMSTs::FloatCount] = "fWortChanceValue" }; -const char * CSMWorld::DefaultGMSTs::Ints[CSMWorld::DefaultGMSTs::IntCount] = +const char * CSMWorld::DefaultGmsts::Ints[CSMWorld::DefaultGmsts::IntCount] = { "i1stPersonSneakDelta", "iAlarmAttack", @@ -363,7 +363,7 @@ const char * CSMWorld::DefaultGMSTs::Ints[CSMWorld::DefaultGMSTs::IntCount] = "iWereWolfLevelToAttack" }; -const char * CSMWorld::DefaultGMSTs::Strings[CSMWorld::DefaultGMSTs::StringCount] = +const char * CSMWorld::DefaultGmsts::Strings[CSMWorld::DefaultGmsts::StringCount] = { "s3dAudio", "s3dHardware", @@ -1541,7 +1541,7 @@ const char * CSMWorld::DefaultGMSTs::Strings[CSMWorld::DefaultGMSTs::StringCount "sYourGold" }; -const char * CSMWorld::DefaultGMSTs::OptionalFloats[CSMWorld::DefaultGMSTs::OptionalFloatCount] = +const char * CSMWorld::DefaultGmsts::OptionalFloats[CSMWorld::DefaultGmsts::OptionalFloatCount] = { "fCombatDistanceWerewolfMod", "fFleeDistance", @@ -1587,7 +1587,7 @@ const char * CSMWorld::DefaultGMSTs::OptionalFloats[CSMWorld::DefaultGMSTs::Opti "fWereWolfWillPower" }; -const char * CSMWorld::DefaultGMSTs::OptionalInts[CSMWorld::DefaultGMSTs::OptionalIntCount] = +const char * CSMWorld::DefaultGmsts::OptionalInts[CSMWorld::DefaultGmsts::OptionalIntCount] = { "iWereWolfBounty", "iWereWolfFightMod", @@ -1595,7 +1595,7 @@ const char * CSMWorld::DefaultGMSTs::OptionalInts[CSMWorld::DefaultGMSTs::Option "iWereWolfLevelToAttack" }; -const char * CSMWorld::DefaultGMSTs::OptionalStrings[CSMWorld::DefaultGMSTs::OptionalStringCount] = +const char * CSMWorld::DefaultGmsts::OptionalStrings[CSMWorld::DefaultGmsts::OptionalStringCount] = { "sCompanionShare", "sCompanionWarningButtonOne", @@ -1625,7 +1625,7 @@ const char * CSMWorld::DefaultGMSTs::OptionalStrings[CSMWorld::DefaultGMSTs::Opt "sWerewolfRestMessage" }; -const float CSMWorld::DefaultGMSTs::FloatsDefaultValues[CSMWorld::DefaultGMSTs::FloatCount] = +const float CSMWorld::DefaultGmsts::FloatsDefaultValues[CSMWorld::DefaultGmsts::FloatCount] = { 0.3, // fAIFleeFleeMult 7.0, // fAIFleeHealthMult @@ -1887,7 +1887,7 @@ const float CSMWorld::DefaultGMSTs::FloatsDefaultValues[CSMWorld::DefaultGMSTs:: 15.0 // fWortChanceValue }; -const int CSMWorld::DefaultGMSTs::IntsDefaultValues[CSMWorld::DefaultGMSTs::IntCount] = +const int CSMWorld::DefaultGmsts::IntsDefaultValues[CSMWorld::DefaultGmsts::IntCount] = { 10, // i1stPersonSneakDelta 50, // iAlarmAttack @@ -1980,7 +1980,7 @@ const int CSMWorld::DefaultGMSTs::IntsDefaultValues[CSMWorld::DefaultGMSTs::IntC 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, // fAIFleeHealthMult @@ -2242,7 +2242,7 @@ const float CSMWorld::DefaultGMSTs::FloatLimits[CSMWorld::DefaultGMSTs::FloatCou 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, // iAlarmAttack diff --git a/apps/opencs/model/world/defaultgmsts.hpp b/apps/opencs/model/world/defaultgmsts.hpp index ba65be805..a2888ed6a 100644 --- a/apps/opencs/model/world/defaultgmsts.hpp +++ b/apps/opencs/model/world/defaultgmsts.hpp @@ -4,7 +4,7 @@ #include namespace CSMWorld { - namespace DefaultGMSTs { + namespace DefaultGmsts { const size_t FloatCount = 258; const size_t IntCount = 89;