From: Holger Schemel Date: Tue, 17 Oct 2017 16:43:57 +0000 (+0200) Subject: fixed updating user level set fields (more generic approach) X-Git-Tag: 4.1.0.0~95 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=b73d298732ea8fe62b79ff23b84e8f5c4e0cf7e6;p=rocksndiamonds.git fixed updating user level set fields (more generic approach) --- diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 5784ac49..ab8ecd37 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -3525,24 +3525,20 @@ boolean UpdateUserLevelSet(char *level_subdir, FILE *file = NULL; FILE *file_tmp = NULL; char line[MAX_LINE_LEN]; - boolean update_num_levels_only = FALSE; boolean success = FALSE; - if (level_name == NULL || level_author == NULL || first_level_nr == -1) - update_num_levels_only = TRUE; - if ((file = fopen(filename, MODE_READ)) && (file_tmp = fopen(filename_tmp, MODE_WRITE))) { while (fgets(line, MAX_LINE_LEN, file)) { - if (strPrefix(line, "name:") && !update_num_levels_only) + if (strPrefix(line, "name:") && level_name != NULL) fprintf(file_tmp, "%-32s%s\n", "name:", level_name); - else if (strPrefix(line, "author:") && !update_num_levels_only) + else if (strPrefix(line, "author:") && level_author != NULL) fprintf(file_tmp, "%-32s%s\n", "author:", level_author); - else if (strPrefix(line, "levels:")) + else if (strPrefix(line, "levels:") && num_levels != -1) fprintf(file_tmp, "%-32s%d\n", "levels:", num_levels); - else if (strPrefix(line, "first_level:") && !update_num_levels_only) + else if (strPrefix(line, "first_level:") && first_level_nr != -1) fprintf(file_tmp, "%-32s%d\n", "first_level:", first_level_nr); else fputs(line, file_tmp);