{
strcpy(scores.entry[i].name, EMPTY_PLAYER_NAME);
scores.entry[i].score = 0;
+ scores.entry[i].time = 0;
}
}
return chunk_size;
}
+static int LoadScore_TIME(File *file, int chunk_size, struct ScoreInfo *scores)
+{
+ int i;
+
+ for (i = 0; i < scores->num_entries; i++)
+ scores->entry[i].time = getFile32BitBE(file);
+
+ chunk_size = scores->num_entries * 4;
+
+ return chunk_size;
+}
+
void LoadScore(int nr)
{
char *filename = getScoreFilename(nr);
{ "INFO", -1, LoadScore_INFO },
{ "NAME", -1, LoadScore_NAME },
{ "SCOR", -1, LoadScore_SCOR },
+ { "TIME", -1, LoadScore_TIME },
{ NULL, 0, NULL }
};
putFile16BitBE(file, scores->entry[i].score);
}
+static void SaveScore_TIME(FILE *file, struct ScoreInfo *scores)
+{
+ int i;
+
+ for (i = 0; i < scores->num_entries; i++)
+ putFile32BitBE(file, scores->entry[i].time);
+}
+
static void SaveScoreToFilename(char *filename)
{
FILE *file;
int info_chunk_size;
int name_chunk_size;
int scor_chunk_size;
+ int time_chunk_size;
if (!(file = fopen(filename, MODE_WRITE)))
{
info_chunk_size = 2 + (strlen(scores.level_identifier) + 1) + 2 + 2;
name_chunk_size = scores.num_entries * MAX_PLAYER_NAME_LEN;
scor_chunk_size = scores.num_entries * 2;
+ time_chunk_size = scores.num_entries * 4;
putFileChunkBE(file, "RND1", CHUNK_SIZE_UNDEFINED);
putFileChunkBE(file, "SCOR", CHUNK_SIZE_NONE);
putFileChunkBE(file, "SCOR", scor_chunk_size);
SaveScore_SCOR(file, &scores);
+ putFileChunkBE(file, "TIME", time_chunk_size);
+ SaveScore_TIME(file, &scores);
+
fclose(file);
SetFilePermissions(filename, permissions);
for (i = 0; i < MAX_SCORE_ENTRIES; i++)
if (scores.entry[i].score == 0 &&
+ scores.entry[i].time == 0 &&
strEqual(scores.entry[i].name, EMPTY_PLAYER_NAME))
break;