From 6d4aa312e6251e97a182a4f99fe85cc2cda5243b Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 22 Apr 2015 09:02:38 +0300 Subject: [PATCH] Unify hero free hand check and msg --- include/extern.h | 1 + src/pickup.c | 23 ++++++++++++++++------- src/steed.c | 9 +-------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/include/extern.h b/include/extern.h index f651976bb..d5d6bbb47 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1701,6 +1701,7 @@ E struct obj *FDECL(pick_obj, (struct obj *)); E int NDECL(encumber_msg); E int NDECL(doloot); E boolean FDECL(container_gone, (int (*)(OBJ_P))); +E boolean NDECL(u_handsy); E int FDECL(use_container, (struct obj **,int)); E int FDECL(loot_mon, (struct monst *,int *,boolean *)); E int NDECL(dotip); diff --git a/src/pickup.c b/src/pickup.c index fe6a991a5..3866c2287 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -2099,6 +2099,19 @@ explain_container_prompt() } } +boolean +u_handsy() +{ + if (nohands(youmonst.data)) { + You("have no hands!"); /* not `body_part(HAND)' */ + return FALSE; + } else if (!freehand()) { + You("have no free %s.", body_part(HAND)); + return FALSE; + } + return TRUE; +} + static const char stashable[] = { ALLOW_COUNT, COIN_CLASS, ALL_CLASSES, 0 }; int @@ -2115,13 +2128,9 @@ int held; int used = 0; emptymsg[0] = '\0'; - if (nohands(youmonst.data)) { - You("have no hands!"); /* not `body_part(HAND)' */ - return 0; - } else if (!freehand()) { - You("have no free %s.", body_part(HAND)); - return 0; - } + + if (!u_handsy()) return 0; + if (obj->olocked) { pline("%s locked.", Tobjnam(obj, "are")); if (held) You("must put it down to unlock."); diff --git a/src/steed.c b/src/steed.c index a18b418b9..8bfe3fe0e 100644 --- a/src/steed.c +++ b/src/steed.c @@ -46,14 +46,7 @@ use_saddle(otmp) const char *s; - /* Can you use it? */ - if (nohands(youmonst.data)) { - You("have no hands!"); /* not `body_part(HAND)' */ - return 0; - } else if (!freehand()) { - You("have no free %s.", body_part(HAND)); - return 0; - } + if (!u_handsy()) return 0; /* Select an animal */ if (u.uswallow || Underwater || !getdir((char *)0)) {