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.29 by root, Wed Dec 13 21:27:09 2006 UTC vs.
Revision 1.33 by root, Thu Dec 14 01:21:58 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 packet sl;
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 } 111 }
112 112
113 /* If we are using the Map1aCmd, we may in fact send 113 /* If we are using the Map1aCmd, we may in fact send
114 * head information that is outside the viewable map. 114 * head information that is outside the viewable map.
115 * So set the mx,my to the max value we want to 115 * So set the mx,my to the max value we want to
161 NewSocket & socket = pl->socket; 161 NewSocket & socket = pl->socket;
162 162
163 memset (&socket.lastmap, 0, sizeof (socket.lastmap)); 163 memset (&socket.lastmap, 0, sizeof (socket.lastmap));
164 164
165 if (socket.newmapcmd == 1) 165 if (socket.newmapcmd == 1)
166 Write_String_To_Socket (&socket, "newmap", 6); 166 socket.send_packet ("newmap");
167 167
168 socket.update_look = 1; 168 socket.update_look = 1;
169 socket.look_position = 0; 169 socket.look_position = 0;
170} 170}
171 171
202 flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y, ob->map->width, ob->map->height, ob->map->path); 202 flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y, ob->map->width, ob->map->height, ob->map->path);
203 } 203 }
204 else 204 else
205 snprintf (buf, MAX_BUF, "mapinfo current"); 205 snprintf (buf, MAX_BUF, "mapinfo current");
206 206
207 Write_String_To_Socket (&socket, buf, strlen (buf)); 207 socket.send_packet (buf);
208 } 208 }
209 } 209 }
210 else if (socket.current_x != ob->x || socket.current_y != ob->y) 210 else if (socket.current_x != ob->x || socket.current_y != ob->y)
211 { 211 {
212 int dx = ob->x - socket.current_x; 212 int dx = ob->x - socket.current_x;
314 snprintf (bigbuf, MAX_BUF, "mapinfo %s nomap", token); 314 snprintf (bigbuf, MAX_BUF, "mapinfo %s nomap", token);
315 } 315 }
316 else 316 else
317 snprintf (bigbuf, MAX_BUF, "mapinfo %s unsupported", token); 317 snprintf (bigbuf, MAX_BUF, "mapinfo %s unsupported", token);
318 318
319 Write_String_To_Socket (&pl->socket, bigbuf, strlen (bigbuf)); 319 pl->socket.send_packet (bigbuf);
320} 320}
321 321
322/** This is the Setup cmd - easy first implementation */ 322/** This is the Setup cmd - easy first implementation */
323void 323void
324SetUp (char *buf, int len, NewSocket * ns) 324SetUp (char *buf, int len, NewSocket * ns)
331 * 331 *
332 * we send the status of the cmd back, or a FALSE is the cmd is the server unknown 332 * 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 333 * The client then must sort this out
334 */ 334 */
335 335
336 LOG (llevInfo, "Get SetupCmd:: %s\n", buf); 336 //LOG (llevInfo, "Get SetupCmd:: %s\n", buf);
337
337 strcpy (cmdback, "setup"); 338 strcpy (cmdback, "setup");
338 for (s = 0; s < len;) 339 for (s = 0; s < len; )
339 { 340 {
340
341 cmd = &buf[s]; 341 cmd = &buf[s];
342 342
343 /* find the next space, and put a null there */ 343 /* find the next space, and put a null there */
344 for (; buf[s] && buf[s] != ' '; s++); 344 for (; buf[s] && buf[s] != ' '; s++)
345 ;
346
345 buf[s++] = 0; 347 buf[s++] = 0;
348
346 while (buf[s] == ' ') 349 while (buf[s] == ' ')
347 s++; 350 s++;
348 351
349 if (s >= len) 352 if (s >= len)
350 break; 353 break;
351 354
352 param = &buf[s]; 355 param = &buf[s];
353 356
354 for (; buf[s] && buf[s] != ' '; s++); 357 for (; buf[s] && buf[s] != ' '; s++)
358 ;
359
355 buf[s++] = 0; 360 buf[s++] = 0;
361
356 while (buf[s] == ' ') 362 while (buf[s] == ' ')
357 s++; 363 s++;
358 364
359 slen = strlen (cmdback); 365 slen = strlen (cmdback);
360 safe_strcat (cmdback, " ", &slen, HUGE_BUF); 366 safe_strcat (cmdback, " ", &slen, HUGE_BUF);
521 * report a failure to the client. 527 * report a failure to the client.
522 */ 528 */
523 safe_strcat (cmdback, "FALSE", &slen, HUGE_BUF); 529 safe_strcat (cmdback, "FALSE", &slen, HUGE_BUF);
524 } 530 }
525 } /* for processing all the setup commands */ 531 } /* for processing all the setup commands */
532
526 LOG (llevInfo, "SendBack SetupCmd:: %s\n", cmdback); 533 LOG (llevInfo, "SendBack SetupCmd:: %s\n", cmdback);
527 Write_String_To_Socket (ns, cmdback, strlen (cmdback)); 534 ns->send_packet (cmdback);
528} 535}
529 536
530/** 537/**
531 * The client has requested to be added to the game. 538 * 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. 539 * This is what takes care of it. We tell the client how things worked out.
538{ 545{
539 Settings oldsettings; 546 Settings oldsettings;
540 547
541 oldsettings = settings; 548 oldsettings = settings;
542 if (ns->status != Ns_Add || add_player (ns)) 549 if (ns->status != Ns_Add || add_player (ns))
543 { 550 ns->send_packet ("addme_failed");
544 Write_String_To_Socket (ns, "addme_failed", 12);
545 }
546 else 551 else
547 { 552 {
548 /* Basically, the add_player copies the socket structure into 553 /* Basically, the add_player copies the socket structure into
549 * the player structure, so this one (which is from init_sockets) 554 * the player structure, so this one (which is from init_sockets)
550 * is not needed anymore. The write below should still work, as the 555 * is not needed anymore. The write below should still work, as the
551 * stuff in ns is still relevant. 556 * stuff in ns is still relevant.
552 */ 557 */
553 Write_String_To_Socket (ns, "addme_success", 13); 558 ns->send_packet ("addme_success");
554 socket_info.nconns--; 559 socket_info.nconns--;
555 ns->status = Ns_Avail; 560 ns->status = Ns_Avail;
556 } 561 }
562
557 settings = oldsettings; 563 settings = oldsettings;
558} 564}
559 565
560/** Reply to ExtendedInfos command */ 566/** Reply to ExtendedInfos command */
561void 567void
605 { 611 {
606 strcat (cmdback, " "); 612 strcat (cmdback, " ");
607 strcat (cmdback, "smoothing"); 613 strcat (cmdback, "smoothing");
608 } 614 }
609 615
610 Write_String_To_Socket (ns, cmdback, strlen (cmdback)); 616 ns->send_packet (cmdback);
611} 617}
612 618
613/* 619/*
614#define MSG_TYPE_BOOK 1 620#define MSG_TYPE_BOOK 1
615#define MSG_TYPE_CARD 2 621#define MSG_TYPE_CARD 2
668 strcat (cmdback, " "); 674 strcat (cmdback, " ");
669 snprintf (temp, sizeof (temp), "%d", i); 675 snprintf (temp, sizeof (temp), "%d", i);
670 strcat (cmdback, temp); 676 strcat (cmdback, temp);
671 } 677 }
672 678
673 Write_String_To_Socket (ns, cmdback, strlen (cmdback)); 679 ns->send_packet (cmdback);
674} 680}
675 681
676/** 682/**
677 * A lot like the old AskSmooth (in fact, now called by AskSmooth). 683 * 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 684 * Basically, it makes no sense to wait for the client to request a
699 if (!(ns->faces_sent[smoothface] & NS_FACESENT_FACE)) 705 if (!(ns->faces_sent[smoothface] & NS_FACESENT_FACE))
700 esrv_send_face (ns, smoothface, 0); 706 esrv_send_face (ns, smoothface, 0);
701 707
702 ns->faces_sent[face] |= NS_FACESENT_SMOOTH; 708 ns->faces_sent[face] |= NS_FACESENT_SMOOTH;
703 709
704 SockList sl (MAXSOCKBUF); 710 packet sl;
705 711
706 sl << "smooth " 712 sl << "smooth "
707 << uint16 (face) 713 << uint16 (face)
708 << uint16 (smoothface); 714 << uint16 (smoothface);
709 715
710 Send_With_Handling (ns, &sl); 716 Send_With_Handling (ns, &sl);
711 sl.free ();
712} 717}
713 718
714 /** 719 /**
715 * Tells client the picture it has to use 720 * Tells client the picture it has to use
716 * to smooth a picture number given as argument. 721 * to smooth a picture number given as argument.
785void 790void
786NewPlayerCmd (uint8 * buf, int len, player *pl) 791NewPlayerCmd (uint8 * buf, int len, player *pl)
787{ 792{
788 int time, repeat; 793 int time, repeat;
789 char command[MAX_BUF]; 794 char command[MAX_BUF];
790 short packet; 795 int pktlen;
791 796
792 if (len < 7) 797 if (len < 7)
793 { 798 {
794 LOG (llevDebug, "Corrupt ncom command <%s> not long enough - discarding\n", buf); 799 LOG (llevDebug, "Corrupt ncom command <%s> not long enough - discarding\n", buf);
795 return; 800 return;
796 } 801 }
797 802
798 packet = GetShort_String (buf); 803 pktlen = net_uint16 (buf);
799 repeat = GetInt_String (buf + 2); 804 repeat = net_uint32 (buf + 2);
805
800 /* -1 is special - no repeat, but don't update */ 806 /* -1 is special - no repeat, but don't update */
801 if (repeat != -1) 807 if (repeat != -1)
802 pl->count = repeat; 808 pl->count = repeat;
803 809
804 if ((len - 4) >= MAX_BUF) 810 if ((len - 4) >= MAX_BUF)
836 else 842 else
837 time = (int) (MAX_TIME / FABS (pl->ob->speed)); 843 time = (int) (MAX_TIME / FABS (pl->ob->speed));
838 844
839 /* Send confirmation of command execution now */ 845 /* Send confirmation of command execution now */
840 846
841 SockList sl (MAXSOCKBUF); 847 packet sl;
842 sl << "comc " << uint16 (packet) << uint32 (time); 848 sl << "comc " << uint16 (pktlen) << uint32 (time);
843 Send_With_Handling (&pl->socket, &sl); 849 Send_With_Handling (&pl->socket, &sl);
844 sl.free ();
845} 850}
846 851
847 852
848/** This is a reply to a previous query. */ 853/** This is a reply to a previous query. */
849void 854void
965 */ 970 */
966 if (ns->sc_version < 1026) 971 if (ns->sc_version < 1026)
967 { 972 {
968 sprintf (version_warning, "drawinfo %d %s", NDI_RED, 973 sprintf (version_warning, "drawinfo %d %s", NDI_RED,
969 "**** VERSION WARNING ****\n**** CLIENT IS TOO OLD!! UPDATE THE CLIENT!! ****"); 974 "**** VERSION WARNING ****\n**** CLIENT IS TOO OLD!! UPDATE THE CLIENT!! ****");
970 Write_String_To_Socket (ns, version_warning, strlen (version_warning)); 975 ns->send_packet (version_warning);
971 } 976 }
972 977
973 } 978 }
974} 979}
975 980
1047send_query (NewSocket * ns, uint8 flags, char *text) 1052send_query (NewSocket * ns, uint8 flags, char *text)
1048{ 1053{
1049 char buf[MAX_BUF]; 1054 char buf[MAX_BUF];
1050 1055
1051 sprintf (buf, "query %d %s", flags, text ? text : ""); 1056 sprintf (buf, "query %d %s", flags, text ? text : "");
1052 Write_String_To_Socket (ns, buf, strlen (buf)); 1057 ns->send_packet (buf);
1053} 1058}
1054 1059
1055#define AddIfInt64(Old,New,Type) if (Old != New) {\ 1060#define AddIfInt64(Old,New,Type) if (Old != New) {\
1056 Old = New; \ 1061 Old = New; \
1057 sl << uint8 (Type) << uint64 (New); \ 1062 sl << uint8 (Type) << uint64 (New); \
1087esrv_update_stats (player *pl) 1092esrv_update_stats (player *pl)
1088{ 1093{
1089 char buf[MAX_BUF]; 1094 char buf[MAX_BUF];
1090 uint16 flags; 1095 uint16 flags;
1091 1096
1092 SockList sl (MAXSOCKBUF); 1097 packet sl;
1093 sl << "stats "; 1098 sl << "stats ";
1094 1099
1095 if (pl->ob != NULL) 1100 if (pl->ob != NULL)
1096 { 1101 {
1097 AddIfShort (pl->last_stats.hp, pl->ob->stats.hp, CS_STAT_HP); 1102 AddIfShort (pl->last_stats.hp, pl->ob->stats.hp, CS_STAT_HP);
1187 LOG (llevDebug, "Sending stats command, %d bytes long.\n", sl.len); 1192 LOG (llevDebug, "Sending stats command, %d bytes long.\n", sl.len);
1188#endif 1193#endif
1189 Send_With_Handling (&pl->socket, &sl); 1194 Send_With_Handling (&pl->socket, &sl);
1190 } 1195 }
1191 1196
1192 sl.free ();
1193} 1197}
1194 1198
1195/** 1199/**
1196 * Tells the client that here is a player it should start using. 1200 * Tells the client that here is a player it should start using.
1197 */ 1201 */
1198void 1202void
1199esrv_new_player (player *pl, uint32 weight) 1203esrv_new_player (player *pl, uint32 weight)
1200{ 1204{
1201 pl->last_weight = weight; 1205 pl->last_weight = weight;
1202 1206
1203 SockList sl (MAXSOCKBUF); 1207 packet sl;
1204 sl << "player "; 1208 sl << "player ";
1205 1209
1206 sl << uint32 (pl->ob->count) 1210 sl << uint32 (pl->ob->count)
1207 << uint32 (weight) 1211 << uint32 (weight)
1208 << uint32 (pl->ob->face->number) 1212 << uint32 (pl->ob->face->number)
1209 << data8 (pl->ob->name); 1213 << data8 (pl->ob->name);
1210 1214
1211 Send_With_Handling (&pl->socket, &sl); 1215 Send_With_Handling (&pl->socket, &sl);
1212 sl.free ();
1213 SET_FLAG (pl->ob, FLAG_CLIENT_SENT); 1216 SET_FLAG (pl->ob, FLAG_CLIENT_SENT);
1214} 1217}
1215 1218
1216/** 1219/**
1217 * Need to send an animation sequence to the client. 1220 * Need to send an animation sequence to the client.
1233 { 1236 {
1234 LOG (llevError, "esrv_send_anim (%d) out of bounds??\n", anim_num); 1237 LOG (llevError, "esrv_send_anim (%d) out of bounds??\n", anim_num);
1235 return; 1238 return;
1236 } 1239 }
1237 1240
1238 SockList sl (MAXSOCKBUF); 1241 packet sl;
1239 1242
1240 sl << "anim " 1243 sl << "anim "
1241 << uint16 (anim_num) 1244 << uint16 (anim_num)
1242 << uint16 (0); /* flags - not used right now */ 1245 << uint16 (0); /* flags - not used right now */
1243 1246
1250 esrv_send_face (ns, animations[anim_num].faces[i], 0); 1253 esrv_send_face (ns, animations[anim_num].faces[i], 0);
1251 sl << uint16 (animations[anim_num].faces[i]); /* flags - not used right now */ 1254 sl << uint16 (animations[anim_num].faces[i]); /* flags - not used right now */
1252 } 1255 }
1253 1256
1254 Send_With_Handling (ns, &sl); 1257 Send_With_Handling (ns, &sl);
1255 sl.free ();
1256 1258
1257 ns->anims_sent[anim_num] = 1; 1259 ns->anims_sent[anim_num] = 1;
1258} 1260}
1259 1261
1260 1262
1396esrv_map_doneredraw (NewSocket * ns, struct Map *newmap) 1398esrv_map_doneredraw (NewSocket * ns, struct Map *newmap)
1397{ 1399{
1398 static long frames, bytes, tbytes, tframes; 1400 static long frames, bytes, tbytes, tframes;
1399 char *cur; 1401 char *cur;
1400 1402
1401 SockList sl (MAXSOCKBUF); 1403 packet sl;
1402 sl << "map "; 1404 sl << "map ";
1403 1405
1404 cur = (char *) compactlayer (ns, (unsigned char *) sl.buf + sl.len, MAP_LAYERS, newmap); 1406 cur = (char *) compactlayer (ns, (unsigned char *) sl.buf + sl.len, MAP_LAYERS, newmap);
1405 sl.len = cur - (char *) sl.buf; 1407 sl.len = cur - (char *) sl.buf;
1406 1408
1419 memcpy (&ns->lastmap, newmap, sizeof (struct Map)); 1421 memcpy (&ns->lastmap, newmap, sizeof (struct Map));
1420 Send_With_Handling (ns, &sl); 1422 Send_With_Handling (ns, &sl);
1421 ns->sent_scroll = 0; 1423 ns->sent_scroll = 0;
1422 } 1424 }
1423 1425
1424 sl.free ();
1425} 1426}
1426 1427
1427 1428
1428/** Clears a map cell */ 1429/** Clears a map cell */
1429static void 1430static void
1471 * needs to get sent - if so, it adds the data, sending the head 1472 * needs to get sent - if so, it adds the data, sending the head
1472 * if needed, and returning 1. If this no data needs to get 1473 * if needed, and returning 1. If this no data needs to get
1473 * sent, it returns zero. 1474 * sent, it returns zero.
1474 */ 1475 */
1475static int 1476static int
1476check_head (SockList &sl, NewSocket &ns, int ax, int ay, int layer) 1477check_head (packet &sl, NewSocket &ns, int ax, int ay, int layer)
1477{ 1478{
1478 short face_num; 1479 short face_num;
1479 1480
1480 if (heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]) 1481 if (heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer])
1481 face_num = heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]->face->number; 1482 face_num = heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]->face->number;
1482 else 1483 else
1483 face_num = 0; 1484 face_num = 0;
1484 1485
1485 if (face_num != ns.lastmap.cells[ax][ay].faces[layer]) 1486 if (face_num != ns.lastmap.cells[ax][ay].faces[layer])
1486 { 1487 {
1487 SockList_AddShort (&sl, face_num); 1488 sl << uint16 (face_num);
1488 if (face_num && !(ns.faces_sent[face_num] & NS_FACESENT_FACE)) 1489 if (face_num && !(ns.faces_sent[face_num] & NS_FACESENT_FACE))
1489 esrv_send_face (&ns, face_num, 0); 1490 esrv_send_face (&ns, face_num, 0);
1490 1491
1491 heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer] = NULL; 1492 heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer] = NULL;
1492 ns.lastmap.cells[ax][ay].faces[layer] = face_num; 1493 ns.lastmap.cells[ax][ay].faces[layer] = face_num;
1515 * the case, it seems to make more sense to have these layer values 1516 * the case, it seems to make more sense to have these layer values
1516 * actually match. 1517 * actually match.
1517 */ 1518 */
1518 1519
1519static int 1520static int
1520update_space (SockList &sl, NewSocket &ns, maptile *mp, int mx, int my, int sx, int sy, int layer) 1521update_space (packet &sl, NewSocket &ns, maptile *mp, int mx, int my, int sx, int sy, int layer)
1521{ 1522{
1522 object *ob, *head; 1523 object *ob, *head;
1523 uint16 face_num; 1524 uint16 face_num;
1524 int bx, by, i; 1525 int bx, by, i;
1525 1526
1738 * top layer (this matches what the GET_MAP_FACE and GET_MAP_FACE_OBJ 1739 * top layer (this matches what the GET_MAP_FACE and GET_MAP_FACE_OBJ
1739 * take. 1740 * take.
1740 */ 1741 */
1741 1742
1742static inline int 1743static inline int
1743update_smooth (SockList &sl, NewSocket &ns, maptile *mp, int mx, int my, int sx, int sy, int layer) 1744update_smooth (packet &sl, NewSocket &ns, maptile *mp, int mx, int my, int sx, int sy, int layer)
1744{ 1745{
1745 object *ob; 1746 object *ob;
1746 int smoothlevel; /* old face_num; */ 1747 int smoothlevel; /* old face_num; */
1747 1748
1748 ob = GET_MAP_FACE_OBJ (mp, mx, my, layer); 1749 ob = GET_MAP_FACE_OBJ (mp, mx, my, layer);
1832 1833
1833 NewSocket &socket = pl->contr->socket; 1834 NewSocket &socket = pl->contr->socket;
1834 1835
1835 check_map_change (pl->contr); 1836 check_map_change (pl->contr);
1836 1837
1837 SockList sl (MAXSOCKBUF); 1838 packet sl;
1838 SockList esl (MAXSOCKBUF); 1839 packet esl;
1839 1840
1840 sl << (socket.mapmode == Map1Cmd ? "map1 " : "map1a "); 1841 sl << (socket.mapmode == Map1Cmd ? "map1 " : "map1a ");
1841 startlen = sl.len; 1842 startlen = sl.len;
1842 1843
1843 /*Extendedmapinfo structure initialisation */ 1844 /*Extendedmapinfo structure initialisation */
2195 if (sl.len > startlen || socket.sent_scroll) 2196 if (sl.len > startlen || socket.sent_scroll)
2196 { 2197 {
2197 Send_With_Handling (&socket, &sl); 2198 Send_With_Handling (&socket, &sl);
2198 socket.sent_scroll = 0; 2199 socket.sent_scroll = 0;
2199 } 2200 }
2200
2201 sl.free ();
2202 esl.free ();
2203} 2201}
2204 2202
2205/** 2203/**
2206 * Draws client map. 2204 * Draws client map.
2207 */ 2205 */
2340 2338
2341/*****************************************************************************/ 2339/*****************************************************************************/
2342void 2340void
2343send_plugin_custom_message (object *pl, char *buf) 2341send_plugin_custom_message (object *pl, char *buf)
2344{ 2342{
2345 cs_write_string (&pl->contr->socket, buf, strlen (buf)); 2343 pl->contr->socket.send_packet (buf);
2346} 2344}
2347 2345
2348/** 2346/**
2349 * This sends the skill number to name mapping. We ignore 2347 * This sends the skill number to name mapping. We ignore
2350 * the params - we always send the same info no matter what. 2348 * the params - we always send the same info no matter what.
2351 */ 2349 */
2352void 2350void
2353send_skill_info (NewSocket *ns, char *params) 2351send_skill_info (NewSocket *ns, char *params)
2354{ 2352{
2355 SockList sl (MAXSOCKBUF); 2353 packet sl;
2356 sl << "replyinfo skill_info\n"; 2354 sl << "replyinfo skill_info\n";
2357 2355
2358 for (int i = 1; i < NUM_SKILLS; i++) 2356 for (int i = 1; i < NUM_SKILLS; i++)
2359 sl.printf ("%d:%s\n", i + CS_STAT_SKILLINFO, &skill_names[i]); 2357 sl.printf ("%d:%s\n", i + CS_STAT_SKILLINFO, &skill_names[i]);
2360 2358
2363 LOG (llevError, "Buffer overflow in send_skill_info!\n"); 2361 LOG (llevError, "Buffer overflow in send_skill_info!\n");
2364 fatal (0); 2362 fatal (0);
2365 } 2363 }
2366 2364
2367 Send_With_Handling (ns, &sl); 2365 Send_With_Handling (ns, &sl);
2368 sl.free ();
2369} 2366}
2370 2367
2371/** 2368/**
2372 * This sends the spell path to name mapping. We ignore 2369 * This sends the spell path to name mapping. We ignore
2373 * the params - we always send the same info no matter what. 2370 * the params - we always send the same info no matter what.
2374 */ 2371 */
2375void 2372void
2376send_spell_paths (NewSocket * ns, char *params) 2373send_spell_paths (NewSocket * ns, char *params)
2377{ 2374{
2378 SockList sl (MAXSOCKBUF); 2375 packet sl;
2379 2376
2380 sl << "replyinfo spell_paths\n"; 2377 sl << "replyinfo spell_paths\n";
2381 2378
2382 for (int i = 0; i < NRSPELLPATHS; i++) 2379 for (int i = 0; i < NRSPELLPATHS; i++)
2383 sl.printf ("%d:%s\n", 1 << i, spellpathnames[i]); 2380 sl.printf ("%d:%s\n", 1 << i, spellpathnames[i]);
2387 LOG (llevError, "Buffer overflow in send_spell_paths!\n"); 2384 LOG (llevError, "Buffer overflow in send_spell_paths!\n");
2388 fatal (0); 2385 fatal (0);
2389 } 2386 }
2390 2387
2391 Send_With_Handling (ns, &sl); 2388 Send_With_Handling (ns, &sl);
2392 sl.free ();
2393} 2389}
2394 2390
2395/** 2391/**
2396 * This looks for any spells the player may have that have changed their stats. 2392 * This looks for any spells the player may have that have changed their stats.
2397 * it then sends an updspell packet for each spell that has changed in this way 2393 * it then sends an updspell packet for each spell that has changed in this way
2427 flags |= UPD_SP_DAMAGE; 2423 flags |= UPD_SP_DAMAGE;
2428 } 2424 }
2429 2425
2430 if (flags) 2426 if (flags)
2431 { 2427 {
2432 SockList sl (MAXSOCKBUF); 2428 packet sl;
2433 2429
2434 sl << "updspell " 2430 sl << "updspell "
2435 << uint8 (flags) 2431 << uint8 (flags)
2436 << uint32 (spell->count); 2432 << uint32 (spell->count);
2437 2433
2438 if (flags & UPD_SP_MANA ) sl << uint16 (spell->last_sp); 2434 if (flags & UPD_SP_MANA ) sl << uint16 (spell->last_sp);
2439 if (flags & UPD_SP_GRACE ) sl << uint16 (spell->last_grace); 2435 if (flags & UPD_SP_GRACE ) sl << uint16 (spell->last_grace);
2440 if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->last_eat); 2436 if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->last_eat);
2441 2437
2442 Send_With_Handling (&pl->socket, &sl); 2438 Send_With_Handling (&pl->socket, &sl);
2443 sl.free ();
2444 } 2439 }
2445 } 2440 }
2446 } 2441 }
2447} 2442}
2448 2443
2456 { 2451 {
2457 LOG (llevError, "Invalid call to esrv_remove_spell"); 2452 LOG (llevError, "Invalid call to esrv_remove_spell");
2458 return; 2453 return;
2459 } 2454 }
2460 2455
2461 SockList sl (MAXSOCKBUF); 2456 packet sl;
2462 2457
2463 sl << "delspell " 2458 sl << "delspell "
2464 << uint32 (spell->count); 2459 << uint32 (spell->count);
2465 2460
2466 Send_With_Handling (&pl->socket, &sl); 2461 Send_With_Handling (&pl->socket, &sl);
2467 sl.free ();
2468} 2462}
2469 2463
2470/* appends the spell *spell to the Socklist we will send the data to. */ 2464/* appends the spell *spell to the Socklist we will send the data to. */
2471static void 2465static void
2472append_spell (player *pl, SockList &sl, object *spell) 2466append_spell (player *pl, packet &sl, object *spell)
2473{ 2467{
2474 int len, i, skill = 0; 2468 int len, i, skill = 0;
2475 2469
2476 if (!(spell->name)) 2470 if (!(spell->name))
2477 { 2471 {
2523 } 2517 }
2524 2518
2525 if (!pl->socket.monitor_spells) 2519 if (!pl->socket.monitor_spells)
2526 return; 2520 return;
2527 2521
2528 SockList sl (MAXSOCKBUF); 2522 packet sl;
2529 2523
2530 sl << "addspell "; 2524 sl << "addspell ";
2531 2525
2532 if (!spell) 2526 if (!spell)
2533 { 2527 {
2574 } 2568 }
2575 2569
2576 /* finally, we can send the packet */ 2570 /* finally, we can send the packet */
2577 Send_With_Handling (&pl->socket, &sl); 2571 Send_With_Handling (&pl->socket, &sl);
2578 2572
2579 sl.free ();
2580} 2573}
2581 2574

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines