"(contents, N zorkmids)" fix (trunk only)
Some code I recently added was misusing count_unpaid() and would traverse some or all of inventory instead of just container's contents when looking for unpaid items. Add mew routine `is_unpaid(obj)' to do what I was intending to do with count_unpaid().
This commit is contained in:
@@ -1975,6 +1975,7 @@ E void NDECL(shopper_financial_report);
|
|||||||
E int FDECL(inhishop, (struct monst *));
|
E int FDECL(inhishop, (struct monst *));
|
||||||
E struct monst *FDECL(shop_keeper, (CHAR_P));
|
E struct monst *FDECL(shop_keeper, (CHAR_P));
|
||||||
E boolean FDECL(tended_shop, (struct mkroom *));
|
E boolean FDECL(tended_shop, (struct mkroom *));
|
||||||
|
E boolean FDECL(is_unpaid, (struct obj *));
|
||||||
E void FDECL(delete_contents, (struct obj *));
|
E void FDECL(delete_contents, (struct obj *));
|
||||||
E void FDECL(obfree, (struct obj *,struct obj *));
|
E void FDECL(obfree, (struct obj *,struct obj *));
|
||||||
E void FDECL(home_shk, (struct monst *,BOOLEAN_P));
|
E void FDECL(home_shk, (struct monst *,BOOLEAN_P));
|
||||||
|
|||||||
@@ -1311,7 +1311,7 @@ boolean shop_floor_obj;
|
|||||||
(toloc != MIGR_LADDER_UP && rn2(3));
|
(toloc != MIGR_LADDER_UP && rn2(3));
|
||||||
|
|
||||||
container = Has_contents(otmp);
|
container = Has_contents(otmp);
|
||||||
unpaid = (otmp->unpaid || (container && count_unpaid(otmp->cobj)));
|
unpaid = is_unpaid(otmp);
|
||||||
|
|
||||||
if(OBJ_AT(x, y)) {
|
if(OBJ_AT(x, y)) {
|
||||||
for(obj = level.objects[x][y]; obj; obj = obj->nexthere)
|
for(obj = level.objects[x][y]; obj; obj = obj->nexthere)
|
||||||
|
|||||||
@@ -702,13 +702,13 @@ boolean broken;
|
|||||||
if (broken ||
|
if (broken ||
|
||||||
!costly_spot(x, y) || *in_rooms(x, y, SHOPBASE) != *u.ushops) {
|
!costly_spot(x, y) || *in_rooms(x, y, SHOPBASE) != *u.ushops) {
|
||||||
/* thrown out of a shop or into a different shop */
|
/* thrown out of a shop or into a different shop */
|
||||||
if (count_unpaid(obj))
|
if (is_unpaid(obj))
|
||||||
(void)stolen_value(obj, u.ux, u.uy,
|
(void)stolen_value(obj, u.ux, u.uy,
|
||||||
(boolean)shkp->mpeaceful, FALSE);
|
(boolean)shkp->mpeaceful, FALSE);
|
||||||
if (broken) obj->no_charge = 1;
|
if (broken) obj->no_charge = 1;
|
||||||
} else {
|
} else {
|
||||||
if (costly_spot(u.ux, u.uy) && costly_spot(x, y)) {
|
if (costly_spot(u.ux, u.uy) && costly_spot(x, y)) {
|
||||||
if (count_unpaid(obj))
|
if (is_unpaid(obj))
|
||||||
subfrombill(obj, shkp);
|
subfrombill(obj, shkp);
|
||||||
else if (x != shkp->mx || y != shkp->my)
|
else if (x != shkp->mx || y != shkp->my)
|
||||||
sellobj(obj, x, y);
|
sellobj(obj, x, y);
|
||||||
|
|||||||
@@ -827,7 +827,7 @@ ring:
|
|||||||
Strcat(bp, " (alternate weapon; not wielded)");
|
Strcat(bp, " (alternate weapon; not wielded)");
|
||||||
}
|
}
|
||||||
if(obj->owornmask & W_QUIVER) Strcat(bp, " (in quiver)");
|
if(obj->owornmask & W_QUIVER) Strcat(bp, " (in quiver)");
|
||||||
if (!iflags.suppress_price && count_unpaid(obj)) {
|
if (!iflags.suppress_price && is_unpaid(obj)) {
|
||||||
long quotedprice = unpaid_cost(obj, TRUE);
|
long quotedprice = unpaid_cost(obj, TRUE);
|
||||||
|
|
||||||
Sprintf(eos(bp), " (%s, %ld %s)",
|
Sprintf(eos(bp), " (%s, %ld %s)",
|
||||||
|
|||||||
13
src/shk.c
13
src/shk.c
@@ -769,6 +769,14 @@ register boolean silent;
|
|||||||
return (struct bill_x *)0;
|
return (struct bill_x *)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check whether an object or any of its contents belongs to a shop */
|
||||||
|
boolean
|
||||||
|
is_unpaid(obj)
|
||||||
|
struct obj *obj;
|
||||||
|
{
|
||||||
|
return (obj->unpaid || (Has_contents(obj) && count_unpaid(obj->cobj)));
|
||||||
|
}
|
||||||
|
|
||||||
/* Delete the contents of the given object. */
|
/* Delete the contents of the given object. */
|
||||||
void
|
void
|
||||||
delete_contents(obj)
|
delete_contents(obj)
|
||||||
@@ -2621,14 +2629,13 @@ xchar x, y;
|
|||||||
|
|
||||||
/* get one case out of the way: nothing to sell, and no gold */
|
/* get one case out of the way: nothing to sell, and no gold */
|
||||||
if (!isgold && ((offer + gltmp) == 0L || sell_how == SELL_DONTSELL)) {
|
if (!isgold && ((offer + gltmp) == 0L || sell_how == SELL_DONTSELL)) {
|
||||||
boolean unpaid = (obj->unpaid ||
|
boolean unpaid = is_unpaid(obj);
|
||||||
(container && count_unpaid(obj->cobj)));
|
|
||||||
|
|
||||||
if(container) {
|
if(container) {
|
||||||
dropped_container(obj, shkp, FALSE);
|
dropped_container(obj, shkp, FALSE);
|
||||||
if(!obj->unpaid && !saleitem)
|
if(!obj->unpaid && !saleitem)
|
||||||
obj->no_charge = 1;
|
obj->no_charge = 1;
|
||||||
if(obj->unpaid || count_unpaid(obj->cobj))
|
if (unpaid)
|
||||||
subfrombill(obj, shkp);
|
subfrombill(obj, shkp);
|
||||||
} else obj->no_charge = 1;
|
} else obj->no_charge = 1;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user