2015-08-03 16:08:01 +00:00
|
|
|
#include "magiceffectcheck.hpp"
|
|
|
|
|
|
|
|
#include <components/misc/resourcehelpers.hpp>
|
|
|
|
|
2018-06-19 22:20:03 +00:00
|
|
|
#include "../prefs/state.hpp"
|
|
|
|
|
2018-08-24 13:57:32 +00:00
|
|
|
std::string CSMTools::MagicEffectCheckStage::checkTexture(const std::string &texture, bool isIcon) const
|
2015-08-03 16:08:01 +00:00
|
|
|
{
|
|
|
|
const CSMWorld::Resources &textures = isIcon ? mIcons : mTextures;
|
2018-08-24 13:57:32 +00:00
|
|
|
if (textures.searchId(texture) != -1) return std::string();
|
2015-08-03 16:08:01 +00:00
|
|
|
|
2018-08-24 13:57:32 +00:00
|
|
|
std::string ddsTexture = texture;
|
|
|
|
if (Misc::ResourceHelpers::changeExtensionToDds(ddsTexture) && textures.searchId(ddsTexture) != -1) return std::string();
|
2015-08-03 16:08:01 +00:00
|
|
|
|
2018-08-24 13:57:32 +00:00
|
|
|
return (isIcon ? "Icon '" : "Particle '") + texture + "' does not exist";
|
2015-08-03 16:08:01 +00:00
|
|
|
}
|
|
|
|
|
2018-08-24 13:57:32 +00:00
|
|
|
std::string CSMTools::MagicEffectCheckStage::checkObject(const std::string &id,
|
2015-08-03 16:08:01 +00:00
|
|
|
const CSMWorld::UniversalId &type,
|
|
|
|
const std::string &column) const
|
|
|
|
{
|
2018-08-24 23:38:02 +00:00
|
|
|
CSMWorld::RefIdData::LocalIndex index = mObjects.getDataSet().searchId(id);
|
|
|
|
if (index.first == -1) return (column + " '" + id + "' " + "does not exist");
|
|
|
|
else if (index.second != type.getType()) return (column + " '" + id + "' " + "does not have " + type.getTypeName() + " type");
|
|
|
|
return std::string();
|
2015-08-03 16:08:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string CSMTools::MagicEffectCheckStage::checkSound(const std::string &id, const std::string &column) const
|
|
|
|
{
|
2018-08-24 23:38:02 +00:00
|
|
|
if (!id.empty() && mSounds.searchId(id) == -1) return (column + " '" + id + "' " + "does not exist");
|
|
|
|
return std::string();
|
2015-08-03 16:08:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CSMTools::MagicEffectCheckStage::MagicEffectCheckStage(const CSMWorld::IdCollection<ESM::MagicEffect> &effects,
|
|
|
|
const CSMWorld::IdCollection<ESM::Sound> &sounds,
|
2018-08-24 13:57:32 +00:00
|
|
|
const CSMWorld::RefIdCollection &objects,
|
2015-08-03 16:08:01 +00:00
|
|
|
const CSMWorld::Resources &icons,
|
|
|
|
const CSMWorld::Resources &textures)
|
|
|
|
: mMagicEffects(effects),
|
|
|
|
mSounds(sounds),
|
2018-08-24 13:57:32 +00:00
|
|
|
mObjects(objects),
|
2015-08-03 16:08:01 +00:00
|
|
|
mIcons(icons),
|
|
|
|
mTextures(textures)
|
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
|
|
|
}
|
2015-08-03 16:08:01 +00:00
|
|
|
|
|
|
|
int CSMTools::MagicEffectCheckStage::setup()
|
|
|
|
{
|
2018-06-19 22:20:03 +00:00
|
|
|
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
|
|
|
|
|
2015-08-03 16:08:01 +00:00
|
|
|
return mMagicEffects.getSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSMTools::MagicEffectCheckStage::perform(int stage, CSMDoc::Messages &messages)
|
|
|
|
{
|
2018-06-19 22:20:03 +00:00
|
|
|
const CSMWorld::Record<ESM::MagicEffect> &record = mMagicEffects.getRecord(stage);
|
|
|
|
|
|
|
|
// 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())
|
2018-06-19 22:20:03 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
ESM::MagicEffect effect = record.get();
|
2015-08-03 16:08:01 +00:00
|
|
|
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_MagicEffect, effect.mId);
|
|
|
|
|
2018-08-24 13:57:32 +00:00
|
|
|
if (effect.mDescription.empty())
|
2015-08-03 16:08:01 +00:00
|
|
|
{
|
2018-08-24 23:38:02 +00:00
|
|
|
messages.add(id, "Description is missing", "", CSMDoc::Message::Severity_Warning);
|
2015-08-03 16:08:01 +00:00
|
|
|
}
|
2018-08-24 20:12:11 +00:00
|
|
|
|
2018-08-24 13:57:32 +00:00
|
|
|
if (effect.mData.mBaseCost < 0.0f)
|
2015-08-03 16:08:01 +00:00
|
|
|
{
|
2018-08-24 23:38:02 +00:00
|
|
|
messages.add(id, "Base cost is negative", "", CSMDoc::Message::Severity_Error);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (effect.mIcon.empty())
|
|
|
|
{
|
|
|
|
messages.add(id, "Icon is missing", "", CSMDoc::Message::Severity_Error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const std::string error = checkTexture(effect.mIcon, true);
|
|
|
|
if (!error.empty())
|
|
|
|
messages.add(id, error, "", CSMDoc::Message::Severity_Error);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!effect.mParticle.empty())
|
|
|
|
{
|
|
|
|
const std::string error = checkTexture(effect.mParticle, false);
|
|
|
|
if (!error.empty())
|
|
|
|
messages.add(id, error, "", CSMDoc::Message::Severity_Error);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!effect.mCasting.empty())
|
|
|
|
{
|
|
|
|
const std::string error = checkObject(effect.mCasting, CSMWorld::UniversalId::Type_Static, "Casting object");
|
|
|
|
if (!error.empty())
|
|
|
|
messages.add(id, error, "", CSMDoc::Message::Severity_Error);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!effect.mHit.empty())
|
|
|
|
{
|
|
|
|
const std::string error = checkObject(effect.mHit, CSMWorld::UniversalId::Type_Static, "Hit object");
|
|
|
|
if (!error.empty())
|
|
|
|
messages.add(id, error, "", CSMDoc::Message::Severity_Error);
|
2015-08-03 16:08:01 +00:00
|
|
|
}
|
|
|
|
|
2018-08-24 23:38:02 +00:00
|
|
|
if (!effect.mArea.empty())
|
|
|
|
{
|
|
|
|
const std::string error = checkObject(effect.mArea, CSMWorld::UniversalId::Type_Static, "Area object");
|
|
|
|
if (!error.empty())
|
|
|
|
messages.add(id, error, "", CSMDoc::Message::Severity_Error);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!effect.mBolt.empty())
|
|
|
|
{
|
|
|
|
const std::string error = checkObject(effect.mBolt, CSMWorld::UniversalId::Type_Static, "Bolt object");
|
|
|
|
if (!error.empty())
|
|
|
|
messages.add(id, error, "", CSMDoc::Message::Severity_Error);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!effect.mCastSound.empty())
|
|
|
|
{
|
|
|
|
const std::string error = checkSound(effect.mCastSound, "Casting sound");
|
|
|
|
if (!error.empty())
|
|
|
|
messages.add(id, error, "", CSMDoc::Message::Severity_Error);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!effect.mHitSound.empty())
|
|
|
|
{
|
|
|
|
const std::string error = checkSound(effect.mHitSound, "Hit sound");
|
|
|
|
if (!error.empty())
|
|
|
|
messages.add(id, error, "", CSMDoc::Message::Severity_Error);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!effect.mAreaSound.empty())
|
|
|
|
{
|
|
|
|
const std::string error = checkSound(effect.mAreaSound, "Area sound");
|
|
|
|
if (!error.empty())
|
|
|
|
messages.add(id, error, "", CSMDoc::Message::Severity_Error);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!effect.mBoltSound.empty())
|
|
|
|
{
|
|
|
|
const std::string error = checkSound(effect.mBoltSound, "Bolt sound");
|
|
|
|
if (!error.empty())
|
|
|
|
messages.add(id, error, "", CSMDoc::Message::Severity_Error);
|
|
|
|
}
|
2015-08-03 16:08:01 +00:00
|
|
|
}
|