diff options
author | Simon Howard | 2006-10-14 13:26:17 +0000 |
---|---|---|
committer | Simon Howard | 2006-10-14 13:26:17 +0000 |
commit | df4cb5af90a67d02c2e64b02462d39edfadf469f (patch) | |
tree | 16a026606d169b3fa03616a57d1d89bbf2ce9792 | |
parent | 2561fee6091fec2248a102e951cc108f3e2ea4b7 (diff) | |
download | chocolate-doom-df4cb5af90a67d02c2e64b02462d39edfadf469f.tar.gz chocolate-doom-df4cb5af90a67d02c2e64b02462d39edfadf469f.tar.bz2 chocolate-doom-df4cb5af90a67d02c2e64b02462d39edfadf469f.zip |
Display drone indicator on the netgame waiting screen if drones are connected.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 699
-rw-r--r-- | src/net_client.c | 11 | ||||
-rw-r--r-- | src/net_client.h | 5 | ||||
-rw-r--r-- | src/net_gui.c | 22 | ||||
-rw-r--r-- | src/net_server.c | 26 |
4 files changed, 55 insertions, 9 deletions
diff --git a/src/net_client.c b/src/net_client.c index 39272dd0..a296737f 100644 --- a/src/net_client.c +++ b/src/net_client.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_client.c 698 2006-10-14 12:55:02Z fraggle $ +// $Id: net_client.c 699 2006-10-14 13:26:17Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -237,7 +237,11 @@ boolean net_client_controller = false; // Number of clients currently connected to the server -int net_clients_in_game; +unsigned int net_clients_in_game; + +// Number of drone players connected to the server + +unsigned int net_drones_in_game; // Names of all players @@ -645,6 +649,7 @@ void NET_CL_SendTiccmd(ticcmd_t *ticcmd, int maketic) static void NET_CL_ParseWaitingData(net_packet_t *packet) { unsigned int num_players; + unsigned int num_drones; unsigned int is_controller; signed int player_number; char *player_names[MAXPLAYERS]; @@ -654,6 +659,7 @@ static void NET_CL_ParseWaitingData(net_packet_t *packet) size_t i; if (!NET_ReadInt8(packet, &num_players) + || !NET_ReadInt8(packet, &num_drones) || !NET_ReadInt8(packet, &is_controller) || !NET_ReadSInt8(packet, &player_number)) { @@ -699,6 +705,7 @@ static void NET_CL_ParseWaitingData(net_packet_t *packet) } net_clients_in_game = num_players; + net_drones_in_game = num_drones; net_client_controller = is_controller != 0; net_player_number = player_number; diff --git a/src/net_client.h b/src/net_client.h index 58488db6..2f47226d 100644 --- a/src/net_client.h +++ b/src/net_client.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_client.h 698 2006-10-14 12:55:02Z fraggle $ +// $Id: net_client.h 699 2006-10-14 13:26:17Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -86,7 +86,8 @@ void NET_Init(void); extern boolean net_client_connected; extern boolean net_client_received_wait_data; extern boolean net_client_controller; -extern int net_clients_in_game; +extern unsigned int net_clients_in_game; +extern unsigned int net_drones_in_game; extern boolean net_waiting_for_start; extern char net_player_names[MAXPLAYERS][MAXPLAYERNAME]; extern char net_player_addresses[MAXPLAYERS][MAXPLAYERNAME]; diff --git a/src/net_gui.c b/src/net_gui.c index 7ef9d909..899090d0 100644 --- a/src/net_gui.c +++ b/src/net_gui.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_gui.c 698 2006-10-14 12:55:02Z fraggle $ +// $Id: net_gui.c 699 2006-10-14 13:26:17Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -93,6 +93,7 @@ static txt_window_t *window; static txt_label_t *player_labels[MAXPLAYERS]; static txt_label_t *ip_labels[MAXPLAYERS]; +static txt_label_t *drone_label; static boolean had_warning; static void EscapePressed(TXT_UNCAST_ARG(widget), void *unused) @@ -139,7 +140,9 @@ static void BuildGUI(void) TXT_AddWidget(table, ip_labels[i]); } - TXT_AddWidget(window, TXT_NewStrut(0, 1)); + drone_label = TXT_NewLabel(""); + + TXT_AddWidget(window, drone_label); cancel = TXT_NewWindowAction(KEY_ESCAPE, "Cancel"); TXT_SignalConnect(cancel, "pressed", EscapePressed, NULL); @@ -150,13 +153,14 @@ static void BuildGUI(void) static void UpdateGUI(void) { txt_window_action_t *startgame; - int i; + char buf[20]; + unsigned int i; for (i=0; i<MAXPLAYERS; ++i) { txt_color_t color = TXT_COLOR_BRIGHT_WHITE; - if (i == net_player_number) + if ((signed) i == net_player_number) { color = TXT_COLOR_YELLOW; } @@ -176,6 +180,16 @@ static void UpdateGUI(void) } } + if (net_drones_in_game > 0) + { + sprintf(buf, " (+%i observer clients)", net_drones_in_game); + TXT_SetLabel(drone_label, buf); + } + else + { + TXT_SetLabel(drone_label, ""); + } + if (net_client_controller) { startgame = TXT_NewWindowAction(' ', "Start game"); diff --git a/src/net_server.c b/src/net_server.c index 9223588c..b5cc5675 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_server.c 698 2006-10-14 12:55:02Z fraggle $ +// $Id: net_server.c 699 2006-10-14 13:26:17Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -380,6 +380,26 @@ static int NET_SV_NumPlayers(void) return result; } +// Returns the number of drones currently connected. + +static int NET_SV_NumDrones(void) +{ + int i; + int result; + + result = 0; + + for (i=0; i<MAXNETNODES; ++i) + { + if (ClientConnected(&clients[i]) && clients[i].drone) + { + result += 1; + } + } + + return result; +} + // returns the number of clients connected static int NET_SV_NumClients(void) @@ -1299,6 +1319,10 @@ static void NET_SV_SendWaitingData(net_client_t *client) NET_WriteInt8(packet, num_players); + // send the number of drone clients + + NET_WriteInt8(packet, NET_SV_NumDrones()); + // indicate whether the client is the controller NET_WriteInt8(packet, client == controller); |