… | |
… | |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | /** |
25 | /** |
… | |
… | |
164 | sl << uint8 (anim_speed) |
165 | sl << uint8 (anim_speed) |
165 | << uint32 (head->nrof); |
166 | << uint32 (head->nrof); |
166 | |
167 | |
167 | if (ns.itemcmd == 2) |
168 | if (ns.itemcmd == 2) |
168 | sl << uint16 (head->client_type); |
169 | sl << uint16 (head->client_type); |
169 | |
|
|
170 | SET_FLAG (head, FLAG_CLIENT_SENT); |
|
|
171 | } |
170 | } |
172 | |
171 | |
173 | static faceidx |
172 | static faceidx |
174 | need_face_now (player *pl, const char *name) |
173 | need_face_now (player *pl, const char *name) |
175 | { |
174 | { |
… | |
… | |
385 | |
384 | |
386 | client *ns = pl->contr->ns; |
385 | client *ns = pl->contr->ns; |
387 | if (!ns) |
386 | if (!ns) |
388 | return; |
387 | return; |
389 | |
388 | |
390 | if (!QUERY_FLAG (op, FLAG_CLIENT_SENT)) |
|
|
391 | /* FLAG_CLIENT_SENT is debug only. We are using it to see where |
|
|
392 | * this is happening - we can set a breakpoint here in the debugger |
|
|
393 | * and track back the call. |
|
|
394 | */ |
|
|
395 | LOG (llevDebug | logBacktrace, "We have not sent item %s (%d)\n", &op->name, op->count); |
|
|
396 | |
|
|
397 | packet sl ("upditem"); |
389 | packet sl ("upditem"); |
398 | |
390 | |
399 | sl << uint8 (flags); |
391 | sl << uint8 (flags); |
400 | |
392 | |
401 | op = op->head_ (); |
393 | op = op->head_ (); |
… | |
… | |
408 | if (flags & UPD_FLAGS) |
400 | if (flags & UPD_FLAGS) |
409 | sl << uint32 (query_flags (op)); |
401 | sl << uint32 (query_flags (op)); |
410 | |
402 | |
411 | if (flags & UPD_WEIGHT) |
403 | if (flags & UPD_WEIGHT) |
412 | { |
404 | { |
413 | sint32 weight = op->flag [FLAG_NO_PICK] ? -1 : op->client_weight (); |
405 | sint32 weight = op->client_weight (); |
414 | |
406 | |
415 | if (op) |
407 | if (op == pl) |
416 | ns->last_weight = weight; |
408 | ns->last_weight = weight; |
417 | |
409 | |
418 | sl << uint32 (weight); |
410 | sl << uint32 (weight); |
419 | } |
411 | } |
420 | |
412 | |
… | |
… | |
427 | |
419 | |
428 | if (flags & UPD_NAME) |
420 | if (flags & UPD_NAME) |
429 | { |
421 | { |
430 | int len; |
422 | int len; |
431 | const char *item_p; |
423 | const char *item_p; |
432 | char item_n[MAX_BUF]; |
424 | char item_n[127 * 2]; |
433 | |
425 | |
434 | if (!op->custom_name) |
426 | if (!op->custom_name) |
435 | { |
427 | { |
436 | strncpy (item_n, query_base_name (op, 0), 127); |
428 | len = assign (item_n, query_base_name (op, 0), 127); |
437 | item_n[127] = 0; |
|
|
438 | len = strlen (item_n); |
|
|
439 | item_p = query_base_name (op, 1); |
429 | item_p = query_base_name (op, 1); |
440 | } |
430 | } |
441 | else |
431 | else |
442 | { |
432 | { |
443 | strncpy (item_n, op->custom_name, 127); |
433 | len = assign (item_n, &op->custom_name, 127); |
444 | item_n[127] = 0; |
|
|
445 | len = strlen (item_n); |
|
|
446 | item_p = op->custom_name; |
434 | item_p = &op->custom_name; |
447 | } |
435 | } |
448 | |
436 | |
449 | strncpy (item_n + len + 1, item_p, 127); |
437 | len += assign (item_n + len, item_p, 127); |
450 | item_n[254] = 0; |
|
|
451 | len += strlen (item_n + 1 + len) + 1; |
|
|
452 | |
438 | |
453 | sl << data8 (item_n, len); |
439 | sl << data8 (item_n, len); |
454 | } |
440 | } |
455 | |
441 | |
456 | if (flags & UPD_ANIM) |
442 | if (flags & UPD_ANIM) |
… | |
… | |
509 | sl << uint32 (op->env ? op->env->count : 0); |
495 | sl << uint32 (op->env ? op->env->count : 0); |
510 | |
496 | |
511 | add_object_to_socklist (*pl->contr->ns, sl, op); |
497 | add_object_to_socklist (*pl->contr->ns, sl, op); |
512 | |
498 | |
513 | pl->contr->ns->send_packet (sl); |
499 | pl->contr->ns->send_packet (sl); |
514 | SET_FLAG (op, FLAG_CLIENT_SENT); |
|
|
515 | } |
500 | } |
516 | |
501 | |
517 | /** |
502 | /** |
518 | * Tells the client to delete an item. |
503 | * Tells the client to delete an item. |
519 | */ |
504 | */ |
… | |
… | |
607 | |
592 | |
608 | if (object *op = esrv_get_ob_from_count (pl->ob, tag)) |
593 | if (object *op = esrv_get_ob_from_count (pl->ob, tag)) |
609 | { |
594 | { |
610 | std::string s = op->describe (pl->ob); |
595 | std::string s = op->describe (pl->ob); |
611 | |
596 | |
612 | if (msg_is_special (s.c_str (), false)) |
|
|
613 | cfperl_expand_cfpod (pl, s); |
|
|
614 | |
|
|
615 | packet sl ("ex"); |
597 | packet sl ("ex"); |
616 | sl << ber32 (tag) << s.c_str (); |
598 | sl << ber32 (tag) |
|
|
599 | << data (*pl->expand_cfpod (s.c_str ())); |
617 | |
600 | |
618 | pl->ns->send_packet (sl); |
601 | pl->ns->send_packet (sl); |
619 | } |
602 | } |
620 | } |
603 | } |
621 | |
604 | |
… | |
… | |
690 | * Tero.Haatanen@lut.fi ] |
673 | * Tero.Haatanen@lut.fi ] |
691 | */ |
674 | */ |
692 | static void |
675 | static void |
693 | look_at (player *pl, int dx, int dy) |
676 | look_at (player *pl, int dx, int dy) |
694 | { |
677 | { |
695 | dynbuf_text buf; |
678 | dynbuf_text &buf = msg_dynbuf; buf.clear (); |
696 | object *ob = pl->ob; |
679 | object *ob = pl->ob; |
697 | |
680 | |
698 | if (!pl->observe->map) |
681 | if (!pl->observe->map) |
699 | return; |
682 | return; |
700 | |
683 | |
|
|
684 | bool wiz = ob->flag [FLAG_WIZ] || ob->flag [FLAG_WIZLOOK]; |
|
|
685 | |
701 | mapxy pos (pl->observe); |
686 | mapxy pos (pl->observe); |
702 | pos.move (dx, dy); |
687 | pos.move (dx, dy); |
703 | |
688 | |
|
|
689 | if (wiz) |
|
|
690 | { |
704 | if (pos.normalise ()) |
691 | if (pos.normalise ()) |
|
|
692 | { |
|
|
693 | mapspace &ms = *pos; |
|
|
694 | ms.update (); |
|
|
695 | |
|
|
696 | buf.printf (" map: %s%+d%+d (%+d%+d)\n" |
|
|
697 | " smell %u/%u; flags %x; light %d; block %x; slow %x; on %x; off %x; volume %lld\n\n", |
|
|
698 | &pos.m->path, pos.x, pos.y, dx, dy, |
|
|
699 | (unsigned int)ms.smell, (unsigned int)mapspace::smellcount, ms.flags (), ms.light, |
|
|
700 | ms.move_block, ms.move_slow, ms.move_on, ms.move_off, (long long)ms.volume () |
|
|
701 | ); |
|
|
702 | } |
|
|
703 | else |
|
|
704 | buf << "off-map\n\n"; |
|
|
705 | } |
|
|
706 | |
|
|
707 | int darkness = pl->blocked_los (dx, dy); |
|
|
708 | |
|
|
709 | if (darkness == LOS_BLOCKED) |
|
|
710 | buf << "You cannot see that place from your position. H<Something is in between or it is too far away.>"; |
|
|
711 | else if (darkness == LOS_MAX) |
|
|
712 | buf << "That place is too dark to see anything. H<Move nearer or find better lighting.>"; |
|
|
713 | else |
|
|
714 | { |
|
|
715 | if (pos.normalise ()) |
705 | for (object *tmp = pos->top; tmp; tmp = tmp->below) |
716 | for (object *tmp = pos->top; tmp; tmp = tmp->below) |
706 | { |
717 | { |
707 | if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) |
718 | if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) |
708 | continue; |
719 | continue; |
709 | |
720 | |
710 | if (QUERY_FLAG (ob, FLAG_WIZ)) |
721 | if (wiz) |
711 | buf.printf ("- %s (%d).\n", query_name (tmp), tmp->count); |
722 | buf.printf (" - %s (%d).\n", query_name (tmp), tmp->count); |
712 | else |
723 | else |
713 | buf.printf ("- %s.\n", query_name (tmp)); |
724 | buf.printf (" - %s.\n", query_name (tmp)); |
714 | |
725 | |
715 | object *head = tmp->head_ (); |
726 | object *head = tmp->head_ (); |
716 | |
727 | |
717 | if (head->inv) |
728 | if (head->inv) |
718 | if ((head->type != CONTAINER && head->type != FLESH) |
729 | if ((head->type != CONTAINER && head->type != FLESH) |
719 | || QUERY_FLAG (ob, FLAG_WIZ)) |
730 | || QUERY_FLAG (ob, FLAG_WIZ)) |
720 | buf << head->query_inventory (ob, " "); |
731 | buf << head->query_inventory (ob, " "); |
721 | |
732 | |
722 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !QUERY_FLAG (ob, FLAG_WIZ)) /* don't continue under the floor */ |
733 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !wiz) /* don't continue under the floor */ |
723 | break; |
734 | break; |
|
|
735 | } |
724 | } |
736 | } |
725 | |
737 | |
726 | if (buf.empty ()) |
738 | if (buf.empty ()) |
727 | pl->failmsg ("You see nothing there."); |
739 | buf << "You see nothing there."; |
728 | else |
740 | |
729 | pl->infobox (MSG_CHANNEL ("lookat"), buf); |
741 | pl->infobox (MSG_CHANNEL ("lookat"), buf); |
730 | } |
742 | } |
731 | |
743 | |
732 | /** Client wants to look at some object. Lets do so. */ |
744 | /** Client wants to look at some object. Lets do so. */ |
733 | void |
745 | void |
734 | LookAt (char *buf, int len, player *pl) |
746 | LookAt (char *buf, int len, player *pl) |
… | |
… | |
738 | int dx = atoi (buf); |
750 | int dx = atoi (buf); |
739 | if (!(cp = strchr (buf, ' '))) |
751 | if (!(cp = strchr (buf, ' '))) |
740 | return; |
752 | return; |
741 | |
753 | |
742 | int dy = atoi (cp); |
754 | int dy = atoi (cp); |
743 | |
|
|
744 | if (player *opl = pl->observe->contr) |
|
|
745 | if (client *ns = opl->ns) |
|
|
746 | { |
|
|
747 | if (fabs (dx) > ns->mapx / 2 || fabs (dy) > ns->mapy / 2) |
|
|
748 | return; |
|
|
749 | |
|
|
750 | if (opl->blocked_los[dx + ns->mapx / 2][dy + ns->mapy / 2]) |
|
|
751 | return; |
|
|
752 | } |
|
|
753 | |
755 | |
754 | look_at (pl, dx, dy); |
756 | look_at (pl, dx, dy); |
755 | } |
757 | } |
756 | |
758 | |
757 | /** Move an object to a new location */ |
759 | /** Move an object to a new location */ |