Jump to content

Filtering the chat


Go to solution Solved by Owsap,

Recommended Posts

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

System Administrator @ Hungarian Government
System Administrator @ Vibestro
Freelancer Developer @ Various projects

Link to comment
Share on other sites

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

Announcements



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