From 014f8db5b98964dddaf817ce5cd8cf7930bc7ae4 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 1 Jun 2018 19:03:58 +0200 Subject: [PATCH] added setup option to enable network multi-player games This is a work-in-progress change: The new setup option to enable network mode just sets the same flag as using the command-line option "--network" (without specifying a hostname or a port). For local network games, and if UDP broadcasting works as it should to auto-detect a local network server that is already running, this is already sufficient to play network multi-player games. What's still missing is a way to explicitly specify a network server to also be able to play network games with hosts outside of the local network (or if UDP broadcasting does not work correctly). --- src/files.c | 6 +++++- src/init.c | 3 +++ src/libgame/system.h | 2 ++ src/screens.c | 6 ++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/files.c b/src/files.c index ac75c2af..2ce77889 100644 --- a/src/files.c +++ b/src/files.c @@ -8312,8 +8312,9 @@ void SaveScore(int nr) #define SETUP_TOKEN_TOUCH_GRID_YSIZE_0 48 #define SETUP_TOKEN_TOUCH_GRID_XSIZE_1 49 #define SETUP_TOKEN_TOUCH_GRID_YSIZE_1 50 +#define SETUP_TOKEN_NETWORK_MODE 51 -#define NUM_GLOBAL_SETUP_TOKENS 51 +#define NUM_GLOBAL_SETUP_TOKENS 52 /* auto setup */ #define SETUP_TOKEN_AUTO_EDITOR_ZOOM_TILESIZE 0 @@ -8521,6 +8522,7 @@ static struct TokenInfo global_setup_tokens[] = { TYPE_INTEGER,&si.touch.grid_ysize[0], "touch.virtual_buttons.0.ysize" }, { TYPE_INTEGER,&si.touch.grid_xsize[1], "touch.virtual_buttons.1.xsize" }, { TYPE_INTEGER,&si.touch.grid_ysize[1], "touch.virtual_buttons.1.ysize" }, + { TYPE_SWITCH, &si.network_mode, "network_mode" }, }; static struct TokenInfo auto_setup_tokens[] = @@ -8787,6 +8789,8 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->touch.grid_initialized = video.initialized; + si->network_mode = FALSE; + si->editor.el_boulderdash = TRUE; si->editor.el_emerald_mine = TRUE; si->editor.el_emerald_mine_club = TRUE; diff --git a/src/init.c b/src/init.c index b32141fb..8fb9f80d 100644 --- a/src/init.c +++ b/src/init.c @@ -5611,6 +5611,9 @@ void InitNetworkServer() int nr_wanted; #endif + if (setup.network_mode) + options.network = TRUE; + if (!options.network) return; diff --git a/src/libgame/system.h b/src/libgame/system.h index 1b2b079b..bc294f22 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1272,6 +1272,8 @@ struct SetupInfo int volume_loops; int volume_music; + boolean network_mode; + struct SetupAutoSetupInfo auto_setup; struct SetupEditorInfo editor; struct SetupEditorCascadeInfo editor_cascade; diff --git a/src/screens.c b/src/screens.c index 200f725c..1346c218 100644 --- a/src/screens.c +++ b/src/screens.c @@ -5879,6 +5879,7 @@ static struct TokenInfo setup_info_main[] = static struct TokenInfo setup_info_game[] = { { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" }, + { TYPE_SWITCH, &setup.network_mode, "Network Multi-Player Mode:" }, { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" }, { TYPE_SWITCH, &setup.time_limit, "Time Limit:" }, { TYPE_SWITCH, &setup.handicap, "Handicap:" }, @@ -6411,6 +6412,11 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx) // fullscreen state may have changed at this point if (si->value == &setup.fullscreen) ToggleFullscreenOrChangeWindowScalingIfNeeded(); + + if (si->value == &setup.network_mode && + setup.network_mode && + !options.network) + Request("Please restart game to enable network games!", REQ_CONFIRM); } static struct TokenInfo *getSetupInfoFinal(struct TokenInfo *setup_info_orig) -- 2.34.1