1 /*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8 #ifndef lint
9 static char sccsid[] = "@(#)init.c 8.4 (Berkeley) 04/30/95";
10 #endif /* not lint */
11
12 #include <sys/types.h>
13 #include "extern.h"
14 #include <pwd.h>
15
initialize(startup)16 initialize(startup)
17 char startup;
18 {
19 register struct objs *p;
20 void die();
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 location = dayfile;
26 srand(getpid());
27 getutmp(uname);
28 wiz = wizard(uname);
29 wordinit();
30 if (startup) {
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
getutmp(uname)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
54 char *list[] = { /* hereditary wizards */
55 "riggle",
56 "chris",
57 "edward",
58 "comay",
59 "yee",
60 "dmr",
61 "ken",
62 0
63 };
64
65 char *badguys[] = {
66 "wnj",
67 "root",
68 "ted",
69 0
70 };
71
wizard(uname)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
checkout(uname)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;
95 WEIGHT = 9; /* that'll get him! */
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 }
105