--- deliantra/server/socket/request.C 2006/09/10 13:43:33 1.16 +++ deliantra/server/socket/request.C 2006/09/14 23:13:49 1.20 @@ -1,9 +1,3 @@ - -/* - * static char *rcsid_init_c = - * "$Id: request.C,v 1.16 2006/09/10 13:43:33 root Exp $"; - */ - /* CrossFire, A Multiplayer game for X-windows @@ -24,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - The author can be reached via e-mail to crossfire-devel@real-time.com + The author can be reached via e-mail to */ /** @@ -52,8 +46,6 @@ * esrv_map_doneredraw finishes the map update, and ships across the * map updates. * - * esrv_map_scroll tells the client to scroll the map, and does similarily - * for the locally cached copy. */ #include @@ -583,39 +575,46 @@ cmdback[0] = '\0'; nextinfo = 0; + while (1) { /* 1. Extract an info */ info = nextinfo; + while ((info < len) && (buf[info] == ' ')) info++; + if (info >= len) break; + nextinfo = info + 1; + while ((nextinfo < len) && (buf[nextinfo] != ' ')) nextinfo++; + if (nextinfo - info >= 49) /*Erroneous info asked */ continue; + strncpy (command, &(buf[info]), nextinfo - info); - command[nextinfo - info] = '\0'; + /* 2. Interpret info */ if (!strcmp ("smooth", command)) - { - /* Toggle smoothing */ - ns->EMI_smooth = !ns->EMI_smooth; - } + /* Toggle smoothing */ + ns->EMI_smooth = !ns->EMI_smooth; else - { - /*bad value */ - } + /*bad value */; + /*3. Next info */ } + strcpy (cmdback, "ExtendedInfoSet"); + if (ns->EMI_smooth) { strcat (cmdback, " "); strcat (cmdback, "smoothing"); } + Write_String_To_Socket (ns, cmdback, strlen (cmdback)); } @@ -637,30 +636,40 @@ int info, nextinfo, i, flag; cmdback[0] = '\0'; + nextinfo = 0; while (1) { /* 1. Extract an info */ info = nextinfo; + while ((info < len) && (buf[info] == ' ')) info++; + if (info >= len) break; + nextinfo = info + 1; + while ((nextinfo < len) && (buf[nextinfo] != ' ')) nextinfo++; + if (nextinfo - info >= 49) /*Erroneous info asked */ continue; + strncpy (command, &(buf[info]), nextinfo - info); command[nextinfo - info] = '\0'; /* 2. Interpret info */ i = sscanf (command, "%d", &flag); + if ((i == 1) && (flag > 0) && (flag <= MSG_TYPE_LAST)) ns->supported_readables |= (1 << flag); /*3. Next info */ } + /* Send resulting state */ strcpy (cmdback, "ExtendedTextSet"); + for (i = 0; i <= MSG_TYPE_LAST; i++) if (ns->supported_readables & (1 << i)) { @@ -668,6 +677,7 @@ snprintf (temp, sizeof (temp), "%d", i); strcat (cmdback, temp); } + Write_String_To_Socket (ns, cmdback, strlen (cmdback)); } @@ -1428,9 +1438,8 @@ { /* All of this is just accounting stuff */ if (tframes > 100) - { - tframes = tbytes = 0; - } + tframes = tbytes = 0; + tframes++; frames++; tbytes += sl.len; @@ -1439,6 +1448,7 @@ Send_With_Handling (ns, &sl); ns->sent_scroll = 0; } + free (sl.buf); } @@ -2118,7 +2128,7 @@ } } - if (lastcell.player !=player) + if (lastcell.player != player) { lastcell.player = player; @@ -2205,17 +2215,19 @@ ewhatflag &= (~EMI_NOREDRAW); esl.buf[ewhatstart + 1] = ewhatflag & 0xff; } + if (esl.len > estartlen) - { - Send_With_Handling (&socket, &esl); - } + Send_With_Handling (&socket, &esl); + free (esl.buf); } + if (sl.len > startlen || socket.sent_scroll) { Send_With_Handling (&socket, &sl); socket.sent_scroll = 0; } + free (sl.buf); }