Nice Commit! :)

This commit is contained in:
TomNordesen 2021-12-07 19:58:24 +01:00
parent fe5814d5ba
commit bfcce19649
3 changed files with 9 additions and 2 deletions

View File

@ -110,16 +110,22 @@ bool dChatFilter::IsSentenceOkay(const std::string& message, int gmLevel) {
segment = std::regex_replace(segment, reg, ""); segment = std::regex_replace(segment, reg, "");
size_t hash = CalculateHash(segment); size_t hash = CalculateHash(segment);
Game::logger->Log("SEGMENT", "Word: %s Hash: %zu", segment.c_str(), hash);
if (std::find(m_UserUnapprovedWordCache.begin(), m_UserUnapprovedWordCache.end(), hash) != m_UserUnapprovedWordCache.end()) { if (std::find(m_UserUnapprovedWordCache.begin(), m_UserUnapprovedWordCache.end(), hash) != m_UserUnapprovedWordCache.end()) {
Game::logger->Log("SENTENCEOKAY", "SENTENCE IS UNNAPROVED");
return false; return false;
} }
if (!IsInWordlist(hash)) { bool a = IsInWordlist(hash);
Game::logger->Log("ISWORDLIST", "ISINWORDLIST: %s", a?"YES":"NO");
if (!a) {
Game::logger->Log("SENTENCEOKAY", "SENTENCE IS NOT IN WORDLIST");
m_UserUnapprovedWordCache.push_back(hash); m_UserUnapprovedWordCache.push_back(hash);
return false; return false;
} }
} }
Game::logger->Log("SENTENCEOKAY", "SENTENCE IS OKAY TO SEND");
return true; return true;
} }

View File

@ -295,6 +295,7 @@ void ClientPackets::HandleChatModerationRequest(const SystemAddress& sysAddr, Pa
std::unordered_map<char, char> unacceptedItems; std::unordered_map<char, char> unacceptedItems;
bool bAllClean = Game::chatFilter->IsSentenceOkay(message, user->GetLastUsedChar()->GetGMLevel()); bool bAllClean = Game::chatFilter->IsSentenceOkay(message, user->GetLastUsedChar()->GetGMLevel());
Game::logger->Log("BALLCLEAN", "%s", bAllClean?"Is Clean":"IS NOT CLEAN!!!");
if (!bAllClean) { if (!bAllClean) {
unacceptedItems.insert(std::make_pair((char)0, (char)message.length())); unacceptedItems.insert(std::make_pair((char)0, (char)message.length()));
} }

View File

@ -833,7 +833,7 @@ void HandlePacket(Packet* packet) {
} }
if (packet->data[1] != WORLD) return; if (packet->data[1] != WORLD) return;
switch (packet->data[3]) { switch (packet->data[3]) {
case MSG_WORLD_CLIENT_VALIDATION: { case MSG_WORLD_CLIENT_VALIDATION: {
std::string username = PacketUtils::ReadString(0x08, packet, true); std::string username = PacketUtils::ReadString(0x08, packet, true);