--- deliantra/server/socket/init.C 2006/12/13 02:55:51 1.11 +++ deliantra/server/socket/init.C 2006/12/14 01:21:58 1.14 @@ -61,8 +61,6 @@ void InitConnection (NewSocket *ns, const char *from_ip) { - SockList sl; - char buf[256]; int bufsize = 65535; /*Supposed absolute upper limit */ int oldbufsize; int buflen = sizeof (int); @@ -112,13 +110,12 @@ * duplicating (not likely in normal cases, but malicous attacks that * just open and close connections could get this total up. */ - ns->inbuf.len = 0; - ns->inbuf.buf = (unsigned char *) malloc (sizeof (unsigned char) * MAXSOCKBUF); + ns->inbuf_len = 0; + /* Basic initialization. Needed because we do a check in * HandleClient for oldsocketmode without checking the * length of data. */ - memset (ns->inbuf.buf, 0, sizeof (unsigned char) * MAXSOCKBUF); memset (&ns->lastmap, 0, sizeof (struct Map)); memset (ns->faces_sent, 0, ns->faces_sent_len * sizeof (*ns->faces_sent)); memset (&ns->anims_sent, 0, sizeof (ns->anims_sent)); @@ -142,10 +139,14 @@ ns->sent_scroll = 0; ns->host = strdup_local (from_ip); - sprintf ((char *) buf, "version %d %d %s\n", VERSION_CS, VERSION_SC, VERSION_INFO); - sl.buf = (unsigned char *) buf; - sl.len = strlen ((char *) buf); - Send_With_Handling (ns, &sl); + + { + packet sl; + + sl.printf ("version %d %d %s\n", VERSION_CS, VERSION_SC, VERSION_INFO); + Send_With_Handling (ns, &sl); + } + #ifdef CS_LOGSTATS if (socket_info.nconns > cst_tot.max_conn) cst_tot.max_conn = socket_info.nconns; @@ -265,14 +266,14 @@ free (ns->stats.title); free (ns->host); - free (ns->inbuf.buf); } /** Sends the 'goodbye' command to the player, and closes connection. */ void final_free_player (player *pl) { - cs_write_string (&pl->socket, "goodbye", 8); + pl->socket.send_packet ("goodbye"); free_newsocket (&pl->socket); free_player (pl); } +