diff --git a/src/engine/console.h b/src/engine/console.h index 026a1946f..f33ec45bc 100644 --- a/src/engine/console.h +++ b/src/engine/console.h @@ -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; diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 137280198..81d028b68 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -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)); } } } diff --git a/src/engine/shared/console.cpp b/src/engine/shared/console.cpp index fb97ec569..5e08a7740 100644 --- a/src/engine/shared/console.cpp +++ b/src/engine/shared/console.cpp @@ -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); } } diff --git a/src/engine/shared/console.h b/src/engine/shared/console.h index a77f660b5..bc85816d8 100644 --- a/src/engine/shared/console.h +++ b/src/engine/shared/console.h @@ -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);