+/* $NetBSD: room.c,v 1.14 2019/02/03 03:19:25 mrg Exp $ */
+
/*
- * Copyright (c) 1988 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Timothy C. Stoehr.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-/*static char sccsid[] = "from: @(#)room.c 5.3 (Berkeley) 6/1/90";*/
-static char rcsid[] = "$Id: room.c,v 1.2 1993/08/01 18:52:16 mycroft Exp $";
+#if 0
+static char sccsid[] = "@(#)room.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: room.c,v 1.14 2019/02/03 03:19:25 mrg Exp $");
+#endif
#endif /* not lint */
/*
#include "rogue.h"
room rooms[MAXROOMS];
-boolean rooms_visited[MAXROOMS];
-extern short blind;
-extern boolean detect_monster, jump, passgo, no_skull, ask_quit;
-extern char *nick_name, *fruit, *save_file, *press_space;
+static boolean rooms_visited[MAXROOMS];
#define NOPTS 7
-
-struct option {
- char *prompt;
+static const struct option {
+ const char *prompt;
boolean is_bool;
char **strval;
boolean *bval;
} options[NOPTS] = {
{
"Show position only at end of run (\"jump\"): ",
- 1, (char **) 0, &jump
+ 1, NULL, &jump
},
{
"Follow turnings in passageways (\"passgo\"): ",
- 1, (char **) 0, &passgo
+ 1, NULL, &passgo
},
{
"Don't print skull when killed (\"noskull\" or \"notombstone\"): ",
- 1, (char **) 0, &no_skull
+ 1, NULL, &no_skull
},
{
"Ask player before saying 'Okay, bye-bye!' (\"askquit\"): ",
- 1, (char **) 0, &ask_quit
+ 1, NULL, &ask_quit
},
{
"Name (\"name\"): ",
- 0, &nick_name
+ 0, &nick_name, NULL
},
{
"Fruit (\"fruit\"): ",
- 0, &fruit
+ 0, &fruit, NULL
},
{
"Save file (\"file\"): ",
- 0, &save_file
+ 0, &save_file, NULL
}
};
-light_up_room(rn)
-int rn;
+static boolean get_oth_room(short, short *, short *);
+static void opt_erase(int);
+static void opt_go(int);
+static void opt_show(int);
+static void visit_rooms(int);
+
+void
+light_up_room(int rn)
{
short i, j;
if (dungeon[i][j] & MONSTER) {
object *monster;
- if (monster = object_at(&level_monsters, i, j)) {
+ if ((monster = object_at(
+ &level_monsters, i, j)) != NULL) {
dungeon[monster->row][monster->col] &= (~MONSTER);
monster->trail_char =
get_dungeon_char(monster->row, monster->col);
}
}
-light_passage(row, col)
+void
+light_passage(int row, int col)
{
short i, j, i_end, j_end;
}
}
-darken_room(rn)
-short rn;
+void
+darken_room(short rn)
{
short i, j;
}
}
-get_dungeon_char(row, col)
-register row, col;
+char
+get_dungeon_char(short row, short col)
{
- register unsigned short mask = dungeon[row][col];
+ unsigned short mask = dungeon[row][col];
if (mask & MONSTER) {
return(gmc_row_col(row, col));
return(' ');
}
-get_mask_char(mask)
-register unsigned short mask;
+char
+get_mask_char(unsigned short mask)
{
switch(mask) {
case SCROL:
}
}
-gr_row_col(row, col, mask)
-short *row, *col;
-unsigned short mask;
+void
+gr_row_col(short *row, short *col, unsigned short mask)
{
short rn;
short r, c;
*col = c;
}
-gr_room()
+short
+gr_room(void)
{
short i;
return(i);
}
-party_objects(rn)
+short
+party_objects(int rn)
{
short i, j, nf = 0;
object *obj;
short n, N, row, col;
boolean found;
+ row = col = 0;
N = ((rooms[rn].bottom_row - rooms[rn].top_row) - 1) *
((rooms[rn].right_col - rooms[rn].left_col) - 1);
n = get_rand(5, 10);
return(nf);
}
-get_room_number(row, col)
-register row, col;
+short
+get_room_number(int row, int col)
{
short i;
return(NO_ROOM);
}
-is_all_connected()
+boolean
+is_all_connected(void)
{
short i, starting_room;
+ starting_room = 0;
for (i = 0; i < MAXROOMS; i++) {
rooms_visited[i] = 0;
if (rooms[i].is_room & (R_ROOM | R_MAZE)) {
return(1);
}
-visit_rooms(rn)
-int rn;
+static void
+visit_rooms(int rn)
{
short i;
short oth_rn;
}
}
-draw_magic_map()
+void
+draw_magic_map(void)
{
short i, j, ch, och;
unsigned short mask = (HORWALL | VERTWALL | DOOR | TUNNEL | TRAP | STAIRS |
if (s & MONSTER) {
object *monster;
- if (monster = object_at(&level_monsters, i, j)) {
- monster->trail_char = ch;
+ if ((monster = object_at(
+ &level_monsters, i, j))
+ != NULL) {
+ monster->trail_char =
+ ch;
}
}
}
}
}
-dr_course(monster, entering, row, col)
-object *monster;
-boolean entering;
-short row, col;
+void
+dr_course(object *monster, boolean entering, short row, short col)
{
short i, j, k, rn;
short r, rr;
}
}
/* look for door to dead end */
+ if (rn == NO_ROOM)
+ clean_up("dr_course: monster not in room");
for (i = rooms[rn].top_row; i <= rooms[rn].bottom_row; i++) {
for (j = rooms[rn].left_col; j <= rooms[rn].right_col; j++) {
if ((i != monster->row) && (j != monster->col) &&
/* no place to send monster */
monster->trow = NO_ROOM;
} else { /* exiting room */
- if (!get_oth_room(rn, &row, &col)) {
+ if (rn == NO_ROOM || !get_oth_room(rn, &row, &col)) {
monster->trow = NO_ROOM;
} else {
monster->trow = row;
}
}
-get_oth_room(rn, row, col)
-short rn, *row, *col;
+static boolean
+get_oth_room(short rn, short *row, short *col)
{
short d = -1;
return(0);
}
-edit_opts()
+void
+edit_opts(void)
{
char save[NOPTS+1][DCOLS];
short i, j;
opt_go(++i);
break;
}
+ /* FALLTHROUGH */
default:
if (options[i].is_bool) {
sound_bell();
ch = rgetchar();
} while ((ch != '\012') && (ch != '\015') && (ch != '\033'));
if (j != 0) {
- (void) strcpy(*(options[i].strval), buf);
+ /*
+ * We rely on the option string being
+ * allocated to hold MAX_OPT_LEN+2
+ * bytes. This is arranged in init.c.
+ */
+ (void)strcpy(*(options[i].strval), buf);
}
opt_show(i);
goto CH;
}
}
-opt_show(i)
-int i;
+static void
+opt_show(int i)
{
- char *s;
- struct option *opt = &options[i];
+ const char *s;
+ const struct option *opt = &options[i];
opt_erase(i);
addstr(s);
}
-opt_erase(i)
-int i;
+static void
+opt_erase(int i)
{
- struct option *opt = &options[i];
+ const struct option *opt = &options[i];
mvaddstr(i, 0, opt->prompt);
clrtoeol();
}
-opt_go(i)
-int i;
+static void
+opt_go(int i)
{
move(i, strlen(options[i].prompt));
}
-do_shell()
+void
+do_shell(void)
{
#ifdef UNIX
- char *sh;
+ const char *sh;
md_ignore_signals();
if (!(sh = md_getenv("SHELL"))) {