dropping unpaid items vs containers (trunk only)

From a bug report, the 'D'
command would list 'u' as an item category choice if you were carrying
unpaid items inside a container, but if those were the only unpaid items
then nothing would happen once the dropping stage was reached.  Applied
to all menustyles (except partial, which bypasses categories and goes
straight to a menu listing all items).  There were two alternatives for
the fix:  suppress 'u' as an applicable category when it only applies
to container contents, or include the container among the drop candidates
even though it isn't an unpaid item itself.  I went with the latter; it's
simpler to implement and also feels a little more intuitive than behaving
like there aren't any unpaid items present.
This commit is contained in:
nethack.rankin
2009-03-28 01:36:12 +00:00
parent b8b8a65dfb
commit 1ab038dca5
3 changed files with 20 additions and 16 deletions

View File

@@ -315,6 +315,8 @@ auto-wielding a polearm took no time if ESC was used to cancel target choice
applying a bullwhip while at very edge of map could target beyond edge,
potentially leading to a panic or crash
prevent temple priests and minions from wearing helms of opposite alignment
'D' drop command didn't handle 'u' choice correctly if the only unpaid items
were inside containers
Platform- and/or Interface-Specific Fixes

View File

@@ -1233,7 +1233,7 @@ STATIC_PTR int
ckunpaid(otmp)
register struct obj *otmp;
{
return((int)(otmp->unpaid));
return (otmp->unpaid || (Has_contents(otmp) && count_unpaid(otmp)));
}
boolean

View File

@@ -379,23 +379,25 @@ allow_category(obj)
struct obj *obj;
{
if (Role_if(PM_PRIEST)) obj->bknown = TRUE;
if (((index(valid_menu_classes,'u') != (char *)0) && obj->unpaid) ||
(index(valid_menu_classes, obj->oclass) != (char *)0))
/* if obj's class is in the list, then obj is acceptable */
if (index(valid_menu_classes, obj->oclass))
return TRUE;
else if (((index(valid_menu_classes,'U') != (char *)0) &&
(obj->oclass != COIN_CLASS && obj->bknown && !obj->blessed && !obj->cursed)))
return TRUE;
else if (((index(valid_menu_classes,'B') != (char *)0) &&
(obj->oclass != COIN_CLASS && obj->bknown && obj->blessed)))
return TRUE;
else if (((index(valid_menu_classes,'C') != (char *)0) &&
(obj->oclass != COIN_CLASS && obj->bknown && obj->cursed)))
return TRUE;
else if (((index(valid_menu_classes,'X') != (char *)0) &&
(obj->oclass != COIN_CLASS && !obj->bknown)))
return TRUE;
else
/* unpaid and BUC checks don't apply to coins */
if (obj->oclass == COIN_CLASS)
return FALSE;
/* check for unpaid item */
if (index(valid_menu_classes, 'u') &&
(obj->unpaid || (Has_contents(obj) && count_unpaid(obj))))
return TRUE;
/* check for particular bless/curse state */
if (!obj->bknown ? index(valid_menu_classes, 'X') : /* unknown BUC state */
obj->blessed ? index(valid_menu_classes, 'B') : /* known blessed */
!obj->cursed ? index(valid_menu_classes, 'U') : /* known uncursed */
index(valid_menu_classes, 'C')) /* known cursed */
return TRUE;
/* obj isn't acceptable */
return FALSE;
}
#if 0 /* not used */