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, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34 #ifndef lint 35 /*static char sccsid[] = "from: @(#)init.c 5.5 (Berkeley) 2/27/91";*/ 36 static char rcsid[] = "$Id: init.c,v 1.3 1993/08/01 18:55:59 mycroft Exp $"; 37 #endif /* not lint */ 38 39 #include <sys/types.h> 40 #include "externs.h" 41 #include <pwd.h> 42 43 initialize(startup) 44 char startup; 45 { 46 register struct objs *p; 47 void die(); 48 49 puts("Version 4.2, fall 1984."); 50 puts("First Adventure game written by His Lordship, the honorable"); 51 puts("Admiral D.W. Riggle\n"); 52 srand(getpid()); 53 getutmp(uname); 54 wordinit(); 55 if (startup) { 56 location = dayfile; 57 direction = NORTH; 58 time = 0; 59 snooze = CYCLE * 1.5; 60 position = 22; 61 setbit(wear, PAJAMAS); 62 fuel = TANKFULL; 63 torps = TORPEDOES; 64 for (p = dayobjs; p->room != 0; p++) 65 setbit(location[p->room].objects, p->obj); 66 } else 67 restore(); 68 wiz = wizard(uname); 69 signal(SIGINT, die); 70 } 71 72 getutmp(uname) 73 char *uname; 74 { 75 struct passwd *ptr; 76 77 ptr = getpwuid(getuid()); 78 strcpy(uname, ptr ? ptr->pw_name : ""); 79 } 80 81 char *list[] = { /* hereditary wizards */ 82 "riggle", 83 "chris", 84 "edward", 85 "comay", 86 "yee", 87 "dmr", 88 "ken", 89 0 90 }; 91 92 char *badguys[] = { 93 "wnj", 94 "root", 95 "ted", 96 0 97 }; 98 99 wizard(uname) 100 char *uname; 101 { 102 char flag; 103 104 if (flag = checkout(uname)) 105 printf("You are the Great wizard %s.\n", uname); 106 return flag; 107 } 108 109 checkout(uname) 110 register char *uname; 111 { 112 register char **ptr; 113 114 for (ptr = list; *ptr; ptr++) 115 if (strcmp(*ptr, uname) == 0) 116 return 1; 117 for (ptr = badguys; *ptr; ptr++) 118 if (strcmp(*ptr, uname) == 0) { 119 printf("You are the Poor anti-wizard %s. Good Luck!\n", 120 uname); 121 CUMBER = 3; 122 WEIGHT = 9; /* that'll get him! */ 123 clock = 10; 124 setbit(location[7].objects, WOODSMAN); /* viper room */ 125 setbit(location[20].objects, WOODSMAN); /* laser " */ 126 setbit(location[13].objects, DARK); /* amulet " */ 127 setbit(location[8].objects, ELF); /* closet */ 128 return 0; /* anything else, Chris? */ 129 } 130 return 0; 131 } 132