From: Holger Schemel Date: Mon, 23 Aug 2021 10:14:24 +0000 (+0200) Subject: moved getting different solution tape filenames to separate functions X-Git-Tag: 4.3.0.0~90 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=05ee9c39039a7329aa0e8ff747e30526c8c61260;p=rocksndiamonds.git moved getting different solution tape filenames to separate functions --- diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 4bbfba20..48f967c3 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -582,7 +582,7 @@ char *getTapeFilename(int nr) return filename; } -char *getSolutionTapeFilename(int nr) +char *getDefaultSolutionTapeFilename(int nr) { static char *filename = NULL; char basename[MAX_FILENAME_LEN]; @@ -592,17 +592,32 @@ char *getSolutionTapeFilename(int nr) sprintf(basename, "%03d.%s", nr, TAPEFILE_EXTENSION); filename = getPath2(getSolutionTapeDir(), basename); - if (!fileExists(filename)) - { - static char *filename_sln = NULL; + return filename; +} + +char *getSokobanSolutionTapeFilename(int nr) +{ + static char *filename = NULL; + char basename[MAX_FILENAME_LEN]; + + checked_free(filename); + + sprintf(basename, "%03d.sln", nr); + filename = getPath2(getSolutionTapeDir(), basename); + + return filename; +} - checked_free(filename_sln); +char *getSolutionTapeFilename(int nr) +{ + char *filename = getDefaultSolutionTapeFilename(nr); - sprintf(basename, "%03d.sln", nr); - filename_sln = getPath2(getSolutionTapeDir(), basename); + if (!fileExists(filename)) + { + char *filename2 = getSokobanSolutionTapeFilename(nr); - if (fileExists(filename_sln)) - return filename_sln; + if (fileExists(filename2)) + return filename2; } return filename; diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 0b7a8628..056e0bbb 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -264,6 +264,8 @@ char *setLevelArtworkDir(TreeInfo *); char *getProgramMainDataPath(char *, char *); char *getProgramConfigFilename(char *); char *getTapeFilename(int); +char *getDefaultSolutionTapeFilename(int); +char *getSokobanSolutionTapeFilename(int); char *getSolutionTapeFilename(int); char *getScoreFilename(int); char *getScoreCacheFilename(int);