forked from mgius/zork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dso5.c
169 lines (143 loc) · 3.57 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
/*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_(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;
} /* gttime_ */
/* OPNCLS-- PROCESS OPEN/CLOSE FOR DOORS */
/* DECLARATIONS */
logical opncls_(integer obj, integer so, integer sc)
{
/* System generated locals */
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:
rspeak_(rnd_(3) + 125);
/* !DUMMY. */
return ret_val;
} /* opncls_ */
/* LIT-- IS ROOM LIT? */
/* DECLARATIONS */
logical lit_(integer rm)
{
/* System generated locals */
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;
}
for (i = 1; i <= objcts_1.olnt; ++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 */
for (j = 1; j <= objcts_1.olnt; ++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_(integer rm, integer cn, integer ad)
{
/* System generated locals */
integer ret_val, i__1;
/* Local variables */
integer i, j;
ret_val = 0;
for (i = 1; i <= objcts_1.olnt; ++i) {
/* !OMIT BIG FIXED ITEMS. */
if (objcts_1.osize[i - 1] >= 10000) {
continue;
}
/* !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. */
do {
j = objcts_1.ocan[j - 1];
/* !GET NEXT LEVEL UP. */
if (j == 0) {
continue;
}
/* !END OF LIST? */
} while (j != cn);
L50:
ret_val += objcts_1.osize[i - 1];
}
return ret_val;
} /* weight_ */