From: Holger Schemel Date: Thu, 10 Sep 2020 18:35:15 +0000 (+0200) Subject: split function to save tape X-Git-Tag: 4.2.0.3~54 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=76d9e113943e9f28f30dbb21ca2e8175ac5af560;p=rocksndiamonds.git split function to save tape --- diff --git a/src/files.c b/src/files.c index 283ebf0f..32fbf32b 100644 --- a/src/files.c +++ b/src/files.c @@ -8144,16 +8144,12 @@ static void SaveTape_BODY(FILE *file, struct TapeInfo *tape) } } -void SaveTape(int nr) +void SaveTapeToFilename(char *filename) { - char *filename = getTapeFilename(nr); FILE *file; int tape_pos_size; int info_chunk_size; int body_chunk_size; - int i; - - InitTapeDirectory(leveldir_current->subdir); if (!(file = fopen(filename, MODE_WRITE))) { @@ -8161,16 +8157,6 @@ void SaveTape(int nr) return; } - tape.file_version = FILE_VERSION_ACTUAL; - tape.game_version = GAME_VERSION_ACTUAL; - - tape.num_participating_players = 0; - - // count number of participating players - for (i = 0; i < MAX_PLAYERS; i++) - if (tape.player_participates[i]) - tape.num_participating_players++; - tape_pos_size = getTapePosSize(&tape); info_chunk_size = 2 + (strlen(tape.level_identifier) + 1) + 2; @@ -8194,6 +8180,26 @@ void SaveTape(int nr) fclose(file); SetFilePermissions(filename, PERMS_PRIVATE); +} + +void SaveTape(int nr) +{ + char *filename = getTapeFilename(nr); + int i; + + InitTapeDirectory(leveldir_current->subdir); + + tape.file_version = FILE_VERSION_ACTUAL; + tape.game_version = GAME_VERSION_ACTUAL; + + tape.num_participating_players = 0; + + // count number of participating players + for (i = 0; i < MAX_PLAYERS; i++) + if (tape.player_participates[i]) + tape.num_participating_players++; + + SaveTapeToFilename(filename); tape.changed = FALSE; } diff --git a/src/files.h b/src/files.h index fd55786c..ca331ad7 100644 --- a/src/files.h +++ b/src/files.h @@ -50,6 +50,7 @@ void CopyNativeLevel_Native_to_RND(struct LevelInfo *); void LoadTapeFromFilename(char *); void LoadTape(int); void LoadSolutionTape(int); +void SaveTapeToFilename(char *); void SaveTape(int); void DumpTape(struct TapeInfo *); boolean SaveTapeChecked(int);