ref: df4cb5af90a67d02c2e64b02462d39edfadf469f
parent: 2561fee6091fec2248a102e951cc108f3e2ea4b7
author: Simon Howard <[email protected]>
date: Sat Oct 14 09:26:17 EDT 2006
Display drone indicator on the netgame waiting screen if drones are connected. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 699
--- 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,8 +237,12 @@
// 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
char net_player_addresses[MAXPLAYERS][MAXPLAYERNAME];
@@ -645,6 +649,7 @@
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 @@
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 @@
}
net_clients_in_game = num_players;
+ net_drones_in_game = num_drones;
net_client_controller = is_controller != 0;
net_player_number = player_number;
--- 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 @@
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];
--- 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,8 +140,10 @@
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 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;
}
@@ -174,6 +178,16 @@
TXT_SetLabel(player_labels[i], "");
TXT_SetLabel(ip_labels[i], "");
}
+ }
+
+ 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)
--- 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 @@
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)
@@ -1298,6 +1318,10 @@
// include the number of players waiting
NET_WriteInt8(packet, num_players);
+
+ // send the number of drone clients
+
+ NET_WriteInt8(packet, NET_SV_NumDrones());
// indicate whether the client is the controller