1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-10 15:39:02 +00:00
OpenMW/apps/opencs/model/tools/startscriptcheck.cpp

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

53 lines
1.6 KiB
C++
Raw Normal View History

2015-03-05 10:24:01 +00:00
#include "startscriptcheck.hpp"
2022-10-19 17:02:00 +00:00
#include <string>
#include "../prefs/state.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/universalid.hpp>
#include <components/esm3/loadsscr.hpp>
#include <components/misc/strings/lower.hpp>
2015-03-05 10:24:01 +00:00
2022-10-19 17:02:00 +00:00
namespace ESM
{
class Script;
}
2015-03-05 10:24:01 +00:00
CSMTools::StartScriptCheckStage::StartScriptCheckStage(
const CSMWorld::IdCollection<ESM::StartScript>& startScripts, const CSMWorld::IdCollection<ESM::Script>& scripts)
: mStartScripts(startScripts)
, mScripts(scripts)
{
mIgnoreBaseRecords = false;
}
2015-03-05 10:24:01 +00:00
void CSMTools::StartScriptCheckStage::perform(int stage, CSMDoc::Messages& messages)
{
const CSMWorld::Record<ESM::StartScript>& record = mStartScripts.getRecord(stage);
// Skip "Base" records (setting!) and "Deleted" records
if ((mIgnoreBaseRecords && record.mState == CSMWorld::RecordBase::State_BaseOnly) || record.isDeleted())
2015-03-05 10:24:01 +00:00
return;
const auto& scriptId = record.get().mId;
2015-03-05 10:24:01 +00:00
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_StartScript, scriptId);
if (mScripts.searchId(scriptId) == -1)
messages.add(
id, "Start script " + scriptId.getRefIdString() + " does not exist", "", CSMDoc::Message::Severity_Error);
2015-03-05 10:24:01 +00:00
}
int CSMTools::StartScriptCheckStage::setup()
{
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
2015-03-05 10:24:01 +00:00
return mStartScripts.getSize();
}