diff options
author | Simon Howard | 2006-01-09 01:50:51 +0000 |
---|---|---|
committer | Simon Howard | 2006-01-09 01:50:51 +0000 |
commit | 65c8df250f0a138e22ad70c6ac1c6bf53cfa3ad7 (patch) | |
tree | c4d0036a2808708d2a7c4da7aa5584c0b49f784c /src/net_server.c | |
parent | 2d20dee9798613951023bc570104a6f80f0ef628 (diff) | |
download | chocolate-doom-65c8df250f0a138e22ad70c6ac1c6bf53cfa3ad7.tar.gz chocolate-doom-65c8df250f0a138e22ad70c6ac1c6bf53cfa3ad7.tar.bz2 chocolate-doom-65c8df250f0a138e22ad70c6ac1c6bf53cfa3ad7.zip |
Deduce a sane player name by examining environment variables. Add
a "player_name" setting to chocolate-doom.cfg. Transmit the name
to the server and use the names players send in the waiting data list.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 277
Diffstat (limited to 'src/net_server.c')
-rw-r--r-- | src/net_server.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/net_server.c b/src/net_server.c index 26085f68..070d6b6b 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_server.c 270 2006-01-08 05:06:06Z fraggle $ +// $Id: net_server.c 277 2006-01-09 01:50:51Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -21,6 +21,11 @@ // 02111-1307, USA. // // $Log$ +// 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 +// to the server and use the names players send in the waiting data list. +// // Revision 1.16 2006/01/08 05:06:06 fraggle // Reject new connections if the server is not in the waiting state. // @@ -84,6 +89,9 @@ // Network server code // +#include <stdlib.h> +#include <string.h> + #include "doomdef.h" #include "doomstat.h" #include "i_system.h" @@ -113,6 +121,7 @@ typedef struct net_addr_t *addr; net_connection_t connection; int last_send_time; + char *name; } net_client_t; static net_server_state_t server_state; @@ -218,6 +227,7 @@ static void NET_SV_ParseSYN(net_packet_t *packet, { unsigned int magic; unsigned int cl_gamemode, cl_gamemission; + char *player_name; int i; // read the magic number @@ -242,6 +252,15 @@ static void NET_SV_ParseSYN(net_packet_t *packet, return; } + // read the player's name + + player_name = NET_ReadString(packet); + + if (player_name == NULL) + { + return; + } + // received a valid SYN // not accepting new connections? @@ -322,6 +341,7 @@ static void NET_SV_ParseSYN(net_packet_t *packet, NET_Conn_InitServer(&client->connection, addr); client->addr = addr; client->last_send_time = -1; + client->name = strdup(player_name); } if (client->connection.state == NET_CONN_STATE_WAITING_ACK) @@ -417,7 +437,7 @@ static void NET_SV_SendWaitingData(net_client_t *client) // name - NET_WriteString(packet, "Player"); + NET_WriteString(packet, clients[i].name); // address @@ -447,6 +467,7 @@ static void NET_SV_RunClient(net_client_t *client) // deactivate and free back client->active = false; + free(client->name); NET_FreeAddress(client->addr); } |