X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsetup.c;h=22fd408408e767508e4e336cd0cdf39781adb864;hb=3cc2ee99e57014c6962d26365e92bd3eac36a492;hp=69eecdb54140b75ef1422a42c7739aecee79c294;hpb=ce0ddd8fa8de5b935099390718980e59d4d10a09;p=rocksndiamonds.git diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 69eecdb5..22fd4084 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -178,7 +178,7 @@ static char *getNetworkDir(void) return network_dir; } -static char *getLevelDirFromTreeInfo(TreeInfo *node) +char *getLevelDirFromTreeInfo(TreeInfo *node) { static char *level_dir = NULL; @@ -3860,32 +3860,29 @@ void LoadLevelArtworkInfo(void) print_timestamp_done("LoadLevelArtworkInfo"); } -static boolean AddUserTreeSetToTreeInfoExt(char *tree_subdir_new, int type) +static boolean AddTreeSetToTreeInfoExt(TreeInfo *tree_node_old, char *tree_dir, + char *tree_subdir_new, int type) { - TreeInfo **tree_node_first, *tree_node_old, *tree_node_new; - char *tree_user_dir = TREE_USERDIR(type); - - if (tree_user_dir == NULL) // should not happen - return FALSE; - - // get first node of level or artwork tree - tree_node_first = TREE_FIRST_NODE_PTR(type); - - if (tree_node_first == NULL) // should not happen - return FALSE; - - if (type == TREE_TYPE_LEVEL_DIR) - { - // get level info tree node of personal user level set - tree_node_old = getTreeInfoFromIdentifier(*tree_node_first, getLoginName()); - } - else + if (tree_node_old == NULL) { - // get artwork info tree node of first artwork set - tree_node_old = *tree_node_first; + if (type == TREE_TYPE_LEVEL_DIR) + { + // get level info tree node of personal user level set + tree_node_old = getTreeInfoFromIdentifier(leveldir_first, getLoginName()); + } + else + { + // get artwork info tree node of first artwork set + tree_node_old = ARTWORK_FIRST_NODE(artwork, type); + } } - if (tree_node_old == NULL) // should not happen + if (tree_dir == NULL) + tree_dir = TREE_USERDIR(type); + + if (tree_node_old == NULL || + tree_dir == NULL || + tree_subdir_new == NULL) // should not happen return FALSE; int draw_deactivation_mask = GetDrawDeactivationMask(); @@ -3896,21 +3893,27 @@ static boolean AddUserTreeSetToTreeInfoExt(char *tree_subdir_new, int type) if (type == TREE_TYPE_LEVEL_DIR) { // load new level set config and add it next to first user level set - LoadLevelInfoFromLevelConf(&tree_node_old->next, NULL, - tree_user_dir, tree_subdir_new); + LoadLevelInfoFromLevelConf(&tree_node_old->next, + tree_node_old->node_parent, + tree_dir, tree_subdir_new); } else { // load new artwork set config and add it next to first artwork set - LoadArtworkInfoFromArtworkConf(&tree_node_old->next, NULL, - tree_user_dir, tree_subdir_new, type); + LoadArtworkInfoFromArtworkConf(&tree_node_old->next, + tree_node_old->node_parent, + tree_dir, tree_subdir_new, type); } // set draw deactivation mask to previous value SetDrawDeactivationMask(draw_deactivation_mask); - // get tree info tree node of newly added tree set - tree_node_new = getTreeInfoFromIdentifier(*tree_node_first, tree_subdir_new); + // get first node of level or artwork info tree + TreeInfo **tree_node_first = TREE_FIRST_NODE_PTR(type); + + // get tree info node of newly added level or artwork set + TreeInfo *tree_node_new = getTreeInfoFromIdentifier(*tree_node_first, + tree_subdir_new); if (tree_node_new == NULL) // should not happen return FALSE; @@ -3919,21 +3922,22 @@ static boolean AddUserTreeSetToTreeInfoExt(char *tree_subdir_new, int type) tree_node_new->node_top = tree_node_old->node_top; tree_node_new->node_parent = tree_node_old->node_parent; - // sort tree info tree to adjust position of newly added tree set + // sort tree info to adjust position of newly added tree set sortTreeInfo(tree_node_first); return TRUE; } -void AddUserTreeSetToTreeInfo(char *tree_subdir_new, int type) +void AddTreeSetToTreeInfo(TreeInfo *tree_node, char *tree_dir, + char *tree_subdir_new, int type) { - if (!AddUserTreeSetToTreeInfoExt(tree_subdir_new, type)) - Error(ERR_EXIT, "internal tree set structure corrupted -- aborting"); + if (!AddTreeSetToTreeInfoExt(tree_node, tree_dir, tree_subdir_new, type)) + Error(ERR_EXIT, "internal tree info structure corrupted -- aborting"); } void AddUserLevelSetToLevelInfo(char *level_subdir_new) { - AddUserTreeSetToTreeInfo(level_subdir_new, TREE_TYPE_LEVEL_DIR); + AddTreeSetToTreeInfo(NULL, NULL, level_subdir_new, TREE_TYPE_LEVEL_DIR); } char *getArtworkIdentifierForUserLevelSet(int type) @@ -3963,8 +3967,17 @@ TreeInfo *getArtworkTreeInfoForUserLevelSet(int type) { char *artwork_set = getArtworkIdentifierForUserLevelSet(type); TreeInfo *artwork_first_node = ARTWORK_FIRST_NODE(artwork, type); + TreeInfo *ti = getTreeInfoFromIdentifier(artwork_first_node, artwork_set); - return getTreeInfoFromIdentifier(artwork_first_node, artwork_set); + if (ti == NULL) + { + ti = getTreeInfoFromIdentifier(artwork_first_node, + ARTWORK_DEFAULT_SUBDIR(type)); + if (ti == NULL) + Error(ERR_EXIT, "cannot find default graphics -- should not happen"); + } + + return ti; } boolean checkIfCustomArtworkExistsForCurrentLevelSet(void) @@ -4332,6 +4345,11 @@ static void checkSeriesInfo(void) { static char *level_directory = NULL; Directory *dir; +#if 0 + DirectoryEntry *dir_entry; +#endif + + checked_free(level_directory); // check for more levels besides the 'levels' field of 'levelinfo.conf' @@ -4347,6 +4365,35 @@ static void checkSeriesInfo(void) return; } +#if 0 + while ((dir_entry = readDirectory(dir)) != NULL) // loop all entries + { + if (strlen(dir_entry->basename) > 4 && + dir_entry->basename[3] == '.' && + strEqual(&dir_entry->basename[4], LEVELFILE_EXTENSION)) + { + char levelnum_str[4]; + int levelnum_value; + + strncpy(levelnum_str, dir_entry->basename, 3); + levelnum_str[3] = '\0'; + + levelnum_value = atoi(levelnum_str); + + if (levelnum_value < leveldir_current->first_level) + { + Error(ERR_WARN, "additional level %d found", levelnum_value); + leveldir_current->first_level = levelnum_value; + } + else if (levelnum_value > leveldir_current->last_level) + { + Error(ERR_WARN, "additional level %d found", levelnum_value); + leveldir_current->last_level = levelnum_value; + } + } + } +#endif + closeDirectory(dir); }