rnd-20131211-1-src
authorHolger Schemel <info@artsoft.org>
Wed, 11 Dec 2013 10:29:05 +0000 (11:29 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 09:00:15 +0000 (11:00 +0200)
src/conftime.h
src/init.c
src/libgame/image.c
src/libgame/misc.c
src/libgame/misc.h
src/libgame/sdl.c
src/libgame/setup.c

index 537f0a44b69ef31dd204e657bb2aa9e494f66bcf..17c014948843490bc668e79b1a54126d8928c723 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2013-12-10 01:00"
+#define COMPILE_DATE_STRING "2013-12-11 11:28"
index c2344a507175af8ce42059a4d563ca8c35cada54..c0395762ae63fd5312ad1fdc3e3223a59f3ab84d 100644 (file)
@@ -38,9 +38,6 @@
 #define CONFIG_TOKEN_FONT_INITIAL              "font.initial"
 #define CONFIG_TOKEN_GLOBAL_BUSY               "global.busy"
 
-#define DEBUG_PRINT_INIT_TIMESTAMPS            TRUE
-#define DEBUG_PRINT_INIT_TIMESTAMPS_DEPTH      0
-
 
 static struct FontBitmapInfo font_initial[NUM_INITIAL_FONTS];
 static struct GraphicInfo    anim_initial;
@@ -89,72 +86,6 @@ static int copy_properties[][5] =
 };
 
 
-static void print_timestamp_ext(char *message, char *mode)
-{
-#if DEBUG
-#if DEBUG_PRINT_INIT_TIMESTAMPS
-  static char *debug_message = NULL;
-  static char *last_message = NULL;
-  static int counter_nr = 0;
-  int max_depth = DEBUG_PRINT_INIT_TIMESTAMPS_DEPTH;
-
-  checked_free(debug_message);
-  debug_message = getStringCat3(mode, " ", message);
-
-  if (strEqual(mode, "INIT"))
-  {
-    debug_print_timestamp(counter_nr, NULL);
-
-    if (counter_nr + 1 < max_depth)
-      debug_print_timestamp(counter_nr, debug_message);
-
-    counter_nr++;
-
-    debug_print_timestamp(counter_nr, NULL);
-  }
-  else if (strEqual(mode, "DONE"))
-  {
-    counter_nr--;
-
-    if (counter_nr + 1 < max_depth ||
-       (counter_nr == 0 && max_depth == 1))
-    {
-      last_message = message;
-
-      if (counter_nr == 0 && max_depth == 1)
-      {
-       checked_free(debug_message);
-       debug_message = getStringCat3("TIME", " ", message);
-      }
-
-      debug_print_timestamp(counter_nr, debug_message);
-    }
-  }
-  else if (!strEqual(mode, "TIME") ||
-          !strEqual(message, last_message))
-  {
-    if (counter_nr < max_depth)
-      debug_print_timestamp(counter_nr, debug_message);
-  }
-#endif
-#endif
-}
-
-static void print_timestamp_init(char *message)
-{
-  print_timestamp_ext(message, "INIT");
-}
-
-static void print_timestamp_time(char *message)
-{
-  print_timestamp_ext(message, "TIME");
-}
-
-static void print_timestamp_done(char *message)
-{
-  print_timestamp_ext(message, "DONE");
-}
-
 void DrawInitAnim()
 {
   struct GraphicInfo *graphic_info_last = graphic_info;
index 498c1c0bfb3a2c034cda879797ac2401e9cb54d8..9d76865e2666653edabab39f07f4810307260666 100644 (file)
@@ -1040,8 +1040,15 @@ void ReloadCustomImages()
   printf("::: reloading images '%s' ...\n", artwork.gfx_current_identifier);
 #endif
 
+  print_timestamp_init("ReloadCustomImages");
+
   LoadArtworkConfig(image_info);
+  print_timestamp_time("LoadArtworkConfig");
+
   ReloadCustomArtworkList(image_info);
+  print_timestamp_time("ReloadCustomArtworkList");
+
+  print_timestamp_done("ReloadCustomImages");
 }
 
 void CreateImageWithSmallImages(int pos, int zoom_factor)
index eb7f75d90029c1a7bfd8198b798673ec91881e31..37aacf9187da13d46839f82cae07b629e357ac7e 100644 (file)
@@ -2115,7 +2115,13 @@ DirectoryEntry *readDirectory(Directory *dir)
 
   dir->dir_entry->is_directory =
     (stat(dir->dir_entry->filename, &file_status) == 0 &&
-     (file_status.st_mode & S_IFMT) != S_IFDIR);
+     (file_status.st_mode & S_IFMT) == S_IFDIR);
+
+#if 0
+  Error(ERR_INFO, "::: '%s' is directory: %d",
+       dir->dir_entry->basename,
+       dir->dir_entry->is_directory);
+#endif
 
   return dir->dir_entry;
 }
@@ -3324,6 +3330,7 @@ static void LoadCustomArtwork(struct ArtworkListInfo *artwork_info,
   if (strEqual(file_list_entry->filename, UNDEFINED_FILENAME))
   {
     deleteArtworkListEntry(artwork_info, listnode);
+
     return;
   }
 
@@ -3339,6 +3346,8 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info)
     artwork_info->num_dynamic_file_list_entries;
   int i;
 
+  print_timestamp_init("ReloadCustomArtworkList");
+
   for (i = 0; i < num_file_list_entries; i++)
     LoadCustomArtwork(artwork_info, &artwork_info->artwork_list[i],
                      &file_list[i]);
@@ -3347,6 +3356,8 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info)
     LoadCustomArtwork(artwork_info, &artwork_info->dynamic_artwork_list[i],
                      &dynamic_file_list[i]);
 
+  print_timestamp_done("ReloadCustomArtworkList");
+
 #if 0
   dumpList(artwork_info->content_list);
 #endif
@@ -3444,8 +3455,11 @@ void NotifyUserAboutErrorFile()
 
 #if DEBUG
 
-#define DEBUG_NUM_TIMESTAMPS           5
-#define DEBUG_TIME_IN_MICROSECONDS     0
+#define DEBUG_PRINT_INIT_TIMESTAMPS            TRUE
+#define DEBUG_PRINT_INIT_TIMESTAMPS_DEPTH      10
+
+#define DEBUG_NUM_TIMESTAMPS                   10
+#define DEBUG_TIME_IN_MICROSECONDS             0
 
 #if DEBUG_TIME_IN_MICROSECONDS
 static double Counter_Microseconds()
@@ -3509,7 +3523,11 @@ void debug_print_timestamp(int counter_nr, char *message)
   counter[counter_nr][1] = counter[counter_nr][0];
 
   if (message)
+#if 1
+    Error(ERR_INFO, "%s%s%s %.3f %s",
+#else
     printf("%s%s%s %.3f %s\n",
+#endif
           debug_print_timestamp_get_padding(counter_nr * indent_size),
           message,
           debug_print_timestamp_get_padding(padding_size - strlen(message)),
@@ -3533,4 +3551,69 @@ void debug_print_parent_only(char *format, ...)
     printf("\n");
   }
 }
+
+void print_timestamp_ext(char *message, char *mode)
+{
+#if DEBUG_PRINT_INIT_TIMESTAMPS
+  static char *debug_message = NULL;
+  static char *last_message = NULL;
+  static int counter_nr = 0;
+  int max_depth = DEBUG_PRINT_INIT_TIMESTAMPS_DEPTH;
+
+  checked_free(debug_message);
+  debug_message = getStringCat3(mode, " ", message);
+
+  if (strEqual(mode, "INIT"))
+  {
+    debug_print_timestamp(counter_nr, NULL);
+
+    if (counter_nr + 1 < max_depth)
+      debug_print_timestamp(counter_nr, debug_message);
+
+    counter_nr++;
+
+    debug_print_timestamp(counter_nr, NULL);
+  }
+  else if (strEqual(mode, "DONE"))
+  {
+    counter_nr--;
+
+    if (counter_nr + 1 < max_depth ||
+       (counter_nr == 0 && max_depth == 1))
+    {
+      last_message = message;
+
+      if (counter_nr == 0 && max_depth == 1)
+      {
+       checked_free(debug_message);
+       debug_message = getStringCat3("TIME", " ", message);
+      }
+
+      debug_print_timestamp(counter_nr, debug_message);
+    }
+  }
+  else if (!strEqual(mode, "TIME") ||
+          !strEqual(message, last_message))
+  {
+    if (counter_nr < max_depth)
+      debug_print_timestamp(counter_nr, debug_message);
+  }
 #endif
+}
+
+void print_timestamp_init(char *message)
+{
+  print_timestamp_ext(message, "INIT");
+}
+
+void print_timestamp_time(char *message)
+{
+  print_timestamp_ext(message, "TIME");
+}
+
+void print_timestamp_done(char *message)
+{
+  print_timestamp_ext(message, "DONE");
+}
+
+#endif /* DEBUG */
index 431d59139850d925f7343340dc26dcdfeb06ff57..4f3c3481c099c7f71d3b8c97ae037a48028968c9 100644 (file)
@@ -260,6 +260,13 @@ void closeErrorFile();
 void dumpErrorFile();
 void NotifyUserAboutErrorFile();
 
