* Get valuables from the given list. Revised code: the list always remains * intact. */
| 760 | * intact. |
| 761 | */ |
| 762 | staticfn void |
| 763 | get_valuables(struct obj *list) /* inventory or container contents */ |
| 764 | { |
| 765 | struct obj *obj; |
| 766 | int i; |
| 767 | |
| 768 | /* find amulets and gems, ignoring all artifacts */ |
| 769 | for (obj = list; obj; obj = obj->nobj) |
| 770 | if (Has_contents(obj)) { |
| 771 | get_valuables(obj->cobj); |
| 772 | } else if (obj->oartifact) { |
| 773 | continue; |
| 774 | } else if (obj->oclass == AMULET_CLASS) { |
| 775 | i = obj->otyp - FIRST_AMULET; |
| 776 | if (!ga.amulets[i].count) { |
| 777 | ga.amulets[i].count = obj->quan; |
| 778 | ga.amulets[i].typ = obj->otyp; |
| 779 | } else |
| 780 | ga.amulets[i].count += obj->quan; /* always adds one */ |
| 781 | } else if (obj->oclass == GEM_CLASS && obj->otyp <= LAST_GLASS_GEM) { |
| 782 | /* last+1: combine all glass gems into one slot */ |
| 783 | i = min(obj->otyp, LAST_REAL_GEM + 1) - FIRST_REAL_GEM; |
| 784 | if (!gg.gems[i].count) { |
| 785 | gg.gems[i].count = obj->quan; |
| 786 | gg.gems[i].typ = obj->otyp; |
| 787 | } else |
| 788 | gg.gems[i].count += obj->quan; |
| 789 | } |
| 790 | return; |
| 791 | } |
| 792 | |
| 793 | /* |
| 794 | * Sort collected valuables, most frequent to least. We could just |