From: Holger Schemel Date: Tue, 26 Jun 2018 22:02:22 +0000 (+0200) Subject: added disconnecting from network server from setup menu X-Git-Tag: 4.1.1.0~99 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=41165ff0a84cf7c0391f6b56520a1f7f97ccf496;p=rocksndiamonds.git added disconnecting from network server from setup menu --- diff --git a/src/netserv.c b/src/netserv.c index 4fd84610..963a862b 100644 --- a/src/netserv.c +++ b/src/netserv.c @@ -129,6 +129,7 @@ static void RemovePlayer(struct NetworkServerPlayerInfo *player) free(player); clients--; +#if 0 /* do not terminate network server if last player disconnected */ if (onceonly && clients == 0) { if (options.verbose) @@ -138,6 +139,7 @@ static void RemovePlayer(struct NetworkServerPlayerInfo *player) } exit(0); } +#endif } static void AddPlayer(TCPsocket fd) diff --git a/src/network.c b/src/network.c index 5f35825a..e21de8c5 100644 --- a/src/network.c +++ b/src/network.c @@ -809,3 +809,16 @@ void HandleNetworking() } } } + +void DisconnectFromNetworkServer() +{ + DrawNetworkText_Title("Terminating Network"); + DrawNetworkText("Disconnecting from network server ..."); + + HandleNetworkingDisconnect(); + + DrawNetworkText_Success("Successfully disconnected!"); + + /* short time to recognize result of network initialization */ + Delay(1000); +} diff --git a/src/network.h b/src/network.h index 23b33077..fbbea6db 100644 --- a/src/network.h +++ b/src/network.h @@ -27,5 +27,6 @@ void SendToServer_ContinuePlaying(void); void SendToServer_StopPlaying(int); void SendToServer_MovePlayer(byte); void HandleNetworking(void); +void DisconnectFromNetworkServer(void); #endif diff --git a/src/screens.c b/src/screens.c index 54e27e31..3ffcb484 100644 --- a/src/screens.c +++ b/src/screens.c @@ -6445,10 +6445,9 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx) ToggleFullscreenOrChangeWindowScalingIfNeeded(); if (si->value == &setup.network_mode && - setup.network_mode && - !network.enabled) + setup.network_mode != network.enabled) { - network.enabled = TRUE; + network.enabled = setup.network_mode; SetGameStatus(GAME_MODE_LOADING); SetDrawBackgroundMask(REDRAW_NONE); @@ -6459,7 +6458,10 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx) FadeIn(REDRAW_ALL); - InitNetworkServer(); + if (network.enabled) + InitNetworkServer(); + else + DisconnectFromNetworkServer(); SetGameStatus(GAME_MODE_SETUP); SetDrawBackgroundMask(REDRAW_FIELD);