… | |
… | |
164 | sl << uint8 (anim_speed) |
164 | sl << uint8 (anim_speed) |
165 | << uint32 (head->nrof); |
165 | << uint32 (head->nrof); |
166 | |
166 | |
167 | if (ns.itemcmd == 2) |
167 | if (ns.itemcmd == 2) |
168 | sl << uint16 (head->client_type); |
168 | sl << uint16 (head->client_type); |
169 | |
|
|
170 | SET_FLAG (head, FLAG_CLIENT_SENT); |
|
|
171 | } |
169 | } |
172 | |
170 | |
173 | static faceidx |
171 | static faceidx |
174 | need_face_now (player *pl, const char *name) |
172 | need_face_now (player *pl, const char *name) |
175 | { |
173 | { |
… | |
… | |
385 | |
383 | |
386 | client *ns = pl->contr->ns; |
384 | client *ns = pl->contr->ns; |
387 | if (!ns) |
385 | if (!ns) |
388 | return; |
386 | return; |
389 | |
387 | |
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"); |
388 | packet sl ("upditem"); |
398 | |
389 | |
399 | sl << uint8 (flags); |
390 | sl << uint8 (flags); |
400 | |
391 | |
401 | op = op->head_ (); |
392 | op = op->head_ (); |
… | |
… | |
408 | if (flags & UPD_FLAGS) |
399 | if (flags & UPD_FLAGS) |
409 | sl << uint32 (query_flags (op)); |
400 | sl << uint32 (query_flags (op)); |
410 | |
401 | |
411 | if (flags & UPD_WEIGHT) |
402 | if (flags & UPD_WEIGHT) |
412 | { |
403 | { |
413 | sint32 weight = op->flag [FLAG_NO_PICK] ? -1 : op->client_weight (); |
404 | sint32 weight = op->client_weight (); |
414 | |
405 | |
415 | if (op) |
406 | if (op == pl) |
416 | ns->last_weight = weight; |
407 | ns->last_weight = weight; |
417 | |
408 | |
418 | sl << uint32 (weight); |
409 | sl << uint32 (weight); |
419 | } |
410 | } |
420 | |
411 | |
… | |
… | |
509 | sl << uint32 (op->env ? op->env->count : 0); |
500 | sl << uint32 (op->env ? op->env->count : 0); |
510 | |
501 | |
511 | add_object_to_socklist (*pl->contr->ns, sl, op); |
502 | add_object_to_socklist (*pl->contr->ns, sl, op); |
512 | |
503 | |
513 | pl->contr->ns->send_packet (sl); |
504 | pl->contr->ns->send_packet (sl); |
514 | SET_FLAG (op, FLAG_CLIENT_SENT); |
|
|
515 | } |
505 | } |
516 | |
506 | |
517 | /** |
507 | /** |
518 | * Tells the client to delete an item. |
508 | * Tells the client to delete an item. |
519 | */ |
509 | */ |
… | |
… | |
607 | |
597 | |
608 | if (object *op = esrv_get_ob_from_count (pl->ob, tag)) |
598 | if (object *op = esrv_get_ob_from_count (pl->ob, tag)) |
609 | { |
599 | { |
610 | std::string s = op->describe (pl->ob); |
600 | std::string s = op->describe (pl->ob); |
611 | |
601 | |
612 | if (msg_is_special (s.c_str (), false)) |
|
|
613 | cfperl_expand_cfpod (pl, s); |
|
|
614 | |
|
|
615 | packet sl ("ex"); |
602 | packet sl ("ex"); |
616 | sl << ber32 (tag) << s.c_str (); |
603 | sl << ber32 (tag) |
|
|
604 | << data (*pl->expand_cfpod (s.c_str ())); |
617 | |
605 | |
618 | pl->ns->send_packet (sl); |
606 | pl->ns->send_packet (sl); |
619 | } |
607 | } |
620 | } |
608 | } |
621 | |
609 | |
… | |
… | |
696 | object *ob = pl->ob; |
684 | object *ob = pl->ob; |
697 | |
685 | |
698 | if (!pl->observe->map) |
686 | if (!pl->observe->map) |
699 | return; |
687 | return; |
700 | |
688 | |
|
|
689 | bool wiz = ob->flag [FLAG_WIZ] || ob->flag [FLAG_WIZLOOK]; |
|
|
690 | |
701 | mapxy pos (pl->observe); |
691 | mapxy pos (pl->observe); |
702 | pos.move (dx, dy); |
692 | pos.move (dx, dy); |
703 | |
693 | |
|
|
694 | if (wiz) |
|
|
695 | { |
704 | if (pos.normalise ()) |
696 | if (pos.normalise ()) |
|
|
697 | { |
|
|
698 | mapspace &ms = *pos; |
|
|
699 | ms.update (); |
|
|
700 | |
|
|
701 | buf.printf (" map: %s%+d%+d (%+d%+d)\n" |
|
|
702 | " smell %u/%u; flags %x; light %d; block %x; slow %x; on %x; off %x; volume %lld\n\n", |
|
|
703 | &pos.m->path, pos.x, pos.y, dx, dy, |
|
|
704 | (unsigned int)ms.smell, (unsigned int)mapspace::smellcount, ms.flags (), ms.light, |
|
|
705 | ms.move_block, ms.move_slow, ms.move_on, ms.move_off, (long long)ms.volume () |
|
|
706 | ); |
|
|
707 | } |
|
|
708 | else |
|
|
709 | buf << "off-map\n\n"; |
|
|
710 | } |
|
|
711 | |
|
|
712 | int darkness = pl->blocked_los (dx, dy); |
|
|
713 | |
|
|
714 | if (darkness == LOS_BLOCKED) |
|
|
715 | buf << "You cannot see that place from your position. H<Something is in between or it is too far away.>"; |
|
|
716 | else if (darkness == LOS_MAX) |
|
|
717 | buf << "That place is too dark to see anything. H<Move nearer or find better lighting.>"; |
|
|
718 | else |
|
|
719 | { |
|
|
720 | if (pos.normalise ()) |
705 | for (object *tmp = pos->top; tmp; tmp = tmp->below) |
721 | for (object *tmp = pos->top; tmp; tmp = tmp->below) |
706 | { |
722 | { |
707 | if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) |
723 | if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) |
708 | continue; |
724 | continue; |
709 | |
725 | |
710 | if (QUERY_FLAG (ob, FLAG_WIZ)) |
726 | if (wiz) |
711 | buf.printf ("- %s (%d).\n", query_name (tmp), tmp->count); |
727 | buf.printf (" - %s (%d).\n", query_name (tmp), tmp->count); |
712 | else |
728 | else |
713 | buf.printf ("- %s.\n", query_name (tmp)); |
729 | buf.printf (" - %s.\n", query_name (tmp)); |
714 | |
730 | |
715 | object *head = tmp->head_ (); |
731 | object *head = tmp->head_ (); |
716 | |
732 | |
717 | if (head->inv) |
733 | if (head->inv) |
718 | if ((head->type != CONTAINER && head->type != FLESH) |
734 | if ((head->type != CONTAINER && head->type != FLESH) |
719 | || QUERY_FLAG (ob, FLAG_WIZ)) |
735 | || QUERY_FLAG (ob, FLAG_WIZ)) |
720 | buf << head->query_inventory (ob, " "); |
736 | buf << head->query_inventory (ob, " "); |
721 | |
737 | |
722 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !QUERY_FLAG (ob, FLAG_WIZ)) /* don't continue under the floor */ |
738 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !wiz) /* don't continue under the floor */ |
723 | break; |
739 | break; |
|
|
740 | } |
724 | } |
741 | } |
725 | |
742 | |
726 | if (buf.empty ()) |
743 | if (buf.empty ()) |
727 | pl->failmsg ("You see nothing there."); |
744 | buf << "You see nothing there."; |
728 | else |
745 | |
729 | pl->infobox (MSG_CHANNEL ("lookat"), buf); |
746 | pl->infobox (MSG_CHANNEL ("lookat"), buf); |
730 | } |
747 | } |
731 | |
748 | |
732 | /** Client wants to look at some object. Lets do so. */ |
749 | /** Client wants to look at some object. Lets do so. */ |
733 | void |
750 | void |
734 | LookAt (char *buf, int len, player *pl) |
751 | LookAt (char *buf, int len, player *pl) |
… | |
… | |
738 | int dx = atoi (buf); |
755 | int dx = atoi (buf); |
739 | if (!(cp = strchr (buf, ' '))) |
756 | if (!(cp = strchr (buf, ' '))) |
740 | return; |
757 | return; |
741 | |
758 | |
742 | int dy = atoi (cp); |
759 | 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 | |
760 | |
754 | look_at (pl, dx, dy); |
761 | look_at (pl, dx, dy); |
755 | } |
762 | } |
756 | |
763 | |
757 | /** Move an object to a new location */ |
764 | /** Move an object to a new location */ |