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