Skip to content

Commit

Permalink
Patch to avoid memory leaks, thanks to rodolforg
Browse files Browse the repository at this point in the history
  • Loading branch information
nevat committed Aug 23, 2013
1 parent 5a774b1 commit e04c9d0
Showing 1 changed file with 45 additions and 73 deletions.
118 changes: 45 additions & 73 deletions src/barradeestado.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,33 @@
#include <SDL_ttf.h>
#include "comun.h"

static const char *nome_habitacion[] = {
":)",
"A prayer of Hope",
"Tower of the Bell",
"Wine supplies"
":$",
"Escape !!!",
"Death is close",
"Abandoned church",
"The Altar",
"Hangman tree",
"Pestilent Beast",
"Cave of illusions",
"Plagued ruins",
"Catacombs",
"Hidden garden",
"Gloomy tunels",
"Lake of despair",
"The wheel of faith",
"Banquet of Death",
"Underground river",
"Unexpected gate",
"Evil church",
"Tortured souls",
"Ashes to ashes",
"Satan !!!"};

void barradeestado (SDL_Surface *ventana, SDL_Surface *tiles, int habitacion, int vidas, int cruces, TTF_Font *fuente) {

SDL_Rect srcbarra = {448,104,13,12};
Expand All @@ -19,7 +46,7 @@ void barradeestado (SDL_Surface *ventana, SDL_Surface *tiles, int habitacion, in
int i = 0;

char datos[1];
char nompantalla[18];
const char *nompantalla;
int ancho = 0;
int alto = 0;

Expand All @@ -31,77 +58,22 @@ void barradeestado (SDL_Surface *ventana, SDL_Surface *tiles, int habitacion, in

desmarcador.y = 174;

for (i=0; i<=2; i++) {
switch (i) {
case 0: sprintf(datos, "%d", vidas);
marcador = TTF_RenderText_Solid(fuente, datos, fgcolor);
desmarcador.x = 18;
break;
case 1: sprintf(datos, "%d", cruces);
marcador = TTF_RenderText_Solid(fuente, datos, fgcolor);
desmarcador.x = 50;
break;
case 2:
if (habitacion == 0)
sprintf (nompantalla, ":)");
if (habitacion == 1)
sprintf (nompantalla, "A prayer of Hope");
if (habitacion == 2)
sprintf (nompantalla, "Tower of the Bell");
if (habitacion == 3)
sprintf (nompantalla, "Wine supplies");
if (habitacion == 4)
sprintf (nompantalla, ":$");
if (habitacion == 5)
sprintf (nompantalla, "Escape !!!");
if (habitacion == 6)
sprintf (nompantalla, "Death is close");
if (habitacion == 7)
sprintf (nompantalla, "Abandoned church");
if (habitacion == 8)
sprintf (nompantalla, "The Altar");
if (habitacion == 9)
sprintf (nompantalla, "Hangman tree");
if (habitacion == 10)
sprintf (nompantalla, "Pestilent Beast");
if (habitacion == 11)
sprintf (nompantalla, "Cave of illusions");
if (habitacion == 12)
sprintf (nompantalla, "Plagued ruins");
if (habitacion == 13)
sprintf (nompantalla, "Catacombs");
if (habitacion == 14)
sprintf (nompantalla, "Hidden garden");
if (habitacion == 15)
sprintf (nompantalla, "Gloomy tunels");
if (habitacion == 16)
sprintf (nompantalla, "Lake of despair");
if (habitacion == 17)
sprintf (nompantalla, "The wheel of faith");
if (habitacion == 18)
sprintf (nompantalla, "Banquet of Death");
if (habitacion == 19)
sprintf (nompantalla, "Underground river");
if (habitacion == 20)
sprintf (nompantalla, "Unexpected gate");
if (habitacion == 21)
sprintf (nompantalla, "Evil church");
if (habitacion == 22)
sprintf (nompantalla, "Tortured souls");
if (habitacion == 23)
sprintf (nompantalla, "Ashes to ashes");
if (habitacion == 24)
sprintf (nompantalla, "Satan !!!");

marcador = TTF_RenderText_Solid(fuente, nompantalla, fgcolor);
TTF_SizeText(fuente, nompantalla, &ancho, &alto);
desmarcador.x = 256 - ancho;
break;
}

SDL_BlitSurface(marcador, NULL, ventana, &desmarcador);
SDL_FreeSurface (marcador);

}
sprintf(datos, "%d", vidas);
marcador = TTF_RenderText_Solid(fuente, datos, fgcolor);
desmarcador.x = 18;
SDL_BlitSurface(marcador, NULL, ventana, &desmarcador);

sprintf(datos, "%d", cruces);
marcador = TTF_RenderText_Solid(fuente, datos, fgcolor);
desmarcador.x = 50;
SDL_BlitSurface(marcador, NULL, ventana, &desmarcador);

nompantalla = nome_habitacion[habitacion];
marcador = TTF_RenderText_Solid(fuente, nompantalla, fgcolor);
TTF_SizeText(fuente, nompantalla, &ancho, &alto);
desmarcador.x = 256 - ancho;

SDL_BlitSurface(marcador, NULL, ventana, &desmarcador);
SDL_FreeSurface (marcador);

}

0 comments on commit e04c9d0

Please sign in to comment.