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

Comparing deliantra/server/server/c_object.C (file contents):
Revision 1.68 by root, Tue Apr 22 02:46:18 2008 UTC vs.
Revision 1.80 by elmex, Sun Oct 5 12:40:21 2008 UTC

94} 94}
95 95
96static bool 96static bool
97can_split (object *pl, object *&op, sint32 nrof) 97can_split (object *pl, object *&op, sint32 nrof)
98{ 98{
99 if (object *tmp = op->split (nrof)) 99 if (object *tmp = op->split (nrof ? nrof : op->number_of ()))
100 { 100 {
101 op = tmp; 101 op = tmp;
102 return true; 102 return true;
103 } 103 }
104 else 104 else
284 * (sack, luggage, etc), tmp->env->env then points to the player (nested 284 * (sack, luggage, etc), tmp->env->env then points to the player (nested
285 * containers not allowed as of now) 285 * containers not allowed as of now)
286 */ 286 */
287 if ((pl->move_type & MOVE_FLYING) && !QUERY_FLAG (pl, FLAG_WIZ) && tmp->in_player () != pl) 287 if ((pl->move_type & MOVE_FLYING) && !QUERY_FLAG (pl, FLAG_WIZ) && tmp->in_player () != pl)
288 { 288 {
289 new_draw_info (NDI_UNIQUE, 0, pl, "You are levitating, you can't reach the ground!"); 289 pl->failmsg ("You are levitating, you can't reach the ground! "
290 "H<You have to stop levitating first, if you can, either by using your levitation skill, "
291 "or waiting till the levitation effect wears off.>");
290 return; 292 return;
291 } 293 }
292 294
293 if (QUERY_FLAG (tmp, FLAG_NO_DROP)) 295 if (QUERY_FLAG (tmp, FLAG_NO_DROP))
294 return; 296 return;
311 313
312 if (!can_split (pl, tmp, nrof)) 314 if (!can_split (pl, tmp, nrof))
313 return; 315 return;
314 316
315 if (QUERY_FLAG (tmp, FLAG_UNPAID)) 317 if (QUERY_FLAG (tmp, FLAG_UNPAID))
318 {
319 tmp->flag.reset (FLAG_UNPAID);
316 new_draw_info_format (NDI_UNIQUE, 0, pl, "%s will cost you %s.", query_name (tmp), query_cost_string (tmp, pl, F_BUY | F_SHOP)); 320 new_draw_info_format (NDI_UNIQUE, 0, pl, "%s will cost you %s.", query_name (tmp), query_cost_string (tmp, pl, F_BUY | F_SHOP));
321 tmp->flag.set (FLAG_UNPAID);
322 }
317 else 323 else
318 new_draw_info_format (NDI_UNIQUE, 0, pl, "You pick up the %s.", query_name (tmp)); 324 new_draw_info_format (NDI_UNIQUE, 0, pl, "You pick up the %s.", query_name (tmp));
319 325
320 tmp = insert_ob_in_ob (tmp, op); 326 op->insert (tmp);
321
322 /* All the stuff below deals with client/server code, and is only
323 * usable by players
324 */
325 if (pl->contr)
326 {
327 esrv_send_item (pl, tmp);
328
329 /* These are needed to update the weight for the container we
330 * are putting the object in.
331 */
332 if (op != pl)
333 {
334 esrv_update_item (UPD_WEIGHT, pl, op);
335 esrv_send_item (pl, pl);
336 }
337
338 /* Update the container the object was in */
339 if (env && env != pl && env != op)
340 esrv_update_item (UPD_WEIGHT, pl, env);
341 }
342} 327}
343 328
344/* modified slightly to allow monsters use this -b.t. 5-31-95 */ 329/* modified slightly to allow monsters use this -b.t. 5-31-95 */
345void 330void
346pick_up (object *op, object *alt) 331pick_up (object *op, object *alt)
499 * but that probably will make it more difficult to read, and 484 * but that probably will make it more difficult to read, and
500 * not make it any more efficient 485 * not make it any more efficient
501 */ 486 */
502 if (params && item_matched_string (op, tmp, params)) 487 if (params && item_matched_string (op, tmp, params))
503 { 488 {
489 if (--cnt < 0) break;
504 pick_up (op, tmp); 490 pick_up (op, tmp);
505 if (--cnt <= 0) break;
506 } 491 }
507 else if (can_pick (op, tmp) && !params) 492 else if (can_pick (op, tmp) && !params)
508 { 493 {
494 if (--cnt < 0) break;
509 pick_up (op, tmp); 495 pick_up (op, tmp);
510 break; 496 break;
511 } 497 }
512 498
513 tmp = next; 499 tmp = next;
514 } 500 }
515 501
516 if (cnt <= 0) 502 if (cnt < 0)
517 { 503 {
518 op->failmsg ("Couldn't pick up so many items at once."); 504 op->failmsg ("Couldn't pick up so many items at once.");
519 return 0; 505 return 0;
520 } 506 }
521 507
569 for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) 555 for (tmp2 = tmp->inv; tmp2; tmp2 = tmp)
570 { 556 {
571 tmp = tmp2->below; 557 tmp = tmp2->below;
572 558
573 if ((sack->type == CONTAINER && sack_can_hold (op, op->container, tmp2, tmp2->nrof))) 559 if ((sack->type == CONTAINER && sack_can_hold (op, op->container, tmp2, tmp2->nrof)))
574 {
575 put_object_in_sack (op, sack, tmp2, 0); 560 put_object_in_sack (op, sack, tmp2, 0);
576 }
577 else 561 else
578 { 562 {
579 sprintf (buf, "Your %s fills up.", query_name (sack)); 563 sprintf (buf, "Your %s fills up.", query_name (sack));
580 new_draw_info (NDI_UNIQUE, 0, op, buf); 564 new_draw_info (NDI_UNIQUE, 0, op, buf);
581 break; 565 break;
582 } 566 }
583 } 567 }
584 568
585 esrv_update_item (UPD_WEIGHT, op, sack2);
586 return; 569 return;
587 } 570 }
588 571
589 /* Don't worry about this for containers - our caller should have 572 /* Don't worry about this for containers - our caller should have
590 * already checked this. 573 * already checked this.
595 if (QUERY_FLAG (tmp, FLAG_APPLIED)) 578 if (QUERY_FLAG (tmp, FLAG_APPLIED))
596 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) 579 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE))
597 return; 580 return;
598 581
599 /* we want to put some portion of the item into the container */ 582 /* we want to put some portion of the item into the container */
600 if (nrof && tmp->nrof != nrof)
601 {
602 if (!can_split (op, tmp, nrof)) 583 if (!can_split (op, tmp, nrof))
603 return; 584 return;
604 }
605 else
606 tmp->remove ();
607 585
608 new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack)); 586 new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack));
609 tmp2 = insert_ob_in_ob (tmp, sack); 587 sack->insert (tmp);
610
611 // elmex: 2007-11-26: removed update_stats and replaced
612 // it by update_after_inventory_change () in the caller
613 // of this function
614
615 /* If an object merged (and thus, different object), we need to
616 * delete the original.
617 */
618 if (tmp2 != tmp)
619 esrv_del_item (op->contr, tmp->count);
620
621 esrv_send_item (op, tmp2);
622
623 /* update the sacks weight */
624 esrv_update_item (UPD_WEIGHT, op, sack);
625} 588}
626 589
627/* 590/*
628 * This function was part of drop, now is own function. 591 * This function was part of drop, now is own function.
629 * Player 'op' tries to drop object 'tmp', if tmp is non zero, then 592 * Player 'op' tries to drop object 'tmp', if tmp is non zero, then
631 * This is used when dropping objects onto the floor. 594 * This is used when dropping objects onto the floor.
632 */ 595 */
633void 596void
634drop_object (object *op, object *tmp, uint32 nrof) 597drop_object (object *op, object *tmp, uint32 nrof)
635{ 598{
636 object *floor;
637
638 if (QUERY_FLAG (tmp, FLAG_NO_DROP)) 599 if (QUERY_FLAG (tmp, FLAG_NO_DROP))
639 return; 600 return;
640 601
641 if (QUERY_FLAG (tmp, FLAG_APPLIED)) 602 if (QUERY_FLAG (tmp, FLAG_APPLIED))
642 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) 603 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE))
645 //fprintf (stderr, "ui, on space is %ld\n", op->ms ().volume ());//D 606 //fprintf (stderr, "ui, on space is %ld\n", op->ms ().volume ());//D
646 607
647 /* We are only dropping some of the items. We split the current object 608 /* We are only dropping some of the items. We split the current object
648 * off 609 * off
649 */ 610 */
650 if (nrof && tmp->nrof != nrof)
651 {
652 if (!can_split (op, tmp, nrof)) 611 if (!can_split (op, tmp, nrof))
653 return; 612 return;
654 }
655 else
656 tmp->remove ();
657 613
658 if (INVOKE_OBJECT (DROP, tmp, ARG_OBJECT (op))) 614 if (INVOKE_OBJECT (DROP, tmp, ARG_OBJECT (op)))
659 return; 615 return;
660 616
661 if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) 617 if (QUERY_FLAG (tmp, FLAG_STARTEQUIP))
662 { 618 {
663 op->statusmsg (format ("You drop the %s.", query_name (tmp))); 619 op->statusmsg (format ("You drop the %s.", query_name (tmp)));
664 op->statusmsg ("The gods who lent it to you retrieves it."); 620 op->statusmsg ("The god who lent it to you retrieves it.");
665 621
666 tmp->destroy (); 622 tmp->destroy ();
667 op->update_stats (); 623 op->update_stats ();
668 return; 624 return;
669 } 625 }
670
671 if (op->type == PLAYER)
672 esrv_del_item (op->contr, tmp->count);
673 626
674 /* Call this before we update the various windows/players. At least 627 /* Call this before we update the various windows/players. At least
675 * that we, we know the weight is correct. 628 * that we, we know the weight is correct.
676 */ 629 */
677 // 2007-11-26: moved op->update_stats away and calling it later after 630 // 2007-11-26: moved op->update_stats away and calling it later after
678 // all items of a drop command have been processed. 631 // all items of a drop command have been processed.
679 632
680 for (floor = GET_MAP_OB (op->map, op->x, op->y); floor; floor = floor->above) 633 for (object *floor = GET_MAP_OB (op->map, op->x, op->y); floor; floor = floor->above)
681 if (INVOKE_OBJECT (DROP_ON, floor, ARG_OBJECT (tmp), ARG_OBJECT (op))) 634 if (INVOKE_OBJECT (DROP_ON, floor, ARG_OBJECT (tmp), ARG_OBJECT (op)))
682 return; 635 return;
683 636
684 if (is_in_shop (op) && !QUERY_FLAG (tmp, FLAG_UNPAID) && tmp->type != MONEY) 637 if (is_in_shop (op) && !QUERY_FLAG (tmp, FLAG_UNPAID) && tmp->type != MONEY)
638 {
685 sell_item (tmp, op); 639 if (!sell_item (tmp, op))
640 {
641 // if we can't sell it we don't drop it, so give it back to the seller
642 op->insert (tmp);
643 return;
644 }
645 }
686 646
687 tmp->x = op->x; 647 tmp->x = op->x;
688 tmp->y = op->y; 648 tmp->y = op->y;
689 649
690 insert_ob_in_map (tmp, op->map, op, INS_BELOW_ORIGINATOR); 650 insert_ob_in_map (tmp, op->map, op, INS_BELOW_ORIGINATOR);
691}
692
693void update_after_inventory_change (object *op)
694{
695 /* Call this before we update the various windows/players. At least
696 * that we, we know the weight is correct.
697 */
698 op->update_stats ();
699
700 // elmex: kept this for now, i have no idea what happens when i remove it:
701 if (op->type == PLAYER)
702 {
703 /* Need to update the weight for the player */
704 esrv_send_item (op, op);
705 op->contr->ns->floorbox_update ();
706 }
707} 651}
708 652
709void 653void
710drop (object *op, object *tmp) 654drop (object *op, object *tmp)
711{ 655{
720 if (tmp->env && tmp->env->type != PLAYER) 664 if (tmp->env && tmp->env->type != PLAYER)
721 { 665 {
722 /* Just toss the object - probably shouldn't be hanging 666 /* Just toss the object - probably shouldn't be hanging
723 * around anyways 667 * around anyways
724 */ 668 */
725 tmp->remove ();
726 tmp->destroy (); 669 tmp->destroy ();
727 return; 670 return;
728 } 671 }
729 else 672 else
730 { 673 {
731 while (tmp != NULL && tmp->invisible) 674 while (tmp && tmp->invisible)
732 tmp = tmp->below; 675 tmp = tmp->below;
733 } 676 }
734 } 677 }
735 678
736 if (tmp == NULL) 679 if (tmp == NULL)
737 { 680 {
738 new_draw_info (NDI_UNIQUE, 0, op, "You don't have anything to drop."); 681 new_draw_info (NDI_UNIQUE, 0, op, "You don't have anything to drop.");
739 return; 682 return;
740 } 683 }
684
741 if (QUERY_FLAG (tmp, FLAG_INV_LOCKED)) 685 if (QUERY_FLAG (tmp, FLAG_INV_LOCKED))
742 { 686 {
743 new_draw_info (NDI_UNIQUE, 0, op, "This item is locked"); 687 new_draw_info (NDI_UNIQUE, 0, op, "This item is locked");
744 return; 688 return;
745 } 689 }
690
746 if (QUERY_FLAG (tmp, FLAG_NO_DROP)) 691 if (QUERY_FLAG (tmp, FLAG_NO_DROP))
747 { 692 {
748#if 0 693#if 0
749 /* Eneq(@csd.uu.se): Objects with NO_DROP defined can't be dropped. */ 694 /* Eneq(@csd.uu.se): Objects with NO_DROP defined can't be dropped. */
750 new_draw_info (NDI_UNIQUE, 0, op, "This item can't be dropped."); 695 new_draw_info (NDI_UNIQUE, 0, op, "This item can't be dropped.");
774 719
775 if (op->type == PLAYER) 720 if (op->type == PLAYER)
776 op->contr->count = 0; 721 op->contr->count = 0;
777} 722}
778 723
779
780
781/* Command will drop all items that have not been locked */ 724/* Command will drop all items that have not been locked */
782int 725int
783command_dropall (object *op, char *params) 726command_dropall (object *op, char *params)
784{ 727{
785 728
786 object *curinv, *nextinv;
787
788 if (op->inv == NULL) 729 if (op->inv == NULL)
789 { 730 {
790 new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop!"); 731 new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop!");
791 return 0; 732 return 0;
792 } 733 }
793 734
794 curinv = op->inv; 735 object *curinv = op->inv;
736 object *nextinv;
795 737
796 /* 738 /*
797 This is the default. Drops everything not locked or considered 739 This is the default. Drops everything not locked or considered
798 not something that should be dropped. 740 not something that should be dropped.
799 */ 741 */
803 in a shop. --Tero.Pelander@utu.fi 745 in a shop. --Tero.Pelander@utu.fi
804 */ 746 */
805 747
806 int cnt = MAX_ITEM_PER_DROP; 748 int cnt = MAX_ITEM_PER_DROP;
807 749
808 if (params == NULL) 750 if (!params)
809 { 751 {
810 while (curinv != NULL) 752 while (curinv)
811 { 753 {
812 nextinv = curinv->below; 754 nextinv = curinv->below;
755
813 while (nextinv && nextinv->type == MONEY) 756 while (nextinv && nextinv->type == MONEY)
814 nextinv = nextinv->below; 757 nextinv = nextinv->below;
758
815 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && curinv->type != MONEY && 759 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && curinv->type != MONEY &&
816 curinv->type != FOOD && curinv->type != KEY && 760 curinv->type != FOOD && curinv->type != KEY &&
817 curinv->type != SPECIAL_KEY && curinv->type != GEM && 761 curinv->type != SPECIAL_KEY && curinv->type != GEM &&
818 !curinv->invisible && (curinv->type != CONTAINER || op->container != curinv)) 762 !curinv->invisible && (curinv->type != CONTAINER || op->container != curinv))
819 { 763 {
820 drop (op, curinv); 764 drop (op, curinv);
821 if (--cnt <= 0) break; 765 if (--cnt <= 0) break;
822 } 766 }
767
823 curinv = nextinv; 768 curinv = nextinv;
824 } 769 }
825 } 770 }
826
827 else if (strcmp (params, "weapons") == 0) 771 else if (strcmp (params, "weapons") == 0)
828 { 772 {
829 while (curinv != NULL) 773 while (curinv)
830 { 774 {
831 nextinv = curinv->below; 775 nextinv = curinv->below;
776
832 while (nextinv && nextinv->type == MONEY) 777 while (nextinv && nextinv->type == MONEY)
833 nextinv = nextinv->below; 778 nextinv = nextinv->below;
779
834 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == WEAPON) || (curinv->type == BOW) || (curinv->type == ARROW))) 780 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == WEAPON) || (curinv->type == BOW) || (curinv->type == ARROW)))
835 { 781 {
836 drop (op, curinv); 782 drop (op, curinv);
837 if (--cnt <= 0) break; 783 if (--cnt <= 0) break;
838 } 784 }
785
839 curinv = nextinv; 786 curinv = nextinv;
840 } 787 }
841 } 788 }
842
843 else if (strcmp (params, "armor") == 0 || strcmp (params, "armour") == 0) 789 else if (strcmp (params, "armor") == 0 || strcmp (params, "armour") == 0)
844 { 790 {
845 while (curinv != NULL) 791 while (curinv)
846 { 792 {
847 nextinv = curinv->below; 793 nextinv = curinv->below;
794
848 while (nextinv && nextinv->type == MONEY) 795 while (nextinv && nextinv->type == MONEY)
849 nextinv = nextinv->below; 796 nextinv = nextinv->below;
797
850 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == ARMOUR) || curinv->type == SHIELD || curinv->type == HELMET)) 798 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == ARMOUR) || curinv->type == SHIELD || curinv->type == HELMET))
851 { 799 {
852 drop (op, curinv); 800 drop (op, curinv);
853 if (--cnt <= 0) break; 801 if (--cnt <= 0) break;
854 } 802 }
803
855 curinv = nextinv; 804 curinv = nextinv;
856 } 805 }
857 } 806 }
858
859 else if (strcmp (params, "misc") == 0) 807 else if (strcmp (params, "misc") == 0)
860 { 808 {
861 while (curinv != NULL) 809 while (curinv)
862 { 810 {
863 nextinv = curinv->below; 811 nextinv = curinv->below;
812
864 while (nextinv && nextinv->type == MONEY) 813 while (nextinv && nextinv->type == MONEY)
865 nextinv = nextinv->below; 814 nextinv = nextinv->below;
815
866 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && !QUERY_FLAG (curinv, FLAG_APPLIED)) 816 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && !QUERY_FLAG (curinv, FLAG_APPLIED))
867 { 817 {
868 switch (curinv->type) 818 switch (curinv->type)
869 { 819 {
870 case HORN: 820 case HORN:
888 break; 838 break;
889 default: 839 default:
890 curinv = nextinv; 840 curinv = nextinv;
891 break; 841 break;
892 } 842 }
843
893 if (--cnt <= 0) break; 844 if (--cnt <= 0) break;
894 } 845 }
846
895 curinv = nextinv; 847 curinv = nextinv;
896 } 848 }
897 } 849 }
898 850
899 if (cnt <= 0) 851 if (cnt <= 0)
900 op->failmsg ("Only dropped some items, can't drop that many items at once."); 852 op->failmsg ("Only dropped some items, can't drop that many items at once.");
901
902 update_after_inventory_change (op);
903 853
904/* draw_look(op);*/ 854/* draw_look(op);*/
905 return 0; 855 return 0;
906} 856}
907 857
908/* Object op wants to drop object(s) params. params can be a 858/* Object op wants to drop object(s) params. params can be a
909 * comma seperated list. 859 * comma seperated list.
910 */ 860 */
911
912int 861int
913command_drop (object *op, char *params) 862command_drop (object *op, char *params)
914{ 863{
915 object *tmp, *next; 864 object *tmp, *next;
916 int did_one = 0; 865 int did_one = 0;
941 if (!did_one) 890 if (!did_one)
942 new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop."); 891 new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop.");
943 892
944 if (cnt <= 0) 893 if (cnt <= 0)
945 op->failmsg ("Only dropped some items, can't drop that many items at once."); 894 op->failmsg ("Only dropped some items, can't drop that many items at once.");
946
947 update_after_inventory_change (op);
948 } 895 }
949 896
950 return 0; 897 return 0;
951} 898}
952 899
1027 dynbuf_text buf (512, 512); 974 dynbuf_text buf (512, 512);
1028 975
1029 object *mon = head ? head : this; 976 object *mon = head ? head : this;
1030 977
1031 if (QUERY_FLAG (mon, FLAG_UNDEAD)) 978 if (QUERY_FLAG (mon, FLAG_UNDEAD))
1032 buf << "It is an undead force.\n"; 979 buf << "It is an undead force.\r";
1033 980
1034 if (mon->level > who->level) 981 if (mon->level > who->level)
1035 buf << "It is likely more powerful than you.\n"; 982 buf << "It is likely more powerful than you.\r";
1036 else if (mon->level < who->level) 983 else if (mon->level < who->level)
1037 buf << "It is likely less powerful than you.\n"; 984 buf << "It is likely less powerful than you.\r";
1038 else 985 else
1039 buf << "It is probably as powerful as you.\n"; 986 buf << "It is probably as powerful as you.\r";
1040 987
1041 if (mon->attacktype & AT_ACID) 988 if (mon->attacktype & AT_ACID)
1042 buf << "You seem to smell an acrid odor.\n"; 989 buf << "You seem to smell an acrid odor.\r";
1043 990
1044 /* Anyone know why this used to use the clone value instead of the 991 /* Anyone know why this used to use the clone value instead of the
1045 * maxhp field? This seems that it should give more accurate results. 992 * maxhp field? This seems that it should give more accurate results.
1046 */ 993 */
1047 switch ((mon->stats.hp + 1) * 4 / (mon->stats.maxhp + 1)) 994 switch ((mon->stats.hp + 1) * 4 / (mon->stats.maxhp + 1))
1048 { /* From 1-4 */ 995 { /* From 1-4 */
1049 case 1: 996 case 1:
1050 buf << "It is in a bad shape.\n"; 997 buf << "It is in a bad shape.\r";
1051 break; 998 break;
1052 case 2: 999 case 2:
1053 buf << "It is hurt.\n"; 1000 buf << "It is hurt.\r";
1054 break; 1001 break;
1055 case 3: 1002 case 3:
1056 buf << "It is somewhat hurt.\n"; 1003 buf << "It is somewhat hurt.\r";
1057 break; 1004 break;
1058 case 4: 1005 case 4:
1059 buf << "It is in excellent shape.\n"; 1006 buf << "It is in excellent shape.\r";
1060 break; 1007 break;
1061 } 1008 }
1062 1009
1063 if (present_in_ob (POISONING, mon)) 1010 if (present_in_ob (POISONING, mon))
1064 buf << "It looks very ill.\n"; 1011 buf << "It looks very ill.\r";
1012
1013 buf << '\n';
1065 1014
1066 return buf; 1015 return buf;
1067} 1016}
1068 1017
1069/* tmp is the object being described, pl is who is examing it. */ 1018/* tmp is the object being described, pl is who is examing it. */
1127std::string 1076std::string
1128object::describe (object *who) 1077object::describe (object *who)
1129{ 1078{
1130 dynbuf_text buf (1024, 1024); 1079 dynbuf_text buf (1024, 1024);
1131 1080
1132 buf.printf ("That is: %s.\n", long_desc (who).c_str ()); 1081 buf.printf ("That is: %s.\r", long_desc (who).c_str ());
1133 1082
1134 if (custom_name) 1083 if (custom_name)
1135 buf.printf ("You call it %s\n", &custom_name); 1084 buf.printf ("You call it %s.\r", &custom_name);
1136 1085
1137 switch (type) 1086 switch (type)
1138 { 1087 {
1139 case SPELLBOOK: 1088 case SPELLBOOK:
1140 if (flag [FLAG_IDENTIFIED] && inv) 1089 if (flag [FLAG_IDENTIFIED] && inv)
1141 buf.printf ("%s is a %s %s spell\n", &inv->name, get_levelnumber (inv->level), &inv->skill); 1090 buf.printf ("%s is a %s %s spell.\r", &inv->name, get_levelnumber (inv->level), &inv->skill);
1142 break; 1091 break;
1143 1092
1144 case BOOK: 1093 case BOOK:
1145 if (msg) 1094 if (msg)
1146 buf << "Something is written in it.\n"; 1095 buf << "Something is written in it.\r";
1147 break; 1096 break;
1148 1097
1149 case CONTAINER: 1098 case CONTAINER:
1150 if (race != NULL) 1099 if (race)
1151 { 1100 {
1152 if (weight_limit && stats.Str < 100) 1101 if (weight_limit && stats.Str < 100)
1153 buf.printf ("It can hold only %s and its weight limit is %.1f kg.\n", 1102 buf.printf ("It can hold only %s and its weight limit is %.1f kg.\r",
1154 &race, weight_limit / (10.0 * (100 - stats.Str))); 1103 &race, weight_limit / (10.0 * (100 - stats.Str)));
1155 else 1104 else
1156 buf.printf ("It can hold only %s.\n", &race); 1105 buf.printf ("It can hold only %s.\r", &race);
1157 } 1106 }
1158 else if (weight_limit && stats.Str < 100) 1107 else if (weight_limit && stats.Str < 100)
1159 buf.printf ("Its weight limit is %.1f kg.\n", weight_limit / (10.0 * (100 - stats.Str))); 1108 buf.printf ("Its weight limit is %.1f kg.\r", weight_limit / (10.0 * (100 - stats.Str)));
1160 break; 1109 break;
1161 1110
1162 case WAND: 1111 case WAND:
1163 if (flag [FLAG_IDENTIFIED]) 1112 if (flag [FLAG_IDENTIFIED])
1164 buf.printf ("It has %d charges left.\n", stats.food); 1113 buf.printf ("It has %d charges left.\r", stats.food);
1165 break; 1114 break;
1166 } 1115 }
1167 1116
1168 if (materialname && !msg) 1117 if (materialname && !msg)
1169 buf.printf ("It is made of: %s.\n", &materialname); 1118 buf.printf ("It is made of: %s.\r", &materialname);
1170 1119
1171 if (who) 1120 if (who)
1172 /* Where to wear this item */ 1121 /* Where to wear this item */
1173 for (int i = 0; i < NUM_BODY_LOCATIONS; i++) 1122 for (int i = 0; i < NUM_BODY_LOCATIONS; i++)
1174 if (slot[i].info) 1123 if (slot[i].info)
1176 buf << (who->slot[i].info ? body_locations[i].use_name : body_locations[i].nonuse_name); 1125 buf << (who->slot[i].info ? body_locations[i].use_name : body_locations[i].nonuse_name);
1177 1126
1178 if (slot[i].info < -1 && who->slot[i].info) 1127 if (slot[i].info < -1 && who->slot[i].info)
1179 buf.printf ("(%d)", -slot[i].info); 1128 buf.printf ("(%d)", -slot[i].info);
1180 1129
1181 buf << ".\n"; 1130 buf << ".\r";
1182 } 1131 }
1183 1132
1184 if (weight) 1133 if (weight)
1185 buf.printf (nrof > 1 ? "They weigh %3.3f kg.\n" : "It weighs %3.3f kg.\n", weight * (nrof ? nrof : 1) / 1000.0); 1134 buf.printf ("%s %3.3f kg.\r", nrof > 1 ? "They weigh" : "It weighs", weight * (nrof ? nrof : 1) / 1000.0);
1186 1135
1187 if (value && !flag [FLAG_STARTEQUIP] && !flag [FLAG_NO_PICK] && who) 1136 if (value && !flag [FLAG_STARTEQUIP] && !flag [FLAG_NO_PICK] && who)
1188 { 1137 {
1189 buf.printf ("You reckon %s worth %s.\n", nrof > 1 ? "they are" : "it is", query_cost_string (this, who, F_TRUE | F_APPROX)); 1138 buf.printf ("You reckon %s worth %s.\r", nrof > 1 ? "they are" : "it is", query_cost_string (this, who, F_TRUE | F_APPROX));
1190 1139
1191 if (is_in_shop (who)) 1140 if (is_in_shop (who))
1192 { 1141 {
1193 if (flag [FLAG_UNPAID]) 1142 if (flag [FLAG_UNPAID])
1194 buf.printf ("%s would cost you %s.\n", nrof > 1 ? "They" : "It", query_cost_string (this, who, F_BUY | F_SHOP)); 1143 buf.printf ("%s would cost you %s.\r", nrof > 1 ? "They" : "It", query_cost_string (this, who, F_BUY | F_SHOP));
1195 else 1144 else
1196 buf.printf ("You are offered %s for %s.\n", query_cost_string (this, who, F_SELL + F_SHOP), nrof > 1 ? "them" : "it"); 1145 buf.printf ("You are offered %s for %s.\r", query_cost_string (this, who, F_SELL + F_SHOP), nrof > 1 ? "them" : "it");
1197 } 1146 }
1198 } 1147 }
1199 1148
1200 if (flag [FLAG_MONSTER]) 1149 if (flag [FLAG_MONSTER])
1201 buf << describe_monster (who); 1150 buf << describe_monster (who);
1202 1151
1203 /* Is this item buildable? */ 1152 /* Is this item buildable? */
1204 if (flag [FLAG_IS_BUILDABLE]) 1153 if (flag [FLAG_IS_BUILDABLE])
1205 buf << "This is a buildable item.\n"; 1154 buf << "This is a buildable item.\r";
1206 1155
1207 /* Does the object have a message? Don't show message for all object 1156 /* Does the object have a message? Don't show message for all object
1208 * types - especially if the first entry is a match 1157 * types - especially if the first entry is a match
1209 */ 1158 */
1210 if (msg && type != EXIT && type != BOOK && type != CORPSE && !move_on && *msg != '@') 1159 if (msg && type != EXIT && type != BOOK && type != CORPSE && !move_on && !has_dialogue ())
1211 { 1160 {
1212 /* This is just a hack so when identifying the items, we print 1161 /* This is just a hack so when identifying the items, we print
1213 * out the extra message 1162 * out the extra message
1214 */ 1163 */
1215 if (need_identify (this) && flag [FLAG_IDENTIFIED]) 1164 if (need_identify (this) && flag [FLAG_IDENTIFIED])
1216 buf << "The object has a story:\n"; 1165 buf << "The object has a story:\r";
1217 1166
1218 buf << msg << '\n'; 1167 buf << msg << '\n';
1219 } 1168 }
1220 1169
1221 buf << '\n'; 1170 buf << '\n';

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines