… | |
… | |
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 | /** |
… | |
… | |
399 | if (flags & UPD_FLAGS) |
400 | if (flags & UPD_FLAGS) |
400 | sl << uint32 (query_flags (op)); |
401 | sl << uint32 (query_flags (op)); |
401 | |
402 | |
402 | if (flags & UPD_WEIGHT) |
403 | if (flags & UPD_WEIGHT) |
403 | { |
404 | { |
404 | sint32 weight = op->flag [FLAG_NO_PICK] ? -1 : op->client_weight (); |
405 | sint32 weight = op->client_weight (); |
405 | |
406 | |
406 | if (op) |
407 | if (op == pl) |
407 | ns->last_weight = weight; |
408 | ns->last_weight = weight; |
408 | |
409 | |
409 | sl << uint32 (weight); |
410 | sl << uint32 (weight); |
410 | } |
411 | } |
411 | |
412 | |
… | |
… | |
418 | |
419 | |
419 | if (flags & UPD_NAME) |
420 | if (flags & UPD_NAME) |
420 | { |
421 | { |
421 | int len; |
422 | int len; |
422 | const char *item_p; |
423 | const char *item_p; |
423 | char item_n[MAX_BUF]; |
424 | char item_n[127 * 2]; |
424 | |
425 | |
425 | if (!op->custom_name) |
426 | if (!op->custom_name) |
426 | { |
427 | { |
427 | strncpy (item_n, query_base_name (op, 0), 127); |
428 | 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); |
429 | item_p = query_base_name (op, 1); |
431 | } |
430 | } |
432 | else |
431 | else |
433 | { |
432 | { |
434 | strncpy (item_n, op->custom_name, 127); |
433 | len = assign (item_n, &op->custom_name, 127); |
435 | item_n[127] = 0; |
|
|
436 | len = strlen (item_n); |
|
|
437 | item_p = op->custom_name; |
434 | item_p = &op->custom_name; |
438 | } |
435 | } |
439 | |
436 | |
440 | strncpy (item_n + len + 1, item_p, 127); |
437 | len += assign (item_n + len, item_p, 127); |
441 | item_n[254] = 0; |
|
|
442 | len += strlen (item_n + 1 + len) + 1; |
|
|
443 | |
438 | |
444 | sl << data8 (item_n, len); |
439 | sl << data8 (item_n, len); |
445 | } |
440 | } |
446 | |
441 | |
447 | if (flags & UPD_ANIM) |
442 | if (flags & UPD_ANIM) |
… | |
… | |
678 | * Tero.Haatanen@lut.fi ] |
673 | * Tero.Haatanen@lut.fi ] |
679 | */ |
674 | */ |
680 | static void |
675 | static void |
681 | look_at (player *pl, int dx, int dy) |
676 | look_at (player *pl, int dx, int dy) |
682 | { |
677 | { |
683 | dynbuf_text buf; |
678 | dynbuf_text &buf = msg_dynbuf; buf.clear (); |
684 | object *ob = pl->ob; |
679 | object *ob = pl->ob; |
685 | |
680 | |
686 | if (!pl->observe->map) |
681 | if (!pl->observe->map) |
687 | return; |
682 | return; |
688 | |
683 | |
|
|
684 | bool wiz = ob->flag [FLAG_WIZ] || ob->flag [FLAG_WIZLOOK]; |
|
|
685 | |
689 | mapxy pos (pl->observe); |
686 | mapxy pos (pl->observe); |
690 | pos.move (dx, dy); |
687 | pos.move (dx, dy); |
691 | |
688 | |
|
|
689 | if (wiz) |
|
|
690 | { |
692 | 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 ()) |
693 | for (object *tmp = pos->top; tmp; tmp = tmp->below) |
716 | for (object *tmp = pos->top; tmp; tmp = tmp->below) |
694 | { |
717 | { |
695 | if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) |
718 | if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) |
696 | continue; |
719 | continue; |
697 | |
720 | |
698 | if (QUERY_FLAG (ob, FLAG_WIZ)) |
721 | if (wiz) |
699 | buf.printf (" - %s (%d).\n", query_name (tmp), tmp->count); |
722 | buf.printf (" - %s (%d).\n", query_name (tmp), tmp->count); |
700 | else |
723 | else |
701 | buf.printf (" - %s.\n", query_name (tmp)); |
724 | buf.printf (" - %s.\n", query_name (tmp)); |
702 | |
725 | |
703 | object *head = tmp->head_ (); |
726 | object *head = tmp->head_ (); |
704 | |
727 | |
705 | if (head->inv) |
728 | if (head->inv) |
706 | if ((head->type != CONTAINER && head->type != FLESH) |
729 | if ((head->type != CONTAINER && head->type != FLESH) |
707 | || QUERY_FLAG (ob, FLAG_WIZ)) |
730 | || QUERY_FLAG (ob, FLAG_WIZ)) |
708 | buf << head->query_inventory (ob, " "); |
731 | buf << head->query_inventory (ob, " "); |
709 | |
732 | |
710 | 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 */ |
711 | break; |
734 | break; |
|
|
735 | } |
712 | } |
736 | } |
713 | |
737 | |
714 | if (buf.empty ()) |
738 | if (buf.empty ()) |
715 | pl->failmsg ("You see nothing there."); |
739 | buf << "You see nothing there."; |
716 | else |
740 | |
717 | pl->infobox (MSG_CHANNEL ("lookat"), buf); |
741 | pl->infobox (MSG_CHANNEL ("lookat"), buf); |
718 | } |
742 | } |
719 | |
743 | |
720 | /** Client wants to look at some object. Lets do so. */ |
744 | /** Client wants to look at some object. Lets do so. */ |
721 | void |
745 | void |
722 | LookAt (char *buf, int len, player *pl) |
746 | LookAt (char *buf, int len, player *pl) |
… | |
… | |
726 | int dx = atoi (buf); |
750 | int dx = atoi (buf); |
727 | if (!(cp = strchr (buf, ' '))) |
751 | if (!(cp = strchr (buf, ' '))) |
728 | return; |
752 | return; |
729 | |
753 | |
730 | int dy = atoi (cp); |
754 | int dy = atoi (cp); |
731 | |
|
|
732 | if (player *opl = pl->observe->contr) |
|
|
733 | if (client *ns = opl->ns) |
|
|
734 | { |
|
|
735 | if (fabs (dx) > ns->mapx / 2 || fabs (dy) > ns->mapy / 2) |
|
|
736 | return; |
|
|
737 | |
|
|
738 | if (opl->blocked_los[dx + ns->mapx / 2][dy + ns->mapy / 2]) |
|
|
739 | return; |
|
|
740 | } |
|
|
741 | |
755 | |
742 | look_at (pl, dx, dy); |
756 | look_at (pl, dx, dy); |
743 | } |
757 | } |
744 | |
758 | |
745 | /** Move an object to a new location */ |
759 | /** Move an object to a new location */ |