mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-02 05:45:32 +00:00
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
|
opencs_units_noqt (model/tools
|
||||||
mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck
|
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 "regioncheck.hpp"
|
||||||
#include "birthsigncheck.hpp"
|
#include "birthsigncheck.hpp"
|
||||||
#include "spellcheck.hpp"
|
#include "spellcheck.hpp"
|
||||||
|
#include "referenceablecheck.hpp"
|
||||||
|
|
||||||
CSMDoc::Operation *CSMTools::Tools::get (int type)
|
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 BirthsignCheckStage (mData.getBirthsigns()));
|
||||||
|
|
||||||
mVerifier->appendStage (new SpellCheckStage (mData.getSpells()));
|
mVerifier->appendStage (new SpellCheckStage (mData.getSpells()));
|
||||||
|
|
||||||
|
mVerifier->appendStage( new ReferenceableCheckStage (mData.getReferenceables().getDataSet()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return mVerifier;
|
return mVerifier;
|
||||||
|
|
|
@ -549,3 +549,9 @@ void CSMWorld::RefIdCollection::save (int index, ESM::ESMWriter& writer) const
|
||||||
{
|
{
|
||||||
mData.save (index, writer);
|
mData.save (index, writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CSMWorld::RefIdData& CSMWorld::RefIdCollection::getDataSet() const
|
||||||
|
{
|
||||||
|
return mData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,8 @@ namespace CSMWorld
|
||||||
/// \return Success?
|
/// \return Success?
|
||||||
|
|
||||||
void save (int index, ESM::ESMWriter& writer) const;
|
void save (int index, ESM::ESMWriter& writer) const;
|
||||||
|
|
||||||
|
const RefIdData& getDataSet() const; //I can't figure out a better name for this one :(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,3 +231,8 @@ void CSMWorld::RefIdData::save (int index, ESM::ESMWriter& writer) const
|
||||||
|
|
||||||
iter->second->save (localIndex.first, writer);
|
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
|
/// \param listDeleted include deleted record in the list
|
||||||
|
|
||||||
void save (int index, ESM::ESMWriter& writer) const;
|
void save (int index, ESM::ESMWriter& writer) const;
|
||||||
|
|
||||||
|
//RECORD CONTAINERS ACCESS METHODS
|
||||||
|
const RefIdDataContainer<ESM::Book>& getBooks() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue