Exterminate script blacklisting (#8214)

pull/3236/head
Alexei Kotov 2 months ago
parent 34b6a9d402
commit 5d37cb3b74

@ -286,6 +286,7 @@
Task #7182: FFMpeg 5.1.1+ support Task #7182: FFMpeg 5.1.1+ support
Task #7394: Drop support for --fs-strict Task #7394: Drop support for --fs-strict
Task #7720: Drop 360-degree screenshot support Task #7720: Drop 360-degree screenshot support
Task #8214: Drop script blacklisting functionality
0.48.0 0.48.0
------ ------

@ -74,10 +74,6 @@ Command line options
1 - show warning but consider script as 1 - show warning but consider script as
correctly compiled anyway correctly compiled anyway
2 - treat warnings as errors 2 - treat warnings as errors
--script-blacklist arg ignore the specified script (if the use
of the blacklist is enabled)
--script-blacklist-use [=arg(=1)] (=1)
enable script blacklisting
--load-savegame arg load a save game file on game startup --load-savegame arg load a save game file on game startup
(specify an absolute filename or a (specify an absolute filename or a
filename relative to the current filename relative to the current

@ -8,7 +8,7 @@ opencs_units (model/doc
) )
opencs_units (model/doc opencs_units (model/doc
savingstate savingstages blacklist messages savingstate savingstages messages
) )
opencs_hdrs (model/doc opencs_hdrs (model/doc

@ -126,13 +126,6 @@ boost::program_options::variables_map CS::Editor::readConfiguration()
addOption("fallback", addOption("fallback",
boost::program_options::value<FallbackMap>()->default_value(FallbackMap(), "")->multitoken()->composing(), boost::program_options::value<FallbackMap>()->default_value(FallbackMap(), "")->multitoken()->composing(),
"fallback values"); "fallback values");
addOption("script-blacklist",
boost::program_options::value<std::vector<std::string>>()
->default_value(std::vector<std::string>(), "")
->multitoken(),
"exclude specified script from the verifier (if the use of the blacklist is enabled)");
addOption("script-blacklist-use", boost::program_options::value<bool>()->implicit_value(true)->default_value(true),
"enable script blacklisting");
Files::ConfigurationManager::addCommonOptions(desc); Files::ConfigurationManager::addCommonOptions(desc);
boost::program_options::notify(variables); boost::program_options::notify(variables);
@ -159,9 +152,6 @@ std::pair<Files::PathContainer, std::vector<std::string>> CS::Editor::readConfig
.u8string()); // This call to u8string is redundant, but required .u8string()); // This call to u8string is redundant, but required
// to build on MSVC 14.26 due to implementation bugs. // to build on MSVC 14.26 due to implementation bugs.
if (variables["script-blacklist-use"].as<bool>())
mDocumentManager.setBlacklistedScripts(variables["script-blacklist"].as<std::vector<std::string>>());
Files::PathContainer dataDirs, dataLocal; Files::PathContainer dataDirs, dataLocal;
if (!variables["data"].empty()) if (!variables["data"].empty())
{ {

@ -1,32 +0,0 @@
#include "blacklist.hpp"
#include <algorithm>
#include <stddef.h>
#include <utility>
#include <apps/opencs/model/world/universalid.hpp>
#include <components/misc/strings/lower.hpp>
bool CSMDoc::Blacklist::isBlacklisted(const CSMWorld::UniversalId& id) const
{
std::map<CSMWorld::UniversalId::Type, std::vector<std::string>>::const_iterator iter = mIds.find(id.getType());
if (iter == mIds.end())
return false;
return std::binary_search(iter->second.begin(), iter->second.end(), Misc::StringUtils::lowerCase(id.getId()));
}
void CSMDoc::Blacklist::add(CSMWorld::UniversalId::Type type, const std::vector<std::string>& ids)
{
std::vector<std::string>& list = mIds[type];
size_t size = list.size();
list.resize(size + ids.size());
std::transform(ids.begin(), ids.end(), list.begin() + size,
[](const std::string& s) { return Misc::StringUtils::lowerCase(s); });
std::sort(list.begin(), list.end());
}

@ -1,24 +0,0 @@
#ifndef CSM_DOC_BLACKLIST_H
#define CSM_DOC_BLACKLIST_H
#include <map>
#include <string>
#include <vector>
#include "../world/universalid.hpp"
namespace CSMDoc
{
/// \brief ID blacklist sorted by UniversalId type
class Blacklist
{
std::map<CSMWorld::UniversalId::Type, std::vector<std::string>> mIds;
public:
bool isBlacklisted(const CSMWorld::UniversalId& id) const;
void add(CSMWorld::UniversalId::Type type, const std::vector<std::string>& ids);
};
}
#endif

@ -2,7 +2,6 @@
#include "state.hpp" #include "state.hpp"
#include <apps/opencs/model/doc/blacklist.hpp>
#include <apps/opencs/model/doc/messages.hpp> #include <apps/opencs/model/doc/messages.hpp>
#include <apps/opencs/model/doc/operationholder.hpp> #include <apps/opencs/model/doc/operationholder.hpp>
#include <apps/opencs/model/doc/runner.hpp> #include <apps/opencs/model/doc/runner.hpp>
@ -295,8 +294,7 @@ void CSMDoc::Document::createBase()
CSMDoc::Document::Document(const Files::ConfigurationManager& configuration, std::vector<std::filesystem::path> files, CSMDoc::Document::Document(const Files::ConfigurationManager& configuration, std::vector<std::filesystem::path> files,
bool new_, const std::filesystem::path& savePath, const std::filesystem::path& resDir, ToUTF8::FromType encoding, bool new_, const std::filesystem::path& savePath, const std::filesystem::path& resDir, ToUTF8::FromType encoding,
const std::vector<std::string>& blacklistedScripts, const Files::PathContainer& dataPaths, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives)
const std::vector<std::string>& archives)
: mSavePath(savePath) : mSavePath(savePath)
, mContentFiles(std::move(files)) , mContentFiles(std::move(files))
, mNew(new_) , mNew(new_)
@ -339,8 +337,6 @@ CSMDoc::Document::Document(const Files::ConfigurationManager& configuration, std
createBase(); createBase();
} }
mBlacklist.add(CSMWorld::UniversalId::Type_Script, blacklistedScripts);
addOptionalGmsts(); addOptionalGmsts();
addOptionalGlobals(); addOptionalGlobals();
addOptionalMagicEffects(); addOptionalMagicEffects();
@ -485,11 +481,6 @@ CSMTools::ReportModel* CSMDoc::Document::getReport(const CSMWorld::UniversalId&
return mTools.getReport(id); return mTools.getReport(id);
} }
bool CSMDoc::Document::isBlacklisted(const CSMWorld::UniversalId& id) const
{
return mBlacklist.isBlacklisted(id);
}
void CSMDoc::Document::startRunning(const std::string& profile, const std::string& startupInstruction) void CSMDoc::Document::startRunning(const std::string& profile, const std::string& startupInstruction)
{ {
std::vector<std::filesystem::path> contentFiles; std::vector<std::filesystem::path> contentFiles;

@ -19,7 +19,6 @@
#include "../tools/tools.hpp" #include "../tools/tools.hpp"
#include "blacklist.hpp"
#include "operationholder.hpp" #include "operationholder.hpp"
#include "runner.hpp" #include "runner.hpp"
#include "saving.hpp" #include "saving.hpp"
@ -61,7 +60,6 @@ namespace CSMDoc
Saving mSavingOperation; Saving mSavingOperation;
OperationHolder mSaving; OperationHolder mSaving;
std::filesystem::path mResDir; std::filesystem::path mResDir;
Blacklist mBlacklist;
Runner mRunner; Runner mRunner;
bool mDirty; bool mDirty;
@ -95,8 +93,7 @@ namespace CSMDoc
public: public:
Document(const Files::ConfigurationManager& configuration, std::vector<std::filesystem::path> files, bool new_, Document(const Files::ConfigurationManager& configuration, std::vector<std::filesystem::path> files, bool new_,
const std::filesystem::path& savePath, const std::filesystem::path& resDir, ToUTF8::FromType encoding, const std::filesystem::path& savePath, const std::filesystem::path& resDir, ToUTF8::FromType encoding,
const std::vector<std::string>& blacklistedScripts, const Files::PathContainer& dataPaths, const Files::PathContainer& dataPaths, const std::vector<std::string>& archives);
const std::vector<std::string>& archives);
~Document() override = default; ~Document() override = default;
@ -136,8 +133,6 @@ namespace CSMDoc
CSMTools::ReportModel* getReport(const CSMWorld::UniversalId& id); CSMTools::ReportModel* getReport(const CSMWorld::UniversalId& id);
///< The ownership of the returned report is not transferred. ///< The ownership of the returned report is not transferred.
bool isBlacklisted(const CSMWorld::UniversalId& id) const;
void startRunning(const std::string& profile, const std::string& startupInstruction = ""); void startRunning(const std::string& profile, const std::string& startupInstruction = "");
void stopRunning(); void stopRunning();

@ -61,8 +61,7 @@ void CSMDoc::DocumentManager::addDocument(
CSMDoc::Document* CSMDoc::DocumentManager::makeDocument( CSMDoc::Document* CSMDoc::DocumentManager::makeDocument(
const std::vector<std::filesystem::path>& files, const std::filesystem::path& savePath, bool new_) const std::vector<std::filesystem::path>& files, const std::filesystem::path& savePath, bool new_)
{ {
return new Document( return new Document(mConfiguration, files, new_, savePath, mResDir, mEncoding, mDataPaths, mArchives);
mConfiguration, files, new_, savePath, mResDir, mEncoding, mBlacklistedScripts, mDataPaths, mArchives);
} }
void CSMDoc::DocumentManager::insertDocument(CSMDoc::Document* document) void CSMDoc::DocumentManager::insertDocument(CSMDoc::Document* document)
@ -102,11 +101,6 @@ void CSMDoc::DocumentManager::setEncoding(ToUTF8::FromType encoding)
mEncoding = encoding; mEncoding = encoding;
} }
void CSMDoc::DocumentManager::setBlacklistedScripts(const std::vector<std::string>& scriptIds)
{
mBlacklistedScripts = scriptIds;
}
void CSMDoc::DocumentManager::documentLoaded(Document* document) void CSMDoc::DocumentManager::documentLoaded(Document* document)
{ {
emit documentAdded(document); emit documentAdded(document);

@ -31,7 +31,6 @@ namespace CSMDoc
QThread mLoaderThread; QThread mLoaderThread;
Loader mLoader; Loader mLoader;
ToUTF8::FromType mEncoding; ToUTF8::FromType mEncoding;
std::vector<std::string> mBlacklistedScripts;
std::filesystem::path mResDir; std::filesystem::path mResDir;
@ -64,8 +63,6 @@ namespace CSMDoc
void setEncoding(ToUTF8::FromType encoding); void setEncoding(ToUTF8::FromType encoding);
void setBlacklistedScripts(const std::vector<std::string>& scriptIds);
/// Sets the file data that gets passed to newly created documents. /// Sets the file data that gets passed to newly created documents.
void setFileData(const Files::PathContainer& dataPaths, const std::vector<std::string>& archives); void setFileData(const Files::PathContainer& dataPaths, const std::vector<std::string>& archives);

@ -106,9 +106,6 @@ void CSMTools::ScriptCheckStage::perform(int stage, CSMDoc::Messages& messages)
mId = mDocument.getData().getScripts().getId(stage); mId = mDocument.getData().getScripts().getId(stage);
if (mDocument.isBlacklisted(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Script, mId.getRefIdString())))
return;
// Skip "Base" records (setting!) and "Deleted" records // Skip "Base" records (setting!) and "Deleted" records
if ((mIgnoreBaseRecords && record.mState == CSMWorld::RecordBase::State_BaseOnly) || record.isDeleted()) if ((mIgnoreBaseRecords && record.mState == CSMWorld::RecordBase::State_BaseOnly) || record.isDeleted())
return; return;

@ -374,7 +374,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
, mActivationDistanceOverride(-1) , mActivationDistanceOverride(-1)
, mGrab(true) , mGrab(true)
, mRandomSeed(0) , mRandomSeed(0)
, mScriptBlacklistUse(true)
, mNewGame(false) , mNewGame(false)
, mCfgMgr(configurationManager) , mCfgMgr(configurationManager)
, mGlMaxTextureImageUnits(0) , mGlMaxTextureImageUnits(0)
@ -884,8 +883,7 @@ void OMW::Engine::prepareEngine()
mScriptContext = std::make_unique<MWScript::CompilerContext>(MWScript::CompilerContext::Type_Full); mScriptContext = std::make_unique<MWScript::CompilerContext>(MWScript::CompilerContext::Type_Full);
mScriptContext->setExtensions(&mExtensions); mScriptContext->setExtensions(&mExtensions);
mScriptManager = std::make_unique<MWScript::ScriptManager>(mWorld->getStore(), *mScriptContext, mWarningsMode, mScriptManager = std::make_unique<MWScript::ScriptManager>(mWorld->getStore(), *mScriptContext, mWarningsMode);
mScriptBlacklistUse ? mScriptBlacklist : std::vector<ESM::RefId>());
mEnvironment.setScriptManager(*mScriptManager); mEnvironment.setScriptManager(*mScriptManager);
// Create game mechanics system // Create game mechanics system
@ -1111,16 +1109,6 @@ void OMW::Engine::setWarningsMode(int mode)
mWarningsMode = mode; mWarningsMode = mode;
} }
void OMW::Engine::setScriptBlacklist(const std::vector<ESM::RefId>& list)
{
mScriptBlacklist = list;
}
void OMW::Engine::setScriptBlacklistUse(bool use)
{
mScriptBlacklistUse = use;
}
void OMW::Engine::setSaveGameFile(const std::filesystem::path& savegame) void OMW::Engine::setSaveGameFile(const std::filesystem::path& savegame)
{ {
mSaveGameFile = savegame; mSaveGameFile = savegame;

@ -178,8 +178,6 @@ namespace OMW
Files::Collections mFileCollections; Files::Collections mFileCollections;
Translation::Storage mTranslationDataStorage; Translation::Storage mTranslationDataStorage;
std::vector<ESM::RefId> mScriptBlacklist;
bool mScriptBlacklistUse;
bool mNewGame; bool mNewGame;
// not implemented // not implemented
@ -253,10 +251,6 @@ namespace OMW
void setWarningsMode(int mode); void setWarningsMode(int mode);
void setScriptBlacklist(const std::vector<ESM::RefId>& list);
void setScriptBlacklistUse(bool use);
/// Set the save game file to load after initialising the engine. /// Set the save game file to load after initialising the engine.
void setSaveGameFile(const std::filesystem::path& savegame); void setSaveGameFile(const std::filesystem::path& savegame);

@ -149,14 +149,6 @@ bool parseOptions(int argc, char** argv, OMW::Engine& engine, Files::Configurati
engine.setScriptConsoleMode(variables["script-console"].as<bool>()); engine.setScriptConsoleMode(variables["script-console"].as<bool>());
engine.setStartupScript(variables["script-run"].as<std::string>()); engine.setStartupScript(variables["script-run"].as<std::string>());
engine.setWarningsMode(variables["script-warn"].as<int>()); engine.setWarningsMode(variables["script-warn"].as<int>());
std::vector<ESM::RefId> scriptBlacklist;
auto& scriptBlacklistString = variables["script-blacklist"].as<StringsVector>();
for (const auto& blacklistString : scriptBlacklistString)
{
scriptBlacklist.push_back(ESM::RefId::stringRefId(blacklistString));
}
engine.setScriptBlacklist(scriptBlacklist);
engine.setScriptBlacklistUse(variables["script-blacklist-use"].as<bool>());
engine.setSaveGameFile(variables["load-savegame"].as<Files::MaybeQuotedPath>().u8string()); engine.setSaveGameFile(variables["load-savegame"].as<Files::MaybeQuotedPath>().u8string());
// other settings // other settings

@ -24,8 +24,7 @@
namespace MWScript namespace MWScript
{ {
ScriptManager::ScriptManager(const MWWorld::ESMStore& store, Compiler::Context& compilerContext, int warningsMode, ScriptManager::ScriptManager(const MWWorld::ESMStore& store, Compiler::Context& compilerContext, int warningsMode)
const std::vector<ESM::RefId>& scriptBlacklist)
: mErrorHandler() : mErrorHandler()
, mStore(store) , mStore(store)
, mCompilerContext(compilerContext) , mCompilerContext(compilerContext)
@ -35,10 +34,6 @@ namespace MWScript
installOpcodes(mInterpreter); installOpcodes(mInterpreter);
mErrorHandler.setWarningsMode(warningsMode); mErrorHandler.setWarningsMode(warningsMode);
mScriptBlacklist.resize(scriptBlacklist.size());
std::sort(mScriptBlacklist.begin(), mScriptBlacklist.end());
} }
bool ScriptManager::compile(const ESM::RefId& name) bool ScriptManager::compile(const ESM::RefId& name)
@ -148,13 +143,10 @@ namespace MWScript
for (auto& script : mStore.get<ESM::Script>()) for (auto& script : mStore.get<ESM::Script>())
{ {
if (!std::binary_search(mScriptBlacklist.begin(), mScriptBlacklist.end(), script.mId)) ++count;
{
++count;
if (compile(script.mId)) if (compile(script.mId))
++success; ++success;
}
} }
return std::make_pair(count, success); return std::make_pair(count, success);

@ -59,11 +59,9 @@ namespace MWScript
std::unordered_map<ESM::RefId, CompiledScript> mScripts; std::unordered_map<ESM::RefId, CompiledScript> mScripts;
GlobalScripts mGlobalScripts; GlobalScripts mGlobalScripts;
std::unordered_map<ESM::RefId, Compiler::Locals> mOtherLocals; std::unordered_map<ESM::RefId, Compiler::Locals> mOtherLocals;
std::vector<ESM::RefId> mScriptBlacklist;
public: public:
ScriptManager(const MWWorld::ESMStore& store, Compiler::Context& compilerContext, int warningsMode, ScriptManager(const MWWorld::ESMStore& store, Compiler::Context& compilerContext, int warningsMode);
const std::vector<ESM::RefId>& scriptBlacklist);
void clear() override; void clear() override;

@ -64,13 +64,6 @@ namespace OpenMW
"\t1 - show warning but consider script as correctly compiled anyway\n" "\t1 - show warning but consider script as correctly compiled anyway\n"
"\t2 - treat warnings as errors"); "\t2 - treat warnings as errors");
addOption("script-blacklist",
bpo::value<StringsVector>()->default_value(StringsVector(), "")->multitoken()->composing(),
"ignore the specified script (if the use of the blacklist is enabled)");
addOption("script-blacklist-use", bpo::value<bool>()->implicit_value(true)->default_value(true),
"enable script blacklisting");
addOption("load-savegame", bpo::value<Files::MaybeQuotedPath>()->default_value(Files::MaybeQuotedPath(), ""), addOption("load-savegame", bpo::value<Files::MaybeQuotedPath>()->default_value(Files::MaybeQuotedPath(), ""),
"load a save game file on game startup (specify an absolute filename or a filename relative to the current " "load a save game file on game startup (specify an absolute filename or a filename relative to the current "
"working directory)"); "working directory)");

@ -121,8 +121,7 @@ bool Config::GameSettings::readFile(
// Replace composing entries with a replace= line // Replace composing entries with a replace= line
if (key == QLatin1String("config") || key == QLatin1String("replace") || key == QLatin1String("data") if (key == QLatin1String("config") || key == QLatin1String("replace") || key == QLatin1String("data")
|| key == QLatin1String("fallback-archive") || key == QLatin1String("content") || key == QLatin1String("fallback-archive") || key == QLatin1String("content")
|| key == QLatin1String("groundcover") || key == QLatin1String("script-blacklist") || key == QLatin1String("groundcover") || key == QLatin1String("fallback"))
|| key == QLatin1String("fallback"))
settings.remove(key); settings.remove(key);
} }
} }
@ -145,8 +144,7 @@ bool Config::GameSettings::readFile(
// Don't remove composing entries // Don't remove composing entries
if (key != QLatin1String("config") && key != QLatin1String("replace") && key != QLatin1String("data") if (key != QLatin1String("config") && key != QLatin1String("replace") && key != QLatin1String("data")
&& key != QLatin1String("fallback-archive") && key != QLatin1String("content") && key != QLatin1String("fallback-archive") && key != QLatin1String("content")
&& key != QLatin1String("groundcover") && key != QLatin1String("script-blacklist") && key != QLatin1String("groundcover") && key != QLatin1String("fallback"))
&& key != QLatin1String("fallback"))
settings.remove(key); settings.remove(key);
if (key == QLatin1String("config") || key == QLatin1String("user-data") || key == QLatin1String("resources") if (key == QLatin1String("config") || key == QLatin1String("user-data") || key == QLatin1String("resources")

@ -7,12 +7,6 @@ user-data="?userdata?"
config="?userconfig?" config="?userconfig?"
resources=${OPENMW_RESOURCE_FILES} resources=${OPENMW_RESOURCE_FILES}
data=${OPENMW_RESOURCE_FILES}/vfs-mw data=${OPENMW_RESOURCE_FILES}/vfs-mw
script-blacklist=Museum
script-blacklist=MockChangeScript
script-blacklist=doortestwarp
script-blacklist=WereChange2Script
script-blacklist=wereDreamScript2
script-blacklist=wereDreamScript3
# lighting # lighting
fallback=LightAttenuation_UseConstant,0 fallback=LightAttenuation_UseConstant,0

@ -7,12 +7,6 @@ user-data="?userdata?"
config="?userconfig?" config="?userconfig?"
resources=./resources resources=./resources
data=./resources/vfs-mw data=./resources/vfs-mw
script-blacklist=Museum
script-blacklist=MockChangeScript
script-blacklist=doortestwarp
script-blacklist=WereChange2Script
script-blacklist=wereDreamScript2
script-blacklist=wereDreamScript3
# lighting # lighting
fallback=LightAttenuation_UseConstant,0 fallback=LightAttenuation_UseConstant,0

Loading…
Cancel
Save