E char *FDECL(upstart, (char *));
E char *FDECL(mungspaces, (char *));
E char *FDECL(eos, (char *));
+E char *FDECL(strkitten, (char *,CHAR_P));
E char *FDECL(s_suffix, (const char *));
E char *FDECL(xcrypt, (const char *,char *));
E boolean FDECL(onlyspace, (const char *));
-/* SCCS Id: @(#)hacklib.c 3.4 1999/04/10 */
+/* SCCS Id: @(#)hacklib.c 3.4 2002/12/13 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* Copyright (c) Robert Patrick Rankin, 1991 */
/* NetHack may be freely redistributed. See license for details. */
char * upstart (char *)
char * mungspaces (char *)
char * eos (char *)
+ char * strkitten (char *,char)
char * s_suffix (const char *)
char * xcrypt (const char *, char *)
boolean onlyspace (const char *)
return s;
}
+/* strcat(s, {c,'\0'}); */
+char *
+strkitten(s, c) /* append a character to a string (in place) */
+ char *s;
+ char c;
+{
+ char *p = eos(s);
+
+ *p++ = c;
+ *p = '\0';
+ return s;
+}
+
char *
s_suffix(s) /* return a name converted to possessive */
const char *s;
-/* SCCS Id: @(#)invent.c 3.4 2002/10/07 */
+/* SCCS Id: @(#)invent.c 3.4 2002/12/13 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
int oletct, iletct, unpaid, oc_of_sym;
#endif
char sym, *ip, olets[MAXOCLASSES+5], ilets[MAXOCLASSES+5];
+ char extra_removeables[3+1]; /* uwep,uswapwep,uquiver */
char buf[BUFSZ], qbuf[QBUFSZ];
if (resultflags) *resultflags = 0;
break;
}
+ extra_removeables[0] = '\0';
+ if (takeoff) {
+ /* arbitrary types of items can be placed in the weapon slots
+ [any duplicate entries in extra_removeables[] won't matter] */
+ if (uwep) (void)strkitten(extra_removeables, uwep->oclass);
+ if (uswapwep) (void)strkitten(extra_removeables, uswapwep->oclass);
+ if (uquiver) (void)strkitten(extra_removeables, uquiver->oclass);
+ }
+
ip = buf;
olets[oletct = 0] = '\0';
while ((sym = *ip++) != '\0') {
if (sym == ' ') continue;
oc_of_sym = def_char_to_objclass(sym);
- if (takeoff && !(uwep && oc_of_sym == uwep->oclass) &&
- (oc_of_sym != MAXOCLASSES)) {
- if (!index(removeables, oc_of_sym)) {
+ if (takeoff && oc_of_sym != MAXOCLASSES) {
+ if (index(extra_removeables, oc_of_sym)) {
+ ; /* skip rest of takeoff checks */
+ } else if (!index(removeables, oc_of_sym)) {
pline("Not applicable.");
return 0;
} else if (oc_of_sym == ARMOR_CLASS && !wearing_armor()) {
You("are not wearing any armor.");
return 0;
- } else if (oc_of_sym == WEAPON_CLASS && !uwep && !uswapwep && !uquiver) {
+ } else if (oc_of_sym == WEAPON_CLASS &&
+ !uwep && !uswapwep && !uquiver) {
You("are not wielding anything.");
return 0;
} else if (oc_of_sym == RING_CLASS && !uright && !uleft) {