… | |
… | |
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 | |
… | |
… | |
427 | |
418 | |
428 | if (flags & UPD_NAME) |
419 | if (flags & UPD_NAME) |
429 | { |
420 | { |
430 | int len; |
421 | int len; |
431 | const char *item_p; |
422 | const char *item_p; |
432 | char item_n[MAX_BUF]; |
423 | char item_n[127 * 2]; |
433 | |
424 | |
434 | if (!op->custom_name) |
425 | if (!op->custom_name) |
435 | { |
426 | { |
436 | strncpy (item_n, query_base_name (op, 0), 127); |
427 | 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); |
428 | item_p = query_base_name (op, 1); |
440 | } |
429 | } |
441 | else |
430 | else |
442 | { |
431 | { |
443 | strncpy (item_n, op->custom_name, 127); |
432 | len = assign (item_n, &op->custom_name, 127); |
444 | item_n[127] = 0; |
|
|
445 | len = strlen (item_n); |
|
|
446 | item_p = op->custom_name; |
433 | item_p = &op->custom_name; |
447 | } |
434 | } |
448 | |
435 | |
449 | strncpy (item_n + len + 1, item_p, 127); |
436 | len += assign (item_n + len, item_p, 127); |
450 | item_n[254] = 0; |
|
|
451 | len += strlen (item_n + 1 + len) + 1; |
|
|
452 | |
437 | |
453 | sl << data8 (item_n, len); |
438 | sl << data8 (item_n, len); |
454 | } |
439 | } |
455 | |
440 | |
456 | if (flags & UPD_ANIM) |
441 | if (flags & UPD_ANIM) |
… | |
… | |
509 | sl << uint32 (op->env ? op->env->count : 0); |
494 | sl << uint32 (op->env ? op->env->count : 0); |
510 | |
495 | |
511 | add_object_to_socklist (*pl->contr->ns, sl, op); |
496 | add_object_to_socklist (*pl->contr->ns, sl, op); |
512 | |
497 | |
513 | pl->contr->ns->send_packet (sl); |
498 | pl->contr->ns->send_packet (sl); |
514 | SET_FLAG (op, FLAG_CLIENT_SENT); |
|
|
515 | } |
499 | } |
516 | |
500 | |
517 | /** |
501 | /** |
518 | * Tells the client to delete an item. |
502 | * Tells the client to delete an item. |
519 | */ |
503 | */ |
… | |
… | |
607 | |
591 | |
608 | if (object *op = esrv_get_ob_from_count (pl->ob, tag)) |
592 | if (object *op = esrv_get_ob_from_count (pl->ob, tag)) |
609 | { |
593 | { |
610 | std::string s = op->describe (pl->ob); |
594 | std::string s = op->describe (pl->ob); |
611 | |
595 | |
612 | if (msg_is_special (s.c_str (), false)) |
|
|
613 | cfperl_expand_cfpod (pl, s); |
|
|
614 | |
|
|
615 | packet sl ("ex"); |
596 | packet sl ("ex"); |
616 | sl << ber32 (tag) << s.c_str (); |
597 | sl << ber32 (tag) |
|
|
598 | << data (*pl->expand_cfpod (s.c_str ())); |
617 | |
599 | |
618 | pl->ns->send_packet (sl); |
600 | pl->ns->send_packet (sl); |
619 | } |
601 | } |
620 | } |
602 | } |
621 | |
603 | |
… | |
… | |
696 | object *ob = pl->ob; |
678 | object *ob = pl->ob; |
697 | |
679 | |
698 | if (!pl->observe->map) |
680 | if (!pl->observe->map) |
699 | return; |
681 | return; |
700 | |
682 | |
|
|
683 | bool wiz = ob->flag [FLAG_WIZ] || ob->flag [FLAG_WIZLOOK]; |
|
|
684 | |
701 | mapxy pos (pl->observe); |
685 | mapxy pos (pl->observe); |
702 | pos.move (dx, dy); |
686 | pos.move (dx, dy); |
703 | |
687 | |
|
|
688 | if (wiz) |
|
|
689 | { |
704 | 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 ()) |
705 | for (object *tmp = pos->top; tmp; tmp = tmp->below) |
715 | for (object *tmp = pos->top; tmp; tmp = tmp->below) |
706 | { |
716 | { |
707 | if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) |
717 | if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) |
708 | continue; |
718 | continue; |
709 | |
719 | |
710 | if (QUERY_FLAG (ob, FLAG_WIZ)) |
720 | if (wiz) |
711 | buf.printf ("- %s (%d).\n", query_name (tmp), tmp->count); |
721 | buf.printf (" - %s (%d).\n", query_name (tmp), tmp->count); |
712 | else |
722 | else |
713 | buf.printf ("- %s.\n", query_name (tmp)); |
723 | buf.printf (" - %s.\n", query_name (tmp)); |
714 | |
724 | |
715 | object *head = tmp->head_ (); |
725 | object *head = tmp->head_ (); |
716 | |
726 | |
717 | if (head->inv) |
727 | if (head->inv) |
718 | if ((head->type != CONTAINER && head->type != FLESH) |
728 | if ((head->type != CONTAINER && head->type != FLESH) |
719 | || QUERY_FLAG (ob, FLAG_WIZ)) |
729 | || QUERY_FLAG (ob, FLAG_WIZ)) |
720 | buf << head->query_inventory (ob, " "); |
730 | buf << head->query_inventory (ob, " "); |
721 | |
731 | |
722 | 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 */ |
723 | break; |
733 | break; |
|
|
734 | } |
724 | } |
735 | } |
725 | |
736 | |
726 | if (buf.empty ()) |
737 | if (buf.empty ()) |
727 | pl->failmsg ("You see nothing there."); |
738 | buf << "You see nothing there."; |
728 | else |
739 | |
729 | pl->infobox (MSG_CHANNEL ("lookat"), buf); |
740 | pl->infobox (MSG_CHANNEL ("lookat"), buf); |
730 | } |
741 | } |
731 | |
742 | |
732 | /** Client wants to look at some object. Lets do so. */ |
743 | /** Client wants to look at some object. Lets do so. */ |
733 | void |
744 | void |
734 | LookAt (char *buf, int len, player *pl) |
745 | LookAt (char *buf, int len, player *pl) |
… | |
… | |
738 | int dx = atoi (buf); |
749 | int dx = atoi (buf); |
739 | if (!(cp = strchr (buf, ' '))) |
750 | if (!(cp = strchr (buf, ' '))) |
740 | return; |
751 | return; |
741 | |
752 | |
742 | int dy = atoi (cp); |
753 | 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 | |
754 | |
754 | look_at (pl, dx, dy); |
755 | look_at (pl, dx, dy); |
755 | } |
756 | } |
756 | |
757 | |
757 | /** Move an object to a new location */ |
758 | /** Move an object to a new location */ |