Added ai modes. Altered output of highscores to allow possible parsing with tools easier

This commit is contained in:
Tiehuis
2015-02-25 14:51:48 +13:00
parent 2d9f89f339
commit cf1a147078
7 changed files with 67 additions and 23 deletions
+8 -3
View File
@@ -78,23 +78,28 @@ reset_scores:;
fclose(fd);
}
void highscore_load(struct gamestate *g)
long highscore_load(struct gamestate *g)
{
const char *hsfile = highscore_retrieve_file();
long result = 0;
FILE *fd = fopen(hsfile, "r");
if (fd == NULL)
fd = fopen(hsfile, "w+");
fscanf(fd, "%ld", &g->score_high);
fscanf(fd, "%ld", &result);
fclose(fd);
if (g) g->score_high = result;
return result;
}
void highscore_save(struct gamestate *g)
{
/* Someone could make their own merge rules for highscores and this could be meaningless,
* howeverhighscores are in plaintext, so that isn't that much of a concern */
if (g->score < g->score_high || g->opts->grid_width != 4 || g->opts->grid_height != 4)
if (g->score < g->score_high || g->opts->grid_width != 4 ||
g->opts->grid_height != 4 || g->opts->ai == true)
return;
const char *hsfile = highscore_retrieve_file();