added storing score tapes from score server in cache directory 4.3.2.0
authorHolger Schemel <info@artsoft.org>
Sat, 16 Apr 2022 23:11:28 +0000 (01:11 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 16 Apr 2022 23:21:41 +0000 (01:21 +0200)
src/api.c
src/tape.c

index f2679fa1ae91cc87f798c127a22d4ea8f1039e15..3e2b387e88ea483dfd600fe294bcdbf3e7c984b4 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -651,7 +651,7 @@ static void *CreateThreadData_ApiGetScoreTape(int nr, int id,
 {
   struct ApiGetScoreTapeThreadData *data =
     checked_malloc(sizeof(struct ApiGetScoreTapeThreadData));
-  char *score_tape_filename = getScoreTapeFilename(score_tape_basename, nr);
+  char *score_tape_filename = getScoreCacheTapeFilename(score_tape_basename, nr);
 
   data->level_nr = nr;
   data->score_id = id;
@@ -716,7 +716,7 @@ static void HandleResponse_ApiGetScoreTape(struct HttpResponse *response,
   int i;
 
   // used instead of "leveldir_current->subdir" (for network games)
-  InitScoreTapeDirectory(levelset.identifier, level_nr);
+  InitScoreCacheTapeDirectory(levelset.identifier, level_nr);
 
   if (!(file = fopen(filename, MODE_WRITE)))
   {
index 5033507342b4f8029d893737555ce8ccf5972cab..cd07263f007f2e4842c1395e13a5c17f6d6adecf 100644 (file)
@@ -1402,7 +1402,10 @@ static boolean PlayScoreTape_WaitForDownload(void)
 boolean PlayScoreTape(int entry_nr)
 {
   struct ScoreEntry *entry = &scores.entry[entry_nr];
-  char *tape_filename = getScoreTapeFilename(entry->tape_basename, level_nr);
+  char *tape_filename =
+    (entry->id == -1 ?
+     getScoreTapeFilename(entry->tape_basename, level_nr) :
+     getScoreCacheTapeFilename(entry->tape_basename, level_nr));
   boolean download_tape = (!fileExists(tape_filename));
 
   if (download_tape && entry->id == -1)
@@ -1439,7 +1442,10 @@ boolean PlayScoreTape(int entry_nr)
   // if tape recorder already contains a tape, remove it without asking
   TapeErase();
 
-  LoadScoreTape(entry->tape_basename, level_nr);
+  if (entry->id == -1)
+    LoadScoreTape(entry->tape_basename, level_nr);
+  else
+    LoadScoreCacheTape(entry->tape_basename, level_nr);
 
   if (TAPE_IS_EMPTY(tape))
   {