|
|
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: (1) source distributions retain this entire copyright
7: * notice and comment, and (2) distributions including binaries display
8: * the following acknowledgement: ``This product includes software
9: * developed by the University of California, Berkeley and its contributors''
10: * in the documentation or other materials provided with the distribution
11: * and in all advertising materials mentioning features or use of this
12: * software. Neither the name of the University nor the names of its
13: * contributors may be used to endorse or promote products derived
14: * from this software without specific prior written permission.
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18: */
19:
20: #ifndef lint
21: static char sccsid[] = "@(#)init.c 5.4 (Berkeley) 6/1/90";
22: #endif /* not lint */
23:
24: #include <sys/types.h>
25: #include "externs.h"
26: #include <pwd.h>
27:
28: initialize(startup)
29: char startup;
30: {
31: register struct objs *p;
32: int die();
33:
34: puts("Version 4.2, fall 1984.");
35: puts("First Adventure game written by His Lordship, the honorable");
36: puts("Admiral D.W. Riggle\n");
37: srand(getpid());
38: getutmp(uname);
39: wiz = wizard(uname);
40: wordinit();
41: if (startup) {
42: location = dayfile;
43: direction = NORTH;
44: time = 0;
45: snooze = CYCLE * 1.5;
46: position = 22;
47: setbit(wear, PAJAMAS);
48: fuel = TANKFULL;
49: torps = TORPEDOES;
50: for (p = dayobjs; p->room != 0; p++)
51: setbit(location[p->room].objects, p->obj);
52: } else
53: restore();
54: signal(SIGINT, die);
55: }
56:
57: getutmp(uname)
58: char *uname;
59: {
60: struct passwd *ptr;
61:
62: ptr = getpwuid(getuid());
63: strcpy(uname, ptr ? ptr->pw_name : "");
64: }
65:
66: char *list[] = { /* hereditary wizards */
67: "riggle",
68: "chris",
69: "edward",
70: "comay",
71: "yee",
72: "dmr",
73: "ken",
74: 0
75: };
76:
77: char *badguys[] = {
78: "wnj",
79: "root",
80: "ted",
81: 0
82: };
83:
84: wizard(uname)
85: char *uname;
86: {
87: char flag;
88:
89: if (flag = checkout(uname))
90: printf("You are the Great wizard %s.\n", uname);
91: return flag;
92: }
93:
94: checkout(uname)
95: register char *uname;
96: {
97: register char **ptr;
98:
99: for (ptr = list; *ptr; ptr++)
100: if (strcmp(*ptr, uname) == 0)
101: return 1;
102: for (ptr = badguys; *ptr; ptr++)
103: if (strcmp(*ptr, uname) == 0) {
104: printf("You are the Poor anti-wizard %s. Good Luck!\n",
105: uname);
106: CUMBER = 3;
107: WEIGHT = 9; /* that'll get him! */
108: clock = 10;
109: setbit(location[7].objects, WOODSMAN); /* viper room */
110: setbit(location[20].objects, WOODSMAN); /* laser " */
111: setbit(location[13].objects, DARK); /* amulet " */
112: setbit(location[8].objects, ELF); /* closet */
113: return 0; /* anything else, Chris? */
114: }
115: return 0;
116: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.