rnd-20131028-1-src
[rocksndiamonds.git] / src / libgame / setup.c
index 7bb8ecdb3369ce8ad515885f0a3e29ad1f82b276..246e3891f486e44cdfb1abf58c60be87d7e3e593 100644 (file)
@@ -1184,8 +1184,13 @@ void dumpTreeInfo(TreeInfo *node, int depth)
     for (i = 0; i < (depth + 1) * 3; i++)
       printf(" ");
 
+    printf("'%s' / '%s'\n", node->identifier, node->name);
+
+    /*
+    // use for dumping artwork info tree
     printf("subdir == '%s' ['%s', '%s'] [%d])\n",
           node->subdir, node->fullpath, node->basepath, node->in_user_dir);
+    */
 
     if (node->node_group != NULL)
       dumpTreeInfo(node->node_group, depth + 1);
@@ -1630,6 +1635,7 @@ SetupFileList *addListEntry(SetupFileList *list, char *token, char *value)
     return addListEntry(list->next, token, value);
 }
 
+#if 0
 #ifdef DEBUG
 static void printSetupFileList(SetupFileList *list)
 {
@@ -1642,6 +1648,7 @@ static void printSetupFileList(SetupFileList *list)
   printSetupFileList(list->next);
 }
 #endif
+#endif
 
 #ifdef DEBUG
 DEFINE_HASHTABLE_INSERT(insert_hash_entry, char, char);
@@ -2770,7 +2777,7 @@ static int compareTreeInfoEntries(const void *object1, const void *object2)
 {
   const TreeInfo *entry1 = *((TreeInfo **)object1);
   const TreeInfo *entry2 = *((TreeInfo **)object2);
-  int class_sorting1, class_sorting2;
+  int class_sorting1 = 0, class_sorting2 = 0;
   int compare_result;
 
   if (entry1->type == TREE_TYPE_LEVEL_DIR)
@@ -2778,7 +2785,9 @@ static int compareTreeInfoEntries(const void *object1, const void *object2)
     class_sorting1 = LEVELSORTING(entry1);
     class_sorting2 = LEVELSORTING(entry2);
   }
-  else
+  else if (entry1->type == TREE_TYPE_GRAPHICS_DIR ||
+          entry1->type == TREE_TYPE_SOUNDS_DIR ||
+          entry1->type == TREE_TYPE_MUSIC_DIR)
   {
     class_sorting1 = ARTWORKSORTING(entry1);
     class_sorting2 = ARTWORKSORTING(entry2);
@@ -3061,8 +3070,8 @@ static boolean LoadLevelInfoFromLevelConf(TreeInfo **node_first,
                                          char *directory_name)
 {
 #if 0
-  static unsigned long progress_delay = 0;
-  unsigned long progress_delay_value = 100;    /* (in milliseconds) */
+  static unsigned int progress_delay = 0;
+  unsigned int progress_delay_value = 100;     /* (in milliseconds) */
 #endif
   char *directory_path = getPath2(level_directory, directory_name);
   char *filename = getPath2(directory_path, LEVELINFO_FILENAME);
@@ -3625,8 +3634,8 @@ void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node,
                                  LevelDirTree *level_node)
 {
 #if 0
-  static unsigned long progress_delay = 0;
-  unsigned long progress_delay_value = 100;    /* (in milliseconds) */
+  static unsigned int progress_delay = 0;
+  unsigned int progress_delay_value = 100;     /* (in milliseconds) */
 #endif
   int type = (*artwork_node)->type;
 
@@ -3977,7 +3986,9 @@ static void checkSeriesInfo()
 {
   static char *level_directory = NULL;
   DIR *dir;
+#if 0
   struct dirent *dir_entry;
+#endif
 
   /* check for more levels besides the 'levels' field of 'levelinfo.conf' */
 
@@ -3989,9 +4000,11 @@ static void checkSeriesInfo()
   if ((dir = opendir(level_directory)) == NULL)
   {
     Error(ERR_WARN, "cannot read level directory '%s'", level_directory);
+
     return;
   }
 
+#if 0
   while ((dir_entry = readdir(dir)) != NULL)   /* last directory entry */
   {
     if (strlen(dir_entry->d_name) > 4 &&
@@ -4006,7 +4019,6 @@ static void checkSeriesInfo()
 
       levelnum_value = atoi(levelnum_str);
 
-#if 0
       if (levelnum_value < leveldir_current->first_level)
       {
        Error(ERR_WARN, "additional level %d found", levelnum_value);
@@ -4017,9 +4029,9 @@ static void checkSeriesInfo()
        Error(ERR_WARN, "additional level %d found", levelnum_value);
        leveldir_current->last_level = levelnum_value;
       }
-#endif
     }
   }
+#endif
 
   closedir(dir);
 }
@@ -4092,7 +4104,7 @@ void LoadLevelSetup_SeriesInfo()
     BEGIN_HASH_ITERATION(level_setup_hash, itr)
     {
       char *token = HASH_ITERATION_TOKEN(itr);
-      char *value = HASH_ITERATION_TOKEN(itr);
+      char *value = HASH_ITERATION_VALUE(itr);
 
       if (strlen(token) == 3 &&
          token[0] >= '0' && token[0] <= '9' &&
@@ -4101,8 +4113,13 @@ void LoadLevelSetup_SeriesInfo()
       {
        int level_nr = atoi(token);
 
-       LevelStats_setPlayed(level_nr, atoi(value));
-       LevelStats_setSolved(level_nr, atoi(strchr(value, ' ')));
+       if (value != NULL)
+         LevelStats_setPlayed(level_nr, atoi(value));  /* read 1st column */
+
+       value = strchr(value, ' ');
+
+       if (value != NULL)
+         LevelStats_setSolved(level_nr, atoi(value));  /* read 2nd column */
       }
     }
     END_HASH_ITERATION(hash, itr)