xref: /netbsd-src/games/hack/hack.fix (revision 456dff6cb86edf66a568fe64ddf51c189a134a94)
1*456dff6cSwiz$NetBSD: hack.fix,v 1.3 2001/09/16 16:34:25 wiz Exp $
242fb1b9dScgd
361f28255Scgd/***** unido:net.games.hack / ab /  7:23 pm  Sep 13, 1985*/
461f28255Scgd
561f28255ScgdRecently hack (1.0.3) crashed with core dumps during some good games.
6*456dff6cSwizThe crashes occurred in the onbill-routine. After investigating the core
761f28255Scgddump I found that the shopkeeper's bill was still to be paid.  Normaly
861f28255Scgdif you leave a shop the bill will be cleared and onbill() would not
961f28255Scgdcheck it. But under certain conditions you can leave a shop without
1061f28255Scgdclearing the bill. The conditions are:
1161f28255Scgd
1261f28255Scgd     1. You have to rob a shop in order to make the shopkeeper
1361f28255Scgd	follow you.
1461f28255Scgd
1561f28255Scgd     2. After leaving the shop being followed by the shopkeeper
1661f28255Scgd	you must return to the shop...
1761f28255Scgd
1861f28255Scgd     3. ...and then leave the unguarded shop again.
1961f28255Scgd	- The shopkeeper mustn't be present!
2061f28255Scgd
2161f28255ScgdIf you climb the stairs to the previous level, chances are that your
2261f28255Scgdbill now contains much more items than allowed. If so the next call to
2361f28255Scgdonbill() will dump the core.
2461f28255Scgd
2561f28255ScgdFollowing is a context diff to fix the bug. Actually just the last hunk
2661f28255Scgddoes the fix [it deletes two lines which have been inserted in 1.0.3],
2761f28255Scgdbut I think the other fix was intended by the now deleted lines.
2861f28255Scgd
2961f28255Scgd	Andreas
3061f28255Scgd
3161f28255Scgd--
3261f28255ScgdAndreas Bormann                 ab@unido.UUCP
3361f28255ScgdUniversity of Dortmund          N 51 29' 05"   E 07 24' 42"
3461f28255ScgdWest Germany
3561f28255Scgd
3661f28255Scgd------ the diff follows:
3761f28255Scgd
3861f28255Scgd*** hack.shk.c.orig	Sun Aug  4 12:07:51 1985
3961f28255Scgd--- hack.shk.c	Fri Sep 13 14:29:52 1985
4061f28255Scgd***************
4161f28255Scgd*** 133,139
4261f28255Scgd  	/* Did we just leave a shop? */
4361f28255Scgd  	if(u.uinshop &&
4461f28255Scgd  	    (u.uinshop != roomno + 1 || shlevel != dlevel || !shopkeeper)) {
4561f28255Scgd- 		u.uinshop = 0;
4661f28255Scgd  		if(shopkeeper) {
4761f28255Scgd  		    if(ESHK(shopkeeper)->billct) {
4861f28255Scgd  			pline("Somehow you escaped the shop without paying!");
4961f28255Scgd
5061f28255Scgd--- 133,138 -----
5161f28255Scgd  	/* Did we just leave a shop? */
5261f28255Scgd  	if(u.uinshop &&
5361f28255Scgd  	    (u.uinshop != roomno + 1 || shlevel != dlevel || !shopkeeper)) {
5461f28255Scgd  		if(shopkeeper) {
5561f28255Scgd  		    if(ESHK(shopkeeper)->billct) {
5661f28255Scgd  			if(inroom(shopkeeper->mx, shopkeeper->my)
5761f28255Scgd***************
5861f28255Scgd*** 136,142
5961f28255Scgd  		u.uinshop = 0;
6061f28255Scgd  		if(shopkeeper) {
6161f28255Scgd  		    if(ESHK(shopkeeper)->billct) {
6261f28255Scgd! 			pline("Somehow you escaped the shop without paying!");
6361f28255Scgd  			addupbill();
6461f28255Scgd  			pline("You stole for a total worth of %ld zorkmids.",
6561f28255Scgd  				total);
6661f28255Scgd
6761f28255Scgd--- 135,143 -----
6861f28255Scgd  	    (u.uinshop != roomno + 1 || shlevel != dlevel || !shopkeeper)) {
6961f28255Scgd  		if(shopkeeper) {
7061f28255Scgd  		    if(ESHK(shopkeeper)->billct) {
7161f28255Scgd! 			if(inroom(shopkeeper->mx, shopkeeper->my)
7261f28255Scgd! 			    == u.uinshop - 1)	/* ab@unido */
7361f28255Scgd! 			    pline("Somehow you escaped the shop without paying!");
7461f28255Scgd  			addupbill();
7561f28255Scgd  			pline("You stole for a total worth of %ld zorkmids.",
7661f28255Scgd  				total);
7761f28255Scgd***************
7861f28255Scgd*** 149,154
7961f28255Scgd  		    shopkeeper = 0;
8061f28255Scgd  		    shlevel = 0;
8161f28255Scgd  		}
8261f28255Scgd  	}
8361f28255Scgd
8461f28255Scgd  	/* Did we just enter a zoo of some kind? */
8561f28255Scgd
8661f28255Scgd--- 150,156 -----
8761f28255Scgd  		    shopkeeper = 0;
8861f28255Scgd  		    shlevel = 0;
8961f28255Scgd  		}
9061f28255Scgd+ 		u.uinshop = 0;
9161f28255Scgd  	}
9261f28255Scgd
9361f28255Scgd  	/* Did we just enter a zoo of some kind? */
9461f28255Scgd***************
9561f28255Scgd*** 183,190
9661f28255Scgd  		findshk(roomno);
9761f28255Scgd  	    if(!shopkeeper) {
9861f28255Scgd  		rooms[roomno].rtype = 0;
9961f28255Scgd- 		u.uinshop = 0;
10061f28255Scgd- 	    } else if(inroom(shopkeeper->mx, shopkeeper->my) != roomno) {
10161f28255Scgd  		u.uinshop = 0;
10261f28255Scgd  	    } else if(!u.uinshop){
10361f28255Scgd  		if(!ESHK(shopkeeper)->visitct ||
10461f28255Scgd
10561f28255Scgd--- 185,190 -----
10661f28255Scgd  		findshk(roomno);
10761f28255Scgd  	    if(!shopkeeper) {
10861f28255Scgd  		rooms[roomno].rtype = 0;
10961f28255Scgd  		u.uinshop = 0;
11061f28255Scgd  	    } else if(!u.uinshop){
11161f28255Scgd  		if(!ESHK(shopkeeper)->visitct ||
11261f28255Scgd/* ---------- */
11361f28255Scgd
11461f28255Scgd
11561f28255Scgd
116