From 43e65726f77c28ca85fbb1b9337b956b606b700b Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Mon, 15 Apr 2002 10:52:20 +0000 Subject: [PATCH] shop credit fix [ Fix a bug reported in the newsgroup; I thought I sent this last week, but it isn't in the current code so I must have forgotten. ] When I split u_left_shop() into two routines I neglected to propagate the early return condition from the second half to the first. The result is that if you leave a shop with unpaid goods but have enough credit there to cover the cost, the shopkeeper will take that credit and be satisified, but the kops were still getting summoned as if he had been robbed. --- doc/fixes34.1 | 1 + src/shk.c | 29 ++++++++++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/doc/fixes34.1 b/doc/fixes34.1 index a09129672..5e3a05cf3 100644 --- a/doc/fixes34.1 +++ b/doc/fixes34.1 @@ -75,6 +75,7 @@ lookat monster notes if you see monster is trapped don't crash when angry shopkeeper re-enters the shop and you pick up something monsters with WAITFORU strategy should act if successfully attacked by non-damaging attacks (e.g. seduction, rust damage) +don't summon kops if credit covers cost of unpaid goods taken out of shop Platform- and/or Interface-Specific Fixes diff --git a/src/shk.c b/src/shk.c index e9076de07..e3ec83d5d 100644 --- a/src/shk.c +++ b/src/shk.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)shk.c 3.4 2002/03/29 */ +/* SCCS Id: @(#)shk.c 3.4 2002/04/12 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -64,7 +64,7 @@ STATIC_DCL void FDECL(add_to_billobjs, (struct obj *)); STATIC_DCL void FDECL(bill_box_content, (struct obj *, BOOLEAN_P, BOOLEAN_P, struct monst *)); #ifdef OVL1 -static void FDECL(rob_shop, (struct monst *)); +static boolean FDECL(rob_shop, (struct monst *)); #endif #ifdef OVLB @@ -425,13 +425,13 @@ boolean newlev; return; } - rob_shop(shkp); - + if (rob_shop(shkp)) { #ifdef KOPS - call_kops(shkp, (!newlev && levl[u.ux0][u.uy0].edge)); + call_kops(shkp, (!newlev && levl[u.ux0][u.uy0].edge)); #else - (void) angry_guards(FALSE); + (void) angry_guards(FALSE); #endif + } } /* robbery from outside the shop via telekinesis or grappling hook */ @@ -450,17 +450,19 @@ xchar x, y; if (!eshkp->billct && !eshkp->debit) /* bill is settled */ return; - rob_shop(shkp); - + if (rob_shop(shkp)) { #ifdef KOPS - /* [might want to set 2nd arg based on distance from shop doorway] */ - call_kops(shkp, FALSE); + /*[might want to set 2nd arg based on distance from shop doorway]*/ + call_kops(shkp, FALSE); #else - (void) angry_guards(FALSE); + (void) angry_guards(FALSE); #endif + } } -static void +/* shop merchanize has been taken; pay for it with any credit available; + return false if the debt is fully covered by credit, true otherwise */ +static boolean rob_shop(shkp) struct monst *shkp; { @@ -478,7 +480,7 @@ struct monst *shkp; total -= eshkp->credit; } setpaid(shkp); - if (!total) return; + if (!total) return FALSE; /* by this point, we know an actual robbery has taken place */ eshkp->robbed += total; @@ -488,6 +490,7 @@ struct monst *shkp; adjalign(-sgn(u.ualign.type)); hot_pursuit(shkp); + return TRUE; } void