2014-08-26 15:55:31 +00:00
|
|
|
#include "bodypartcheck.hpp"
|
|
|
|
|
2018-06-19 22:20:03 +00:00
|
|
|
#include "../prefs/state.hpp"
|
|
|
|
|
2014-08-26 15:55:31 +00:00
|
|
|
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)
|
2018-06-19 22:20:03 +00:00
|
|
|
{
|
2018-06-20 09:29:38 +00:00
|
|
|
mIgnoreBaseRecords = false;
|
2018-06-19 22:20:03 +00:00
|
|
|
}
|
2014-08-26 15:55:31 +00:00
|
|
|
|
|
|
|
int CSMTools::BodyPartCheckStage::setup()
|
|
|
|
{
|
2018-06-19 22:20:03 +00:00
|
|
|
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
|
|
|
|
|
2014-08-26 15:55:31 +00:00
|
|
|
return mBodyParts.getSize();
|
|
|
|
}
|
|
|
|
|
2014-12-07 17:57:47 +00:00
|
|
|
void CSMTools::BodyPartCheckStage::perform (int stage, CSMDoc::Messages &messages)
|
2014-08-26 15:55:31 +00:00
|
|
|
{
|
|
|
|
const CSMWorld::Record<ESM::BodyPart> &record = mBodyParts.getRecord(stage);
|
|
|
|
|
2018-06-19 22:20:03 +00:00
|
|
|
// Skip "Base" records (setting!) and "Deleted" records
|
2018-06-20 09:29:38 +00:00
|
|
|
if ((mIgnoreBaseRecords && record.mState == CSMWorld::RecordBase::State_BaseOnly) || record.isDeleted())
|
2014-08-26 15:55:31 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
const ESM::BodyPart &bodyPart = record.get();
|
|
|
|
|
|
|
|
CSMWorld::UniversalId id( CSMWorld::UniversalId::Type_BodyPart, bodyPart.mId );
|
|
|
|
|
|
|
|
// Check BYDT
|
2014-09-11 12:19:18 +00:00
|
|
|
if (bodyPart.mData.mPart > 14 )
|
2018-08-25 00:49:10 +00:00
|
|
|
messages.add(id, "Invalid part", "", CSMDoc::Message::Severity_Error);
|
2014-08-26 15:55:31 +00:00
|
|
|
|
2014-09-11 12:19:18 +00:00
|
|
|
if (bodyPart.mData.mFlags > 3 )
|
2018-08-25 00:49:10 +00:00
|
|
|
messages.add(id, "Invalid flags", "", CSMDoc::Message::Severity_Error);
|
2014-08-26 15:55:31 +00:00
|
|
|
|
2014-09-11 12:19:18 +00:00
|
|
|
if (bodyPart.mData.mType > 2 )
|
2018-08-25 00:49:10 +00:00
|
|
|
messages.add(id, "Invalid type", "", CSMDoc::Message::Severity_Error);
|
2014-08-26 15:55:31 +00:00
|
|
|
|
|
|
|
// Check MODL
|
|
|
|
if ( bodyPart.mModel.empty() )
|
2018-08-25 00:49:10 +00:00
|
|
|
messages.add(id, "Model is missing", "", CSMDoc::Message::Severity_Error);
|
2014-08-26 15:55:31 +00:00
|
|
|
else if ( mMeshes.searchId( bodyPart.mModel ) == -1 )
|
2018-08-25 00:49:10 +00:00
|
|
|
messages.add(id, "Model '" + bodyPart.mModel + "' does not exist", "", CSMDoc::Message::Severity_Error);
|
2014-08-26 15:55:31 +00:00
|
|
|
|
|
|
|
// Check FNAM
|
|
|
|
if ( bodyPart.mRace.empty() )
|
2018-08-25 00:49:10 +00:00
|
|
|
messages.add(id, "Race is missing", "", CSMDoc::Message::Severity_Error);
|
2014-08-26 15:55:31 +00:00
|
|
|
else if ( mRaces.searchId( bodyPart.mRace ) == -1 )
|
2018-08-25 00:49:10 +00:00
|
|
|
messages.add(id, "Race '" + bodyPart.mRace + " does not exist", "", CSMDoc::Message::Severity_Error);
|
2014-09-03 12:40:32 +00:00
|
|
|
}
|