From 17cf1ae58fd4c14e1131304b0e021d0f23e8fe01 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 1 Sep 2020 21:51:11 +0200 Subject: [PATCH] Dehardcode some strings --- cheevos/badges.c | 2 +- cheevos/cheevos.c | 10 ++++++---- file_path_special.h | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cheevos/badges.c b/cheevos/badges.c index 1b053c4850..9aa951abc5 100644 --- a/cheevos/badges.c +++ b/cheevos/badges.c @@ -78,7 +78,7 @@ uintptr_t cheevos_get_badge_texture(const char *badge, bool locked) strlcpy(badge_file, badge, sizeof(badge_file)); if (locked) strlcat(badge_file, "_lock", sizeof(badge_file)); - strlcat(badge_file, ".png", sizeof(badge_file)); + strlcat(badge_file, FILE_PATH_PNG_EXTENSION, sizeof(badge_file)); fill_pathname_application_special(fullpath, sizeof(fullpath), APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES); diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index d120eb7587..906bd6a1e5 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -1861,11 +1861,13 @@ static int rcheevos_iterate(rcheevos_coro_t* coro) if (coro->j == 0) snprintf(coro->badge_name, sizeof(coro->badge_name), - "%s.png", coro->cheevo->info->badge); + "%s" FILE_PATH_PNG_EXTENSION, + coro->cheevo->info->badge); else snprintf(coro->badge_name, sizeof(coro->badge_name), - "%s_lock.png", coro->cheevo->info->badge); + "%s_lock" FILE_PATH_PNG_EXTENSION, + coro->cheevo->info->badge); fill_pathname_join( coro->badge_fullpath, @@ -1882,7 +1884,7 @@ static int rcheevos_iterate(rcheevos_coro_t* coro) #endif snprintf(coro->url, sizeof(coro->url), - "http://i.retroachievements.org/Badge/%s", + FILE_PATH_RETROACHIEVEMENTS_URL "/Badge/%s", coro->badge_name); CORO_GOSUB(RCHEEVOS_HTTP_GET); @@ -1891,7 +1893,7 @@ static int rcheevos_iterate(rcheevos_coro_t* coro) { if (!filestream_write_file(coro->badge_fullpath, coro->json, coro->k)) - CHEEVOS_ERR(RCHEEVOS_TAG "error writing badge %s\n", coro->badge_fullpath); + CHEEVOS_ERR(RCHEEVOS_TAG "Error writing badge %s\n", coro->badge_fullpath); else { CHEEVOS_FREE(coro->json); diff --git a/file_path_special.h b/file_path_special.h index 6b4e7cce35..bf63782dca 100644 --- a/file_path_special.h +++ b/file_path_special.h @@ -71,6 +71,7 @@ RETRO_BEGIN_DECLS #define FILE_PATH_INDEX_DIRS_URL ".index-dirs" #define FILE_PATH_INDEX_EXTENDED_URL ".index-extended" #define FILE_PATH_NETPLAY_ROOM_LIST_URL "registry.lpl" +#define FILE_PATH_RETROACHIEVEMENTS_URL "http://i.retroachievements.org" #define FILE_PATH_LOBBY_LIBRETRO_URL "http://lobby.libretro.com/" #define FILE_PATH_CORE_THUMBNAILS_URL "http://thumbnails.libretro.com" #define FILE_PATH_CORE_THUMBNAILPACKS_URL "http://thumbnailpacks.libretro.com"