2 * Copyright (c) 1988 The Regents of the University of California.
5 * This code is derived from software contributed to Berkeley by
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 /*static char sccsid[] = "from: @(#)init.c 5.4 (Berkeley) 2/28/91";*/
39 static char rcsid
[] = "$Id: init.c,v 1.2 1993/08/01 18:52:30 mycroft Exp $";
45 * This source herein may be modified and/or distributed by anybody who
46 * so desires, with the following restrictions:
47 * 1.) No portion of this notice shall be removed.
48 * 2.) Credit shall not be taken for the creation of this source.
49 * 3.) This code is not to be traded, sold, or used for personal
57 char login_name
[MAX_OPT_LEN
];
58 char *nick_name
= (char *) 0;
63 boolean init_curses
= 0;
64 boolean save_is_interactive
= 1;
68 char *error_file
= "rogue.esave";
69 char *byebye_string
= "Okay, bye bye!";
72 extern char *save_file
;
73 extern short party_room
;
84 if ((!pn
) || (strlen(pn
) >= MAX_OPT_LEN
)) {
85 clean_up("Hey! Who are you?");
87 (void) strcpy(login_name
, pn
);
92 if (!score_only
&& !rest_file
) {
93 printf("Hello %s, just a moment while I dig the dungeon...",
99 if ((LINES
< DROWS
) || (COLS
< DCOLS
)) {
100 clean_up("must be played on 24 x 80 screen");
108 put_scores((object
*) 0, 0);
111 (void) srrandom(seed
);
117 get_wand_and_ring_materials();
118 make_scroll_titles();
120 level_objects
.next_object
= (object
*) 0;
121 level_monsters
.next_monster
= (object
*) 0;
131 rogue
.pack
.next_object
= (object
*) 0;
133 obj
= alloc_object();
135 (void) add_to_pack(obj
, &rogue
.pack
, 1);
137 obj
= alloc_object(); /* initial armor */
138 obj
->what_is
= ARMOR
;
139 obj
->which_kind
= RINGMAIL
;
140 obj
->class = RINGMAIL
+2;
141 obj
->is_protected
= 0;
143 (void) add_to_pack(obj
, &rogue
.pack
, 1);
146 obj
= alloc_object(); /* initial weapons */
147 obj
->what_is
= WEAPON
;
148 obj
->which_kind
= MACE
;
150 obj
->hit_enchant
= obj
->d_enchant
= 1;
152 (void) add_to_pack(obj
, &rogue
.pack
, 1);
155 obj
= alloc_object();
156 obj
->what_is
= WEAPON
;
157 obj
->which_kind
= BOW
;
159 obj
->hit_enchant
= 1;
162 (void) add_to_pack(obj
, &rogue
.pack
, 1);
164 obj
= alloc_object();
165 obj
->what_is
= WEAPON
;
166 obj
->which_kind
= ARROW
;
167 obj
->quantity
= get_rand(25, 35);
169 obj
->hit_enchant
= 0;
172 (void) add_to_pack(obj
, &rogue
.pack
, 1);
178 if (save_is_interactive
) {
184 printf("\n%s\n", estr
);
196 md_control_keybord(0);
202 md_control_keybord(1);
212 clean_up(byebye_string
);
225 message("interrupt", 1);
233 save_is_interactive
= 0;
234 save_into_file(error_file
);
244 for (i
= 1; i
< argc
; i
++) {
245 if (argv
[i
][0] == '-') {
246 for (j
= 1; argv
[i
][j
]; j
++) {
263 if (eptr
= md_getenv("ROGUEOPTS")) {
265 while ((*eptr
) == ' ') {
271 if (!strncmp(eptr
, "fruit=", 6)) {
273 env_get_value(&fruit
, eptr
, 1);
274 } else if (!strncmp(eptr
, "file=", 5)) {
276 env_get_value(&save_file
, eptr
, 0);
277 } else if (!strncmp(eptr
, "jump", 4)) {
279 } else if (!strncmp(eptr
, "name=", 5)) {
281 env_get_value(&nick_name
, eptr
, 0);
282 } else if (!strncmp(eptr
, "noaskquit", 9)) {
284 } else if (!strncmp(eptr
, "noskull", 5) ||
285 !strncmp(eptr
,"notomb", 6)) {
287 } else if (!strncmp(eptr
, "passgo", 5)) {
290 while ((*eptr
) && (*eptr
!= ',')) {
298 /* If some strings have not been set through ROGUEOPTS, assign defaults
299 * to them so that the options editor has data to work with.
301 init_str(&nick_name
, login_name
);
302 init_str(&save_file
, "rogue.save");
303 init_str(&fruit
, "slime-mold");
306 env_get_value(s
, e
, add_blank
)
315 while ((*e
) && (*e
!= ',')) {
317 *e
= ';'; /* ':' reserved for score file purposes */
320 if (++i
>= MAX_OPT_LEN
) {
324 *s
= md_malloc(MAX_OPT_LEN
+ 2);
325 (void) strncpy(*s
, t
, i
);
336 *str
= md_malloc(MAX_OPT_LEN
+ 2);
337 (void) strcpy(*str
, dflt
);