From fc969e4981a2365304f88e664d625c3a07d57bee Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 9 Jan 2006 02:03:39 +0000 Subject: Send clients their player number, and indicate on the waiting screen which client we are. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 278 --- src/net_client.c | 20 ++++++++++++++++---- src/net_client.h | 7 ++++++- src/net_gui.c | 14 ++++++++++++-- src/net_server.c | 35 ++++++++++++++++++++++++++++++++++- 4 files changed, 68 insertions(+), 8 deletions(-) diff --git a/src/net_client.c b/src/net_client.c index da29d86f..eae95cc9 100644 --- a/src/net_client.c +++ b/src/net_client.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_client.c 277 2006-01-09 01:50:51Z fraggle $ +// $Id: net_client.c 278 2006-01-09 02:03:39Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -21,6 +21,10 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.15 2006/01/09 02:03:39 fraggle +// Send clients their player number, and indicate on the waiting screen +// which client we are. +// // Revision 1.14 2006/01/09 01:50:51 fraggle // Deduce a sane player name by examining environment variables. Add // a "player_name" setting to chocolate-doom.cfg. Transmit the name @@ -124,6 +128,10 @@ int net_clients_in_game; char net_player_addresses[MAXPLAYERS][MAXPLAYERNAME]; char net_player_names[MAXPLAYERS][MAXPLAYERNAME]; +// Player number + +int net_player_number; + // Waiting for the game to start? boolean net_waiting_for_start = false; @@ -152,21 +160,24 @@ static void NET_CL_ParseWaitingData(net_packet_t *packet) { unsigned int num_players; unsigned int is_controller; + unsigned int player_number; char *player_names[MAXPLAYERS]; char *player_addr[MAXPLAYERS]; int i; if (!NET_ReadInt8(packet, &num_players) - || !NET_ReadInt8(packet, &is_controller)) + || !NET_ReadInt8(packet, &is_controller) + || !NET_ReadInt8(packet, &player_number)) { // invalid packet return; } - if (num_players > MAXPLAYERS) + if (num_players > MAXPLAYERS + || player_number >= num_players) { - // Invalid number of players + // insane data return; } @@ -186,6 +197,7 @@ static void NET_CL_ParseWaitingData(net_packet_t *packet) net_clients_in_game = num_players; net_client_controller = is_controller != 0; + net_player_number = player_number; for (i=0; i