mirror of https://github.com/OpenMW/openmw.git
Exterminate script blacklisting (#8214)
parent
34b6a9d402
commit
5d37cb3b74
@ -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
|
Loading…
Reference in New Issue