MCPcopy Create free account
hub / github.com/ddnet/ddnet / CChat

Method CChat

src/game/client/components/chat.cpp:45–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45CChat::CChat()
46{
47 m_Mode = MODE_NONE;
48
49 m_Input.SetCalculateOffsetCallback([this]() { return m_IsInputCensored; });
50 m_Input.SetDisplayTextCallback([this](char *pStr, size_t NumChars) {
51 m_IsInputCensored = false;
52 if(
53 g_Config.m_ClStreamerMode &&
54 (str_startswith(pStr, "/login ") ||
55 str_startswith(pStr, "/register ") ||
56 str_startswith(pStr, "/code ") ||
57 str_startswith(pStr, "/timeout ") ||
58 str_startswith(pStr, "/save ") ||
59 str_startswith(pStr, "/load ")))
60 {
61 bool Censor = false;
62 const size_t NumLetters = minimum(NumChars, sizeof(ms_aDisplayText) - 1);
63 for(size_t i = 0; i < NumLetters; ++i)
64 {
65 if(Censor)
66 ms_aDisplayText[i] = '*';
67 else
68 ms_aDisplayText[i] = pStr[i];
69 if(pStr[i] == ' ')
70 {
71 Censor = true;
72 m_IsInputCensored = true;
73 }
74 }
75 ms_aDisplayText[NumLetters] = '\0';
76 return ms_aDisplayText;
77 }
78 return pStr;
79 });
80}
81
82void CChat::RegisterCommand(const char *pName, const char *pParams, const char *pHelpText)
83{

Callers

nothing calls this directly

Calls 4

str_startswithFunction · 0.85
minimumFunction · 0.50

Tested by

no test coverage detected