diff -Nub nethack-3.4.3/include/extern.h nethack-patched/include/extern.h --- nethack-3.4.3/include/extern.h 2006-07-21 22:16:04.000000000 +0000 +++ nethack-patched/include/extern.h 2006-07-21 22:16:16.000000000 +0000 @@ -1399,6 +1399,7 @@ E int FDECL(rnd_class, (int,int)); E const char *FDECL(cloak_simple_name, (struct obj *)); E const char *FDECL(mimic_obj_name, (struct monst *)); +E int FDECL(ring_to_gem, (struct objclass *)); /* ### options.c ### */ diff -Nub nethack-3.4.3/src/invent.c nethack-patched/src/invent.c --- nethack-3.4.3/src/invent.c 2006-07-21 22:00:36.000000000 +0000 +++ nethack-patched/src/invent.c 2006-07-21 22:04:18.000000000 +0000 @@ -1477,11 +1477,15 @@ fully_identify_obj(otmp) struct obj *otmp; { + int gemtyp; makeknown(otmp->otyp); if (otmp->oartifact) discover_artifact((xchar)otmp->oartifact); otmp->known = otmp->dknown = otmp->bknown = otmp->rknown = 1; if (otmp->otyp == EGG && otmp->corpsenm != NON_PM) learn_egg_type(otmp->corpsenm); + if (otmp->oclass == RING_CLASS && + (gemtyp = ring_to_gem(&objects[otmp->otyp]))) + makeknown(gemtyp); } /* ggetobj callback routine; identify an object and give immediate feedback */ diff -Nub nethack-3.4.3/src/objnam.c nethack-patched/src/objnam.c --- nethack-3.4.3/src/objnam.c 2003-12-11 17:05:22.000000000 +0000 +++ nethack-patched/src/objnam.c 2006-07-21 22:03:44.000000000 +0000 @@ -117,7 +117,25 @@ Strcpy(buf, "spellbook"); break; case RING_CLASS: + /* handle "ring of foo (green stone)" -ajo */ Strcpy(buf, "ring"); + if (dn) { + int gemtyp = ring_to_gem(ocl); + if (gemtyp && !objects[gemtyp].oc_name_known) { + if(nn) { + /* no unique rings at the moment, but... */ + if (ocl->oc_unique) + Strcpy(buf, actualn); + else + Sprintf(buf, "ring of %s", actualn); + } + dn = OBJ_DESCR(objects[gemtyp]); + if(un) + Sprintf(eos(buf)," called %s",un); + Sprintf(eos(buf), " (%s stone)", dn); + return buf; + } + } break; case AMULET_CLASS: if(nn) @@ -230,6 +248,22 @@ #endif /* OVLB */ #ifdef OVL1 +int +ring_to_gem(oc) +struct objclass *oc; +{ + register int i; + const char *dn = OBJ_DESCR(*oc); + register const char *zn = 0; + for(i = bases[GEM_CLASS]; i <= LAST_GEM; i++) { + if((zn = OBJ_NAME(objects[i])) && !strcmpi(dn, zn)) { + return i; + } + } + return 0; +} + + char * xname(obj) register struct obj *obj; @@ -448,8 +482,16 @@ Sprintf(buf, "ring of %s", actualn); else if(un) Sprintf(buf, "ring called %s", un); - else + else { + /* gems may not be identified yet... */ + register int gemidx = ring_to_gem(&objects[obj->otyp]); + if(gemidx && !objects[gemidx].oc_name_known) { + Sprintf(buf, "%s stone ring", OBJ_DESCR(objects[gemidx])); + } else { Sprintf(buf, "%s ring", dn); + } + break; + } break; case GEM_CLASS: { @@ -1784,6 +1826,7 @@ char oclass; char *un, *dn, *actualn; const char *name=0; + int chance; cnt = spe = spesgn = typ = very = rechrg = blessed = uncursed = iscursed = @@ -2203,6 +2246,7 @@ } } i = oclass ? bases[(int)oclass] : 1; + chance = 1; while(i < NUM_OBJECTS && (!oclass || objects[i].oc_class == oclass)){ register const char *zn; @@ -2223,8 +2267,28 @@ typ = i; goto typfnd; } + + /* Allow user to wish for "(color) stone ring" -ajo */ + if (dn && oclass == RING_CLASS) { + char unidn[22]; /* >= sizeof("yellowish brown stone") */ + int gemidx = ring_to_gem(&objects[i]); + if (gemidx) { + Sprintf(unidn, "%s stone", OBJ_DESCR(objects[gemidx])); + if (wishymatch(dn, unidn, FALSE)) { + if (0 == rn2(chance++)) { + typ = i; + } + } + } + } + i++; } + /* Wishing for a "green stone ring" sometimes drops out here with + a jade ring, and sometimes drops out here with an emerald ring, + for example. -ajo */ + if (typ) goto typfnd; + if (actualn) { struct Jitem *j = Japanese_items; while(j->item) { diff -Nub nethack-3.4.3/src/u_init.c nethack-patched/src/u_init.c --- nethack-3.4.3/src/u_init.c 2003-12-11 17:05:22.000000000 +0000 +++ nethack-patched/src/u_init.c 2006-07-21 22:12:18.000000000 +0000 @@ -1010,8 +1010,12 @@ obj = addinv(obj); /* Make the type known if necessary */ - if (OBJ_DESCR(objects[otyp]) && obj->known) + if (OBJ_DESCR(objects[otyp]) && obj->known) { discover_object(otyp, TRUE, FALSE); + /* hack: ID gems of rings in starting inv -AJO */ + if (obj->oclass == RING_CLASS) + fully_identify_obj(obj); + } if (otyp == OIL_LAMP) discover_object(POT_OIL, TRUE, FALSE);