From 19a20b3c0bb1ff4230b2f3504bd5ed8e43ffab3c Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Thu, 29 Aug 2013 09:54:29 -0400 Subject: Took terminator into consideration when rendering highscores Fixes the bug where the 10th highscore would show 10:1 instead of just 10: --- hslist.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'hslist.cpp') diff --git a/hslist.cpp b/hslist.cpp index a0debd7..3e11e41 100644 --- a/hslist.cpp +++ b/hslist.cpp @@ -40,21 +40,21 @@ SDL_Surface* HighscoreList::render() Highscore* h = *it; int posw, posh; - char pos[3]; // 2 max characters in rank plus the colon at the end + char pos[4]; // 2 max characters in rank plus the colon at the end, plus terminator sprintf(pos, "%d:", h->getRank()); TTF_SizeText(posFont, pos, &posw, &posh); SDL_Rect posSpace = {0, (i+1)*40, posw, posh}; SDL_BlitSurface(TTF_RenderText_Blended(posFont, pos, fontColor), NULL, tmp, &posSpace); int namew, nameh; - char name[26]; // 25 max characters in username plus the space at the beginning + char name[27]; // 25 max characters in username plus the space at the beginning, plus terminator sprintf(name, " %s", h->getName()); TTF_SizeText(dataFont, name, &namew, &nameh); SDL_Rect nameSpace = {posw, (i+1)*40+((posh/2)-(nameh/2)), namew, nameh}; SDL_BlitSurface(TTF_RenderText_Blended(dataFont, name, fontColor), NULL, tmp, &nameSpace); int lvlw, lvlh; - char lvl[10]; // 10 max characters in level (based off the fact that 2^32-1 is 10 characters long, and is the highest int) + char lvl[11]; // 10 max characters in level (based off the fact that 2^32-1 is 10 characters long, and is the highest int), plus terminator sprintf(lvl, "%d", h->getLevel()); TTF_SizeText(dataFont, lvl, &lvlw, &lvlh); SDL_Rect lvlSpace = {480-lvlw, (i+1)*40+((posh/2)-(nameh/2)), lvlw, lvlh}; -- cgit 1.4.1