X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=81ec00e7a1cc2245f1dd573d100a3c6e38296f48;hp=eb7f75d90029c1a7bfd8198b798673ec91881e31;hb=a8816d6e5319f9ec26a45346b08250f61e95c011;hpb=142d88521dfcde187ea315279d79203c00e1b0f3 diff --git a/src/libgame/misc.c b/src/libgame/misc.c index eb7f75d9..81ec00e7 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1047,8 +1047,11 @@ void Error(int mode, char *format, ...) char *process_name = ""; #if defined(PLATFORM_ANDROID) - android_log_prio = (mode & ERR_WARN ? ANDROID_LOG_WARN : - mode & ERR_EXIT ? ANDROID_LOG_FATAL : ANDROID_LOG_INFO); + android_log_prio = (mode & ERR_DEBUG ? ANDROID_LOG_DEBUG : + mode & ERR_INFO ? ANDROID_LOG_INFO : + mode & ERR_WARN ? ANDROID_LOG_WARN : + mode & ERR_EXIT ? ANDROID_LOG_FATAL : + ANDROID_LOG_UNKNOWN); #endif #if 1 @@ -2115,7 +2118,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; } @@ -2200,20 +2209,31 @@ boolean fileHasSuffix(char *basename, char *suffix) boolean FileIsGraphic(char *filename) { +#if 1 + return TRUE; +#else char *basename = getBaseNamePtr(filename); return fileHasSuffix(basename, "pcx"); +#endif } boolean FileIsSound(char *filename) { +#if 1 + return TRUE; +#else char *basename = getBaseNamePtr(filename); return fileHasSuffix(basename, "wav"); +#endif } boolean FileIsMusic(char *filename) { +#if 1 + return TRUE; +#else char *basename = getBaseNamePtr(filename); if (FileIsSound(basename)) @@ -2233,6 +2253,7 @@ boolean FileIsMusic(char *filename) #endif return FALSE; +#endif } boolean FileIsArtworkType(char *basename, int type) @@ -2490,10 +2511,13 @@ struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, } list_pos = 0; + for (i = 0; config_list[i].token != NULL; i++) { int len_config_token = strlen(config_list[i].token); +#if 0 int len_config_value = strlen(config_list[i].value); +#endif boolean is_file_entry = TRUE; for (j = 0; suffix_list[j].token != NULL; j++) @@ -2508,6 +2532,7 @@ struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, config_list[i].value); is_file_entry = FALSE; + break; } } @@ -2525,6 +2550,7 @@ struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, if (list_pos >= num_file_list_entries) break; +#if 0 /* simple sanity check if this is really a file definition */ if (!strEqual(&config_list[i].value[len_config_value - 4], ".pcx") && !strEqual(&config_list[i].value[len_config_value - 4], ".wav") && @@ -2534,6 +2560,7 @@ struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, config_list[i].token, config_list[i].value); Error(ERR_EXIT, "This seems to be no valid definition -- please fix"); } +#endif file_list[list_pos].token = config_list[i].token; file_list[list_pos].default_filename = config_list[i].value; @@ -3324,6 +3351,7 @@ static void LoadCustomArtwork(struct ArtworkListInfo *artwork_info, if (strEqual(file_list_entry->filename, UNDEFINED_FILENAME)) { deleteArtworkListEntry(artwork_info, listnode); + return; } @@ -3339,6 +3367,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 +3377,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 +3476,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 +3544,11 @@ void debug_print_timestamp(int counter_nr, char *message) counter[counter_nr][1] = counter[counter_nr][0]; if (message) +#if 1 + Error(ERR_DEBUG, "%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 +3572,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 */