From: Holger Schemel Date: Sat, 13 Dec 2014 21:21:15 +0000 (+0100) Subject: fixed loading custom PCX image files with default artwork file names X-Git-Tag: 4.0.0.0-rc1~310 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=98c00f2bbb6bbb40e6ac5f989963638122acd17c;p=rocksndiamonds.git fixed loading custom PCX image files with default artwork file names --- diff --git a/ChangeLog b/ChangeLog index ca0742a8..2fd5e233 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2014-12-13 + * fixed loading custom PCX image files with default artwork file names + (like "RocksDoor.pcx") which are not redefined in artwork config file + (this is a special fix for Zelda 2 and probably some other existing + level sets which use new graphics which are not defined in the file + "graphicsinfo.conf", but use a file name of one of default graphics + (like "RocksScreen.pcx"); this did not work anymore for PCX files + since the default graphics files have been changed to PNG files, so + different file names are checked now (like "RocksScreen.png"), so if + the PNG files cannot be found, the old PCX files are also checked) + 2014-12-03 * added some more graphics customization options for the level editor: - editor.button.prev_level (position) diff --git a/src/libgame/misc.c b/src/libgame/misc.c index c123892d..259fb4de 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -606,6 +606,48 @@ char *getPath3(char *path1, char *path2, char *path3) return getStringCat3WithSeparator(path1, path2, path3, STRING_PATH_SEPARATOR); } +char *getImg2(char *path1, char *path2) +{ + char *filename = getPath2(path1, path2); + + if (!fileExists(filename) && strSuffix(path2, ".png")) + { + // backward compatibility: if PNG file not found, check for PCX file + char *path2pcx = getStringCopy(path2); + + strcpy(&path2pcx[strlen(path2pcx) - 3], "pcx"); + + free(filename); + + filename = getPath2(path1, path2pcx); + + free(path2pcx); + } + + return filename; +} + +char *getImg3(char *path1, char *path2, char *path3) +{ + char *filename = getPath3(path1, path2, path3); + + if (!fileExists(filename) && strSuffix(path3, ".png")) + { + // backward compatibility: if PNG file not found, check for PCX file + char *path3pcx = getStringCopy(path3); + + strcpy(&path3pcx[strlen(path3pcx) - 3], "pcx"); + + free(filename); + + filename = getPath3(path1, path2, path3pcx); + + free(path3pcx); + } + + return filename; +} + char *getStringCopy(const char *s) { char *s_copy; diff --git a/src/libgame/misc.h b/src/libgame/misc.h index 9f75cc20..584f9826 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -147,6 +147,8 @@ char *getStringCat2(char *, char *); char *getStringCat3(char *, char *, char *); char *getPath2(char *, char *); char *getPath3(char *, char *, char*); +char *getImg2(char *, char *); +char *getImg3(char *, char *, char*); char *getStringCopy(const char *); char *getStringCopyN(const char *, int); char *getStringCopyNStatic(const char *, int); diff --git a/src/libgame/setup.c b/src/libgame/setup.c index b07f2fdf..8e2152a2 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -614,7 +614,7 @@ char *getCustomImageFilename(char *basename) if (!gfx.override_level_graphics) { /* 1st try: look for special artwork in current level series directory */ - filename = getPath3(getCurrentLevelDir(), GRAPHICS_DIRECTORY, basename); + filename = getImg3(getCurrentLevelDir(), GRAPHICS_DIRECTORY, basename); if (fileExists(filename)) return filename; @@ -624,7 +624,7 @@ char *getCustomImageFilename(char *basename) if (getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) != NULL) { /* 2nd try: look for special artwork configured in level series config */ - filename = getPath2(getLevelArtworkDir(ARTWORK_TYPE_GRAPHICS), basename); + filename = getImg2(getLevelArtworkDir(ARTWORK_TYPE_GRAPHICS), basename); if (fileExists(filename)) return filename; @@ -638,7 +638,7 @@ char *getCustomImageFilename(char *basename) if (!skip_setup_artwork) { /* 3rd try: look for special artwork in configured artwork directory */ - filename = getPath2(getSetupArtworkDir(artwork.gfx_current), basename); + filename = getImg2(getSetupArtworkDir(artwork.gfx_current), basename); if (fileExists(filename)) return filename; @@ -646,14 +646,14 @@ char *getCustomImageFilename(char *basename) } /* 4th try: look for default artwork in new default artwork directory */ - filename = getPath2(getDefaultGraphicsDir(GFX_DEFAULT_SUBDIR), basename); + filename = getImg2(getDefaultGraphicsDir(GFX_DEFAULT_SUBDIR), basename); if (fileExists(filename)) return filename; free(filename); /* 5th try: look for default artwork in old default artwork directory */ - filename = getPath2(options.graphics_directory, basename); + filename = getImg2(options.graphics_directory, basename); if (fileExists(filename)) return filename; @@ -665,7 +665,7 @@ char *getCustomImageFilename(char *basename) /* 6th try: look for fallback artwork in old default artwork directory */ /* (needed to prevent errors when trying to access unused artwork files) */ - filename = getPath2(options.graphics_directory, GFX_FALLBACK_FILENAME); + filename = getImg2(options.graphics_directory, GFX_FALLBACK_FILENAME); if (fileExists(filename)) return filename; #endif