Jump to content
  • Join-Us

    https://metin2.dev is the 1st international community on Metin2 development. Join us to develop your skills and share your knowledge with the community, respectful and ethical forum.

  • 0

Filtering the chat


Minton

Question

Hi,

Im trying with a function to filter some string from the chat, but it gives a strange error.

Functions:

const char* FilterChat(const char* c_pszBuffer)
{
    std::string strChatBuf = c_pszBuffer;

    // Other stuff with the string, but its commented out rn.
    
    char szTmpBuf[1024 + 1] = {};
    const char* c_szpFilterBuf = strChatBuf.c_str();
    _snprintf(szTmpBuf, sizeof(szTmpBuf), "%s", c_szpFilterBuf);

    return szTmpBuf;

}

In bool CPythonNetworkStream::RecvChatPacket():

#ifdef CHAT_FILTER
	CPythonTextTail::Instance().RegisterChatTail(kChat.dwVID, FilterChat(line));
#else
	CPythonTextTail::Instance().RegisterChatTail(kChat.dwVID, line);
#endif

 

And in-game its junk:

junk.png

 

What's the problem? With debugging it seems the array gets created with full of junk already, but i've initialized it with full of zeroes if im not wrong.

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
  • Moderator
Quote

1>PythonNetworkStreamPhaseGame.cpp(xxxx): warning C4172: returning address of local variable or temporary

9958e2b3d79009b1dac47564889a9009.png2ca536ee18e2cfcbc31d70ed1c21369f.png

or:

081210Screenshot-1.png

That's a small tip for the next time when you're coding, so you'll know if it's a critical warning and it needs real attention or not, based on the level.

https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • 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.