SetFilePermissions(filename, PERMS_PRIVATE);
}
-void SaveTape(int nr)
+static void SaveTapeExt(char *filename)
{
- char *filename = getTapeFilename(nr);
int i;
- InitTapeDirectory(leveldir_current->subdir);
-
tape.file_version = FILE_VERSION_ACTUAL;
tape.game_version = GAME_VERSION_ACTUAL;
tape.changed = FALSE;
}
+void SaveTape(int nr)
+{
+ char *filename = getTapeFilename(nr);
+
+ InitTapeDirectory(leveldir_current->subdir);
+
+ SaveTapeExt(filename);
+}
+
+void SaveScoreTape(int nr)
+{
+ char *filename = getScoreTapeFilename(tape.score_tape_basename, nr);
+
+ // used instead of "leveldir_current->subdir" (for network games)
+ InitScoreTapeDirectory(levelset.identifier, nr);
+
+ SaveTapeExt(filename);
+}
+
static boolean SaveTapeCheckedExt(int nr, char *msg_replace, char *msg_saved,
unsigned int req_state_added)
{
void LoadSolutionTape(int);
void SaveTapeToFilename(char *);
void SaveTape(int);
+void SaveScoreTape(int);
void DumpTape(struct TapeInfo *);
boolean SaveTapeChecked(int);
boolean SaveTapeChecked_LevelSolved(int);
CloseDoor(DOOR_CLOSE_1);
SaveTapeChecked_LevelSolved(tape.level_nr); // ask to save tape
+
+ // set unique basename for score tape (also saved in high score table)
+ strcpy(tape.score_tape_basename, getScoreTapeBasename(setup.player_name));
}
// if no tape is to be saved, close both doors simultaneously
}
if (position >= 0)
+ {
+ SaveScoreTape(level_nr);
SaveScore(level_nr);
+ }
return position;
}
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 };
return filename;
}
+char *getScoreTapeBasename(char *name)
+{
+ static char basename[MAX_FILENAME_LEN];
+ char basename_raw[MAX_FILENAME_LEN];
+ char timestamp[20];
+
+ sprintf(timestamp, "%s", getCurrentTimestamp());
+ sprintf(basename_raw, "%s-%s", timestamp, name);
+ sprintf(basename, "%s-%08x", timestamp, get_hash_from_key(basename_raw));
+
+ return basename;
+}
+
+char *getScoreTapeFilename(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(getScoreTapeDir(levelset.identifier, nr), basename);
+
+ return filename;
+}
+
char *getSetupFilename(void)
{
static char *filename = NULL;
createDirectory(getScoreDir(level_subdir), "level score", permissions);
}
+void InitScoreTapeDirectory(char *level_subdir, int nr)
+{
+ int permissions = (program.global_scores ? PERMS_PUBLIC : PERMS_PRIVATE);
+
+ InitScoreDirectory(level_subdir);
+
+ createDirectory(getScoreTapeDir(level_subdir, nr), "score tape", permissions);
+}
+
static void SaveUserLevelInfo(void);
void InitUserLevelDirectory(char *level_subdir)
char *getTapeFilename(int);
char *getSolutionTapeFilename(int);
char *getScoreFilename(int);
+char *getScoreTapeBasename(char *);
+char *getScoreTapeFilename(char *, int);
char *getSetupFilename(void);
char *getDefaultSetupFilename(void);
char *getEditorSetupFilename(void);
void InitTapeDirectory(char *);
void InitScoreDirectory(char *);
+void InitScoreTapeDirectory(char *, int);
void InitUserLevelDirectory(char *);
void InitNetworkLevelDirectory(char *);
void InitLevelSetupDirectory(char *);
tape.length_frames = 0;
tape.length_seconds = 0;
+ tape.score_tape_basename[0] = '\0';
+
if (leveldir_current)
{
strncpy(tape.level_identifier, leveldir_current->identifier,
int game_version; // game release version the tape was created with
int engine_version; // game engine version the tape was recorded with
+ char score_tape_basename[MAX_FILENAME_LEN + 1];
char level_identifier[MAX_FILENAME_LEN + 1];
int level_nr;
unsigned int random_seed;