projects
/
rocksndiamonds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
cb52801
)
fixed backwards compatibility code regarding PCX/PNG file change
author
Holger Schemel
<info@artsoft.org>
Tue, 2 Feb 2016 19:58:26 +0000
(20:58 +0100)
committer
Holger Schemel
<info@artsoft.org>
Tue, 2 Feb 2016 19:58:26 +0000
(20:58 +0100)
src/libgame/misc.c
patch
|
blob
|
history
diff --git
a/src/libgame/misc.c
b/src/libgame/misc.c
index dbc0b3072d24eda9f839f44221f980ed79b196ce..59c7d1a20ac9d1aecc8fd5f303d220f375437e41 100644
(file)
--- a/
src/libgame/misc.c
+++ b/
src/libgame/misc.c
@@
-776,46
+776,27
@@
char *getPath3(char *path1, char *path2, char *path3)
return getStringCat3WithSeparator(path1, path2, path3, STRING_PATH_SEPARATOR);
}
return getStringCat3WithSeparator(path1, path2, path3, STRING_PATH_SEPARATOR);
}
-
char *getImg2(char *path1, char *path2
)
+
static char *getPngOrPcxIfNotExists(char *filename
)
{
{
- 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);
+ // switch from PNG to PCX file and vice versa, if file does not exist
+ // (backwards compatibility with PCX files used in previous versions)
- filename = getPath2(path1, path2pcx);
-
- free(path2pcx);
- }
+ if (!fileExists(filename) && strSuffix(filename, ".png"))
+ strcpy(&filename[strlen(filename) - 3], "pcx");
+ else if (!fileExists(filename) && strSuffix(filename, ".pcx"))
+ strcpy(&filename[strlen(filename) - 3], "png");
return filename;
}
return filename;
}
-char *getImg
3(char *path1, char *path2, char *path3
)
+char *getImg
2(char *path1, char *path2
)
{
{
- 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 getPngOrPcxIfNotExists(getPath2(path1, path2));
+}
- return filename;
+char *getImg3(char *path1, char *path2, char *path3)
+{
+ return getPngOrPcxIfNotExists(getPath3(path1, path2, path3));
}
char *getStringCopy(const char *s)
}
char *getStringCopy(const char *s)