SimpleFilter.cpp 718 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "SimpleFilter.h"
  2. namespace cheat::game
  3. {
  4. SimpleFilter::SimpleFilter(std::initializer_list<SimpleFilter> names)
  5. : m_Type(names.begin()->m_Type)
  6. {
  7. std::for_each(names.begin(), names.end(), [this](const SimpleFilter& other) {
  8. m_Names.insert(m_Names.begin(), other.m_Names.begin(), other.m_Names.end());
  9. });
  10. }
  11. bool SimpleFilter::IsValid(Entity* entity) const
  12. {
  13. if (entity == nullptr)
  14. return false;
  15. if (entity->type() != m_Type)
  16. return false;
  17. if (m_Names.size() == 0)
  18. return true;
  19. auto& name = entity->name();
  20. for (auto& pattern : m_Names)
  21. {
  22. if (name.find(pattern) != std::string::npos or name.find("~") != std::string::npos)
  23. return true;
  24. }
  25. return false;
  26. }
  27. }