1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-23 06:41:08 +00:00

changed message passing format from QString to a UniversalId/std::string pair

This commit is contained in:
Marc Zinnschlag 2014-05-08 12:42:29 +02:00
parent 0e7d40de6a
commit 205306ee3d
34 changed files with 316 additions and 497 deletions

View File

@ -6,11 +6,14 @@
#include <QApplication> #include <QApplication>
#include <QIcon> #include <QIcon>
#include <QMetaType>
#include <extern/shiny/Main/Factory.hpp> #include <extern/shiny/Main/Factory.hpp>
#include <components/ogreinit/ogreinit.hpp> #include <components/ogreinit/ogreinit.hpp>
#include "model/world/universalid.hpp"
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
#include <QDir> #include <QDir>
#endif #endif
@ -42,6 +45,8 @@ int main(int argc, char *argv[])
{ {
Q_INIT_RESOURCE (resources); Q_INIT_RESOURCE (resources);
qRegisterMetaType<CSMWorld::UniversalId> ("CSMWorld::UniversalId");
OgreInit::OgreInit ogreInit; OgreInit::OgreInit ogreInit;
std::auto_ptr<sh::Factory> shinyFactory; std::auto_ptr<sh::Factory> shinyFactory;

View File

@ -2288,8 +2288,9 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration, co
connect (&mSaving, SIGNAL (progress (int, int, int)), this, SLOT (progress (int, int, int))); connect (&mSaving, SIGNAL (progress (int, int, int)), this, SLOT (progress (int, int, int)));
connect (&mSaving, SIGNAL (done (int)), this, SLOT (operationDone (int))); connect (&mSaving, SIGNAL (done (int)), this, SLOT (operationDone (int)));
connect (&mSaving, SIGNAL (reportMessage (const QString&, int)), connect (
this, SLOT (reportMessage (const QString&, int))); &mSaving, SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, int)),
this, SLOT (reportMessage (const CSMWorld::UniversalId&, const std::string&, int)));
} }
CSMDoc::Document::~Document() CSMDoc::Document::~Document()
@ -2358,10 +2359,11 @@ void CSMDoc::Document::modificationStateChanged (bool clean)
emit stateChanged (getState(), this); emit stateChanged (getState(), this);
} }
void CSMDoc::Document::reportMessage (const QString& message, int type) void CSMDoc::Document::reportMessage (const CSMWorld::UniversalId& id, const std::string& message,
int type)
{ {
/// \todo find a better way to get these messages to the user. /// \todo find a better way to get these messages to the user.
std::cout << message.toUtf8().constData() << std::endl; std::cout << message << std::endl;
} }
void CSMDoc::Document::operationDone (int type) void CSMDoc::Document::operationDone (int type)

View File

@ -111,7 +111,8 @@ namespace CSMDoc
void modificationStateChanged (bool clean); void modificationStateChanged (bool clean);
void reportMessage (const QString& message, int type); void reportMessage (const CSMWorld::UniversalId& id, const std::string& message,
int type);
void operationDone (int type); void operationDone (int type);

View File

@ -6,6 +6,8 @@
#include <QTimer> #include <QTimer>
#include "../world/universalid.hpp"
#include "state.hpp" #include "state.hpp"
#include "stage.hpp" #include "stage.hpp"
@ -80,7 +82,7 @@ void CSMDoc::Operation::abort()
void CSMDoc::Operation::executeStage() void CSMDoc::Operation::executeStage()
{ {
std::vector<std::string> messages; Stage::Messages messages;
while (mCurrentStage!=mStages.end()) while (mCurrentStage!=mStages.end())
{ {
@ -97,7 +99,7 @@ void CSMDoc::Operation::executeStage()
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
emit reportMessage (e.what(), mType); emit reportMessage (CSMWorld::UniversalId(), e.what(), mType);
abort(); abort();
} }
@ -108,8 +110,8 @@ void CSMDoc::Operation::executeStage()
emit progress (mCurrentStepTotal, mTotalSteps ? mTotalSteps : 1, mType); emit progress (mCurrentStepTotal, mTotalSteps ? mTotalSteps : 1, mType);
for (std::vector<std::string>::const_iterator iter (messages.begin()); iter!=messages.end(); ++iter) for (Stage::Messages::const_iterator iter (messages.begin()); iter!=messages.end(); ++iter)
emit reportMessage (iter->c_str(), mType); emit reportMessage (iter->first, iter->second, mType);
if (mCurrentStage==mStages.end()) if (mCurrentStage==mStages.end())
exit(); exit();

View File

@ -5,6 +5,11 @@
#include <QThread> #include <QThread>
namespace CSMWorld
{
class UniversalId;
}
namespace CSMDoc namespace CSMDoc
{ {
class Stage; class Stage;
@ -46,7 +51,8 @@ namespace CSMDoc
void progress (int current, int max, int type); void progress (int current, int max, int type);
void reportMessage (const QString& message, int type); void reportMessage (const CSMWorld::UniversalId& id, const std::string& message,
int type);
void done (int type); void done (int type);

View File

@ -23,7 +23,7 @@ int CSMDoc::OpenSaveStage::setup()
return 1; return 1;
} }
void CSMDoc::OpenSaveStage::perform (int stage, std::vector<std::string>& messages) void CSMDoc::OpenSaveStage::perform (int stage, Messages& messages)
{ {
mState.start (mDocument, mProjectFile); mState.start (mDocument, mProjectFile);
@ -43,7 +43,7 @@ int CSMDoc::WriteHeaderStage::setup()
return 1; return 1;
} }
void CSMDoc::WriteHeaderStage::perform (int stage, std::vector<std::string>& messages) void CSMDoc::WriteHeaderStage::perform (int stage, Messages& messages)
{ {
mState.getWriter().setVersion(); mState.getWriter().setVersion();
@ -96,7 +96,7 @@ int CSMDoc::WriteDialogueCollectionStage::setup()
return mTopics.getSize(); return mTopics.getSize();
} }
void CSMDoc::WriteDialogueCollectionStage::perform (int stage, std::vector<std::string>& messages) void CSMDoc::WriteDialogueCollectionStage::perform (int stage, Messages& messages)
{ {
const CSMWorld::Record<ESM::Dialogue>& topic = mTopics.getRecord (stage); const CSMWorld::Record<ESM::Dialogue>& topic = mTopics.getRecord (stage);
@ -191,7 +191,7 @@ int CSMDoc::WriteRefIdCollectionStage::setup()
return mDocument.getData().getReferenceables().getSize(); return mDocument.getData().getReferenceables().getSize();
} }
void CSMDoc::WriteRefIdCollectionStage::perform (int stage, std::vector<std::string>& messages) void CSMDoc::WriteRefIdCollectionStage::perform (int stage, Messages& messages)
{ {
mDocument.getData().getReferenceables().save (stage, mState.getWriter()); mDocument.getData().getReferenceables().save (stage, mState.getWriter());
} }
@ -204,7 +204,7 @@ CSMDoc::WriteFilterStage::WriteFilterStage (Document& document, SavingState& sta
mDocument (document), mScope (scope) mDocument (document), mScope (scope)
{} {}
void CSMDoc::WriteFilterStage::perform (int stage, std::vector<std::string>& messages) void CSMDoc::WriteFilterStage::perform (int stage, Messages& messages)
{ {
const CSMWorld::Record<CSMFilter::Filter>& record = const CSMWorld::Record<CSMFilter::Filter>& record =
mDocument.getData().getFilters().getRecord (stage); mDocument.getData().getFilters().getRecord (stage);
@ -223,7 +223,7 @@ int CSMDoc::CloseSaveStage::setup()
return 1; return 1;
} }
void CSMDoc::CloseSaveStage::perform (int stage, std::vector<std::string>& messages) void CSMDoc::CloseSaveStage::perform (int stage, Messages& messages)
{ {
mState.getStream().close(); mState.getStream().close();
@ -241,7 +241,7 @@ int CSMDoc::FinalSavingStage::setup()
return 1; return 1;
} }
void CSMDoc::FinalSavingStage::perform (int stage, std::vector<std::string>& messages) void CSMDoc::FinalSavingStage::perform (int stage, Messages& messages)
{ {
if (mState.hasError()) if (mState.hasError())
{ {

View File

@ -39,7 +39,7 @@ namespace CSMDoc
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this stage will be appended to \a messages. ///< Messages resulting from this stage will be appended to \a messages.
}; };
@ -57,7 +57,7 @@ namespace CSMDoc
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this stage will be appended to \a messages. ///< Messages resulting from this stage will be appended to \a messages.
}; };
@ -75,7 +75,7 @@ namespace CSMDoc
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this stage will be appended to \a messages. ///< Messages resulting from this stage will be appended to \a messages.
}; };
@ -92,7 +92,7 @@ namespace CSMDoc
} }
template<class CollectionT> template<class CollectionT>
void WriteCollectionStage<CollectionT>::perform (int stage, std::vector<std::string>& messages) void WriteCollectionStage<CollectionT>::perform (int stage, Messages& messages)
{ {
CSMWorld::RecordBase::State state = mCollection.getRecord (stage).mState; CSMWorld::RecordBase::State state = mCollection.getRecord (stage).mState;
@ -130,7 +130,7 @@ namespace CSMDoc
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this stage will be appended to \a messages. ///< Messages resulting from this stage will be appended to \a messages.
}; };
@ -147,7 +147,7 @@ namespace CSMDoc
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this stage will be appended to \a messages. ///< Messages resulting from this stage will be appended to \a messages.
}; };
@ -161,7 +161,7 @@ namespace CSMDoc
WriteFilterStage (Document& document, SavingState& state, CSMFilter::Filter::Scope scope); WriteFilterStage (Document& document, SavingState& state, CSMFilter::Filter::Scope scope);
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this stage will be appended to \a messages. ///< Messages resulting from this stage will be appended to \a messages.
}; };
@ -177,7 +177,7 @@ namespace CSMDoc
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this stage will be appended to \a messages. ///< Messages resulting from this stage will be appended to \a messages.
}; };
@ -193,7 +193,7 @@ namespace CSMDoc
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this stage will be appended to \a messages. ///< Messages resulting from this stage will be appended to \a messages.
}; };
} }

