summaryrefslogtreecommitdiff
path: root/src/net_client.c
diff options
context:
space:
mode:
authorSimon Howard2006-01-02 21:50:26 +0000
committerSimon Howard2006-01-02 21:50:26 +0000
commitfba617a6b4504c9a21f2a7f0749570f741fa8254 (patch)
tree9ffe6a0417179fac55ff4068b9a0b3abbce88ba0 /src/net_client.c
parentdd2339bca5ee57aaee232061a4015cf30454e42e (diff)
downloadchocolate-doom-fba617a6b4504c9a21f2a7f0749570f741fa8254.tar.gz
chocolate-doom-fba617a6b4504c9a21f2a7f0749570f741fa8254.tar.bz2
chocolate-doom-fba617a6b4504c9a21f2a7f0749570f741fa8254.zip
Restructure the waiting screen code. Establish our own separate event
loop while waiting for the game to start, to avoid affecting the original code too much. Move some _gui variables to net_client.c. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 252
Diffstat (limited to 'src/net_client.c')
-rw-r--r--src/net_client.c54
1 files changed, 39 insertions, 15 deletions
diff --git a/src/net_client.c b/src/net_client.c
index 4e9b42f3..fc3082fa 100644
--- a/src/net_client.c
+++ b/src/net_client.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: net_client.c 246 2006-01-02 20:14:07Z fraggle $
+// $Id: net_client.c 252 2006-01-02 21:50:26Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -21,6 +21,11 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.8 2006/01/02 21:50:26 fraggle
+// Restructure the waiting screen code. Establish our own separate event
+// loop while waiting for the game to start, to avoid affecting the original
+// code too much. Move some _gui variables to net_client.c.
+//
// Revision 1.7 2006/01/02 20:14:07 fraggle
// Fix connect timeout and shutdown client properly if we fail to connect.
//
@@ -83,13 +88,38 @@ typedef enum
CLIENT_STATE_DISCONNECTED,
} net_clientstate_t;
-static boolean client_initialised = false;
-
static net_clientstate_t client_state;
static net_addr_t *server_addr;
static net_context_t *client_context;
static int last_send_time;
+// if TRUE, we are connected to a server
+
+boolean net_client_connected = false;
+
+// if TRUE, this client is the controller of the game
+
+boolean net_client_controller = false;
+
+// Number of clients currently connected to the server
+
+int net_clients_in_game;
+
+// Waiting for the game to start?
+
+boolean net_waiting_for_start = false;
+
+// Shut down the client code, etc. Invoked after a disconnect.
+
+static void NET_CL_Shutdown(void)
+{
+ net_client_connected = false;
+
+ NET_FreeAddress(server_addr);
+
+ // Shut down network module, etc. To do.
+}
+
// data received while we are waiting for the game to start
static void NET_CL_ParseWaitingData(net_packet_t *packet)
@@ -154,6 +184,8 @@ static void NET_CL_ParseDisconnect(net_packet_t *packet)
fprintf(stderr, "Disconnected from server.\n");
// Now what?
+
+ NET_CL_Disconnect();
}
// parse a DISCONNECT_ACK packet
@@ -283,7 +315,7 @@ void NET_CL_Run(void)
net_addr_t *addr;
net_packet_t *packet;
- if (!client_initialised)
+ if (!net_client_connected)
{
return;
}
@@ -315,15 +347,6 @@ void NET_CL_Run(void)
}
}
-static void NET_CL_Shutdown(void)
-{
- client_initialised = false;
-
- NET_FreeAddress(server_addr);
-
- // Shut down network module, etc. To do.
-}
-
// connect to a server
boolean NET_CL_Connect(net_addr_t *addr)
@@ -346,7 +369,8 @@ boolean NET_CL_Connect(net_addr_t *addr)
NET_AddModule(client_context, addr->module);
- client_initialised = true;
+ net_client_connected = true;
+ net_waiting_for_start = true;
// try to connect
@@ -400,7 +424,7 @@ void NET_CL_Disconnect(void)
{
int start_time;
- if (!client_initialised)
+ if (!net_client_connected)
{
return;
}