From: Holger Schemel Date: Sun, 15 Oct 2017 19:06:29 +0000 (+0200) Subject: replaced duplicate code for updating user level set with function call X-Git-Tag: 4.1.0.0~98 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=1f03a0834b693a361bb98d883cec8f8ef9232681;p=rocksndiamonds.git replaced duplicate code for updating user level set with function call --- diff --git a/src/editor.c b/src/editor.c index cfcf8288..d78703f3 100644 --- a/src/editor.c +++ b/src/editor.c @@ -7508,37 +7508,7 @@ static void ModifyLevelInfoForSavingIntoPersonalLevelSet(char *former_name) } if (level_nr > leveldir_current->last_level) - { - static char *temp_levelinfo = NULL; - FILE *temp_file = NULL; - char line[MAX_LINE_LEN]; - - setString(&temp_levelinfo, - getPath2(getCurrentLevelDir(), - getStringCat2(LEVELINFO_FILENAME, ".new"))); - - if ((file = fopen(filename_levelinfo, MODE_READ)) && - (temp_file = fopen(temp_levelinfo, MODE_WRITE))) - { - while (fgets(line, MAX_LINE_LEN, file)) - { - if (!strPrefix(line, "levels:")) - fputs(line, temp_file); - else - fprintf(temp_file, "%-32s%d\n", "levels:", level_nr + 9); - } - } - - if (temp_file) - fclose(temp_file); - - if (file) - fclose(file); - - // needs error handling; also, ok on dos/win? - unlink(filename_levelinfo); - rename(temp_levelinfo, filename_levelinfo); - } + UpdateUserLevelSet(getLoginName(), NULL, NULL, level_nr + 9, -1); // else: allow the save even if annotation failed