summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2014-04-12 17:02:20 -0400
committerSimon Howard2014-04-12 17:02:20 -0400
commit67fae2be49cb9203de5b952ab8b17a37db800c15 (patch)
tree2c4c32882800c07d788a25b5609c9536488619b0
parentdf5be3d8c12bda4f22a8500240765fefe5ccf21c (diff)
downloadchocolate-doom-67fae2be49cb9203de5b952ab8b17a37db800c15.tar.gz
chocolate-doom-67fae2be49cb9203de5b952ab8b17a37db800c15.tar.bz2
chocolate-doom-67fae2be49cb9203de5b952ab8b17a37db800c15.zip
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.
-rw-r--r--src/net_gui.c45
1 files changed, 45 insertions, 0 deletions
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 <n>
+ // @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();