for (i = 0; i < MAX_SCORE_ENTRIES; i++)
{
- strcpy(highscore[i].Name, EMPTY_PLAYER_NAME);
- highscore[i].Score = 0;
+ strcpy(scores.entry[i].name, EMPTY_PLAYER_NAME);
+ scores.entry[i].score = 0;
}
}
for (i = 0; i < MAX_SCORE_ENTRIES; i++)
{
- if (fscanf(file, "%d", &highscore[i].Score) == EOF)
+ if (fscanf(file, "%d", &scores.entry[i].score) == EOF)
Warn("fscanf() failed; %s", strerror(errno));
if (fgets(line, MAX_LINE_LEN, file) == NULL)
{
if (*line_ptr != ' ' && *line_ptr != '\t' && *line_ptr != '\0')
{
- strncpy(highscore[i].Name, line_ptr, MAX_PLAYER_NAME_LEN);
- highscore[i].Name[MAX_PLAYER_NAME_LEN] = '\0';
+ strncpy(scores.entry[i].name, line_ptr, MAX_PLAYER_NAME_LEN);
+ scores.entry[i].name[MAX_PLAYER_NAME_LEN] = '\0';
break;
}
}
for (i = 0; i < scores->num_entries; i++)
{
for (j = 0; j < MAX_PLAYER_NAME_LEN; j++)
- highscore[i].Name[j] = getFile8Bit(file);
+ scores->entry[i].name[j] = getFile8Bit(file);
- highscore[i].Name[MAX_PLAYER_NAME_LEN] = '\0';
+ scores->entry[i].name[MAX_PLAYER_NAME_LEN] = '\0';
}
chunk_size = scores->num_entries * MAX_PLAYER_NAME_LEN;
int i;
for (i = 0; i < scores->num_entries; i++)
- highscore[i].Score = getFile16BitBE(file);
+ scores->entry[i].score = getFile16BitBE(file);
chunk_size = scores->num_entries * 2;
fprintf(file, "%s\n\n", SCORE_COOKIE);
for (i = 0; i < MAX_SCORE_ENTRIES; i++)
- fprintf(file, "%d %s\n", highscore[i].Score, highscore[i].Name);
+ fprintf(file, "%d %s\n", scores.entry[i].score, scores.entry[i].name);
fclose(file);
for (i = 0; i < scores->num_entries; i++)
{
- int name_size = strlen(highscore[i].Name);
+ int name_size = strlen(scores->entry[i].name);
for (j = 0; j < MAX_PLAYER_NAME_LEN; j++)
- putFile8Bit(file, (j < name_size ? highscore[i].Name[j] : 0));
+ putFile8Bit(file, (j < name_size ? scores->entry[i].name[j] : 0));
}
}
int i;
for (i = 0; i < scores->num_entries; i++)
- putFile16BitBE(file, highscore[i].Score);
+ putFile16BitBE(file, scores->entry[i].score);
}
static void SaveScoreToFilename(char *filename)
scores.level_nr = level_nr;
for (i = 0; i < MAX_SCORE_ENTRIES; i++)
- if (highscore[i].Score == 0 &&
- strEqual(highscore[i].Name, EMPTY_PLAYER_NAME))
+ if (scores.entry[i].score == 0 &&
+ strEqual(scores.entry[i].name, EMPTY_PLAYER_NAME))
break;
scores.num_entries = i;
}
game_panel_controls[GAME_PANEL_SCORE].value = score;
- game_panel_controls[GAME_PANEL_HIGHSCORE].value = highscore[0].Score;
+ game_panel_controls[GAME_PANEL_HIGHSCORE].value = scores.entry[0].score;
game_panel_controls[GAME_PANEL_TIME].value = time;
LoadScore(level_nr);
if (strEqual(setup.player_name, EMPTY_PLAYER_NAME) ||
- game.score_final < highscore[MAX_SCORE_ENTRIES - 1].Score)
+ game.score_final < scores.entry[MAX_SCORE_ENTRIES - 1].score)
return -1;
for (k = 0; k < MAX_SCORE_ENTRIES; k++)
{
- if (game.score_final > highscore[k].Score)
+ if (game.score_final > scores.entry[k].score)
{
// player has made it to the hall of fame
if (one_score_entry_per_name)
{
for (l = k; l < MAX_SCORE_ENTRIES; l++)
- if (strEqual(setup.player_name, highscore[l].Name))
+ if (strEqual(setup.player_name, scores.entry[l].name))
m = l;
if (m == k) // player's new highscore overwrites his old one
for (l = m; l > k; l--)
{
- strcpy(highscore[l].Name, highscore[l - 1].Name);
- highscore[l].Score = highscore[l - 1].Score;
+ strcpy(scores.entry[l].name, scores.entry[l - 1].name);
+ scores.entry[l].score = scores.entry[l - 1].score;
}
}
put_into_list:
- strncpy(highscore[k].Name, setup.player_name, MAX_PLAYER_NAME_LEN);
- highscore[k].Name[MAX_PLAYER_NAME_LEN] = '\0';
- highscore[k].Score = game.score_final;
+ strncpy(scores.entry[k].name, setup.player_name, MAX_PLAYER_NAME_LEN);
+ scores.entry[k].name[MAX_PLAYER_NAME_LEN] = '\0';
+ scores.entry[k].score = game.score_final;
position = k;
break;
}
else if (one_score_entry_per_name &&
- !strncmp(setup.player_name, highscore[k].Name,
+ !strncmp(setup.player_name, scores.entry[k].name,
MAX_PLAYER_NAME_LEN))
break; // player already there with a higher score
}
struct LevelInfo level, level_template;
struct PlayerInfo stored_player[MAX_PLAYERS], *local_player = NULL;
-struct HiScore highscore[MAX_SCORE_ENTRIES];
struct ScoreInfo scores;
struct TapeInfo tape;
struct GameInfo game;
struct RectWithBorder door_2[NUM_SPECIAL_GFX_ARGS];
};
-struct HiScore
+struct ScoreEntry
{
- char Name[MAX_PLAYER_NAME_LEN + 1];
- int Score;
+ char name[MAX_PLAYER_NAME_LEN + 1];
+ int score;
};
struct ScoreInfo
int level_nr;
int num_entries;
+
+ struct ScoreEntry entry[MAX_SCORE_ENTRIES];
};
struct Content
extern int graphics_action_mapping[];
extern struct LevelInfo level, level_template;
-extern struct HiScore highscore[];
extern struct ScoreInfo scores;
extern struct TapeInfo tape;
extern struct GlobalInfo global;
for (j = 0; j < num_dots; j++)
DrawText(mSX + dx2 + j * getFontWidth(font_nr3), sy, ".", font_nr3);
- if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME))
- DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2);
+ if (!strEqual(scores.entry[entry].name, EMPTY_PLAYER_NAME))
+ DrawText(mSX + dx2, sy, scores.entry[entry].name, font_nr2);
- DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4);
+ DrawText(mSX + dx3, sy, int2str(scores.entry[entry].score, 5), font_nr4);
}
redraw_mask |= REDRAW_FIELD;