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

🖥️ SysAdmin — Government (HU)
🛠️ Freelance Metin2 Dev • DevOps
🐧 FreeBSD / Linux | 🛡️ Security & WAF | 🚀 Performance | 🔥 Firewalls | ⚙ Automation
Open to work - Contact me on Discord @matteo_r

Link to comment
https://metin2.dev/topic/28028-filtering-the-chat/
Share on other sites

On 10/5/2021 at 8:59 PM, Owsap said:

Use a static variable instead for szTmpBuf.

static char szTmpBuf[1024 + 1] = {};	

Thanks worked!

🖥️ SysAdmin — Government (HU)
🛠️ Freelance Metin2 Dev • DevOps
🐧 FreeBSD / Linux | 🛡️ Security & WAF | 🚀 Performance | 🔥 Firewalls | ⚙ Automation
Open to work - Contact me on Discord @matteo_r

Link to comment
https://metin2.dev/topic/28028-filtering-the-chat/#findComment-143977
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
https://metin2.dev/topic/28028-filtering-the-chat/#findComment-144003
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

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.