forked from richelbilderbeek/Zork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DSO5.C
188 lines (162 loc) · 3.41 KB
/
DSO5.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142*/
/* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
/* WRITTEN BY R. M. SUPNIK */
#include "funcs.h"
#include "vars.h"
/* GTTIME-- GET TOTAL TIME PLAYED */
void gttime_(t)
integer *t;
{
integer h, m, s;
itime_(&h, &m, &s);
*t = h * 60 + m - (time_1.shour * 60 + time_1.smin);
if (*t < 0) {
*t += 1440;
}
*t += time_1.pltime;
return;
} /* gttime_ */
/* OPNCLS-- PROCESS OPEN/CLOSE FOR DOORS */
/* DECLARATIONS */
logical opncls_(obj, so, sc)
integer obj;
integer so;
integer sc;
{
/* System generated locals */
integer i__1;
logical ret_val;
ret_val = TRUE_;
/* !ASSUME WINS. */
if (prsvec_1.prsa == vindex_1.closew) {
goto L100;
}
/* !CLOSE? */
if (prsvec_1.prsa == vindex_1.openw) {
goto L50;
}
/* !OPEN? */
ret_val = FALSE_;
/* !LOSE */
return ret_val;
L50:
if ((objcts_1.oflag2[obj - 1] & OPENBT) != 0) {
goto L200;
}
/* !OPEN... IS IT? */
rspeak_(so);
objcts_1.oflag2[obj - 1] |= OPENBT;
return ret_val;
L100:
if (! ((objcts_1.oflag2[obj - 1] & OPENBT) != 0)) {
goto L200;
}
/* !CLOSE... IS IT? */
rspeak_(sc);
objcts_1.oflag2[obj - 1] &= ~ OPENBT;
return ret_val;
L200:
i__1 = rnd_(3) + 125;
rspeak_(i__1);
/* !DUMMY. */
return ret_val;
} /* opncls_ */
/* LIT-- IS ROOM LIT? */
/* DECLARATIONS */
logical lit_(rm)
integer rm;
{
/* System generated locals */
integer i__1, i__2;
logical ret_val;
/* Local variables */
integer i, j, oa;
ret_val = TRUE_;
/* !ASSUME WINS */
if ((rooms_1.rflag[rm - 1] & RLIGHT) != 0) {
return ret_val;
}
i__1 = objcts_1.olnt;
for (i = 1; i <= i__1; ++i) {
/* !LOOK FOR LIT OBJ */
if (qhere_(i, rm)) {
goto L100;
}
/* !IN ROOM? */
oa = objcts_1.oadv[i - 1];
/* !NO */
if (oa <= 0) {
goto L1000;
}
/* !ON ADV? */
if (advs_1.aroom[oa - 1] != rm) {
goto L1000;
}
/* !ADV IN ROOM? */
/* OBJ IN ROOM OR ON ADV IN ROOM */
L100:
if ((objcts_1.oflag1[i - 1] & ONBT) != 0) {
return ret_val;
}
if ((objcts_1.oflag1[i - 1] & VISIBT) == 0 || (
objcts_1.oflag1[i - 1] & TRANBT) == 0 && (
objcts_1.oflag2[i - 1] & OPENBT) == 0) {
goto L1000;
}
/* OBJ IS VISIBLE AND OPEN OR TRANSPARENT */
i__2 = objcts_1.olnt;
for (j = 1; j <= i__2; ++j) {
if (objcts_1.ocan[j - 1] == i && (objcts_1.oflag1[j - 1] &
ONBT) != 0) {
return ret_val;
}
/* L500: */
}
L1000:
;
}
ret_val = FALSE_;
return ret_val;
} /* lit_ */
/* WEIGHT- RETURNS SUM OF WEIGHT OF QUALIFYING OBJECTS */
/* DECLARATIONS */
integer weight_(rm, cn, ad)
integer rm;
integer cn;
integer ad;
{
/* System generated locals */
integer ret_val, i__1;
/* Local variables */
integer i, j;
ret_val = 0;
i__1 = objcts_1.olnt;
for (i = 1; i <= i__1; ++i) {
/* !OMIT BIG FIXED ITEMS. */
if (objcts_1.osize[i - 1] >= 10000) {
goto L100;
}
/* !IF FIXED, FORGET IT. */
if (qhere_(i, rm) && rm != 0 || objcts_1.oadv[i - 1] == ad && ad
!= 0) {
goto L50;
}
j = i;
/* !SEE IF CONTAINED. */
L25:
j = objcts_1.ocan[j - 1];
/* !GET NEXT LEVEL UP. */
if (j == 0) {
goto L100;
}
/* !END OF LIST? */
if (j != cn) {
goto L25;
}
L50:
ret_val += objcts_1.osize[i - 1];
L100:
;
}
return ret_val;
} /* weight_ */