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.1.1.3 by elmex, Wed Mar 15 14:04:36 2006 UTC vs.
Revision 1.2 by elmex, Sun Aug 13 17:16:00 2006 UTC

1/* 1/*
2 * static char *rcsid_item_c = 2 * static char *rcsid_item_c =
3 * "$Id: item.c,v 1.1.1.3 2006/03/15 14:04:36 elmex Exp $"; 3 * "$Id: item.c,v 1.2 2006/08/13 17:16:00 elmex dead $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
112{BOW, "bow", "bows", SK_BOWYER, 0}, 112{BOW, "bow", "bows", SK_BOWYER, 0},
113{WEAPON, "weapon", "weapons", SK_SMITHERY, 0}, 113{WEAPON, "weapon", "weapons", SK_SMITHERY, 0},
114{ARMOUR, "armour", "armour", SK_SMITHERY, 0}, 114{ARMOUR, "armour", "armour", SK_SMITHERY, 0},
115{PEDESTAL, "pedestal", "pedestals", 0, 0}, 115{PEDESTAL, "pedestal", "pedestals", 0, 0},
116{ALTAR, "altar", "altars", 0, 0}, 116{ALTAR, "altar", "altars", 0, 0},
117{CONFUSION, "confusion", "confusions", 0, 0},
117{LOCKED_DOOR, "locked door", "locked doors", 0, 0}, 118{LOCKED_DOOR, "locked door", "locked doors", 0, 0},
118{SPECIAL_KEY, "special key", "special keys", 0, 0}, 119{SPECIAL_KEY, "special key", "special keys", 0, 0},
119{MAP, "map", "maps", 0, 0}, 120{MAP, "map", "maps", 0, 0},
120{DOOR, "door", "doors", 0, 0}, 121{DOOR, "door", "doors", 0, 0},
121{KEY, "key", "keys", 0, 0}, 122{KEY, "key", "keys", 0, 0},
274 * generation code, and when loading legacy objects. It returns 275 * generation code, and when loading legacy objects. It returns
275 * the item_power it calculates. 276 * the item_power it calculates.
276 * If flag is 1, we return the number of enchantment, and not the 277 * If flag is 1, we return the number of enchantment, and not the
277 * the power. This is used in the treasure code. 278 * the power. This is used in the treasure code.
278 */ 279 */
279int calc_item_power(const object *op, int flag) 280int calc_item_power(object *op, int flag)
280{ 281{
281 int i, tmp, enc; 282 int i, tmp, enc;
282 283
283 enc = 0; 284 enc = 0;
284 for (i=0; i<NUM_STATS; i++) 285 for (i=0; i<NUM_STATS; i++)
371 * returns a static array of the description. This can return 372 * returns a static array of the description. This can return
372 * a big buffer. 373 * a big buffer.
373 * if newline is true, we don't put parens around the description 374 * if newline is true, we don't put parens around the description
374 * but do put a newline at the end. Useful when dumping to files 375 * but do put a newline at the end. Useful when dumping to files
375 */ 376 */
376char *describe_resistance(const object *op, int newline) 377char *describe_resistance(object *op, int newline)
377{ 378{
378 static char buf[VERY_BIG_BUF]; 379 static char buf[VERY_BIG_BUF];
379 char buf1[VERY_BIG_BUF]; 380 char buf1[VERY_BIG_BUF];
380 int tmpvar; 381 int tmpvar;
381 382
398 * query_weight(object) returns a character pointer to a static buffer 399 * query_weight(object) returns a character pointer to a static buffer
399 * containing the text-representation of the weight of the given object. 400 * containing the text-representation of the weight of the given object.
400 * The buffer will be overwritten by the next call to query_weight(). 401 * The buffer will be overwritten by the next call to query_weight().
401 */ 402 */
402 403
403char *query_weight(const object *op) { 404char *query_weight(object *op) {
404 static char buf[10]; 405 static char buf[10];
405 sint32 i=(op->nrof?op->nrof:1)*op->weight+op->carrying; 406 sint32 i=(op->nrof?op->nrof:1)*op->weight+op->carrying;
406 407
407 if(op->weight<0) 408 if(op->weight<0)
408 return " "; 409 return " ";
461 * client handle names. 462 * client handle names.
462 */ 463 */
463/* Aug 95 modified this slightly so that Skill tools don't have magic bonus 464/* Aug 95 modified this slightly so that Skill tools don't have magic bonus
464 * from stats.sp - b.t. 465 * from stats.sp - b.t.
465 */ 466 */
466char *ring_desc (const object *op) 467char *ring_desc (object *op)
467{ 468{
468 static char buf[VERY_BIG_BUF]; 469 static char buf[VERY_BIG_BUF];
469 int attr, val,len; 470 int attr, val,len;
470 471
471 buf[0] = 0; 472 buf[0] = 0;
527 528
528/* 529/*
529 * query_short_name(object) is similar to query_name, but doesn't 530 * query_short_name(object) is similar to query_name, but doesn't
530 * contain any information about object status (worn/cursed/etc.) 531 * contain any information about object status (worn/cursed/etc.)
531 */ 532 */
532const char *query_short_name(const object *op) 533const char *query_short_name(object *op)
533{ 534{
534 static char buf[HUGE_BUF]; 535 static char buf[HUGE_BUF];
535 char buf2[HUGE_BUF]; 536 char buf2[HUGE_BUF];
536 int len=0; 537 int len=0;
537 538
601 * overwritten. This may be a bad thing (it may be easier to assume the value 602 * overwritten. This may be a bad thing (it may be easier to assume the value
602 * returned is good forever.) However, it makes printing statements that 603 * returned is good forever.) However, it makes printing statements that
603 * use several names much easier (don't need to store them to temp variables.) 604 * use several names much easier (don't need to store them to temp variables.)
604 * 605 *
605 */ 606 */
606char *query_name(const object *op) { 607char *query_name(object *op) {
607 static char buf[5][HUGE_BUF]; 608 static char buf[5][HUGE_BUF];
608 static int use_buf=0; 609 static int use_buf=0;
609 int len=0; 610 int len=0;
610#ifdef NEW_MATERIAL_CODE 611#ifdef NEW_MATERIAL_CODE
611 materialtype_t *mt; 612 materialtype_t *mt;
704 * call to query_base_name(). This is a lot like query_name, but we 705 * call to query_base_name(). This is a lot like query_name, but we
705 * don't include the item count or item status. Used for inventory sorting 706 * don't include the item count or item status. Used for inventory sorting
706 * and sending to client. 707 * and sending to client.
707 * If plural is set, we generate the plural name of this. 708 * If plural is set, we generate the plural name of this.
708 */ 709 */
709const char *query_base_name(const object *op, int plural) { 710const char *query_base_name(object *op, int plural) {
710 static char buf[MAX_BUF], buf2[MAX_BUF]; 711 static char buf[MAX_BUF], buf2[MAX_BUF];
711 int len; 712 int len;
712 materialtype_t *mt; 713 materialtype_t *mt;
713 714
714 if((!plural && !op->name) || (plural && !op->name_pl)) 715 if((!plural && !op->name) || (plural && !op->name_pl))
794 * with describing the monsters & players abilities. It should only 795 * with describing the monsters & players abilities. It should only
795 * be called with monster & player objects. Returns a description 796 * be called with monster & player objects. Returns a description
796 * in a static buffer. 797 * in a static buffer.
797 */ 798 */
798 799
799static char *describe_monster(const object *op) { 800static char *describe_monster(object *op) {
800 char buf[MAX_BUF]; 801 char buf[MAX_BUF];
801 static char retbuf[VERY_BIG_BUF]; 802 static char retbuf[VERY_BIG_BUF];
802 int i; 803 int i;
803 804
804 retbuf[0]='\0'; 805 retbuf[0]='\0';
961 * Add 'owner' who is the person examining this object. 962 * Add 'owner' who is the person examining this object.
962 * owner can be null if no one is being associated with this 963 * owner can be null if no one is being associated with this
963 * item (eg, debug dump or the like) 964 * item (eg, debug dump or the like)
964 */ 965 */
965 966
966char *describe_item(const object *op, object *owner) { 967char *describe_item(object *op, object *owner) {
967 char buf[MAX_BUF]; 968 char buf[MAX_BUF];
968 static char retbuf[VERY_BIG_BUF]; 969 static char retbuf[VERY_BIG_BUF];
969 int identified,i; 970 int identified,i;
970 971
971 retbuf[0]='\0'; 972 retbuf[0]='\0';
1253 * has a generic magical bonus, or is an artifact. 1254 * has a generic magical bonus, or is an artifact.
1254 * This function is used by detect_magic to determine if an item 1255 * This function is used by detect_magic to determine if an item
1255 * should be marked as magical. 1256 * should be marked as magical.
1256 */ 1257 */
1257 1258
1258int is_magical(const object *op) { 1259int is_magical(object *op) {
1259 int i; 1260 int i;
1260 1261
1261 /* living creatures are considered non magical */ 1262 /* living creatures are considered non magical */
1262 if (QUERY_FLAG(op, FLAG_ALIVE)) return 0; 1263 if (QUERY_FLAG(op, FLAG_ALIVE)) return 0;
1263 1264
1324/* need_identify returns true if the item should be identified. This 1325/* need_identify returns true if the item should be identified. This
1325 * function really should not exist - by default, any item not identified 1326 * function really should not exist - by default, any item not identified
1326 * should need it. 1327 * should need it.
1327 */ 1328 */
1328 1329
1329int need_identify(const object *op) { 1330int need_identify(object *op) {
1330 switch(op->type) { 1331 switch(op->type) {
1331 case RING: 1332 case RING:
1332 case WAND: 1333 case WAND:
1333 case ROD: 1334 case ROD:
1334 case HORN: 1335 case HORN:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines