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:
20
src/o_init.c
20
src/o_init.c
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user