mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 01:45:33 +00:00
9d61d76e92
Adds a boolean setting to the user preferences. This setting is locally saved to all OpenMW-CS check stages. When a verification is done, the setting is updated on setup for each check stage. If set to true, the boolean value is then used to skip the verification process for every base record - minus some special cases where, e.g., counters are to be set first. Related issue: - Fixes #4466: Editor: Add option to ignore base records when running verifier (https://gitlab.com/OpenMW/openmw/issues/4466) Tests: The changes were successfully tested in OpenMW-CS by creating faulty "Base" and "Modified" records for every record type (if possible) and, then, running the verifier with and without the option respectively.
145 lines
4.9 KiB
C++
145 lines
4.9 KiB
C++
#include "magiceffectcheck.hpp"
|
|
|
|
#include <components/misc/resourcehelpers.hpp>
|
|
|
|
#include "../prefs/state.hpp"
|
|
|
|
#include "../world/resources.hpp"
|
|
#include "../world/data.hpp"
|
|
|
|
namespace
|
|
{
|
|
void addMessageIfNotEmpty(CSMDoc::Messages &messages, const CSMWorld::UniversalId &id, const std::string& text)
|
|
{
|
|
if (!text.empty())
|
|
{
|
|
messages.push_back(std::make_pair(id, text));
|
|
}
|
|
}
|
|
}
|
|
|
|
bool CSMTools::MagicEffectCheckStage::isTextureExists(const std::string &texture, bool isIcon) const
|
|
{
|
|
const CSMWorld::Resources &textures = isIcon ? mIcons : mTextures;
|
|
bool exists = false;
|
|
|
|
if (textures.searchId(texture) != -1)
|
|
{
|
|
exists = true;
|
|
}
|
|
else
|
|
{
|
|
std::string ddsTexture = texture;
|
|
if (Misc::ResourceHelpers::changeExtensionToDds(ddsTexture) && textures.searchId(ddsTexture) != -1)
|
|
{
|
|
exists = true;
|
|
}
|
|
}
|
|
|
|
return exists;
|
|
}
|
|
|
|
std::string CSMTools::MagicEffectCheckStage::checkReferenceable(const std::string &id,
|
|
const CSMWorld::UniversalId &type,
|
|
const std::string &column) const
|
|
{
|
|
std::string error;
|
|
if (!id.empty())
|
|
{
|
|
CSMWorld::RefIdData::LocalIndex index = mReferenceables.getDataSet().searchId(id);
|
|
if (index.first == -1)
|
|
{
|
|
error = "No such " + column + " '" + id + "'";
|
|
}
|
|
else if (index.second != type.getType())
|
|
{
|
|
error = column + " is not of type " + type.getTypeName();
|
|
}
|
|
}
|
|
return error;
|
|
}
|
|
|
|
std::string CSMTools::MagicEffectCheckStage::checkSound(const std::string &id, const std::string &column) const
|
|
{
|
|
std::string error;
|
|
if (!id.empty() && mSounds.searchId(id) == -1)
|
|
{
|
|
error = "No such " + column + " '" + id + "'";
|
|
}
|
|
return error;
|
|
}
|
|
|
|
CSMTools::MagicEffectCheckStage::MagicEffectCheckStage(const CSMWorld::IdCollection<ESM::MagicEffect> &effects,
|
|
const CSMWorld::IdCollection<ESM::Sound> &sounds,
|
|
const CSMWorld::RefIdCollection &referenceables,
|
|
const CSMWorld::Resources &icons,
|
|
const CSMWorld::Resources &textures)
|
|
: mMagicEffects(effects),
|
|
mSounds(sounds),
|
|
mReferenceables(referenceables),
|
|
mIcons(icons),
|
|
mTextures(textures)
|
|
{
|
|
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
|
|
}
|
|
|
|
int CSMTools::MagicEffectCheckStage::setup()
|
|
{
|
|
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
|
|
|
|
return mMagicEffects.getSize();
|
|
}
|
|
|
|
void CSMTools::MagicEffectCheckStage::perform(int stage, CSMDoc::Messages &messages)
|
|
{
|
|
const CSMWorld::Record<ESM::MagicEffect> &record = mMagicEffects.getRecord(stage);
|
|
|
|
// Skip "Base" records (setting!) and "Deleted" records
|
|
if ((mIgnoreBaseRecords && record.isBaseOnly()) || record.isDeleted())
|
|
return;
|
|
|
|
ESM::MagicEffect effect = record.get();
|
|
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_MagicEffect, effect.mId);
|
|
|
|
if (effect.mData.mBaseCost < 0.0f)
|
|
{
|
|
messages.push_back(std::make_pair(id, "Base Cost is negative"));
|
|
}
|
|
|
|
if (effect.mIcon.empty())
|
|
{
|
|
messages.push_back(std::make_pair(id, "Icon is not specified"));
|
|
}
|
|
else if (!isTextureExists(effect.mIcon, true))
|
|
{
|
|
messages.push_back(std::make_pair(id, "No such Icon '" + effect.mIcon + "'"));
|
|
}
|
|
|
|
if (!effect.mParticle.empty() && !isTextureExists(effect.mParticle, false))
|
|
{
|
|
messages.push_back(std::make_pair(id, "No such Particle '" + effect.mParticle + "'"));
|
|
}
|
|
|
|
addMessageIfNotEmpty(messages,
|
|
id,
|
|
checkReferenceable(effect.mCasting, CSMWorld::UniversalId::Type_Static, "Casting Object"));
|
|
addMessageIfNotEmpty(messages,
|
|
id,
|
|
checkReferenceable(effect.mHit, CSMWorld::UniversalId::Type_Static, "Hit Object"));
|
|
addMessageIfNotEmpty(messages,
|
|
id,
|
|
checkReferenceable(effect.mArea, CSMWorld::UniversalId::Type_Static, "Area Object"));
|
|
addMessageIfNotEmpty(messages,
|
|
id,
|
|
checkReferenceable(effect.mBolt, CSMWorld::UniversalId::Type_Weapon, "Bolt Object"));
|
|
|
|
addMessageIfNotEmpty(messages, id, checkSound(effect.mCastSound, "Casting Sound"));
|
|
addMessageIfNotEmpty(messages, id, checkSound(effect.mHitSound, "Hit Sound"));
|
|
addMessageIfNotEmpty(messages, id, checkSound(effect.mAreaSound, "Area Sound"));
|
|
addMessageIfNotEmpty(messages, id, checkSound(effect.mBoltSound, "Bolt Sound"));
|
|
|
|
if (effect.mDescription.empty())
|
|
{
|
|
messages.push_back(std::make_pair(id, "Description is empty"));
|
|
}
|
|
}
|