--- deliantra/server/socket/request.C 2006/09/10 13:43:33 1.16 +++ deliantra/server/socket/request.C 2006/09/12 19:20:09 1.17 @@ -1,7 +1,7 @@ /* * static char *rcsid_init_c = - * "$Id: request.C,v 1.16 2006/09/10 13:43:33 root Exp $"; + * "$Id: request.C,v 1.17 2006/09/12 19:20:09 root Exp $"; */ /* @@ -583,39 +583,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 +644,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 +685,7 @@ snprintf (temp, sizeof (temp), "%d", i); strcat (cmdback, temp); } + Write_String_To_Socket (ns, cmdback, strlen (cmdback)); }