Match object description via single function

making the code more readable.

Instead of doing strcmp(OBJ_DESCR(objects[otyp]), "foo"),
just call objdescr_is(obj, "foo")

(via xNetHack)
This commit is contained in:
Pasi Kallinen
2020-10-20 19:19:54 +03:00
parent 5880da9269
commit 566dde8683
10 changed files with 42 additions and 30 deletions

View File

@@ -282,6 +282,26 @@ shuffle_all()
return;
}
/* Return TRUE if the provided string matches the unidentified description of
* the provided object. */
boolean
objdescr_is(obj, descr)
struct obj *obj;
const char *descr;
{
const char *objdescr;
if (!obj) {
impossible("objdescr_is: null obj");
return FALSE;
}
objdescr = OBJ_DESCR(objects[obj->otyp]);
if (!objdescr)
return FALSE; /* no obj description, no match */
return !strcmp(objdescr, descr);
}
/* find the object index for snow boots; used [once] by slippery ice code */
int
find_skates()