X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsetup.c;h=e1840b1d375e92491492ed31752ecaaf59c07b48;hb=869fe83e41f2fa6459b33d15816c730874326f08;hp=1298d9271e8108147d0b1e3fd97f9cf3b5a27169;hpb=bcffcb9d803359d36cad2130f065de3bbf38d7bc;p=rocksndiamonds.git diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 1298d927..e1840b1d 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -96,6 +96,7 @@ static SetupFileHash *artworkinfo_cache_old = NULL; static SetupFileHash *artworkinfo_cache_new = NULL; static SetupFileHash *optional_tokens_hash = NULL; static boolean use_artworkinfo_cache = TRUE; +static boolean update_artworkinfo_cache = FALSE; // ---------------------------------------------------------------------------- @@ -2934,6 +2935,19 @@ static TreeInfo *createTopTreeInfoNode(TreeInfo *node_first) return ti_new; } +static void setTreeInfoParentNodes(TreeInfo *node, TreeInfo *node_parent) +{ + while (node) + { + if (node->node_group) + setTreeInfoParentNodes(node->node_group, node); + + node->node_parent = node_parent; + + node = node->next; + } +} + // ---------------------------------------------------------------------------- // functions for handling level and custom artwork info cache @@ -2959,10 +2973,15 @@ static void LoadArtworkInfoCache(void) if (artworkinfo_cache_new == NULL) artworkinfo_cache_new = newSetupFileHash(); + + update_artworkinfo_cache = FALSE; } static void SaveArtworkInfoCache(void) { + if (!update_artworkinfo_cache) + return; + char *filename = getPath2(getCacheDir(), ARTWORKINFO_CACHE_FILE); InitCacheDirectory(); @@ -3007,6 +3026,9 @@ static boolean modifiedFileTimestamp(char *filename, char *timestamp_string) if (timestamp_string == NULL) return TRUE; + if (!fileExists(filename)) // file does not exist + return (atoi(timestamp_string) != 0); + if (stat(filename, &file_status) != 0) // cannot stat file return TRUE; @@ -3987,6 +4009,8 @@ static void LoadArtworkInfoFromLevelInfoExt(ArtworkDirTree **artwork_node, artwork_new->sort_priority = level_node->sort_priority; artwork_new->color = LEVELCOLOR(artwork_new); + + update_artworkinfo_cache = TRUE; } free(path); @@ -4048,10 +4072,18 @@ static void LoadArtworkInfoFromLevelInfoExt(ArtworkDirTree **artwork_node, static void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node) { + // move peviously loaded artwork tree into separate sub-tree MoveArtworkInfoIntoSubTree(artwork_node); + // load artwork from level sets into separate sub-trees LoadArtworkInfoFromLevelInfoExt(artwork_node, NULL, leveldir_first_all, TRUE); LoadArtworkInfoFromLevelInfoExt(artwork_node, NULL, leveldir_first_all, FALSE); + + // add top tree node over all three separate sub-trees + *artwork_node = createTopTreeInfoNode(*artwork_node); + + // set all parent links (back links) in complete artwork tree + setTreeInfoParentNodes(*artwork_node, NULL); } void LoadLevelArtworkInfo(void)