| 691 | #endif /*0*/ |
| 692 | |
| 693 | void |
| 694 | assigninvlet(struct obj *otmp) |
| 695 | { |
| 696 | boolean inuse[invlet_basic]; |
| 697 | int i; |
| 698 | struct obj *obj; |
| 699 | |
| 700 | /* there should be at most one of these in inventory... */ |
| 701 | if (otmp->oclass == COIN_CLASS) { |
| 702 | otmp->invlet = GOLD_SYM; |
| 703 | return; |
| 704 | } |
| 705 | |
| 706 | for (i = 0; i < invlet_basic; i++) |
| 707 | inuse[i] = FALSE; |
| 708 | for (obj = gi.invent; obj; obj = obj->nobj) |
| 709 | if (obj != otmp) { |
| 710 | i = obj->invlet; |
| 711 | if ('a' <= i && i <= 'z') |
| 712 | inuse[i - 'a'] = TRUE; |
| 713 | else if ('A' <= i && i <= 'Z') |
| 714 | inuse[i - 'A' + 26] = TRUE; |
| 715 | if (i == otmp->invlet) |
| 716 | otmp->invlet = 0; |
| 717 | } |
| 718 | if ((i = otmp->invlet) |
| 719 | && (('a' <= i && i <= 'z') || ('A' <= i && i <= 'Z'))) |
| 720 | return; |
| 721 | for (i = gl.lastinvnr + 1; i != gl.lastinvnr; i++) { |
| 722 | if (i == invlet_basic) { |
| 723 | i = -1; |
| 724 | continue; |
| 725 | } |
| 726 | if (!inuse[i]) |
| 727 | break; |
| 728 | } |
| 729 | otmp->invlet = |
| 730 | (inuse[i] ? NOINVSYM : (i < 26) ? ('a' + i) : ('A' + i - 26)); |
| 731 | gl.lastinvnr = i; |
| 732 | } |
| 733 | |
| 734 | /* note: assumes ASCII; toggling a bit puts lowercase in front of uppercase */ |
| 735 | #define inv_rank(o) ((o)->invlet ^ 040) |
no outgoing calls
no test coverage detected