1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-17 19:10:24 +00:00
OpenMW/apps/opencs/model/tools/soundgencheck.cpp

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

72 lines
2.4 KiB
C++
Raw Normal View History

2015-06-13 16:08:31 +00:00
#include "soundgencheck.hpp"
2022-10-19 17:02:00 +00:00
#include <string>
#include "../prefs/state.hpp"
2015-06-13 16:08:31 +00:00
#include "../world/refiddata.hpp"
#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/refidcollection.hpp>
2022-08-19 17:19:42 +00:00
#include <components/esm3/loadsndg.hpp>
#include <components/esm3/loadsoun.hpp>
2015-06-13 16:08:31 +00:00
CSMTools::SoundGenCheckStage::SoundGenCheckStage(const CSMWorld::IdCollection<ESM::SoundGenerator>& soundGens,
const CSMWorld::IdCollection<ESM::Sound>& sounds, const CSMWorld::RefIdCollection& objects)
: mSoundGens(soundGens)
, mSounds(sounds)
, mObjects(objects)
{
mIgnoreBaseRecords = false;
}
2015-06-13 16:08:31 +00:00
int CSMTools::SoundGenCheckStage::setup()
{
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
2015-06-13 16:08:31 +00:00
return mSoundGens.getSize();
}
void CSMTools::SoundGenCheckStage::perform(int stage, CSMDoc::Messages& messages)
{
const CSMWorld::Record<ESM::SoundGenerator>& record = mSoundGens.getRecord(stage);
2022-09-22 18:26:05 +00:00
// Skip "Base" records (setting!) and "Deleted" records
if ((mIgnoreBaseRecords && record.mState == CSMWorld::RecordBase::State_BaseOnly) || record.isDeleted())
2015-06-13 16:08:31 +00:00
return;
2016-01-03 17:20:34 +00:00
const ESM::SoundGenerator& soundGen = record.get();
2015-06-13 16:08:31 +00:00
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_SoundGen, soundGen.mId);
if (!soundGen.mCreature.empty())
2015-06-13 16:08:31 +00:00
{
CSMWorld::RefIdData::LocalIndex creatureIndex = mObjects.getDataSet().searchId(soundGen.mCreature);
2015-06-13 16:08:31 +00:00
if (creatureIndex.first == -1)
{
messages.add(id, "Creature '" + soundGen.mCreature.getRefIdString() + "' doesn't exist", "",
CSMDoc::Message::Severity_Error);
2015-06-13 16:08:31 +00:00
}
else if (creatureIndex.second != CSMWorld::UniversalId::Type_Creature)
{
messages.add(id, "'" + soundGen.mCreature.getRefIdString() + "' is not a creature", "",
CSMDoc::Message::Severity_Error);
2015-06-13 16:08:31 +00:00
}
}
if (soundGen.mSound.empty())
{
messages.add(id, "Sound is missing", "", CSMDoc::Message::Severity_Error);
}
else if (mSounds.searchId(soundGen.mSound) == -1)
2015-06-13 16:08:31 +00:00
{
messages.add(
id, "Sound '" + soundGen.mSound.getRefIdString() + "' doesn't exist", "", CSMDoc::Message::Severity_Error);
2015-06-13 16:08:31 +00:00
}
}