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

Comparing deliantra/server/socket/request.C (file contents):
Revision 1.31 by root, Thu Dec 14 00:23:59 2006 UTC vs.
Revision 1.32 by root, Thu Dec 14 01:12:35 2006 UTC

102{ 102{
103 struct Map newmap; 103 struct Map newmap;
104 int x, y, mx, my; 104 int x, y, mx, my;
105 105
106 { 106 {
107 char buf[MAXSOCKBUF]; 107 SockList sl (MAXSOCKBUF);
108 108
109 sprintf (buf, "map_scroll %d %d", dx, dy); 109 sl.printf ("map_scroll %d %d", dx, dy);
110 Write_String_To_Socket (ns, buf, strlen (buf)); 110 ns->send_packet (sl);
111 sl.free ();
111 } 112 }
112 113
113 /* If we are using the Map1aCmd, we may in fact send 114 /* If we are using the Map1aCmd, we may in fact send
114 * head information that is outside the viewable map. 115 * head information that is outside the viewable map.
115 * So set the mx,my to the max value we want to 116 * So set the mx,my to the max value we want to
161 NewSocket & socket = pl->socket; 162 NewSocket & socket = pl->socket;
162 163
163 memset (&socket.lastmap, 0, sizeof (socket.lastmap)); 164 memset (&socket.lastmap, 0, sizeof (socket.lastmap));
164 165
165 if (socket.newmapcmd == 1) 166 if (socket.newmapcmd == 1)
166 Write_String_To_Socket (&socket, "newmap", 6); 167 socket.send_packet ("newmap");
167 168
168 socket.update_look = 1; 169 socket.update_look = 1;
169 socket.look_position = 0; 170 socket.look_position = 0;
170} 171}
171 172
202 flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y, ob->map->width, ob->map->height, ob->map->path); 203 flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y, ob->map->width, ob->map->height, ob->map->path);
203 } 204 }
204 else 205 else
205 snprintf (buf, MAX_BUF, "mapinfo current"); 206 snprintf (buf, MAX_BUF, "mapinfo current");
206 207
207 Write_String_To_Socket (&socket, buf, strlen (buf)); 208 socket.send_packet (buf);
208 } 209 }
209 } 210 }
210 else if (socket.current_x != ob->x || socket.current_y != ob->y) 211 else if (socket.current_x != ob->x || socket.current_y != ob->y)
211 { 212 {
212 int dx = ob->x - socket.current_x; 213 int dx = ob->x - socket.current_x;
314 snprintf (bigbuf, MAX_BUF, "mapinfo %s nomap", token); 315 snprintf (bigbuf, MAX_BUF, "mapinfo %s nomap", token);
315 } 316 }
316 else 317 else
317 snprintf (bigbuf, MAX_BUF, "mapinfo %s unsupported", token); 318 snprintf (bigbuf, MAX_BUF, "mapinfo %s unsupported", token);
318 319
319 Write_String_To_Socket (&pl->socket, bigbuf, strlen (bigbuf)); 320 pl->socket.send_packet (bigbuf);
320} 321}
321 322
322/** This is the Setup cmd - easy first implementation */ 323/** This is the Setup cmd - easy first implementation */
323void 324void
324SetUp (char *buf, int len, NewSocket * ns) 325SetUp (char *buf, int len, NewSocket * ns)
331 * 332 *
332 * we send the status of the cmd back, or a FALSE is the cmd is the server unknown 333 * we send the status of the cmd back, or a FALSE is the cmd is the server unknown
333 * The client then must sort this out 334 * The client then must sort this out
334 */ 335 */
335 336
336 LOG (llevInfo, "Get SetupCmd:: %s\n", buf); 337 //LOG (llevInfo, "Get SetupCmd:: %s\n", buf);
338
337 strcpy (cmdback, "setup"); 339 strcpy (cmdback, "setup");
338 for (s = 0; s < len;) 340 for (s = 0; s < len; )
339 { 341 {
340
341 cmd = &buf[s]; 342 cmd = &buf[s];
342 343
343 /* find the next space, and put a null there */ 344 /* find the next space, and put a null there */
344 for (; buf[s] && buf[s] != ' '; s++); 345 for (; buf[s] && buf[s] != ' '; s++)
346 ;
347
345 buf[s++] = 0; 348 buf[s++] = 0;
349
346 while (buf[s] == ' ') 350 while (buf[s] == ' ')
347 s++; 351 s++;
348 352
349 if (s >= len) 353 if (s >= len)
350 break; 354 break;
351 355
352 param = &buf[s]; 356 param = &buf[s];
353 357
354 for (; buf[s] && buf[s] != ' '; s++); 358 for (; buf[s] && buf[s] != ' '; s++)
359 ;
360
355 buf[s++] = 0; 361 buf[s++] = 0;
362
356 while (buf[s] == ' ') 363 while (buf[s] == ' ')
357 s++; 364 s++;
358 365
359 slen = strlen (cmdback); 366 slen = strlen (cmdback);
360 safe_strcat (cmdback, " ", &slen, HUGE_BUF); 367 safe_strcat (cmdback, " ", &slen, HUGE_BUF);
521 * report a failure to the client. 528 * report a failure to the client.
522 */ 529 */
523 safe_strcat (cmdback, "FALSE", &slen, HUGE_BUF); 530 safe_strcat (cmdback, "FALSE", &slen, HUGE_BUF);
524 } 531 }
525 } /* for processing all the setup commands */ 532 } /* for processing all the setup commands */
533
526 LOG (llevInfo, "SendBack SetupCmd:: %s\n", cmdback); 534 LOG (llevInfo, "SendBack SetupCmd:: %s\n", cmdback);
527 Write_String_To_Socket (ns, cmdback, strlen (cmdback)); 535 ns->send_packet (cmdback);
528} 536}
529 537
530/** 538/**
531 * The client has requested to be added to the game. 539 * The client has requested to be added to the game.
532 * This is what takes care of it. We tell the client how things worked out. 540 * This is what takes care of it. We tell the client how things worked out.
538{ 546{
539 Settings oldsettings; 547 Settings oldsettings;
540 548
541 oldsettings = settings; 549 oldsettings = settings;
542 if (ns->status != Ns_Add || add_player (ns)) 550 if (ns->status != Ns_Add || add_player (ns))
543 { 551 ns->send_packet ("addme_failed");
544 Write_String_To_Socket (ns, "addme_failed", 12);
545 }
546 else 552 else
547 { 553 {
548 /* Basically, the add_player copies the socket structure into 554 /* Basically, the add_player copies the socket structure into
549 * the player structure, so this one (which is from init_sockets) 555 * the player structure, so this one (which is from init_sockets)
550 * is not needed anymore. The write below should still work, as the 556 * is not needed anymore. The write below should still work, as the
551 * stuff in ns is still relevant. 557 * stuff in ns is still relevant.
552 */ 558 */
553 Write_String_To_Socket (ns, "addme_success", 13); 559 ns->send_packet ("addme_success");
554 socket_info.nconns--; 560 socket_info.nconns--;
555 ns->status = Ns_Avail; 561 ns->status = Ns_Avail;
556 } 562 }
563
557 settings = oldsettings; 564 settings = oldsettings;
558} 565}
559 566
560/** Reply to ExtendedInfos command */ 567/** Reply to ExtendedInfos command */
561void 568void
605 { 612 {
606 strcat (cmdback, " "); 613 strcat (cmdback, " ");
607 strcat (cmdback, "smoothing"); 614 strcat (cmdback, "smoothing");
608 } 615 }
609 616
610 Write_String_To_Socket (ns, cmdback, strlen (cmdback)); 617 ns->send_packet (cmdback);
611} 618}
612 619
613/* 620/*
614#define MSG_TYPE_BOOK 1 621#define MSG_TYPE_BOOK 1
615#define MSG_TYPE_CARD 2 622#define MSG_TYPE_CARD 2
668 strcat (cmdback, " "); 675 strcat (cmdback, " ");
669 snprintf (temp, sizeof (temp), "%d", i); 676 snprintf (temp, sizeof (temp), "%d", i);
670 strcat (cmdback, temp); 677 strcat (cmdback, temp);
671 } 678 }
672 679
673 Write_String_To_Socket (ns, cmdback, strlen (cmdback)); 680 ns->send_packet (cmdback);
674} 681}
675 682
676/** 683/**
677 * A lot like the old AskSmooth (in fact, now called by AskSmooth). 684 * A lot like the old AskSmooth (in fact, now called by AskSmooth).
678 * Basically, it makes no sense to wait for the client to request a 685 * Basically, it makes no sense to wait for the client to request a
966 */ 973 */
967 if (ns->sc_version < 1026) 974 if (ns->sc_version < 1026)
968 { 975 {
969 sprintf (version_warning, "drawinfo %d %s", NDI_RED, 976 sprintf (version_warning, "drawinfo %d %s", NDI_RED,
970 "**** VERSION WARNING ****\n**** CLIENT IS TOO OLD!! UPDATE THE CLIENT!! ****"); 977 "**** VERSION WARNING ****\n**** CLIENT IS TOO OLD!! UPDATE THE CLIENT!! ****");
971 Write_String_To_Socket (ns, version_warning, strlen (version_warning)); 978 ns->send_packet (version_warning);
972 } 979 }
973 980
974 } 981 }
975} 982}
976 983
1048send_query (NewSocket * ns, uint8 flags, char *text) 1055send_query (NewSocket * ns, uint8 flags, char *text)
1049{ 1056{
1050 char buf[MAX_BUF]; 1057 char buf[MAX_BUF];
1051 1058
1052 sprintf (buf, "query %d %s", flags, text ? text : ""); 1059 sprintf (buf, "query %d %s", flags, text ? text : "");
1053 Write_String_To_Socket (ns, buf, strlen (buf)); 1060 ns->send_packet (buf);
1054} 1061}
1055 1062
1056#define AddIfInt64(Old,New,Type) if (Old != New) {\ 1063#define AddIfInt64(Old,New,Type) if (Old != New) {\
1057 Old = New; \ 1064 Old = New; \
1058 sl << uint8 (Type) << uint64 (New); \ 1065 sl << uint8 (Type) << uint64 (New); \
2341 2348
2342/*****************************************************************************/ 2349/*****************************************************************************/
2343void 2350void
2344send_plugin_custom_message (object *pl, char *buf) 2351send_plugin_custom_message (object *pl, char *buf)
2345{ 2352{
2346 cs_write_string (&pl->contr->socket, buf, strlen (buf)); 2353 pl->contr->socket.send_packet (buf);
2347} 2354}
2348 2355
2349/** 2356/**
2350 * This sends the skill number to name mapping. We ignore 2357 * This sends the skill number to name mapping. We ignore
2351 * the params - we always send the same info no matter what. 2358 * the params - we always send the same info no matter what.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines