summaryrefslogtreecommitdiff
path: root/src/net_client.c
diff options
context:
space:
mode:
authorSimon Howard2013-04-02 20:44:26 +0000
committerSimon Howard2013-04-02 20:44:26 +0000
commit48b1728d9145baf1912aa6566d8e64abea65f83b (patch)
treeeffa7b76b8b8ecd10f8faaa96d8cc744398df839 /src/net_client.c
parent609e5d2928561b35fc16749e063dbfd61c9a17e1 (diff)
downloadchocolate-doom-48b1728d9145baf1912aa6566d8e64abea65f83b.tar.gz
chocolate-doom-48b1728d9145baf1912aa6566d8e64abea65f83b.tar.bz2
chocolate-doom-48b1728d9145baf1912aa6566d8e64abea65f83b.zip
Split game start sequence into two-stage process. This is the first
stage in refactoring the way that network startup works. Subversion-branch: /branches/v2-branch Subversion-revision: 2580
Diffstat (limited to 'src/net_client.c')
-rw-r--r--src/net_client.c52
1 files changed, 38 insertions, 14 deletions
diff --git a/src/net_client.c b/src/net_client.c
index 43e28441..f258eb44 100644
--- a/src/net_client.c
+++ b/src/net_client.c
@@ -51,6 +51,10 @@ extern void D_ReceiveTic(ticcmd_t *ticcmds, boolean *playeringame);
typedef enum
{
+ // waiting for the game to launch
+
+ CLIENT_STATE_WAITING_LAUNCH,
+
// waiting for the game to start
CLIENT_STATE_WAITING_START,
@@ -73,10 +77,10 @@ typedef struct
unsigned int resend_time;
- // Tic data from server
+ // Tic data from server
net_full_ticcmd_t cmd;
-
+
} net_server_recv_t;
// Type of structure used in the send window
@@ -115,15 +119,15 @@ static net_gamesettings_t settings;
boolean net_client_connected;
-// true if we have received waiting data from the server
+// true if we have received waiting data from the server,
+// and the wait data that was received.
boolean net_client_received_wait_data;
-
net_waitdata_t net_client_wait_data;
-// Waiting for the game to start?
+// Waiting at the initial wait screen for the game to be launched?
-boolean net_waiting_for_start = false;
+boolean net_waiting_for_launch = false;
// Name that we send to the server
@@ -306,6 +310,11 @@ static void NET_CL_Shutdown(void)
}
}
+void NET_CL_LaunchGame(void)
+{
+ NET_Conn_NewReliable(&client_connection, NET_PACKET_TYPE_LAUNCH);
+}
+
void NET_CL_StartGame(net_gamesettings_t *settings)
{
net_packet_t *packet;
@@ -457,6 +466,16 @@ static void NET_CL_ParseWaitingData(net_packet_t *packet)
net_client_received_wait_data = true;
}
+static void NET_CL_ParseLaunch(net_packet_t *packet)
+{
+ if (client_state != CLIENT_STATE_WAITING_LAUNCH)
+ {
+ return;
+ }
+
+ client_state = CLIENT_STATE_WAITING_START;
+}
+
static void NET_CL_ParseGameStart(net_packet_t *packet)
{
if (!NET_ReadSettings(packet, &settings))
@@ -805,6 +824,10 @@ static void NET_CL_ParsePacket(net_packet_t *packet)
NET_CL_ParseWaitingData(packet);
break;
+ case NET_PACKET_TYPE_LAUNCH:
+ NET_CL_ParseLaunch(packet);
+ break;
+
case NET_PACKET_TYPE_GAMESTART:
NET_CL_ParseGameStart(packet);
break;
@@ -864,12 +887,13 @@ void NET_CL_Run(void)
|| client_connection.state == NET_CONN_STATE_DISCONNECTED_SLEEP)
{
NET_CL_Disconnected();
-
+
NET_CL_Shutdown();
}
-
- net_waiting_for_start = client_connection.state == NET_CONN_STATE_CONNECTED
- && client_state == CLIENT_STATE_WAITING_START;
+
+ net_waiting_for_launch =
+ client_connection.state == NET_CONN_STATE_CONNECTED
+ && client_state == CLIENT_STATE_WAITING_LAUNCH;
if (client_state == CLIENT_STATE_IN_GAME)
{
@@ -932,7 +956,7 @@ boolean NET_CL_Connect(net_addr_t *addr, net_connect_data_t *data)
NET_Conn_InitClient(&client_connection, addr);
// try to connect
-
+
start_time = I_GetTimeMS();
last_send_time = -1;
@@ -947,8 +971,8 @@ boolean NET_CL_Connect(net_addr_t *addr, net_connect_data_t *data)
NET_CL_SendSYN(data);
last_send_time = nowtime;
}
-
- // time out after 5 seconds
+
+ // time out after 5 seconds
if (nowtime - start_time > 5000)
{
@@ -973,7 +997,7 @@ boolean NET_CL_Connect(net_addr_t *addr, net_connect_data_t *data)
{
// connected ok!
- client_state = CLIENT_STATE_WAITING_START;
+ client_state = CLIENT_STATE_WAITING_LAUNCH;
drone = data->drone;
return true;