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