View File

@ -4,18 +4,22 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include "../world/universalid.hpp"
namespace CSMDoc namespace CSMDoc
{ {
class Stage class Stage
{ {
public: public:
typedef std::vector<std::pair<CSMWorld::UniversalId, std::string> > Messages;
virtual ~Stage(); virtual ~Stage();
virtual int setup() = 0; virtual int setup() = 0;
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages) = 0; virtual void perform (int stage, Messages& messages) = 0;
///< Messages resulting from this stage will be appended to \a messages. ///< Messages resulting from this stage will be appended to \a messages.
}; };
} }

View File

@ -17,7 +17,7 @@ int CSMTools::BirthsignCheckStage::setup()
return mBirthsigns.getSize(); return mBirthsigns.getSize();
} }
void CSMTools::BirthsignCheckStage::perform (int stage, std::vector<std::string>& messages) void CSMTools::BirthsignCheckStage::perform (int stage, Messages& messages)
{ {
const CSMWorld::Record<ESM::BirthSign>& record = mBirthsigns.getRecord (stage); const CSMWorld::Record<ESM::BirthSign>& record = mBirthsigns.getRecord (stage);
@ -30,13 +30,13 @@ void CSMTools::BirthsignCheckStage::perform (int stage, std::vector<std::string>
// test for empty name, description and texture // test for empty name, description and texture
if (birthsign.mName.empty()) if (birthsign.mName.empty())
messages.push_back (id.toString() + "|" + birthsign.mId + " has an empty name"); messages.push_back (std::make_pair (id, birthsign.mId + " has an empty name"));
if (birthsign.mDescription.empty()) if (birthsign.mDescription.empty())
messages.push_back (id.toString() + "|" + birthsign.mId + " has an empty description"); messages.push_back (std::make_pair (id, birthsign.mId + " has an empty description"));
if (birthsign.mTexture.empty()) if (birthsign.mTexture.empty())
messages.push_back (id.toString() + "|" + birthsign.mId + " is missing a texture"); messages.push_back (std::make_pair (id, birthsign.mId + " is missing a texture"));
/// \todo test if the texture exists /// \todo test if the texture exists

View File

@ -21,7 +21,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View File

@ -18,7 +18,7 @@ int CSMTools::ClassCheckStage::setup()
return mClasses.getSize(); return mClasses.getSize();
} }
void CSMTools::ClassCheckStage::perform (int stage, std::vector<std::string>& messages) void CSMTools::ClassCheckStage::perform (int stage, Messages& messages)
{ {
const CSMWorld::Record<ESM::Class>& record = mClasses.getRecord (stage); const CSMWorld::Record<ESM::Class>& record = mClasses.getRecord (stage);
@ -31,10 +31,10 @@ void CSMTools::ClassCheckStage::perform (int stage, std::vector<std::string>& me
// test for empty name and description // test for empty name and description
if (class_.mName.empty()) if (class_.mName.empty())
messages.push_back (id.toString() + "|" + class_.mId + " has an empty name"); messages.push_back (std::make_pair (id, class_.mId + " has an empty name"));
if (class_.mDescription.empty()) if (class_.mDescription.empty())
messages.push_back (id.toString() + "|" + class_.mId + " has an empty description"); messages.push_back (std::make_pair (id, class_.mId + " has an empty description"));
// test for invalid attributes // test for invalid attributes
for (int i=0; i<2; ++i) for (int i=0; i<2; ++i)
@ -42,18 +42,14 @@ void CSMTools::ClassCheckStage::perform (int stage, std::vector<std::string>& me
{ {
std::ostringstream stream; std::ostringstream stream;
stream << id.toString() << "|Attribute #" << i << " of " << class_.mId << " is not set"; stream << "Attribute #" << i << " of " << class_.mId << " is not set";
messages.push_back (stream.str()); messages.push_back (std::make_pair (id, stream.str()));
} }
if (class_.mData.mAttribute[0]==class_.mData.mAttribute[1] && class_.mData.mAttribute[0]!=-1) if (class_.mData.mAttribute[0]==class_.mData.mAttribute[1] && class_.mData.mAttribute[0]!=-1)
{ {
std::ostringstream stream; messages.push_back (std::make_pair (id, "Class lists same attribute twice"));
stream << id.toString() << "|Class lists same attribute twice";
messages.push_back (stream.str());
} }
// test for non-unique skill // test for non-unique skill
@ -66,12 +62,7 @@ void CSMTools::ClassCheckStage::perform (int stage, std::vector<std::string>& me
for (std::map<int, int>::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter) for (std::map<int, int>::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter)
if (iter->second>1) if (iter->second>1)
{ {
std::ostringstream stream; messages.push_back (std::make_pair (id,
ESM::Skill::indexToId (iter->first) + " is listed more than once"));
stream
<< id.toString() << "|"
<< ESM::Skill::indexToId (iter->first) << " is listed more than once";
messages.push_back (stream.str());
} }
} }

View File

@ -21,7 +21,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View File

@ -18,7 +18,7 @@ int CSMTools::FactionCheckStage::setup()
return mFactions.getSize(); return mFactions.getSize();
} }
void CSMTools::FactionCheckStage::perform (int stage, std::vector<std::string>& messages) void CSMTools::FactionCheckStage::perform (int stage, Messages& messages)
{ {
const CSMWorld::Record<ESM::Faction>& record = mFactions.getRecord (stage); const CSMWorld::Record<ESM::Faction>& record = mFactions.getRecord (stage);
@ -31,16 +31,12 @@ void CSMTools::FactionCheckStage::perform (int stage, std::vector<std::string>&
// test for empty name // test for empty name
if (faction.mName.empty()) if (faction.mName.empty())
messages.push_back (id.toString() + "|" + faction.mId + " has an empty name"); messages.push_back (std::make_pair (id, faction.mId + " has an empty name"));
// test for invalid attributes // test for invalid attributes
if (faction.mData.mAttribute[0]==faction.mData.mAttribute[1] && faction.mData.mAttribute[0]!=-1) if (faction.mData.mAttribute[0]==faction.mData.mAttribute[1] && faction.mData.mAttribute[0]!=-1)
{ {
std::ostringstream stream; messages.push_back (std::make_pair (id , "Faction lists same attribute twice"));
stream << id.toString() << "|Faction lists same attribute twice";
messages.push_back (stream.str());
} }
// test for non-unique skill // test for non-unique skill
@ -53,13 +49,8 @@ void CSMTools::FactionCheckStage::perform (int stage, std::vector<std::string>&
for (std::map<int, int>::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter) for (std::map<int, int>::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter)
if (iter->second>1) if (iter->second>1)
{ {
std::ostringstream stream; messages.push_back (std::make_pair (id,
ESM::Skill::indexToId (iter->first) + " is listed more than once"));
stream
<< id.toString() << "|"
<< ESM::Skill::indexToId (iter->first) << " is listed more than once";
messages.push_back (stream.str());
} }
/// \todo check data members that can't be edited in the table view /// \todo check data members that can't be edited in the table view

View File

@ -21,7 +21,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View File

@ -15,9 +15,10 @@ int CSMTools::MandatoryIdStage::setup()
return mIds.size(); return mIds.size();
} }
void CSMTools::MandatoryIdStage::perform (int stage, std::vector<std::string>& messages) void CSMTools::MandatoryIdStage::perform (int stage, Messages& messages)
{ {
if (mIdCollection.searchId (mIds.at (stage))==-1 || if (mIdCollection.searchId (mIds.at (stage))==-1 ||
mIdCollection.getRecord (mIds.at (stage)).isDeleted()) mIdCollection.getRecord (mIds.at (stage)).isDeleted())
messages.push_back (mCollectionId.toString() + "|Missing mandatory record: " + mIds.at (stage)); messages.push_back (std::make_pair (mCollectionId,
"|Missing mandatory record: " + mIds.at (stage)));
} }

View File

@ -30,7 +30,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View File

@ -7,7 +7,7 @@
#include "../world/universalid.hpp" #include "../world/universalid.hpp"
void CSMTools::RaceCheckStage::performPerRecord (int stage, std::vector<std::string>& messages) void CSMTools::RaceCheckStage::performPerRecord (int stage, Messages& messages)
{ {
const CSMWorld::Record<ESM::Race>& record = mRaces.getRecord (stage); const CSMWorld::Record<ESM::Race>& record = mRaces.getRecord (stage);
@ -20,24 +20,24 @@ void CSMTools::RaceCheckStage::performPerRecord (int stage, std::vector<std::str
// test for empty name and description // test for empty name and description
if (race.mName.empty()) if (race.mName.empty())
messages.push_back (id.toString() + "|" + race.mId + " has an empty name"); messages.push_back (std::make_pair (id, race.mId + " has an empty name"));
if (race.mDescription.empty()) if (race.mDescription.empty())
messages.push_back (id.toString() + "|" + race.mId + " has an empty description"); messages.push_back (std::make_pair (id, race.mId + " has an empty description"));
// test for positive height // test for positive height
if (race.mData.mHeight.mMale<=0) if (race.mData.mHeight.mMale<=0)
messages.push_back (id.toString() + "|male " + race.mId + " has non-positive height"); messages.push_back (std::make_pair (id, "male " + race.mId + " has non-positive height"));
if (race.mData.mHeight.mFemale<=0) if (race.mData.mHeight.mFemale<=0)
messages.push_back (id.toString() + "|female " + race.mId + " has non-positive height"); messages.push_back (std::make_pair (id, "female " + race.mId + " has non-positive height"));
// test for non-negative weight // test for non-negative weight
if (race.mData.mWeight.mMale<0) if (race.mData.mWeight.mMale<0)
messages.push_back (id.toString() + "|male " + race.mId + " has negative weight"); messages.push_back (std::make_pair (id, "male " + race.mId + " has negative weight"));
if (race.mData.mWeight.mFemale<0) if (race.mData.mWeight.mFemale<0)
messages.push_back (id.toString() + "|female " + race.mId + " has negative weight"); messages.push_back (std::make_pair (id, "female " + race.mId + " has negative weight"));
// remember playable flag // remember playable flag
if (race.mData.mFlags & 0x1) if (race.mData.mFlags & 0x1)
@ -46,12 +46,12 @@ void CSMTools::RaceCheckStage::performPerRecord (int stage, std::vector<std::str
/// \todo check data members that can't be edited in the table view /// \todo check data members that can't be edited in the table view
} }
void CSMTools::RaceCheckStage::performFinal (std::vector<std::string>& messages) void CSMTools::RaceCheckStage::performFinal (Messages& messages)
{ {
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Races); CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Races);
if (!mPlayable) if (!mPlayable)
messages.push_back (id.toString() + "|No playable race"); messages.push_back (std::make_pair (id, "No playable race"));
} }
CSMTools::RaceCheckStage::RaceCheckStage (const CSMWorld::IdCollection<ESM::Race>& races) CSMTools::RaceCheckStage::RaceCheckStage (const CSMWorld::IdCollection<ESM::Race>& races)
@ -64,7 +64,7 @@ int CSMTools::RaceCheckStage::setup()
return mRaces.getSize()+1; return mRaces.getSize()+1;
} }
void CSMTools::RaceCheckStage::perform (int stage, std::vector<std::string>& messages) void CSMTools::RaceCheckStage::perform (int stage, Messages& messages)
{ {
if (stage==mRaces.getSize()) if (stage==mRaces.getSize())
performFinal (messages); performFinal (messages);

View File

@ -15,9 +15,9 @@ namespace CSMTools
const CSMWorld::IdCollection<ESM::Race>& mRaces; const CSMWorld::IdCollection<ESM::Race>& mRaces;
bool mPlayable; bool mPlayable;
void performPerRecord (int stage, std::vector<std::string>& messages); void performPerRecord (int stage, Messages& messages);
void performFinal (std::vector<std::string>& messages); void performFinal (Messages& messages);
public: public:
@ -26,7 +26,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View File

@ -1,7 +1,9 @@
#include "referenceablecheck.hpp" #include "referenceablecheck.hpp"
#include <components/misc/stringops.hpp>
#include "../world/record.hpp" #include "../world/record.hpp"
#include "../world/universalid.hpp" #include "../world/universalid.hpp"
#include <components/misc/stringops.hpp>
CSMTools::ReferenceableCheckStage::ReferenceableCheckStage( CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(
const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection<ESM::Race >& races, const CSMWorld::RefIdData& referenceable, const CSMWorld::IdCollection<ESM::Race >& races,
@ -16,7 +18,7 @@ CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(
{ {
} }
void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages) void CSMTools::ReferenceableCheckStage::perform (int stage, Messages& messages)
{ {
//Checks for books, than, when stage is above mBooksSize goes to other checks, with (stage - PrevSum) as stage. //Checks for books, than, when stage is above mBooksSize goes to other checks, with (stage - PrevSum) as stage.
const int bookSize(mReferencables.getBooks().getSize()); const int bookSize(mReferencables.getBooks().getSize());
@ -230,7 +232,7 @@ int CSMTools::ReferenceableCheckStage::setup()
void CSMTools::ReferenceableCheckStage::bookCheck( void CSMTools::ReferenceableCheckStage::bookCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Book >& records, const CSMWorld::RefIdDataContainer< ESM::Book >& records,
std::vector< std::string >& messages) Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -248,7 +250,7 @@ void CSMTools::ReferenceableCheckStage::bookCheck(
void CSMTools::ReferenceableCheckStage::activatorCheck( void CSMTools::ReferenceableCheckStage::activatorCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Activator >& records, const CSMWorld::RefIdDataContainer< ESM::Activator >& records,
std::vector< std::string >& messages) Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -262,15 +264,13 @@ void CSMTools::ReferenceableCheckStage::activatorCheck(
//Checking for model, IIRC all activators should have a model //Checking for model, IIRC all activators should have a model
if (activator.mModel.empty()) if (activator.mModel.empty())
{ messages.push_back (std::make_pair (id, activator.mId + " has no model"));
messages.push_back(id.toString() + "|" + activator.mId + " has no model");
}
} }
void CSMTools::ReferenceableCheckStage::potionCheck( void CSMTools::ReferenceableCheckStage::potionCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Potion >& records, const CSMWorld::RefIdDataContainer< ESM::Potion >& records,
std::vector< std::string >& messages) Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -290,7 +290,7 @@ void CSMTools::ReferenceableCheckStage::potionCheck(
void CSMTools::ReferenceableCheckStage::apparatusCheck( void CSMTools::ReferenceableCheckStage::apparatusCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Apparatus >& records, const CSMWorld::RefIdDataContainer< ESM::Apparatus >& records,
std::vector< std::string >& messages) Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -310,7 +310,7 @@ void CSMTools::ReferenceableCheckStage::apparatusCheck(
void CSMTools::ReferenceableCheckStage::armorCheck( void CSMTools::ReferenceableCheckStage::armorCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Armor >& records, const CSMWorld::RefIdDataContainer< ESM::Armor >& records,
std::vector< std::string >& messages) Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -326,21 +326,17 @@ void CSMTools::ReferenceableCheckStage::armorCheck(
//checking for armor class, armor should have poistive armor class, but 0 is considered legal //checking for armor class, armor should have poistive armor class, but 0 is considered legal
if (armor.mData.mArmor < 0) if (armor.mData.mArmor < 0)
{ messages.push_back (std::make_pair (id, armor.mId + " has negative armor class"));
messages.push_back(id.toString() + "|" + armor.mId + " has negative armor class");
}
//checking for health. Only positive numbers are allowed, or 0 is illegal //checking for health. Only positive numbers are allowed, or 0 is illegal
if (armor.mData.mHealth <= 0) if (armor.mData.mHealth <= 0)
{ messages.push_back (std::make_pair (id, armor.mId + " has non positive health"));
messages.push_back(id.toString() + "|" + armor.mId + " has non positive health");
}
} }
void CSMTools::ReferenceableCheckStage::clothingCheck( void CSMTools::ReferenceableCheckStage::clothingCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Clothing >& records, const CSMWorld::RefIdDataContainer< ESM::Clothing >& records,
std::vector< std::string >& messages) Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -357,7 +353,7 @@ void CSMTools::ReferenceableCheckStage::clothingCheck(
void CSMTools::ReferenceableCheckStage::containerCheck( void CSMTools::ReferenceableCheckStage::containerCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Container >& records, const CSMWorld::RefIdDataContainer< ESM::Container >& records,
std::vector< std::string >& messages) Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -371,153 +367,109 @@ void CSMTools::ReferenceableCheckStage::containerCheck(
//Checking for model, IIRC all containers should have a model //Checking for model, IIRC all containers should have a model
if (container.mModel.empty()) if (container.mModel.empty())
{ messages.push_back (std::make_pair (id, container.mId + " has no model"));
messages.push_back(id.toString() + "|" + container.mId + " has no model");
}
//Checking for capacity (weight) //Checking for capacity (weight)
if (container.mWeight < 0) //0 is allowed if (container.mWeight < 0) //0 is allowed
{ messages.push_back (std::make_pair (id,
messages.push_back(id.toString() + "|" + container.mId + " has negative weight (capacity)"); container.mId + " has negative weight (capacity)"));
}
//checking for name //checking for name
if (container.mName.empty()) if (container.mName.empty())
{ messages.push_back (std::make_pair (id, container.mId + " has an empty name"));
messages.push_back(id.toString() + "|" + container.mId + " has an empty name");
}
} }
void CSMTools::ReferenceableCheckStage::creatureCheck( void CSMTools::ReferenceableCheckStage::creatureCheck (
int stage, int stage, const CSMWorld::RefIdDataContainer< ESM::Creature >& records,
const CSMWorld::RefIdDataContainer< ESM::Creature >& records, Messages& messages)
std::vector< std::string >& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
if (baseRecord.isDeleted()) if (baseRecord.isDeleted())
{
return; return;
}
const ESM::Creature& creature = (dynamic_cast<const CSMWorld::Record<ESM::Creature>&>(baseRecord)).get(); const ESM::Creature& creature = (dynamic_cast<const CSMWorld::Record<ESM::Creature>&>(baseRecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Creature, creature.mId); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Creature, creature.mId);
if (creature.mModel.empty()) if (creature.mModel.empty())
{ messages.push_back (std::make_pair (id, creature.mId + " has no model"));
messages.push_back(id.toString() + "|" + creature.mId + " has no model");
}
if (creature.mName.empty()) if (creature.mName.empty())
{ messages.push_back (std::make_pair (id, creature.mId + " has an empty name"));
messages.push_back(id.toString() + "|" + creature.mId + " has an empty name");
}
//stats checks //stats checks
if (creature.mData.mLevel < 1) if (creature.mData.mLevel < 1)
{ messages.push_back (std::make_pair (id, creature.mId + " has non-postive level"));
messages.push_back(id.toString() + "|" + creature.mId + " has non-postive level");
}
if (creature.mData.mStrength < 0) if (creature.mData.mStrength < 0)
{ messages.push_back (std::make_pair (id, creature.mId + " has negative strength"));
messages.push_back(id.toString() + "|" + creature.mId + " has negative strength");
}
if (creature.mData.mIntelligence < 0) if (creature.mData.mIntelligence < 0)
{ messages.push_back (std::make_pair (id, creature.mId + " has negative intelligence"));
messages.push_back(id.toString() + "|" + creature.mId + " has negative intelligence");
}
if (creature.mData.mWillpower < 0) if (creature.mData.mWillpower < 0)
{ messages.push_back (std::make_pair (id, creature.mId + " has negative willpower"));
messages.push_back(id.toString() + "|" + creature.mId + " has negative willpower");
}
if (creature.mData.mAgility < 0) if (creature.mData.mAgility < 0)
{ messages.push_back (std::make_pair (id, creature.mId + " has negative agility"));
messages.push_back(id.toString() + "|" + creature.mId + " has negative agility");
}
if (creature.mData.mSpeed < 0) if (creature.mData.mSpeed < 0)
{ messages.push_back (std::make_pair (id, creature.mId + " has negative speed"));
messages.push_back(id.toString() + "|" + creature.mId + " has negative speed");
}
if (creature.mData.mEndurance < 0) if (creature.mData.mEndurance < 0)
{ messages.push_back (std::make_pair (id, creature.mId + " has negative endurance"));
messages.push_back(id.toString() + "|" + creature.mId + " has negative endurance");
}
if (creature.mData.mPersonality < 0) if (creature.mData.mPersonality < 0)
{ messages.push_back (std::make_pair (id, creature.mId + " has negative personality"));
messages.push_back(id.toString() + "|" + creature.mId + " has negative personality");
}
if (creature.mData.mLuck < 0) if (creature.mData.mLuck < 0)
{ messages.push_back (std::make_pair (id, creature.mId + " has negative luck"));
messages.push_back(id.toString() + "|" + creature.mId + " has negative luck");
}
if (creature.mData.mHealth < 0) if (creature.mData.mHealth < 0)
{ messages.push_back (std::make_pair (id, creature.mId + " has negative health"));
messages.push_back(id.toString() + "|" + creature.mId + " has negative health");
}
if (creature.mData.mSoul < 0) if (creature.mData.mSoul < 0)
{ messages.push_back (std::make_pair (id, creature.mId + " has negative soul value"));
messages.push_back(id.toString() + "|" + creature.mId + " has negative soul value");
}
for (int i = 0; i < 6; ++i) for (int i = 0; i < 6; ++i)
{ {
if (creature.mData.mAttack[i] < 0) if (creature.mData.mAttack[i] < 0)
{ {
messages.push_back(id.toString() + "|" + creature.mId + " has negative attack strength"); messages.push_back (std::make_pair (id,
creature.mId + " has negative attack strength"));
break; break;
} }
} }
//TODO, find meaning of other values //TODO, find meaning of other values
if (creature.mData.mGold < 0) //It seems that this is for gold in merchant creatures if (creature.mData.mGold < 0) //It seems that this is for gold in merchant creatures
{ messages.push_back (std::make_pair (id, creature.mId + " has negative gold "));
messages.push_back(id.toString() + "|" + creature.mId + " has negative gold ");
}
} }
void CSMTools::ReferenceableCheckStage::doorCheck( void CSMTools::ReferenceableCheckStage::doorCheck(
int stage, int stage, const CSMWorld::RefIdDataContainer< ESM::Door >& records,
const CSMWorld::RefIdDataContainer< ESM::Door >& records, Messages& messages)
std::vector< std::string >& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
if (baseRecord.isDeleted()) if (baseRecord.isDeleted())
{
return; return;
}
const ESM::Door& Door = (dynamic_cast<const CSMWorld::Record<ESM::Door>&>(baseRecord)).get(); const ESM::Door& Door = (dynamic_cast<const CSMWorld::Record<ESM::Door>&>(baseRecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Door, Door.mId); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Door, Door.mId);
//usual, name or model //usual, name or model
if (Door.mName.empty()) if (Door.mName.empty())
{ messages.push_back (std::make_pair (id, Door.mId + " has an empty name"));
messages.push_back(id.toString() + "|" + Door.mId + " has an empty name");
}
if (Door.mModel.empty()) if (Door.mModel.empty())
{ messages.push_back (std::make_pair (id, Door.mId + " has no model"));
messages.push_back(id.toString() + "|" + Door.mId + " has no model");
}
//TODO, check what static unsigned int sRecordId; is for
} }
void CSMTools::ReferenceableCheckStage::ingredientCheck( void CSMTools::ReferenceableCheckStage::ingredientCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Ingredient >& records, const CSMWorld::RefIdDataContainer< ESM::Ingredient >& records,
std::vector< std::string >& messages) Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -535,7 +487,7 @@ void CSMTools::ReferenceableCheckStage::ingredientCheck(
void CSMTools::ReferenceableCheckStage::creaturesLevListCheck( void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::CreatureLevList >& records, const CSMWorld::RefIdDataContainer< ESM::CreatureLevList >& records,
std::vector< std::string >& messages) Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -553,7 +505,7 @@ void CSMTools::ReferenceableCheckStage::creaturesLevListCheck(
void CSMTools::ReferenceableCheckStage::itemLevelledListCheck( void CSMTools::ReferenceableCheckStage::itemLevelledListCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::ItemLevList >& records, const CSMWorld::RefIdDataContainer< ESM::ItemLevList >& records,
std::vector< std::string >& messages) Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -569,40 +521,33 @@ void CSMTools::ReferenceableCheckStage::itemLevelledListCheck(
} }
void CSMTools::ReferenceableCheckStage::lightCheck( void CSMTools::ReferenceableCheckStage::lightCheck(
int stage, int stage, const CSMWorld::RefIdDataContainer< ESM::Light >& records,
const CSMWorld::RefIdDataContainer< ESM::Light >& records, Messages& messages)
std::vector< std::string >& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
if (baseRecord.isDeleted()) if (baseRecord.isDeleted())
{
return; return;
}
const ESM::Light& light = (dynamic_cast<const CSMWorld::Record<ESM::Light>& >(baseRecord)).get(); const ESM::Light& light = (dynamic_cast<const CSMWorld::Record<ESM::Light>& >(baseRecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Light, light.mId); CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Light, light.mId);
if (light.mData.mRadius < 0) if (light.mData.mRadius < 0)
{ messages.push_back (std::make_pair (id, light.mId + " has negative light radius"));
messages.push_back(id.toString() + "|" + light.mId + " has negative light radius");
}
if (light.mData.mFlags & ESM::Light::Carry) if (light.mData.mFlags & ESM::Light::Carry)
{ {
inventoryItemCheck<ESM::Light>(light, messages, id.toString()); inventoryItemCheck<ESM::Light>(light, messages, id.toString());
if (light.mData.mTime == 0) if (light.mData.mTime == 0)
{ messages.push_back (std::make_pair (id, light.mId + " has zero duration"));
messages.push_back(id.toString() + "|" + light.mId + " has zero duration");
}
} }
} }
void CSMTools::ReferenceableCheckStage::lockpickCheck( void CSMTools::ReferenceableCheckStage::lockpickCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Lockpick >& records, const CSMWorld::RefIdDataContainer< ESM::Lockpick >& records,
std::vector< std::string >& messages) Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -622,7 +567,7 @@ void CSMTools::ReferenceableCheckStage::lockpickCheck(
void CSMTools::ReferenceableCheckStage::miscCheck( void CSMTools::ReferenceableCheckStage::miscCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Miscellaneous >& records, const CSMWorld::RefIdDataContainer< ESM::Miscellaneous >& records,
std::vector< std::string >& messages) Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -637,20 +582,17 @@ void CSMTools::ReferenceableCheckStage::miscCheck(
inventoryItemCheck<ESM::Miscellaneous>(miscellaneous, messages, id.toString()); inventoryItemCheck<ESM::Miscellaneous>(miscellaneous, messages, id.toString());
} }
void CSMTools::ReferenceableCheckStage::npcCheck( void CSMTools::ReferenceableCheckStage::npcCheck (
int stage, int stage, const CSMWorld::RefIdDataContainer< ESM::NPC >& records,
const CSMWorld::RefIdDataContainer< ESM::NPC >& records, Messages& messages)
std::vector< std::string >& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
if (baseRecord.isDeleted()) if (baseRecord.isDeleted())
{
return; return;
}
const ESM::NPC& npc = (dynamic_cast<const CSMWorld::Record<ESM::NPC>& >(baseRecord)).get(); const ESM::NPC& npc = (dynamic_cast<const CSMWorld::Record<ESM::NPC>& >(baseRecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Npc, npc.mId); CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Npc, npc.mId);
short level(npc.mNpdt52.mLevel); short level(npc.mNpdt52.mLevel);
char disposition(npc.mNpdt52.mDisposition); char disposition(npc.mNpdt52.mDisposition);
@ -661,15 +603,13 @@ void CSMTools::ReferenceableCheckStage::npcCheck(
//Detect if player is present //Detect if player is present
if (Misc::StringUtils::ciEqual(npc.mId, "player")) //Happy now, scrawl? if (Misc::StringUtils::ciEqual(npc.mId, "player")) //Happy now, scrawl?
{
mPlayerPresent = true; mPlayerPresent = true;
}
if (npc.mNpdtType == ESM::NPC::NPC_WITH_AUTOCALCULATED_STATS) //12 = autocalculated if (npc.mNpdtType == ESM::NPC::NPC_WITH_AUTOCALCULATED_STATS) //12 = autocalculated
{ {
if ((npc.mFlags & ESM::NPC::Autocalc) == 0) //0x0008 = autocalculated flag if ((npc.mFlags & ESM::NPC::Autocalc) == 0) //0x0008 = autocalculated flag
{ {
messages.push_back(id.toString() + "|" + npc.mId + " mNpdtType or flags mismatch!"); //should not happend? messages.push_back (std::make_pair (id, npc.mId + " mNpdtType or flags mismatch!")); //should not happend?
return; return;
} }
@ -682,145 +622,100 @@ void CSMTools::ReferenceableCheckStage::npcCheck(
else else
{ {
if (npc.mNpdt52.mMana < 0) if (npc.mNpdt52.mMana < 0)
{ messages.push_back (std::make_pair (id, npc.mId + " mana has negative value"));
messages.push_back(id.toString() + "|" + npc.mId + " mana has negative value");
}
if (npc.mNpdt52.mFatigue < 0) if (npc.mNpdt52.mFatigue < 0)
{ messages.push_back (std::make_pair (id, npc.mId + " fatigue has negative value"));
messages.push_back(id.toString() + "|" + npc.mId + " fatigue has negative value");
}
if (npc.mNpdt52.mAgility == 0) if (npc.mNpdt52.mAgility == 0)
{ messages.push_back (std::make_pair (id, npc.mId + " agility has zero value"));
messages.push_back(id.toString() + "|" + npc.mId + " agility has zero value");
}
if (npc.mNpdt52.mEndurance == 0) if (npc.mNpdt52.mEndurance == 0)
{ messages.push_back (std::make_pair (id, npc.mId + " endurance has zero value"));
messages.push_back(id.toString() + "|" + npc.mId + " endurance has zero value");
}
if (npc.mNpdt52.mIntelligence == 0) if (npc.mNpdt52.mIntelligence == 0)
{ messages.push_back (std::make_pair (id, npc.mId + " intelligence has zero value"));
messages.push_back(id.toString() + "|" + npc.mId + " intelligence has zero value");
}
if (npc.mNpdt52.mLuck == 0) if (npc.mNpdt52.mLuck == 0)
{ messages.push_back (std::make_pair (id, npc.mId + " luck has zero value"));
messages.push_back(id.toString() + "|" + npc.mId + " luck has zero value");
}
if (npc.mNpdt52.mPersonality == 0) if (npc.mNpdt52.mPersonality == 0)
{ messages.push_back (std::make_pair (id, npc.mId + " personality has zero value"));
messages.push_back(id.toString() + "|" + npc.mId + " personality has zero value");
}
if (npc.mNpdt52.mStrength == 0) if (npc.mNpdt52.mStrength == 0)
{ messages.push_back (std::make_pair (id, npc.mId + " strength has zero value"));
messages.push_back(id.toString() + "|" + npc.mId + " strength has zero value");
}
if (npc.mNpdt52.mSpeed == 0) if (npc.mNpdt52.mSpeed == 0)
{ messages.push_back (std::make_pair (id, npc.mId + " speed has zero value"));
messages.push_back(id.toString() + "|" + npc.mId + " speed has zero value");
}
if (npc.mNpdt52.mWillpower == 0) if (npc.mNpdt52.mWillpower == 0)
{ messages.push_back (std::make_pair (id, npc.mId + " willpower has zero value"));
messages.push_back(id.toString() + "|" + npc.mId + " willpower has zero value");
}
} }
if (level < 1) if (level < 1)
{ messages.push_back (std::make_pair (id, npc.mId + " level is non positive"));
messages.push_back(id.toString() + "|" + npc.mId + " level is non positive");
}
if (gold < 0) if (gold < 0)
{ messages.push_back (std::make_pair (id, npc.mId + " gold has negative value"));
messages.push_back(id.toString() + "|" + npc.mId + " gold has negative value");
}
if (npc.mName.empty()) if (npc.mName.empty())
{ messages.push_back (std::make_pair (id, npc.mId + " has any empty name"));
messages.push_back(id.toString() + "|" + npc.mId + " has any empty name");
}
if (npc.mClass.empty()) if (npc.mClass.empty())
{ {
messages.push_back(id.toString() + "|" + npc.mId + " has any empty class"); messages.push_back (std::make_pair (id, npc.mId + " has any empty class"));
} }
else //checking if there is such class else if (mClasses.searchId (npc.mClass) == -1)
{ {
if (mClasses.searchId(npc.mClass) == -1) messages.push_back (std::make_pair (id, npc.mId + " has invalid class"));
{
messages.push_back(id.toString() + "|" + npc.mId + " has invalid class");
}
} }
if (npc.mRace.empty()) if (npc.mRace.empty())
{ {
messages.push_back(id.toString() + "|" + npc.mId + " has any empty race"); messages.push_back (std::make_pair (id, npc.mId + " has any empty race"));
} }
else //checking if there is a such race else if (mRaces.searchId (npc.mRace) == -1)
{ {
if (mRaces.searchId(npc.mRace) == -1) messages.push_back (std::make_pair (id, npc.mId + " has invalid race"));
{
messages.push_back(id.toString() + "|" + npc.mId + " has invalid race");
}
} }
if (disposition < 0) if (disposition < 0)
{ messages.push_back (std::make_pair (id, npc.mId + " has negative disposition"));
messages.push_back(id.toString() + "|" + npc.mId + " has negative disposition");
}
if (reputation < 0) //It seems that no character in Morrowind.esm have negative reputation. I'm assuming that negative reputation is invalid if (reputation < 0) //It seems that no character in Morrowind.esm have negative reputation. I'm assuming that negative reputation is invalid
{ {
messages.push_back(id.toString() + "|" + npc.mId + " has negative reputation"); messages.push_back (std::make_pair (id, npc.mId + " has negative reputation"));
} }
if (npc.mFaction.empty() == false) if (!npc.mFaction.empty())
{ {
if (rank < 0) if (rank < 0)
{ messages.push_back (std::make_pair (id, npc.mId + " has negative rank"));
messages.push_back(id.toString() + "|" + npc.mId + " has negative rank");
}
if (mFactions.searchId(npc.mFaction) == -1) if (mFactions.searchId(npc.mFaction) == -1)
{ messages.push_back (std::make_pair (id, npc.mId + " has invalid faction"));
messages.push_back(id.toString() + "|" + npc.mId + " has invalid faction");
}
} }
if (npc.mHead.empty()) if (npc.mHead.empty())
{ messages.push_back (std::make_pair (id, npc.mId + " has no head"));
messages.push_back(id.toString() + "|" + npc.mId + " has no head");
}
if (npc.mHair.empty()) if (npc.mHair.empty())
{ messages.push_back (std::make_pair (id, npc.mId + " has no hair"));
messages.push_back(id.toString() + "|" + npc.mId + " has no hair");
}
//TODO: reputation, Disposition, rank, everything else //TODO: reputation, Disposition, rank, everything else
} }
void CSMTools::ReferenceableCheckStage::weaponCheck( void CSMTools::ReferenceableCheckStage::weaponCheck(
int stage, int stage, const CSMWorld::RefIdDataContainer< ESM::Weapon >& records,
const CSMWorld::RefIdDataContainer< ESM::Weapon >& records, Messages& messages)
std::vector< std::string >& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord (stage);
if (baseRecord.isDeleted()) if (baseRecord.isDeleted())
{
return; return;
}
const ESM::Weapon& weapon = (dynamic_cast<const CSMWorld::Record<ESM::Weapon>& >(baseRecord)).get(); const ESM::Weapon& weapon = (dynamic_cast<const CSMWorld::Record<ESM::Weapon>& >(baseRecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Weapon, weapon.mId); CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Weapon, weapon.mId);
//TODO, It seems that this stuff for spellcasting is obligatory and In fact We should check if records are present //TODO, It seems that this stuff for spellcasting is obligatory and In fact We should check if records are present
if if
@ -860,20 +755,17 @@ void CSMTools::ReferenceableCheckStage::weaponCheck(
weapon.mData.mType == ESM::Weapon::Bolt)) weapon.mData.mType == ESM::Weapon::Bolt))
{ {
if (weapon.mData.mSlash[0] > weapon.mData.mSlash[1]) if (weapon.mData.mSlash[0] > weapon.mData.mSlash[1])
{ messages.push_back (std::make_pair (id,
messages.push_back(id.toString() + "|" + weapon.mId + " has minimum slash damage higher than maximum"); weapon.mId + " has minimum slash damage higher than maximum"));
}
if (weapon.mData.mThrust[0] > weapon.mData.mThrust[1]) if (weapon.mData.mThrust[0] > weapon.mData.mThrust[1])
{ messages.push_back (std::make_pair (id,
messages.push_back(id.toString() + "|" + weapon.mId + " has minimum thrust damage higher than maximum"); weapon.mId + " has minimum thrust damage higher than maximum"));
}
} }
if (weapon.mData.mChop[0] > weapon.mData.mChop[1]) if (weapon.mData.mChop[0] > weapon.mData.mChop[1])
{ messages.push_back (std::make_pair (id,
messages.push_back(id.toString() + "|" + weapon.mId + " has minimum chop damage higher than maximum"); weapon.mId + " has minimum chop damage higher than maximum"));
}
if (!(weapon.mData.mType == ESM::Weapon::Arrow || if (!(weapon.mData.mType == ESM::Weapon::Arrow ||
weapon.mData.mType == ESM::Weapon::Bolt || weapon.mData.mType == ESM::Weapon::Bolt ||
@ -881,14 +773,10 @@ void CSMTools::ReferenceableCheckStage::weaponCheck(
{ {
//checking of health //checking of health
if (weapon.mData.mHealth <= 0) if (weapon.mData.mHealth <= 0)
{ messages.push_back (std::make_pair (id, weapon.mId + " has non-positivie health"));
messages.push_back(id.toString() + "|" + weapon.mId + " has non-positivie health");
}
if (weapon.mData.mReach < 0) if (weapon.mData.mReach < 0)
{ messages.push_back (std::make_pair (id, weapon.mId + " has negative reach"));
messages.push_back(id.toString() + "|" + weapon.mId + " has negative reach");
}
} }
} }
} }
@ -896,7 +784,7 @@ void CSMTools::ReferenceableCheckStage::weaponCheck(
void CSMTools::ReferenceableCheckStage::probeCheck( void CSMTools::ReferenceableCheckStage::probeCheck(
int stage, int stage,
const CSMWorld::RefIdDataContainer< ESM::Probe >& records, const CSMWorld::RefIdDataContainer< ESM::Probe >& records,
std::vector< std::string >& messages) Messages& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord(stage);
@ -912,184 +800,128 @@ void CSMTools::ReferenceableCheckStage::probeCheck(
toolCheck<ESM::Probe>(probe, messages, id.toString(), true); toolCheck<ESM::Probe>(probe, messages, id.toString(), true);
} }
void CSMTools::ReferenceableCheckStage::repairCheck( void CSMTools::ReferenceableCheckStage::repairCheck (
int stage, int stage, const CSMWorld::RefIdDataContainer< ESM::Repair >& records,
const CSMWorld::RefIdDataContainer< ESM::Repair >& records, Messages& messages)
std::vector< std::string >& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord (stage);
if (baseRecord.isDeleted()) if (baseRecord.isDeleted())
{
return; return;
}
const ESM::Repair& repair = (dynamic_cast<const CSMWorld::Record<ESM::Repair>& >(baseRecord)).get(); const ESM::Repair& repair = (dynamic_cast<const CSMWorld::Record<ESM::Repair>& >(baseRecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Repair, repair.mId); CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Repair, repair.mId);
inventoryItemCheck<ESM::Repair>(repair, messages, id.toString()); inventoryItemCheck<ESM::Repair> (repair, messages, id.toString());
toolCheck<ESM::Repair>(repair, messages, id.toString(), true); toolCheck<ESM::Repair> (repair, messages, id.toString(), true);
} }
void CSMTools::ReferenceableCheckStage::staticCheck( void CSMTools::ReferenceableCheckStage::staticCheck (
int stage, int stage, const CSMWorld::RefIdDataContainer< ESM::Static >& records,
const CSMWorld::RefIdDataContainer< ESM::Static >& records, Messages& messages)
std::vector< std::string >& messages)
{ {
const CSMWorld::RecordBase& baseRecord = records.getRecord(stage); const CSMWorld::RecordBase& baseRecord = records.getRecord (stage);
if (baseRecord.isDeleted()) if (baseRecord.isDeleted())
{
return; return;
}
const ESM::Static& staticElement = (dynamic_cast<const CSMWorld::Record<ESM::Static>& >(baseRecord)).get(); const ESM::Static& staticElement = (dynamic_cast<const CSMWorld::Record<ESM::Static>& >(baseRecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Static, staticElement.mId); CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Static, staticElement.mId);
if (staticElement.mModel.empty()) if (staticElement.mModel.empty())
{ messages.push_back (std::make_pair (id, staticElement.mId + " has no model"));
messages.push_back(id.toString() + "|" + staticElement.mId + " has no model");
}
} }
//final check //final check
void CSMTools::ReferenceableCheckStage::finalCheck(std::vector< std::string >& messages) void CSMTools::ReferenceableCheckStage::finalCheck (Messages& messages)
{ {
if (!mPlayerPresent) if (!mPlayerPresent)
{ messages.push_back (std::make_pair (CSMWorld::UniversalId::Type_Referenceables,
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Npc); "There is no player record"));
messages.push_back(id.toString() + "| There is no player record");
}
} }
//Templates begins here //Templates begins here
template<typename ITEM> void CSMTools::ReferenceableCheckStage::inventoryItemCheck( template<typename Item> void CSMTools::ReferenceableCheckStage::inventoryItemCheck (
const ITEM& someItem, const Item& someItem, Messages& messages, const std::string& someID, bool enchantable)
std::vector< std::string >& messages,
const std::string& someID, bool enchantable)
{ {
if (someItem.mName.empty()) if (someItem.mName.empty())
{ messages.push_back (std::make_pair (someID, someItem.mId + " has an empty name"));
messages.push_back(someID + "|" + someItem.mId + " has an empty name");
}
//Checking for weight //Checking for weight
if (someItem.mData.mWeight < 0) if (someItem.mData.mWeight < 0)
{ messages.push_back (std::make_pair (someID, someItem.mId + " has negative weight"));
messages.push_back(someID + "|" + someItem.mId + " has negative weight");
}
//Checking for value //Checking for value
if (someItem.mData.mValue < 0) if (someItem.mData.mValue < 0)
{ messages.push_back (std::make_pair (someID, someItem.mId + " has negative value"));
messages.push_back(someID + "|" + someItem.mId + " has negative value");
}
//checking for model
if (someItem.mModel.empty())
{
messages.push_back(someID + "|" + someItem.mId + " has no model");
}
//checking for icon
if (someItem.mIcon.empty())
{
messages.push_back(someID + "|" + someItem.mId + " has no icon");
}
if (enchantable)
{
if (someItem.mData.mEnchant < 0)
{
messages.push_back(someID + "|" + someItem.mId + " has negative enchantment");
}
}
}
template<typename ITEM> void CSMTools::ReferenceableCheckStage::inventoryItemCheck(
const ITEM& someItem,
std::vector< std::string >& messages,
const std::string& someID)
{
if (someItem.mName.empty())
{
messages.push_back(someID + "|" + someItem.mId + " has an empty name");
}
//Checking for weight
if (someItem.mData.mWeight < 0)
{
messages.push_back(someID + "|" + someItem.mId + " has negative weight");
}
//Checking for value
if (someItem.mData.mValue < 0)
{
messages.push_back(someID + "|" + someItem.mId + " has negative value");
}
//checking for model //checking for model
if (someItem.mModel.empty()) if (someItem.mModel.empty())
{ messages.push_back (std::make_pair (someID, someItem.mId + " has no model"));
messages.push_back(someID + "|" + someItem.mId + " has no model");
}
//checking for icon //checking for icon
if (someItem.mIcon.empty()) if (someItem.mIcon.empty())
{ messages.push_back (std::make_pair (someID, someItem.mId + " has no icon"));
messages.push_back(someID + "|" + someItem.mId + " has no icon");
} if (enchantable && someItem.mData.mEnchant < 0)
messages.push_back (std::make_pair (someID, someItem.mId + " has negative enchantment"));
} }
template<typename TOOL> void CSMTools::ReferenceableCheckStage::toolCheck( template<typename Item> void CSMTools::ReferenceableCheckStage::inventoryItemCheck (
const TOOL& someTool, const Item& someItem, Messages& messages, const std::string& someID)
std::vector< std::string >& messages, {
const std::string& someID, bool canBeBroken) if (someItem.mName.empty())
messages.push_back (std::make_pair (someID, someItem.mId + " has an empty name"));
//Checking for weight
if (someItem.mData.mWeight < 0)
messages.push_back (std::make_pair (someID, someItem.mId + " has negative weight"));
//Checking for value
if (someItem.mData.mValue < 0)
messages.push_back (std::make_pair (someID, someItem.mId + " has negative value"));
//checking for model
if (someItem.mModel.empty())
messages.push_back (std::make_pair (someID, someItem.mId + " has no model"));
//checking for icon
if (someItem.mIcon.empty())
messages.push_back (std::make_pair (someID, someItem.mId + " has no icon"));
}
template<typename Tool> void CSMTools::ReferenceableCheckStage::toolCheck (
const Tool& someTool, Messages& messages, const std::string& someID, bool canBeBroken)
{ {
if (someTool.mData.mQuality <= 0) if (someTool.mData.mQuality <= 0)
{ messages.push_back (std::make_pair (someID, someTool.mId + " has non-positive quality"));
messages.push_back(someID + "|" + someTool.mId + " has non-positive quality");
}
if (canBeBroken) if (canBeBroken && someTool.mData.mUses<=0)
{ messages.push_back (std::make_pair (someID,
if (someTool.mData.mUses <= 0) someTool.mId + " has non-positive uses count"));
{
messages.push_back(someID + "|" + someTool.mId + " has non-positive uses count");
}
}
} }
template<typename TOOL> void CSMTools::ReferenceableCheckStage::toolCheck( template<typename Tool> void CSMTools::ReferenceableCheckStage::toolCheck (
const TOOL& someTool, const Tool& someTool, Messages& messages, const std::string& someID)
std::vector< std::string >& messages,
const std::string& someID)
{ {
if (someTool.mData.mQuality <= 0) if (someTool.mData.mQuality <= 0)
{ messages.push_back (std::make_pair (someID, someTool.mId + " has non-positive quality"));
messages.push_back(someID + "|" + someTool.mId + " has non-positive quality");
}
} }
template<typename LIST> void CSMTools::ReferenceableCheckStage::listCheck( template<typename List> void CSMTools::ReferenceableCheckStage::listCheck (
const LIST& someList, const List& someList, Messages& messages, const std::string& someID)
std::vector< std::string >& messages,
const std::string& someID)
{ {
for (unsigned i = 0; i < someList.mList.size(); ++i) for (unsigned i = 0; i < someList.mList.size(); ++i)
{ {
if (mReferencables.searchId(someList.mList[i].mId).first == -1) if (mReferencables.searchId(someList.mList[i].mId).first == -1)
{ messages.push_back (std::make_pair (someID,
messages.push_back(someID + "|" + someList.mId + " contains item without referencable"); someList.mId + " contains item without referencable"));
}
if (someList.mList[i].mLevel < 1) if (someList.mList[i].mLevel < 1)
{ messages.push_back (std::make_pair (someID,
messages.push_back(someID + "|" + someList.mId + " contains item with non-positive level"); someList.mId + " contains item with non-positive level"));
}
} }
} }
// kate: indent-mode cstyle; indent-width 4; replace-tabs on;

View File

@ -11,61 +11,62 @@ namespace CSMTools
class ReferenceableCheckStage : public CSMDoc::Stage class ReferenceableCheckStage : public CSMDoc::Stage
{ {
public: public:
ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable,
ReferenceableCheckStage (const CSMWorld::RefIdData& referenceable,
const CSMWorld::IdCollection<ESM::Race>& races, const CSMWorld::IdCollection<ESM::Race>& races,
const CSMWorld::IdCollection<ESM::Class>& classes, const CSMWorld::IdCollection<ESM::Class>& classes,
const CSMWorld::IdCollection<ESM::Faction>& factions); const CSMWorld::IdCollection<ESM::Faction>& factions);
virtual void perform(int stage, std::vector< std::string >& messages); virtual void perform(int stage, Messages& messages);
virtual int setup(); virtual int setup();
private: private:
//CONCRETE CHECKS //CONCRETE CHECKS
void bookCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Book >& records, std::vector< std::string >& messages); void bookCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Book >& records, Messages& messages);
void activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, std::vector< std::string >& messages); void activatorCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Activator >& records, Messages& messages);
void potionCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Potion>& records, std::vector<std::string>& messages); void potionCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Potion>& records, Messages& messages);
void apparatusCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Apparatus>& records, std::vector<std::string>& messages); void apparatusCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Apparatus>& records, Messages& messages);
void armorCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Armor>& records, std::vector<std::string>& messages); void armorCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Armor>& records, Messages& messages);
void clothingCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Clothing>& records, std::vector<std::string>& messages); void clothingCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Clothing>& records, Messages& messages);
void containerCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Container>& records, std::vector<std::string>& messages); void containerCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Container>& records, Messages& messages);
void creatureCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Creature>& records, std::vector<std::string>& messages); void creatureCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Creature>& records, Messages& messages);
void doorCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Door>& records, std::vector<std::string>& messages); void doorCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Door>& records, Messages& messages);
void ingredientCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Ingredient>& records, std::vector<std::string>& messages); void ingredientCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Ingredient>& records, Messages& messages);
void creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::CreatureLevList>& records, std::vector<std::string>& messages); void creaturesLevListCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::CreatureLevList>& records, Messages& messages);
void itemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::ItemLevList>& records, std::vector<std::string>& messages); void itemLevelledListCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::ItemLevList>& records, Messages& messages);
void lightCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Light>& records, std::vector<std::string>& messages); void lightCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Light>& records, Messages& messages);
void lockpickCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Lockpick>& records, std::vector<std::string>& messages); void lockpickCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Lockpick>& records, Messages& messages);
void miscCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Miscellaneous>& records, std::vector<std::string>& messages); void miscCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Miscellaneous>& records, Messages& messages);
void npcCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::NPC>& records, std::vector<std::string>& messages); void npcCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::NPC>& records, Messages& messages);
void weaponCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Weapon>& records, std::vector<std::string>& messages); void weaponCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Weapon>& records, Messages& messages);
void probeCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Probe>& records, std::vector<std::string>& messages); void probeCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Probe>& records, Messages& messages);
void repairCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Repair>& records, std::vector<std::string>& messages); void repairCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Repair>& records, Messages& messages);
void staticCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Static>& records, std::vector<std::string>& messages); void staticCheck(int stage, const CSMWorld::RefIdDataContainer<ESM::Static>& records, Messages& messages);
//FINAL CHECK //FINAL CHECK
void finalCheck(std::vector<std::string>& messages); void finalCheck (Messages& messages);
//TEMPLATE CHECKS //TEMPLATE CHECKS
template<typename ITEM> void inventoryItemCheck(const ITEM& someItem, template<typename ITEM> void inventoryItemCheck(const ITEM& someItem,
std::vector<std::string>& messages, Messages& messages,
const std::string& someID, const std::string& someID,
bool enchantable); //for all enchantable items. bool enchantable); //for all enchantable items.
template<typename ITEM> void inventoryItemCheck(const ITEM& someItem, template<typename ITEM> void inventoryItemCheck(const ITEM& someItem,
std::vector<std::string>& messages, Messages& messages,
const std::string& someID); //for non-enchantable items. const std::string& someID); //for non-enchantable items.
template<typename TOOL> void toolCheck(const TOOL& someTool, template<typename TOOL> void toolCheck(const TOOL& someTool,
std::vector<std::string>& messages, Messages& messages,
const std::string& someID, const std::string& someID,
bool canbebroken); //for tools with uses. bool canbebroken); //for tools with uses.
template<typename TOOL> void toolCheck(const TOOL& someTool, template<typename TOOL> void toolCheck(const TOOL& someTool,
std::vector<std::string>& messages, Messages& messages,
const std::string& someID); //for tools without uses. const std::string& someID); //for tools without uses.
template<typename LIST> void listCheck(const LIST& someList, template<typename LIST> void listCheck(const LIST& someList,
std::vector< std::string >& messages, Messages& messages,
const std::string& someID); const std::string& someID);
const CSMWorld::RefIdData& mReferencables; const CSMWorld::RefIdData& mReferencables;

View File

@ -17,7 +17,7 @@ int CSMTools::RegionCheckStage::setup()
return mRegions.getSize(); return mRegions.getSize();
} }
void CSMTools::RegionCheckStage::perform (int stage, std::vector<std::string>& messages) void CSMTools::RegionCheckStage::perform (int stage, Messages& messages)
{ {
const CSMWorld::Record<ESM::Region>& record = mRegions.getRecord (stage); const CSMWorld::Record<ESM::Region>& record = mRegions.getRecord (stage);
@ -30,7 +30,7 @@ void CSMTools::RegionCheckStage::perform (int stage, std::vector<std::string>& m
// test for empty name // test for empty name
if (region.mName.empty()) if (region.mName.empty())
messages.push_back (id.toString() + "|" + region.mId + " has an empty name"); messages.push_back (std::make_pair (id, region.mId + " has an empty name"));
/// \todo test that the ID in mSleeplist exists /// \todo test that the ID in mSleeplist exists

View File

@ -21,7 +21,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View File

@ -51,16 +51,11 @@ bool CSMTools::ReportModel::removeRows (int row, int count, const QModelIndex& p
return true; return true;
} }
void CSMTools::ReportModel::add (const std::string& row) void CSMTools::ReportModel::add (const CSMWorld::UniversalId& id, const std::string& message)
{ {
std::string::size_type index = row.find ('|');
if (index==std::string::npos)
throw std::logic_error ("invalid report message");
beginInsertRows (QModelIndex(), mRows.size(), mRows.size()); beginInsertRows (QModelIndex(), mRows.size(), mRows.size());
mRows.push_back (std::make_pair (row.substr (0, index), row.substr (index+1))); mRows.push_back (std::make_pair (id, message));
endInsertRows(); endInsertRows();
} }

View File

@ -28,7 +28,7 @@ namespace CSMTools
virtual bool removeRows (int row, int count, const QModelIndex& parent = QModelIndex()); virtual bool removeRows (int row, int count, const QModelIndex& parent = QModelIndex());
void add (const std::string& row); void add (const CSMWorld::UniversalId& id, const std::string& message);
const CSMWorld::UniversalId& getUniversalId (int row) const; const CSMWorld::UniversalId& getUniversalId (int row) const;
}; };

View File

@ -16,8 +16,6 @@ void CSMTools::ScriptCheckStage::report (const std::string& message, const Compi
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId); CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId);
stream << id.toString() << "|";
if (type==ErrorMessage) if (type==ErrorMessage)
stream << "error "; stream << "error ";
else else
@ -28,25 +26,15 @@ void CSMTools::ScriptCheckStage::report (const std::string& message, const Compi
<< ", line " << loc.mLine << ", column " << loc.mColumn << ", line " << loc.mLine << ", column " << loc.mColumn
<< " (" << loc.mLiteral << "): " << message; << " (" << loc.mLiteral << "): " << message;
mMessages->push_back (stream.str()); mMessages->push_back (std::make_pair (id, stream.str()));
} }
void CSMTools::ScriptCheckStage::report (const std::string& message, Type type) void CSMTools::ScriptCheckStage::report (const std::string& message, Type type)
{ {
std::ostringstream stream;
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId); CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId);
stream << id.toString() << "|"; mMessages->push_back (std::make_pair (id,
(type==ErrorMessage ? "error: " : "warning: ") + message));
if (type==ErrorMessage)
stream << "error: ";
else
stream << "warning: ";
stream << message;
mMessages->push_back (stream.str());
} }
CSMTools::ScriptCheckStage::ScriptCheckStage (const CSMWorld::Data& data) CSMTools::ScriptCheckStage::ScriptCheckStage (const CSMWorld::Data& data)
@ -68,7 +56,7 @@ int CSMTools::ScriptCheckStage::setup()
return mData.getScripts().getSize(); return mData.getScripts().getSize();
} }
void CSMTools::ScriptCheckStage::perform (int stage, std::vector<std::string>& messages) void CSMTools::ScriptCheckStage::perform (int stage, Messages& messages)
{ {
mMessages = &messages; mMessages = &messages;
mId = mData.getScripts().getId (stage); mId = mData.getScripts().getId (stage);
@ -90,13 +78,10 @@ void CSMTools::ScriptCheckStage::perform (int stage, std::vector<std::string>& m
} }
catch (const std::exception& error) catch (const std::exception& error)
{ {
std::ostringstream stream;
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId); CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Script, mId);
stream << id.toString() << "|Critical compile error: " << error.what(); messages.push_back (std::make_pair (id,
std::string ("Critical compile error: ") + error.what()));
messages.push_back (stream.str());
} }
mMessages = 0; mMessages = 0;

