From: Holger Schemel Date: Thu, 6 Apr 2006 23:25:35 +0000 (+0200) Subject: rnd-20060407-2-src X-Git-Tag: 3.2.0^2~34 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=95ff39b11bc3c268d8206193bad1433ac9526c94;p=rocksndiamonds.git rnd-20060407-2-src * added selection between ECS and AGA graphics for EMC levels to setup * adjusted font handling for various narrow EMC style fonts --- diff --git a/ChangeLog b/ChangeLog index f4a12b5e..f0745cf8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-04-06 + * added selection between ECS and AGA graphics for EMC levels to setup + +2006-04-04 + * adjusted font handling for various narrow EMC style fonts + 2006-04-03 * changed EM engine behaviour back to re-allow initial rolling springs diff --git a/src/conftime.h b/src/conftime.h index 99ffae5a..8fc5c7a6 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-04-06 19:38]" +#define COMPILE_DATE_STRING "[2006-04-07 01:18]" diff --git a/src/editor.c b/src/editor.c index d628b8be..23c38b21 100644 --- a/src/editor.c +++ b/src/editor.c @@ -4630,7 +4630,7 @@ static void ReinitializeElementList() if (element >= NUM_FILE_ELEMENTS) Error(ERR_WARN, "editor element %d is runtime element", element); - if (strcmp(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT) == 0) + if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT)) Error(ERR_WARN, "no element description for element %d", element); } } diff --git a/src/events.c b/src/events.c index a818d96a..1ae5caa9 100644 --- a/src/events.c +++ b/src/events.c @@ -468,7 +468,7 @@ static boolean is_string_suffix(char *string, char *suffix) if (suffix_len > string_len) return FALSE; - return (strcmp(&string[string_len - suffix_len], suffix) == 0); + return (strEqual(&string[string_len - suffix_len], suffix)); } #define MAX_CHEAT_INPUT_LEN 32 diff --git a/src/files.c b/src/files.c index d97bb2b7..a0b0aff3 100644 --- a/src/files.c +++ b/src/files.c @@ -774,7 +774,7 @@ static void setLevelInfoToDefaults(struct LevelInfo *level) return; /* try to determine better author name than 'anonymous' */ - if (strcmp(leveldir_current->author, ANONYMOUS_NAME) != 0) + if (!strEqual(leveldir_current->author, ANONYMOUS_NAME)) { strncpy(level->author, leveldir_current->author, MAX_LEVEL_AUTHOR_LEN); level->author[MAX_LEVEL_AUTHOR_LEN] = '\0'; @@ -982,7 +982,7 @@ static int getFiletypeFromID(char *filetype_id) { char *id_lower = getStringToLower(filetype_id_list[i].id); - if (strcmp(filetype_id_lower, id_lower) == 0) + if (strEqual(filetype_id_lower, id_lower)) filetype = filetype_id_list[i].filetype; free(id_lower); @@ -1866,12 +1866,12 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, } getFileChunkBE(file, chunk_name, NULL); - if (strcmp(chunk_name, "RND1") == 0) + if (strEqual(chunk_name, "RND1")) { getFile32BitBE(file); /* not used */ getFileChunkBE(file, chunk_name, NULL); - if (strcmp(chunk_name, "CAVE") != 0) + if (!strEqual(chunk_name, "CAVE")) { level->no_valid_file = TRUE; @@ -1947,7 +1947,7 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, int i = 0; while (chunk_info[i].name != NULL && - strcmp(chunk_name, chunk_info[i].name) != 0) + !strEqual(chunk_name, chunk_info[i].name)) i++; if (chunk_info[i].name == NULL) @@ -3088,7 +3088,7 @@ static void LoadLevelFromFileInfo_SP(struct LevelInfo *level, if (reading_multipart_level && (!is_multipart_level || - strcmp(level->name, multipart_level.name) != 0)) + !strEqual(level->name, multipart_level.name))) { /* we are already reading parts of a multi-part level, but this level is either not a multi-part level, or a part of a different multi-part @@ -4541,12 +4541,12 @@ void LoadTapeFromFilename(char *filename) } getFileChunkBE(file, chunk_name, NULL); - if (strcmp(chunk_name, "RND1") == 0) + if (strEqual(chunk_name, "RND1")) { getFile32BitBE(file); /* not used */ getFileChunkBE(file, chunk_name, NULL); - if (strcmp(chunk_name, "TAPE") != 0) + if (!strEqual(chunk_name, "TAPE")) { tape.no_valid_file = TRUE; @@ -4612,7 +4612,7 @@ void LoadTapeFromFilename(char *filename) int i = 0; while (chunk_info[i].name != NULL && - strcmp(chunk_name, chunk_info[i].name) != 0) + !strEqual(chunk_name, chunk_info[i].name)) i++; if (chunk_info[i].name == NULL) @@ -5550,7 +5550,7 @@ void LoadSpecialMenuDesignSettings() /* always start with reliable default values from default config */ for (i = 0; image_config_vars[i].token != NULL; i++) for (j = 0; image_config[j].token != NULL; j++) - if (strcmp(image_config_vars[i].token, image_config[j].token) == 0) + if (strEqual(image_config_vars[i].token, image_config[j].token)) *image_config_vars[i].value = get_auto_parameter_value(image_config_vars[i].token, image_config[j].value); @@ -5775,7 +5775,7 @@ static boolean music_info_listed_ext(struct MusicFileInfo *list, char *basename, boolean is_sound) { for (; list != NULL; list = list->next) - if (list->is_sound == is_sound && strcmp(list->basename, basename) == 0) + if (list->is_sound == is_sound && strEqual(list->basename, basename)) return TRUE; return FALSE; @@ -5833,7 +5833,7 @@ void LoadMusicInfo() if (music->filename == NULL) continue; - if (strcmp(music->filename, UNDEFINED_FILENAME) == 0) + if (strEqual(music->filename, UNDEFINED_FILENAME)) continue; /* a configured file may be not recognized as music */ @@ -5872,7 +5872,7 @@ void LoadMusicInfo() if (music->filename == NULL) continue; - if (strcmp(basename, music->filename) == 0) + if (strEqual(basename, music->filename)) { music_already_used = TRUE; break; @@ -5908,7 +5908,7 @@ void LoadMusicInfo() if (sound->filename == NULL) continue; - if (strcmp(sound->filename, UNDEFINED_FILENAME) == 0) + if (strEqual(sound->filename, UNDEFINED_FILENAME)) continue; /* a configured file may be not recognized as sound */ @@ -6017,7 +6017,7 @@ void LoadHelpAnimInfo() char *element_value, *action_value, *direction_value; int delay = atoi(list->value); - if (strcmp(list->token, "end") == 0) + if (strEqual(list->token, "end")) { add_helpanim_entry(HELPANIM_LIST_NEXT, -1, -1, -1, &num_list_entries); diff --git a/src/game.c b/src/game.c index dbfb37e9..d78023fd 100644 --- a/src/game.c +++ b/src/game.c @@ -2911,7 +2911,7 @@ int NewHiScore() LoadScore(level_nr); - if (strcmp(setup.player_name, EMPTY_PLAYER_NAME) == 0 || + if (strEqual(setup.player_name, EMPTY_PLAYER_NAME) || local_player->score < highscore[MAX_SCORE_ENTRIES - 1].Score) return -1; @@ -2927,7 +2927,7 @@ int NewHiScore() #ifdef ONE_PER_NAME for (l = k; l < MAX_SCORE_ENTRIES; l++) - if (!strcmp(setup.player_name, highscore[l].Name)) + if (strEqual(setup.player_name, highscore[l].Name)) m = l; if (m == k) /* player's new highscore overwrites his old one */ goto put_into_list; diff --git a/src/init.c b/src/init.c index 28fda4e0..d9de7cfc 100644 --- a/src/init.c +++ b/src/init.c @@ -824,12 +824,12 @@ static int get_graphic_parameter_value(char *value_raw, char *suffix, int type) if (type != TYPE_TOKEN) return get_parameter_value(value_raw, suffix, type); - if (strcmp(value_raw, ARG_UNDEFINED) == 0) + if (strEqual(value_raw, ARG_UNDEFINED)) return ARG_UNDEFINED_VALUE; /* !!! OPTIMIZE THIS BY USING HASH !!! */ for (i = 0; i < MAX_NUM_ELEMENTS; i++) - if (strcmp(element_info[i].token_name, value_raw) == 0) + if (strEqual(element_info[i].token_name, value_raw)) return i; /* !!! OPTIMIZE THIS BY USING HASH !!! */ @@ -837,12 +837,12 @@ static int get_graphic_parameter_value(char *value_raw, char *suffix, int type) { int len_config_value = strlen(image_config[i].value); - if (strcmp(&image_config[i].value[len_config_value - 4], ".pcx") != 0 && - strcmp(&image_config[i].value[len_config_value - 4], ".wav") != 0 && - strcmp(image_config[i].value, UNDEFINED_FILENAME) != 0) + if (!strEqual(&image_config[i].value[len_config_value - 4], ".pcx") && + !strEqual(&image_config[i].value[len_config_value - 4], ".wav") && + !strEqual(image_config[i].value, UNDEFINED_FILENAME)) continue; - if (strcmp(image_config[i].token, value_raw) == 0) + if (strEqual(image_config[i].token, value_raw)) return x; x++; @@ -1290,8 +1290,8 @@ static void InitElementSoundInfo() element_info[element].sound[action] = sound; else for (j = 0; j < MAX_NUM_ELEMENTS; j++) - if (strcmp(element_info[j].class_name, - element_info[element].class_name) == 0) + if (strEqual(element_info[j].class_name, + element_info[element].class_name)) element_info[j].sound[action] = sound; } @@ -1309,8 +1309,8 @@ static void InitElementSoundInfo() action = ACTION_DEFAULT; for (j = 0; j < MAX_NUM_ELEMENTS; j++) - if (strcmp(element_info[j].class_name, - element_info[element_class].class_name) == 0) + if (strEqual(element_info[j].class_name, + element_info[element_class].class_name)) element_info[j].sound[action] = sound; } @@ -1465,8 +1465,8 @@ static void InitSoundInfo() int len_action_text = strlen(element_action_info[j].suffix); if (len_action_text < len_effect_text && - strcmp(&sound->token[len_effect_text - len_action_text], - element_action_info[j].suffix) == 0) + strEqual(&sound->token[len_effect_text - len_action_text], + element_action_info[j].suffix)) { sound_effect_properties[i] = element_action_info[j].value; sound_info[i].loop = element_action_info[j].is_loop_sound; @@ -3969,7 +3969,7 @@ void Execute_Command(char *command) { int i; - if (strcmp(command, "print graphicsinfo.conf") == 0) + if (strEqual(command, "print graphicsinfo.conf")) { printf("# You can configure additional/alternative image files here.\n"); printf("# (The entries below are default and therefore commented out.)\n"); @@ -3985,7 +3985,7 @@ void Execute_Command(char *command) exit(0); } - else if (strcmp(command, "print soundsinfo.conf") == 0) + else if (strEqual(command, "print soundsinfo.conf")) { printf("# You can configure additional/alternative sound files here.\n"); printf("# (The entries below are default and therefore commented out.)\n"); @@ -4001,7 +4001,7 @@ void Execute_Command(char *command) exit(0); } - else if (strcmp(command, "print musicinfo.conf") == 0) + else if (strEqual(command, "print musicinfo.conf")) { printf("# You can configure additional/alternative music files here.\n"); printf("# (The entries below are default and therefore commented out.)\n"); @@ -4017,7 +4017,7 @@ void Execute_Command(char *command) exit(0); } - else if (strcmp(command, "print editorsetup.conf") == 0) + else if (strEqual(command, "print editorsetup.conf")) { printf("# You can configure your personal editor element list here.\n"); printf("# (The entries below are default and therefore commented out.)\n"); @@ -4031,7 +4031,7 @@ void Execute_Command(char *command) exit(0); } - else if (strcmp(command, "print helpanim.conf") == 0) + else if (strEqual(command, "print helpanim.conf")) { printf("# You can configure different element help animations here.\n"); printf("# (The entries below are default and therefore commented out.)\n"); @@ -4042,13 +4042,13 @@ void Execute_Command(char *command) printf("# %s\n", getFormattedSetupEntry(helpanim_config[i].token, helpanim_config[i].value)); - if (strcmp(helpanim_config[i].token, "end") == 0) + if (strEqual(helpanim_config[i].token, "end")) printf("#\n"); } exit(0); } - else if (strcmp(command, "print helptext.conf") == 0) + else if (strEqual(command, "print helptext.conf")) { printf("# You can configure different element help text here.\n"); printf("# (The entries below are default and therefore commented out.)\n"); @@ -4342,18 +4342,18 @@ void InitGfx() sprintf(font_token, "%s_%d", CONFIG_TOKEN_FONT_INITIAL, j + 1); len_font_token = strlen(font_token); - if (strcmp(image_config[i].token, font_token) == 0) + if (strEqual(image_config[i].token, font_token)) filename_font_initial = image_config[i].value; else if (strlen(image_config[i].token) > len_font_token && strncmp(image_config[i].token, font_token, len_font_token) == 0) { - if (strcmp(&image_config[i].token[len_font_token], ".x") == 0) + if (strEqual(&image_config[i].token[len_font_token], ".x")) font_initial[j].src_x = atoi(image_config[i].value); - else if (strcmp(&image_config[i].token[len_font_token], ".y") == 0) + else if (strEqual(&image_config[i].token[len_font_token], ".y")) font_initial[j].src_y = atoi(image_config[i].value); - else if (strcmp(&image_config[i].token[len_font_token], ".width") == 0) + else if (strEqual(&image_config[i].token[len_font_token], ".width")) font_initial[j].width = atoi(image_config[i].value); - else if (strcmp(&image_config[i].token[len_font_token],".height") == 0) + else if (strEqual(&image_config[i].token[len_font_token],".height")) font_initial[j].height = atoi(image_config[i].value); } } @@ -4573,8 +4573,8 @@ static char *getNewArtworkIdentifier(int type) #endif /* ---------- reload if current artwork identifier has changed ----------- */ - if (strcmp(ARTWORK_CURRENT_IDENTIFIER(artwork, type), - artwork_current_identifier) != 0) + if (!strEqual(ARTWORK_CURRENT_IDENTIFIER(artwork, type), + artwork_current_identifier)) artwork_new_identifier = artwork_current_identifier; *(ARTWORK_CURRENT_IDENTIFIER_PTR(artwork, type))= artwork_current_identifier; diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index 00a41a8b..ede8cfc7 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -1464,7 +1464,7 @@ boolean HandleGadgets(int mx, int my, int button) { CheckRangeOfNumericInputGadget(gi); - if (strcmp(gi->textinput.value, gi->textinput.last_value) != 0) + if (!strEqual(gi->textinput.last_value, gi->textinput.value)) strcpy(gi->textinput.last_value, gi->textinput.value); else gadget_changed = FALSE; @@ -1911,7 +1911,7 @@ boolean HandleGadgetsKeyInput(Key key) { CheckRangeOfNumericInputGadget(gi); - if (strcmp(gi->textinput.value, gi->textinput.last_value) != 0) + if (!strEqual(gi->textinput.last_value, gi->textinput.value)) strcpy(gi->textinput.last_value, gi->textinput.value); else gadget_changed = FALSE; diff --git a/src/libgame/image.c b/src/libgame/image.c index 719c662a..7f257751 100644 --- a/src/libgame/image.c +++ b/src/libgame/image.c @@ -930,7 +930,7 @@ int getImageIDFromToken(char *token) int i; for (i = 0; i < num_list_entries; i++) - if (strcmp(file_list[i].token, token) == 0) + if (strEqual(file_list[i].token, token)) return i; return -1; diff --git a/src/libgame/joystick.c b/src/libgame/joystick.c index c2d0c192..8cf04cf6 100644 --- a/src/libgame/joystick.c +++ b/src/libgame/joystick.c @@ -148,7 +148,7 @@ void translate_joyname(int *joysymbol, char **name, int mode) for (i = 0; i < 6; i++) { - if (strcmp(*name, translate_joy[i].name) == 0) + if (strEqual(*name, translate_joy[i].name)) { *joysymbol = translate_joy[i].joysymbol; break; diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 970dc77e..154f8343 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -565,6 +565,14 @@ void setString(char **old_value, char *new_value) *old_value = getStringCopy(new_value); } +boolean strEqual(char *s1, char *s2) +{ + return (s1 == NULL && s2 == NULL ? TRUE : + s1 == NULL && s2 != NULL ? FALSE : + s1 != NULL && s2 == NULL ? FALSE : + strcmp(s1, s2) == 0); +} + /* ------------------------------------------------------------------------- */ /* command line option handling functions */ @@ -583,9 +591,9 @@ void GetOptions(char *argv[], void (*print_usage_function)(void)) in an application package directory -- do not try to use this directory as the program data directory (Mac OS X handles this correctly anyway) */ - if (strcmp(ro_base_path, ".") == 0) + if (strEqual(ro_base_path, ".")) ro_base_path = program.command_basepath; - if (strcmp(rw_base_path, ".") == 0) + if (strEqual(rw_base_path, ".")) rw_base_path = program.command_basepath; #endif @@ -625,7 +633,7 @@ void GetOptions(char *argv[], void (*print_usage_function)(void)) strcpy(option_str, option); /* copy argument into buffer */ option = option_str; - if (strcmp(option, "--") == 0) /* stop scanning arguments */ + if (strEqual(option, "--")) /* stop scanning arguments */ break; if (strncmp(option, "--", 2) == 0) /* treat '--' like '-' */ @@ -643,7 +651,7 @@ void GetOptions(char *argv[], void (*print_usage_function)(void)) option_len = strlen(option); - if (strcmp(option, "-") == 0) + if (strEqual(option, "-")) Error(ERR_EXIT_HELP, "unrecognized option '%s'", option); else if (strncmp(option, "-help", option_len) == 0) { @@ -1305,7 +1313,7 @@ void translate_keyname(Key *keysym, char **x11name, char **name, int mode) i = 0; do { - if (strcmp(translate_key[i].name, *name) == 0) + if (strEqual(translate_key[i].name, *name)) { key = translate_key[i].key; break; @@ -1360,7 +1368,7 @@ void translate_keyname(Key *keysym, char **x11name, char **name, int mode) do { - if (strcmp(name_ptr, translate_key[i].x11name) == 0) + if (strEqual(name_ptr, translate_key[i].x11name)) { key = translate_key[i].key; break; @@ -1442,9 +1450,9 @@ char getCharFromKey(Key key) if (strlen(keyname) == 1) letter = keyname[0]; - else if (strcmp(keyname, "space") == 0) + else if (strEqual(keyname, "space")) letter = ' '; - else if (strcmp(keyname, "circumflex") == 0) + else if (strEqual(keyname, "circumflex")) letter = '^'; return letter; @@ -1482,14 +1490,14 @@ int get_integer_from_string(char *s) for (i = 0; number_text[i][0] != NULL; i++) for (j = 0; j < 3; j++) - if (strcmp(s_lower, number_text[i][j]) == 0) + if (strEqual(s_lower, number_text[i][j])) result = i; if (result == -1) { - if (strcmp(s_lower, "false") == 0) + if (strEqual(s_lower, "false")) result = 0; - else if (strcmp(s_lower, "true") == 0) + else if (strEqual(s_lower, "true")) result = 1; else result = atoi(s); @@ -1505,9 +1513,9 @@ boolean get_boolean_from_string(char *s) char *s_lower = getStringToLower(s); boolean result = FALSE; - if (strcmp(s_lower, "true") == 0 || - strcmp(s_lower, "yes") == 0 || - strcmp(s_lower, "on") == 0 || + if (strEqual(s_lower, "true") || + strEqual(s_lower, "yes") || + strEqual(s_lower, "on") || get_integer_from_string(s) == 1) result = TRUE; @@ -1542,7 +1550,7 @@ void deleteNodeFromList(ListNode **node_first, char *key, if (node_first == NULL || *node_first == NULL) return; - if (strcmp((*node_first)->key, key) == 0) + if (strEqual((*node_first)->key, key)) { free((*node_first)->key); if (destructor_function) @@ -1558,7 +1566,7 @@ ListNode *getNodeFromKey(ListNode *node_first, char *key) if (node_first == NULL) return NULL; - if (strcmp(node_first->key, key) == 0) + if (strEqual(node_first->key, key)) return node_first; else return getNodeFromKey(node_first->next, key); @@ -1634,7 +1642,7 @@ boolean fileHasSuffix(char *basename, char *suffix) if (basename_length > suffix_length + 1 && basename_lower[basename_length - suffix_length - 1] == '.' && - strcmp(&basename_lower[basename_length - suffix_length], suffix) == 0) + strEqual(&basename_lower[basename_length - suffix_length], suffix)) return TRUE; return FALSE; @@ -1754,14 +1762,14 @@ int get_parameter_value(char *value_raw, char *suffix, int type) char *value = getStringToLower(value_raw); int result = 0; /* probably a save default value */ - if (strcmp(suffix, ".direction") == 0) + if (strEqual(suffix, ".direction")) { - result = (strcmp(value, "left") == 0 ? MV_LEFT : - strcmp(value, "right") == 0 ? MV_RIGHT : - strcmp(value, "up") == 0 ? MV_UP : - strcmp(value, "down") == 0 ? MV_DOWN : MV_NONE); + result = (strEqual(value, "left") ? MV_LEFT : + strEqual(value, "right") ? MV_RIGHT : + strEqual(value, "up") ? MV_UP : + strEqual(value, "down") ? MV_DOWN : MV_NONE); } - else if (strcmp(suffix, ".anim_mode") == 0) + else if (strEqual(suffix, ".anim_mode")) { result = (string_has_parameter(value, "none") ? ANIM_NONE : string_has_parameter(value, "loop") ? ANIM_LOOP : @@ -1786,7 +1794,7 @@ int get_parameter_value(char *value_raw, char *suffix, int type) } else /* generic parameter of type integer or boolean */ { - result = (strcmp(value, ARG_UNDEFINED) == 0 ? ARG_UNDEFINED_VALUE : + result = (strEqual(value, ARG_UNDEFINED) ? ARG_UNDEFINED_VALUE : type == TYPE_INTEGER ? get_integer_from_string(value) : type == TYPE_BOOLEAN ? get_boolean_from_string(value) : ARG_UNDEFINED_VALUE); @@ -1868,8 +1876,8 @@ struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, int len_suffix = strlen(suffix_list[j].token); if (len_suffix < len_config_token && - strcmp(&config_list[i].token[len_config_token - len_suffix], - suffix_list[j].token) == 0) + strEqual(&config_list[i].token[len_config_token - len_suffix], + suffix_list[j].token)) { setString(&file_list[list_pos].default_parameter[j], config_list[i].value); @@ -1881,7 +1889,7 @@ struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, /* the following tokens are no file definitions, but other config tokens */ for (j = 0; ignore_tokens[j] != NULL; j++) - if (strcmp(config_list[i].token, ignore_tokens[j]) == 0) + if (strEqual(config_list[i].token, ignore_tokens[j])) is_file_entry = FALSE; if (is_file_entry) @@ -1893,9 +1901,9 @@ struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, break; /* simple sanity check if this is really a file definition */ - if (strcmp(&config_list[i].value[len_config_value - 4], ".pcx") != 0 && - strcmp(&config_list[i].value[len_config_value - 4], ".wav") != 0 && - strcmp(config_list[i].value, UNDEFINED_FILENAME) != 0) + if (!strEqual(&config_list[i].value[len_config_value - 4], ".pcx") && + !strEqual(&config_list[i].value[len_config_value - 4], ".wav") && + !strEqual(config_list[i].value, UNDEFINED_FILENAME)) { Error(ERR_RETURN, "Configuration directive '%s' -> '%s':", config_list[i].token, config_list[i].value); @@ -2112,7 +2120,7 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info, { char *value = HASH_ITERATION_VALUE(itr); - if (strcmp(value, known_token_value) != 0) + if (!strEqual(value, known_token_value)) setHashEntry(extra_file_hash, HASH_ITERATION_TOKEN(itr), value); } END_HASH_ITERATION(valid_file_hash, itr) @@ -2341,7 +2349,7 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info, BEGIN_HASH_ITERATION(extra_file_hash, itr) { - if (strcmp(HASH_ITERATION_VALUE(itr), known_token_value) == 0) + if (strEqual(HASH_ITERATION_VALUE(itr), known_token_value)) dynamic_tokens_found = TRUE; else unknown_tokens_found = TRUE; @@ -2358,7 +2366,7 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info, { char *value = getHashEntry(extra_file_hash, list->token); - if (value != NULL && strcmp(value, known_token_value) == 0) + if (value != NULL && strEqual(value, known_token_value)) Error(ERR_RETURN, "- dynamic token: '%s'", list->token); } @@ -2375,7 +2383,7 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info, { char *value = getHashEntry(extra_file_hash, list->token); - if (value != NULL && strcmp(value, known_token_value) != 0) + if (value != NULL && !strEqual(value, known_token_value)) Error(ERR_RETURN, "- dynamic token: '%s'", list->token); } @@ -2481,7 +2489,7 @@ void LoadArtworkConfig(struct ArtworkListInfo *artwork_info) filename_local = getCustomArtworkConfigFilename(artwork_info->type); - if (filename_local != NULL && strcmp(filename_base, filename_local) != 0) + if (filename_local != NULL && !strEqual(filename_base, filename_local)) LoadArtworkConfigFromFilename(artwork_info, filename_local); } @@ -2522,7 +2530,7 @@ static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info, basename = file_list_entry->default_filename; /* dynamic artwork has no default filename / skip empty default artwork */ - if (basename == NULL || strcmp(basename, UNDEFINED_FILENAME) == 0) + if (basename == NULL || strEqual(basename, UNDEFINED_FILENAME)) return; file_list_entry->fallback_to_default = TRUE; @@ -2546,7 +2554,7 @@ static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info, } /* check if the old and the new artwork file are the same */ - if (*listnode && strcmp((*listnode)->source_filename, filename) == 0) + if (*listnode && strEqual((*listnode)->source_filename, filename)) { /* The old and new artwork are the same (have the same filename and path). This usually means that this artwork does not exist in this artwork set @@ -2609,7 +2617,7 @@ static void LoadCustomArtwork(struct ArtworkListInfo *artwork_info, printf("GOT CUSTOM ARTWORK FILE '%s'\n", filename); #endif - if (strcmp(file_list_entry->filename, UNDEFINED_FILENAME) == 0) + if (strEqual(file_list_entry->filename, UNDEFINED_FILENAME)) { deleteArtworkListEntry(artwork_info, listnode); return; diff --git a/src/libgame/misc.h b/src/libgame/misc.h index c69d5f5c..7b36d47a 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -104,6 +104,7 @@ char *getStringCat2(char *, char *); char *getStringCopy(char *); char *getStringToLower(char *); void setString(char **, char *); +boolean strEqual(char *, char *); void GetOptions(char **, void (*print_usage_function)(void)); diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index e460de3b..a6afa282 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -1284,7 +1284,7 @@ void SDLSetMouseCursor(struct MouseCursorInfo *cursor_info) inline void SDLOpenAudio(void) { - if (strcmp(setup.system.sdl_audiodriver, ARG_DEFAULT) != 0) + if (!strEqual(setup.system.sdl_audiodriver, ARG_DEFAULT)) putenv(getStringCat2("SDL_AUDIODRIVER=", setup.system.sdl_audiodriver)); if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 6f8ffaca..a004bc82 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -515,22 +515,6 @@ char *getCustomImageFilename(char *basename) if (!setup.override_level_graphics) { -#if 1 - /* try special ECS graphics */ - filename = getPath3(getCurrentLevelDir(), GRAPHICS_ECS_DIRECTORY, basename); - if (fileExists(filename) && !setup.prefer_aga_graphics) - return filename; - - free(filename); - - /* try special AGA graphics */ - filename = getPath3(getCurrentLevelDir(), GRAPHICS_AGA_DIRECTORY, basename); - if (fileExists(filename) && setup.prefer_aga_graphics) - return filename; - - free(filename); -#endif - /* 1st try: look for special artwork in current level series directory */ filename = getPath3(getCurrentLevelDir(), GRAPHICS_DIRECTORY, basename); if (fileExists(filename)) @@ -538,22 +522,9 @@ char *getCustomImageFilename(char *basename) free(filename); -#if 1 - if (leveldir_current) - printf("::: A -> '%s' [%s]\n", leveldir_current->graphics_set, - leveldir_current->subdir); -#endif - /* check if there is special artwork configured in level series config */ if (getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) != NULL) { -#if 1 - printf("::: B -> '%s' ---------> '%s'\n", - getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS), - leveldir_current->graphics_path); - /* -> getLevelArtworkDir(ARTWORK_TYPE_GRAPHICS)); */ -#endif - /* 2nd try: look for special artwork configured in level series config */ filename = getPath2(getLevelArtworkDir(ARTWORK_TYPE_GRAPHICS), basename); if (fileExists(filename)) @@ -946,7 +917,7 @@ TreeInfo *getTreeInfoFromIdentifier(TreeInfo *node, char *identifier) } else if (!node->parent_link) { - if (strcmp(identifier, node->identifier) == 0) + if (strEqual(identifier, node->identifier)) return node; } @@ -993,51 +964,27 @@ void cloneTree(TreeInfo **ti_new, TreeInfo *ti, boolean skip_empty_sets) *ti_new = ti_cloned; } -static boolean adjustTreeGraphics(TreeInfo *node) +static boolean adjustTreeGraphicsForEMC(TreeInfo *node) { boolean settings_changed = FALSE; while (node) { -#if 1 - if (node->graphics_ecs_set && !setup.prefer_aga_graphics) + if (node->graphics_set_ecs && !setup.prefer_aga_graphics && + !strEqual(node->graphics_set, node->graphics_set_ecs)) { - setString(&node->graphics_set, node->graphics_ecs_set); -#if 0 - printf("::: setting graphics for set '%s' to '%s' [ECS]\n", - node->subdir, node->graphics_set); -#endif - + setString(&node->graphics_set, node->graphics_set_ecs); settings_changed = TRUE; } - else if (node->graphics_aga_set && setup.prefer_aga_graphics) + else if (node->graphics_set_aga && setup.prefer_aga_graphics && + !strEqual(node->graphics_set, node->graphics_set_aga)) { - setString(&node->graphics_set, node->graphics_aga_set); -#if 0 - printf("::: setting graphics for set '%s' to '%s' [AGA]\n", - node->subdir, node->graphics_set); -#endif - + setString(&node->graphics_set, node->graphics_set_aga); settings_changed = TRUE; } - else if (node->graphics_set == NULL) - { -#if 0 - printf("::: cannot set graphics_set for set '%s'\n", node->subdir); -#endif - } -#else - if (node->graphics_ecs_set) - printf("::: SET '%s': found ECS set '%s'\n", - node->subdir, node->graphics_ecs_set); - - if (node->graphics_aga_set) - printf("::: SET '%s': found AGA set '%s'\n", - node->subdir, node->graphics_aga_set); -#endif if (node->node_group != NULL) - settings_changed |= adjustTreeGraphics(node->node_group); + settings_changed |= adjustTreeGraphicsForEMC(node->node_group); node = node->next; } @@ -1181,7 +1128,7 @@ char *getCommonDataDir(void) char *dir = checked_malloc(MAX_PATH + 1); if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_DOCUMENTS, NULL, 0, dir)) - && strcmp(dir, "") != 0) /* empty for Windows 95/98 */ + && !strEqual(dir, "")) /* empty for Windows 95/98 */ common_data_dir = getPath2(dir, program.userdata_directory); else common_data_dir = options.rw_base_directory; @@ -1362,7 +1309,7 @@ char *getListEntry(SetupFileList *list, char *token) if (list == NULL) return NULL; - if (strcmp(list->token, token) == 0) + if (strEqual(list->token, token)) return list->value; else return getListEntry(list->next, token); @@ -1373,7 +1320,7 @@ SetupFileList *setListEntry(SetupFileList *list, char *token, char *value) if (list == NULL) return NULL; - if (strcmp(list->token, token) == 0) + if (strEqual(list->token, token)) { checked_free(list->value); @@ -1455,7 +1402,7 @@ static unsigned int get_hash_from_key(void *key) static int keys_are_equal(void *key1, void *key2) { - return (strcmp((char *)key1, (char *)key2) == 0); + return (strEqual((char *)key1, (char *)key2)); } SetupFileHash *newSetupFileHash() @@ -1703,8 +1650,8 @@ void checkSetupFileHashIdentifier(SetupFileHash *setup_file_hash, #define LEVELINFO_TOKEN_LATEST_ENGINE 9 #define LEVELINFO_TOKEN_LEVEL_GROUP 10 #define LEVELINFO_TOKEN_READONLY 11 -#define LEVELINFO_TOKEN_GRAPHICS_ECS_SET 12 -#define LEVELINFO_TOKEN_GRAPHICS_AGA_SET 13 +#define LEVELINFO_TOKEN_GRAPHICS_SET_ECS 12 +#define LEVELINFO_TOKEN_GRAPHICS_SET_AGA 13 #define LEVELINFO_TOKEN_GRAPHICS_SET 14 #define LEVELINFO_TOKEN_SOUNDS_SET 15 #define LEVELINFO_TOKEN_MUSIC_SET 16 @@ -1732,8 +1679,8 @@ static struct TokenInfo levelinfo_tokens[] = { TYPE_BOOLEAN, &ldi.latest_engine, "latest_engine" }, { TYPE_BOOLEAN, &ldi.level_group, "level_group" }, { TYPE_BOOLEAN, &ldi.readonly, "readonly" }, - { TYPE_STRING, &ldi.graphics_ecs_set, "graphics_ecs_set" }, - { TYPE_STRING, &ldi.graphics_aga_set, "graphics_aga_set" }, + { TYPE_STRING, &ldi.graphics_set_ecs, "graphics_set.ecs" }, + { TYPE_STRING, &ldi.graphics_set_aga, "graphics_set.aga" }, { TYPE_STRING, &ldi.graphics_set, "graphics_set" }, { TYPE_STRING, &ldi.sounds_set, "sounds_set" }, { TYPE_STRING, &ldi.music_set, "music_set" }, @@ -1781,8 +1728,8 @@ static void setTreeInfoToDefaults(TreeInfo *ldi, int type) ldi->imported_from = NULL; ldi->imported_by = NULL; - ldi->graphics_ecs_set = NULL; - ldi->graphics_aga_set = NULL; + ldi->graphics_set_ecs = NULL; + ldi->graphics_set_aga = NULL; ldi->graphics_set = NULL; ldi->sounds_set = NULL; ldi->music_set = NULL; @@ -1848,8 +1795,8 @@ static void setTreeInfoToDefaultsFromParent(TreeInfo *ldi, TreeInfo *parent) ldi->imported_from = getStringCopy(parent->imported_from); ldi->imported_by = getStringCopy(parent->imported_by); - ldi->graphics_ecs_set = NULL; - ldi->graphics_aga_set = NULL; + ldi->graphics_set_ecs = NULL; + ldi->graphics_set_aga = NULL; ldi->graphics_set = NULL; ldi->sounds_set = NULL; ldi->music_set = NULL; @@ -1889,8 +1836,8 @@ static void freeTreeInfo(TreeInfo *ldi) checked_free(ldi->imported_from); checked_free(ldi->imported_by); - checked_free(ldi->graphics_ecs_set); - checked_free(ldi->graphics_aga_set); + checked_free(ldi->graphics_set_ecs); + checked_free(ldi->graphics_set_aga); checked_free(ldi->graphics_set); checked_free(ldi->sounds_set); checked_free(ldi->music_set); @@ -2063,7 +2010,7 @@ static boolean LoadLevelInfoFromLevelConf(TreeInfo **node_first, getHashEntry(setup_file_hash, levelinfo_tokens[i].text)); *leveldir_new = ldi; - if (strcmp(leveldir_new->name, ANONYMOUS_NAME) == 0) + if (strEqual(leveldir_new->name, ANONYMOUS_NAME)) setString(&leveldir_new->name, leveldir_new->subdir); DrawInitText(leveldir_new->name, 150, FC_YELLOW); @@ -2094,14 +2041,14 @@ static boolean LoadLevelInfoFromLevelConf(TreeInfo **node_first, leveldir_new->first_level + leveldir_new->levels - 1; leveldir_new->in_user_dir = - (strcmp(leveldir_new->basepath, options.level_directory) != 0); + (!strEqual(leveldir_new->basepath, options.level_directory)); /* adjust some settings if user's private level directory was detected */ if (leveldir_new->sort_priority == LEVELCLASS_UNDEFINED && leveldir_new->in_user_dir && - (strcmp(leveldir_new->subdir, getLoginName()) == 0 || - strcmp(leveldir_new->name, getLoginName()) == 0 || - strcmp(leveldir_new->author, getRealName()) == 0)) + (strEqual(leveldir_new->subdir, getLoginName()) || + strEqual(leveldir_new->name, getLoginName()) || + strEqual(leveldir_new->author, getRealName()))) { leveldir_new->sort_priority = LEVELCLASS_PRIVATE_START; leveldir_new->readonly = FALSE; @@ -2175,8 +2122,8 @@ static void LoadLevelInfoFromLevelDir(TreeInfo **node_first, char *directory_path = getPath2(level_directory, directory_name); /* skip entries for current and parent directory */ - if (strcmp(directory_name, ".") == 0 || - strcmp(directory_name, "..") == 0) + if (strEqual(directory_name, ".") || + strEqual(directory_name, "..")) { free(directory_path); continue; @@ -2192,9 +2139,9 @@ static void LoadLevelInfoFromLevelDir(TreeInfo **node_first, free(directory_path); - if (strcmp(directory_name, GRAPHICS_DIRECTORY) == 0 || - strcmp(directory_name, SOUNDS_DIRECTORY) == 0 || - strcmp(directory_name, MUSIC_DIRECTORY) == 0) + if (strEqual(directory_name, GRAPHICS_DIRECTORY) || + strEqual(directory_name, SOUNDS_DIRECTORY) || + strEqual(directory_name, MUSIC_DIRECTORY)) continue; valid_entry_found |= LoadLevelInfoFromLevelConf(node_first, node_parent, @@ -2221,17 +2168,8 @@ boolean AdjustGraphicsForEMC() { boolean settings_changed = FALSE; -#if 1 - printf("::: AdjustGraphicsForEMC()\n"); - - settings_changed |= adjustTreeGraphics(leveldir_first_all); - settings_changed |= adjustTreeGraphics(leveldir_first); - - if (leveldir_current) - printf("::: X -> '%s'\n", leveldir_current->graphics_set); - else - printf("::: X (leveldir_current == NULL)\n"); -#endif + settings_changed |= adjustTreeGraphicsForEMC(leveldir_first_all); + settings_changed |= adjustTreeGraphicsForEMC(leveldir_first); return settings_changed; } @@ -2280,10 +2218,6 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, TreeInfo *artwork_new = NULL; int i; -#if 0 - printf("::: CHECKING FOR CONFIG FILE '%s'\n", filename); -#endif - if (fileExists(filename)) setup_file_hash = loadSetupFileHash(filename); @@ -2311,7 +2245,7 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, if (!valid_file_found) { - if (strcmp(directory_name, ".") != 0) + if (!strEqual(directory_name, ".")) Error(ERR_WARN, "ignoring artwork directory '%s'", directory_path); free(directory_path); @@ -2343,7 +2277,7 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, getHashEntry(setup_file_hash, levelinfo_tokens[i].text)); *artwork_new = ldi; - if (strcmp(artwork_new->name, ANONYMOUS_NAME) == 0) + if (strEqual(artwork_new->name, ANONYMOUS_NAME)) setString(&artwork_new->name, artwork_new->subdir); #if 0 @@ -2369,7 +2303,7 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, } artwork_new->in_user_dir = - (strcmp(artwork_new->basepath, OPTIONS_ARTWORK_DIRECTORY(type)) != 0); + (!strEqual(artwork_new->basepath, OPTIONS_ARTWORK_DIRECTORY(type))); /* (may use ".sort_priority" from "setup_file_hash" above) */ artwork_new->color = ARTWORKCOLOR(artwork_new); @@ -2378,7 +2312,7 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, if (setup_file_hash == NULL) /* (after determining ".user_defined") */ { - if (strcmp(artwork_new->subdir, ".") == 0) + if (strEqual(artwork_new->subdir, ".")) { if (artwork_new->user_defined) { @@ -2426,10 +2360,6 @@ static void LoadArtworkInfoFromArtworkDir(TreeInfo **node_first, struct dirent *dir_entry; boolean valid_entry_found = FALSE; -#if 0 - printf("::: CHECKING BASE DIR '%s'\n", base_directory); -#endif - if ((dir = opendir(base_directory)) == NULL) { /* display error if directory is main "options.graphics_directory" etc. */ @@ -2446,8 +2376,8 @@ static void LoadArtworkInfoFromArtworkDir(TreeInfo **node_first, char *directory_path = getPath2(base_directory, directory_name); /* skip directory entries for current and parent directory */ - if (strcmp(directory_name, ".") == 0 || - strcmp(directory_name, "..") == 0) + if (strEqual(directory_name, ".") || + strEqual(directory_name, "..")) { free(directory_path); continue; @@ -2576,36 +2506,6 @@ void LoadArtworkInfo() #endif } -void LoadArtworkInfoFromLevelNode(ArtworkDirTree **artwork_node, - LevelDirTree *level_node, - char *artwork_directory) -{ - TreeInfo *topnode_last = *artwork_node; - char *path = getPath2(getLevelDirFromTreeInfo(level_node), artwork_directory); - -#if 1 - printf("::: CHECKING '%s' ...\n", path); -#endif - - LoadArtworkInfoFromArtworkDir(artwork_node, NULL, path,(*artwork_node)->type); - - if (topnode_last != *artwork_node) - { - free((*artwork_node)->identifier); - free((*artwork_node)->name); - free((*artwork_node)->name_sorting); - - (*artwork_node)->identifier = getStringCopy(level_node->subdir); - (*artwork_node)->name = getStringCopy(level_node->name); - (*artwork_node)->name_sorting = getStringCopy(level_node->name); - - (*artwork_node)->sort_priority = level_node->sort_priority; - (*artwork_node)->color = LEVELCOLOR((*artwork_node)); - } - - free(path); -} - void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node, LevelDirTree *level_node) { @@ -2616,28 +2516,6 @@ void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node, /* check all tree entries for artwork, but skip parent link entries */ if (!level_node->parent_link) { -#if 1 - struct - { - int type; - char *dir; - } - artwork_type_dirs[] = - { - { ARTWORK_TYPE_GRAPHICS, GRAPHICS_DIRECTORY }, - { ARTWORK_TYPE_GRAPHICS, GRAPHICS_ECS_DIRECTORY }, - { ARTWORK_TYPE_GRAPHICS, GRAPHICS_AGA_DIRECTORY }, - { ARTWORK_TYPE_SOUNDS, SOUNDS_DIRECTORY }, - { ARTWORK_TYPE_MUSIC, MUSIC_DIRECTORY }, - { -1, NULL } - }; - int i; - - for (i = 0; artwork_type_dirs[i].type != -1; i++) - if ((*artwork_node)->type == artwork_type_dirs[i].type) - LoadArtworkInfoFromLevelNode(artwork_node, level_node, - artwork_type_dirs[i].dir); -#else TreeInfo *topnode_last = *artwork_node; char *path = getPath2(getLevelDirFromTreeInfo(level_node), ARTWORK_DIRECTORY((*artwork_node)->type)); @@ -2660,7 +2538,6 @@ void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node, } free(path); -#endif } if (level_node->node_group != NULL) @@ -2680,7 +2557,7 @@ void LoadLevelArtworkInfo() /* needed for reloading level artwork not known at ealier stage */ - if (strcmp(artwork.gfx_current_identifier, setup.graphics_set) != 0) + if (!strEqual(artwork.gfx_current_identifier, setup.graphics_set)) { artwork.gfx_current = getTreeInfoFromIdentifier(artwork.gfx_first, setup.graphics_set); @@ -2691,7 +2568,7 @@ void LoadLevelArtworkInfo() artwork.gfx_current = getFirstValidTreeInfoEntry(artwork.gfx_first); } - if (strcmp(artwork.snd_current_identifier, setup.sounds_set) != 0) + if (!strEqual(artwork.snd_current_identifier, setup.sounds_set)) { artwork.snd_current = getTreeInfoFromIdentifier(artwork.snd_first, setup.sounds_set); @@ -2702,7 +2579,7 @@ void LoadLevelArtworkInfo() artwork.snd_current = getFirstValidTreeInfoEntry(artwork.snd_first); } - if (strcmp(artwork.mus_current_identifier, setup.music_set) != 0) + if (!strEqual(artwork.mus_current_identifier, setup.music_set)) { artwork.mus_current = getTreeInfoFromIdentifier(artwork.mus_first, setup.music_set); @@ -2853,8 +2730,8 @@ char *getSetupLine(struct TokenInfo *token_info, char *prefix, int token_nr) char *keyname = getKeyNameFromKey(key); /* add comment, if useful */ - if (strcmp(keyname, "(undefined)") != 0 && - strcmp(keyname, "(unknown)") != 0) + if (!strEqual(keyname, "(undefined)") && + !strEqual(keyname, "(unknown)")) { /* add at least one whitespace */ strcat(line, " "); @@ -2956,7 +2833,7 @@ static void checkSeriesInfo() { if (strlen(dir_entry->d_name) > 4 && dir_entry->d_name[3] == '.' && - strcmp(&dir_entry->d_name[4], LEVELFILE_EXTENSION) == 0) + strEqual(&dir_entry->d_name[4], LEVELFILE_EXTENSION)) { char levelnum_str[4]; int levelnum_value; diff --git a/src/libgame/sound.c b/src/libgame/sound.c index a4b31c06..d75acaf3 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -1568,7 +1568,7 @@ static void *Load_WAV(char *filename) /* read chunk id "RIFF" */ getFileChunkLE(file, chunk_name, &chunk_size); - if (strcmp(chunk_name, "RIFF") != 0) + if (!strEqual(chunk_name, "RIFF")) { Error(ERR_WARN, "missing 'RIFF' chunk of sound file '%s'", filename); fclose(file); @@ -1578,7 +1578,7 @@ static void *Load_WAV(char *filename) /* read "RIFF" type id "WAVE" */ getFileChunkLE(file, chunk_name, NULL); - if (strcmp(chunk_name, "WAVE") != 0) + if (!strEqual(chunk_name, "WAVE")) { Error(ERR_WARN, "missing 'WAVE' type ID of sound file '%s'", filename); fclose(file); @@ -1588,7 +1588,7 @@ static void *Load_WAV(char *filename) while (getFileChunkLE(file, chunk_name, &chunk_size)) { - if (strcmp(chunk_name, "fmt ") == 0) + if (strEqual(chunk_name, "fmt ")) { if (chunk_size < WAV_HEADER_SIZE) { @@ -1652,7 +1652,7 @@ static void *Load_WAV(char *filename) printf(" Significant bits per sample: %d'\n", header.bits_per_sample); #endif } - else if (strcmp(chunk_name, "data") == 0) + else if (strEqual(chunk_name, "data")) { data_byte_len = chunk_size; @@ -1775,7 +1775,7 @@ void LoadCustomMusic_NoConf(void) return; if (last_music_directory != NULL && - strcmp(last_music_directory, music_directory) == 0) + strEqual(last_music_directory, music_directory)) return; /* old and new music directory are the same */ if (last_music_directory != NULL) @@ -1807,7 +1807,7 @@ void LoadCustomMusic_NoConf(void) { struct FileInfo *music = getMusicListEntry(i); - if (strcmp(basename, music->filename) == 0) + if (strEqual(basename, music->filename)) { music_already_used = TRUE; break; diff --git a/src/libgame/system.c b/src/libgame/system.c index 12e72404..94bcccdc 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -753,7 +753,7 @@ void ReloadCustomImage(Bitmap *bitmap, char *basename) return; } - if (strcmp(filename, bitmap->source_filename) == 0) + if (strEqual(filename, bitmap->source_filename)) { /* The old and new image are the same (have the same filename and path). This usually means that this image does not exist in this graphic set diff --git a/src/libgame/system.h b/src/libgame/system.h index 4901a874..40783a5c 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -277,8 +277,6 @@ #define RW_BASE_PATH RW_GAME_DIR /* directory names */ -#define GRAPHICS_ECS_DIRECTORY "graphics.ecs" -#define GRAPHICS_AGA_DIRECTORY "graphics.aga" #define GRAPHICS_DIRECTORY "graphics" #define SOUNDS_DIRECTORY "sounds" #define MUSIC_DIRECTORY "music" @@ -748,8 +746,8 @@ struct TreeInfo char *imported_from; /* optional comment for imported levels or artwork */ char *imported_by; /* optional comment for imported levels or artwork */ - char *graphics_ecs_set; /* special EMC custom graphics set (ECS graphics) */ - char *graphics_aga_set; /* special EMC custom graphics set (AGA graphics) */ + char *graphics_set_ecs; /* special EMC custom graphics set (ECS graphics) */ + char *graphics_set_aga; /* special EMC custom graphics set (AGA graphics) */ char *graphics_set; /* optional custom graphics set (level tree only) */ char *sounds_set; /* optional custom sounds set (level tree only) */ char *music_set; /* optional custom music set (level tree only) */ diff --git a/src/libgame/toons.c b/src/libgame/toons.c index 6f4fd2f7..2eb805bd 100644 --- a/src/libgame/toons.c +++ b/src/libgame/toons.c @@ -88,10 +88,10 @@ int getAnimationFrame(int num_frames, int delay, int mode, int start_frame, static int get_toon_direction(char *direction_string_raw) { char *direction_string = getStringToLower(direction_string_raw); - int direction = (strcmp(direction_string, "left") == 0 ? MV_LEFT : - strcmp(direction_string, "right") == 0 ? MV_RIGHT : - strcmp(direction_string, "up") == 0 ? MV_UP : - strcmp(direction_string, "down") == 0 ? MV_DOWN : + int direction = (strEqual(direction_string, "left") ? MV_LEFT : + strEqual(direction_string, "right") ? MV_RIGHT : + strEqual(direction_string, "up") ? MV_UP : + strEqual(direction_string, "down") ? MV_DOWN : MV_NONE); free(direction_string); @@ -177,13 +177,13 @@ boolean AnimateToon(int toon_nr, boolean restart) { int pos_bottom = screen_info.height - anim->height; - if (strcmp(anim->position, "top") == 0) + if (strEqual(anim->position, "top")) pos_y = 0; - else if (strcmp(anim->position, "bottom") == 0) + else if (strEqual(anim->position, "bottom")) pos_y = pos_bottom; - else if (strcmp(anim->position, "upper") == 0) + else if (strEqual(anim->position, "upper")) pos_y = SimpleRND(pos_bottom / 2); - else if (strcmp(anim->position, "lower") == 0) + else if (strEqual(anim->position, "lower")) pos_y = pos_bottom / 2 + SimpleRND(pos_bottom / 2); else pos_y = SimpleRND(pos_bottom); @@ -205,9 +205,9 @@ boolean AnimateToon(int toon_nr, boolean restart) { int pos_right = screen_info.width - anim->width; - if (strcmp(anim->position, "left") == 0) + if (strEqual(anim->position, "left")) pos_x = 0; - else if (strcmp(anim->position, "right") == 0) + else if (strEqual(anim->position, "right")) pos_x = pos_right; else pos_x = SimpleRND(pos_right); diff --git a/src/screens.c b/src/screens.c index 7a7fe1af..2a59fee7 100644 --- a/src/screens.c +++ b/src/screens.c @@ -594,7 +594,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) else if (y == 3) { if (leveldir_current->readonly && - strcmp(setup.player_name, "Artsoft") != 0) + !strEqual(setup.player_name, "Artsoft")) Request("This level is read only !", REQ_CONFIRM); game_status = GAME_MODE_EDITOR; DrawLevelEd(); @@ -1140,17 +1140,17 @@ void HandleInfoScreen_Music(int button) DrawTextSCentered(100, FONT_TEXT_1, "The Game Background Music:"); } - if (strcmp(list->title, UNKNOWN_NAME) != 0) + if (!strEqual(list->title, UNKNOWN_NAME)) { - if (strcmp(list->title_header, UNKNOWN_NAME) != 0) + if (!strEqual(list->title_header, UNKNOWN_NAME)) DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, list->title_header); DrawTextFCentered(ystart + y++ * dy, FONT_TEXT_3, "\"%s\"", list->title); } - if (strcmp(list->artist, UNKNOWN_NAME) != 0) + if (!strEqual(list->artist, UNKNOWN_NAME)) { - if (strcmp(list->artist_header, UNKNOWN_NAME) != 0) + if (!strEqual(list->artist_header, UNKNOWN_NAME)) DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, list->artist_header); else DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, "by"); @@ -1158,9 +1158,9 @@ void HandleInfoScreen_Music(int button) DrawTextFCentered(ystart + y++ * dy, FONT_TEXT_3, "%s", list->artist); } - if (strcmp(list->album, UNKNOWN_NAME) != 0) + if (!strEqual(list->album, UNKNOWN_NAME)) { - if (strcmp(list->album_header, UNKNOWN_NAME) != 0) + if (!strEqual(list->album_header, UNKNOWN_NAME)) DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, list->album_header); else DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, "from the album"); @@ -1168,9 +1168,9 @@ void HandleInfoScreen_Music(int button) DrawTextFCentered(ystart + y++ * dy, FONT_TEXT_3, "\"%s\"", list->album); } - if (strcmp(list->year, UNKNOWN_NAME) != 0) + if (!strEqual(list->year, UNKNOWN_NAME)) { - if (strcmp(list->year_header, UNKNOWN_NAME) != 0) + if (!strEqual(list->year_header, UNKNOWN_NAME)) DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, list->year_header); else DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, "from the year"); @@ -1904,8 +1904,10 @@ static void drawHallOfFameList(int first_entry, int highlight_position) DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1); DrawText(mSX + dx1, sy, ".", font_nr1); DrawText(mSX + dx2, sy, ".........................", font_nr3); - if (strcmp(highscore[entry].Name, EMPTY_PLAYER_NAME) != 0) + + if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME)) DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2); + DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4); } diff --git a/src/tools.c b/src/tools.c index 3f611344..1c02798b 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1652,9 +1652,9 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart) /* !!! THIS ALL SUCKS -- SHOULD BE CLEANLY REWRITTEN !!! */ /* redraw micro level label, if needed */ - if (strcmp(level.name, NAMELESS_LEVEL_NAME) != 0 && - strcmp(level.author, ANONYMOUS_NAME) != 0 && - strcmp(level.author, leveldir_current->name) != 0 && + if (!strEqual(level.name, NAMELESS_LEVEL_NAME) && + !strEqual(level.author, ANONYMOUS_NAME) && + !strEqual(level.author, leveldir_current->name) && DelayReached(&label_delay, MICROLEVEL_LABEL_DELAY)) { int max_label_counter = 23;