Jump to content

about the banword


Recommended Posts

Open the banword.cpp 

Search it

CBanwordManager::~CBanwordManager()
{
}

Change it

CBanwordManager::~CBanwordManager()
{
	delete [] m_hashmap_words;
}

Search it

bool CBanwordManager::Initialize(TBanwordTable * p, WORD wSize)

Remove this

	m_hashmap_words.clear();

Looks like

bool CBanwordManager::Initialize(TBanwordTable * p, WORD wSize)
{
	for (WORD i = 0; i < wSize; ++i, ++p)
		m_hashmap_words[p->szWord] = true;

	char szBuf[256];
	snprintf(szBuf, sizeof(szBuf), "Banword reloaded! (total %zu banwords)", m_hashmap_words.size());
	SendLog(szBuf);
	return true;
}

Search it

char szBuf[256];

Change it

char szBuf[QUERY_MAX_LEN];

Search it

bool CBanwordManager::Initialize(TBanwordTable * p, WORD wSize)

Change it

bool CBanwordManager::Initialize(TBanwordTable * p, UINT wSize)

Search it

for (WORD i = 0; i < wSize; ++i, ++p)

Change it

for (UINT i = 0; i < wSize; ++i, ++p)

Search it

snprintf(szBuf, sizeof(szBuf), "Banword reloaded! (total %zu banwords)", m_hashmap_words.size());

Change it

snprintf(szBuf, sizeof(szBuf), "Banword reloaded! (total %u banwords)", m_hashmap_words.size());

Search it

bool CBanwordManager::CheckString(const char * c_pszString, size_t _len)
{
	if (m_hashmap_words.empty())
		return false;

	typeof(m_hashmap_words.begin()) it = m_hashmap_words.begin();

	while (it != m_hashmap_words.end())
	{
		const std::string & r = it->first;
		const char * tmp = c_pszString;
		ssize_t len = _len;

		while (len > 0)
		{
			if (is_twobyte(tmp))
			{
				if (!strncmp(tmp, r.c_str(), r.size()))
					return true;

				tmp += 2;
				len -= 2;
			}
			else
			{
				if (!strncmp(tmp, r.c_str(), r.size()))
					return true;

				++tmp;
				--len;
			}
		}

		it++;
	}

	return false;
}

Change it

bool CBanwordManager::CheckString(const char *c_pszString, size_t _len) {
    if (m_hashmap_words.empty()) {
        return false;
    }

    for (auto it = m_hashmap_words.cbegin(); it != m_hashmap_words.cend(); ++it) {
        const std::string &r = it->first;
        const char *tmp = c_pszString;
        ssize_t len = _len;

        while (len > 0) {
            if (!strncmp(tmp, r.c_str(), r.size())) {
                return true;
            }

            if (is_twobyte(tmp)) {
                tmp += 2;
                len -= 2;
            } else {
                ++tmp;
                --len;
            }
        }
    }

    return false;
}

open banword.h and search it

bool Initialize(TBanwordTable * p, WORD wSize);

Change it

bool Initialize(TBanwordTable * p, UINT wSize);

That is now completely finish.

  • Good 1
Link to comment
Share on other sites

  • Management

You should provide an explanation to improve understanding.

My empire, my kingdom... of Metin2... I will dominate the world and dominate you all...
metin2.dev | fr.metin2.dev | metin2dev.org | metin2.download | metin2.top | top-metin2.org

251469083416068096.png

Link to comment
Share on other sites



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.