чување db36d3795c5a0c7c2ef9690cfcfa9ae3751f8a3c
родитељ 45d20d18bbbfd478fb7b3e8dcab845228d98a9c9
Аутор: Страхиња Радић <sr@strahinja.org>
Датум: Tue, 4 Aug 2026 21:03:54 +0000
(hs_load): Ignore HOF file not existing initially; (handle_input): Cast keycode
Diffstat:
измењених датотека: 2, додавања: 10(+), брисања: 3(-)
diff --git a/hiscore.c b/hiscore.c
@@ -216,7 +216,13 @@ hs_load(struct HiScoreEntry** table, const char* hofdir)
snprintf(filename, filename_size, "%s/%s", hofdir, HOFFILE);
if (!(infile = fopen(filename, "rb")))
+ {
+ /* ENOENT means we don't have the file yet */
+ if (errno == ENOENT)
+ goto hs_load_cleanup;
+
goto hs_load_error;
+ }
i = 0;
while (!feof(infile) && i < HI_SCORE_MAX)
@@ -250,7 +256,8 @@ hs_load(struct HiScoreEntry** table, const char* hofdir)
i++;
}
- if (fclose(infile) == EOF)
+hs_load_cleanup:
+ if (infile && fclose(infile) == EOF)
goto hs_load_error;
free(filename);
diff --git a/linije.c b/linije.c
@@ -23,9 +23,9 @@
#include <time.h>
#include <unistd.h>
+#include "hiscore.h"
#include "local.h"
#include "version.h"
-#include "hiscore.h"
/* clang-format off */
#define ANIM_SPEED 100 /* how long does it take for the animation to go
@@ -1040,7 +1040,7 @@ handle_input(struct State* state, SDL_Event* event)
state->player_name[state->input_col++]
= event->key.mod & SDL_KMOD_SHIFT
? ascii_shift[event->key.key]
- : event->key.key;
+ : (char)event->key.key;
state->player_name_length++;
state->player_name[state->player_name_length] = 0;
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION,