]> granicus.if.org Git - nethack/commitdiff
shop credit fix
authornethack.rankin <nethack.rankin>
Mon, 15 Apr 2002 10:52:20 +0000 (10:52 +0000)
committernethack.rankin <nethack.rankin>
Mon, 15 Apr 2002 10:52:20 +0000 (10:52 +0000)
[ 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
src/shk.c

index a09129672fec4a5e0343015614393ee49aac12fa..5e3a05cf34e3a26059949b76a109aa7a05dfd6c1 100644 (file)
@@ -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
index e9076de075ccc41359229c18c51eaa0c57bc5c12..e3ec83d5d24779bdf38efc90abdc4052303e1d6d 100644 (file)
--- 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