diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 162e8b2bc..98f16ae92 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -42,7 +42,7 @@ CChat::CChat() void CChat::RegisterCommand(const char *pName, const char *pParams, int flags, const char *pHelp) { - m_Commands.push_back(CCommand{pName, pParams}); + m_Commands.emplace_back(pName, pParams); } void CChat::RebuildChat() @@ -380,7 +380,7 @@ bool CChat::OnInput(IInput::CEvent Event) auto &Command = m_Commands[Index]; - if(str_startswith(Command.pName, pCommandStart)) + if(str_startswith(Command.m_pName, pCommandStart)) { pCompletionCommand = &Command; m_CompletionChosen = Index + SearchType * NumCommands; @@ -397,10 +397,10 @@ bool CChat::OnInput(IInput::CEvent Event) // add the command str_append(aBuf, "/", sizeof(aBuf)); - str_append(aBuf, pCompletionCommand->pName, sizeof(aBuf)); + str_append(aBuf, pCompletionCommand->m_pName, sizeof(aBuf)); // add separator - const char *pSeparator = pCompletionCommand->pParams[0] == '\0' ? "" : " "; + const char *pSeparator = pCompletionCommand->m_pParams[0] == '\0' ? "" : " "; str_append(aBuf, pSeparator, sizeof(aBuf)); if(*pSeparator) str_append(aBuf, pSeparator, sizeof(aBuf)); @@ -408,7 +408,7 @@ bool CChat::OnInput(IInput::CEvent Event) // add part after the name str_append(aBuf, m_Input.GetString() + m_PlaceholderOffset + m_PlaceholderLength, sizeof(aBuf)); - m_PlaceholderLength = str_length(pSeparator) + str_length(pCompletionCommand->pName) + 1; + m_PlaceholderLength = str_length(pSeparator) + str_length(pCompletionCommand->m_pName) + 1; m_OldChatStringLength = m_Input.GetLength(); m_Input.Set(aBuf); // TODO: Use Add instead m_Input.SetCursorOffset(m_PlaceholderOffset + m_PlaceholderLength); diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index 8e9fad858..645c57e2a 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -93,12 +93,18 @@ class CChat : public CComponent struct CCommand { - const char *pName; - const char *pParams; + const char *m_pName; + const char *m_pParams; - bool operator<(const CCommand &Other) const { return str_comp(pName, Other.pName) < 0; } - bool operator<=(const CCommand &Other) const { return str_comp(pName, Other.pName) <= 0; } - bool operator==(const CCommand &Other) const { return str_comp(pName, Other.pName) == 0; } + CCommand() {} + CCommand(const char *pName, const char *pParams) : + m_pName(pName), m_pParams(pParams) + { + } + + bool operator<(const CCommand &Other) const { return str_comp(m_pName, Other.m_pName) < 0; } + bool operator<=(const CCommand &Other) const { return str_comp(m_pName, Other.m_pName) <= 0; } + bool operator==(const CCommand &Other) const { return str_comp(m_pName, Other.m_pName) == 0; } }; std::vector m_Commands;