View File

@ -18,7 +18,7 @@ namespace CSMTools
CSMWorld::ScriptContext mContext; CSMWorld::ScriptContext mContext;
std::string mId; std::string mId;
std::string mFile; std::string mFile;
std::vector<std::string> *mMessages; Messages *mMessages;
virtual void report (const std::string& message, const Compiler::TokenLoc& loc, Type type); virtual void report (const std::string& message, const Compiler::TokenLoc& loc, Type type);
///< Report error to the user. ///< Report error to the user.
@ -33,7 +33,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View File

@ -16,7 +16,7 @@ int CSMTools::SkillCheckStage::setup()
return mSkills.getSize(); return mSkills.getSize();
} }
void CSMTools::SkillCheckStage::perform (int stage, std::vector<std::string>& messages) void CSMTools::SkillCheckStage::perform (int stage, Messages& messages)
{ {
const CSMWorld::Record<ESM::Skill>& record = mSkills.getRecord (stage); const CSMWorld::Record<ESM::Skill>& record = mSkills.getRecord (stage);
@ -32,11 +32,11 @@ void CSMTools::SkillCheckStage::perform (int stage, std::vector<std::string>& me
{ {
std::ostringstream stream; std::ostringstream stream;
stream << id.toString() << "|Use value #" << i << " of " << skill.mId << " is negative"; stream << "Use value #" << i << " of " << skill.mId << " is negative";
messages.push_back (stream.str()); messages.push_back (std::make_pair (id, stream.str()));
} }
if (skill.mDescription.empty()) if (skill.mDescription.empty())
messages.push_back (id.toString() + "|" + skill.mId + " has an empty description"); messages.push_back (std::make_pair (id, skill.mId + " has an empty description"));
} }

View File

@ -21,7 +21,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View File

@ -16,7 +16,7 @@ int CSMTools::SoundCheckStage::setup()
return mSounds.getSize(); return mSounds.getSize();
} }
void CSMTools::SoundCheckStage::perform (int stage, std::vector<std::string>& messages) void CSMTools::SoundCheckStage::perform (int stage, Messages& messages)
{ {
const CSMWorld::Record<ESM::Sound>& record = mSounds.getRecord (stage); const CSMWorld::Record<ESM::Sound>& record = mSounds.getRecord (stage);
@ -28,7 +28,7 @@ void CSMTools::SoundCheckStage::perform (int stage, std::vector<std::string>& me
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Sound, sound.mId); CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Sound, sound.mId);
if (sound.mData.mMinRange>sound.mData.mMaxRange) if (sound.mData.mMinRange>sound.mData.mMaxRange)
messages.push_back (id.toString() + "|Maximum range larger than minimum range"); messages.push_back (std::make_pair (id, "Maximum range larger than minimum range"));
/// \todo check, if the sound file exists /// \todo check, if the sound file exists
} }

