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