2014-08-26 15:55:31 +00:00
|
|
|
#include "bodypartcheck.hpp"
|
|
|
|
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <apps/opencs/model/doc/messages.hpp>
|
|
|
|
#include <apps/opencs/model/prefs/category.hpp>
|
|
|
|
#include <apps/opencs/model/prefs/setting.hpp>
|
|
|
|
#include <apps/opencs/model/world/idcollection.hpp>
|
|
|
|
#include <apps/opencs/model/world/record.hpp>
|
|
|
|
#include <apps/opencs/model/world/resources.hpp>
|
|
|
|
#include <apps/opencs/model/world/universalid.hpp>
|
|
|
|
|
|
|
|
#include <components/esm3/loadbody.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
|
2020-05-08 21:31:10 +00:00
|
|
|
if (bodyPart.mData.mPart >= ESM::BodyPart::MP_Count)
|
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
|
|
|
|
2020-05-08 21:31:10 +00:00
|
|
|
if (bodyPart.mData.mType > ESM::BodyPart::MT_Armor)
|
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
|
|
|
|
2020-05-08 21:31:10 +00:00
|
|
|
// Check FNAM for skin body parts (for non-skin body parts it's meaningless)
|
|
|
|
if (bodyPart.mData.mType == ESM::BodyPart::MT_Skin)
|
|
|
|
{
|
|
|
|
if (bodyPart.mRace.empty())
|
|
|
|
messages.add(id, "Race is missing", "", CSMDoc::Message::Severity_Error);
|
|
|
|
else if (mRaces.searchId(bodyPart.mRace) == -1)
|
2022-10-18 07:26:55 +00:00
|
|
|
messages.add(id, "Race '" + bodyPart.mRace.getRefIdString() + "' does not exist", "",
|
|
|
|
CSMDoc::Message::Severity_Error);
|
2020-05-08 21:31:10 +00:00
|
|
|
}
|
2014-09-03 12:40:32 +00:00
|
|
|
}
|