ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/item.C
(Generate patch)

Comparing deliantra/server/socket/item.C (file contents):
Revision 1.71 by root, Mon Sep 8 11:27:25 2008 UTC vs.
Revision 1.77 by root, Mon Jan 12 03:40:21 2009 UTC

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)
684 object *ob = pl->ob; 678 object *ob = pl->ob;
685 679
686 if (!pl->observe->map) 680 if (!pl->observe->map)
687 return; 681 return;
688 682
683 bool wiz = ob->flag [FLAG_WIZ] || ob->flag [FLAG_WIZLOOK];
684
689 mapxy pos (pl->observe); 685 mapxy pos (pl->observe);
690 pos.move (dx, dy); 686 pos.move (dx, dy);
691 687
688 if (wiz)
689 {
692 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 ())
693 for (object *tmp = pos->top; tmp; tmp = tmp->below) 715 for (object *tmp = pos->top; tmp; tmp = tmp->below)
694 { 716 {
695 if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) 717 if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ))
696 continue; 718 continue;
697 719
698 if (QUERY_FLAG (ob, FLAG_WIZ)) 720 if (wiz)
699 buf.printf (" - %s (%d).\n", query_name (tmp), tmp->count); 721 buf.printf (" - %s (%d).\n", query_name (tmp), tmp->count);
700 else 722 else
701 buf.printf (" - %s.\n", query_name (tmp)); 723 buf.printf (" - %s.\n", query_name (tmp));
702 724
703 object *head = tmp->head_ (); 725 object *head = tmp->head_ ();
704 726
705 if (head->inv) 727 if (head->inv)
706 if ((head->type != CONTAINER && head->type != FLESH) 728 if ((head->type != CONTAINER && head->type != FLESH)
707 || QUERY_FLAG (ob, FLAG_WIZ)) 729 || QUERY_FLAG (ob, FLAG_WIZ))
708 buf << head->query_inventory (ob, " "); 730 buf << head->query_inventory (ob, " ");
709 731
710 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 */
711 break; 733 break;
734 }
712 } 735 }
713 736
714 if (buf.empty ()) 737 if (buf.empty ())
715 pl->failmsg ("You see nothing there."); 738 buf << "You see nothing there.";
716 else 739
717 pl->infobox (MSG_CHANNEL ("lookat"), buf); 740 pl->infobox (MSG_CHANNEL ("lookat"), buf);
718} 741}
719 742
720/** Client wants to look at some object. Lets do so. */ 743/** Client wants to look at some object. Lets do so. */
721void 744void
722LookAt (char *buf, int len, player *pl) 745LookAt (char *buf, int len, player *pl)
726 int dx = atoi (buf); 749 int dx = atoi (buf);
727 if (!(cp = strchr (buf, ' '))) 750 if (!(cp = strchr (buf, ' ')))
728 return; 751 return;
729 752
730 int dy = atoi (cp); 753 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 754
742 look_at (pl, dx, dy); 755 look_at (pl, dx, dy);
743} 756}
744 757
745/** Move an object to a new location */ 758/** Move an object to a new location */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines