mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
Feature #1616: Body part record verifier
This commit is contained in:
parent
2cbe17ca0a
commit
bdfb0c8351
@ -38,7 +38,7 @@ opencs_units (model/tools
|
||||
|
||||
opencs_units_noqt (model/tools
|
||||
mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck
|
||||
birthsigncheck spellcheck referenceablecheck scriptcheck
|
||||
birthsigncheck spellcheck referenceablecheck scriptcheck bodypartcheck
|
||||
)
|
||||
|
||||
|
||||
|
55
apps/opencs/model/tools/bodypartcheck.cpp
Normal file
55
apps/opencs/model/tools/bodypartcheck.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include "bodypartcheck.hpp"
|
||||
|
||||
CSMTools::BodyPartCheckStage::BodyPartCheckStage(
|
||||
const CSMWorld::IdCollection<ESM::BodyPart> &bodyParts,
|
||||
const CSMWorld::Resources &meshes,
|
||||
const CSMWorld::IdCollection<ESM::Race> &races ) :
|
||||
mBodyParts(bodyParts),
|
||||
mMeshes(meshes),
|
||||
mRaces(races)
|
||||
{ }
|
||||
|
||||
int CSMTools::BodyPartCheckStage::setup()
|
||||
{
|
||||
return mBodyParts.getSize();
|
||||
}
|
||||
|
||||
void CSMTools::BodyPartCheckStage::perform ( int stage, Messages &messages )
|
||||
{
|
||||
const CSMWorld::Record<ESM::BodyPart> &record = mBodyParts.getRecord(stage);
|
||||
|
||||
if ( record.isDeleted() )
|
||||
return;
|
||||
|
||||
const ESM::BodyPart &bodyPart = record.get();
|
||||
|
||||
CSMWorld::UniversalId id( CSMWorld::UniversalId::Type_BodyPart, bodyPart.mId );
|
||||
|
||||
// Check BYDT
|
||||
|
||||
if ( bodyPart.mData.mPart < 0 || bodyPart.mData.mPart > 14 )
|
||||
messages.push_back(std::make_pair( id, bodyPart.mId + " has out of range part value." ));
|
||||
|
||||
if ( bodyPart.mData.mVampire < 0 )
|
||||
messages.push_back(std::make_pair( id, bodyPart.mId + " has negative vampire flag." ));
|
||||
|
||||
if ( bodyPart.mData.mFlags < 0 || bodyPart.mData.mFlags > 2 )
|
||||
messages.push_back(std::make_pair( id, bodyPart.mId + " has out of range flags value." ));
|
||||
|
||||
if ( bodyPart.mData.mType < 0 || bodyPart.mData.mType > 2 )
|
||||
messages.push_back(std::make_pair( id, bodyPart.mId + " has out of range type value." ));
|
||||
|
||||
// Check MODL
|
||||
|
||||
if ( bodyPart.mModel.empty() )
|
||||
messages.push_back(std::make_pair( id, bodyPart.mId + " has no model." ));
|
||||
else if ( mMeshes.searchId( bodyPart.mModel ) == -1 )
|
||||
messages.push_back(std::make_pair( id, bodyPart.mId + " has unreferenced model." ));
|
||||
|
||||
// Check FNAM
|
||||
|
||||
if ( bodyPart.mRace.empty() )
|
||||
messages.push_back(std::make_pair( id, bodyPart.mId + " has no race." ));
|
||||
else if ( mRaces.searchId( bodyPart.mRace ) == -1 )
|
||||
messages.push_back(std::make_pair( id, bodyPart.mId + " has invalid race." ));
|
||||
}
|
35
apps/opencs/model/tools/bodypartcheck.hpp
Normal file
35
apps/opencs/model/tools/bodypartcheck.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef CSM_TOOLS_BODYPARTCHECK_H
|
||||
#define CSM_TOOLS_BODYPARTCHECK_H
|
||||
|
||||
#include <components/esm/loadbody.hpp>
|
||||
#include <components/esm/loadrace.hpp>
|
||||
|
||||
#include "../world/resources.hpp"
|
||||
#include "../world/idcollection.hpp"
|
||||
|
||||
#include "../doc/stage.hpp"
|
||||
|
||||
namespace CSMTools
|
||||
{
|
||||
/// \brief VerifyStage: make sure that body part records are internally consistent
|
||||
class BodyPartCheckStage : public CSMDoc::Stage
|
||||
{
|
||||
const CSMWorld::IdCollection<ESM::BodyPart> &mBodyParts;
|
||||
const CSMWorld::Resources &mMeshes;
|
||||
const CSMWorld::IdCollection<ESM::Race> &mRaces;
|
||||
|
||||
public:
|
||||
BodyPartCheckStage(
|
||||
const CSMWorld::IdCollection<ESM::BodyPart> &bodyParts,
|
||||
const CSMWorld::Resources &meshes,
|
||||
const CSMWorld::IdCollection<ESM::Race> &races );
|
||||
|
||||
virtual int setup();
|
||||
///< \return number of steps
|
||||
|
||||
virtual void perform( int stage, Messages &messages );
|
||||
///< Messages resulting from this tage will be appended to \a messages.
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -22,6 +22,7 @@
|
||||
#include "spellcheck.hpp"
|
||||
#include "referenceablecheck.hpp"
|
||||
#include "scriptcheck.hpp"
|
||||
#include "bodypartcheck.hpp"
|
||||
|
||||
CSMDoc::Operation *CSMTools::Tools::get (int type)
|
||||
{
|
||||
@ -79,9 +80,16 @@ CSMDoc::Operation *CSMTools::Tools::getVerifier()
|
||||
|
||||
mVerifier->appendStage (new SpellCheckStage (mData.getSpells()));
|
||||
|
||||
mVerifier->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses(), mData.getFactions()));
|
||||
mVerifier->appendStage (new ReferenceableCheckStage (mData.getReferenceables().getDataSet(), mData.getRaces(), mData.getClasses(), mData.getFactions()));
|
||||
|
||||
mVerifier->appendStage (new ScriptCheckStage (mDocument));
|
||||
|
||||
mVerifier->appendStage(
|
||||
new BodyPartCheckStage(
|
||||
mData.getBodyParts(),
|
||||
mData.getResources(
|
||||
CSMWorld::UniversalId( CSMWorld::UniversalId::Type_Meshes )),
|
||||
mData.getRaces() ));
|
||||
}
|
||||
|
||||
return mVerifier;
|
||||
|
Loading…
Reference in New Issue
Block a user