From: nethack.rankin Date: Thu, 4 Jan 2007 05:46:14 +0000 (+0000) Subject: container groundwork / splitting welded weapons (trunk only) X-Git-Tag: MOVE2GIT~768 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c45ce7a999c013fea5b38e7797157cc6c9f41efa;p=nethack container groundwork / splitting welded weapons (trunk only) Some miscellaneous changes preparatory to enhancing the container interface. This also fixes a minor inconsistency in object manipulation: askchain() wouldn't let you split a stack of welded weapons but getobj() would, so you couldn't get rid of part of the stack using 'D' or #loot, but you could with 'd' (and post-3.4.3, with #adjust). Now getobj() will behave like askchain(); if you have 3 cursed daggers welded to your hand, you won't be able to drop 1 or 2 of them anymore. --- diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 3afad9964..2c43ea1de 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -183,6 +183,7 @@ allow hero to attempt to offer the Amulet at ordinary altars shooting range for crossbow isn't affected by strength; multi-shot volley is right-handed boomerang throw travels counterclockwise monsters can use ranged attacks over/around boulders, same as hero +can't drop part of a stack of N weapons welded to hero's hand Platform- and/or Interface-Specific Fixes diff --git a/include/extern.h b/include/extern.h index b9cb954d4..3c8a8ec40 100644 --- a/include/extern.h +++ b/include/extern.h @@ -616,7 +616,7 @@ E void FDECL(done_in_by, (struct monst *,int)); E void VDECL(panic, (const char *,...)) PRINTF_F(1,2); #if !defined(MAKEDEFS_C) && !defined(LEV_LEX_C) E void FDECL(done, (int)); -E void FDECL(container_contents, (struct obj *,BOOLEAN_P,BOOLEAN_P)); +E void FDECL(container_contents, (struct obj *,BOOLEAN_P,BOOLEAN_P,BOOLEAN_P)); E void FDECL(terminate, (int)); E int NDECL(num_genocides); E void FDECL(delayed_killer, (int, int, const char*)); @@ -1639,8 +1639,8 @@ E void FDECL(add_valid_menu_class, (int)); E boolean FDECL(allow_all, (struct obj *)); E boolean FDECL(allow_category, (struct obj *)); E boolean FDECL(is_worn_by_type, (struct obj *)); -#ifdef USE_TRAMPOLI E int FDECL(ck_bag, (struct obj *)); +#ifdef USE_TRAMPOLI E int FDECL(in_container, (struct obj *)); E int FDECL(out_container, (struct obj *)); #endif diff --git a/src/do.c b/src/do.c index 6cedf77b1..ee75ca29f 100644 --- a/src/do.c +++ b/src/do.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)do.c 3.5 2006/07/08 */ +/* SCCS Id: @(#)do.c 3.5 2007/01/02 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -657,6 +657,7 @@ int retry; assigninvlet(u_gold); /* might end up as NOINVSYM */ u_gold->nobj = invent; invent = u_gold; + u_gold->where = OBJ_INVENT; } #endif if (retry) { @@ -732,6 +733,7 @@ int retry; u_gold = invent; invent = u_gold->nobj; u_gold->in_use = FALSE; + u_gold->where = OBJ_FREE; dealloc_obj(u_gold); update_inventory(); } diff --git a/src/end.c b/src/end.c index 1c44e25ae..17afad2b9 100644 --- a/src/end.c +++ b/src/end.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)end.c 3.5 2006/04/14 */ +/* SCCS Id: @(#)end.c 3.5 2007/01/02 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -384,7 +384,7 @@ boolean taken; obj->cknown = obj->lknown = 1; } (void) display_inventory((char *)0, TRUE); - container_contents(invent, TRUE, TRUE); + container_contents(invent, TRUE, TRUE, FALSE); } if (c == 'q') done_stopprint++; } @@ -959,9 +959,9 @@ die: void -container_contents(list, identified, all_containers) +container_contents(list, identified, all_containers, reportempty) struct obj *list; -boolean identified, all_containers; +boolean identified, all_containers, reportempty; { register struct obj *box, *obj; char buf[BUFSZ]; @@ -1002,15 +1002,15 @@ boolean identified, all_containers; display_nhwindow(tmpwin, TRUE); destroy_nhwindow(tmpwin); if (all_containers) - container_contents(box->cobj, identified, TRUE); - } else { - if (cat || deadcat) { - pline("%s%s contains Schroedinger's %scat!", - (box->quan > 1L) ? "One of the " : "", - (box->quan > 1L) ? xname(box) : upstart(xname(box)), - (deadcat) ? "dead " : ""); - display_nhwindow(WIN_MESSAGE, FALSE); - } + container_contents(box->cobj, identified, TRUE, + reportempty); + } else if (cat || deadcat) { + pline("%s Schroedinger's %scat!", + Tobjnam(box, "contain"), deadcat ? "dead " : ""); + display_nhwindow(WIN_MESSAGE, FALSE); + } else if (reportempty) { + pline("%s is empty.", upstart(thesimpleoname(box))); + display_nhwindow(WIN_MESSAGE, FALSE); } } if (!all_containers) diff --git a/src/invent.c b/src/invent.c index 2764547b7..14881c370 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)invent.c 3.5 2006/11/29 */ +/* SCCS Id: @(#)invent.c 3.5 2007/01/02 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -13,6 +13,7 @@ STATIC_DCL void FDECL(invdisp_nothing, (const char *,const char *)); STATIC_DCL boolean FDECL(worn_wield_only, (struct obj *)); STATIC_DCL boolean FDECL(only_here, (struct obj *)); STATIC_DCL void FDECL(compactify,(char *)); +STATIC_DCL boolean FDECL(splittable, (struct obj *)); STATIC_DCL boolean FDECL(taking_off, (const char *)); STATIC_DCL boolean FDECL(putting_on, (const char *)); STATIC_PTR int FDECL(ckunpaid,(struct obj *)); @@ -49,13 +50,11 @@ register struct obj *otmp; register int i; register struct obj *obj; -#ifdef GOLDOBJ - /* There is only one of these in inventory... */ - if (otmp->oclass == COIN_CLASS) { + /* there should be at most one of these in inventory... */ + if (otmp->oclass == COIN_CLASS) { otmp->invlet = GOLD_SYM; return; } -#endif for(i = 0; i < 52; i++) inuse[i] = FALSE; for(obj = invent; obj; obj = obj->nobj) if(obj != otmp) { @@ -736,6 +735,15 @@ register char *buf; } } +/* some objects shouldn't be split when count given to getobj or askchain */ +STATIC_OVL boolean +splittable(obj) +struct obj *obj; +{ + return !((obj->otyp == LOADSTONE && obj->cursed) || + (obj == uwep && welded(uwep))); +} + /* match the prompt for either 'T' or 'R' command */ STATIC_OVL boolean taking_off(action) @@ -1098,11 +1106,11 @@ register const char *let,*word; if(cnt == 0) return (struct obj *)0; if(cnt != otmp->quan) { /* don't split a stack of cursed loadstones */ - if (otmp->otyp == LOADSTONE && otmp->cursed) + if (splittable(otmp)) + otmp = splitobj(otmp, cnt); + else if (otmp->otyp == LOADSTONE && otmp->cursed) /* kludge for canletgo()'s can't-drop-this message */ otmp->corpsenm = (int) cnt; - else - otmp = splitobj(otmp, cnt); } } return(otmp); @@ -1463,10 +1471,8 @@ nextclass: sym = 'n'; else { sym = 'y'; - if (yn_number < otmp->quan && !welded(otmp) && - (!otmp->cursed || otmp->otyp != LOADSTONE)) { + if (yn_number < otmp->quan && splittable(otmp)) otmp = splitobj(otmp, yn_number); - } } } switch(sym){ diff --git a/src/pickup.c b/src/pickup.c index 84e0f62ab..1991454dd 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -30,7 +30,6 @@ STATIC_DCL long FDECL(carry_count, STATIC_DCL int FDECL(lift_object, (struct obj *,struct obj *,long *,BOOLEAN_P)); STATIC_DCL boolean FDECL(mbag_explodes, (struct obj *,int)); STATIC_PTR int FDECL(in_container,(struct obj *)); -STATIC_PTR int FDECL(ck_bag,(struct obj *)); STATIC_PTR int FDECL(out_container,(struct obj *)); STATIC_DCL long FDECL(mbag_item_gone, (int,struct obj *)); STATIC_DCL void FDECL(observe_quantum_cat, (struct obj *)); @@ -1908,7 +1907,7 @@ register struct obj *obj; return(current_container ? 1 : -1); } -STATIC_PTR int +int ck_bag(obj) struct obj *obj; { @@ -2174,7 +2173,7 @@ ask_again2: if (cnt) Strcat(pbuf, "m"); switch (yn_function(qbuf, pbuf, 'n')) { case ':': - container_contents(current_container, FALSE, FALSE); + container_contents(current_container, FALSE, FALSE, TRUE); goto ask_again2; case 'y': if (query_classes(selection, &one_by_one, &allflag, @@ -2257,6 +2256,7 @@ ask_again2: assigninvlet(u_gold); /* might end up as NOINVSYM */ u_gold->nobj = invent; invent = u_gold; + u_gold->where = OBJ_INVENT; } #endif add_valid_menu_class(0); /* reset */ @@ -2287,6 +2287,7 @@ ask_again2: u_gold = invent; invent = u_gold->nobj; u_gold->in_use = FALSE; + u_gold->where = OBJ_FREE; dealloc_obj(u_gold); } #endif