From: Holger Schemel Date: Mon, 1 Oct 2018 19:22:42 +0000 (+0200) Subject: moved starting or stopping network mode to separate function X-Git-Tag: 4.1.1.0~17 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=15166fddf78bff71ddec88fb3e4dda9424953403;p=rocksndiamonds.git moved starting or stopping network mode to separate function --- diff --git a/src/screens.c b/src/screens.c index 7771f24e..6dd964f3 100644 --- a/src/screens.c +++ b/src/screens.c @@ -5951,6 +5951,27 @@ static void execGadgetNetworkServer(void) ClickOnGadget(gi, MB_LEFTBUTTON); } +static void ToggleNetworkModeIfNeeded(void) +{ + if (setup.network_mode == network.enabled) + return; + + network.enabled = setup.network_mode; + + FadeOut(REDRAW_ALL); + + ClearField(); + + FadeIn(REDRAW_ALL); + + if (network.enabled) + InitNetworkServer(); + else + DisconnectFromNetworkServer(); + + DrawSetupScreen(); +} + static struct { void *value; @@ -6621,24 +6642,9 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx) if (si->value == &setup.fullscreen) ToggleFullscreenOrChangeWindowScalingIfNeeded(); - if (si->value == &setup.network_mode && - setup.network_mode != network.enabled) - { - network.enabled = setup.network_mode; - - FadeOut(REDRAW_ALL); - - ClearField(); - - FadeIn(REDRAW_ALL); - - if (network.enabled) - InitNetworkServer(); - else - DisconnectFromNetworkServer(); - - DrawSetupScreen(); - } + // network mode may have changed at this point + if (si->value == &setup.network_mode) + ToggleNetworkModeIfNeeded(); } static struct TokenInfo *getSetupInfoFinal(struct TokenInfo *setup_info_orig)