From: Holger Schemel Date: Mon, 25 Oct 2021 06:22:11 +0000 (+0200) Subject: re-added using level number sub-directories when saving score tapes X-Git-Tag: 4.3.0.0~10 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=2c5027751cc177b5a2c6b3100d5a3bcfa7a277f9;p=rocksndiamonds.git re-added using level number sub-directories when saving score tapes This reverts commit 94045da2. --- diff --git a/src/files.c b/src/files.c index 442a0b67..b0bb49ec 100644 --- a/src/files.c +++ b/src/files.c @@ -8401,7 +8401,7 @@ void SaveScoreTape(int nr) char *filename = getScoreTapeFilename(tape.score_tape_basename, nr); // used instead of "leveldir_current->subdir" (for network games) - InitScoreDirectory(levelset.identifier); + InitScoreTapeDirectory(levelset.identifier, nr); SaveTapeExt(filename); } diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 129be747..0a406540 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -140,6 +140,19 @@ static char *getScoreCacheDir(char *level_subdir) return score_dir; } +static char *getScoreTapeDir(char *level_subdir, int nr) +{ + static char *score_tape_dir = NULL; + char tape_subdir[MAX_FILENAME_LEN]; + + checked_free(score_tape_dir); + + sprintf(tape_subdir, "%03d", nr); + score_tape_dir = getPath2(getScoreDir(level_subdir), tape_subdir); + + return score_tape_dir; +} + static char *getUserSubdir(int nr) { static char user_subdir[16] = { 0 }; @@ -673,10 +686,10 @@ char *getScoreTapeFilename(char *basename_no_ext, int nr) checked_free(filename); - sprintf(basename, "%03d.%s.%s", nr, basename_no_ext, TAPEFILE_EXTENSION); + sprintf(basename, "%s.%s", basename_no_ext, TAPEFILE_EXTENSION); // used instead of "leveldir_current->subdir" (for network games) - filename = getPath2(getScoreDir(levelset.identifier), basename); + filename = getPath2(getScoreTapeDir(levelset.identifier, nr), basename); return filename; } @@ -1164,6 +1177,13 @@ void InitScoreCacheDirectory(char *level_subdir) createDirectory(getScoreCacheDir(level_subdir), "level score", PERMS_PRIVATE); } +void InitScoreTapeDirectory(char *level_subdir, int nr) +{ + InitScoreDirectory(level_subdir); + + createDirectory(getScoreTapeDir(level_subdir, nr), "score tape", PERMS_PRIVATE); +} + static void SaveUserLevelInfo(void); void InitUserLevelDirectory(char *level_subdir) diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 194dea7e..68f67a78 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -291,6 +291,7 @@ char *getCustomMusicDirectory(void); void InitTapeDirectory(char *); void InitScoreDirectory(char *); void InitScoreCacheDirectory(char *); +void InitScoreTapeDirectory(char *, int); void InitUserLevelDirectory(char *); void InitNetworkLevelDirectory(char *); void InitLevelSetupDirectory(char *);