Commit | Line | Data |
---|---|---|
fdc7d56f | 1 | /* |
86164080 KB |
2 | * Copyright (c) 1983, 1993 |
3 | * The Regents of the University of California. All rights reserved. | |
e95fc82a | 4 | * |
a6547b1d | 5 | * %sccs.include.redist.c% |
fdc7d56f EW |
6 | */ |
7 | ||
f6db809c | 8 | #ifndef lint |
ac1774e9 | 9 | static char sccsid[] = "@(#)init.c 8.2 (Berkeley) %G%"; |
e95fc82a | 10 | #endif /* not lint */ |
f6db809c | 11 | |
8c1a1b7b | 12 | #include <sys/types.h> |
ac1774e9 | 13 | #include "extern.h" |
f6db809c EW |
14 | #include <pwd.h> |
15 | ||
16 | initialize(startup) | |
17 | char startup; | |
18 | { | |
19 | register struct objs *p; | |
5ddbd132 | 20 | void die(); |
f6db809c EW |
21 | |
22 | puts("Version 4.2, fall 1984."); | |
23 | puts("First Adventure game written by His Lordship, the honorable"); | |
24 | puts("Admiral D.W. Riggle\n"); | |
25 | srand(getpid()); | |
26 | getutmp(uname); | |
27 | wiz = wizard(uname); | |
28 | wordinit(); | |
29 | if (startup) { | |
30 | location = dayfile; | |
31 | direction = NORTH; | |
32 | time = 0; | |
33 | snooze = CYCLE * 1.5; | |
34 | position = 22; | |
35 | setbit(wear, PAJAMAS); | |
36 | fuel = TANKFULL; | |
37 | torps = TORPEDOES; | |
38 | for (p = dayobjs; p->room != 0; p++) | |
39 | setbit(location[p->room].objects, p->obj); | |
40 | } else | |
41 | restore(); | |
42 | signal(SIGINT, die); | |
43 | } | |
44 | ||
45 | getutmp(uname) | |
46 | char *uname; | |
47 | { | |
48 | struct passwd *ptr; | |
49 | ||
50 | ptr = getpwuid(getuid()); | |
51 | strcpy(uname, ptr ? ptr->pw_name : ""); | |
52 | } | |
53 | ||
a7c71d1e | 54 | char *list[] = { /* hereditary wizards */ |
f6db809c EW |
55 | "riggle", |
56 | "chris", | |
f6db809c | 57 | "edward", |
f6db809c | 58 | "comay", |
a7c71d1e EW |
59 | "yee", |
60 | "dmr", | |
61 | "ken", | |
f6db809c EW |
62 | 0 |
63 | }; | |
64 | ||
a7c71d1e EW |
65 | char *badguys[] = { |
66 | "wnj", | |
67 | "root", | |
68 | "ted", | |
69 | 0 | |
70 | }; | |
f6db809c EW |
71 | |
72 | wizard(uname) | |
73 | char *uname; | |
74 | { | |
75 | char flag; | |
76 | ||
77 | if (flag = checkout(uname)) | |
78 | printf("You are the Great wizard %s.\n", uname); | |
79 | return flag; | |
80 | } | |
81 | ||
82 | checkout(uname) | |
83 | register char *uname; | |
84 | { | |
85 | register char **ptr; | |
86 | ||
87 | for (ptr = list; *ptr; ptr++) | |
88 | if (strcmp(*ptr, uname) == 0) | |
89 | return 1; | |
90 | for (ptr = badguys; *ptr; ptr++) | |
91 | if (strcmp(*ptr, uname) == 0) { | |
92 | printf("You are the Poor anti-wizard %s. Good Luck!\n", | |
93 | uname); | |
94 | CUMBER = 3; | |
a7c71d1e | 95 | WEIGHT = 9; /* that'll get him! */ |
f6db809c EW |
96 | clock = 10; |
97 | setbit(location[7].objects, WOODSMAN); /* viper room */ | |
98 | setbit(location[20].objects, WOODSMAN); /* laser " */ | |
99 | setbit(location[13].objects, DARK); /* amulet " */ | |
100 | setbit(location[8].objects, ELF); /* closet */ | |
101 | return 0; /* anything else, Chris? */ | |
102 | } | |
103 | return 0; | |
104 | } |