1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-27 03:35:27 +00:00
OpenMW/apps/opencs/model/tools/regioncheck.cpp

63 lines
2.0 KiB
C++
Raw Normal View History

2013-04-07 19:39:13 +02:00
#include "regioncheck.hpp"
2022-10-19 19:02:00 +02:00
#include <string>
#include <vector>
#include "../prefs/state.hpp"
2013-04-07 19:39:13 +02:00
#include "../world/universalid.hpp"
2022-10-19 19:02:00 +02: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/loadregn.hpp>
2022-09-22 21:26:05 +03:00
CSMTools::RegionCheckStage::RegionCheckStage(const CSMWorld::IdCollection<ESM::Region>& regions)
: mRegions(regions)
{
mIgnoreBaseRecords = false;
}
2013-04-07 19:39:13 +02:00
int CSMTools::RegionCheckStage::setup()
{
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
2013-04-07 19:39:13 +02:00
return mRegions.getSize();
}
2022-09-22 21:26:05 +03:00
void CSMTools::RegionCheckStage::perform(int stage, CSMDoc::Messages& messages)
2013-04-07 19:39:13 +02:00
{
2022-09-22 21:26:05 +03:00
const CSMWorld::Record<ESM::Region>& record = mRegions.getRecord(stage);
2013-09-27 10:08:09 +02:00
// Skip "Base" records (setting!) and "Deleted" records
if ((mIgnoreBaseRecords && record.mState == CSMWorld::RecordBase::State_BaseOnly) || record.isDeleted())
2013-09-27 10:08:09 +02:00
return;
const ESM::Region& region = record.get();
2013-04-07 19:39:13 +02:00
2022-09-22 21:26:05 +03:00
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Region, region.mId);
2013-04-07 19:39:13 +02:00
// test for empty name
if (region.mName.empty())
messages.add(id, "Name is missing", "", CSMDoc::Message::Severity_Error);
2013-04-07 19:39:13 +02:00
/// \todo test that the ID in mSleeplist exists
// test that chances add up to 100
auto chances = std::accumulate(region.mData.mProbabilities.begin(), region.mData.mProbabilities.end(), 0u);
if (chances != 100)
messages.add(id, "Weather chances do not add up to 100", "", CSMDoc::Message::Severity_Error);
for (const ESM::Region::SoundRef& sound : region.mSoundList)
{
if (sound.mChance > 100)
messages.add(id, "Chance of '" + sound.mSound.getRefIdString() + "' sound to play is over 100 percent", "",
2022-09-22 21:26:05 +03:00
CSMDoc::Message::Severity_Warning);
}
2013-04-07 19:39:13 +02:00
/// \todo check data members that can't be edited in the table view
2015-03-11 10:54:45 -04:00
}