From: Holger Schemel Date: Mon, 3 May 2021 10:50:11 +0000 (+0200) Subject: added runtime flag to store if high score server is available X-Git-Tag: 4.3.0.0~163 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=e25161c4cc2371ce2ace1d9aae03f8539074af3c;p=rocksndiamonds.git added runtime flag to store if high score server is available --- diff --git a/src/files.c b/src/files.c index 38b19f83..d5118422 100644 --- a/src/files.c +++ b/src/files.c @@ -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); diff --git a/src/libgame/http.c b/src/libgame/http.c index 30f4c03a..592aeb17 100644 --- a/src/libgame/http.c +++ b/src/libgame/http.c @@ -290,5 +290,7 @@ boolean DoHttpRequest(struct HttpRequest *request, checked_free(send_buffer); checked_free(recv_buffer); + runtime.api_server = success; + return success; } diff --git a/src/libgame/system.c b/src/libgame/system.c index 3d23f5fa..edae9c60 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -127,6 +127,8 @@ void InitRuntimeInfo() #else runtime.uses_touch_device = FALSE; #endif + + runtime.api_server = setup.api_server; } void InitScoresInfo(void) diff --git a/src/libgame/system.h b/src/libgame/system.h index 4d738a10..94ebe7a5 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1039,6 +1039,8 @@ struct NetworkInfo struct RuntimeInfo { boolean uses_touch_device; + + boolean api_server; }; struct OptionInfo diff --git a/src/screens.c b/src/screens.c index cb3ada37..2f3ff410 100644 --- a/src/screens.c +++ b/src/screens.c @@ -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();