added saving non-standard solution tape to temporary file before uploading
authorHolger Schemel <info@artsoft.org>
Mon, 23 Aug 2021 10:25:57 +0000 (12:25 +0200)
committerHolger Schemel <info@artsoft.org>
Mon, 23 Aug 2021 10:25:57 +0000 (12:25 +0200)
src/tape.c

index 3d6774dd95390f6ca92f930bfbd64f8935311978..21a5945bc92b0519016e7029547ca96f8d5187d2 100644 (file)
@@ -1629,18 +1629,35 @@ void AutoPlayTapes(void)
 
     if (global.autoplay_mode == AUTOPLAY_MODE_UPLOAD)
     {
+      boolean use_temporary_tape_file = FALSE;
+
       Print("Tape %03d:\n", level_nr);
 
       AutoPlayTapes_SetScoreEntry(0, 0);
 
       if (tape_filename == NULL)
+      {
        tape_filename = (options.mytapes ? getTapeFilename(level_nr) :
-                        getSolutionTapeFilename(level_nr));
+                        getDefaultSolutionTapeFilename(level_nr));
+
+       if (!fileExists(tape_filename))
+       {
+         // non-standard solution tape -- save to temporary file
+         tape_filename = getTemporaryTapeFilename();
+
+         SaveTapeToFilename(tape_filename);
+
+         use_temporary_tape_file = TRUE;
+       }
+      }
 
       SaveServerScoreFromFile(level_nr, tape_filename);
 
       AutoPlayTapes_WaitForUpload();
 
+      if (use_temporary_tape_file)
+        unlink(tape_filename);
+
       // required for uploading multiple tapes
       tape_filename = NULL;