… | |
… | |
387 | * returns a static array of the description. This can return |
387 | * returns a static array of the description. This can return |
388 | * a big buffer. |
388 | * a big buffer. |
389 | * if newline is true, we don't put parens around the description |
389 | * if newline is true, we don't put parens around the description |
390 | * but do put a newline at the end. Useful when dumping to files |
390 | * but do put a newline at the end. Useful when dumping to files |
391 | */ |
391 | */ |
392 | char * |
392 | const char * |
393 | describe_resistance (const object *op, int newline) |
393 | describe_resistance (const object *op, int newline) |
394 | { |
394 | { |
395 | static char buf[VERY_BIG_BUF]; |
395 | static char buf[VERY_BIG_BUF]; |
396 | char buf1[VERY_BIG_BUF]; |
396 | char buf1[VERY_BIG_BUF]; |
397 | int tmpvar; |
397 | int tmpvar; |
… | |
… | |
416 | /* |
416 | /* |
417 | * query_weight(object) returns a character pointer to a static buffer |
417 | * query_weight(object) returns a character pointer to a static buffer |
418 | * containing the text-representation of the weight of the given object. |
418 | * containing the text-representation of the weight of the given object. |
419 | * The buffer will be overwritten by the next call to query_weight(). |
419 | * The buffer will be overwritten by the next call to query_weight(). |
420 | */ |
420 | */ |
421 | |
421 | const char * |
422 | char * |
|
|
423 | query_weight (const object *op) |
422 | query_weight (const object *op) |
424 | { |
423 | { |
425 | static char buf[10]; |
424 | static char buf[10]; |
426 | sint32 i = (op->nrof ? op->nrof : 1) * op->weight + op->carrying; |
425 | sint32 i = (op->nrof ? op->nrof : 1) * op->weight + op->carrying; |
427 | |
426 | |
428 | if (op->weight < 0) |
427 | if (op->weight < 0) |
429 | return " "; |
428 | return " "; |
|
|
429 | |
430 | if (i % 1000) |
430 | if (i % 1000) |
431 | sprintf (buf, "%6.1f", i / 1000.0); |
431 | sprintf (buf, "%6.1f", i / 1000.0); |
432 | else |
432 | else |
433 | sprintf (buf, "%4d ", i / 1000); |
433 | sprintf (buf, "%4d ", i / 1000); |
|
|
434 | |
434 | return buf; |
435 | return buf; |
435 | } |
436 | } |
436 | |
437 | |
437 | /* |
438 | /* |
438 | * Returns the pointer to a static buffer containing |
439 | * Returns the pointer to a static buffer containing |
439 | * the number requested (of the form first, second, third...) |
440 | * the number requested (of the form first, second, third...) |
440 | */ |
441 | */ |
441 | |
442 | const char * |
442 | char * |
|
|
443 | get_levelnumber (int i) |
443 | get_levelnumber (int i) |
444 | { |
444 | { |
445 | static char buf[MAX_BUF]; |
445 | static char buf[MAX_BUF]; |
446 | |
446 | |
447 | if (i > 99) |
447 | if (i > 99) |
448 | { |
448 | { |
449 | sprintf (buf, "%d.", i); |
449 | sprintf (buf, "%d.", i); |
450 | return buf; |
450 | return buf; |
451 | } |
451 | } |
|
|
452 | |
452 | if (i < 21) |
453 | if (i < 21) |
453 | return levelnumbers[i]; |
454 | return levelnumbers[i]; |
454 | if (!(i % 10)) |
455 | if (!(i % 10)) |
455 | return levelnumbers_10[i / 10]; |
456 | return levelnumbers_10[i / 10]; |
|
|
457 | |
456 | strcpy (buf, numbers_10[i / 10]); |
458 | strcpy (buf, numbers_10[i / 10]); |
457 | strcat (buf, levelnumbers[i % 10]); |
459 | strcat (buf, levelnumbers[i % 10]); |
458 | return buf; |
460 | return buf; |
459 | } |
461 | } |
460 | |
462 | |
… | |
… | |
462 | * get_number(integer) returns the text-representation of the given number |
464 | * get_number(integer) returns the text-representation of the given number |
463 | * in a static buffer. The buffer might be overwritten at the next |
465 | * in a static buffer. The buffer might be overwritten at the next |
464 | * call to get_number(). |
466 | * call to get_number(). |
465 | * It is currently only used by the query_name() function. |
467 | * It is currently only used by the query_name() function. |
466 | */ |
468 | */ |
467 | char * |
469 | const char * |
468 | get_number (int i) |
470 | get_number (int i) |
469 | { |
471 | { |
470 | if (i <= 20) |
472 | if (i <= 20) |
471 | return numbers[i]; |
473 | return numbers[i]; |
472 | else |
474 | else |
… | |
… | |
489 | */ |
491 | */ |
490 | |
492 | |
491 | /* Aug 95 modified this slightly so that Skill tools don't have magic bonus |
493 | /* Aug 95 modified this slightly so that Skill tools don't have magic bonus |
492 | * from stats.sp - b.t. |
494 | * from stats.sp - b.t. |
493 | */ |
495 | */ |
494 | char * |
496 | const char * |
495 | ring_desc (const object *op) |
497 | ring_desc (const object *op) |
496 | { |
498 | { |
497 | static char buf[VERY_BIG_BUF]; |
499 | static char buf[VERY_BIG_BUF]; |
498 | int attr, val, len; |
500 | int attr, val, len; |
499 | |
501 | |
… | |
… | |
612 | case AMULET: |
614 | case AMULET: |
613 | case RING: |
615 | case RING: |
614 | if (!op->title) |
616 | if (!op->title) |
615 | { |
617 | { |
616 | /* If ring has a title, full description isn't so useful */ |
618 | /* If ring has a title, full description isn't so useful */ |
617 | char *s = ring_desc (op); |
619 | const char *s = ring_desc (op); |
618 | |
620 | |
619 | if (s[0]) |
621 | if (s[0]) |
620 | { |
622 | { |
621 | safe_strcat (buf, " ", &len, HUGE_BUF); |
623 | safe_strcat (buf, " ", &len, HUGE_BUF); |
622 | safe_strcat (buf, s, &len, HUGE_BUF); |
624 | safe_strcat (buf, s, &len, HUGE_BUF); |
… | |
… | |
642 | * 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 |
643 | * returned is good forever.) However, it makes printing statements that |
645 | * returned is good forever.) However, it makes printing statements that |
644 | * 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.) |
645 | * |
647 | * |
646 | */ |
648 | */ |
647 | char * |
649 | const char * |
648 | query_name (const object *op) |
650 | query_name (const object *op) |
649 | { |
651 | { |
650 | static char buf[5][HUGE_BUF]; // OMFG |
652 | static char buf[5][HUGE_BUF]; // OMFG |
651 | static int use_buf = 0; |
653 | static int use_buf = 0; |
652 | int len = 0; |
654 | int len = 0; |
… | |
… | |
831 | case AMULET: |
833 | case AMULET: |
832 | case RING: |
834 | case RING: |
833 | if (!op->title) |
835 | if (!op->title) |
834 | { |
836 | { |
835 | /* If ring has a title, full description isn't so useful */ |
837 | /* If ring has a title, full description isn't so useful */ |
836 | char *s = ring_desc (op); |
838 | const char *s = ring_desc (op); |
837 | |
839 | |
838 | if (s[0]) |
840 | if (s[0]) |
839 | { |
841 | { |
840 | safe_strcat (buf, " ", &len, MAX_BUF); |
842 | safe_strcat (buf, " ", &len, MAX_BUF); |
841 | safe_strcat (buf, s, &len, MAX_BUF); |
843 | safe_strcat (buf, s, &len, MAX_BUF); |
… | |
… | |
1039 | * |
1041 | * |
1040 | * Add 'owner' who is the person examining this object. |
1042 | * Add 'owner' who is the person examining this object. |
1041 | * owner can be null if no one is being associated with this |
1043 | * owner can be null if no one is being associated with this |
1042 | * item (eg, debug dump or the like) |
1044 | * item (eg, debug dump or the like) |
1043 | */ |
1045 | */ |
1044 | |
1046 | const char * |
1045 | char * |
|
|
1046 | describe_item (const object *op, object *owner) |
1047 | describe_item (const object *op, object *owner) |
1047 | { |
1048 | { |
1048 | char buf[MAX_BUF]; |
1049 | char buf[MAX_BUF]; |
1049 | static char retbuf[VERY_BIG_BUF]; |
1050 | static char retbuf[VERY_BIG_BUF]; |
1050 | int identified, i; |
1051 | int identified, i; |