added setup option to enable or disable using high score server
authorHolger Schemel <info@artsoft.org>
Sun, 2 May 2021 17:04:34 +0000 (19:04 +0200)
committerHolger Schemel <info@artsoft.org>
Sun, 2 May 2021 17:04:34 +0000 (19:04 +0200)
src/files.c
src/libgame/system.h
src/screens.c

index 4e281d03aec9229a8d2863370692d04bd05d22bb..38b19f83c58c1429a246a833fef20bcdac685407 100644 (file)
@@ -9084,6 +9084,9 @@ static void LoadServerScoreFromCache(int nr)
 
 void LoadServerScore(int nr, boolean download_score)
 {
+  if (!setup.api_server)
+    return;
+
   // always start with reliable default values
   setServerScoreInfoToDefaults();
 
@@ -9250,6 +9253,9 @@ static void UploadScoreToServerAsThread(int nr)
 
 void SaveServerScore(int nr)
 {
+  if (!setup.api_server)
+    return;
+
   UploadScoreToServerAsThread(nr);
 }
 
@@ -9262,9 +9268,14 @@ void LoadLocalAndServerScore(int nr, boolean download_score)
   // restore last added local score entry (before merging server scores)
   scores.last_added = scores.last_added_local = last_added_local;
 
-  LoadServerScore(nr, download_score);
+  if (setup.api_server)
+  {
+    // load server scores from cache file and trigger update from server
+    LoadServerScore(nr, download_score);
 
-  MergeServerScore();
+    // merge local scores with scores from server
+    MergeServerScore();
+  }
 }
 
 
@@ -9501,6 +9512,14 @@ static struct TokenInfo global_setup_tokens[] =
     TYPE_STRING,
     &setup.network_server_hostname,            "network_server_hostname"
   },
+  {
+    TYPE_SWITCH,
+    &setup.api_server,                         "api_server"
+  },
+  {
+    TYPE_STRING,
+    &setup.api_server_hostname,                        "api_server_hostname"
+  },
   {
     TYPE_STRING,
     &setup.touch.control_type,                 "touch.control_type"
@@ -10134,6 +10153,9 @@ static void setSetupInfoToDefaults(struct SetupInfo *si)
   si->network_player_nr = 0;           // first player
   si->network_server_hostname = getStringCopy(STR_NETWORK_AUTO_DETECT);
 
+  si->api_server = TRUE;
+  si->api_server_hostname = getStringCopy(API_SERVER_HOSTNAME);
+
   si->touch.control_type = getStringCopy(TOUCH_CONTROL_DEFAULT);
   si->touch.move_distance = TOUCH_MOVE_DISTANCE_DEFAULT;       // percent
   si->touch.drop_distance = TOUCH_DROP_DISTANCE_DEFAULT;       // percent
@@ -10749,6 +10771,7 @@ void SaveSetup(void)
        global_setup_tokens[i].value == &setup.graphics_set             ||
        global_setup_tokens[i].value == &setup.volume_simple            ||
        global_setup_tokens[i].value == &setup.network_mode             ||
+       global_setup_tokens[i].value == &setup.api_server               ||
        global_setup_tokens[i].value == &setup.touch.control_type       ||
        global_setup_tokens[i].value == &setup.touch.grid_xsize[0]      ||
        global_setup_tokens[i].value == &setup.touch.grid_xsize[1])
index 796db13e1450291c5bf079b80ff994ecf6fa318d..4d738a10f98fc69ddb2c844233954b7d7b54ffb3 100644 (file)
@@ -1496,6 +1496,9 @@ struct SetupInfo
   int network_player_nr;
   char *network_server_hostname;
 
+  boolean api_server;
+  char *api_server_hostname;
+
   struct SetupAutoSetupInfo auto_setup;
   struct SetupLevelSetupInfo level_setup;
 
index 4fb4e148fbdc2e54621aeb3045d23f35defbe255..cb3ada371284778f4cf0b087a0594e41bf81128b 100644 (file)
@@ -6756,6 +6756,7 @@ static struct TokenInfo setup_info_game[] =
   { TYPE_PLAYER,       &setup.network_player_nr,"Preferred Network Player:" },
   { TYPE_TEXT_INPUT,   execGadgetNetworkServer, "Network Server Hostname:" },
   { TYPE_STRING,       &network_server_text,   ""                      },
+  { TYPE_SWITCH,       &setup.api_server,      "Use Highscore Server:" },
   { TYPE_SWITCH,       &setup.multiple_users,  "Multiple Users/Teams:" },
   { TYPE_YES_NO,       &setup.input_on_focus,  "Only Move Focussed Player:" },
   { TYPE_SWITCH,       &setup.time_limit,      "Time Limit:"           },