Commit | Line | Data |
---|---|---|
fdc7d56f | 1 | /* |
e95fc82a KB |
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 | |
28c5bacc KB |
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. | |
fdc7d56f EW |
16 | */ |
17 | ||
f6db809c | 18 | #ifndef lint |
28c5bacc | 19 | static char sccsid[] = "@(#)init.c 5.2 (Berkeley) %G%"; |
e95fc82a | 20 | #endif /* not lint */ |
f6db809c EW |
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 | ||
a7c71d1e | 63 | char *list[] = { /* hereditary wizards */ |
f6db809c EW |
64 | "riggle", |
65 | "chris", | |
f6db809c | 66 | "edward", |
f6db809c | 67 | "comay", |
a7c71d1e EW |
68 | "yee", |
69 | "dmr", | |
70 | "ken", | |
f6db809c EW |
71 | 0 |
72 | }; | |
73 | ||
a7c71d1e EW |
74 | char *badguys[] = { |
75 | "wnj", | |
76 | "root", | |
77 | "ted", | |
78 | 0 | |
79 | }; | |
f6db809c EW |
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; | |
a7c71d1e | 104 | WEIGHT = 9; /* that'll get him! */ |
f6db809c EW |
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 | } |