From: Holger Schemel Date: Tue, 5 Dec 2023 18:05:08 +0000 (+0100) Subject: added forcing user to restart program after adding level collection X-Git-Tag: 4.3.8.0~10 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=375d84a0da3b1254915bd034fe327f094e87a4a1;p=rocksndiamonds.git added forcing user to restart program after adding level collection When adding a level group or an artwork group by dropping a zip file into the program window, show a request dialog that the program has to be restarted to activate the new content. Unfortunately, this is currently required to rebuild the internal level and artwork set structures (and should be improved to be rebuild them on-the-fly without a program restart). Before, the program was just stopped with a user-unfriendly message reporting a fatal error. --- diff --git a/src/events.c b/src/events.c index d9ba0586..87eaa2b9 100644 --- a/src/events.c +++ b/src/events.c @@ -1551,6 +1551,15 @@ static int HandleDropFileEvent(char *filename) // add extracted level or artwork set to tree info structure AddTreeSetToTreeInfo(tree_node, directory, top_dir, tree_type); + // force restart after adding level collection + if (getTreeInfoFromIdentifier(TREE_FIRST_NODE(tree_type), top_dir) == NULL) + { + Request("Program must be restarted after adding a new level collection!", + REQ_CONFIRM); + + CloseAllAndExit(0); + } + // update menu screen (and possibly change current level set) DrawScreenAfterAddingSet(top_dir, tree_type); diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 493fc74e..b419875a 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -4594,6 +4594,12 @@ static boolean AddTreeSetToTreeInfoExt(TreeInfo *tree_node_old, char *tree_dir, TreeInfo *tree_node_new = getTreeInfoFromIdentifier(*tree_node_first, tree_subdir_new); + // if not found, check if added node is level group or artwork group + if (tree_node_new == NULL) + tree_node_new = getTreeInfoFromIdentifierExt(*tree_node_first, + tree_subdir_new, + TREE_NODE_TYPE_GROUP); + if (tree_node_new == NULL) // should not happen return FALSE;