2013-04-06 19:48:52 +00:00
|
|
|
#include "soundcheck.hpp"
|
|
|
|
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <string>
|
|
|
|
|
2018-06-19 22:20:03 +00:00
|
|
|
#include "../prefs/state.hpp"
|
|
|
|
|
2013-04-06 19:48:52 +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 <apps/opencs/model/world/resources.hpp>
|
|
|
|
|
|
|
|
#include <components/esm3/loadsoun.hpp>
|
|
|
|
|
2018-08-24 21:47:38 +00:00
|
|
|
CSMTools::SoundCheckStage::SoundCheckStage(
|
|
|
|
const CSMWorld::IdCollection<ESM::Sound>& sounds, const CSMWorld::Resources& soundfiles)
|
|
|
|
: mSounds(sounds)
|
|
|
|
, mSoundFiles(soundfiles)
|
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
|
|
|
}
|
2013-04-06 19:48:52 +00:00
|
|
|
|
|
|
|
int CSMTools::SoundCheckStage::setup()
|
|
|
|
{
|
2018-06-19 22:20:03 +00:00
|
|
|
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
|
|
|
|
|
2013-04-06 19:48:52 +00:00
|
|
|
return mSounds.getSize();
|
|
|
|
}
|
|
|
|
|
2014-12-07 17:57:47 +00:00
|
|
|
void CSMTools::SoundCheckStage::perform(int stage, CSMDoc::Messages& messages)
|
2013-04-06 19:48:52 +00:00
|
|
|
{
|
2013-09-27 08:08:09 +00:00
|
|
|
const CSMWorld::Record<ESM::Sound>& record = mSounds.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())
|
2013-09-27 08:08:09 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
const ESM::Sound& sound = record.get();
|
2013-04-06 19:48:52 +00:00
|
|
|
|
|
|
|
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Sound, sound.mId);
|
|
|
|
|
|
|
|
if (sound.mData.mMinRange > sound.mData.mMaxRange)
|
2018-08-25 00:49:10 +00:00
|
|
|
{
|
2018-09-14 18:42:11 +00:00
|
|
|
messages.add(id, "Minimum range is larger than maximum range", "", CSMDoc::Message::Severity_Warning);
|
2018-08-25 00:49:10 +00:00
|
|
|
}
|
2013-04-06 19:48:52 +00:00
|
|
|
|
2018-08-24 21:47:38 +00:00
|
|
|
if (sound.mSound.empty())
|
|
|
|
{
|
2018-08-25 00:49:10 +00:00
|
|
|
messages.add(id, "Sound file is missing", "", CSMDoc::Message::Severity_Error);
|
2018-08-24 21:47:38 +00:00
|
|
|
}
|
|
|
|
else if (mSoundFiles.searchId(sound.mSound) == -1)
|
|
|
|
{
|
2018-08-25 00:49:10 +00:00
|
|
|
messages.add(id, "Sound file '" + sound.mSound + "' does not exist", "", CSMDoc::Message::Severity_Error);
|
2018-08-24 21:47:38 +00:00
|
|
|
}
|
2015-03-11 14:54:45 +00:00
|
|
|
}
|