|
|
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[] = "@(#)init.c 5.2 (Berkeley) 6/19/88";
20: #endif /* not lint */
21:
22: #include "externs.h"
23: #include <pwd.h>
24:
25: initialize(startup)
26: char startup;
27: {
28: register struct objs *p;
29: int die();
30:
31: puts("Version 4.2, fall 1984.");
32: puts("First Adventure game written by His Lordship, the honorable");
33: puts("Admiral D.W. Riggle\n");
34: srand(getpid());
35: getutmp(uname);
36: wiz = wizard(uname);
37: wordinit();
38: if (startup) {
39: location = dayfile;
40: direction = NORTH;
41: time = 0;
42: snooze = CYCLE * 1.5;
43: position = 22;
44: setbit(wear, PAJAMAS);
45: fuel = TANKFULL;
46: torps = TORPEDOES;
47: for (p = dayobjs; p->room != 0; p++)
48: setbit(location[p->room].objects, p->obj);
49: } else
50: restore();
51: signal(SIGINT, die);
52: }
53:
54: getutmp(uname)
55: char *uname;
56: {
57: struct passwd *ptr;
58:
59: ptr = getpwuid(getuid());
60: strcpy(uname, ptr ? ptr->pw_name : "");
61: }
62:
63: char *list[] = { /* hereditary wizards */
64: "riggle",
65: "chris",
66: "edward",
67: "comay",
68: "yee",
69: "dmr",
70: "ken",
71: 0
72: };
73:
74: char *badguys[] = {
75: "wnj",
76: "root",
77: "ted",
78: 0
79: };
80:
81: wizard(uname)
82: char *uname;
83: {
84: char flag;
85:
86: if (flag = checkout(uname))
87: printf("You are the Great wizard %s.\n", uname);
88: return flag;
89: }
90:
91: checkout(uname)
92: register char *uname;
93: {
94: register char **ptr;
95:
96: for (ptr = list; *ptr; ptr++)
97: if (strcmp(*ptr, uname) == 0)
98: return 1;
99: for (ptr = badguys; *ptr; ptr++)
100: if (strcmp(*ptr, uname) == 0) {
101: printf("You are the Poor anti-wizard %s. Good Luck!\n",
102: uname);
103: CUMBER = 3;
104: WEIGHT = 9; /* that'll get him! */
105: clock = 10;
106: setbit(location[7].objects, WOODSMAN); /* viper room */
107: setbit(location[20].objects, WOODSMAN); /* laser " */
108: setbit(location[13].objects, DARK); /* amulet " */
109: setbit(location[8].objects, ELF); /* closet */
110: return 0; /* anything else, Chris? */
111: }
112: return 0;
113: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.