Home | History | Annotate | Line # | Download | only in hack
      1  1.3  wiz $NetBSD: hack.fix,v 1.3 2001/09/16 16:34:25 wiz Exp $
      2  1.2  cgd 
      3  1.1  cgd /***** unido:net.games.hack / ab /  7:23 pm  Sep 13, 1985*/
      4  1.1  cgd 
      5  1.1  cgd Recently hack (1.0.3) crashed with core dumps during some good games.
      6  1.3  wiz The crashes occurred in the onbill-routine. After investigating the core
      7  1.1  cgd dump I found that the shopkeeper's bill was still to be paid.  Normaly
      8  1.1  cgd if you leave a shop the bill will be cleared and onbill() would not
      9  1.1  cgd check it. But under certain conditions you can leave a shop without
     10  1.1  cgd clearing the bill. The conditions are:
     11  1.1  cgd 
     12  1.1  cgd      1. You have to rob a shop in order to make the shopkeeper
     13  1.1  cgd 	follow you.
     14  1.1  cgd 
     15  1.1  cgd      2. After leaving the shop being followed by the shopkeeper
     16  1.1  cgd 	you must return to the shop...
     17  1.1  cgd 
     18  1.1  cgd      3. ...and then leave the unguarded shop again.
     19  1.1  cgd 	- The shopkeeper mustn't be present!
     20  1.1  cgd 
     21  1.1  cgd If you climb the stairs to the previous level, chances are that your
     22  1.1  cgd bill now contains much more items than allowed. If so the next call to
     23  1.1  cgd onbill() will dump the core.
     24  1.1  cgd 
     25  1.1  cgd Following is a context diff to fix the bug. Actually just the last hunk
     26  1.1  cgd does the fix [it deletes two lines which have been inserted in 1.0.3],
     27  1.1  cgd but I think the other fix was intended by the now deleted lines.
     28  1.1  cgd 
     29  1.1  cgd 	Andreas
     30  1.1  cgd 
     31  1.1  cgd --
     32  1.1  cgd Andreas Bormann                 ab (a] unido.UUCP
     33  1.1  cgd University of Dortmund          N 51 29' 05"   E 07 24' 42"
     34  1.1  cgd West Germany
     35  1.1  cgd 
     36  1.1  cgd ------ the diff follows:
     37  1.1  cgd 
     38  1.1  cgd *** hack.shk.c.orig	Sun Aug  4 12:07:51 1985
     39  1.1  cgd --- hack.shk.c	Fri Sep 13 14:29:52 1985
     40  1.1  cgd ***************
     41  1.1  cgd *** 133,139
     42  1.1  cgd   	/* Did we just leave a shop? */
     43  1.1  cgd   	if(u.uinshop &&
     44  1.1  cgd   	    (u.uinshop != roomno + 1 || shlevel != dlevel || !shopkeeper)) {
     45  1.1  cgd - 		u.uinshop = 0;
     46  1.1  cgd   		if(shopkeeper) {
     47  1.1  cgd   		    if(ESHK(shopkeeper)->billct) {
     48  1.1  cgd   			pline("Somehow you escaped the shop without paying!");
     49  1.1  cgd 
     50  1.1  cgd --- 133,138 -----
     51  1.1  cgd   	/* Did we just leave a shop? */
     52  1.1  cgd   	if(u.uinshop &&
     53  1.1  cgd   	    (u.uinshop != roomno + 1 || shlevel != dlevel || !shopkeeper)) {
     54  1.1  cgd   		if(shopkeeper) {
     55  1.1  cgd   		    if(ESHK(shopkeeper)->billct) {
     56  1.1  cgd   			if(inroom(shopkeeper->mx, shopkeeper->my) 
     57  1.1  cgd ***************
     58  1.1  cgd *** 136,142
     59  1.1  cgd   		u.uinshop = 0;
     60  1.1  cgd   		if(shopkeeper) {
     61  1.1  cgd   		    if(ESHK(shopkeeper)->billct) {
     62  1.1  cgd ! 			pline("Somehow you escaped the shop without paying!");
     63  1.1  cgd   			addupbill();
     64  1.1  cgd   			pline("You stole for a total worth of %ld zorkmids.",
     65  1.1  cgd   				total);
     66  1.1  cgd 
     67  1.1  cgd --- 135,143 -----
     68  1.1  cgd   	    (u.uinshop != roomno + 1 || shlevel != dlevel || !shopkeeper)) {
     69  1.1  cgd   		if(shopkeeper) {
     70  1.1  cgd   		    if(ESHK(shopkeeper)->billct) {
     71  1.1  cgd ! 			if(inroom(shopkeeper->mx, shopkeeper->my) 
     72  1.1  cgd ! 			    == u.uinshop - 1)	/* ab@unido */
     73  1.1  cgd ! 			    pline("Somehow you escaped the shop without paying!");
     74  1.1  cgd   			addupbill();
     75  1.1  cgd   			pline("You stole for a total worth of %ld zorkmids.",
     76  1.1  cgd   				total);
     77  1.1  cgd ***************
     78  1.1  cgd *** 149,154
     79  1.1  cgd   		    shopkeeper = 0;
     80  1.1  cgd   		    shlevel = 0;
     81  1.1  cgd   		}
     82  1.1  cgd   	}
     83  1.1  cgd   
     84  1.1  cgd   	/* Did we just enter a zoo of some kind? */
     85  1.1  cgd 
     86  1.1  cgd --- 150,156 -----
     87  1.1  cgd   		    shopkeeper = 0;
     88  1.1  cgd   		    shlevel = 0;
     89  1.1  cgd   		}
     90  1.1  cgd + 		u.uinshop = 0;
     91  1.1  cgd   	}
     92  1.1  cgd   
     93  1.1  cgd   	/* Did we just enter a zoo of some kind? */
     94  1.1  cgd ***************
     95  1.1  cgd *** 183,190
     96  1.1  cgd   		findshk(roomno);
     97  1.1  cgd   	    if(!shopkeeper) {
     98  1.1  cgd   		rooms[roomno].rtype = 0;
     99  1.1  cgd - 		u.uinshop = 0;
    100  1.1  cgd - 	    } else if(inroom(shopkeeper->mx, shopkeeper->my) != roomno) {
    101  1.1  cgd   		u.uinshop = 0;
    102  1.1  cgd   	    } else if(!u.uinshop){
    103  1.1  cgd   		if(!ESHK(shopkeeper)->visitct ||
    104  1.1  cgd 
    105  1.1  cgd --- 185,190 -----
    106  1.1  cgd   		findshk(roomno);
    107  1.1  cgd   	    if(!shopkeeper) {
    108  1.1  cgd   		rooms[roomno].rtype = 0;
    109  1.1  cgd   		u.uinshop = 0;
    110  1.1  cgd   	    } else if(!u.uinshop){
    111  1.1  cgd   		if(!ESHK(shopkeeper)->visitct ||
    112  1.1  cgd /* ---------- */
    113  1.1  cgd 
    114  1.1  cgd 
    115  1.1  cgd 
    116