… | |
… | |
704 | ns->faces_sent[face] |= NS_FACESENT_SMOOTH; |
704 | ns->faces_sent[face] |= NS_FACESENT_SMOOTH; |
705 | |
705 | |
706 | sl.buf = reply; |
706 | sl.buf = reply; |
707 | strcpy ((char *) sl.buf, "smooth "); |
707 | strcpy ((char *) sl.buf, "smooth "); |
708 | sl.len = strlen ((char *) sl.buf); |
708 | sl.len = strlen ((char *) sl.buf); |
709 | SockList_AddShort (&sl, face); |
709 | |
710 | SockList_AddShort (&sl, smoothface); |
710 | sl << uint16 (face) << uint16 (smoothface); |
|
|
711 | |
711 | Send_With_Handling (ns, &sl); |
712 | Send_With_Handling (ns, &sl); |
712 | } |
713 | } |
713 | |
714 | |
714 | /** |
715 | /** |
715 | * Tells client the picture it has to use |
716 | * Tells client the picture it has to use |
… | |
… | |
840 | |
841 | |
841 | /* Send confirmation of command execution now */ |
842 | /* Send confirmation of command execution now */ |
842 | sl.buf = command; |
843 | sl.buf = command; |
843 | strcpy ((char *) sl.buf, "comc "); |
844 | strcpy ((char *) sl.buf, "comc "); |
844 | sl.len = 5; |
845 | sl.len = 5; |
845 | SockList_AddShort (&sl, packet); |
846 | |
846 | if (FABS (pl->ob->speed) < 0.001) |
847 | if (FABS (pl->ob->speed) < 0.001) |
847 | time = MAX_TIME * 100; |
848 | time = MAX_TIME * 100; |
848 | else |
849 | else |
849 | time = (int) (MAX_TIME / FABS (pl->ob->speed)); |
850 | time = (int) (MAX_TIME / FABS (pl->ob->speed)); |
850 | SockList_AddInt (&sl, time); |
851 | |
|
|
852 | sl << uint16 (packet) << uint32 (time); |
|
|
853 | |
851 | Send_With_Handling (&pl->socket, &sl); |
854 | Send_With_Handling (&pl->socket, &sl); |
852 | } |
855 | } |
853 | |
856 | |
854 | |
857 | |
855 | /** This is a reply to a previous query. */ |
858 | /** This is a reply to a previous query. */ |
… | |
… | |
2082 | if (socket.extmap) |
2085 | if (socket.extmap) |
2083 | { |
2086 | { |
2084 | uint8 stat_hp = 0; |
2087 | uint8 stat_hp = 0; |
2085 | uint8 stat_width = 0; |
2088 | uint8 stat_width = 0; |
2086 | uint8 flags = 0; |
2089 | uint8 flags = 0; |
2087 | tag_t player = 0; |
2090 | UUID player = 0; |
2088 | |
2091 | |
2089 | // send hp information, if applicable |
2092 | // send hp information, if applicable |
2090 | if (object *op = GET_MAP_FACE_OBJ (m, nx, ny, 0)) |
2093 | if (object *op = GET_MAP_FACE_OBJ (m, nx, ny, 0)) |
2091 | { |
2094 | { |
2092 | if (op->head || op->invisible) |
2095 | if (op->head || op->invisible) |
… | |
… | |
2113 | lastcell.stat_hp = stat_hp; |
2116 | lastcell.stat_hp = stat_hp; |
2114 | |
2117 | |
2115 | mask |= 0x8; |
2118 | mask |= 0x8; |
2116 | *last_ext |= 0x80; |
2119 | *last_ext |= 0x80; |
2117 | last_ext = sl.buf + sl.len; |
2120 | last_ext = sl.buf + sl.len; |
2118 | SockList_AddChar (&sl, 5); |
2121 | |
2119 | SockList_AddChar (&sl, stat_hp); |
2122 | sl << uint8 (5) << uint8 (stat_hp); |
2120 | |
2123 | |
2121 | if (stat_width > 1) |
2124 | if (stat_width > 1) |
2122 | { |
2125 | { |
2123 | *last_ext |= 0x80; |
2126 | *last_ext |= 0x80; |
2124 | last_ext = sl.buf + sl.len; |
2127 | last_ext = sl.buf + sl.len; |
2125 | SockList_AddChar (&sl, 6); |
2128 | |
2126 | SockList_AddChar (&sl, stat_width); |
2129 | sl << uint8 (6) << uint8 (stat_width); |
2127 | } |
2130 | } |
2128 | } |
2131 | } |
2129 | |
2132 | |
2130 | if (lastcell.player != player) |
2133 | if (lastcell.player != player) |
2131 | { |
2134 | { |
2132 | lastcell.player = player; |
2135 | lastcell.player = player; |
2133 | |
2136 | |
2134 | mask |= 0x8; |
2137 | mask |= 0x8; |
2135 | *last_ext |= 0x80; |
2138 | *last_ext |= 0x80; |
2136 | last_ext = sl.buf + sl.len; |
2139 | last_ext = sl.buf + sl.len; |
2137 | SockList_AddChar (&sl, 0x47); |
2140 | |
2138 | SockList_AddChar (&sl, 4); |
2141 | sl << uint8 (0x47) << uint8 (8) << (uint64)player; |
2139 | SockList_AddInt (&sl, player); |
|
|
2140 | } |
2142 | } |
2141 | |
2143 | |
2142 | if (lastcell.flags != flags) |
2144 | if (lastcell.flags != flags) |
2143 | { |
2145 | { |
2144 | lastcell.flags = flags; |
2146 | lastcell.flags = flags; |
2145 | |
2147 | |
2146 | mask |= 0x8; |
2148 | mask |= 0x8; |
2147 | *last_ext |= 0x80; |
2149 | *last_ext |= 0x80; |
2148 | last_ext = sl.buf + sl.len; |
2150 | last_ext = sl.buf + sl.len; |
2149 | SockList_AddChar (&sl, 8); |
2151 | |
2150 | SockList_AddChar (&sl, flags); |
2152 | sl << uint8 (8) << uint8 (flags); |
2151 | } |
2153 | } |
2152 | } |
2154 | } |
2153 | |
2155 | |
2154 | /* Floor face */ |
2156 | /* Floor face */ |
2155 | if (update_space (&sl, &socket, m, nx, ny, ax, ay, 2)) |
2157 | if (update_space (&sl, &socket, m, nx, ny, ax, ay, 2)) |
… | |
… | |
2175 | mask |= 0x1; |
2177 | mask |= 0x1; |
2176 | |
2178 | |
2177 | if (!(socket.faces_sent[pl->face->number] & NS_FACESENT_FACE)) |
2179 | if (!(socket.faces_sent[pl->face->number] & NS_FACESENT_FACE)) |
2178 | esrv_send_face (&socket, pl->face->number, 0); |
2180 | esrv_send_face (&socket, pl->face->number, 0); |
2179 | |
2181 | |
2180 | SockList_AddShort (&sl, pl->face->number); |
2182 | sl << uint16 (pl->face->number); |
2181 | } |
2183 | } |
2182 | } |
2184 | } |
2183 | else |
2185 | else |
2184 | { |
2186 | { |
2185 | /* Top face */ |
2187 | /* Top face */ |
… | |
… | |
2464 | if (flags != 0) |
2466 | if (flags != 0) |
2465 | { |
2467 | { |
2466 | sl.buf = (unsigned char *) malloc (MAXSOCKBUF); |
2468 | sl.buf = (unsigned char *) malloc (MAXSOCKBUF); |
2467 | strcpy ((char *) sl.buf, "updspell "); |
2469 | strcpy ((char *) sl.buf, "updspell "); |
2468 | sl.len = strlen ((char *) sl.buf); |
2470 | sl.len = strlen ((char *) sl.buf); |
2469 | SockList_AddChar (&sl, flags); |
2471 | |
2470 | SockList_AddInt (&sl, spell->count); |
2472 | sl << uint8 (flags) << uint32 (spell->count); |
2471 | if (flags & UPD_SP_MANA) |
2473 | |
2472 | SockList_AddShort (&sl, spell->last_sp); |
2474 | if (flags & UPD_SP_MANA ) sl << uint16 (spell->last_sp); |
2473 | if (flags & UPD_SP_GRACE) |
2475 | if (flags & UPD_SP_GRACE ) sl << uint16 (spell->last_grace); |
2474 | SockList_AddShort (&sl, spell->last_grace); |
2476 | if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->last_eat); |
2475 | if (flags & UPD_SP_DAMAGE) |
2477 | |
2476 | SockList_AddShort (&sl, spell->last_eat); |
|
|
2477 | flags = 0; |
2478 | flags = 0; |
2478 | Send_With_Handling (&pl->socket, &sl); |
2479 | Send_With_Handling (&pl->socket, &sl); |
2479 | free (sl.buf); |
2480 | free (sl.buf); |
2480 | } |
2481 | } |
2481 | } |
2482 | } |
… | |
… | |
2495 | return; |
2496 | return; |
2496 | } |
2497 | } |
2497 | sl.buf = (unsigned char *) malloc (MAXSOCKBUF); |
2498 | sl.buf = (unsigned char *) malloc (MAXSOCKBUF); |
2498 | strcpy ((char *) sl.buf, "delspell "); |
2499 | strcpy ((char *) sl.buf, "delspell "); |
2499 | sl.len = strlen ((char *) sl.buf); |
2500 | sl.len = strlen ((char *) sl.buf); |
2500 | SockList_AddInt (&sl, spell->count); |
2501 | |
|
|
2502 | sl << uint32 (spell->count); |
|
|
2503 | |
2501 | Send_With_Handling (&pl->socket, &sl); |
2504 | Send_With_Handling (&pl->socket, &sl); |
2502 | free (sl.buf); |
2505 | free (sl.buf); |
2503 | } |
2506 | } |
2504 | |
2507 | |
2505 | /* appends the spell *spell to the Socklist we will send the data to. */ |
2508 | /* appends the spell *spell to the Socklist we will send the data to. */ |
2506 | static void |
2509 | static void |
2507 | append_spell (player *pl, SockList * sl, object *spell) |
2510 | append_spell (player *pl, SockList &sl, object *spell) |
2508 | { |
2511 | { |
2509 | int len, i, skill = 0; |
2512 | int len, i, skill = 0; |
2510 | |
2513 | |
2511 | if (!(spell->name)) |
2514 | if (!(spell->name)) |
2512 | { |
2515 | { |
2513 | LOG (llevError, "item number %d is a spell with no name.\n", spell->count); |
2516 | LOG (llevError, "item number %d is a spell with no name.\n", spell->count); |
2514 | return; |
2517 | return; |
2515 | } |
2518 | } |
2516 | SockList_AddInt (sl, spell->count); |
2519 | |
2517 | SockList_AddShort (sl, spell->level); |
|
|
2518 | SockList_AddShort (sl, spell->casting_time); |
|
|
2519 | /* store costs and damage in the object struct, to compare to later */ |
2520 | /* store costs and damage in the object struct, to compare to later */ |
2520 | spell->last_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
2521 | spell->last_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
2521 | spell->last_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
2522 | spell->last_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
2522 | spell->last_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
2523 | spell->last_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
2523 | /* send the current values */ |
|
|
2524 | SockList_AddShort (sl, spell->last_sp); |
|
|
2525 | SockList_AddShort (sl, spell->last_grace); |
|
|
2526 | SockList_AddShort (sl, spell->last_eat); |
|
|
2527 | |
2524 | |
2528 | /* figure out which skill it uses, if it uses one */ |
2525 | /* figure out which skill it uses, if it uses one */ |
2529 | if (spell->skill) |
2526 | if (spell->skill) |
2530 | { |
2527 | { |
2531 | for (i = 1; i < NUM_SKILLS; i++) |
2528 | for (i = 1; i < NUM_SKILLS; i++) |
… | |
… | |
2533 | { |
2530 | { |
2534 | skill = i + CS_STAT_SKILLINFO; |
2531 | skill = i + CS_STAT_SKILLINFO; |
2535 | break; |
2532 | break; |
2536 | } |
2533 | } |
2537 | } |
2534 | } |
2538 | SockList_AddChar (sl, skill); |
|
|
2539 | |
2535 | |
2540 | SockList_AddInt (sl, spell->path_attuned); |
2536 | /* send the current values */ |
|
|
2537 | sl << uint32 (spell->count) |
|
|
2538 | << uint16 (spell->level) |
|
|
2539 | << uint16 (spell->casting_time) |
|
|
2540 | << uint16 (spell->last_sp) |
|
|
2541 | << uint16 (spell->last_grace) |
|
|
2542 | << uint16 (spell->last_eat) |
|
|
2543 | << uint8 (skill) |
|
|
2544 | << uint32 (spell->path_attuned) |
2541 | SockList_AddInt (sl, (spell->face) ? spell->face->number : 0); |
2545 | << uint32 (spell->face ? spell->face->number : 0) |
2542 | |
2546 | << data8 (spell->name) |
2543 | len = strlen (spell->name); |
2547 | << data16 (spell->msg); |
2544 | SockList_AddChar (sl, (char) len); |
|
|
2545 | memcpy (sl->buf + sl->len, spell->name, len); |
|
|
2546 | sl->len += len; |
|
|
2547 | |
|
|
2548 | if (!spell->msg) |
|
|
2549 | { |
|
|
2550 | SockList_AddShort (sl, 0); |
|
|
2551 | } |
|
|
2552 | else |
|
|
2553 | { |
|
|
2554 | len = strlen (spell->msg); |
|
|
2555 | SockList_AddShort (sl, len); |
|
|
2556 | memcpy (sl->buf + sl->len, spell->msg, len); |
|
|
2557 | sl->len += len; |
|
|
2558 | } |
|
|
2559 | } |
2548 | } |
2560 | |
2549 | |
2561 | /** |
2550 | /** |
2562 | * This tells the client to add the spell *ob, if *ob is NULL, then add |
2551 | * This tells the client to add the spell *ob, if *ob is NULL, then add |
2563 | * all spells in the player's inventory. |
2552 | * all spells in the player's inventory. |
… | |
… | |
2594 | * is hundreds of bytes off, so correcting 22 vs 26 doesn't seem |
2583 | * is hundreds of bytes off, so correcting 22 vs 26 doesn't seem |
2595 | * like it will fix this |
2584 | * like it will fix this |
2596 | */ |
2585 | */ |
2597 | if (spell->type != SPELL) |
2586 | if (spell->type != SPELL) |
2598 | continue; |
2587 | continue; |
|
|
2588 | |
2599 | if (sl.len >= (MAXSOCKBUF - (26 + strlen (spell->name) + (spell->msg ? strlen (spell->msg) : 0)))) |
2589 | if (sl.len >= (MAXSOCKBUF - (26 + strlen (spell->name) + (spell->msg ? strlen (spell->msg) : 0)))) |
2600 | { |
2590 | { |
2601 | Send_With_Handling (&pl->socket, &sl); |
2591 | Send_With_Handling (&pl->socket, &sl); |
2602 | strcpy ((char *) sl.buf, "addspell "); |
2592 | strcpy ((char *) sl.buf, "addspell "); |
2603 | sl.len = strlen ((char *) sl.buf); |
2593 | sl.len = strlen ((char *) sl.buf); |
2604 | } |
2594 | } |
|
|
2595 | |
2605 | append_spell (pl, &sl, spell); |
2596 | append_spell (pl, sl, spell); |
2606 | } |
2597 | } |
2607 | } |
2598 | } |
2608 | else if (spell->type != SPELL) |
2599 | else if (spell->type != SPELL) |
2609 | { |
2600 | { |
2610 | LOG (llevError, "Asked to send a non-spell object as a spell"); |
2601 | LOG (llevError, "Asked to send a non-spell object as a spell"); |
2611 | return; |
2602 | return; |
2612 | } |
2603 | } |
2613 | else |
2604 | else |
2614 | append_spell (pl, &sl, spell); |
2605 | append_spell (pl, sl, spell); |
|
|
2606 | |
2615 | if (sl.len >= MAXSOCKBUF) |
2607 | if (sl.len >= MAXSOCKBUF) |
2616 | { |
2608 | { |
2617 | LOG (llevError, "Buffer overflow in esrv_add_spells!\n"); |
2609 | LOG (llevError, "Buffer overflow in esrv_add_spells!\n"); |
2618 | fatal (0); |
2610 | fatal (0); |
2619 | } |
2611 | } |
|
|
2612 | |
2620 | /* finally, we can send the packet */ |
2613 | /* finally, we can send the packet */ |
2621 | Send_With_Handling (&pl->socket, &sl); |
2614 | Send_With_Handling (&pl->socket, &sl); |
2622 | free (sl.buf); |
2615 | free (sl.buf); |
2623 | } |
2616 | } |