1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 18:19:55 +00:00
openmw-tes3mp/apps/opencs/model/tools/soundgencheck.cpp

60 lines
2 KiB
C++
Raw Normal View History

2015-06-13 16:08:31 +00:00
#include "soundgencheck.hpp"
#include <sstream>
#include "../prefs/state.hpp"
2015-06-13 16:08:31 +00:00
#include "../world/refiddata.hpp"
#include "../world/universalid.hpp"
CSMTools::SoundGenCheckStage::SoundGenCheckStage(const CSMWorld::IdCollection<ESM::SoundGenerator> &soundGens,
const CSMWorld::IdCollection<ESM::Sound> &sounds,
const CSMWorld::RefIdCollection &referenceables)
: mSoundGens(soundGens),
mSounds(sounds),
mReferenceables(referenceables)
{
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
}
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);
// Skip "Base" records (setting!) and "Deleted" records
if ((mIgnoreBaseRecords && record.isBaseOnly()) || 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 = mReferenceables.getDataSet().searchId(soundGen.mCreature);
if (creatureIndex.first == -1)
{
messages.push_back(std::make_pair(id, "No such creature '" + soundGen.mCreature + "'"));
}
else if (creatureIndex.second != CSMWorld::UniversalId::Type_Creature)
{
messages.push_back(std::make_pair(id, "'" + soundGen.mCreature + "' is not a creature"));
}
}
if (soundGen.mSound.empty())
{
messages.push_back(std::make_pair(id, "Sound is not specified"));
}
else if (mSounds.searchId(soundGen.mSound) == -1)
2015-06-13 16:08:31 +00:00
{
messages.push_back(std::make_pair(id, "No such sound '" + soundGen.mSound + "'"));
}
}