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 #7394: Drop support for --fs-strict
Task #7720: Drop 360-degree screenshot support
Task #8214: Drop script blacklisting functionality
0.48.0
------

@ -74,10 +74,6 @@ Command line options
1 - show warning but consider script as
correctly compiled anyway
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
(specify an absolute filename or a
filename relative to the current

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

@ -126,13 +126,6 @@ boost::program_options::variables_map CS::Editor::readConfiguration()
addOption("fallback",
boost::program_options::value<FallbackMap>()->default_value(FallbackMap(), "")->multitoken()->composing(),
"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);
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
// 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;
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 <apps/opencs/model/doc/blacklist.hpp>
#include <apps/opencs/model/doc/messages.hpp>
#include <apps/opencs/model/doc/operationholder.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,
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 std::vector<std::string>& archives)
const Files::PathContainer& dataPaths, const std::vector<std::string>& archives)
: mSavePath(savePath)
, mContentFiles(std::move(files))
, mNew(new_)
@ -339,8 +337,6 @@ CSMDoc::Document::Document(const Files::ConfigurationManager& configuration, std
createBase();
}
mBlacklist.add(CSMWorld::UniversalId::Type_Script, blacklistedScripts);
addOptionalGmsts();
addOptionalGlobals();
addOptionalMagicEffects();
@ -485,11 +481,6 @@ CSMTools::ReportModel* CSMDoc::Document::getReport(const CSMWorld::UniversalId&
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)
{
std::vector<std::filesystem::path> contentFiles;

@ -19,7 +19,6 @@
#include "../tools/tools.hpp"
#include "blacklist.hpp"
#include "operationholder.hpp"
#include "runner.hpp"
#include "saving.hpp"
@ -61,7 +60,6 @@ namespace CSMDoc
Saving mSavingOperation;
OperationHolder mSaving;
std::filesystem::path mResDir;
Blacklist mBlacklist;
Runner mRunner;
bool mDirty;
@ -95,8 +93,7 @@ namespace CSMDoc
public:
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::vector<std::string>& blacklistedScripts, const Files::PathContainer& dataPaths,
const std::vector<std::string>& archives);
const Files::PathContainer& dataPaths, const std::vector<std::string>& archives);
~Document() override = default;
@ -136,8 +133,6 @@ namespace CSMDoc
CSMTools::ReportModel* getReport(const CSMWorld::UniversalId& id);
///< 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 stopRunning();

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

@ -31,7 +31,6 @@ namespace CSMDoc
QThread mLoaderThread;
Loader mLoader;
ToUTF8::FromType mEncoding;
std::vector<std::string> mBlacklistedScripts;
std::filesystem::path mResDir;
@ -64,8 +63,6 @@ namespace CSMDoc
void setEncoding(ToUTF8::FromType encoding);
void setBlacklistedScripts(const std::vector<std::string>& scriptIds);
/// Sets the file data that gets passed to newly created documents.
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);
if (mDocument.isBlacklisted(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Script, mId.getRefIdString())))
return;
// Skip "Base" records (setting!) and "Deleted" records
if ((mIgnoreBaseRecords && record.mState == CSMWorld::RecordBase::State_BaseOnly) || record.isDeleted())
return;

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

@ -178,8 +178,6 @@ namespace OMW
Files::Collections mFileCollections;
Translation::Storage mTranslationDataStorage;
std::vector<ESM::RefId> mScriptBlacklist;
bool mScriptBlacklistUse;
bool mNewGame;
// not implemented
@ -253,10 +251,6 @@ namespace OMW
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.
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.setStartupScript(variables["script-run"].as<std::string>());
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());
// other settings

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

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

@ -64,13 +64,6 @@ namespace OpenMW
"\t1 - show warning but consider script as correctly compiled anyway\n"
"\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(), ""),
"load a save game file on game startup (specify an absolute filename or a filename relative to the current "
"working directory)");

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

@ -7,12 +7,6 @@ user-data="?userdata?"
config="?userconfig?"
resources=${OPENMW_RESOURCE_FILES}
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
fallback=LightAttenuation_UseConstant,0

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

Loading…
Cancel
Save