|
|
1.1 root 1: /*
2: * Copyright (c) 1983 Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted
6: * provided that the above copyright notice and this paragraph are
7: * duplicated in all such forms and that any documentation,
8: * advertising materials, and other materials related to such
9: * distribution and use acknowledge that the software was developed
10: * by the University of California, Berkeley. The name of the
11: * University may not be used to endorse or promote products derived
12: * from this software without specific prior written permission.
13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16: */
17:
18: #ifndef lint
19: static char sccsid[] = "@(#)room.c 5.2 (Berkeley) 6/19/88";
20: #endif /* not lint */
21:
22: #include "externs.h"
23:
24: writedes()
25: {
26: int compass;
27: register char *p;
28: register c;
29:
30: printf("\n\t%s\n", location[position].name);
31: if (beenthere[position] < 3) {
32: compass = NORTH;
33: for (p = location[position].desc; c = *p++;)
34: if (c != '-' && c != '*' && c != '+')
35: putchar(c);
36: else {
37: if (c != '*')
38: printf(truedirec(compass, c));
39: compass++;
40: }
41: }
42: }
43:
44: printobjs()
45: {
46: register unsigned int *p = location[position].objects;
47: register n;
48:
49: printf("\n");
50: for (n = 0; n < NUMOFOBJECTS; n++)
51: if (testbit(p, n) && objdes[n])
52: puts(objdes[n]);
53: }
54:
55: whichway(here)
56: struct room here;
57: {
58: switch(direction) {
59:
60: case NORTH:
61: left = here.west;
62: right = here.east;
63: ahead = here.north;
64: back = here.south;
65: break;
66:
67: case SOUTH:
68: left = here.east;
69: right = here.west;
70: ahead = here.south;
71: back = here.north;
72: break;
73:
74: case EAST:
75: left = here.north;
76: right = here.south;
77: ahead = here.east;
78: back = here.west;
79: break;
80:
81: case WEST:
82: left = here.south;
83: right = here.north;
84: ahead = here.west;
85: back = here.east;
86: break;
87:
88: }
89: }
90:
91: char *
92: truedirec(way, option)
93: int way;
94: char option;
95: {
96: switch(way) {
97:
98: case NORTH:
99: switch(direction) {
100: case NORTH:
101: return("ahead");
102: case SOUTH:
103: return(option == '+' ? "behind you" : "back");
104: case EAST:
105: return("left");
106: case WEST:
107: return("right");
108: }
109:
110: case SOUTH:
111: switch(direction) {
112: case NORTH:
113: return(option == '+' ? "behind you" : "back");
114: case SOUTH:
115: return("ahead");
116: case EAST:
117: return("right");
118: case WEST:
119: return("left");
120: }
121:
122: case EAST:
123: switch(direction) {
124: case NORTH:
125: return("right");
126: case SOUTH:
127: return("left");
128: case EAST:
129: return("ahead");
130: case WEST:
131: return(option == '+' ? "behind you" : "back");
132: }
133:
134: case WEST:
135: switch(direction) {
136: case NORTH:
137: return("left");
138: case SOUTH:
139: return("right");
140: case EAST:
141: return(option == '+' ? "behind you" : "back");
142: case WEST:
143: return("ahead");
144: }
145:
146: default:
147: printf("Error: room %d. More than four directions wanted.", position);
148: return("!!");
149: }
150: }
151:
152: newway(thisway)
153: int thisway;
154: {
155: switch(direction){
156:
157: case NORTH:
158: switch(thisway){
159: case LEFT:
160: direction = WEST;
161: break;
162: case RIGHT:
163: direction = EAST;
164: break;
165: case BACK:
166: direction = SOUTH;
167: break;
168: }
169: break;
170: case SOUTH:
171: switch(thisway){
172: case LEFT:
173: direction = EAST;
174: break;
175: case RIGHT:
176: direction = WEST;
177: break;
178: case BACK:
179: direction = NORTH;
180: break;
181: }
182: break;
183: case EAST:
184: switch(thisway){
185: case LEFT:
186: direction = NORTH;
187: break;
188: case RIGHT:
189: direction = SOUTH;
190: break;
191: case BACK:
192: direction = WEST;
193: break;
194: }
195: break;
196: case WEST:
197: switch(thisway){
198: case LEFT:
199: direction = SOUTH;
200: break;
201: case RIGHT:
202: direction = NORTH;
203: break;
204: case BACK:
205: direction = EAST;
206: break;
207: }
208: break;
209: }
210: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.