summaryrefslogtreecommitdiff
path: root/menuchoixpersos.c
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-01-07 14:12:16 +0100
committerOlivier Gayot <duskcoder@gmail.com>2015-01-07 14:12:16 +0100
commite93ad2847791222937e26b57da5fd01a527d38cc (patch)
treede8bf2b5696b7198b5904e0ec78eec77b73de54b /menuchoixpersos.c
parent8f725a8b90feeca18198add9cea3ff88e495581d (diff)
Fix use of uninitialized variable in Fmenuchoixpersos
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'menuchoixpersos.c')
-rw-r--r--menuchoixpersos.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/menuchoixpersos.c b/menuchoixpersos.c
index 325eadc..cc217a8 100644
--- a/menuchoixpersos.c
+++ b/menuchoixpersos.c
@@ -10,9 +10,9 @@
void Fmenuchoixpersos (SURFACES *surfaces, POSITIONS *positions)
{
TTF_Font *police = NULL;
- int Vchoix = 0;
+ int Vchoix = PALADIN;
SDL_Color vert;
- unsigned int continuer = 1;
+ bool continuer = true;
PERSONNAGES persos[3];
ENNEMIS ennemis[5];
SDL_Event event;
@@ -21,29 +21,40 @@ void Fmenuchoixpersos (SURFACES *surfaces, POSITIONS *positions)
vert.r = 39;
vert.g = 189;
vert.b = 31;
- SDL_BlitSurface (surfaces->Pchoixpaladin,NULL,surfaces->Pecran,&positions->Vpositionmenu);
+
police = TTF_OpenFont ("TIMESI.TTF",36);
- while (Vnbperso!=3)
- {
- continuer = 1;
- if (Vnbperso == 0)
- surfaces->Ptextechoixmenu = TTF_RenderText_Blended (police,"Choisissez la Classe de votre Premier Personnage",vert);
- else if (Vnbperso == 1)
- surfaces->Ptextechoixmenu = TTF_RenderText_Blended (police,"Choisissez la Classe de votre Deuxième Personnage",vert);
- else if (Vnbperso == 2)
- surfaces->Ptextechoixmenu = TTF_RenderText_Blended (police,"Choisissez la Classe de votre Troisième Personnage",vert);
- positions->Vpositiontextemenu.x=XWIN/2-surfaces->Ptextechoixmenu->w/2;
- if (persos[Vnbperso-1].classe == PALADIN)
+
+ /* loop until we have actually chosen our three characters */
+ while (Vnbperso < 3) {
+ static const char *strings[] = {
+ "Please choose the class of your first character",
+ "Please choose the class of your second character",
+ "Please choose the class of your third character",
+ };
+
+ /* display the background with the selected text */
+ if (Vchoix == PALADIN) {
SDL_BlitSurface (surfaces->Pchoixpaladin,NULL,surfaces->Pecran,&positions->Vpositionmenu);
- if (persos[Vnbperso-1].classe == PRETRE)
+ } else if (Vchoix == PRETRE) {
SDL_BlitSurface (surfaces->Pchoixpretre,NULL,surfaces->Pecran,&positions->Vpositionmenu);
- if (persos[Vnbperso-1].classe == VOLEUR)
+ } else if (Vchoix == VOLEUR) {
SDL_BlitSurface (surfaces->Pchoixvoleur,NULL,surfaces->Pecran,&positions->Vpositionmenu);
+ } else {
+ abort();
+ }
+
+ /* display the string associated with the current character number (aka Please choose ...) */
+ surfaces->Ptextechoixmenu = TTF_RenderText_Blended (police, strings[Vnbperso], vert);
+
+ positions->Vpositiontextemenu.x=XWIN/2-surfaces->Ptextechoixmenu->w/2;
+ SDL_BlitSurface (surfaces->Ptextechoixmenu,NULL,surfaces->Pecran,&positions->Vpositiontextemenu);
+
SDL_BlitSurface (surfaces->Ppretre,NULL,surfaces->Pecran,&positions->Vpositionmenupretre);
SDL_BlitSurface (surfaces->Ppaladin,NULL,surfaces->Pecran,&positions->Vpositionmenupaladin);
SDL_BlitSurface (surfaces->Pvoleur,NULL,surfaces->Pecran,&positions->Vpositionmenuvoleur);
- SDL_BlitSurface (surfaces->Ptextechoixmenu,NULL,surfaces->Pecran,&positions->Vpositiontextemenu);
SDL_Flip (surfaces->Pecran);
+
+ continuer = true;
while (continuer)
{
SDL_WaitEvent (&event);
@@ -82,7 +93,7 @@ void Fmenuchoixpersos (SURFACES *surfaces, POSITIONS *positions)
case SDLK_f:
Fremplirpersos (Vchoix,persos,Vnbperso);
Vnbperso++;
- continuer=0;
+ continuer = false;
break;
default:
break;