From 67fae2be49cb9203de5b952ab8b17a37db800c15 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 12 Apr 2014 17:02:20 -0400 Subject: net: Add -nodes command line argument. This matches the -nodes parameter that ipxsetup has; interpret it as an "auto-start" parameter that launches the game when the intended number of clients have joined the server. --- src/net_gui.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/net_gui.c b/src/net_gui.c index 80c606b1..477b466e 100644 --- a/src/net_gui.c +++ b/src/net_gui.c @@ -34,6 +34,7 @@ #include "i_system.h" #include "i_timer.h" #include "i_video.h" +#include "m_argv.h" #include "m_misc.h" #include "net_client.h" @@ -51,6 +52,11 @@ static txt_label_t *drone_label; static txt_label_t *master_msg_label; static boolean had_warning; +// Number of players we expect to be in the game. When the number is +// reached, we auto-start the game (if we're the controller). If +// zero, do not autostart. +static int expected_nodes; + static void EscapePressed(TXT_UNCAST_ARG(widget), void *unused) { TXT_Shutdown(); @@ -343,6 +349,43 @@ static void CheckSHA1Sums(void) had_warning = true; } +static void ParseCommandLineArgs(void) +{ + int i; + + //! + // @arg + // @category net + // + // Autostart the netgame when n nodes (clients) have joined the server. + // + + i = M_CheckParmWithArgs("-nodes", 1); + if (i > 0) + { + expected_nodes = atoi(myargv[i + 1]); + } +} + +static void CheckAutoLaunch(void) +{ + int nodes; + + if (net_client_received_wait_data + && net_client_wait_data.is_controller + && expected_nodes > 0) + { + nodes = net_client_wait_data.num_players + + net_client_wait_data.num_drones; + + if (nodes >= expected_nodes) + { + StartGame(NULL, NULL); + expected_nodes = 0; + } + } +} + void NET_WaitForLaunch(void) { if (!TXT_Init()) @@ -353,12 +396,14 @@ void NET_WaitForLaunch(void) I_InitWindowIcon(); + ParseCommandLineArgs(); OpenWaitDialog(); had_warning = false; while (net_waiting_for_launch) { UpdateGUI(); + CheckAutoLaunch(); CheckSHA1Sums(); CheckMasterStatus(); -- cgit v1.2.3