| 4663 | } |
| 4664 | |
| 4665 | staticfn int |
| 4666 | readobjnam_postparse2(struct _readobjnam_data *d) |
| 4667 | { |
| 4668 | int i; |
| 4669 | |
| 4670 | /* "grey stone" check must be before general "stone" */ |
| 4671 | for (i = 0; i < SIZE(o_ranges); i++) |
| 4672 | if (!strcmpi(d->bp, o_ranges[i].name)) { |
| 4673 | d->typ = rnd_class(o_ranges[i].f_o_range, o_ranges[i].l_o_range); |
| 4674 | return 2; /*goto typfnd;*/ |
| 4675 | } |
| 4676 | |
| 4677 | if (!BSTRCMPI(d->bp, d->p - 6, " stone") |
| 4678 | || !BSTRCMPI(d->bp, d->p - 4, " gem")) { |
| 4679 | d->p[!strcmpi(d->p - 4, " gem") ? -4 : -6] = '\0'; |
| 4680 | d->oclass = GEM_CLASS; |
| 4681 | d->dn = d->actualn = d->bp; |
| 4682 | return 1; /*goto srch;*/ |
| 4683 | } else if (!strcmpi(d->bp, "looking glass")) { |
| 4684 | ; /* avoid false hit on "* glass" */ |
| 4685 | } else if (!BSTRCMPI(d->bp, d->p - 6, " glass") |
| 4686 | || !strcmpi(d->bp, "glass")) { |
| 4687 | char *s = d->bp; |
| 4688 | |
| 4689 | /* treat "broken glass" as a non-existent item; since "broken" is |
| 4690 | also a chest/box prefix it might have been stripped off above */ |
| 4691 | if (d->broken || strstri(s, "broken")) { |
| 4692 | d->otmp = (struct obj *) 0; |
| 4693 | return 3; /* return otmp */ |
| 4694 | } |
| 4695 | if (!strncmpi(s, "worthless ", 10)) |
| 4696 | s += 10; |
| 4697 | if (!strncmpi(s, "piece of ", 9)) |
| 4698 | s += 9; |
| 4699 | if (!strncmpi(s, "colored ", 8)) |
| 4700 | s += 8; |
| 4701 | else if (!strncmpi(s, "coloured ", 9)) |
| 4702 | s += 9; |
| 4703 | if (!strcmpi(s, "glass")) { /* choose random color */ |
| 4704 | /* 9 different kinds */ |
| 4705 | d->typ = FIRST_GLASS_GEM + rn2(NUM_GLASS_GEMS); |
| 4706 | if (objects[d->typ].oc_class == GEM_CLASS) |
| 4707 | return 2; /*goto typfnd;*/ |
| 4708 | else |
| 4709 | d->typ = 0; /* somebody changed objects[]? punt */ |
| 4710 | } else { /* try to construct canonical form */ |
| 4711 | char tbuf[BUFSZ]; |
| 4712 | |
| 4713 | Strcpy(tbuf, "worthless piece of "); |
| 4714 | Strcat(tbuf, s); /* assume it starts with the color */ |
| 4715 | Strcpy(d->bp, tbuf); |
| 4716 | } |
| 4717 | } |
| 4718 | |
| 4719 | d->actualn = d->bp; |
| 4720 | if (!d->dn) |
| 4721 | d->dn = d->actualn; /* ex. "skull cap" */ |
| 4722 |
no test coverage detected