+#if DEBUG
 void debug_print_timestamp(int, char *);
+void print_timestamp_init(char *);
+void print_timestamp_time(char *);
+void print_timestamp_done(char *);
+#endif /* DEBUG */
+
+
 
 #endif /* MISC_H */
index 26cc7a7b103076df0c2d228ad8041f54744c506d..65057b61ba0cd221c273ab4283ed6110ef6eb696 100644 (file)
@@ -1788,6 +1788,10 @@ Bitmap *SDLLoadImage(char *filename)
   Bitmap *new_bitmap = CreateBitmapStruct();
   SDL_Surface *sdl_image_tmp;
 
+  print_timestamp_init("SDLLoadImage");
+
+  print_timestamp_time(getBaseNamePtr(filename));
+
   /* load image to temporary surface */
   if ((sdl_image_tmp = IMG_Load(filename)) == NULL)
   {
@@ -1796,6 +1800,8 @@ Bitmap *SDLLoadImage(char *filename)
     return NULL;
   }
 
+  print_timestamp_time("IMG_Load");
+
   UPDATE_BUSY_STATE();
 
   /* create native non-transparent surface for current image */
@@ -1806,6 +1812,8 @@ Bitmap *SDLLoadImage(char *filename)
     return NULL;
   }
 
+  print_timestamp_time("SDL_DisplayFormat (opaque)");
+
   UPDATE_BUSY_STATE();
 
   /* create native transparent surface for current image */
@@ -1818,6 +1826,8 @@ Bitmap *SDLLoadImage(char *filename)
     return NULL;
   }
 
+  print_timestamp_time("SDL_DisplayFormat (masked)");
+
   UPDATE_BUSY_STATE();
 
   /* free temporary surface */
@@ -1826,6 +1836,8 @@ Bitmap *SDLLoadImage(char *filename)
   new_bitmap->width = new_bitmap->surface->w;
   new_bitmap->height = new_bitmap->surface->h;
 
+  print_timestamp_done("SDLLoadImage");
+
   return new_bitmap;
 }
 
index b9c9899c4a56d468a0d514b942dfc53398c37e32..f7cd1400171ee608cab6bccbc708ddbcc3dff132 100644 (file)
@@ -3447,7 +3447,6 @@ static void LoadLevelInfoFromLevelDir(TreeInfo **node_first,
 
   while ((dir_entry = readDirectory(dir)) != NULL)     /* loop all entries */
   {
-    struct stat file_status;
     char *directory_name = dir_entry->basename;
     char *directory_path = getPath2(level_directory, directory_name);
 
@@ -3470,10 +3469,15 @@ static void LoadLevelInfoFromLevelDir(TreeInfo **node_first,
     {
       free(directory_path);
 
+#if 0
+      Error(ERR_INFO, "* entry '%s' is not a directory ...", directory_name);
+#endif
+
       continue;
     }
 #else
     /* find out if directory entry is itself a directory */
+    struct stat file_status;
     if (stat(directory_path, &file_status) != 0 ||     /* cannot stat file */
        (file_status.st_mode & S_IFMT) != S_IFDIR)      /* not a directory */
     {