1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-23 20:53:54 +00:00
openmw/apps/opencs/model/tools/racecheck.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
2.8 KiB
C++
Raw Normal View History

2013-04-06 15:35:36 +00:00
#include "racecheck.hpp"
2022-10-19 17:02:00 +00:00
#include <string>
#include "../prefs/state.hpp"
2013-04-06 15:35:36 +00:00
#include "../world/universalid.hpp"
2022-10-19 17:02:00 +00:00
#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 <components/esm3/loadrace.hpp>
void CSMTools::RaceCheckStage::performPerRecord(int stage, CSMDoc::Messages& messages)
2013-04-06 15:35:36 +00:00
{
2013-09-27 08:08:09 +00:00
const CSMWorld::Record<ESM::Race>& record = mRaces.getRecord(stage);
if (record.isDeleted())
return;
const ESM::Race& race = record.get();
2013-04-06 15:35:36 +00:00
// Consider mPlayable flag even when "Base" records are ignored
if (race.mData.mFlags & 0x1)
mPlayable = true;
// Skip "Base" records (setting!)
if (mIgnoreBaseRecords && record.mState == CSMWorld::RecordBase::State_BaseOnly)
return;
2013-04-06 15:35:36 +00:00
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Race, race.mId);
// test for empty name and description
2018-09-14 18:42:11 +00:00
if (race.mName.empty())
messages.add(id, "Name is missing", "",
(race.mData.mFlags & 0x1) ? CSMDoc::Message::Severity_Error : CSMDoc::Message::Severity_Warning);
2013-04-06 15:35:36 +00:00
if (race.mDescription.empty())
messages.add(id, "Description is missing", "", CSMDoc::Message::Severity_Warning);
2013-04-06 15:35:36 +00:00
// test for positive height
if (race.mData.mHeight.mMale <= 0)
messages.add(id, "Male height is non-positive", "", CSMDoc::Message::Severity_Error);
2013-04-06 15:35:36 +00:00
if (race.mData.mHeight.mFemale <= 0)
messages.add(id, "Female height is non-positive", "", CSMDoc::Message::Severity_Error);
2013-04-06 15:35:36 +00:00
// test for non-negative weight
if (race.mData.mWeight.mMale < 0)
messages.add(id, "Male weight is negative", "", CSMDoc::Message::Severity_Error);
2013-04-06 15:35:36 +00:00
if (race.mData.mWeight.mFemale < 0)
messages.add(id, "Female weight is negative", "", CSMDoc::Message::Severity_Error);
2013-04-06 15:35:36 +00:00
/// \todo check data members that can't be edited in the table view
2013-04-06 17:20:59 +00:00
}
void CSMTools::RaceCheckStage::performFinal(CSMDoc::Messages& messages)
2013-04-06 17:20:59 +00:00
{
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Races);
if (!mPlayable)
messages.add(id, "No playable race", "", CSMDoc::Message::Severity_SeriousError);
2013-04-06 17:20:59 +00:00
}
CSMTools::RaceCheckStage::RaceCheckStage(const CSMWorld::IdCollection<ESM::Race>& races)
: mRaces(races)
, mPlayable(false)
{
mIgnoreBaseRecords = false;
}
2013-04-06 17:20:59 +00:00
int CSMTools::RaceCheckStage::setup()
{
mPlayable = false;
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
2013-04-06 17:20:59 +00:00
return mRaces.getSize() + 1;
}
void CSMTools::RaceCheckStage::perform(int stage, CSMDoc::Messages& messages)
2013-04-06 17:20:59 +00:00
{
if (stage == mRaces.getSize())
performFinal(messages);
else
performPerRecord(stage, messages);
2015-03-11 14:54:45 +00:00
}