… | |
… | |
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 */ |
323 | void |
323 | void |
324 | SetUp (char *buf, int len, NewSocket * ns) |
324 | SetUp (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 */ |
561 | void |
567 | void |
… | |
… | |
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. |
… | |
… | |
785 | void |
790 | void |
786 | NewPlayerCmd (uint8 * buf, int len, player *pl) |
791 | NewPlayerCmd (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 = net_uint16 (buf); |
803 | pktlen = net_uint16 (buf); |
799 | repeat = net_uint32 (buf + 2); |
804 | repeat = net_uint32 (buf + 2); |
800 | |
805 | |
801 | /* -1 is special - no repeat, but don't update */ |
806 | /* -1 is special - no repeat, but don't update */ |
802 | if (repeat != -1) |
807 | if (repeat != -1) |
803 | pl->count = repeat; |
808 | pl->count = repeat; |
… | |
… | |
837 | else |
842 | else |
838 | time = (int) (MAX_TIME / FABS (pl->ob->speed)); |
843 | time = (int) (MAX_TIME / FABS (pl->ob->speed)); |
839 | |
844 | |
840 | /* Send confirmation of command execution now */ |
845 | /* Send confirmation of command execution now */ |
841 | |
846 | |
842 | SockList sl (MAXSOCKBUF); |
847 | packet sl; |
843 | sl << "comc " << uint16 (packet) << uint32 (time); |
848 | sl << "comc " << uint16 (pktlen) << uint32 (time); |
844 | Send_With_Handling (&pl->socket, &sl); |
849 | Send_With_Handling (&pl->socket, &sl); |
845 | sl.free (); |
|
|
846 | } |
850 | } |
847 | |
851 | |
848 | |
852 | |
849 | /** This is a reply to a previous query. */ |
853 | /** This is a reply to a previous query. */ |
850 | void |
854 | void |
… | |
… | |
966 | */ |
970 | */ |
967 | if (ns->sc_version < 1026) |
971 | if (ns->sc_version < 1026) |
968 | { |
972 | { |
969 | sprintf (version_warning, "drawinfo %d %s", NDI_RED, |
973 | sprintf (version_warning, "drawinfo %d %s", NDI_RED, |
970 | "**** VERSION WARNING ****\n**** CLIENT IS TOO OLD!! UPDATE THE CLIENT!! ****"); |
974 | "**** VERSION WARNING ****\n**** CLIENT IS TOO OLD!! UPDATE THE CLIENT!! ****"); |
971 | Write_String_To_Socket (ns, version_warning, strlen (version_warning)); |
975 | ns->send_packet (version_warning); |
972 | } |
976 | } |
973 | |
977 | |
974 | } |
978 | } |
975 | } |
979 | } |
976 | |
980 | |
… | |
… | |
1048 | send_query (NewSocket * ns, uint8 flags, char *text) |
1052 | send_query (NewSocket * ns, uint8 flags, char *text) |
1049 | { |
1053 | { |
1050 | char buf[MAX_BUF]; |
1054 | char buf[MAX_BUF]; |
1051 | |
1055 | |
1052 | sprintf (buf, "query %d %s", flags, text ? text : ""); |
1056 | sprintf (buf, "query %d %s", flags, text ? text : ""); |
1053 | Write_String_To_Socket (ns, buf, strlen (buf)); |
1057 | ns->send_packet (buf); |
1054 | } |
1058 | } |
1055 | |
1059 | |
1056 | #define AddIfInt64(Old,New,Type) if (Old != New) {\ |
1060 | #define AddIfInt64(Old,New,Type) if (Old != New) {\ |
1057 | Old = New; \ |
1061 | Old = New; \ |
1058 | sl << uint8 (Type) << uint64 (New); \ |
1062 | sl << uint8 (Type) << uint64 (New); \ |
… | |
… | |
1088 | esrv_update_stats (player *pl) |
1092 | esrv_update_stats (player *pl) |
1089 | { |
1093 | { |
1090 | char buf[MAX_BUF]; |
1094 | char buf[MAX_BUF]; |
1091 | uint16 flags; |
1095 | uint16 flags; |
1092 | |
1096 | |
1093 | SockList sl (MAXSOCKBUF); |
1097 | packet sl; |
1094 | sl << "stats "; |
1098 | sl << "stats "; |
1095 | |
1099 | |
1096 | if (pl->ob != NULL) |
1100 | if (pl->ob != NULL) |
1097 | { |
1101 | { |
1098 | 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); |
… | |
… | |
1188 | LOG (llevDebug, "Sending stats command, %d bytes long.\n", sl.len); |
1192 | LOG (llevDebug, "Sending stats command, %d bytes long.\n", sl.len); |
1189 | #endif |
1193 | #endif |
1190 | Send_With_Handling (&pl->socket, &sl); |
1194 | Send_With_Handling (&pl->socket, &sl); |
1191 | } |
1195 | } |
1192 | |
1196 | |
1193 | sl.free (); |
|
|
1194 | } |
1197 | } |
1195 | |
1198 | |
1196 | /** |
1199 | /** |
1197 | * 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. |
1198 | */ |
1201 | */ |
1199 | void |
1202 | void |
1200 | esrv_new_player (player *pl, uint32 weight) |
1203 | esrv_new_player (player *pl, uint32 weight) |
1201 | { |
1204 | { |
1202 | pl->last_weight = weight; |
1205 | pl->last_weight = weight; |
1203 | |
1206 | |
1204 | SockList sl (MAXSOCKBUF); |
1207 | packet sl; |
1205 | sl << "player "; |
1208 | sl << "player "; |
1206 | |
1209 | |
1207 | sl << uint32 (pl->ob->count) |
1210 | sl << uint32 (pl->ob->count) |
1208 | << uint32 (weight) |
1211 | << uint32 (weight) |
1209 | << uint32 (pl->ob->face->number) |
1212 | << uint32 (pl->ob->face->number) |
1210 | << data8 (pl->ob->name); |
1213 | << data8 (pl->ob->name); |
1211 | |
1214 | |
1212 | Send_With_Handling (&pl->socket, &sl); |
1215 | Send_With_Handling (&pl->socket, &sl); |
1213 | sl.free (); |
|
|
1214 | SET_FLAG (pl->ob, FLAG_CLIENT_SENT); |
1216 | SET_FLAG (pl->ob, FLAG_CLIENT_SENT); |
1215 | } |
1217 | } |
1216 | |
1218 | |
1217 | /** |
1219 | /** |
1218 | * Need to send an animation sequence to the client. |
1220 | * Need to send an animation sequence to the client. |
… | |
… | |
1234 | { |
1236 | { |
1235 | 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); |
1236 | return; |
1238 | return; |
1237 | } |
1239 | } |
1238 | |
1240 | |
1239 | SockList sl (MAXSOCKBUF); |
1241 | packet sl; |
1240 | |
1242 | |
1241 | sl << "anim " |
1243 | sl << "anim " |
1242 | << uint16 (anim_num) |
1244 | << uint16 (anim_num) |
1243 | << uint16 (0); /* flags - not used right now */ |
1245 | << uint16 (0); /* flags - not used right now */ |
1244 | |
1246 | |
… | |
… | |
1251 | esrv_send_face (ns, animations[anim_num].faces[i], 0); |
1253 | esrv_send_face (ns, animations[anim_num].faces[i], 0); |
1252 | 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 */ |
1253 | } |
1255 | } |
1254 | |
1256 | |
1255 | Send_With_Handling (ns, &sl); |
1257 | Send_With_Handling (ns, &sl); |
1256 | sl.free (); |
|
|
1257 | |
1258 | |
1258 | ns->anims_sent[anim_num] = 1; |
1259 | ns->anims_sent[anim_num] = 1; |
1259 | } |
1260 | } |
1260 | |
1261 | |
1261 | |
1262 | |
… | |
… | |
1397 | esrv_map_doneredraw (NewSocket * ns, struct Map *newmap) |
1398 | esrv_map_doneredraw (NewSocket * ns, struct Map *newmap) |
1398 | { |
1399 | { |
1399 | static long frames, bytes, tbytes, tframes; |
1400 | static long frames, bytes, tbytes, tframes; |
1400 | char *cur; |
1401 | char *cur; |
1401 | |
1402 | |
1402 | SockList sl (MAXSOCKBUF); |
1403 | packet sl; |
1403 | sl << "map "; |
1404 | sl << "map "; |
1404 | |
1405 | |
1405 | 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); |
1406 | sl.len = cur - (char *) sl.buf; |
1407 | sl.len = cur - (char *) sl.buf; |
1407 | |
1408 | |
… | |
… | |
1420 | memcpy (&ns->lastmap, newmap, sizeof (struct Map)); |
1421 | memcpy (&ns->lastmap, newmap, sizeof (struct Map)); |
1421 | Send_With_Handling (ns, &sl); |
1422 | Send_With_Handling (ns, &sl); |
1422 | ns->sent_scroll = 0; |
1423 | ns->sent_scroll = 0; |
1423 | } |
1424 | } |
1424 | |
1425 | |
1425 | sl.free (); |
|
|
1426 | } |
1426 | } |
1427 | |
1427 | |
1428 | |
1428 | |
1429 | /** Clears a map cell */ |
1429 | /** Clears a map cell */ |
1430 | static void |
1430 | static void |
… | |
… | |
1472 | * 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 |
1473 | * 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 |
1474 | * sent, it returns zero. |
1474 | * sent, it returns zero. |
1475 | */ |
1475 | */ |
1476 | static int |
1476 | static int |
1477 | check_head (SockList &sl, NewSocket &ns, int ax, int ay, int layer) |
1477 | check_head (packet &sl, NewSocket &ns, int ax, int ay, int layer) |
1478 | { |
1478 | { |
1479 | short face_num; |
1479 | short face_num; |
1480 | |
1480 | |
1481 | if (heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]) |
1481 | if (heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]) |
1482 | 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; |
… | |
… | |
1516 | * 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 |
1517 | * actually match. |
1517 | * actually match. |
1518 | */ |
1518 | */ |
1519 | |
1519 | |
1520 | static int |
1520 | static int |
1521 | update_space (SockList &sl, NewSocket &ns, maptile *mp, int mx, int my, int sx, int sy, int layer) |
1521 | update_space (packet &sl, NewSocket &ns, maptile *mp, int mx, int my, int sx, int sy, int layer) |
1522 | { |
1522 | { |
1523 | object *ob, *head; |
1523 | object *ob, *head; |
1524 | uint16 face_num; |
1524 | uint16 face_num; |
1525 | int bx, by, i; |
1525 | int bx, by, i; |
1526 | |
1526 | |
… | |
… | |
1739 | * 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 |
1740 | * take. |
1740 | * take. |
1741 | */ |
1741 | */ |
1742 | |
1742 | |
1743 | static inline int |
1743 | static inline int |
1744 | update_smooth (SockList &sl, NewSocket &ns, maptile *mp, int mx, int my, int sx, int sy, int layer) |
1744 | update_smooth (packet &sl, NewSocket &ns, maptile *mp, int mx, int my, int sx, int sy, int layer) |
1745 | { |
1745 | { |
1746 | object *ob; |
1746 | object *ob; |
1747 | int smoothlevel; /* old face_num; */ |
1747 | int smoothlevel; /* old face_num; */ |
1748 | |
1748 | |
1749 | ob = GET_MAP_FACE_OBJ (mp, mx, my, layer); |
1749 | ob = GET_MAP_FACE_OBJ (mp, mx, my, layer); |
… | |
… | |
1833 | |
1833 | |
1834 | NewSocket &socket = pl->contr->socket; |
1834 | NewSocket &socket = pl->contr->socket; |
1835 | |
1835 | |
1836 | check_map_change (pl->contr); |
1836 | check_map_change (pl->contr); |
1837 | |
1837 | |
1838 | SockList sl (MAXSOCKBUF); |
1838 | packet sl; |
1839 | SockList esl (MAXSOCKBUF); |
1839 | packet esl; |
1840 | |
1840 | |
1841 | sl << (socket.mapmode == Map1Cmd ? "map1 " : "map1a "); |
1841 | sl << (socket.mapmode == Map1Cmd ? "map1 " : "map1a "); |
1842 | startlen = sl.len; |
1842 | startlen = sl.len; |
1843 | |
1843 | |
1844 | /*Extendedmapinfo structure initialisation */ |
1844 | /*Extendedmapinfo structure initialisation */ |
… | |
… | |
2196 | if (sl.len > startlen || socket.sent_scroll) |
2196 | if (sl.len > startlen || socket.sent_scroll) |
2197 | { |
2197 | { |
2198 | Send_With_Handling (&socket, &sl); |
2198 | Send_With_Handling (&socket, &sl); |
2199 | socket.sent_scroll = 0; |
2199 | socket.sent_scroll = 0; |
2200 | } |
2200 | } |
2201 | |
|
|
2202 | sl.free (); |
|
|
2203 | esl.free (); |
|
|
2204 | } |
2201 | } |
2205 | |
2202 | |
2206 | /** |
2203 | /** |
2207 | * Draws client map. |
2204 | * Draws client map. |
2208 | */ |
2205 | */ |
… | |
… | |
2341 | |
2338 | |
2342 | /*****************************************************************************/ |
2339 | /*****************************************************************************/ |
2343 | void |
2340 | void |
2344 | send_plugin_custom_message (object *pl, char *buf) |
2341 | send_plugin_custom_message (object *pl, char *buf) |
2345 | { |
2342 | { |
2346 | cs_write_string (&pl->contr->socket, buf, strlen (buf)); |
2343 | pl->contr->socket.send_packet (buf); |
2347 | } |
2344 | } |
2348 | |
2345 | |
2349 | /** |
2346 | /** |
2350 | * This sends the skill number to name mapping. We ignore |
2347 | * This sends the skill number to name mapping. We ignore |
2351 | * the params - we always send the same info no matter what. |
2348 | * the params - we always send the same info no matter what. |
2352 | */ |
2349 | */ |
2353 | void |
2350 | void |
2354 | send_skill_info (NewSocket *ns, char *params) |
2351 | send_skill_info (NewSocket *ns, char *params) |
2355 | { |
2352 | { |
2356 | SockList sl (MAXSOCKBUF); |
2353 | packet sl; |
2357 | sl << "replyinfo skill_info\n"; |
2354 | sl << "replyinfo skill_info\n"; |
2358 | |
2355 | |
2359 | for (int i = 1; i < NUM_SKILLS; i++) |
2356 | for (int i = 1; i < NUM_SKILLS; i++) |
2360 | 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]); |
2361 | |
2358 | |
… | |
… | |
2364 | LOG (llevError, "Buffer overflow in send_skill_info!\n"); |
2361 | LOG (llevError, "Buffer overflow in send_skill_info!\n"); |
2365 | fatal (0); |
2362 | fatal (0); |
2366 | } |
2363 | } |
2367 | |
2364 | |
2368 | Send_With_Handling (ns, &sl); |
2365 | Send_With_Handling (ns, &sl); |
2369 | sl.free (); |
|
|
2370 | } |
2366 | } |
2371 | |
2367 | |
2372 | /** |
2368 | /** |
2373 | * This sends the spell path to name mapping. We ignore |
2369 | * This sends the spell path to name mapping. We ignore |
2374 | * the params - we always send the same info no matter what. |
2370 | * the params - we always send the same info no matter what. |
2375 | */ |
2371 | */ |
2376 | void |
2372 | void |
2377 | send_spell_paths (NewSocket * ns, char *params) |
2373 | send_spell_paths (NewSocket * ns, char *params) |
2378 | { |
2374 | { |
2379 | SockList sl (MAXSOCKBUF); |
2375 | packet sl; |
2380 | |
2376 | |
2381 | sl << "replyinfo spell_paths\n"; |
2377 | sl << "replyinfo spell_paths\n"; |
2382 | |
2378 | |
2383 | for (int i = 0; i < NRSPELLPATHS; i++) |
2379 | for (int i = 0; i < NRSPELLPATHS; i++) |
2384 | sl.printf ("%d:%s\n", 1 << i, spellpathnames[i]); |
2380 | sl.printf ("%d:%s\n", 1 << i, spellpathnames[i]); |
… | |
… | |
2388 | LOG (llevError, "Buffer overflow in send_spell_paths!\n"); |
2384 | LOG (llevError, "Buffer overflow in send_spell_paths!\n"); |
2389 | fatal (0); |
2385 | fatal (0); |
2390 | } |
2386 | } |
2391 | |
2387 | |
2392 | Send_With_Handling (ns, &sl); |
2388 | Send_With_Handling (ns, &sl); |
2393 | sl.free (); |
|
|
2394 | } |
2389 | } |
2395 | |
2390 | |
2396 | /** |
2391 | /** |
2397 | * 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. |
2398 | * 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 |
… | |
… | |
2428 | flags |= UPD_SP_DAMAGE; |
2423 | flags |= UPD_SP_DAMAGE; |
2429 | } |
2424 | } |
2430 | |
2425 | |
2431 | if (flags) |
2426 | if (flags) |
2432 | { |
2427 | { |
2433 | SockList sl (MAXSOCKBUF); |
2428 | packet sl; |
2434 | |
2429 | |
2435 | sl << "updspell " |
2430 | sl << "updspell " |
2436 | << uint8 (flags) |
2431 | << uint8 (flags) |
2437 | << uint32 (spell->count); |
2432 | << uint32 (spell->count); |
2438 | |
2433 | |
2439 | if (flags & UPD_SP_MANA ) sl << uint16 (spell->last_sp); |
2434 | if (flags & UPD_SP_MANA ) sl << uint16 (spell->last_sp); |
2440 | if (flags & UPD_SP_GRACE ) sl << uint16 (spell->last_grace); |
2435 | if (flags & UPD_SP_GRACE ) sl << uint16 (spell->last_grace); |
2441 | if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->last_eat); |
2436 | if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->last_eat); |
2442 | |
2437 | |
2443 | Send_With_Handling (&pl->socket, &sl); |
2438 | Send_With_Handling (&pl->socket, &sl); |
2444 | sl.free (); |
|
|
2445 | } |
2439 | } |
2446 | } |
2440 | } |
2447 | } |
2441 | } |
2448 | } |
2442 | } |
2449 | |
2443 | |
… | |
… | |
2457 | { |
2451 | { |
2458 | LOG (llevError, "Invalid call to esrv_remove_spell"); |
2452 | LOG (llevError, "Invalid call to esrv_remove_spell"); |
2459 | return; |
2453 | return; |
2460 | } |
2454 | } |
2461 | |
2455 | |
2462 | SockList sl (MAXSOCKBUF); |
2456 | packet sl; |
2463 | |
2457 | |
2464 | sl << "delspell " |
2458 | sl << "delspell " |
2465 | << uint32 (spell->count); |
2459 | << uint32 (spell->count); |
2466 | |
2460 | |
2467 | Send_With_Handling (&pl->socket, &sl); |
2461 | Send_With_Handling (&pl->socket, &sl); |
2468 | sl.free (); |
|
|
2469 | } |
2462 | } |
2470 | |
2463 | |
2471 | /* 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. */ |
2472 | static void |
2465 | static void |
2473 | append_spell (player *pl, SockList &sl, object *spell) |
2466 | append_spell (player *pl, packet &sl, object *spell) |
2474 | { |
2467 | { |
2475 | int len, i, skill = 0; |
2468 | int len, i, skill = 0; |
2476 | |
2469 | |
2477 | if (!(spell->name)) |
2470 | if (!(spell->name)) |
2478 | { |
2471 | { |
… | |
… | |
2524 | } |
2517 | } |
2525 | |
2518 | |
2526 | if (!pl->socket.monitor_spells) |
2519 | if (!pl->socket.monitor_spells) |
2527 | return; |
2520 | return; |
2528 | |
2521 | |
2529 | SockList sl (MAXSOCKBUF); |
2522 | packet sl; |
2530 | |
2523 | |
2531 | sl << "addspell "; |
2524 | sl << "addspell "; |
2532 | |
2525 | |
2533 | if (!spell) |
2526 | if (!spell) |
2534 | { |
2527 | { |
… | |
… | |
2575 | } |
2568 | } |
2576 | |
2569 | |
2577 | /* finally, we can send the packet */ |
2570 | /* finally, we can send the packet */ |
2578 | Send_With_Handling (&pl->socket, &sl); |
2571 | Send_With_Handling (&pl->socket, &sl); |
2579 | |
2572 | |
2580 | sl.free (); |
|
|
2581 | } |
2573 | } |
2582 | |
2574 | |