Skip to content

Commit

Permalink
make shure it doesent need a restart if creator is not root
Browse files Browse the repository at this point in the history
  • Loading branch information
Judro committed Dec 17, 2024
1 parent 968f145 commit 26518c7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/highscore.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ char print_highscore_flag = 0;
FILE *init_state_files() {
char username_n[100];
char *username = getenv("USER");
char is_root = 0;
if (strcmp(username, "root") == 0) {
printf("Please enter your username ($USER): ");
while (scanf("%s[^\n]", username_n) != 1)
;
username = username_n;
is_root = 1;
}
char save_path[strlen(save_directory) + strlen(username) + 5];
strcpy(save_path, save_directory);
Expand Down Expand Up @@ -51,10 +53,13 @@ FILE *init_state_files() {
exit(EXIT_FAILURE);
}
close(file);
printf("Game save files have been successfully created. Please restart the "
"game in non-superuser mode.\n");
if (is_root) {
printf(
"Game save files have been successfully created. Please restart the "
"game in non-superuser mode.\n");

exit(EXIT_SUCCESS);
exit(EXIT_SUCCESS);
}
}
return fopen(save_path, "a+");
}
Expand Down

0 comments on commit 26518c7

Please sign in to comment.