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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
4
src/do.c
4
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();
|
||||
}
|
||||
|
||||
26
src/end.c
26
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)
|
||||
|
||||
28
src/invent.c
28
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){
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user