mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
9d61d76e92
Adds a boolean setting to the user preferences. This setting is locally saved to all OpenMW-CS check stages. When a verification is done, the setting is updated on setup for each check stage. If set to true, the boolean value is then used to skip the verification process for every base record - minus some special cases where, e.g., counters are to be set first. Related issue: - Fixes #4466: Editor: Add option to ignore base records when running verifier (https://gitlab.com/OpenMW/openmw/issues/4466) Tests: The changes were successfully tested in OpenMW-CS by creating faulty "Base" and "Modified" records for every record type (if possible) and, then, running the verifier with and without the option respectively.
83 lines
2.5 KiB
C++
83 lines
2.5 KiB
C++
#include "racecheck.hpp"
|
|
|
|
#include <sstream>
|
|
|
|
#include <components/esm/loadrace.hpp>
|
|
|
|
#include "../prefs/state.hpp"
|
|
|
|
#include "../world/universalid.hpp"
|
|
|
|
void CSMTools::RaceCheckStage::performPerRecord (int stage, CSMDoc::Messages& messages)
|
|
{
|
|
const CSMWorld::Record<ESM::Race>& record = mRaces.getRecord (stage);
|
|
|
|
if (record.isDeleted())
|
|
return;
|
|
|
|
const ESM::Race& race = record.get();
|
|
|
|
// Consider mPlayable flag even when "Base" records are ignored
|
|
if (race.mData.mFlags & 0x1)
|
|
mPlayable = true;
|
|
|
|
// Skip "Base" records (setting!)
|
|
if (mIgnoreBaseRecords && record.isBaseOnly())
|
|
return;
|
|
|
|
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Race, race.mId);
|
|
|
|
// test for empty name and description
|
|
if (race.mName.empty())
|
|
messages.push_back (std::make_pair (id, race.mId + " has an empty name"));
|
|
|
|
if (race.mDescription.empty())
|
|
messages.push_back (std::make_pair (id, race.mId + " has an empty description"));
|
|
|
|
// test for positive height
|
|
if (race.mData.mHeight.mMale<=0)
|
|
messages.push_back (std::make_pair (id, "male " + race.mId + " has non-positive height"));
|
|
|
|
if (race.mData.mHeight.mFemale<=0)
|
|
messages.push_back (std::make_pair (id, "female " + race.mId + " has non-positive height"));
|
|
|
|
// test for non-negative weight
|
|
if (race.mData.mWeight.mMale<0)
|
|
messages.push_back (std::make_pair (id, "male " + race.mId + " has negative weight"));
|
|
|
|
if (race.mData.mWeight.mFemale<0)
|
|
messages.push_back (std::make_pair (id, "female " + race.mId + " has negative weight"));
|
|
|
|
/// \todo check data members that can't be edited in the table view
|
|
}
|
|
|
|
void CSMTools::RaceCheckStage::performFinal (CSMDoc::Messages& messages)
|
|
{
|
|
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Races);
|
|
|
|
if (!mPlayable)
|
|
messages.push_back (std::make_pair (id, "No playable race"));
|
|
}
|
|
|
|
CSMTools::RaceCheckStage::RaceCheckStage (const CSMWorld::IdCollection<ESM::Race>& races)
|
|
: mRaces (races), mPlayable (false)
|
|
{
|
|
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
|
|
}
|
|
|
|
int CSMTools::RaceCheckStage::setup()
|
|
{
|
|
mPlayable = false;
|
|
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
|
|
|
|
return mRaces.getSize()+1;
|
|
}
|
|
|
|
void CSMTools::RaceCheckStage::perform (int stage, CSMDoc::Messages& messages)
|
|
{
|
|
if (stage==mRaces.getSize())
|
|
performFinal (messages);
|
|
else
|
|
performPerRecord (stage, messages);
|
|
}
|