added runtime flag to store if high score server is available
authorHolger Schemel <info@artsoft.org>
Mon, 3 May 2021 10:50:11 +0000 (12:50 +0200)
committerHolger Schemel <info@artsoft.org>
Mon, 3 May 2021 10:50:11 +0000 (12:50 +0200)
src/files.c
src/libgame/http.c
src/libgame/system.c
src/libgame/system.h
src/screens.c

index 38b19f83c58c1429a246a833fef20bcdac685407..d5118422d940e2021debdd88ac70a7793830aaf3 100644 (file)
@@ -9094,7 +9094,7 @@ void LoadServerScore(int nr, boolean download_score)
   // (this should prevent reading it while the thread is writing to it)
   LoadServerScoreFromCache(nr);
 
-  if (download_score)
+  if (download_score && runtime.api_server)
   {
     // 2nd step: download server scores from score server to cache file
     // (as thread, as it might time out if the server is not reachable)
@@ -9253,7 +9253,7 @@ static void UploadScoreToServerAsThread(int nr)
 
 void SaveServerScore(int nr)
 {
-  if (!setup.api_server)
+  if (!runtime.api_server)
     return;
 
   UploadScoreToServerAsThread(nr);
index 30f4c03a572aa7be5e4d043b31df6c4b4f592690..592aeb17c0a4220a7688527a0a01293ae92e93b5 100644 (file)
@@ -290,5 +290,7 @@ boolean DoHttpRequest(struct HttpRequest *request,
   checked_free(send_buffer);
   checked_free(recv_buffer);
 
+  runtime.api_server = success;
+
   return success;
 }
index 3d23f5fad085a43384e3f091935e9f89d89ef266..edae9c60944407647aa230587271253dba7938fd 100644 (file)
@@ -127,6 +127,8 @@ void InitRuntimeInfo()
 #else
   runtime.uses_touch_device = FALSE;
 #endif
+
+  runtime.api_server = setup.api_server;
 }
 
 void InitScoresInfo(void)
index 4d738a10f98fc69ddb2c844233954b7d7b54ffb3..94ebe7a561a628136ae85ec34da76a028763ef55 100644 (file)
@@ -1039,6 +1039,8 @@ struct NetworkInfo
 struct RuntimeInfo
 {
   boolean uses_touch_device;
+
+  boolean api_server;
 };
 
 struct OptionInfo
index cb3ada371284778f4cf0b087a0594e41bf81128b..2f3ff410f4818b63a661bcb5ec257fd349b7586d 100644 (file)
@@ -7358,6 +7358,10 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx)
   if (si->value == &setup.network_mode)
     ToggleNetworkModeIfNeeded();
 
+  // API server mode may have changed at this point
+  if (si->value == &setup.api_server)
+    runtime.api_server = setup.api_server;
+
   // game speed list may have changed at this point
   if (si->value == &setup.game_speed_extended)
     ToggleGameSpeedsListIfNeeded();