re-added using level number sub-directories when saving score tapes
authorHolger Schemel <info@artsoft.org>
Mon, 25 Oct 2021 06:22:11 +0000 (08:22 +0200)
committerHolger Schemel <info@artsoft.org>
Mon, 25 Oct 2021 06:22:11 +0000 (08:22 +0200)
This reverts commit 94045da2.

src/files.c
src/libgame/setup.c
src/libgame/setup.h

index 442a0b674b915681014f63d50075ac4cf2928c50..b0bb49ecdbe2ac9de65ea04b82e44ae29535a932 100644 (file)
@@ -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);
 }
index 129be747af2f74255697c6e5d804fca741543160..0a406540224696e012e1243fe9944407a62a4863 100644 (file)
@@ -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)
index 194dea7ebeb0c8fa99e55bc2f25b7ad7ec2614af..68f67a7825b06360ec610cbf6ff0e0f6c10c2e74 100644 (file)
@@ -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 *);