From: Holger Schemel Date: Sat, 16 Apr 2022 23:04:36 +0000 (+0200) Subject: added functions for accessing score tapes in cache directory (not used yet) X-Git-Tag: 4.3.2.0~2 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=74643e77dcbfe642258dffe01d26687a4abe6bbb;p=rocksndiamonds.git added functions for accessing score tapes in cache directory (not used yet) --- diff --git a/src/files.c b/src/files.c index 6866a4b6..044dcbcc 100644 --- a/src/files.c +++ b/src/files.c @@ -8340,6 +8340,13 @@ void LoadScoreTape(char *score_tape_basename, int nr) LoadTapeFromFilename(filename); } +void LoadScoreCacheTape(char *score_tape_basename, int nr) +{ + char *filename = getScoreCacheTapeFilename(score_tape_basename, nr); + + LoadTapeFromFilename(filename); +} + static boolean checkSaveTape_SCRN(struct TapeInfo *tape) { // chunk required for team mode tapes with non-default screen size diff --git a/src/files.h b/src/files.h index 3736666e..887a9fdf 100644 --- a/src/files.h +++ b/src/files.h @@ -54,6 +54,7 @@ void LoadTapeFromFilename(char *); void LoadTape(int); void LoadSolutionTape(int); void LoadScoreTape(char *, int); +void LoadScoreCacheTape(char *, int); void SaveTapeToFilename(char *); void SaveTape(int); void SaveScoreTape(int); diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 7e34711a..464e9129 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -164,6 +164,19 @@ static char *getScoreTapeDir(char *level_subdir, int nr) return score_tape_dir; } +static char *getScoreCacheTapeDir(char *level_subdir, int nr) +{ + static char *score_cache_tape_dir = NULL; + char tape_subdir[MAX_FILENAME_LEN]; + + checked_free(score_cache_tape_dir); + + sprintf(tape_subdir, "%03d", nr); + score_cache_tape_dir = getPath2(getScoreCacheDir(level_subdir), tape_subdir); + + return score_cache_tape_dir; +} + static char *getUserSubdir(int nr) { static char user_subdir[16] = { 0 }; @@ -705,6 +718,21 @@ char *getScoreTapeFilename(char *basename_no_ext, int nr) return filename; } +char *getScoreCacheTapeFilename(char *basename_no_ext, int nr) +{ + static char *filename = NULL; + char basename[MAX_FILENAME_LEN]; + + checked_free(filename); + + sprintf(basename, "%s.%s", basename_no_ext, TAPEFILE_EXTENSION); + + // used instead of "leveldir_current->subdir" (for network games) + filename = getPath2(getScoreCacheTapeDir(levelset.identifier, nr), basename); + + return filename; +} + char *getSetupFilename(void) { static char *filename = NULL; @@ -1295,6 +1323,13 @@ void InitScoreTapeDirectory(char *level_subdir, int nr) createDirectory(getScoreTapeDir(level_subdir, nr), "score tape", PERMS_PRIVATE); } +void InitScoreCacheTapeDirectory(char *level_subdir, int nr) +{ + InitScoreCacheDirectory(level_subdir); + + createDirectory(getScoreCacheTapeDir(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 573d55b7..1e785a95 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -272,6 +272,7 @@ char *getScoreFilename(int); char *getScoreCacheFilename(int); char *getScoreTapeBasename(char *); char *getScoreTapeFilename(char *, int); +char *getScoreCacheTapeFilename(char *, int); char *getSetupFilename(void); char *getDefaultSetupFilename(void); char *getEditorSetupFilename(void); @@ -299,6 +300,7 @@ void InitTapeDirectory(char *); void InitScoreDirectory(char *); void InitScoreCacheDirectory(char *); void InitScoreTapeDirectory(char *, int); +void InitScoreCacheTapeDirectory(char *, int); void InitUserLevelDirectory(char *); void InitNetworkLevelDirectory(char *); void InitLevelSetupDirectory(char *);