From: Holger Schemel Date: Sun, 2 May 2021 17:04:34 +0000 (+0200) Subject: added setup option to enable or disable using high score server X-Git-Tag: 4.3.0.0~164 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=03a51cffeae04186383ded4280b3ebb923cdbc6f;p=rocksndiamonds.git added setup option to enable or disable using high score server --- diff --git a/src/files.c b/src/files.c index 4e281d03..38b19f83 100644 --- a/src/files.c +++ b/src/files.c @@ -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]) diff --git a/src/libgame/system.h b/src/libgame/system.h index 796db13e..4d738a10 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -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; diff --git a/src/screens.c b/src/screens.c index 4fb4e148..cb3ada37 100644 --- a/src/screens.c +++ b/src/screens.c @@ -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:" },