View File

@ -21,7 +21,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View File

@ -17,7 +17,7 @@ int CSMTools::SpellCheckStage::setup()
return mSpells.getSize(); return mSpells.getSize();
} }
void CSMTools::SpellCheckStage::perform (int stage, std::vector<std::string>& messages) void CSMTools::SpellCheckStage::perform (int stage, Messages& messages)
{ {
const CSMWorld::Record<ESM::Spell>& record = mSpells.getRecord (stage); const CSMWorld::Record<ESM::Spell>& record = mSpells.getRecord (stage);
@ -30,11 +30,11 @@ void CSMTools::SpellCheckStage::perform (int stage, std::vector<std::string>& me
// test for empty name and description // test for empty name and description
if (spell.mName.empty()) if (spell.mName.empty())
messages.push_back (id.toString() + "|" + spell.mId + " has an empty name"); messages.push_back (std::make_pair (id, spell.mId + " has an empty name"));
// test for invalid cost values // test for invalid cost values
if (spell.mData.mCost<0) if (spell.mData.mCost<0)
messages.push_back (id.toString() + "|" + spell.mId + " has a negative spell costs"); messages.push_back (std::make_pair (id, spell.mId + " has a negative spell costs"));
/// \todo check data members that can't be edited in the table view /// \todo check data members that can't be edited in the table view
} }

View File

@ -21,7 +21,7 @@ namespace CSMTools
virtual int setup(); virtual int setup();
///< \return number of steps ///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages); virtual void perform (int stage, Messages& messages);
///< Messages resulting from this tage will be appended to \a messages. ///< Messages resulting from this tage will be appended to \a messages.
}; };
} }

View File

@ -45,8 +45,9 @@ CSMDoc::Operation *CSMTools::Tools::getVerifier()
connect (mVerifier, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int))); connect (mVerifier, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int)));
connect (mVerifier, SIGNAL (done (int)), this, SIGNAL (done (int))); connect (mVerifier, SIGNAL (done (int)), this, SIGNAL (done (int)));
connect (mVerifier, SIGNAL (reportMessage (const QString&, int)), connect (mVerifier,
this, SLOT (verifierMessage (const QString&, int))); SIGNAL (reportMessage (const CSMWorld::UniversalId&, const std::string&, int)),
this, SLOT (verifierMessage (const CSMWorld::UniversalId&, const std::string&, int)));
std::vector<std::string> mandatoryIds; // I want C++11, damn it! std::vector<std::string> mandatoryIds; // I want C++11, damn it!
mandatoryIds.push_back ("Day"); mandatoryIds.push_back ("Day");
@ -138,11 +139,12 @@ CSMTools::ReportModel *CSMTools::Tools::getReport (const CSMWorld::UniversalId&
return mReports.at (id.getIndex()); return mReports.at (id.getIndex());
} }
void CSMTools::Tools::verifierMessage (const QString& message, int type) void CSMTools::Tools::verifierMessage (const CSMWorld::UniversalId& id, const std::string& message,
int type)
{ {
std::map<int, int>::iterator iter = mActiveReports.find (type); std::map<int, int>::iterator iter = mActiveReports.find (type);
if (iter!=mActiveReports.end()) if (iter!=mActiveReports.end())
mReports[iter->second]->add (message.toUtf8().constData()); mReports[iter->second]->add (id, message);
} }

View File

@ -61,7 +61,8 @@ namespace CSMTools
private slots: private slots:
void verifierMessage (const QString& message, int type); void verifierMessage (const CSMWorld::UniversalId& id, const std::string& message,
int type);
signals: signals: