… | |
… | |
399 | if (flags & UPD_FLAGS) |
399 | if (flags & UPD_FLAGS) |
400 | sl << uint32 (query_flags (op)); |
400 | sl << uint32 (query_flags (op)); |
401 | |
401 | |
402 | if (flags & UPD_WEIGHT) |
402 | if (flags & UPD_WEIGHT) |
403 | { |
403 | { |
404 | sint32 weight = op->flag [FLAG_NO_PICK] ? -1 : op->client_weight (); |
404 | sint32 weight = op->client_weight (); |
405 | |
405 | |
406 | if (op) |
406 | if (op == pl) |
407 | ns->last_weight = weight; |
407 | ns->last_weight = weight; |
408 | |
408 | |
409 | sl << uint32 (weight); |
409 | sl << uint32 (weight); |
410 | } |
410 | } |
411 | |
411 | |
… | |
… | |
418 | |
418 | |
419 | if (flags & UPD_NAME) |
419 | if (flags & UPD_NAME) |
420 | { |
420 | { |
421 | int len; |
421 | int len; |
422 | const char *item_p; |
422 | const char *item_p; |
423 | char item_n[MAX_BUF]; |
423 | char item_n[127 * 2]; |
424 | |
424 | |
425 | if (!op->custom_name) |
425 | if (!op->custom_name) |
426 | { |
426 | { |
427 | strncpy (item_n, query_base_name (op, 0), 127); |
427 | len = assign (item_n, query_base_name (op, 0), 127); |
428 | item_n[127] = 0; |
|
|
429 | len = strlen (item_n); |
|
|
430 | item_p = query_base_name (op, 1); |
428 | item_p = query_base_name (op, 1); |
431 | } |
429 | } |
432 | else |
430 | else |
433 | { |
431 | { |
434 | strncpy (item_n, op->custom_name, 127); |
432 | len = assign (item_n, &op->custom_name, 127); |
435 | item_n[127] = 0; |
|
|
436 | len = strlen (item_n); |
|
|
437 | item_p = op->custom_name; |
433 | item_p = &op->custom_name; |
438 | } |
434 | } |
439 | |
435 | |
440 | strncpy (item_n + len + 1, item_p, 127); |
436 | len += assign (item_n + len, item_p, 127); |
441 | item_n[254] = 0; |
|
|
442 | len += strlen (item_n + 1 + len) + 1; |
|
|
443 | |
437 | |
444 | sl << data8 (item_n, len); |
438 | sl << data8 (item_n, len); |
445 | } |
439 | } |
446 | |
440 | |
447 | if (flags & UPD_ANIM) |
441 | if (flags & UPD_ANIM) |
… | |
… | |
597 | |
591 | |
598 | if (object *op = esrv_get_ob_from_count (pl->ob, tag)) |
592 | if (object *op = esrv_get_ob_from_count (pl->ob, tag)) |
599 | { |
593 | { |
600 | std::string s = op->describe (pl->ob); |
594 | std::string s = op->describe (pl->ob); |
601 | |
595 | |
602 | if (msg_is_special (s.c_str (), false)) |
|
|
603 | cfperl_expand_cfpod (pl, s); |
|
|
604 | |
|
|
605 | packet sl ("ex"); |
596 | packet sl ("ex"); |
606 | sl << ber32 (tag) << s.c_str (); |
597 | sl << ber32 (tag) |
|
|
598 | << data (*pl->expand_cfpod (s.c_str ())); |
607 | |
599 | |
608 | pl->ns->send_packet (sl); |
600 | pl->ns->send_packet (sl); |
609 | } |
601 | } |
610 | } |
602 | } |
611 | |
603 | |
… | |
… | |
680 | * Tero.Haatanen@lut.fi ] |
672 | * Tero.Haatanen@lut.fi ] |
681 | */ |
673 | */ |
682 | static void |
674 | static void |
683 | look_at (player *pl, int dx, int dy) |
675 | look_at (player *pl, int dx, int dy) |
684 | { |
676 | { |
685 | dynbuf_text buf; |
677 | dynbuf_text &buf = msg_dynbuf; buf.clear (); |
686 | object *ob = pl->ob; |
678 | object *ob = pl->ob; |
687 | |
679 | |
688 | if (!pl->observe->map) |
680 | if (!pl->observe->map) |
689 | return; |
681 | return; |
690 | |
682 | |
|
|
683 | bool wiz = ob->flag [FLAG_WIZ] || ob->flag [FLAG_WIZLOOK]; |
|
|
684 | |
691 | mapxy pos (pl->observe); |
685 | mapxy pos (pl->observe); |
692 | pos.move (dx, dy); |
686 | pos.move (dx, dy); |
693 | |
687 | |
|
|
688 | if (wiz) |
|
|
689 | { |
694 | if (pos.normalise ()) |
690 | if (pos.normalise ()) |
|
|
691 | { |
|
|
692 | mapspace &ms = *pos; |
|
|
693 | ms.update (); |
|
|
694 | |
|
|
695 | buf.printf (" map: %s%+d%+d (%+d%+d)\n" |
|
|
696 | " smell %u/%u; flags %x; light %d; block %x; slow %x; on %x; off %x; volume %lld\n\n", |
|
|
697 | &pos.m->path, pos.x, pos.y, dx, dy, |
|
|
698 | (unsigned int)ms.smell, (unsigned int)mapspace::smellcount, ms.flags (), ms.light, |
|
|
699 | ms.move_block, ms.move_slow, ms.move_on, ms.move_off, (long long)ms.volume () |
|
|
700 | ); |
|
|
701 | } |
|
|
702 | else |
|
|
703 | buf << "off-map\n\n"; |
|
|
704 | } |
|
|
705 | |
|
|
706 | int darkness = pl->blocked_los (dx, dy); |
|
|
707 | |
|
|
708 | if (darkness == LOS_BLOCKED) |
|
|
709 | buf << "You cannot see that place from your position. H<Something is in between or it is too far away.>"; |
|
|
710 | else if (darkness == LOS_MAX) |
|
|
711 | buf << "That place is too dark to see anything. H<Move nearer or find better lighting.>"; |
|
|
712 | else |
|
|
713 | { |
|
|
714 | if (pos.normalise ()) |
695 | for (object *tmp = pos->top; tmp; tmp = tmp->below) |
715 | for (object *tmp = pos->top; tmp; tmp = tmp->below) |
696 | { |
716 | { |
697 | if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) |
717 | if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) |
698 | continue; |
718 | continue; |
699 | |
719 | |
700 | if (QUERY_FLAG (ob, FLAG_WIZ)) |
720 | if (wiz) |
701 | buf.printf ("- %s (%d).\n", query_name (tmp), tmp->count); |
721 | buf.printf (" - %s (%d).\n", query_name (tmp), tmp->count); |
702 | else |
722 | else |
703 | buf.printf ("- %s.\n", query_name (tmp)); |
723 | buf.printf (" - %s.\n", query_name (tmp)); |
704 | |
724 | |
705 | object *head = tmp->head_ (); |
725 | object *head = tmp->head_ (); |
706 | |
726 | |
707 | if (head->inv) |
727 | if (head->inv) |
708 | if ((head->type != CONTAINER && head->type != FLESH) |
728 | if ((head->type != CONTAINER && head->type != FLESH) |
709 | || QUERY_FLAG (ob, FLAG_WIZ)) |
729 | || QUERY_FLAG (ob, FLAG_WIZ)) |
710 | buf << head->query_inventory (ob, " "); |
730 | buf << head->query_inventory (ob, " "); |
711 | |
731 | |
712 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !QUERY_FLAG (ob, FLAG_WIZ)) /* don't continue under the floor */ |
732 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !wiz) /* don't continue under the floor */ |
713 | break; |
733 | break; |
|
|
734 | } |
714 | } |
735 | } |
715 | |
736 | |
716 | if (buf.empty ()) |
737 | if (buf.empty ()) |
717 | pl->failmsg ("You see nothing there."); |
738 | buf << "You see nothing there."; |
718 | else |
739 | |
719 | pl->infobox (MSG_CHANNEL ("lookat"), buf); |
740 | pl->infobox (MSG_CHANNEL ("lookat"), buf); |
720 | } |
741 | } |
721 | |
742 | |
722 | /** Client wants to look at some object. Lets do so. */ |
743 | /** Client wants to look at some object. Lets do so. */ |
723 | void |
744 | void |
724 | LookAt (char *buf, int len, player *pl) |
745 | LookAt (char *buf, int len, player *pl) |
… | |
… | |
728 | int dx = atoi (buf); |
749 | int dx = atoi (buf); |
729 | if (!(cp = strchr (buf, ' '))) |
750 | if (!(cp = strchr (buf, ' '))) |
730 | return; |
751 | return; |
731 | |
752 | |
732 | int dy = atoi (cp); |
753 | int dy = atoi (cp); |
733 | |
|
|
734 | if (player *opl = pl->observe->contr) |
|
|
735 | if (client *ns = opl->ns) |
|
|
736 | { |
|
|
737 | if (fabs (dx) > ns->mapx / 2 || fabs (dy) > ns->mapy / 2) |
|
|
738 | return; |
|
|
739 | |
|
|
740 | if (opl->blocked_los[dx + ns->mapx / 2][dy + ns->mapy / 2]) |
|
|
741 | return; |
|
|
742 | } |
|
|
743 | |
754 | |
744 | look_at (pl, dx, dy); |
755 | look_at (pl, dx, dy); |
745 | } |
756 | } |
746 | |
757 | |
747 | /** Move an object to a new location */ |
758 | /** Move an object to a new location */ |