ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/init.C
(Generate patch)

Comparing deliantra/server/socket/init.C (file contents):
Revision 1.11 by root, Wed Dec 13 02:55:51 2006 UTC vs.
Revision 1.13 by root, Thu Dec 14 01:12:35 2006 UTC

59 * client. 59 * client.
60 */ 60 */
61void 61void
62InitConnection (NewSocket *ns, const char *from_ip) 62InitConnection (NewSocket *ns, const char *from_ip)
63{ 63{
64 SockList sl;
65 char buf[256];
66 int bufsize = 65535; /*Supposed absolute upper limit */ 64 int bufsize = 65535; /*Supposed absolute upper limit */
67 int oldbufsize; 65 int oldbufsize;
68 int buflen = sizeof (int); 66 int buflen = sizeof (int);
69 67
70 if (fcntl (ns->fd, F_SETFL, O_NONBLOCK) == -1) 68 if (fcntl (ns->fd, F_SETFL, O_NONBLOCK) == -1)
110 /* we should really do some checking here - if total clients overflows 108 /* we should really do some checking here - if total clients overflows
111 * we need to do something more intelligent, because client id's will start 109 * we need to do something more intelligent, because client id's will start
112 * duplicating (not likely in normal cases, but malicous attacks that 110 * duplicating (not likely in normal cases, but malicous attacks that
113 * just open and close connections could get this total up. 111 * just open and close connections could get this total up.
114 */ 112 */
115 ns->inbuf.len = 0; 113 ns->inbuf_len = 0;
116 ns->inbuf.buf = (unsigned char *) malloc (sizeof (unsigned char) * MAXSOCKBUF); 114
117 /* Basic initialization. Needed because we do a check in 115 /* Basic initialization. Needed because we do a check in
118 * HandleClient for oldsocketmode without checking the 116 * HandleClient for oldsocketmode without checking the
119 * length of data. 117 * length of data.
120 */ 118 */
121 memset (ns->inbuf.buf, 0, sizeof (unsigned char) * MAXSOCKBUF);
122 memset (&ns->lastmap, 0, sizeof (struct Map)); 119 memset (&ns->lastmap, 0, sizeof (struct Map));
123 memset (ns->faces_sent, 0, ns->faces_sent_len * sizeof (*ns->faces_sent)); 120 memset (ns->faces_sent, 0, ns->faces_sent_len * sizeof (*ns->faces_sent));
124 memset (&ns->anims_sent, 0, sizeof (ns->anims_sent)); 121 memset (&ns->anims_sent, 0, sizeof (ns->anims_sent));
125 memset (&ns->stats, 0, sizeof (struct statsinfo)); 122 memset (&ns->stats, 0, sizeof (struct statsinfo));
126 /* Do this so we don't send a face command for the client for 123 /* Do this so we don't send a face command for the client for
140 ns->client[0] = 0; 137 ns->client[0] = 0;
141 ns->buggy_mapscroll = 0; 138 ns->buggy_mapscroll = 0;
142 139
143 ns->sent_scroll = 0; 140 ns->sent_scroll = 0;
144 ns->host = strdup_local (from_ip); 141 ns->host = strdup_local (from_ip);
142
143 {
144 SockList sl (MAXSOCKBUF);
145
145 sprintf ((char *) buf, "version %d %d %s\n", VERSION_CS, VERSION_SC, VERSION_INFO); 146 sl.printf ("version %d %d %s\n", VERSION_CS, VERSION_SC, VERSION_INFO);
146 sl.buf = (unsigned char *) buf;
147 sl.len = strlen ((char *) buf);
148 Send_With_Handling (ns, &sl); 147 Send_With_Handling (ns, &sl);
148 sl.free ();
149 }
150
149#ifdef CS_LOGSTATS 151#ifdef CS_LOGSTATS
150 if (socket_info.nconns > cst_tot.max_conn) 152 if (socket_info.nconns > cst_tot.max_conn)
151 cst_tot.max_conn = socket_info.nconns; 153 cst_tot.max_conn = socket_info.nconns;
152 if (socket_info.nconns > cst_lst.max_conn) 154 if (socket_info.nconns > cst_lst.max_conn)
153 cst_lst.max_conn = socket_info.nconns; 155 cst_lst.max_conn = socket_info.nconns;
263 265
264 if (ns->stats.title) 266 if (ns->stats.title)
265 free (ns->stats.title); 267 free (ns->stats.title);
266 268
267 free (ns->host); 269 free (ns->host);
268 free (ns->inbuf.buf);
269} 270}
270 271
271/** Sends the 'goodbye' command to the player, and closes connection. */ 272/** Sends the 'goodbye' command to the player, and closes connection. */
272void 273void
273final_free_player (player *pl) 274final_free_player (player *pl)
274{ 275{
275 cs_write_string (&pl->socket, "goodbye", 8); 276 pl->socket.send_packet ("goodbye");
276 free_newsocket (&pl->socket); 277 free_newsocket (&pl->socket);
277 free_player (pl); 278 free_player (pl);
278} 279}
280

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines