From 4bb90da7a98b741b4576099be6b89d324c8a80de Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 3 Dec 2003 00:38:44 +0100 Subject: [PATCH] rnd-20031203-1-src * added menu entry for level set information to the info screen --- ChangeLog | 8 ++ src/conftime.h | 2 +- src/files.c | 212 ++------------------------------------------ src/libgame/misc.c | 21 +++++ src/libgame/misc.h | 1 + src/libgame/setup.c | 28 +++--- src/screens.c | 4 +- 7 files changed, 53 insertions(+), 223 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1376eac..7d4d5730 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,12 @@ +2003-12-02 + * added menu entry for level set information to the info screen + 2003-12-02 * fixed bug with wrong default impact sound for colored emeralds 2003-11-30 * added several sub-screens for the info screen + * menu text now also clickable (not only blue/red sphere left of it) 2003-11-25 * added configurable "bored" and "sleeping" animations for the player @@ -16,6 +20,9 @@ 2003-11-20 * added configurable music credits for info screen +2003-11-19 + * finally fixed tape recording when player is created from CE + 2003-11-18 * added "editorsetup.conf" for editor element list configuration @@ -39,6 +46,7 @@ 2003-11-09 * fixed reset of player animation frame when, for example, walking, digging or collecting share the same animation + * fixed CE with "deadly when touching" exploding when touching amoeba 2003-11-08 * fixed tape recording when player is created from CE element change diff --git a/src/conftime.h b/src/conftime.h index 0380064c..71221517 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-12-02 02:40]" +#define COMPILE_DATE_STRING "[2003-12-03 00:38]" diff --git a/src/files.c b/src/files.c index 08653161..8233ac51 100644 --- a/src/files.c +++ b/src/files.c @@ -2762,23 +2762,6 @@ void LoadSpecialMenuDesignSettings() freeSetupFileHash(setup_file_hash); } -static char *itoa(unsigned int i) -{ - static char *a = NULL; - - if (a != NULL) - free(a); - - if (i > 2147483647) /* yes, this is a kludge */ - i = 2147483647; - - a = checked_malloc(10 + 1); - - sprintf(a, "%d", i); - - return a; -} - void LoadUserDefinedEditorElementList(int **elements, int *num_elements) { char *filename = getEditorSetupFilename(); @@ -2793,7 +2776,7 @@ void LoadUserDefinedEditorElementList(int **elements, int *num_elements) element_hash = newSetupFileHash(); for (i = 0; i < NUM_FILE_ELEMENTS; i++) - setHashEntry(element_hash, element_info[i].token_name, itoa(i)); + setHashEntry(element_hash, element_info[i].token_name, i_to_a(i)); /* determined size may be larger than needed (due to unknown elements) */ *num_elements = 0; @@ -3066,8 +3049,6 @@ void print_unknown_token_end(int token_nr) Error(ERR_RETURN_LINE, "-"); } -#if 1 - void LoadHelpAnimInfo() { char *filename = getHelpAnimFilename(); @@ -3100,16 +3081,16 @@ void LoadHelpAnimInfo() direction_hash = newSetupFileHash(); for (i = 0; i < MAX_NUM_ELEMENTS; i++) - setHashEntry(element_hash, element_info[i].token_name, itoa(i)); + setHashEntry(element_hash, element_info[i].token_name, i_to_a(i)); for (i = 0; i < NUM_ACTIONS; i++) setHashEntry(action_hash, element_action_info[i].suffix, - itoa(element_action_info[i].value)); + i_to_a(element_action_info[i].value)); /* do not store direction index (bit) here, but direction value! */ for (i = 0; i < NUM_DIRECTIONS; i++) setHashEntry(direction_hash, element_direction_info[i].suffix, - itoa(1 << element_direction_info[i].value)); + i_to_a(1 << element_direction_info[i].value)); for (list = setup_file_list; list != NULL; list = list->next) { @@ -3259,7 +3240,8 @@ void LoadHelpAnimInfo() print_unknown_token_end(num_unknown_tokens); - add_helpanim_entry(HELPANIM_LIST_END, -1, -1, -1, &num_list_entries); + add_helpanim_entry(HELPANIM_LIST_NEXT, -1, -1, -1, &num_list_entries); + add_helpanim_entry(HELPANIM_LIST_END, -1, -1, -1, &num_list_entries); freeSetupFileList(setup_file_list); freeSetupFileHash(element_hash); @@ -3277,188 +3259,6 @@ void LoadHelpAnimInfo() #endif } -#else - -void LoadHelpAnimInfo() -{ - char *filename = getHelpAnimFilename(); - SetupFileList *setup_file_list = NULL, *list; - SetupFileHash *element_hash, *action_hash, *direction_hash; - int num_list_entries = 0; - int num_unknown_tokens = 0; - int i; - - if (fileExists(filename)) - setup_file_list = loadSetupFileList(filename); - - if (setup_file_list == NULL) - { - /* use reliable default values from static configuration */ - SetupFileList *insert_ptr; - - insert_ptr = setup_file_list = - newSetupFileList(helpanim_config[0].token, - helpanim_config[0].value); - - for (i = 1; helpanim_config[i].token; i++) - insert_ptr = addListEntry(insert_ptr, - helpanim_config[i].token, - helpanim_config[i].value); - } - - element_hash = newSetupFileHash(); - action_hash = newSetupFileHash(); - direction_hash = newSetupFileHash(); - - for (i = 0; i < MAX_NUM_ELEMENTS; i++) - setHashEntry(element_hash, element_info[i].token_name, itoa(i)); - - for (i = 0; i < NUM_ACTIONS; i++) - setHashEntry(action_hash, element_action_info[i].suffix, - itoa(element_action_info[i].value)); - - /* do not store direction index (bit) here, but direction value! */ - for (i = 0; i < NUM_DIRECTIONS; i++) - setHashEntry(direction_hash, element_direction_info[i].suffix, - itoa(1 << element_direction_info[i].value)); - - for (list = setup_file_list; list != NULL; list = list->next) - { - char *element_token, *action_token, *direction_token; - char *element_value, *action_value, *direction_value; - int delay = atoi(list->value); - - if (strcmp(list->token, "end") == 0) - { - add_helpanim_entry(HELPANIM_LIST_NEXT, -1, -1, -1, &num_list_entries); - - continue; - } - - element_token = list->token; - element_value = getHashEntry(element_hash, element_token); - - if (element_value != NULL) - { - /* element found */ - add_helpanim_entry(atoi(element_value), -1, -1, delay,&num_list_entries); - - continue; - } - - if (strchr(element_token, '.') == NULL) - { - /* no further suffixes found -- this is not an element */ - print_unknown_token(filename, list->token, num_unknown_tokens++); - - continue; - } - - action_token = strchr(element_token, '.'); - element_token = getStringCopy(element_token); - *strchr(element_token, '.') = '\0'; - - element_value = getHashEntry(element_hash, element_token); - - if (element_value == NULL) - { - /* this is not an element */ - print_unknown_token(filename, list->token, num_unknown_tokens++); - free(element_token); - - continue; - } - - action_value = getHashEntry(action_hash, action_token); - - if (action_value != NULL) - { - /* action found */ - add_helpanim_entry(atoi(element_value), atoi(action_value), -1, delay, - &num_list_entries); - free(element_token); - - continue; - } - - direction_token = action_token; - direction_value = getHashEntry(direction_hash, direction_token); - - if (direction_value != NULL) - { - /* direction found */ - add_helpanim_entry(atoi(element_value), -1, atoi(direction_value), delay, - &num_list_entries); - free(element_token); - - continue; - } - - if (strchr(action_token + 1, '.') == NULL) - { - /* no further suffixes found -- this is not an action or direction */ - print_unknown_token(filename, list->token, num_unknown_tokens++); - free(element_token); - - continue; - } - - direction_token = strchr(action_token + 1, '.'); - action_token = getStringCopy(action_token); - *strchr(action_token + 1, '.') = '\0'; - - action_value = getHashEntry(action_hash, action_token); - - if (action_value == NULL) - { - /* this is not an action */ - print_unknown_token(filename, list->token, num_unknown_tokens++); - free(element_token); - free(action_token); - - continue; - } - - direction_value = getHashEntry(direction_hash, direction_token); - - if (direction_value != NULL) - { - /* direction found */ - add_helpanim_entry(atoi(element_value), atoi(action_value), - atoi(direction_value), delay, &num_list_entries); - free(element_token); - free(action_token); - - continue; - } - - print_unknown_token(filename, list->token, num_unknown_tokens++); - - free(element_token); - free(action_token); - } - - print_unknown_token_end(num_unknown_tokens); - - add_helpanim_entry(HELPANIM_LIST_END, -1, -1, -1, &num_list_entries); - - freeSetupFileList(setup_file_list); - freeSetupFileHash(element_hash); - freeSetupFileHash(action_hash); - freeSetupFileHash(direction_hash); - -#if 0 - /* TEST ONLY */ - for (i = 0; i < num_list_entries; i++) - printf("::: %d, %d, %d => %d\n", - helpanim_info[i].element, - helpanim_info[i].action, - helpanim_info[i].direction, - helpanim_info[i].delay); -#endif -} -#endif - void LoadHelpTextInfo() { char *filename = getHelpTextFilename(); diff --git a/src/libgame/misc.c b/src/libgame/misc.c index cb06ff46..66d10649 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -82,6 +82,27 @@ char *int2str(int number, int size) } } +/* something similar to "int2str()" above, but allocates its own memory + and has a different interface; we cannot use "itoa()", because this + seems to be already defined when cross-compiling to the win32 target */ + +char *i_to_a(unsigned int i) +{ + static char *a = NULL; + + if (a != NULL) + free(a); + + if (i > 2147483647) /* yes, this is a kludge */ + i = 2147483647; + + a = checked_malloc(10 + 1); + + sprintf(a, "%d", i); + + return a; +} + /* ------------------------------------------------------------------------- */ /* counter functions */ diff --git a/src/libgame/misc.h b/src/libgame/misc.h index 266efa28..968837bd 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -70,6 +70,7 @@ void fprintf_line(FILE *, char *, int); void printf_line(char *, int); char *int2str(int, int); +char *i_to_a(unsigned int); void InitCounter(void); unsigned long Counter(void); diff --git a/src/libgame/setup.c b/src/libgame/setup.c index f9063d5d..ac0bfd4c 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -1206,6 +1206,10 @@ char *getFormattedSetupEntry(char *token, char *value) int i; static char entry[MAX_LINE_LEN]; + /* if value is an empty string, just return token without value */ + if (*value == '\0') + return token; + /* start with the token and some spaces to format output line */ sprintf(entry, "%s:", token); for (i = strlen(entry); i < TOKEN_VALUE_POSITION; i++) @@ -1403,7 +1407,6 @@ static void printSetupFileHash(SetupFileHash *hash) static void *loadSetupFileData(char *filename, boolean use_hash) { - int line_len; char line[MAX_LINE_LEN], previous_line[MAX_LINE_LEN]; char *token, *value, *line_ptr; void *setup_file_data, *insert_ptr = NULL; @@ -1478,37 +1481,34 @@ static void *loadSetupFileData(char *filename, boolean use_hash) if (*line == '\0') continue; - line_len = strlen(line); - /* cut leading whitespaces from token */ for (token = line; *token; token++) if (*token != ' ' && *token != '\t') break; - /* find end of token */ + /* start with empty value as reliable default */ + value = ""; + + /* find end of token to determine start of value */ for (line_ptr = token; *line_ptr; line_ptr++) { if (*line_ptr == ' ' || *line_ptr == '\t' || *line_ptr == ':') { - *line_ptr = '\0'; + *line_ptr = '\0'; /* terminate token string */ + value = line_ptr + 1; /* set beginning of value */ + break; } } - if (line_ptr < line + line_len) - value = line_ptr + 1; - else -#if 1 - value = "true"; /* treat tokens without value as "true" */ -#else - value = "\0"; -#endif - /* cut leading whitespaces from value */ for (; *value; value++) if (*value != ' ' && *value != '\t') break; + if (*value == '\0') + value = "true"; /* treat tokens without value as "true" */ + if (*token && *value) { if (use_hash) diff --git a/src/screens.c b/src/screens.c index 015cbd48..d3a05529 100644 --- a/src/screens.c +++ b/src/screens.c @@ -789,7 +789,7 @@ void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init) infoscreen_frame[i - start]--; } - if (helpanim_info[j].element == -1) + if (helpanim_info[j].element == HELPANIM_LIST_NEXT) { if (!infoscreen_frame[i - start]) infoscreen_step[i - start] = 0; @@ -798,7 +798,7 @@ void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init) { if (!infoscreen_frame[i - start]) infoscreen_step[i - start]++; - while (helpanim_info[j].element != -1) + while (helpanim_info[j].element != HELPANIM_LIST_NEXT) j++; } -- 2.34.1