diff options
-rw-r--r-- | source/game/StarNameGenerator.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source/game/StarNameGenerator.cpp b/source/game/StarNameGenerator.cpp index 6dd2350..6b8223e 100644 --- a/source/game/StarNameGenerator.cpp +++ b/source/game/StarNameGenerator.cpp @@ -113,10 +113,13 @@ String PatternedNameGenerator::processRule(JsonArray const& rule, RandomSource& } bool PatternedNameGenerator::isProfane(String const& name) const { - auto matchName = name.toLower().rot13(); - for (auto naughtyWord : m_profanityFilter) { - if (matchName.contains(naughtyWord)) - return true; + auto matchNames = name.toLower().rot13().splitAny(" -"); + for (auto& naughtyWord : m_profanityFilter) { + for (auto& matchName : matchNames) { + auto find = matchName.find(naughtyWord); + if (find != NPos && (find == 0 || naughtyWord.size() + 1 >= matchName.size())) + return true; + } } return false; } |