summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2013-08-29 09:54:29 -0400
committerStarla Insigna <starla4444@gmail.com>2013-08-29 09:54:29 -0400
commit19a20b3c0bb1ff4230b2f3504bd5ed8e43ffab3c (patch)
treedeafef8a59634718fc3c258ffc2bf4e98dc04c02
parent157457f94783d712e6af1a3e29268ab6bcfb8f99 (diff)
downloadmazeoflife-19a20b3c0bb1ff4230b2f3504bd5ed8e43ffab3c.tar.gz
mazeoflife-19a20b3c0bb1ff4230b2f3504bd5ed8e43ffab3c.tar.bz2
mazeoflife-19a20b3c0bb1ff4230b2f3504bd5ed8e43ffab3c.zip
Took terminator into consideration when rendering highscores
Fixes the bug where the 10th highscore would show 10:1 instead of just 10:
-rw-r--r--hslist.cpp6
1 files changed, 3 insertions, 3 deletions
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()
40 Highscore* h = *it; 40 Highscore* h = *it;
41 41
42 int posw, posh; 42 int posw, posh;
43 char pos[3]; // 2 max characters in rank plus the colon at the end 43 char pos[4]; // 2 max characters in rank plus the colon at the end, plus terminator
44 sprintf(pos, "%d:", h->getRank()); 44 sprintf(pos, "%d:", h->getRank());
45 TTF_SizeText(posFont, pos, &posw, &posh); 45 TTF_SizeText(posFont, pos, &posw, &posh);
46 SDL_Rect posSpace = {0, (i+1)*40, posw, posh}; 46 SDL_Rect posSpace = {0, (i+1)*40, posw, posh};
47 SDL_BlitSurface(TTF_RenderText_Blended(posFont, pos, fontColor), NULL, tmp, &posSpace); 47 SDL_BlitSurface(TTF_RenderText_Blended(posFont, pos, fontColor), NULL, tmp, &posSpace);
48 48
49 int namew, nameh; 49 int namew, nameh;
50 char name[26]; // 25 max characters in username plus the space at the beginning 50 char name[27]; // 25 max characters in username plus the space at the beginning, plus terminator
51 sprintf(name, " %s", h->getName()); 51 sprintf(name, " %s", h->getName());
52 TTF_SizeText(dataFont, name, &namew, &nameh); 52 TTF_SizeText(dataFont, name, &namew, &nameh);
53 SDL_Rect nameSpace = {posw, (i+1)*40+((posh/2)-(nameh/2)), namew, nameh}; 53 SDL_Rect nameSpace = {posw, (i+1)*40+((posh/2)-(nameh/2)), namew, nameh};
54 SDL_BlitSurface(TTF_RenderText_Blended(dataFont, name, fontColor), NULL, tmp, &nameSpace); 54 SDL_BlitSurface(TTF_RenderText_Blended(dataFont, name, fontColor), NULL, tmp, &nameSpace);
55 55
56 int lvlw, lvlh; 56 int lvlw, lvlh;
57 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) 57 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
58 sprintf(lvl, "%d", h->getLevel()); 58 sprintf(lvl, "%d", h->getLevel());
59 TTF_SizeText(dataFont, lvl, &lvlw, &lvlh); 59 TTF_SizeText(dataFont, lvl, &lvlw, &lvlh);
60 SDL_Rect lvlSpace = {480-lvlw, (i+1)*40+((posh/2)-(nameh/2)), lvlw, lvlh}; 60 SDL_Rect lvlSpace = {480-lvlw, (i+1)*40+((posh/2)-(nameh/2)), lvlw, lvlh};