ddnet/src/game/client/components/statboard.h
Robert Müller f634f66008 Fix memory leaks in auto stat CSV output, refactoring
And fix stringop-overflow warning:

In function 'str_copy',
    inlined from 'FormatStats' at src\game\client\components\statboard.cpp:541:10:
src\base\system.cpp:2524:16: warning: 'strncat' specified bound depends on the length of the source argument [-Wstringop-overflow=]
 2524 |         strncat(dst, src, dst_size - 1);
      |                ^
src\game\client\components\statboard.cpp: In member function 'FormatStats':
src\base\system.cpp:2557:27: note: length computed here
 2557 |         return (int)strlen(str);
      |                           ^
2022-05-15 20:24:26 +02:00

33 lines
856 B
C++

#ifndef GAME_CLIENT_COMPONENTS_STATBOARD_H
#define GAME_CLIENT_COMPONENTS_STATBOARD_H
#include <game/client/component.h>
#include <string>
class CStatboard : public CComponent
{
private:
bool m_Active;
bool m_ScreenshotTaken;
int64_t m_ScreenshotTime;
static void ConKeyStats(IConsole::IResult *pResult, void *pUserData);
void RenderGlobalStats();
void AutoStatScreenshot();
void AutoStatCSV();
std::string ReplaceCommata(char *pStr);
void FormatStats(char *pDest, size_t DestSize);
public:
CStatboard();
virtual int Sizeof() const override { return sizeof(*this); }
virtual void OnReset() override;
virtual void OnConsoleInit() override;
virtual void OnRender() override;
virtual void OnRelease() override;
virtual void OnMessage(int MsgType, void *pRawMsg) override;
bool IsActive();
};
#endif // GAME_CLIENT_COMPONENTS_STATBOARD_H