Fix show_ips to show regular formatting (fixes #1873)

This commit is contained in:
def 2019-08-01 20:24:30 +02:00
parent 99b814342c
commit cb738ffed0
4 changed files with 17 additions and 8 deletions

View file

@ -98,6 +98,7 @@ public:
virtual int RegisterPrintCallback(int OutputLevel, FPrintCallback pfnPrintCallback, void *pUserData) = 0;
virtual void SetPrintOutputLevel(int Index, int OutputLevel) = 0;
virtual char *Format(char *pBuf, int Size, const char *pFrom, const char *pStr) = 0;
virtual void Print(int Level, const char *pFrom, const char *pStr, bool Highlighted = false) = 0;
virtual void SetTeeHistorianCommandCallback(FTeeHistorianCommandCallback pfnCallback, void *pUser) = 0;

View file

@ -2610,9 +2610,10 @@ void CServer::ConShowIps(IConsole::IResult *pResult, void *pUser)
}
else
{
char aBuf[9];
str_format(aBuf, sizeof(aBuf), "Value: %d", pServer->m_aClients[pServer->m_RconClientID].m_ShowIps);
pServer->SendRconLine(pServer->m_RconClientID, aBuf);
char aStr[9];
str_format(aStr, sizeof(aStr), "Value: %d", pServer->m_aClients[pServer->m_RconClientID].m_ShowIps);
char aBuf[32];
pServer->SendRconLine(pServer->m_RconClientID, pServer->Console()->Format(aBuf, sizeof(aBuf), "server", aStr));
}
}
}

View file

@ -304,18 +304,24 @@ void CConsole::SetPrintOutputLevel(int Index, int OutputLevel)
m_aPrintCB[Index].m_OutputLevel = clamp(OutputLevel, (int)(OUTPUT_LEVEL_STANDARD), (int)(OUTPUT_LEVEL_DEBUG));
}
char *CConsole::Format(char *pBuf, int Size, const char *pFrom, const char *pStr)
{
char aTimeBuf[80];
str_timestamp_format(aTimeBuf, sizeof(aTimeBuf), FORMAT_TIME);
str_format(pBuf, Size, "[%s][%s]: %s", aTimeBuf, pFrom, pStr);
return pBuf;
}
void CConsole::Print(int Level, const char *pFrom, const char *pStr, bool Highlighted)
{
dbg_msg(pFrom ,"%s", pStr);
char aBuf[1024];
Format(aBuf, sizeof(aBuf), pFrom, pStr);
for(int i = 0; i < m_NumPrintCB; ++i)
{
if(Level <= m_aPrintCB[i].m_OutputLevel && m_aPrintCB[i].m_pfnPrintCallback)
{
char aTimeBuf[80];
str_timestamp_format(aTimeBuf, sizeof(aTimeBuf), FORMAT_TIME);
char aBuf[1024];
str_format(aBuf, sizeof(aBuf), "[%s][%s]: %s", aTimeBuf, pFrom, pStr);
m_aPrintCB[i].m_pfnPrintCallback(aBuf, m_aPrintCB[i].m_pPrintCallbackUserdata, Highlighted);
}
}

View file

@ -206,6 +206,7 @@ public:
virtual int RegisterPrintCallback(int OutputLevel, FPrintCallback pfnPrintCallback, void *pUserData);
virtual void SetPrintOutputLevel(int Index, int OutputLevel);
virtual char *Format(char *pBuf, int Size, const char *pFrom, const char *pStr);
virtual void Print(int Level, const char *pFrom, const char *pStr, bool Highlighted = false);
virtual void SetTeeHistorianCommandCallback(FTeeHistorianCommandCallback pfnCallback, void *pUser);