… | |
… | |
265 | flags = query_flags (head); |
265 | flags = query_flags (head); |
266 | if (QUERY_FLAG (head, FLAG_NO_PICK)) |
266 | if (QUERY_FLAG (head, FLAG_NO_PICK)) |
267 | flags |= F_NOPICK; |
267 | flags |= F_NOPICK; |
268 | |
268 | |
269 | ns.send_face (head->face); |
269 | ns.send_face (head->face); |
|
|
270 | ns.flush_fx (); |
270 | |
271 | |
271 | if (QUERY_FLAG (head, FLAG_ANIMATE) && !ns.anims_sent[head->animation_id]) |
272 | if (QUERY_FLAG (head, FLAG_ANIMATE) && !ns.anims_sent[head->animation_id]) |
272 | ns.send_animation (head->animation_id); |
273 | ns.send_animation (head->animation_id); |
273 | |
274 | |
274 | sl << uint32 (head->count) |
275 | sl << uint32 (head->count) |
… | |
… | |
356 | sl.printf ("item%d ", pl->contr->ns->itemcmd); |
357 | sl.printf ("item%d ", pl->contr->ns->itemcmd); |
357 | |
358 | |
358 | sl << uint32 (0); |
359 | sl << uint32 (0); |
359 | |
360 | |
360 | pl->contr->ns->send_face (empty_face); |
361 | pl->contr->ns->send_face (empty_face); |
|
|
362 | pl->contr->ns->flush_fx (); |
361 | |
363 | |
362 | if (pl->contr->ns->look_position) |
364 | if (pl->contr->ns->look_position) |
363 | { |
365 | { |
364 | char buf[80]; |
366 | char buf[80]; |
365 | snprintf (buf, 80, "Apply this to see %d previous items", FLOORBOX_PAGESIZE); |
367 | snprintf (buf, 80, "Apply this to see %d previous items", FLOORBOX_PAGESIZE); |
… | |
… | |
554 | } |
556 | } |
555 | |
557 | |
556 | if (flags & UPD_FACE) |
558 | if (flags & UPD_FACE) |
557 | { |
559 | { |
558 | ns->send_face (op->face); |
560 | ns->send_face (op->face); |
|
|
561 | ns->flush_fx (); |
559 | sl << uint32 (op->face); |
562 | sl << uint32 (op->face); |
560 | } |
563 | } |
561 | |
564 | |
562 | if (flags & UPD_NAME) |
565 | if (flags & UPD_NAME) |
563 | { |
566 | { |
… | |
… | |
688 | |
691 | |
689 | /** |
692 | /** |
690 | * Takes a player and object count (tag) and returns the actual object |
693 | * Takes a player and object count (tag) and returns the actual object |
691 | * pointer, or null if it can't be found. |
694 | * pointer, or null if it can't be found. |
692 | */ |
695 | */ |
693 | |
|
|
694 | object * |
696 | object * |
695 | esrv_get_ob_from_count (object *pl, tag_t count) |
697 | esrv_get_ob_from_count (object *pl, tag_t count) |
696 | { |
698 | { |
697 | object *op, *tmp; |
|
|
698 | |
|
|
699 | if (pl->count == count) |
699 | if (pl->count == count) |
700 | return pl; |
700 | return pl; |
701 | |
701 | |
702 | for (op = pl->inv; op; op = op->below) |
702 | for (object *op = pl->inv; op; op = op->below) |
703 | if (op->count == count) |
703 | if (op->count == count) |
704 | return op; |
704 | return op; |
705 | else if (op->type == CONTAINER && pl->container == op) |
705 | else if (op->type == CONTAINER && pl->container == op) |
706 | for (tmp = op->inv; tmp; tmp = tmp->below) |
706 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
707 | if (tmp->count == count) |
707 | if (tmp->count == count) |
708 | return tmp; |
708 | return tmp; |
709 | |
709 | |
710 | for (op = GET_MAP_OB (pl->map, pl->x, pl->y); op; op = op->above) |
710 | for (object *op = GET_MAP_OB (pl->map, pl->x, pl->y); op; op = op->above) |
711 | if (op->head && op->head->count == count) |
711 | if (op->head && op->head->count == count) |
712 | return op; |
712 | return op; |
713 | else if (op->count == count) |
713 | else if (op->count == count) |
714 | return op; |
714 | return op; |
715 | else if (op->type == CONTAINER && pl->container == op) |
715 | else if (op->type == CONTAINER && pl->container == op) |
716 | for (tmp = op->inv; tmp; tmp = tmp->below) |
716 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
717 | if (tmp->count == count) |
717 | if (tmp->count == count) |
718 | return tmp; |
718 | return tmp; |
719 | |
719 | |
|
|
720 | #if 0 |
|
|
721 | /* If the high bit is set, player examined a pseudo object. */ |
|
|
722 | if (count & 0x80000000) |
|
|
723 | return 0; |
|
|
724 | #endif |
|
|
725 | |
720 | return 0; |
726 | return 0; |
721 | } |
727 | } |
722 | |
728 | |
723 | |
|
|
724 | /** Client wants to examine some object. So lets do so. */ |
729 | /** Client wants to examine some object. So lets do so. */ |
725 | void |
730 | void |
726 | ExamineCmd (char *buf, int len, player *pl) |
731 | ExamineCmd (char *buf, int len, player *pl) |
727 | { |
732 | { |
728 | tag_t tag = atoi (buf); |
733 | tag_t tag = atoi (buf); |
729 | |
|
|
730 | /* If the high bit is set, player examined a pseudo object. */ |
|
|
731 | if (tag & 0x80000000) |
|
|
732 | return; |
|
|
733 | |
734 | |
734 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
735 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
735 | |
736 | |
736 | if (!op) |
737 | if (!op) |
737 | { |
738 | { |
738 | LOG (llevDebug, "Player '%s' tried to examine the unknown object (%ld)\n", &pl->ob->name, tag); |
739 | LOG (llevDebug, "Player '%s' tried to examine the unknown object (%ld)\n", &pl->ob->name, tag); |
739 | return; |
740 | return; |
740 | } |
741 | } |
741 | |
742 | |
742 | examine (pl->ob, op); |
743 | examine (pl->ob, op); |
|
|
744 | } |
|
|
745 | |
|
|
746 | /** Client wants to examine some object. So lets do so. */ |
|
|
747 | void |
|
|
748 | ExCmd (char *buf, int len, player *pl) |
|
|
749 | { |
|
|
750 | tag_t tag = atoi (buf); |
|
|
751 | |
|
|
752 | if (object *op = esrv_get_ob_from_count (pl->ob, tag)) |
|
|
753 | { |
|
|
754 | std::string s = op->describe (pl->ob); |
|
|
755 | |
|
|
756 | packet sl ("ex"); |
|
|
757 | sl << ber32 (tag) << s.c_str (); |
|
|
758 | |
|
|
759 | pl->ns->send_packet (sl); |
|
|
760 | } |
743 | } |
761 | } |
744 | |
762 | |
745 | /** Client wants to apply some object. Lets do so. */ |
763 | /** Client wants to apply some object. Lets do so. */ |
746 | void |
764 | void |
747 | ApplyCmd (char *buf, int len, player *pl) |
765 | ApplyCmd (char *buf, int len, player *pl) |
… | |
… | |
834 | |
852 | |
835 | m = get_map_from_coord (op->map, &x, &y); |
853 | m = get_map_from_coord (op->map, &x, &y); |
836 | if (!m) |
854 | if (!m) |
837 | return; |
855 | return; |
838 | |
856 | |
839 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL && tmp->above != NULL; tmp = tmp->above); |
857 | for (tmp = GET_MAP_OB (m, x, y); tmp && tmp->above; tmp = tmp->above) |
|
|
858 | ; |
840 | |
859 | |
841 | for (; tmp != NULL; tmp = tmp->below) |
860 | for (; tmp; tmp = tmp->below) |
842 | { |
861 | { |
843 | if (tmp->invisible && !QUERY_FLAG (op, FLAG_WIZ)) |
862 | if (tmp->invisible && !QUERY_FLAG (op, FLAG_WIZ)) |
844 | continue; |
863 | continue; |
845 | |
864 | |
846 | if (!flag) |
865 | if (!flag) |
… | |
… | |
884 | int dx, dy; |
903 | int dx, dy; |
885 | char *cp; |
904 | char *cp; |
886 | |
905 | |
887 | dx = atoi (buf); |
906 | dx = atoi (buf); |
888 | if (!(cp = strchr (buf, ' '))) |
907 | if (!(cp = strchr (buf, ' '))) |
889 | { |
|
|
890 | return; |
908 | return; |
891 | } |
909 | |
892 | dy = atoi (cp); |
910 | dy = atoi (cp); |
893 | |
|
|
894 | if (fabs (dx) > pl->ns->mapx / 2 || fabs (dy) > pl->ns->mapy / 2) |
911 | if (fabs (dx) > pl->ns->mapx / 2 || fabs (dy) > pl->ns->mapy / 2) |
895 | return; |
912 | return; |
896 | |
913 | |
897 | if (pl->blocked_los[dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2]) |
914 | if (pl->blocked_los[dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2]) |
898 | return; |
915 | return; |