diff options
author | Simon Howard | 2006-01-09 02:03:39 +0000 |
---|---|---|
committer | Simon Howard | 2006-01-09 02:03:39 +0000 |
commit | fc969e4981a2365304f88e664d625c3a07d57bee (patch) | |
tree | 6f4f6a4e7aa35f03ddf432dc8a876909213358f8 /src/net_server.c | |
parent | 65c8df250f0a138e22ad70c6ac1c6bf53cfa3ad7 (diff) | |
download | chocolate-doom-fc969e4981a2365304f88e664d625c3a07d57bee.tar.gz chocolate-doom-fc969e4981a2365304f88e664d625c3a07d57bee.tar.bz2 chocolate-doom-fc969e4981a2365304f88e664d625c3a07d57bee.zip |
Send clients their player number, and indicate on the waiting screen
which client we are.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 278
Diffstat (limited to 'src/net_server.c')
-rw-r--r-- | src/net_server.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/net_server.c b/src/net_server.c index 070d6b6b..4ed2e2b3 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_server.c 277 2006-01-09 01:50:51Z fraggle $ +// $Id: net_server.c 278 2006-01-09 02:03:39Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -21,6 +21,10 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.18 2006/01/09 02:03:39 fraggle +// Send clients their player number, and indicate on the waiting screen +// which client we are. +// // Revision 1.17 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 @@ -168,6 +172,31 @@ static int NET_SV_NumClients(void) return count; } +// Returns the index of a particular client in the list of connected +// clients. + +static int NET_SV_ClientIndex(net_client_t *client) +{ + int count; + int i; + + count = 0; + + for (i=0; i<MAXNETNODES; ++i) + { + if (ClientConnected(&clients[i])) + { + if (client == &clients[i]) + { + return count; + } + ++count; + } + } + + return -1; +} + // returns a pointer to the client which controls the server static net_client_t *NET_SV_Controller(void) @@ -429,6 +458,10 @@ static void NET_SV_SendWaitingData(net_client_t *client) NET_WriteInt8(packet, NET_SV_Controller() == client); + // send the index of the client + + NET_WriteInt8(packet, NET_SV_ClientIndex(client)); + // send the address of all players for (i=0; i<num_clients; ++i) |