1 /* $NetBSD: init.c,v 1.3 1995/04/22 10:27:32 cgd Exp $ */
4 * Copyright (c) 1988, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 static char sccsid
[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
43 static char rcsid
[] = "$NetBSD: init.c,v 1.3 1995/04/22 10:27:32 cgd Exp $";
50 * This source herein may be modified and/or distributed by anybody who
51 * so desires, with the following restrictions:
52 * 1.) No portion of this notice shall be removed.
53 * 2.) Credit shall not be taken for the creation of this source.
54 * 3.) This code is not to be traded, sold, or used for personal
62 char login_name
[MAX_OPT_LEN
];
63 char *nick_name
= (char *) 0;
68 boolean init_curses
= 0;
69 boolean save_is_interactive
= 1;
73 char *error_file
= "rogue.esave";
74 char *byebye_string
= "Okay, bye bye!";
77 extern char *save_file
;
78 extern short party_room
;
89 if ((!pn
) || (strlen(pn
) >= MAX_OPT_LEN
)) {
90 clean_up("Hey! Who are you?");
92 (void) strcpy(login_name
, pn
);
97 if (!score_only
&& !rest_file
) {
98 printf("Hello %s, just a moment while I dig the dungeon...",
104 if ((LINES
< DROWS
) || (COLS
< DCOLS
)) {
105 clean_up("must be played on 24 x 80 screen");
113 put_scores((object
*) 0, 0);
116 (void) srrandom(seed
);
122 get_wand_and_ring_materials();
123 make_scroll_titles();
125 level_objects
.next_object
= (object
*) 0;
126 level_monsters
.next_monster
= (object
*) 0;
136 rogue
.pack
.next_object
= (object
*) 0;
138 obj
= alloc_object();
140 (void) add_to_pack(obj
, &rogue
.pack
, 1);
142 obj
= alloc_object(); /* initial armor */
143 obj
->what_is
= ARMOR
;
144 obj
->which_kind
= RINGMAIL
;
145 obj
->class = RINGMAIL
+2;
146 obj
->is_protected
= 0;
148 (void) add_to_pack(obj
, &rogue
.pack
, 1);
151 obj
= alloc_object(); /* initial weapons */
152 obj
->what_is
= WEAPON
;
153 obj
->which_kind
= MACE
;
155 obj
->hit_enchant
= obj
->d_enchant
= 1;
157 (void) add_to_pack(obj
, &rogue
.pack
, 1);
160 obj
= alloc_object();
161 obj
->what_is
= WEAPON
;
162 obj
->which_kind
= BOW
;
164 obj
->hit_enchant
= 1;
167 (void) add_to_pack(obj
, &rogue
.pack
, 1);
169 obj
= alloc_object();
170 obj
->what_is
= WEAPON
;
171 obj
->which_kind
= ARROW
;
172 obj
->quantity
= get_rand(25, 35);
174 obj
->hit_enchant
= 0;
177 (void) add_to_pack(obj
, &rogue
.pack
, 1);
183 if (save_is_interactive
) {
189 printf("\n%s\n", estr
);
201 md_control_keybord(0);
207 md_control_keybord(1);
217 clean_up(byebye_string
);
230 message("interrupt", 1);
238 save_is_interactive
= 0;
239 save_into_file(error_file
);
249 for (i
= 1; i
< argc
; i
++) {
250 if (argv
[i
][0] == '-') {
251 for (j
= 1; argv
[i
][j
]; j
++) {
268 if (eptr
= md_getenv("ROGUEOPTS")) {
270 while ((*eptr
) == ' ') {
276 if (!strncmp(eptr
, "fruit=", 6)) {
278 env_get_value(&fruit
, eptr
, 1);
279 } else if (!strncmp(eptr
, "file=", 5)) {
281 env_get_value(&save_file
, eptr
, 0);
282 } else if (!strncmp(eptr
, "jump", 4)) {
284 } else if (!strncmp(eptr
, "name=", 5)) {
286 env_get_value(&nick_name
, eptr
, 0);
287 } else if (!strncmp(eptr
, "noaskquit", 9)) {
289 } else if (!strncmp(eptr
, "noskull", 5) ||
290 !strncmp(eptr
,"notomb", 6)) {
292 } else if (!strncmp(eptr
, "passgo", 5)) {
295 while ((*eptr
) && (*eptr
!= ',')) {
303 /* If some strings have not been set through ROGUEOPTS, assign defaults
304 * to them so that the options editor has data to work with.
306 init_str(&nick_name
, login_name
);
307 init_str(&save_file
, "rogue.save");
308 init_str(&fruit
, "slime-mold");
311 env_get_value(s
, e
, add_blank
)
320 while ((*e
) && (*e
!= ',')) {
322 *e
= ';'; /* ':' reserved for score file purposes */
325 if (++i
>= MAX_OPT_LEN
) {
329 *s
= md_malloc(MAX_OPT_LEN
+ 2);
330 (void) strncpy(*s
, t
, i
);
341 *str
= md_malloc(MAX_OPT_LEN
+ 2);
342 (void) strcpy(*str
, dflt
);