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.1 by root, Fri Feb 3 07:11:31 2006 UTC vs.
Revision 1.1.1.3 by elmex, Wed Mar 15 14:04:36 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines