forked from teamnwah/openmw-tes3coop
Added Referencable checks class, added method to get refidcontainer, added method to get mBooks.
Currently only books are checked, and only if name is present.
This commit is contained in:
parent
230bbf06ba
commit
8085fcc792
8 changed files with 111 additions and 3 deletions
|
@ -38,7 +38,7 @@ opencs_units (model/tools
|
|||
|
||||
opencs_units_noqt (model/tools
|
||||
mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck
|
||||
birthsigncheck spellcheck
|
||||
birthsigncheck spellcheck referenceablecheck
|
||||
)
|
||||
|
||||
|
||||
|
|
63
apps/opencs/model/tools/referenceablecheck.cpp
Normal file
63
apps/opencs/model/tools/referenceablecheck.cpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
#include "referenceablecheck.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include <components/esm/loadbook.hpp>
|
||||
#include "../world/record.hpp"
|
||||
|
||||
#include "../world/universalid.hpp"
|
||||
|
||||
CSMTools::ReferenceableCheckStage::ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable) :
|
||||
mReferencables(referenceable),
|
||||
mBooksSize(0)
|
||||
{
|
||||
setSizeVariables();
|
||||
}
|
||||
|
||||
void CSMTools::ReferenceableCheckStage::perform(int stage, std::vector< std::string >& messages)
|
||||
{
|
||||
//Checks for books, than, when stage is above mBooksSize goes to other checks, with stage - minus prev sizes as stage.
|
||||
bool CheckPerformed = false;
|
||||
|
||||
if (stage <= mBooksSize)
|
||||
{
|
||||
bookCheck(stage, mReferencables.getBooks(), messages);
|
||||
CheckPerformed = true;
|
||||
}
|
||||
|
||||
if (CheckPerformed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int CSMTools::ReferenceableCheckStage::setup()
|
||||
{
|
||||
return mReferencables.getSize();
|
||||
}
|
||||
|
||||
void CSMTools::ReferenceableCheckStage::bookCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Book >& records, std::vector< std::string >& messages)
|
||||
{
|
||||
const CSMWorld::RecordBase& baserecord = records.getRecord(stage);
|
||||
|
||||
if (baserecord.isDeleted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const ESM::Book& Book = (static_cast<const CSMWorld::Record<ESM::Book>& >(baserecord)).get();
|
||||
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Book, Book.mId);
|
||||
|
||||
//Checking for name
|
||||
if (Book.mName.empty())
|
||||
{
|
||||
messages.push_back(id.toString() + "|" + Book.mId + " has an empty name");
|
||||
}
|
||||
}
|
||||
|
||||
void CSMTools::ReferenceableCheckStage::setSizeVariables()
|
||||
{
|
||||
mBooksSize = mReferencables.getBooks().getSize();
|
||||
}
|
26
apps/opencs/model/tools/referenceablecheck.hpp
Normal file
26
apps/opencs/model/tools/referenceablecheck.hpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef REFERENCEABLECHECKSTAGE_H
|
||||
#define REFERENCEABLECHECKSTAGE_H
|
||||
|
||||
#include "../world/universalid.hpp"
|
||||
#include "../doc/stage.hpp"
|
||||
#include "../world/data.hpp"
|
||||
#include "../world/refiddata.hpp"
|
||||
|
||||
namespace CSMTools
|
||||
{
|
||||
class ReferenceableCheckStage : public CSMDoc::Stage
|
||||
{
|
||||
public:
|
||||
ReferenceableCheckStage(const CSMWorld::RefIdData& referenceable);
|
||||
virtual void perform(int stage, std::vector< std::string >& messages);
|
||||
virtual int setup();
|
||||
|
||||
private:
|
||||
void bookCheck(int stage, const CSMWorld::RefIdDataContainer< ESM::Book >& records, std::vector< std::string >& messages);
|
||||
void setSizeVariables();
|
||||
|
||||
const CSMWorld::RefIdData mReferencables;
|
||||
int mBooksSize;
|
||||
};
|
||||
}
|
||||
#endif // REFERENCEABLECHECKSTAGE_H
|
|
@ -19,6 +19,7 @@
|
|||
#include "regioncheck.hpp"
|
||||
#include "birthsigncheck.hpp"
|
||||
#include "spellcheck.hpp"
|
||||
#include "referenceablecheck.hpp"
|
||||
|
||||
CSMDoc::Operation *CSMTools::Tools::get (int type)
|
||||
{
|
||||
|
@ -74,6 +75,8 @@ CSMDoc::Operation *CSMTools::Tools::getVerifier()
|
|||
mVerifier->appendStage (new BirthsignCheckStage (mData.getBirthsigns()));
|
||||
|
||||
mVerifier->appendStage (new SpellCheckStage (mData.getSpells()));
|
||||
|
||||
mVerifier->appendStage( new ReferenceableCheckStage (mData.getReferenceables().getDataSet()));
|
||||
}
|
||||
|
||||
return mVerifier;
|
||||
|
@ -138,4 +141,4 @@ void CSMTools::Tools::verifierMessage (const QString& message, int type)
|
|||
|
||||
if (iter!=mActiveReports.end())
|
||||
mReports[iter->second]->add (message.toStdString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -549,3 +549,9 @@ void CSMWorld::RefIdCollection::save (int index, ESM::ESMWriter& writer) const
|
|||
{
|
||||
mData.save (index, writer);
|
||||
}
|
||||
|
||||
const CSMWorld::RefIdData& CSMWorld::RefIdCollection::getDataSet() const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,8 @@ namespace CSMWorld
|
|||
/// \return Success?
|
||||
|
||||
void save (int index, ESM::ESMWriter& writer) const;
|
||||
|
||||
const RefIdData& getDataSet() const; //I can't figure out a better name for this one :(
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -230,4 +230,9 @@ void CSMWorld::RefIdData::save (int index, ESM::ESMWriter& writer) const
|
|||
throw std::logic_error ("invalid local index type");
|
||||
|
||||
iter->second->save (localIndex.first, writer);
|
||||
}
|
||||
}
|
||||
|
||||
const CSMWorld::RefIdDataContainer< ESM::Book >& CSMWorld::RefIdData::getBooks() const
|
||||
{
|
||||
return mBooks;
|
||||
}
|
||||
|
|
|
@ -219,6 +219,9 @@ namespace CSMWorld
|
|||
/// \param listDeleted include deleted record in the list
|
||||
|
||||
void save (int index, ESM::ESMWriter& writer) const;
|
||||
|
||||
//RECORD CONTAINERS ACCESS METHODS
|
||||
const RefIdDataContainer<ESM::Book>& getBooks() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue