added updating internal level directory tree when changing user level set
authorHolger Schemel <info@artsoft.org>
Tue, 17 Oct 2017 16:57:55 +0000 (18:57 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 23 Mar 2018 22:21:14 +0000 (23:21 +0100)
src/libgame/setup.c

index d857883730534d1ce66596dbc418270bbf603380..d683b67c6b13b736166c362496cf3b1a1ef4645e 100644 (file)
@@ -3526,6 +3526,30 @@ boolean UpdateUserLevelSet(char *level_subdir,
   FILE *file_tmp = NULL;
   char line[MAX_LINE_LEN];
   boolean success = FALSE;
+  LevelDirTree *leveldir = getTreeInfoFromIdentifier(leveldir_first,
+                                                    level_subdir);
+  // update values in level directory tree
+
+  if (level_name != NULL)
+    setString(&leveldir->name, level_name);
+
+  if (level_author != NULL)
+    setString(&leveldir->author, level_author);
+
+  if (num_levels != -1)
+    leveldir->levels = num_levels;
+
+  if (first_level_nr != -1)
+    leveldir->first_level = first_level_nr;
+
+  // update values that depend on other values
+
+  setString(&leveldir->name_sorting, leveldir->name);
+
+  leveldir->last_level = leveldir->first_level + leveldir->levels - 1;
+
+  // sort order of level sets may have changed
+  sortTreeInfo(&leveldir_first);
 
   if ((file     = fopen(filename,     MODE_READ)) &&
       (file_tmp = fopen(filename_tmp, MODE_WRITE)))