added storing and checking program version in artwork info cache
authorHolger Schemel <info@artsoft.org>
Thu, 11 Feb 2021 00:39:33 +0000 (01:39 +0100)
committerHolger Schemel <info@artsoft.org>
Thu, 11 Feb 2021 00:51:28 +0000 (01:51 +0100)
src/libgame/setup.c

index 458ad40b880d2fd9f607fa8c092300457e3e0b83..a135b0d58cf694259d16568d5f4d45dd1aee30f3 100644 (file)
@@ -2330,6 +2330,8 @@ static void saveSetupFileHash(SetupFileHash *hash, char *filename)
     return;
   }
 
+  fprintf(file, "%s\n\n", getFormattedSetupEntry("program.version",
+                                                program.version_string));
   for (i = 0; i < item_count; i++)
     fprintf(file, "%s\n", getFormattedSetupEntry(sort_array[i].token,
                                                 sort_array[i].value));
@@ -2927,6 +2929,17 @@ static void LoadArtworkInfoCache(void)
     // try to load artwork info hash from already existing cache file
     artworkinfo_cache_old = loadSetupFileHash(filename);
 
+    // try to get program version that artwork info cache was written with
+    char *version = getHashEntry(artworkinfo_cache_old, "program.version");
+
+    // check program version of artwork info cache against current version
+    if (!strEqual(version, program.version_string))
+    {
+      freeSetupFileHash(artworkinfo_cache_old);
+
+      artworkinfo_cache_old = NULL;
+    }
+
     // if no artwork info cache file was found, start with empty hash
     if (artworkinfo_cache_old == NULL)
       artworkinfo_cache_old = newSetupFileHash();