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

Comparing deliantra/server/common/item.C (file contents):
Revision 1.16 by elmex, Sat Dec 30 21:07:46 2006 UTC vs.
Revision 1.30 by root, Mon May 7 03:05:57 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game
3 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 11 * (at your option) any later version.
11 12 *
12 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 21 *
21 The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail at <crossfire@schmorp.de>
22*/ 23 */
23 24
24#include <global.h> 25#include <global.h>
25#include <funcpoint.h> 26#include <funcpoint.h>
26#include <living.h> 27#include <living.h>
27#include <spells.h> 28#include <spells.h>
47 * Basically, for the use/nonuse, the code does something like: 48 * Basically, for the use/nonuse, the code does something like:
48 * "This item goes %s\n", with the use/nonuse values filling in the %s 49 * "This item goes %s\n", with the use/nonuse values filling in the %s
49 */ 50 */
50Body_Locations body_locations[NUM_BODY_LOCATIONS] = { 51Body_Locations body_locations[NUM_BODY_LOCATIONS] = {
51 {"body_range", "in your range slot", "in a human's range slot"}, 52 {"body_range", "in your range slot", "in a human's range slot"},
53 {"body_shield", "as a shield", "as a protective shield"},
54 {"body_combat", "as a combat weapon", "as a combat weapon"},
52 {"body_arm", "on your arm", "on a human's arm"}, 55 {"body_arm", "on your arm", "on a human's arm"},
53 {"body_torso", "on your body", "on a human's torso"}, 56 {"body_torso", "on your body", "on a human's torso"},
54 {"body_head", "on your head", "on a human's head"}, 57 {"body_head", "on your head", "on a human's head"},
55 {"body_neck", "around your neck", "around a humans neck"}, 58 {"body_neck", "around your neck", "around a humans neck"},
56 {"body_skill", "in your skill slot", "in a human's skill slot"}, 59 {"body_skill", "in your skill slot", "in a human's skill slot"},
249}; 252};
250 253
251int 254int
252get_power_from_ench (int ench) 255get_power_from_ench (int ench)
253{ 256{
254 if (ench < 0) 257 if (ench < 0) ench = 0;
255 ench = 0; 258 if (ench > 20) ench = 20;
256 if (ench > 20) 259
257 ench = 20;
258 return enc_to_item_power[ench]; 260 return enc_to_item_power[ench];
259} 261}
260 262
261/* This takes an object 'op' and figures out what its item_power 263/* This takes an object 'op' and figures out what its item_power
262 * rating should be. This should only really be used by the treasure 264 * rating should be. This should only really be used by the treasure
341 enc += 1; 343 enc += 1;
342 if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) 344 if (QUERY_FLAG (op, FLAG_MAKE_INVIS))
343 enc += 1; 345 enc += 1;
344 346
345 return get_power_from_ench (enc); 347 return get_power_from_ench (enc);
346
347} 348}
348 349
349/* returns the typedata that has a number equal to itemtype, if there 350/* returns the typedata that has a number equal to itemtype, if there
350 * isn't one, returns NULL */ 351 * isn't one, returns NULL */
351
352const typedata * 352const typedata *
353get_typedata (int itemtype) 353get_typedata (int itemtype)
354{ 354{
355 int i; 355 int i;
356 356
361} 361}
362 362
363/* returns the typedata that has a name equal to itemtype, if there 363/* returns the typedata that has a name equal to itemtype, if there
364 * isn't one, return the plural name that matches, if there still isn't 364 * isn't one, return the plural name that matches, if there still isn't
365 * one return NULL */ 365 * one return NULL */
366
367const typedata * 366const typedata *
368get_typedata_by_name (const char *name) 367get_typedata_by_name (const char *name)
369{ 368{
370 int i; 369 int i;
371 370
386 * returns a static array of the description. This can return 385 * returns a static array of the description. This can return
387 * a big buffer. 386 * a big buffer.
388 * if newline is true, we don't put parens around the description 387 * if newline is true, we don't put parens around the description
389 * but do put a newline at the end. Useful when dumping to files 388 * but do put a newline at the end. Useful when dumping to files
390 */ 389 */
391char * 390const char *
392describe_resistance (const object *op, int newline) 391describe_resistance (const object *op, int newline)
393{ 392{
394 static char buf[VERY_BIG_BUF]; 393 static char buf[VERY_BIG_BUF];
395 char buf1[VERY_BIG_BUF]; 394 char buf1[VERY_BIG_BUF];
396 int tmpvar; 395 int tmpvar;
415/* 414/*
416 * query_weight(object) returns a character pointer to a static buffer 415 * query_weight(object) returns a character pointer to a static buffer
417 * containing the text-representation of the weight of the given object. 416 * containing the text-representation of the weight of the given object.
418 * The buffer will be overwritten by the next call to query_weight(). 417 * The buffer will be overwritten by the next call to query_weight().
419 */ 418 */
420 419const char *
421char *
422query_weight (const object *op) 420query_weight (const object *op)
423{ 421{
424 static char buf[10]; 422 static char buf[10];
425 sint32 i = (op->nrof ? op->nrof : 1) * op->weight + op->carrying; 423 sint32 i = (op->nrof ? op->nrof : 1) * op->weight + op->carrying;
426 424
427 if (op->weight < 0) 425 if (op->weight < 0)
428 return " "; 426 return " ";
427
429 if (i % 1000) 428 if (i % 1000)
430 sprintf (buf, "%6.1f", i / 1000.0); 429 sprintf (buf, "%6.1f", i / 1000.0);
431 else 430 else
432 sprintf (buf, "%4d ", i / 1000); 431 sprintf (buf, "%4d ", i / 1000);
432
433 return buf; 433 return buf;
434} 434}
435 435
436/* 436/*
437 * Returns the pointer to a static buffer containing 437 * Returns the pointer to a static buffer containing
438 * the number requested (of the form first, second, third...) 438 * the number requested (of the form first, second, third...)
439 */ 439 */
440 440const char *
441char *
442get_levelnumber (int i) 441get_levelnumber (int i)
443{ 442{
444 static char buf[MAX_BUF]; 443 static char buf[MAX_BUF];
445 444
446 if (i > 99) 445 if (i > 99)
447 { 446 {
448 sprintf (buf, "%d.", i); 447 sprintf (buf, "%d.", i);
449 return buf; 448 return buf;
450 } 449 }
450
451 if (i < 21) 451 if (i < 21)
452 return levelnumbers[i]; 452 return levelnumbers[i];
453 if (!(i % 10)) 453 if (!(i % 10))
454 return levelnumbers_10[i / 10]; 454 return levelnumbers_10[i / 10];
455
455 strcpy (buf, numbers_10[i / 10]); 456 strcpy (buf, numbers_10[i / 10]);
456 strcat (buf, levelnumbers[i % 10]); 457 strcat (buf, levelnumbers[i % 10]);
457 return buf; 458 return buf;
458} 459}
459
460 460
461/* 461/*
462 * get_number(integer) returns the text-representation of the given number 462 * get_number(integer) returns the text-representation of the given number
463 * in a static buffer. The buffer might be overwritten at the next 463 * in a static buffer. The buffer might be overwritten at the next
464 * call to get_number(). 464 * call to get_number().
465 * It is currently only used by the query_name() function. 465 * It is currently only used by the query_name() function.
466 */ 466 */
467 467const char *
468char *
469get_number (int i) 468get_number (int i)
470{ 469{
471 if (i <= 20) 470 if (i <= 20)
472 return numbers[i]; 471 return numbers[i];
473 else 472 else
490 */ 489 */
491 490
492/* Aug 95 modified this slightly so that Skill tools don't have magic bonus 491/* Aug 95 modified this slightly so that Skill tools don't have magic bonus
493 * from stats.sp - b.t. 492 * from stats.sp - b.t.
494 */ 493 */
495char * 494const char *
496ring_desc (const object *op) 495ring_desc (const object *op)
497{ 496{
498 static char buf[VERY_BIG_BUF]; 497 static char buf[VERY_BIG_BUF];
499 int attr, val, len; 498 int attr, val, len;
500 499
508 if ((val = get_attr_value (&(op->stats), attr)) != 0) 507 if ((val = get_attr_value (&(op->stats), attr)) != 0)
509 { 508 {
510 sprintf (buf + strlen (buf), "(%s%+d)", short_stat_name[attr], val); 509 sprintf (buf + strlen (buf), "(%s%+d)", short_stat_name[attr], val);
511 } 510 }
512 } 511 }
512
513 if (op->stats.exp) 513 if (op->stats.exp)
514 sprintf (buf + strlen (buf), "(speed %+lld)", (long long) op->stats.exp); 514 sprintf (buf + strlen (buf), "(speed %+lld)", (long long) op->stats.exp);
515 if (op->stats.wc) 515 if (op->stats.wc)
516 sprintf (buf + strlen (buf), "(wc%+d)", op->stats.wc); 516 sprintf (buf + strlen (buf), "(wc%+d)", op->stats.wc);
517 if (op->stats.dam) 517 if (op->stats.dam)
539 strcat (buf, "(reflect spells)"); 539 strcat (buf, "(reflect spells)");
540 if (QUERY_FLAG (op, FLAG_REFL_MISSILE)) 540 if (QUERY_FLAG (op, FLAG_REFL_MISSILE))
541 strcat (buf, "(reflect missiles)"); 541 strcat (buf, "(reflect missiles)");
542 if (QUERY_FLAG (op, FLAG_STEALTH)) 542 if (QUERY_FLAG (op, FLAG_STEALTH))
543 strcat (buf, "(stealth)"); 543 strcat (buf, "(stealth)");
544
544 /* Shorten some of the names, so they appear better in the windows */ 545 /* Shorten some of the names, so they appear better in the windows */
545 len = strlen (buf); 546 len = strlen (buf);
546 DESCRIBE_PATH_SAFE (buf, op->path_attuned, "Attuned", &len, VERY_BIG_BUF); 547 DESCRIBE_PATH_SAFE (buf, op->path_attuned, "Attuned", &len, VERY_BIG_BUF);
547 DESCRIBE_PATH_SAFE (buf, op->path_repelled, "Repelled", &len, VERY_BIG_BUF); 548 DESCRIBE_PATH_SAFE (buf, op->path_repelled, "Repelled", &len, VERY_BIG_BUF);
548 DESCRIBE_PATH_SAFE (buf, op->path_denied, "Denied", &len, VERY_BIG_BUF); 549 DESCRIBE_PATH_SAFE (buf, op->path_denied, "Denied", &len, VERY_BIG_BUF);
613 case AMULET: 614 case AMULET:
614 case RING: 615 case RING:
615 if (!op->title) 616 if (!op->title)
616 { 617 {
617 /* If ring has a title, full description isn't so useful */ 618 /* If ring has a title, full description isn't so useful */
618 char *s = ring_desc (op); 619 const char *s = ring_desc (op);
619 620
620 if (s[0]) 621 if (s[0])
621 { 622 {
622 safe_strcat (buf, " ", &len, HUGE_BUF); 623 safe_strcat (buf, " ", &len, HUGE_BUF);
623 safe_strcat (buf, s, &len, HUGE_BUF); 624 safe_strcat (buf, s, &len, HUGE_BUF);
643 * overwritten. This may be a bad thing (it may be easier to assume the value 644 * overwritten. This may be a bad thing (it may be easier to assume the value
644 * returned is good forever.) However, it makes printing statements that 645 * returned is good forever.) However, it makes printing statements that
645 * use several names much easier (don't need to store them to temp variables.) 646 * use several names much easier (don't need to store them to temp variables.)
646 * 647 *
647 */ 648 */
648char * 649const char *
649query_name (const object *op) 650query_name (const object *op)
650{ 651{
651 static char buf[5][HUGE_BUF]; 652 static char buf[5][HUGE_BUF]; // OMFG
652 static int use_buf = 0; 653 static int use_buf = 0;
653 int len = 0; 654 int len = 0;
654 655
655#ifdef NEW_MATERIAL_CODE 656#ifdef NEW_MATERIAL_CODE
656 materialtype_t *mt; 657 materialtype_t *mt;
683 if (QUERY_FLAG (op, FLAG_DAMNED)) 684 if (QUERY_FLAG (op, FLAG_DAMNED))
684 safe_strcat (buf[use_buf], " (damned)", &len, HUGE_BUF); 685 safe_strcat (buf[use_buf], " (damned)", &len, HUGE_BUF);
685 else if (QUERY_FLAG (op, FLAG_CURSED)) 686 else if (QUERY_FLAG (op, FLAG_CURSED))
686 safe_strcat (buf[use_buf], " (cursed)", &len, HUGE_BUF); 687 safe_strcat (buf[use_buf], " (cursed)", &len, HUGE_BUF);
687 } 688 }
689
688 /* Basically, if the object is known magical (detect magic spell on it), 690 /* Basically, if the object is known magical (detect magic spell on it),
689 * and it isn't identified, print out the fact that 691 * and it isn't identified, print out the fact that
690 * it is magical. Assume that the detect magical spell will only set 692 * it is magical. Assume that the detect magical spell will only set
691 * KNOWN_MAGICAL if the item actually is magical. 693 * KNOWN_MAGICAL if the item actually is magical.
692 * 694 *
708 710
709 if (QUERY_FLAG (op, FLAG_APPLIED)) 711 if (QUERY_FLAG (op, FLAG_APPLIED))
710 { 712 {
711 switch (op->type) 713 switch (op->type)
712 { 714 {
713 case BOW: 715 case BOW:
714 case WAND: 716 case WAND:
715 case ROD: 717 case ROD:
716 case HORN: 718 case HORN:
717 safe_strcat (buf[use_buf], " (readied)", &len, HUGE_BUF); 719 safe_strcat (buf[use_buf], op->env && op->env->current_weapon == op ? " (readied)" : " (applied)", &len, HUGE_BUF);
718 break; 720 break;
719 case WEAPON: 721 case WEAPON:
720 safe_strcat (buf[use_buf], " (wielded)", &len, HUGE_BUF); 722 safe_strcat (buf[use_buf], op->env && op->env->current_weapon == op ? " (wielded)" : " (applied)", &len, HUGE_BUF);
721 break; 723 break;
722 case ARMOUR: 724 case ARMOUR:
723 case HELMET: 725 case HELMET:
724 case SHIELD: 726 case SHIELD:
725 case RING: 727 case RING:
726 case BOOTS: 728 case BOOTS:
727 case GLOVES: 729 case GLOVES:
728 case AMULET: 730 case AMULET:
729 case GIRDLE: 731 case GIRDLE:
730 case BRACERS: 732 case BRACERS:
731 case CLOAK: 733 case CLOAK:
732 safe_strcat (buf[use_buf], " (worn)", &len, HUGE_BUF); 734 safe_strcat (buf[use_buf], " (worn)", &len, HUGE_BUF);
733 break; 735 break;
734 case CONTAINER: 736 case CONTAINER:
735 safe_strcat (buf[use_buf], " (active)", &len, HUGE_BUF); 737 safe_strcat (buf[use_buf], " (active)", &len, HUGE_BUF);
736 break; 738 break;
737 case SKILL: 739 case SKILL:
738 default: 740 default:
739 safe_strcat (buf[use_buf], " (applied)", &len, HUGE_BUF); 741 safe_strcat (buf[use_buf], " (applied)", &len, HUGE_BUF);
740 } 742 }
741 } 743 }
744
742 if (QUERY_FLAG (op, FLAG_UNPAID)) 745 if (QUERY_FLAG (op, FLAG_UNPAID))
743 safe_strcat (buf[use_buf], " (unpaid)", &len, HUGE_BUF); 746 safe_strcat (buf[use_buf], " (unpaid)", &len, HUGE_BUF);
744 747
745 return buf[use_buf]; 748 return buf [use_buf];
746} 749}
747 750
748/* 751/*
749 * query_base_name(object) returns a character pointer pointing to a static 752 * query_base_name(object) returns a character pointer pointing to a static
750 * buffer which contains a verbose textual representation of the name 753 * buffer which contains a verbose textual representation of the name
784 } 787 }
785 else 788 else
786 { 789 {
787#endif 790#endif
788 if (!plural) 791 if (!plural)
789 strcpy (buf, op->name); 792 assign (buf, op->name);
790 else 793 else
791 strcpy (buf, op->name_pl); 794 assign (buf, op->name_pl);
795
792 len = strlen (buf); 796 len = strlen (buf);
793#ifdef NEW_MATERIAL_CODE 797#ifdef NEW_MATERIAL_CODE
794 } 798 }
795#endif 799#endif
796 800
800 safe_strcat (buf, op->title, &len, MAX_BUF); 804 safe_strcat (buf, op->title, &len, MAX_BUF);
801 } 805 }
802 806
803 switch (op->type) 807 switch (op->type)
804 { 808 {
805 case SPELLBOOK: 809 case SPELLBOOK:
806 case SCROLL: 810 case SCROLL:
807 case WAND: 811 case WAND:
808 case ROD: 812 case ROD:
809 if (QUERY_FLAG (op, FLAG_IDENTIFIED) || QUERY_FLAG (op, FLAG_BEEN_APPLIED)) 813 if (QUERY_FLAG (op, FLAG_IDENTIFIED) || QUERY_FLAG (op, FLAG_BEEN_APPLIED))
810 { 814 {
811 if (!op->title) 815 if (!op->title)
812 { 816 {
813 safe_strcat (buf, " of ", &len, MAX_BUF); 817 safe_strcat (buf, " of ", &len, MAX_BUF);
814 if (op->inv) 818 if (op->inv)
815 safe_strcat (buf, op->inv->name, &len, MAX_BUF); 819 safe_strcat (buf, op->inv->name, &len, MAX_BUF);
816 else 820 else
817 LOG (llevError, "Spellbook %s lacks inventory\n", &op->name); 821 LOG (llevError, "Spellbook %s lacks inventory\n", &op->name);
818 } 822 }
819 if (op->type != SPELLBOOK) 823 if (op->type != SPELLBOOK)
820 { 824 {
821 sprintf (buf2, " (lvl %d)", op->level); 825 sprintf (buf2, " (lvl %d)", op->level);
822 safe_strcat (buf, buf2, &len, MAX_BUF); 826 safe_strcat (buf, buf2, &len, MAX_BUF);
823 } 827 }
824 } 828 }
825 break; 829 break;
826 830
827 831
828 case SKILL: 832 case SKILL:
829 case AMULET: 833 case AMULET:
830 case RING: 834 case RING:
831 if (!op->title) 835 if (!op->title)
832 { 836 {
833 /* If ring has a title, full description isn't so useful */ 837 /* If ring has a title, full description isn't so useful */
834 char *s = ring_desc (op); 838 const char *s = ring_desc (op);
835 839
836 if (s[0]) 840 if (s[0])
837 { 841 {
838 safe_strcat (buf, " ", &len, MAX_BUF); 842 safe_strcat (buf, " ", &len, MAX_BUF);
839 safe_strcat (buf, s, &len, MAX_BUF); 843 safe_strcat (buf, s, &len, MAX_BUF);
840 } 844 }
841 } 845 }
842 break; 846 break;
847
843 default: 848 default:
844 if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) 849 if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED)))
845 {
846 sprintf (buf + strlen (buf), " %+d", op->magic); 850 sprintf (buf + strlen (buf), " %+d", op->magic);
847 }
848 } 851 }
852
849 return buf; 853 return buf;
850} 854}
851 855
852/* Break this off from describe_item - that function was way 856/* Break this off from describe_item - that function was way
853 * too long, making it difficult to read. This function deals 857 * too long, making it difficult to read. This function deals
854 * with describing the monsters & players abilities. It should only 858 * with describing the monsters & players abilities. It should only
855 * be called with monster & player objects. Returns a description 859 * be called with monster & player objects. Returns a description
856 * in a static buffer. 860 * in a static buffer.
857 */ 861 */
858
859static char * 862static char *
860describe_monster (const object *op) 863describe_monster (const object *op)
861{ 864{
862 char buf[MAX_BUF]; 865 char buf[MAX_BUF];
863 static char retbuf[VERY_BIG_BUF]; 866 static char retbuf[VERY_BIG_BUF];
933 { 936 {
934 treasure *t; 937 treasure *t;
935 int first = 1; 938 int first = 1;
936 939
937 for (t = op->randomitems->items; t != NULL; t = t->next) 940 for (t = op->randomitems->items; t != NULL; t = t->next)
938 if (t->item && (t->item->clone.type == SPELL)) 941 if (t->item && t->item->clone.type == SPELL)
939 { 942 {
940 if (first) 943 if (first)
941 { 944 {
942 first = 0; 945 first = 0;
943 strcat (retbuf, "(Spell abilities:)"); 946 strcat (retbuf, "(Spell abilities:)");
989 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 992 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
990 if (tmp->type == SKILL && !strcmp (tmp->name, "clawing")) 993 if (tmp->type == SKILL && !strcmp (tmp->name, "clawing"))
991 break; 994 break;
992 995
993 if (tmp && tmp->attacktype != 0) 996 if (tmp && tmp->attacktype != 0)
994 {
995 DESCRIBE_ABILITY (retbuf, tmp->attacktype, "Claws"); 997 { DESCRIBE_ABILITY (retbuf, tmp->attacktype, "Claws") }
996 }
997 else 998 else
998 {
999 DESCRIBE_ABILITY (retbuf, op->attacktype, "Attacks"); 999 { DESCRIBE_ABILITY (retbuf, op->attacktype, "Attacks") }
1000 }
1001 } 1000 }
1002 else 1001 else
1003 {
1004 DESCRIBE_ABILITY (retbuf, op->attacktype, "Attacks"); 1002 { DESCRIBE_ABILITY (retbuf, op->attacktype, "Attacks") }
1005 } 1003
1006 DESCRIBE_PATH (retbuf, op->path_attuned, "Attuned"); 1004 DESCRIBE_PATH (retbuf, op->path_attuned, "Attuned");
1007 DESCRIBE_PATH (retbuf, op->path_repelled, "Repelled"); 1005 DESCRIBE_PATH (retbuf, op->path_repelled, "Repelled");
1008 DESCRIBE_PATH (retbuf, op->path_denied, "Denied"); 1006 DESCRIBE_PATH (retbuf, op->path_denied, "Denied");
1007
1009 for (i = 0; i < NROFATTACKS; i++) 1008 for (i = 0; i < NROFATTACKS; i++)
1010 {
1011 if (op->resist[i]) 1009 if (op->resist[i])
1012 { 1010 {
1013 sprintf (buf, "(%s %+d)", resist_plus[i], op->resist[i]); 1011 sprintf (buf, "(%s %+d)", resist_plus[i], op->resist[i]);
1014 strcat (retbuf, buf); 1012 strcat (retbuf, buf);
1015 } 1013 }
1016 } 1014
1017 return retbuf; 1015 return retbuf;
1018} 1016}
1019 1017
1020 1018
1021/* 1019/*
1042 * 1040 *
1043 * Add 'owner' who is the person examining this object. 1041 * Add 'owner' who is the person examining this object.
1044 * owner can be null if no one is being associated with this 1042 * owner can be null if no one is being associated with this
1045 * item (eg, debug dump or the like) 1043 * item (eg, debug dump or the like)
1046 */ 1044 */
1047 1045const char *
1048char *
1049describe_item (const object *op, object *owner) 1046describe_item (const object *op, object *owner)
1050{ 1047{
1051 char buf[MAX_BUF]; 1048 char buf[MAX_BUF];
1052 static char retbuf[VERY_BIG_BUF]; 1049 static char retbuf[VERY_BIG_BUF];
1053 int identified, i; 1050 int identified, i;
1363 } 1360 }
1364 1361
1365 return retbuf; 1362 return retbuf;
1366} 1363}
1367 1364
1365std::string
1366object::describe_item (object *who)
1367{
1368 return std::string (::describe_item (this, who));
1369}
1370
1368/* Return true if the item is magical. A magical item is one that 1371/* Return true if the item is magical. A magical item is one that
1369 * increases/decreases any abilities, provides a resistance, 1372 * increases/decreases any abilities, provides a resistance,
1370 * has a generic magical bonus, or is an artifact. 1373 * has a generic magical bonus, or is an artifact.
1371 * This function is used by detect_magic to determine if an item 1374 * This function is used by detect_magic to determine if an item
1372 * should be marked as magical. 1375 * should be marked as magical.
1523 } 1526 }
1524 } 1527 }
1525 1528
1526 /* If the object is on a map, make sure we update its face */ 1529 /* If the object is on a map, make sure we update its face */
1527 if (op->map) 1530 if (op->map)
1528 update_object (op, UP_OBJ_FACE); 1531 update_object (op, UP_OBJ_CHANGE);
1529 else 1532 else
1530 { 1533 {
1531 pl = op->in_player (); 1534 pl = op->in_player ();
1532 if (pl) 1535 if (pl)
1533 /* A lot of the values can change from an update - might as well send 1536 /* A lot of the values can change from an update - might as well send

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines