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.2 by elmex, Wed Feb 22 18:01:18 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.2 2006/02/22 18:01:18 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
275 * generation code, and when loading legacy objects. It returns 275 * generation code, and when loading legacy objects. It returns
276 * the item_power it calculates. 276 * the item_power it calculates.
277 * 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
278 * the power. This is used in the treasure code. 278 * the power. This is used in the treasure code.
279 */ 279 */
280int calc_item_power(object *op, int flag) 280int calc_item_power(const object *op, int flag)
281{ 281{
282 int i, tmp, enc; 282 int i, tmp, enc;
283 283
284 enc = 0; 284 enc = 0;
285 for (i=0; i<NUM_STATS; i++) 285 for (i=0; i<NUM_STATS; i++)
372 * returns a static array of the description. This can return 372 * returns a static array of the description. This can return
373 * a big buffer. 373 * a big buffer.
374 * 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
375 * 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
376 */ 376 */
377char *describe_resistance(object *op, int newline) 377char *describe_resistance(const object *op, int newline)
378{ 378{
379 static char buf[VERY_BIG_BUF]; 379 static char buf[VERY_BIG_BUF];
380 char buf1[VERY_BIG_BUF]; 380 char buf1[VERY_BIG_BUF];
381 int tmpvar; 381 int tmpvar;
382 382
399 * query_weight(object) returns a character pointer to a static buffer 399 * query_weight(object) returns a character pointer to a static buffer
400 * containing the text-representation of the weight of the given object. 400 * containing the text-representation of the weight of the given object.
401 * 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().
402 */ 402 */
403 403
404char *query_weight(object *op) { 404char *query_weight(const object *op) {
405 static char buf[10]; 405 static char buf[10];
406 sint32 i=(op->nrof?op->nrof:1)*op->weight+op->carrying; 406 sint32 i=(op->nrof?op->nrof:1)*op->weight+op->carrying;
407 407
408 if(op->weight<0) 408 if(op->weight<0)
409 return " "; 409 return " ";
462 * client handle names. 462 * client handle names.
463 */ 463 */
464/* 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
465 * from stats.sp - b.t. 465 * from stats.sp - b.t.
466 */ 466 */
467char *ring_desc (object *op) 467char *ring_desc (const object *op)
468{ 468{
469 static char buf[VERY_BIG_BUF]; 469 static char buf[VERY_BIG_BUF];
470 int attr, val,len; 470 int attr, val,len;
471 471
472 buf[0] = 0; 472 buf[0] = 0;
528 528
529/* 529/*
530 * 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
531 * contain any information about object status (worn/cursed/etc.) 531 * contain any information about object status (worn/cursed/etc.)
532 */ 532 */
533const char *query_short_name(object *op) 533const char *query_short_name(const object *op)
534{ 534{
535 static char buf[HUGE_BUF]; 535 static char buf[HUGE_BUF];
536 char buf2[HUGE_BUF]; 536 char buf2[HUGE_BUF];
537 int len=0; 537 int len=0;
538 538
602 * 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
603 * returned is good forever.) However, it makes printing statements that 603 * 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.) 604 * use several names much easier (don't need to store them to temp variables.)
605 * 605 *
606 */ 606 */
607char *query_name(object *op) { 607char *query_name(const object *op) {
608 static char buf[5][HUGE_BUF]; 608 static char buf[5][HUGE_BUF];
609 static int use_buf=0; 609 static int use_buf=0;
610 int len=0; 610 int len=0;
611#ifdef NEW_MATERIAL_CODE 611#ifdef NEW_MATERIAL_CODE
612 materialtype_t *mt; 612 materialtype_t *mt;
705 * 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
706 * 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
707 * and sending to client. 707 * and sending to client.
708 * If plural is set, we generate the plural name of this. 708 * If plural is set, we generate the plural name of this.
709 */ 709 */
710const char *query_base_name(object *op, int plural) { 710const char *query_base_name(const object *op, int plural) {
711 static char buf[MAX_BUF], buf2[MAX_BUF]; 711 static char buf[MAX_BUF], buf2[MAX_BUF];
712 int len; 712 int len;
713 materialtype_t *mt; 713 materialtype_t *mt;
714 714
715 if((!plural && !op->name) || (plural && !op->name_pl)) 715 if((!plural && !op->name) || (plural && !op->name_pl))
795 * with describing the monsters & players abilities. It should only 795 * with describing the monsters & players abilities. It should only
796 * be called with monster & player objects. Returns a description 796 * be called with monster & player objects. Returns a description
797 * in a static buffer. 797 * in a static buffer.
798 */ 798 */
799 799
800static char *describe_monster(object *op) { 800static char *describe_monster(const object *op) {
801 char buf[MAX_BUF]; 801 char buf[MAX_BUF];
802 static char retbuf[VERY_BIG_BUF]; 802 static char retbuf[VERY_BIG_BUF];
803 int i; 803 int i;
804 804
805 retbuf[0]='\0'; 805 retbuf[0]='\0';
962 * Add 'owner' who is the person examining this object. 962 * Add 'owner' who is the person examining this object.
963 * 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
964 * item (eg, debug dump or the like) 964 * item (eg, debug dump or the like)
965 */ 965 */
966 966
967char *describe_item(object *op, object *owner) { 967char *describe_item(const object *op, object *owner) {
968 char buf[MAX_BUF]; 968 char buf[MAX_BUF];
969 static char retbuf[VERY_BIG_BUF]; 969 static char retbuf[VERY_BIG_BUF];
970 int identified,i; 970 int identified,i;
971 971
972 retbuf[0]='\0'; 972 retbuf[0]='\0';
1254 * has a generic magical bonus, or is an artifact. 1254 * has a generic magical bonus, or is an artifact.
1255 * 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
1256 * should be marked as magical. 1256 * should be marked as magical.
1257 */ 1257 */
1258 1258
1259int is_magical(object *op) { 1259int is_magical(const object *op) {
1260 int i; 1260 int i;
1261 1261
1262 /* living creatures are considered non magical */ 1262 /* living creatures are considered non magical */
1263 if (QUERY_FLAG(op, FLAG_ALIVE)) return 0; 1263 if (QUERY_FLAG(op, FLAG_ALIVE)) return 0;
1264 1264
1325/* need_identify returns true if the item should be identified. This 1325/* need_identify returns true if the item should be identified. This
1326 * function really should not exist - by default, any item not identified 1326 * function really should not exist - by default, any item not identified
1327 * should need it. 1327 * should need it.
1328 */ 1328 */
1329 1329
1330int need_identify(object *op) { 1330int need_identify(const object *op) {
1331 switch(op->type) { 1331 switch(op->type) {
1332 case RING: 1332 case RING:
1333 case WAND: 1333 case WAND:
1334 case ROD: 1334 case ROD:
1335 case HORN: 1335 case HORN:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines