From: Holger Schemel Date: Mon, 20 Jan 2003 17:45:04 +0000 (+0100) Subject: rnd-20030120-2-src X-Git-Tag: 3.0.0^2~167 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=be2766c926ff78b2985565fd9c12390eb5655112;p=rocksndiamonds.git rnd-20030120-2-src --- diff --git a/src/conftime.h b/src/conftime.h index 1098a8e6..9ece7115 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-01-20 15:37]" +#define COMPILE_DATE_STRING "[2003-01-20 18:43]" diff --git a/src/init.c b/src/init.c index 41743eac..ea3e538b 100644 --- a/src/init.c +++ b/src/init.c @@ -185,6 +185,7 @@ static void InitArtworkInfo() static void InitArtworkConfig() { static char *element_prefix[MAX_NUM_ELEMENTS + 1]; + static char *sound_class_prefix[MAX_NUM_ELEMENTS + 1]; static char *action_suffix[NUM_ACTIONS + 1]; static char *direction_suffix[NUM_DIRECTIONS + 1]; static char *dummy[1] = { NULL }; @@ -192,6 +193,8 @@ static void InitArtworkConfig() for (i=0; inum_file_list_entries = num_file_list_entries; + image_info->num_dynamic_file_list_entries = 0; image_info->num_suffix_list_entries = 0; for (i=0; config_suffix_list[i].token != NULL; i++) @@ -742,6 +743,8 @@ void InitImageList(struct ConfigInfo *config_list, int num_file_list_entries, image_info->file_list = getFileListFromConfigList(config_list, config_suffix_list, num_file_list_entries); + image_info->dynamic_file_list = NULL; + image_info->suffix_list = config_suffix_list; /* ---------- initialize base prefix and suffixes lists ---------- */ @@ -761,7 +764,6 @@ void InitImageList(struct ConfigInfo *config_list, int num_file_list_entries, image_info->base_prefixes = base_prefixes; image_info->ext1_suffixes = ext1_suffixes; image_info->ext2_suffixes = ext2_suffixes; - image_info->custom_setup_list = NULL; /* ---------- initialize artwork reference and content lists ---------- */ diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 53562589..87152ceb 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1607,28 +1607,32 @@ struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, return file_list; } -#define SUFFIX_NO_MATCH 0 -#define SUFFIX_MATCH (1 << 0) -#define SUFFIX_MATCH_COMPLETE (1 << 1) - -static int token_suffix_match(char *token, char *suffix, int start_pos) +static boolean token_suffix_match(char *token, char *suffix, int start_pos) { int len_token = strlen(token); int len_suffix = strlen(suffix); - if (start_pos + len_suffix > len_token) - return SUFFIX_NO_MATCH; +#if 0 + if (IS_PARENT_PROCESS(audio.mixer_pid)) + printf(":::::::::: check '%s' for '%s' ::::::::::\n", token, suffix); +#endif + + if (start_pos < 0) /* compare suffix from end of string */ + start_pos += len_token; + + if (start_pos < 0 || start_pos + len_suffix > len_token) + return FALSE; if (strncmp(&token[start_pos], suffix, len_suffix) != 0) - return SUFFIX_NO_MATCH; + return FALSE; if (token[start_pos + len_suffix] == '\0') - return SUFFIX_MATCH_COMPLETE; + return TRUE; if (token[start_pos + len_suffix] == '.') - return SUFFIX_MATCH; + return TRUE; - return SUFFIX_NO_MATCH; + return FALSE; } #define KNOWN_TOKEN_VALUE "[KNOWN_TOKEN]" @@ -1677,6 +1681,31 @@ static void read_token_parameters(struct SetupFileList *setup_file_list, } } +static void add_dynamic_file_list_entry(struct FileInfo **list, + int *num_list_entries, + struct SetupFileList *extra_file_list, + struct ConfigInfo *suffix_list, + int num_suffix_list_entries, + char *token) +{ + struct FileInfo *new_list_entry; + int parameter_array_size = num_suffix_list_entries * sizeof(int); + +#if 0 + if (IS_PARENT_PROCESS(audio.mixer_pid)) + printf("===> found dynamic definition '%s'\n", token); +#endif + + (*num_list_entries)++; + *list = checked_realloc(*list, *num_list_entries * sizeof(struct FileInfo)); + new_list_entry = &(*list)[*num_list_entries - 1]; + + new_list_entry->token = getStringCopy(token); + new_list_entry->parameter = checked_calloc(parameter_array_size); + + read_token_parameters(extra_file_list, suffix_list, new_list_entry); +} + void LoadArtworkConfig(struct ArtworkListInfo *artwork_info) { struct FileInfo *file_list = artwork_info->file_list; @@ -1711,6 +1740,22 @@ void LoadArtworkConfig(struct ArtworkListInfo *artwork_info) file_list[i].parameter[j] = file_list[i].default_parameter[j]; } + /* free previous dynamic artwork file array */ + if (artwork_info->dynamic_file_list != NULL) + { + for (i=0; inum_dynamic_file_list_entries; i++) + { + free(artwork_info->dynamic_file_list[i].token); + free(artwork_info->dynamic_file_list[i].filename); + free(artwork_info->dynamic_file_list[i].parameter); + } + + free(artwork_info->dynamic_file_list); + + artwork_info->dynamic_file_list = NULL; + artwork_info->num_dynamic_file_list_entries = 0; + } + if (filename == NULL) return; @@ -1725,7 +1770,7 @@ void LoadArtworkConfig(struct ArtworkListInfo *artwork_info) setTokenValue(setup_file_list, "name", known_token_value); setTokenValue(setup_file_list, "sort_priority", known_token_value); - /* copy all unknown config file tokens to special config list */ + /* copy all unknown config file tokens to extra config list */ for (list = setup_file_list; list != NULL; list = list->next) { if (strcmp(list->value, known_token_value) != 0) @@ -1740,72 +1785,171 @@ void LoadArtworkConfig(struct ArtworkListInfo *artwork_info) /* at this point, we do not need the config file list anymore -- free it */ freeSetupFileList(setup_file_list); - if (extra_file_list != NULL) + /* now try to determine valid, dynamically defined config tokens */ + + for (list = extra_file_list; list != NULL; list = list->next) { - if (options.verbose && IS_PARENT_PROCESS(audio.mixer_pid)) + struct FileInfo **dynamic_file_list = &artwork_info->dynamic_file_list; + int *num_dynamic_file_list_entries = + &artwork_info->num_dynamic_file_list_entries; + char *token = list->token; + int len_token = strlen(token); + int start_pos; + boolean base_prefix_found = FALSE; + boolean parameter_suffix_found = FALSE; + + /* skip all parameter definitions (handled by read_token_parameters()) */ + for (i=0; i < num_suffix_list_entries && !parameter_suffix_found; i++) { - Error(ERR_RETURN_LINE, "-"); - Error(ERR_RETURN, "warning: unknown token(s) found in config file:"); - Error(ERR_RETURN, "- config file: '%s'", filename); + int len_suffix = strlen(suffix_list[i].token); - for (list = extra_file_list; list != NULL; list = list->next) - Error(ERR_RETURN, "- unknown token: '%s'", list->token); + if (token_suffix_match(token, suffix_list[i].token, -len_suffix)) + parameter_suffix_found = TRUE; + } - Error(ERR_RETURN_LINE, "-"); +#if 0 + if (IS_PARENT_PROCESS(audio.mixer_pid)) + { + if (parameter_suffix_found) + printf("---> skipping token '%s' (parameter token)\n", token); + else + printf("---> examining token '%s': search prefix ...\n", token); } +#endif - /* now try to determine valid, dynamically defined config tokens */ + if (parameter_suffix_found) + continue; - for (list = extra_file_list; list != NULL; list = list->next) + /* ---------- step 1: search for matching base prefix ---------- */ + + start_pos = 0; + for (i=0; itoken; + char *base_prefix = base_prefixes[i]; + int len_base_prefix = strlen(base_prefix); + boolean ext1_suffix_found = FALSE; + + base_prefix_found = token_suffix_match(token, base_prefix, start_pos); + + if (!base_prefix_found) + continue; + + if (start_pos + len_base_prefix == len_token) /* exact match */ + { + add_dynamic_file_list_entry(dynamic_file_list, + num_dynamic_file_list_entries, + extra_file_list, + suffix_list, + num_suffix_list_entries, + token); + continue; + } + +#if 0 + if (IS_PARENT_PROCESS(audio.mixer_pid)) + printf("---> examining token '%s': search 1st suffix ...\n", token); +#endif + + /* ---------- step 2: search for matching first suffix ---------- */ - for (i=0; i examining token '%s': search 2nd suffix ...\n", token); +#endif + + /* ---------- step 3: search for matching second suffix ---------- */ + + start_pos += len_ext1_suffix; + for (k=0; knext) + { + if (strcmp(list->value, known_token_value) == 0) + dynamic_tokens_found = TRUE; + else + unknown_tokens_found = TRUE; + } + +#if DEBUG + if (dynamic_tokens_found) + { + Error(ERR_RETURN_LINE, "-"); + Error(ERR_RETURN, "dynamic token(s) found:"); + + for (list = extra_file_list; list != NULL; list = list->next) + if (strcmp(list->value, known_token_value) == 0) + Error(ERR_RETURN, "- dynamic token: '%s'", list->token); + + Error(ERR_RETURN_LINE, "-"); + } +#endif + + if (unknown_tokens_found) + { + Error(ERR_RETURN_LINE, "-"); + Error(ERR_RETURN, "warning: unknown token(s) found in config file:"); + Error(ERR_RETURN, "- config file: '%s'", filename); + + for (list = extra_file_list; list != NULL; list = list->next) + if (strcmp(list->value, known_token_value) != 0) + Error(ERR_RETURN, "- unknown token: '%s'", list->token); + + Error(ERR_RETURN_LINE, "-"); + } + } + freeSetupFileList(extra_file_list); #if 0 diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 004c4458..61d5d29e 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -1784,6 +1784,7 @@ void InitSoundList(struct ConfigInfo *config_list, int num_file_list_entries, /* ---------- initialize file list and suffix lists ---------- */ sound_info->num_file_list_entries = num_file_list_entries; + sound_info->num_dynamic_file_list_entries = 0; sound_info->num_suffix_list_entries = 0; for (i=0; config_suffix_list[i].token != NULL; i++) @@ -1792,6 +1793,8 @@ void InitSoundList(struct ConfigInfo *config_list, int num_file_list_entries, sound_info->file_list = getFileListFromConfigList(config_list, config_suffix_list, num_file_list_entries); + sound_info->dynamic_file_list = NULL; + sound_info->suffix_list = config_suffix_list; /* ---------- initialize base prefix and suffixes lists ---------- */ @@ -1811,7 +1814,6 @@ void InitSoundList(struct ConfigInfo *config_list, int num_file_list_entries, sound_info->base_prefixes = base_prefixes; sound_info->ext1_suffixes = ext1_suffixes; sound_info->ext2_suffixes = ext2_suffixes; - sound_info->custom_setup_list = NULL; /* ---------- initialize artwork reference and content lists ---------- */ @@ -1910,7 +1912,7 @@ void LoadCustomMusic(void) { num_music++; Music = checked_realloc(Music, num_music * sizeof(MusicInfo *)); - Music[num_music -1] = mus_info; + Music[num_music - 1] = mus_info; } } diff --git a/src/libgame/system.h b/src/libgame/system.h index 6ff9c39f..6ba3ff82 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -516,9 +516,13 @@ struct ArtworkListInfo int type; /* type of artwork */ int num_file_list_entries; + int num_dynamic_file_list_entries; + int num_suffix_list_entries; struct FileInfo *file_list; /* static artwork file array */ + struct FileInfo *dynamic_file_list; /* dynamic artwrk file array */ + struct ConfigInfo *suffix_list; /* parameter suffixes array */ int num_base_prefixes; @@ -528,7 +532,6 @@ struct ArtworkListInfo char **base_prefixes; /* base token prefixes array */ char **ext1_suffixes; /* property suffixes array 1 */ char **ext2_suffixes; /* property suffixes array 2 */ - struct SetupFileList *custom_setup_list; /* additional definitions */ struct ListNodeInfo **artwork_list; /* static artwork node array */ struct ListNode *content_list; /* dynamic artwork node list */ diff --git a/src/main.c b/src/main.c index b0a19802..4e4f38ac 100644 --- a/src/main.c +++ b/src/main.c @@ -417,7 +417,7 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS] = }, { "unused_63", - NULL, + "unused", "(not used)" }, { @@ -636,7 +636,7 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS] = }, { "black_orb", - NULL, + "black_orb", "black orb bomb" }, { @@ -661,22 +661,22 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS] = }, { "arrow_blue_left", - NULL, + "arrow", "arrow left" }, { "arrow_blue_right", - NULL, + "arrow", "arrow right" }, { "arrow_blue_up", - NULL, + "arrow", "arrow up" }, { "arrow_blue_down", - NULL, + "arrow", "arrow down" }, { @@ -696,402 +696,402 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS] = }, { "char_space", - NULL, + "char", "letter ' '" }, { "char_exclam", - NULL, + "char", "letter '!'" }, { "char_quotedbl", - NULL, + "char", "letter '\"'" }, { "char_numbersign", - NULL, + "char", "letter '#'" }, { "char_dollar", - NULL, + "char", "letter '$'" }, { "char_procent", - NULL, + "char", "letter '%'" }, { "char_ampersand", - NULL, + "char", "letter '&'" }, { "char_apostrophe", - NULL, + "char", "letter '''" }, { "char_parenleft", - NULL, + "char", "letter '('" }, { "char_parenright", - NULL, + "char", "letter ')'" }, { "char_asterisk", - NULL, + "char", "letter '*'" }, { "char_plus", - NULL, + "char", "letter '+'" }, { "char_comma", - NULL, + "char", "letter ','" }, { "char_minus", - NULL, + "char", "letter '-'" }, { "char_period", - NULL, + "char", "letter '.'" }, { "char_slash", - NULL, + "char", "letter '/'" }, { "char_0", - NULL, + "char", "letter '0'" }, { "char_1", - NULL, + "char", "letter '1'" }, { "char_2", - NULL, + "char", "letter '2'" }, { "char_3", - NULL, + "char", "letter '3'" }, { "char_4", - NULL, + "char", "letter '4'" }, { "char_5", - NULL, + "char", "letter '5'" }, { "char_6", - NULL, + "char", "letter '6'" }, { "char_7", - NULL, + "char", "letter '7'" }, { "char_8", - NULL, + "char", "letter '8'" }, { "char_9", - NULL, + "char", "letter '9'" }, { "char_colon", - NULL, + "char", "letter ':'" }, { "char_semicolon", - NULL, + "char", "letter ';'" }, { "char_less", - NULL, + "char", "letter '<'" }, { "char_equal", - NULL, + "char", "letter '='" }, { "char_greater", - NULL, + "char", "letter '>'" }, { "char_question", - NULL, + "char", "letter '?'" }, { "char_at", - NULL, + "char", "letter '@'" }, { "char_a", - NULL, + "char", "letter 'A'" }, { "char_b", - NULL, + "char", "letter 'B'" }, { "char_c", - NULL, + "char", "letter 'C'" }, { "char_d", - NULL, + "char", "letter 'D'" }, { "char_e", - NULL, + "char", "letter 'E'" }, { "char_f", - NULL, + "char", "letter 'F'" }, { "char_g", - NULL, + "char", "letter 'G'" }, { "char_h", - NULL, + "char", "letter 'H'" }, { "char_i", - NULL, + "char", "letter 'I'" }, { "char_j", - NULL, + "char", "letter 'J'" }, { "char_k", - NULL, + "char", "letter 'K'" }, { "char_l", - NULL, + "char", "letter 'L'" }, { "char_m", - NULL, + "char", "letter 'M'" }, { "char_n", - NULL, + "char", "letter 'N'" }, { "char_o", - NULL, + "char", "letter 'O'" }, { "char_p", - NULL, + "char", "letter 'P'" }, { "char_q", - NULL, + "char", "letter 'Q'" }, { "char_r", - NULL, + "char", "letter 'R'" }, { "char_s", - NULL, + "char", "letter 'S'" }, { "char_t", - NULL, + "char", "letter 'T'" }, { "char_u", - NULL, + "char", "letter 'U'" }, { "char_v", - NULL, + "char", "letter 'V'" }, { "char_w", - NULL, + "char", "letter 'W'" }, { "char_x", - NULL, + "char", "letter 'X'" }, { "char_y", - NULL, + "char", "letter 'Y'" }, { "char_z", - NULL, + "char", "letter 'Z'" }, { "char_ae", - NULL, + "char", "letter 'Ä'" }, { "char_oe", - NULL, + "char", "letter 'Ö'" }, { "char_ue", - NULL, + "char", "letter 'Ü'" }, { "char_copyright", - NULL, + "char", "letter '^'" }, { "char_underscore", - NULL, + "char", "letter ''" }, { "char_empty", - NULL, + "char", "letter ''" }, { "char_degree", - NULL, + "char", "letter ''" }, { "char_tm", - NULL, + "char", "letter ''" }, { "char_cursor", - NULL, + "char", "letter ''" }, { - NULL, - NULL, + "char_unused", + "char", "letter ''" }, { - NULL, - NULL, + "char_unused", + "char", "letter ''" }, { - NULL, - NULL, + "char_unused", + "char", "letter ''" }, { - NULL, - NULL, + "char_unused", + "char", "letter ''" }, { - NULL, - NULL, + "char_unused", + "char", "letter ''" }, { - NULL, - NULL, + "char_unused", + "char", "letter ''" }, { - NULL, - NULL, + "char_unused", + "char", "letter ''" }, { - NULL, - NULL, + "char_unused", + "char", "letter ''" }, { - NULL, - NULL, + "char_unused", + "char", "letter ''" }, { - NULL, - NULL, + "char_unused", + "char", "letter ''" }, { - NULL, - NULL, + "char_unused", + "char", "letter ''" }, { - NULL, - NULL, + "char_unused", + "char", "letter ''" }, { @@ -1366,12 +1366,12 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS] = }, { "unused_254", - NULL, + "unused", "(not used)" }, { "unused_255", - NULL, + "unused", "(not used)" }, { @@ -1441,12 +1441,12 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS] = }, { "unused_269", - NULL, + "unused", "-" }, { "unused_270", - NULL, + "unused", "-" }, { @@ -1681,22 +1681,22 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS] = }, { "dx_unknown_15", - NULL, + "unknown", "dx unknown element 15" }, { "dx_unknown_42", - NULL, + "unknown", "dx unknown element 42" }, { "unused_319", - NULL, + "unused", "(not used)" }, { "unused_320", - NULL, + "unused", "(not used)" }, { @@ -1886,12 +1886,12 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS] = }, { "unused_358", - NULL, + "unused", "-" }, { "unused_359", - NULL, + "unused", "-" }, { @@ -2764,7 +2764,7 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS] = }, { - "", + NULL, NULL, "-" }