From: Holger Schemel Date: Wed, 11 Dec 2013 10:29:05 +0000 (+0100) Subject: rnd-20131211-1-src X-Git-Tag: 4.0.0.0-rc1~429 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=ccbc62287e20cd3776b95980a77be3fee5ad7053;p=rocksndiamonds.git rnd-20131211-1-src --- diff --git a/src/conftime.h b/src/conftime.h index 537f0a44..17c01494 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2013-12-10 01:00" +#define COMPILE_DATE_STRING "2013-12-11 11:28" diff --git a/src/init.c b/src/init.c index c2344a50..c0395762 100644 --- a/src/init.c +++ b/src/init.c @@ -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; diff --git a/src/libgame/image.c b/src/libgame/image.c index 498c1c0b..9d76865e 100644 --- a/src/libgame/image.c +++ b/src/libgame/image.c @@ -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) diff --git a/src/libgame/misc.c b/src/libgame/misc.c index eb7f75d9..37aacf91 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -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 */ diff --git a/src/libgame/misc.h b/src/libgame/misc.h index 431d5913..4f3c3481 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -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 */ diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 26cc7a7b..65057b61 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -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; } diff --git a/src/libgame/setup.c b/src/libgame/setup.c index b9c9899c..f7cd1400 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -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 */ {