--- deliantra/server/socket/request.C 2006/12/14 00:23:59 1.31 +++ deliantra/server/socket/request.C 2006/12/14 01:12:35 1.32 @@ -104,10 +104,11 @@ int x, y, mx, my; { - char buf[MAXSOCKBUF]; + SockList sl (MAXSOCKBUF); - sprintf (buf, "map_scroll %d %d", dx, dy); - Write_String_To_Socket (ns, buf, strlen (buf)); + sl.printf ("map_scroll %d %d", dx, dy); + ns->send_packet (sl); + sl.free (); } /* If we are using the Map1aCmd, we may in fact send @@ -163,7 +164,7 @@ memset (&socket.lastmap, 0, sizeof (socket.lastmap)); if (socket.newmapcmd == 1) - Write_String_To_Socket (&socket, "newmap", 6); + socket.send_packet ("newmap"); socket.update_look = 1; socket.look_position = 0; @@ -204,7 +205,7 @@ else snprintf (buf, MAX_BUF, "mapinfo current"); - Write_String_To_Socket (&socket, buf, strlen (buf)); + socket.send_packet (buf); } } else if (socket.current_x != ob->x || socket.current_y != ob->y) @@ -316,7 +317,7 @@ else snprintf (bigbuf, MAX_BUF, "mapinfo %s unsupported", token); - Write_String_To_Socket (&pl->socket, bigbuf, strlen (bigbuf)); + pl->socket.send_packet (bigbuf); } /** This is the Setup cmd - easy first implementation */ @@ -333,16 +334,19 @@ * The client then must sort this out */ - LOG (llevInfo, "Get SetupCmd:: %s\n", buf); + //LOG (llevInfo, "Get SetupCmd:: %s\n", buf); + strcpy (cmdback, "setup"); - for (s = 0; s < len;) + for (s = 0; s < len; ) { - cmd = &buf[s]; /* find the next space, and put a null there */ - for (; buf[s] && buf[s] != ' '; s++); + for (; buf[s] && buf[s] != ' '; s++) + ; + buf[s++] = 0; + while (buf[s] == ' ') s++; @@ -351,8 +355,11 @@ param = &buf[s]; - for (; buf[s] && buf[s] != ' '; s++); + for (; buf[s] && buf[s] != ' '; s++) + ; + buf[s++] = 0; + while (buf[s] == ' ') s++; @@ -523,8 +530,9 @@ safe_strcat (cmdback, "FALSE", &slen, HUGE_BUF); } } /* for processing all the setup commands */ + LOG (llevInfo, "SendBack SetupCmd:: %s\n", cmdback); - Write_String_To_Socket (ns, cmdback, strlen (cmdback)); + ns->send_packet (cmdback); } /** @@ -540,9 +548,7 @@ oldsettings = settings; if (ns->status != Ns_Add || add_player (ns)) - { - Write_String_To_Socket (ns, "addme_failed", 12); - } + ns->send_packet ("addme_failed"); else { /* Basically, the add_player copies the socket structure into @@ -550,10 +556,11 @@ * is not needed anymore. The write below should still work, as the * stuff in ns is still relevant. */ - Write_String_To_Socket (ns, "addme_success", 13); + ns->send_packet ("addme_success"); socket_info.nconns--; ns->status = Ns_Avail; } + settings = oldsettings; } @@ -607,7 +614,7 @@ strcat (cmdback, "smoothing"); } - Write_String_To_Socket (ns, cmdback, strlen (cmdback)); + ns->send_packet (cmdback); } /* @@ -670,7 +677,7 @@ strcat (cmdback, temp); } - Write_String_To_Socket (ns, cmdback, strlen (cmdback)); + ns->send_packet (cmdback); } /** @@ -968,7 +975,7 @@ { sprintf (version_warning, "drawinfo %d %s", NDI_RED, "**** VERSION WARNING ****\n**** CLIENT IS TOO OLD!! UPDATE THE CLIENT!! ****"); - Write_String_To_Socket (ns, version_warning, strlen (version_warning)); + ns->send_packet (version_warning); } } @@ -1050,7 +1057,7 @@ char buf[MAX_BUF]; sprintf (buf, "query %d %s", flags, text ? text : ""); - Write_String_To_Socket (ns, buf, strlen (buf)); + ns->send_packet (buf); } #define AddIfInt64(Old,New,Type) if (Old != New) {\ @@ -2343,7 +2350,7 @@ void send_plugin_custom_message (object *pl, char *buf) { - cs_write_string (&pl->contr->socket, buf, strlen (buf)); + pl->contr->socket.send_packet (buf); } /**