Skip to content

Commit

Permalink
Add str_format_integer
Browse files Browse the repository at this point in the history
Add more efficient function for formatting integer-type values as strings.

A benchmark shows that using this function is significantly faster than using `str_format`. It is faster by a factor of 220 with Clang 15.0 O2 (https://quick-bench.com/q/U5VcabQ-I6a_PfHnW87StrawnEg) and by a factor of 12 with GCC 12.2 O2 (https://quick-bench.com/q/YI5oDo03Fa5gZU0hb2bvpANaZ1w).

This increases FPS in the editor by ~25% when many numbers are rendered for switch/tele/speedup/tune layers or with "Show Info" being enabled.

The additional static analysis for `std::to_chars` revealed that the wrong size was used in `CHud` for `aScoreTeam[TEAM_RED]` and `aScoreTeam[TEAM_BLUE]`.

This requires incrementing the macOS deployment target from 10.13 to 10.15.
  • Loading branch information
Robyt3 committed Aug 21, 2023
1 parent afbb95f commit d4a7ba0
Show file tree
Hide file tree
Showing 22 changed files with 81 additions and 62 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ if(CMAKE_VERSION VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_VERSION})
endif()

set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13 CACHE INTERNAL "Minimum macOS deployment version")
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.13)
message(WARNING "Building for macOS < 10.13 is not supported")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15 CACHE INTERNAL "Minimum macOS deployment version")
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.15)
message(WARNING "Building for macOS < 10.15 is not supported")
endif()

file(STRINGS src/game/version.h VERSION_LINE
Expand Down
9 changes: 9 additions & 0 deletions src/base/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define __USE_GNU
#endif

#include <charconv>
#include <cinttypes>
#include <cstdarg>
#include <cstdint>
Expand Down Expand Up @@ -2230,6 +2231,14 @@ unsigned long str_toulong_base(const char *str, int base);
int64_t str_toint64_base(const char *str, int base = 10);
float str_tofloat(const char *str);

template<typename T>
void str_format_integer(char *buffer, size_t buffer_size, T value, int base = 10)
{
buffer[0] = '\0'; // Fix false positive clang-analyzer-core.UndefinedBinaryOperatorResult when using result
auto result = std::to_chars(buffer, buffer + buffer_size - 1, value, base);
result.ptr[0] = '\0';
}

/**
* Determines whether a character is whitespace.
*
Expand Down
4 changes: 2 additions & 2 deletions src/engine/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,7 @@ void CServer::CacheServerInfo(CCache *pCache, int Type, bool SendClients)
#define ADD_INT(p, x) \
do \
{ \
str_format(aBuf, sizeof(aBuf), "%d", x); \
str_format_integer(aBuf, sizeof(aBuf), x); \
(p).AddString(aBuf, 0); \
} while(0)

Expand Down Expand Up @@ -2205,7 +2205,7 @@ void CServer::SendServerInfo(const NETADDR *pAddr, int Token, int Type, bool Sen
#define ADD_INT(p, x) \
do \
{ \
str_format(aBuf, sizeof(aBuf), "%d", x); \
str_format_integer(aBuf, sizeof(aBuf), x); \
(p).AddString(aBuf, 0); \
} while(0)

Expand Down
4 changes: 2 additions & 2 deletions src/engine/server/upnp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void CUPnP::Open(NETADDR Address)
{
m_Enabled = true;
dbg_msg("upnp", "found valid IGD: %s", m_pUPnPUrls->controlURL);
str_format(aPort, sizeof(aPort), "%d", m_Addr.port);
str_format_integer(aPort, sizeof(aPort), m_Addr.port);
Error = UPNP_AddPortMapping(m_pUPnPUrls->controlURL, m_pUPnPData->first.servicetype,
aPort, aPort, aLanAddr,
"DDNet Server " GAME_RELEASE_VERSION,
Expand All @@ -55,7 +55,7 @@ void CUPnP::Shutdown()
if(m_Enabled)
{
char aPort[6];
str_format(aPort, sizeof(aPort), "%d", m_Addr.port);
str_format_integer(aPort, sizeof(aPort), m_Addr.port);
int Error = UPNP_DeletePortMapping(m_pUPnPUrls->controlURL, m_pUPnPData->first.servicetype, aPort, "UDP", NULL);

if(Error != 0)
Expand Down
2 changes: 1 addition & 1 deletion src/engine/shared/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ void CConsole::ConUserCommandStatus(IResult *pResult, void *pUser)
CResult Result;
Result.m_pCommand = "access_status";
char aBuf[4];
str_format(aBuf, sizeof(aBuf), "%d", IConsole::ACCESS_LEVEL_USER);
str_format_integer(aBuf, sizeof(aBuf), (int)IConsole::ACCESS_LEVEL_USER);
Result.AddArgument(aBuf);

pConsole->ConCommandStatus(&Result, pConsole);
Expand Down
2 changes: 1 addition & 1 deletion src/engine/shared/jsonwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void CJsonWriter::WriteIntValue(int Value)
dbg_assert(CanWriteDatatype(), "Cannot write value here");
WriteIndent(false);
char aBuf[32];
str_format(aBuf, sizeof(aBuf), "%d", Value);
str_format_integer(aBuf, sizeof(aBuf), Value);
WriteInternal(aBuf);
CompleteDataType();
}
Expand Down
8 changes: 4 additions & 4 deletions src/game/client/components/debughud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ void CDebugHud::RenderNetCorrections()
str_format(aBuf, sizeof(aBuf), "%.2f", Ramp);
RenderRow("Ramp:", aBuf);

str_format(aBuf, sizeof(aBuf), "%d", pCharacter == nullptr ? -1 : pCharacter->m_TeleCheckpoint);
str_format_integer(aBuf, sizeof(aBuf), pCharacter == nullptr ? -1 : pCharacter->m_TeleCheckpoint);
RenderRow("Checkpoint:", aBuf);

str_format(aBuf, sizeof(aBuf), "%d", pCharacter == nullptr ? -1 : pCharacter->m_TuneZone);
str_format_integer(aBuf, sizeof(aBuf), pCharacter == nullptr ? -1 : pCharacter->m_TuneZone);
RenderRow("Tune zone:", aBuf);

str_format(aBuf, sizeof(aBuf), "%.2f", m_pClient->m_Snap.m_pLocalCharacter->m_X / 32.0f);
Expand All @@ -64,10 +64,10 @@ void CDebugHud::RenderNetCorrections()
str_format(aBuf, sizeof(aBuf), "%.2f", m_pClient->m_Snap.m_pLocalCharacter->m_Y / 32.0f);
RenderRow("Pos.y:", aBuf);

str_format(aBuf, sizeof(aBuf), "%d", m_pClient->m_Snap.m_pLocalCharacter->m_Angle);
str_format_integer(aBuf, sizeof(aBuf), m_pClient->m_Snap.m_pLocalCharacter->m_Angle);
RenderRow("Angle:", aBuf);

str_format(aBuf, sizeof(aBuf), "%d", m_pClient->NetobjNumCorrections());
str_format_integer(aBuf, sizeof(aBuf), m_pClient->NetobjNumCorrections());
RenderRow("Netobj corrections", aBuf);
RenderRow(" on:", m_pClient->NetobjCorrectedOn());
}
Expand Down
12 changes: 6 additions & 6 deletions src/game/client/components/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ void CHud::RenderScoreHud()
if(GameFlags & GAMEFLAG_TEAMS && m_pClient->m_Snap.m_pGameDataObj)
{
char aScoreTeam[2][16];
str_format(aScoreTeam[TEAM_RED], sizeof(aScoreTeam), "%d", m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreRed);
str_format(aScoreTeam[TEAM_BLUE], sizeof(aScoreTeam), "%d", m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreBlue);
str_format_integer(aScoreTeam[TEAM_RED], sizeof(aScoreTeam[TEAM_RED]), m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreRed);
str_format_integer(aScoreTeam[TEAM_BLUE], sizeof(aScoreTeam[TEAM_BLUE]), m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreBlue);

bool aRecreateTeamScore[2] = {str_comp(aScoreTeam[0], m_aScoreInfo[0].m_aScoreText) != 0, str_comp(aScoreTeam[1], m_aScoreInfo[1].m_aScoreText) != 0};

Expand Down Expand Up @@ -324,7 +324,7 @@ void CHud::RenderScoreHud()
aScore[t][0] = 0;
}
else
str_format(aScore[t], sizeof(aScore) / 2, "%d", apPlayerInfo[t]->m_Score);
str_format_integer(aScore[t], sizeof(aScore) / 2, apPlayerInfo[t]->m_Score);
}
else
aScore[t][0] = 0;
Expand Down Expand Up @@ -484,7 +484,7 @@ void CHud::RenderWarmupTimer()
if(Seconds < 5)
str_format(aBuf, sizeof(aBuf), "%d.%d", Seconds, (m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer * 10 / SERVER_TICK_SPEED) % 10);
else
str_format(aBuf, sizeof(aBuf), "%d", Seconds);
str_format_integer(aBuf, sizeof(aBuf), Seconds);
w = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(150 * Graphics()->ScreenAspect() + -w / 2, 75, FontSize, aBuf, -1.0f);
}
Expand All @@ -498,7 +498,7 @@ void CHud::RenderTextInfo()
m_FrameTimeAvg = m_FrameTimeAvg * 0.9f + Client()->RenderFrameTime() * 0.1f;
char aBuf[64];
int FrameTime = (int)(1.0f / m_FrameTimeAvg + 0.5f);
str_format(aBuf, sizeof(aBuf), "%d", FrameTime);
str_format_integer(aBuf, sizeof(aBuf), FrameTime);

static float s_TextWidth0 = TextRender()->TextWidth(12.f, "0", -1, -1.0f);
static float s_TextWidth00 = TextRender()->TextWidth(12.f, "00", -1, -1.0f);
Expand Down Expand Up @@ -527,7 +527,7 @@ void CHud::RenderTextInfo()
if(g_Config.m_ClShowpred)
{
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%d", Client()->GetPredictionTime());
str_format_integer(aBuf, sizeof(aBuf), Client()->GetPredictionTime());
TextRender()->Text(m_Width - 10 - TextRender()->TextWidth(12, aBuf, -1, -1.0f), g_Config.m_ClShowfps ? 20 : 5, 12, aBuf, -1.0f);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/game/client/components/mapimages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ void CMapImages::UpdateEntityLayerText(void *pTexBuffer, int ImageColorChannelCo
if(MaxNumber == -1)
MaxNumber = CurrentNumber * 10 - 1;

str_format(aBuf, sizeof(aBuf), "%d", CurrentNumber);
str_format_integer(aBuf, sizeof(aBuf), CurrentNumber);

int CurrentNumberSuitableFontSize = TextRender()->AdjustFontSize(aBuf, DigitsCount, TextureSize, MaxWidth);
int UniversalSuitableFontSize = CurrentNumberSuitableFontSize * 0.92f; // should be smoothed enough to fit any digits combination
Expand All @@ -460,7 +460,7 @@ void CMapImages::UpdateEntityLayerText(void *pTexBuffer, int ImageColorChannelCo

for(; CurrentNumber <= MaxNumber; ++CurrentNumber)
{
str_format(aBuf, sizeof(aBuf), "%d", CurrentNumber);
str_format_integer(aBuf, sizeof(aBuf), CurrentNumber);

float x = (CurrentNumber % 16) * 64;
float y = (CurrentNumber / 16) * 64;
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/components/menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ int CMenus::DoButton_CheckBox(const void *pID, const char *pText, int Checked, c
int CMenus::DoButton_CheckBox_Number(const void *pID, const char *pText, int Checked, const CUIRect *pRect)
{
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d", Checked);
str_format_integer(aBuf, sizeof(aBuf), Checked);
return DoButton_CheckBox_Common(pID, pText, aBuf, pRect);
}

Expand Down
6 changes: 3 additions & 3 deletions src/game/client/components/menus_browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void FormatServerbrowserPing(char *pBuffer, int BufferLength, const CServerInfo
{
if(!pInfo->m_LatencyIsEstimated)
{
str_format(pBuffer, BufferLength, "%d", pInfo->m_Latency);
str_format_integer(pBuffer, BufferLength, pInfo->m_Latency);
return;
}
static const char *LOCATION_NAMES[CServerInfo::NUM_LOCS] = {
Expand Down Expand Up @@ -345,7 +345,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
if(FriendsOnServer > 1)
{
char aBufFriendsOnServer[64];
str_format(aBufFriendsOnServer, sizeof(aBufFriendsOnServer), "%i", FriendsOnServer);
str_format_integer(aBufFriendsOnServer, sizeof(aBufFriendsOnServer), FriendsOnServer);
TextRender()->TextColor(0.94f, 0.8f, 0.8f, 1);
UI()->DoLabel(&IconText, aBufFriendsOnServer, 10.0f, TEXTALIGN_MC);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1);
Expand Down Expand Up @@ -1192,7 +1192,7 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View)
}
else if(ClientScoreKind == CServerInfo::CLIENT_SCORE_KIND_POINTS)
{
str_format(aTemp, sizeof(aTemp), "%d", CurrentClient.m_Score);
str_format_integer(aTemp, sizeof(aTemp), CurrentClient.m_Score);
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions src/game/client/components/menus_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,13 +984,13 @@ void CMenus::RenderDemoList(CUIRect MainView)
Labels.HSplitTop(20.0f, &Left, &Labels);
Left.VSplitLeft(150.0f, &Left, &Right);
UI()->DoLabel(&Left, Localize("Version:"), 14.0f, TEXTALIGN_ML);
str_format(aBuf, sizeof(aBuf), "%d", m_vDemos[m_DemolistSelectedIndex].m_Info.m_Version);
str_format_integer(aBuf, sizeof(aBuf), m_vDemos[m_DemolistSelectedIndex].m_Info.m_Version);
UI()->DoLabel(&Right, aBuf, 14.0f, TEXTALIGN_ML);
Labels.HSplitTop(5.0f, 0, &Labels);
Labels.HSplitTop(20.0f, &Left, &Labels);
Left.VSplitLeft(150.0f, &Left, &Right);
UI()->DoLabel(&Left, Localize("Markers:"), 14.0f, TEXTALIGN_ML);
str_format(aBuf, sizeof(aBuf), "%d", m_vDemos[m_DemolistSelectedIndex].NumMarkers());
str_format_integer(aBuf, sizeof(aBuf), m_vDemos[m_DemolistSelectedIndex].NumMarkers());
UI()->DoLabel(&Right, aBuf, 14.0f, TEXTALIGN_ML);

// right side
Expand Down Expand Up @@ -1181,7 +1181,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
else if(ID == COL_MARKERS && !Item.m_IsDir && Item.m_InfosLoaded && Item.m_Valid)
{
char aBuf[3];
str_format(aBuf, sizeof(aBuf), "%d", Item.NumMarkers());
str_format_integer(aBuf, sizeof(aBuf), Item.NumMarkers());
Button.VMargin(4.0f, &Button);
UI()->DoLabel(&Button, aBuf, 12.0f, TEXTALIGN_MR);
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/components/menus_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ void CMenus::DoJoystickAxisPicker(CUIRect View)

// Axis label
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d", i + 1);
str_format_integer(aBuf, sizeof(aBuf), i + 1);
if(Active)
TextRender()->TextColor(TextRender()->DefaultTextColor());
else
Expand Down
4 changes: 2 additions & 2 deletions src/game/client/components/nameplates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
{
YOffset -= FontSize;
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "%d", pPlayerInfo->m_ClientID);
str_format_integer(aBuf, sizeof(aBuf), pPlayerInfo->m_ClientID);
float XOffset = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f) / 2.0f;
TextRender()->TextColor(rgb);
TextRender()->Text(Position.x - XOffset, YOffset, FontSize, aBuf, -1.0f);
Expand Down Expand Up @@ -266,7 +266,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
{
YOffset -= FontSize;
char aBuf[12];
str_format(aBuf, sizeof(aBuf), "%d", pCharacter->GetStrongWeakID());
str_format_integer(aBuf, sizeof(aBuf), pCharacter->GetStrongWeakID());
float XOffset = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f) / 2.0f;
TextRender()->Text(Position.x - XOffset, YOffset, FontSize, aBuf, -1.0f);
}
Expand Down
12 changes: 6 additions & 6 deletions src/game/client/components/scoreboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
if(m_pClient->m_Snap.m_pGameDataObj)
{
int Score = Team == TEAM_RED ? m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreRed : m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreBlue;
str_format(aBuf, sizeof(aBuf), "%d", Score);
str_format_integer(aBuf, sizeof(aBuf), Score);
}
}
else
Expand All @@ -211,12 +211,12 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
m_pClient->m_Snap.m_apPlayerInfos[m_pClient->m_Snap.m_SpecInfo.m_SpectatorID])
{
int Score = m_pClient->m_Snap.m_apPlayerInfos[m_pClient->m_Snap.m_SpecInfo.m_SpectatorID]->m_Score;
str_format(aBuf, sizeof(aBuf), "%d", Score);
str_format_integer(aBuf, sizeof(aBuf), Score);
}
else if(m_pClient->m_Snap.m_pLocalInfo)
{
int Score = m_pClient->m_Snap.m_pLocalInfo->m_Score;
str_format(aBuf, sizeof(aBuf), "%d", Score);
str_format_integer(aBuf, sizeof(aBuf), Score);
}
}

Expand Down Expand Up @@ -370,7 +370,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
if(DDTeam == TEAM_SUPER)
str_copy(aBuf, Localize("Super"));
else
str_format(aBuf, sizeof(aBuf), "%d", DDTeam);
str_format_integer(aBuf, sizeof(aBuf), DDTeam);
TextRender()->SetCursor(&Cursor, x - 10.0f, y + Spacing + FontSize - (FontSize / 1.5f), FontSize / 1.5f, TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END);
Cursor.m_LineWidth = NameLength + 3;
}
Expand Down Expand Up @@ -405,7 +405,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
str_time((int64_t)absolute(pInfo->m_Score) * 100, TIME_HOURS, aBuf, sizeof(aBuf));
}
else
str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Score, -999, 99999));
str_format_integer(aBuf, sizeof(aBuf), clamp(pInfo->m_Score, -999, 99999));
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->SetCursor(&Cursor, ScoreOffset + ScoreLength - tw, y + (LineHeight - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER);
TextRender()->TextEx(&Cursor, aBuf, -1);
Expand Down Expand Up @@ -494,7 +494,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
ColorRGBA rgb = color_cast<ColorRGBA>(ColorHSLA((300.0f - clamp(pInfo->m_Latency, 0, 300)) / 1000.0f, 1.0f, 0.5f));
TextRender()->TextColor(rgb);
}
str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Latency, 0, 999));
str_format_integer(aBuf, sizeof(aBuf), clamp(pInfo->m_Latency, 0, 999));
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->SetCursor(&Cursor, PingOffset + PingLength - tw, y + (LineHeight - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END);
Cursor.m_LineWidth = PingLength;
Expand Down
14 changes: 7 additions & 7 deletions src/game/client/components/statboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,22 +293,22 @@ void CStatboard::RenderGlobalStats()

// FRAGS
{
str_format(aBuf, sizeof(aBuf), "%d", pStats->m_Frags);
str_format_integer(aBuf, sizeof(aBuf), pStats->m_Frags);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 85;
}
// DEATHS
{
str_format(aBuf, sizeof(aBuf), "%d", pStats->m_Deaths);
str_format_integer(aBuf, sizeof(aBuf), pStats->m_Deaths);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 85;
}
// SUICIDES
{
px += 10;
str_format(aBuf, sizeof(aBuf), "%d", pStats->m_Suicides);
str_format_integer(aBuf, sizeof(aBuf), pStats->m_Suicides);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 85;
Expand Down Expand Up @@ -340,22 +340,22 @@ void CStatboard::RenderGlobalStats()
}
// SPREE
{
str_format(aBuf, sizeof(aBuf), "%d", pStats->m_CurrentSpree);
str_format_integer(aBuf, sizeof(aBuf), pStats->m_CurrentSpree);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 85;
}
// BEST SPREE
{
str_format(aBuf, sizeof(aBuf), "%d", pStats->m_BestSpree);
str_format_integer(aBuf, sizeof(aBuf), pStats->m_BestSpree);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 85;
}
// GRABS
if(GameWithFlags)
{
str_format(aBuf, sizeof(aBuf), "%d", pStats->m_FlagGrabs);
str_format_integer(aBuf, sizeof(aBuf), pStats->m_FlagGrabs);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 85;
Expand All @@ -375,7 +375,7 @@ void CStatboard::RenderGlobalStats()
// FLAGS
if(GameWithFlags)
{
str_format(aBuf, sizeof(aBuf), "%d", pStats->m_FlagCaptures);
str_format_integer(aBuf, sizeof(aBuf), pStats->m_FlagCaptures);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
}
Expand Down
Loading

0 comments on commit d4a7ba0

Please sign in to comment.