return instead of assert

This commit is contained in:
Mylloon 2023-05-03 21:14:21 +02:00
parent c679e2bf9a
commit dadc103aed
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 8 additions and 2 deletions

View file

@ -17,6 +17,8 @@ int initFont(TTF_Font **, char *, int);
*
* Renvoie 1 en cas de problème d'écriture sur la surface
*
* Renvoie 2 en cas de problème de surface avec la SDL
*
* Renvoie 0 en cas de succès */
int writeText(GLuint *, TTF_Font *, char *, SDL_Color);

View file

@ -27,8 +27,12 @@ int writeText(GLuint *_textTexId, TTF_Font *font, char *text, SDL_Color color) {
return 1;
}
assert((s = SDL_CreateRGBSurface(0, d->w, d->h, 32, R_MASK, G_MASK, B_MASK,
A_MASK)));
if ((s = SDL_CreateRGBSurface(0, d->w, d->h, 32, R_MASK, G_MASK, B_MASK,
A_MASK))) {
freeFont(font);
fprintf(stderr, "Erreur SDL : %s\n", SDL_GetError());
return 2;
}
SDL_BlitSurface(d, NULL, s, NULL);
SDL_FreeSurface(d);