else /* check for pre-2.0 file format with cookie string */
{
strcpy(cookie, chunk_name);
- fgets(&cookie[4], MAX_LINE_LEN - 4, file);
+ if (fgets(&cookie[4], MAX_LINE_LEN - 4, file) == NULL)
+ cookie[4] = '\0';
if (strlen(cookie) > 0 && cookie[strlen(cookie) - 1] == '\n')
cookie[strlen(cookie) - 1] = '\0';
if (level_file_info->packed)
{
/* read "magic bytes" from start of file */
- fgets(magic_bytes, num_magic_bytes + 1, file);
+ if (fgets(magic_bytes, num_magic_bytes + 1, file) == NULL)
+ magic_bytes[0] = '\0';
/* check "magic bytes" for correct file format */
if (!strPrefix(magic_bytes, "DC2"))
else /* check for pre-2.0 file format with cookie string */
{
strcpy(cookie, chunk_name);
- fgets(&cookie[4], MAX_LINE_LEN - 4, file);
+ if (fgets(&cookie[4], MAX_LINE_LEN - 4, file) == NULL)
+ cookie[4] = '\0';
if (strlen(cookie) > 0 && cookie[strlen(cookie) - 1] == '\n')
cookie[strlen(cookie) - 1] = '\0';
return;
/* check file identifier */
- fgets(cookie, MAX_LINE_LEN, file);
+ if (fgets(cookie, MAX_LINE_LEN, file) == NULL)
+ cookie[0] = '\0';
if (strlen(cookie) > 0 && cookie[strlen(cookie) - 1] == '\n')
cookie[strlen(cookie) - 1] = '\0';
for (i = 0; i < MAX_SCORE_ENTRIES; i++)
{
- fscanf(file, "%d", &highscore[i].Score);
- fgets(line, MAX_LINE_LEN, file);
+ if (fscanf(file, "%d", &highscore[i].Score) == EOF)
+ Error(ERR_WARN, "fscanf() failed; %s", strerror(errno));
+ if (fgets(line, MAX_LINE_LEN, file) == NULL)
+ line[0] = '\0';
- if (line[strlen(line) - 1] == '\n')
+ if (strlen(line) > 0 && line[strlen(line) - 1] == '\n')
line[strlen(line) - 1] = '\0';
for (line_ptr = line; *line_ptr; line_ptr++)
#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 30
#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 31
#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 32
+#define SETUP_TOKEN_VOLUME_SIMPLE 33
+#define SETUP_TOKEN_VOLUME_LOOPS 34
+#define SETUP_TOKEN_VOLUME_MUSIC 35
-#define NUM_GLOBAL_SETUP_TOKENS 33
+#define NUM_GLOBAL_SETUP_TOKENS 36
/* editor setup */
#define SETUP_TOKEN_EDITOR_EL_BOULDERDASH 0
{ TYPE_SWITCH3,&si.override_level_graphics, "override_level_graphics" },
{ TYPE_SWITCH3,&si.override_level_sounds, "override_level_sounds" },
{ TYPE_SWITCH3,&si.override_level_music, "override_level_music" },
+ { TYPE_INTEGER,&si.volume_simple, "volume_simple" },
+ { TYPE_INTEGER,&si.volume_loops, "volume_loops" },
+ { TYPE_INTEGER,&si.volume_music, "volume_music" },
};
static boolean not_used = FALSE;
si->override_level_sounds = FALSE;
si->override_level_music = FALSE;
+ si->volume_simple = 100; /* percent */
+ si->volume_loops = 100; /* percent */
+ si->volume_music = 100; /* percent */
+
si->editor.el_boulderdash = TRUE;
si->editor.el_emerald_mine = TRUE;
si->editor.el_emerald_mine_club = TRUE;
{
/* just to make things nicer :) */
if (i == SETUP_TOKEN_PLAYER_NAME + 1 ||
- i == SETUP_TOKEN_GRAPHICS_SET)
+ i == SETUP_TOKEN_GRAPHICS_SET ||
+ i == SETUP_TOKEN_VOLUME_SIMPLE)
fprintf(file, "\n");
fprintf(file, "%s\n", getSetupLine(global_setup_tokens, "", i));