summaryrefslogtreecommitdiffstats
path: root/src/help.c
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-03-19 10:59:04 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-03-19 10:59:04 (EDT)
commit2b3d6f3c16342a25e852aa86c0f5ab3bc214a4ca (patch)
treec690e2159ca91f416e3af0dc634fe9ae967f5f20 /src/help.c
parent68cbaa12b3308716b1cb6dac82b138da7d3cbe9c (diff)
downloaddodge-balls-2b3d6f3c16342a25e852aa86c0f5ab3bc214a4ca.zip
dodge-balls-2b3d6f3c16342a25e852aa86c0f5ab3bc214a4ca.tar.gz
dodge-balls-2b3d6f3c16342a25e852aa86c0f5ab3bc214a4ca.tar.bz2
main-menu, help: Handle quit through call stack
Diffstat (limited to 'src/help.c')
-rw-r--r--src/help.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/help.c b/src/help.c
index 71c2f35..0399c36 100644
--- a/src/help.c
+++ b/src/help.c
@@ -85,7 +85,7 @@ _db_help_triangle(SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SDL_RenderDrawPoints(renderer, points, i);
}
-void
+int
db_help(void)
{
char *font_path;
@@ -121,6 +121,8 @@ db_help(void)
return;
}
+ TTF_CloseFont(font);
+
texture = SDL_CreateTextureFromSurface(renderer, surface);
if (texture == NULL) {
db_err("Failed to create texture (%s)", SDL_GetError());
@@ -141,7 +143,7 @@ db_help(void)
while (SDL_WaitEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
- _db_help_quit = 1;
+ _db_help_quit = 2;
break;
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
@@ -181,7 +183,7 @@ db_help(void)
default:
break;
}
- if (_db_help_quit == 1) {
+ if (_db_help_quit > 0) {
break;
}
SDL_SetRenderDrawColor(renderer, 0x7F, 0x7F, 0x7F, 0xFF);
@@ -204,4 +206,9 @@ db_help(void)
}
SDL_RenderPresent(renderer);
}
+
+ SDL_FreeSurface(surface);
+ SDL_DestroyTexture(texture);
+
+ return _db_help_quit - 1;
}