Skip to content

Commit

Permalink
Merge pull request #7 from Squareville/denylist-for-chat
Browse files Browse the repository at this point in the history
bodge it back in
  • Loading branch information
aronwk-aaron authored Mar 30, 2022
2 parents ff9d736 + 01a712d commit 772ccf2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
14 changes: 13 additions & 1 deletion dChatFilter/dChatFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
#include "dCommonVars.h"
#include "Database.h"
#include "dLogger.h"
#include "dConfig.h"
#include "Database.h"
#include "Game.h"

using namespace dChatFilterDCF;

dChatFilter::dChatFilter(const std::string& filepath, bool dontGenerateDCF) {
m_DontGenerateDCF = dontGenerateDCF;
m_UseWhitelist = bool(std::stoi(Game::config->GetValue("use_chat_words_as_whitelist")));

if (!BinaryIO::DoesFileExist(filepath + ".dcf") || m_DontGenerateDCF) {
ReadWordlistPlaintext(filepath + ".txt");
Expand Down Expand Up @@ -116,12 +119,21 @@ bool dChatFilter::IsSentenceOkay(const std::string& message, int gmLevel) {
size_t hash = CalculateHash(segment);

if (std::find(m_UserUnapprovedWordCache.begin(), m_UserUnapprovedWordCache.end(), hash) != m_UserUnapprovedWordCache.end()) {
// found word that isn't ok, just deny this code works for both white and black list
return false;
}

if (!IsInWordlist(hash)) {
m_UserUnapprovedWordCache.push_back(hash);
if (m_UseWhitelist) {
return false;
m_UserUnapprovedWordCache.push_back(hash);
return false;
}
} else {
if (!m_UseWhitelist) {
m_UserUnapprovedWordCache.push_back(hash);
return false;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions dChatFilter/dChatFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class dChatFilter
bool IsSentenceOkay(const std::string& message, int gmLevel);

private:
bool m_UseWhitelist;
bool m_DontGenerateDCF;
std::vector<size_t> m_Words;
std::vector<size_t> m_UserUnapprovedWordCache;
Expand Down
3 changes: 3 additions & 0 deletions resources/chatconfig.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ log_debug_statements=0

# 0 or 1, should not compile chat hash map to file
dont_generate_dcf=0

# 0 or 1, use chat file as whitelist?
use_chat_words_as_whitelist=1
7 changes: 5 additions & 2 deletions resources/worldconfig.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ disable_chat=0

# Spatial partitioning settings
# 205/12 is 1-1 with LU's terrain. Make sure to keep this ratio correct!
# so 102/24 would be half the size, which nets better phys times.
# so 102/24 would be half the size, which nets better phys times.
# 154/18 is a good middle road
phys_spatial_partitioning=1
phys_sp_tilesize=102
Expand All @@ -51,5 +51,8 @@ solo_racing=0
# Disables the anti-speedhack system. If you get kicked randomly you might want to disable this, as it might just be lag
disable_anti_speedhack=0

# 0 or 1, use chat file as whitelist?
use_chat_words_as_whitelist=1

# 0 or 1, check server fdb (res/CDServer.fdb) against clients
check_fdb=0
check_fdb=0

0 comments on commit 772ccf2

Please sign in to comment.