mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Merge remote-tracking branch 'smbas/feature-soundgen-verifier'
This commit is contained in:
commit
675884ba30
4 changed files with 89 additions and 1 deletions
|
@ -41,7 +41,7 @@ opencs_units (model/tools
|
||||||
opencs_units_noqt (model/tools
|
opencs_units_noqt (model/tools
|
||||||
mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck
|
mandatoryid skillcheck classcheck factioncheck racecheck soundcheck regioncheck
|
||||||
birthsigncheck spellcheck referencecheck referenceablecheck scriptcheck bodypartcheck
|
birthsigncheck spellcheck referencecheck referenceablecheck scriptcheck bodypartcheck
|
||||||
startscriptcheck search searchoperation searchstage pathgridcheck
|
startscriptcheck search searchoperation searchstage pathgridcheck soundgencheck
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
53
apps/opencs/model/tools/soundgencheck.cpp
Normal file
53
apps/opencs/model/tools/soundgencheck.cpp
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#include "soundgencheck.hpp"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#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)
|
||||||
|
{}
|
||||||
|
|
||||||
|
int CSMTools::SoundGenCheckStage::setup()
|
||||||
|
{
|
||||||
|
return mSoundGens.getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMTools::SoundGenCheckStage::perform(int stage, CSMDoc::Messages &messages)
|
||||||
|
{
|
||||||
|
const CSMWorld::Record<ESM::SoundGenerator> &record = mSoundGens.getRecord(stage);
|
||||||
|
if (record.isDeleted())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ESM::SoundGenerator soundGen = record.get();
|
||||||
|
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_SoundGen, soundGen.mId);
|
||||||
|
|
||||||
|
if (!soundGen.mCreature.empty())
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
messages.push_back(std::make_pair(id, "No such sound '" + soundGen.mSound + "'"));
|
||||||
|
}
|
||||||
|
}
|
30
apps/opencs/model/tools/soundgencheck.hpp
Normal file
30
apps/opencs/model/tools/soundgencheck.hpp
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef CSM_TOOLS_SOUNDGENCHECK_HPP
|
||||||
|
#define CSM_TOOLS_SOUNDGENCHECK_HPP
|
||||||
|
|
||||||
|
#include "../world/data.hpp"
|
||||||
|
|
||||||
|
#include "../doc/stage.hpp"
|
||||||
|
|
||||||
|
namespace CSMTools
|
||||||
|
{
|
||||||
|
/// \brief VerifyStage: make sure that sound gen records are internally consistent
|
||||||
|
class SoundGenCheckStage : public CSMDoc::Stage
|
||||||
|
{
|
||||||
|
const CSMWorld::IdCollection<ESM::SoundGenerator> &mSoundGens;
|
||||||
|
const CSMWorld::IdCollection<ESM::Sound> &mSounds;
|
||||||
|
const CSMWorld::RefIdCollection &mReferenceables;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SoundGenCheckStage(const CSMWorld::IdCollection<ESM::SoundGenerator> &soundGens,
|
||||||
|
const CSMWorld::IdCollection<ESM::Sound> &sounds,
|
||||||
|
const CSMWorld::RefIdCollection &referenceables);
|
||||||
|
|
||||||
|
virtual int setup();
|
||||||
|
///< \return number of steps
|
||||||
|
|
||||||
|
virtual void perform(int stage, CSMDoc::Messages &messages);
|
||||||
|
///< Messages resulting from this stage will be appended to \a messages.
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -27,6 +27,7 @@
|
||||||
#include "startscriptcheck.hpp"
|
#include "startscriptcheck.hpp"
|
||||||
#include "searchoperation.hpp"
|
#include "searchoperation.hpp"
|
||||||
#include "pathgridcheck.hpp"
|
#include "pathgridcheck.hpp"
|
||||||
|
#include "soundgencheck.hpp"
|
||||||
|
|
||||||
CSMDoc::OperationHolder *CSMTools::Tools::get (int type)
|
CSMDoc::OperationHolder *CSMTools::Tools::get (int type)
|
||||||
{
|
{
|
||||||
|
@ -99,6 +100,10 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier()
|
||||||
|
|
||||||
mVerifierOperation->appendStage (new PathgridCheckStage (mData.getPathgrids()));
|
mVerifierOperation->appendStage (new PathgridCheckStage (mData.getPathgrids()));
|
||||||
|
|
||||||
|
mVerifierOperation->appendStage (new SoundGenCheckStage (mData.getSoundGens(),
|
||||||
|
mData.getSounds(),
|
||||||
|
mData.getReferenceables()));
|
||||||
|
|
||||||
mVerifier.setOperation (mVerifierOperation);
|
mVerifier.setOperation (mVerifierOperation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue