MCPcopy Index your code
hub / github.com/NetHack/NetHack / readobjnam_postparse1

Function readobjnam_postparse1

src/objnam.c:4239–4663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4237}
4238
4239staticfn int
4240readobjnam_postparse1(struct _readobjnam_data *d)
4241{
4242 int i;
4243
4244 /* now we have the actual name, as delivered by xname, say
4245 * green potions called whisky
4246 * scrolls labeled "QWERTY"
4247 * egg
4248 * fortune cookies
4249 * very heavy iron ball named hoei
4250 * wand of wishing
4251 * elven cloak
4252 */
4253 if ((d->p = strstri(d->bp, " named ")) != 0) {
4254 *d->p = 0;
4255 /* note: if 'name' is too long, oname() will truncate it */
4256 d->name = d->p + 7;
4257 }
4258 if ((d->p = strstri(d->bp, " called ")) != 0) {
4259 *d->p = 0;
4260 /* note: if 'un' is too long, obj lookup just won't match anything */
4261 d->un = d->p + 8;
4262 /* "helmet called telepathy" is not "helmet" (a specific type)
4263 * "shield called reflection" is not "shield" (a general type)
4264 */
4265 for (i = 0; i < SIZE(o_ranges); i++)
4266 if (!strcmpi(d->bp, o_ranges[i].name)) {
4267 d->oclass = o_ranges[i].oclass;
4268 return 1; /*goto srch;*/
4269 }
4270 }
4271 if ((d->p = strstri(d->bp, " labeled ")) != 0) {
4272 *d->p = 0;
4273 d->dn = d->p + 9;
4274 } else if ((d->p = strstri(d->bp, " labelled ")) != 0) {
4275 *d->p = 0;
4276 d->dn = d->p + 10;
4277 }
4278 if ((d->p = strstri(d->bp, " of spinach")) != 0) {
4279 *d->p = 0;
4280 d->contents = TIN_SPINACH;
4281 }
4282 /* real vs fake is only useful for wizard mode but we'll accept its
4283 parsing in normal play (result is never real Amulet for that case) */
4284 if ((d->p = strstri(d->bp, OBJ_DESCR(objects[AMULET_OF_YENDOR]))) != 0
4285 && (d->p == d->bp || d->p[-1] == ' ')) {
4286 char *s = d->bp;
4287
4288 /* "Amulet of Yendor" matches two items, name of real Amulet
4289 and description of fake one; player can explicitly specify
4290 "real" to disambiguate, but not specifying "fake" achieves
4291 the same thing; "real" and "fake" are parsed above with other
4292 prefixes so that combinations like "blessed real" and "real
4293 blessed" work as expected; also accept partial specification
4294 of the full name of the fake; unlike the prefix recognition
4295 loop above, these have to be in the right order when more
4296 than one is present (similar to worthless glass gems below) */

Callers 1

readobjnamFunction · 0.85

Calls 15

strstriFunction · 0.85
name_to_monFunction · 0.85
tin_variety_txtFunction · 0.85
name_to_monplusFunction · 0.85
makesingularFunction · 0.85
wishymatchFunction · 0.85
eosFunction · 0.85
mksobjFunction · 0.85
weightFunction · 0.85
def_char_to_objclassFunction · 0.85
copyncharsFunction · 0.85
rnd_otyp_by_namedescFunction · 0.85

Tested by

no test coverage detected