Externify trycall() and replace many docall() calls with it

trycall() is a short docall() wrapper that is a no-op if the item is
already identified or the player has called the object type already. For
some reason, many calls to docall() did those same exact checks
beforehand.

This commit eliminates that redundancy by converting those calls into
trycall(), which is now made extern rather than local to do.c. No
behavior should be changed by this commit; I've checked that none of the
affected places could take a different code path now that the
oc_name_known and oc_uname checks are removed.
This commit is contained in:
copperwater
2022-03-14 09:48:19 -04:00
parent 9dd69f4b88
commit a61a97856b
9 changed files with 33 additions and 54 deletions
+3 -2
View File
@@ -7,7 +7,6 @@
#include "hack.h"
static void trycall(struct obj *);
static void polymorph_sink(void);
static boolean teleport_sink(void);
static void dosinkring(struct obj *);
@@ -315,7 +314,9 @@ doaltarobj(struct obj *obj)
}
}
static void
/* If obj is neither formally identified nor informally called something
* already, prompt the player to call its object type. */
void
trycall(struct obj *obj)
{
if (!objects[obj->otyp].oc_name_known && !objects[obj->otyp].oc_uname)