ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more

things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
This commit is contained in:
dholland 2008-01-14 03:50:01 +00:00
parent 132fca675f
commit 130a8172b6
24 changed files with 633 additions and 916 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: hit.c,v 1.9 2008/01/14 00:23:51 dholland Exp $ */
/* $NetBSD: hit.c,v 1.10 2008/01/14 03:50:01 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)hit.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: hit.c,v 1.9 2008/01/14 00:23:51 dholland Exp $");
__RCSID("$NetBSD: hit.c,v 1.10 2008/01/14 03:50:01 dholland Exp $");
#endif
#endif /* not lint */
@ -55,12 +55,15 @@ __RCSID("$NetBSD: hit.c,v 1.9 2008/01/14 00:23:51 dholland Exp $");
#include "rogue.h"
object *fight_monster = 0;
static int damage_for_strength(void);
static int get_w_damage(const object *);
static int to_hit(const object *);
static object *fight_monster = NULL;
char hit_message[HIT_MESSAGE_SIZE] = "";
void
mon_hit(monster)
object *monster;
mon_hit(object *monster)
{
short damage, hit_chance;
const char *mn;
@ -119,9 +122,7 @@ mon_hit(monster)
}
void
rogue_hit(monster, force_hit)
object *monster;
boolean force_hit;
rogue_hit(object *monster, boolean force_hit)
{
short damage, hit_chance;
@ -160,10 +161,7 @@ RET: check_gold_seeker(monster);
}
void
rogue_damage(d, monster, other)
short d;
object *monster;
short other;
rogue_damage(short d, object *monster, short other)
{
if (d >= rogue.hp_current) {
rogue.hp_current = 0;
@ -177,9 +175,7 @@ rogue_damage(d, monster, other)
}
int
get_damage(ds, r)
const char *ds;
boolean r;
get_damage(const char *ds, boolean r)
{
int i = 0, j, n, d, total = 0;
@ -211,9 +207,8 @@ get_damage(ds, r)
return(total);
}
int
get_w_damage(obj)
const object *obj;
static int
get_w_damage(const object *obj)
{
char new_damage[32];
int tmp_to_hit, tmp_damage;
@ -238,8 +233,7 @@ get_w_damage(obj)
}
int
get_number(s)
const char *s;
get_number(const char *s)
{
int i = 0;
int total = 0;
@ -252,8 +246,7 @@ get_number(s)
}
long
lget_number(s)
const char *s;
lget_number(const char *s)
{
short i = 0;
long total = 0;
@ -265,9 +258,8 @@ lget_number(s)
return(total);
}
int
to_hit(obj)
const object *obj;
static int
to_hit(const object *obj)
{
if (!obj) {
return(1);
@ -275,8 +267,8 @@ to_hit(obj)
return(get_number(obj->damage) + obj->hit_enchant);
}
int
damage_for_strength()
static int
damage_for_strength(void)
{
short strength;
@ -307,9 +299,7 @@ damage_for_strength()
}
int
mon_damage(monster, damage)
object *monster;
short damage;
mon_damage(object *monster, short damage)
{
const char *mn;
short row, col;
@ -320,7 +310,7 @@ mon_damage(monster, damage)
row = monster->row;
col = monster->col;
dungeon[row][col] &= ~MONSTER;
mvaddch(row, col, (int)get_dungeon_char(row, col));
mvaddch(row, col, get_dungeon_char(row, col));
fight_monster = 0;
cough_up(monster);
@ -340,8 +330,7 @@ mon_damage(monster, damage)
}
void
fight(to_the_death)
boolean to_the_death;
fight(boolean to_the_death)
{
short ch, c, d;
short row, col;
@ -393,10 +382,7 @@ fight(to_the_death)
}
void
get_dir_rc(dir, row, col, allow_off_screen)
short dir;
short *row, *col;
short allow_off_screen;
get_dir_rc(short dir, short *row, short *col, short allow_off_screen)
{
switch(dir) {
case LEFT:
@ -447,8 +433,7 @@ get_dir_rc(dir, row, col, allow_off_screen)
}
int
get_hit_chance(weapon)
const object *weapon;
get_hit_chance(const object *weapon)
{
short hit_chance;
@ -459,8 +444,7 @@ get_hit_chance(weapon)
}
int
get_weapon_damage(weapon)
const object *weapon;
get_weapon_damage(const object *weapon)
{
short damage;
@ -471,8 +455,7 @@ get_weapon_damage(weapon)
}
void
s_con_mon(monster)
object *monster;
s_con_mon(object *monster)
{
if (con_mon) {
monster->m_flags |= CONFUSED;

View File

@ -1,4 +1,4 @@
/* $NetBSD: init.c,v 1.16 2008/01/14 00:23:51 dholland Exp $ */
/* $NetBSD: init.c,v 1.17 2008/01/14 03:50:01 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: init.c,v 1.16 2008/01/14 00:23:51 dholland Exp $");
__RCSID("$NetBSD: init.c,v 1.17 2008/01/14 03:50:01 dholland Exp $");
#endif
#endif /* not lint */
@ -58,13 +58,20 @@ __RCSID("$NetBSD: init.c,v 1.16 2008/01/14 00:23:51 dholland Exp $");
#include "rogue.h"
static void do_args(int, char **);
static void do_opts(void);
static void env_get_value(char **, char *, boolean);
static void init_str(char **, const char *);
static void player_init(void);
static char *rest_file = NULL;
static boolean init_curses = 0;
char login_name[MAX_OPT_LEN];
char *nick_name = (char *)0;
char *rest_file = 0;
char *nick_name = NULL;
boolean cant_int = 0;
boolean did_int = 0;
boolean score_only;
boolean init_curses = 0;
boolean save_is_interactive = 1;
boolean ask_quit = 1;
boolean no_skull = 0;
@ -74,9 +81,7 @@ const char *byebye_string = "Okay, bye bye!";
gid_t gid, egid;
int
init(argc, argv)
int argc;
char *argv[];
init(int argc, char *argv[])
{
const char *pn;
int seed;
@ -110,7 +115,7 @@ init(argc, argv)
initscr();
if ((LINES < DROWS) || (COLS < DCOLS)) {
clean_up("must be played on 24 x 80 screen");
clean_up("must be played on at least 80 x 24 screen");
}
start_window();
init_curses = 1;
@ -118,7 +123,7 @@ init(argc, argv)
md_heed_signals();
if (score_only) {
put_scores((object *)0, 0);
put_scores(NULL, 0);
}
seed = md_gseed();
(void)srrandom(seed);
@ -130,19 +135,19 @@ init(argc, argv)
get_wand_and_ring_materials();
make_scroll_titles();
level_objects.next_object = (object *)0;
level_monsters.next_monster = (object *)0;
level_objects.next_object = NULL;
level_monsters.next_monster = NULL;
player_init();
ring_stats(0);
return(0);
}
void
player_init()
static void
player_init(void)
{
object *obj;
rogue.pack.next_object = (object *)0;
rogue.pack.next_object = NULL;
obj = alloc_object();
get_food(obj, 1);
@ -187,8 +192,7 @@ player_init()
}
void
clean_up(estr)
const char *estr;
clean_up(const char *estr)
{
if (save_is_interactive) {
if (init_curses) {
@ -202,7 +206,7 @@ clean_up(estr)
}
void
start_window()
start_window(void)
{
cbreak();
noecho();
@ -212,14 +216,13 @@ start_window()
}
void
stop_window()
stop_window(void)
{
endwin();
}
void
byebye(dummy)
int dummy __unused;
byebye(int dummy __unused)
{
md_ignore_signals();
if (ask_quit) {
@ -231,8 +234,7 @@ byebye(dummy)
}
void
onintr(dummy)
int dummy __unused;
onintr(int dummy __unused)
{
md_ignore_signals();
if (cant_int) {
@ -245,20 +247,17 @@ onintr(dummy)
}
void
error_save(dummy)
int dummy __unused;
error_save(int dummy __unused)
{
save_is_interactive = 0;
save_into_file(error_file);
clean_up("");
}
void
do_args(argc, argv)
int argc;
char *argv[];
static void
do_args(int argc, char *argv[])
{
short i, j;
int i, j;
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
@ -275,8 +274,8 @@ do_args(argc, argv)
}
}
void
do_opts()
static void
do_opts(void)
{
char *eptr;
@ -323,10 +322,8 @@ do_opts()
init_str(&fruit, "slime-mold");
}
void
env_get_value(s, e, add_blank)
char **s, *e;
boolean add_blank;
static void
env_get_value(char **s, char *e, boolean add_blank)
{
short i = 0;
const char *t;
@ -353,10 +350,8 @@ env_get_value(s, e, add_blank)
(*s)[i] = '\0';
}
void
init_str(str, dflt)
char **str;
const char *dflt;
static void
init_str(char **str, const char *dflt)
{
if (!(*str)) {
/* note: edit_opts() in room.c depends on this size */

View File

@ -1,4 +1,4 @@
/* $NetBSD: inventory.c,v 1.12 2008/01/14 00:23:51 dholland Exp $ */
/* $NetBSD: inventory.c,v 1.13 2008/01/14 03:50:01 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)inventory.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: inventory.c,v 1.12 2008/01/14 00:23:51 dholland Exp $");
__RCSID("$NetBSD: inventory.c,v 1.13 2008/01/14 03:50:01 dholland Exp $");
#endif
#endif /* not lint */
@ -59,7 +59,7 @@ __RCSID("$NetBSD: inventory.c,v 1.12 2008/01/14 00:23:51 dholland Exp $");
boolean is_wood[WANDS];
const char *press_space = " --press space to continue--";
const char *const wand_materials[WAND_MATERIALS] = {
static const char *const wand_materials[WAND_MATERIALS] = {
"steel ",
"bronze ",
"gold ",
@ -93,7 +93,7 @@ const char *const wand_materials[WAND_MATERIALS] = {
"wooden "
};
const char *const gems[GEMS] = {
static const char *const gems[GEMS] = {
"diamond ",
"stibotantalite ",
"lapi-lazuli ",
@ -110,7 +110,7 @@ const char *const gems[GEMS] = {
"garnet "
};
const char *const syllables[MAXSYLLABLES] = {
static const char *const syllables[MAXSYLLABLES] = {
"blech ",
"foo ",
"barf ",
@ -160,7 +160,7 @@ struct id_com_s {
const char *com_desc;
};
const struct id_com_s com_id_tab[COMS] = {
static const struct id_com_s com_id_tab[COMS] = {
{'?', "? prints help"},
{'r', "r read scroll"},
{'/', "/ identify object"},
@ -212,9 +212,7 @@ const struct id_com_s com_id_tab[COMS] = {
};
void
inventory(pack, mask)
const object *pack;
unsigned short mask;
inventory(const object *pack, unsigned short mask)
{
object *obj;
short i = 0, j;
@ -281,7 +279,7 @@ inventory(pack, mask)
}
void
id_com()
id_com(void)
{
int ch = 0;
short i, j, k;
@ -358,8 +356,7 @@ MORE:
}
int
pr_com_id(ch)
int ch;
pr_com_id(int ch)
{
int i;
@ -372,9 +369,7 @@ pr_com_id(ch)
}
int
get_com_id(indexp, ch)
int *indexp;
short ch;
get_com_id(int *indexp, short ch)
{
short i;
@ -388,8 +383,7 @@ get_com_id(indexp, ch)
}
int
pr_motion_char(ch)
int ch;
pr_motion_char(int ch)
{
if ( (ch == 'J') ||
(ch == 'K') ||
@ -426,7 +420,7 @@ pr_motion_char(ch)
}
void
mix_colors()
mix_colors(void)
{
short i, j, k;
char t[MAX_ID_TITLE_LEN];
@ -442,7 +436,7 @@ mix_colors()
}
void
make_scroll_titles()
make_scroll_titles(void)
{
short i, j, n;
short sylls, s;
@ -470,18 +464,16 @@ struct sbuf {
size_t maxlen;
};
static void sbuf_init __P((struct sbuf *s, char *buf, size_t maxlen));
static void sbuf_addstr __P((struct sbuf *s, const char *str));
static void sbuf_addf __P((struct sbuf *s, const char *fmt, ...));
static void desc_count __P((struct sbuf *s, int n));
static void desc_called __P((struct sbuf *s, const object *));
static void sbuf_init(struct sbuf *s, char *buf, size_t maxlen);
static void sbuf_addstr(struct sbuf *s, const char *str);
static void sbuf_addf(struct sbuf *s, const char *fmt, ...)
__attribute__((__format__(__printf__, 2, 3)));
static void desc_count(struct sbuf *s, int n);
static void desc_called(struct sbuf *s, const object *);
static
void
sbuf_init(s, buf, maxlen)
struct sbuf *s;
char *buf;
size_t maxlen;
sbuf_init(struct sbuf *s, char *buf, size_t maxlen)
{
s->buf = buf;
s->maxlen = maxlen;
@ -491,16 +483,11 @@ sbuf_init(s, buf, maxlen)
static
void
sbuf_addstr(s, str)
struct sbuf *s;
const char *str;
sbuf_addstr(struct sbuf *s, const char *str)
{
strlcat(s->buf, str, s->maxlen);
}
static void sbuf_addf(struct sbuf *s, const char *fmt, ...)
__attribute__((__format__(__printf__, 2, 3)));
static
void
sbuf_addf(struct sbuf *s, const char *fmt, ...)
@ -516,9 +503,7 @@ sbuf_addf(struct sbuf *s, const char *fmt, ...)
static
void
desc_count(s, n)
struct sbuf *s;
int n;
desc_count(struct sbuf *s, int n)
{
if (n == 1) {
sbuf_addstr(s, "an ");
@ -529,9 +514,7 @@ desc_count(s, n)
static
void
desc_called(s, obj)
struct sbuf *s;
const object *obj;
desc_called(struct sbuf *s, const object *obj)
{
struct id *id_table;
@ -542,10 +525,7 @@ desc_called(s, obj)
}
void
get_desc(obj, desc, desclen)
const object *obj;
char *desc;
size_t desclen;
get_desc(const object *obj, char *desc, size_t desclen)
{
const char *item_name;
struct id *id_table;
@ -690,7 +670,7 @@ get_desc(obj, desc, desclen)
}
void
get_wand_and_ring_materials()
get_wand_and_ring_materials(void)
{
short i, j;
boolean used[WAND_MATERIALS];
@ -721,8 +701,7 @@ get_wand_and_ring_materials()
}
void
single_inv(ichar)
short ichar;
single_inv(short ichar)
{
short ch, ch2;
char desc[DCOLS];
@ -743,8 +722,7 @@ single_inv(ichar)
}
struct id *
get_id_table(obj)
const object *obj;
get_id_table(const object *obj)
{
switch(obj->what_is) {
case SCROL:
@ -764,8 +742,7 @@ get_id_table(obj)
}
void
inv_armor_weapon(is_weapon)
boolean is_weapon;
inv_armor_weapon(boolean is_weapon)
{
if (is_weapon) {
if (rogue.weapon) {
@ -783,7 +760,7 @@ inv_armor_weapon(is_weapon)
}
void
id_type()
id_type(void)
{
const char *id;
int ch;

View File

@ -1,4 +1,4 @@
/* $NetBSD: level.c,v 1.9 2008/01/14 00:23:51 dholland Exp $ */
/* $NetBSD: level.c,v 1.10 2008/01/14 03:50:01 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)level.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: level.c,v 1.9 2008/01/14 00:23:51 dholland Exp $");
__RCSID("$NetBSD: level.c,v 1.10 2008/01/14 03:50:01 dholland Exp $");
#endif
#endif /* not lint */
@ -55,14 +55,31 @@ __RCSID("$NetBSD: level.c,v 1.9 2008/01/14 00:23:51 dholland Exp $");
#include "rogue.h"
#define swap(x,y) {t = x; x = y; y = t;}
#define SWAP(x,y) (t = (x), (x) = (y), (y) = t)
static void add_mazes(void);
static int connect_rooms(short, short);
static void draw_simple_passage(short, short, short, short, short);
static void fill_it(int, boolean);
static void fill_out_level(void);
static int get_exp_level(long);
static void hide_boxed_passage(short, short, short, short, short);
static void make_maze(short, short, short, short, short, short);
static void make_room(short, short, short, short);
static boolean mask_room(short, short *, short *, unsigned short);
static void mix_random_rooms(void);
static void put_door(room *, short, short *, short *);
static void recursive_deadend(short, const short *, short, short);
static int same_col(int, int);
static int same_row(int, int);
short cur_level = 0;
short max_level = 1;
short cur_room;
const char *new_level_message = 0;
const char *new_level_message = NULL;
short party_room = NO_ROOM;
short r_de;
static short r_de;
const long level_points[MAX_EXP_LEVEL] = {
10L,
@ -88,10 +105,10 @@ const long level_points[MAX_EXP_LEVEL] = {
99900000L
};
short random_rooms[MAXROOMS] = {3, 7, 5, 2, 0, 6, 1, 4, 8};
static short random_rooms[MAXROOMS] = {3, 7, 5, 2, 0, 6, 1, 4, 8};
void
make_level()
make_level(void)
{
short i, j;
short must_1, must_2, must_3;
@ -189,9 +206,8 @@ make_level()
}
}
void
make_room(rn, r1, r2, r3)
short rn, r1, r2, r3;
static void
make_room(short rn, short r1, short r2, short r3)
{
short left_col, right_col, top_row, bottom_row;
short width, height;
@ -300,9 +316,8 @@ END:
rooms[rn].right_col = right_col;
}
int
connect_rooms(room1, room2)
short room1, room2;
static int
connect_rooms(short room1, short room2)
{
short row1, col1, row2, col2, dir;
@ -349,7 +364,7 @@ connect_rooms(room1, room2)
}
void
clear_level()
clear_level(void)
{
short i, j;
@ -375,11 +390,8 @@ clear_level()
clear();
}
void
put_door(rm, dir, row, col)
room *rm;
short dir;
short *row, *col;
static void
put_door(room *rm, short dir, short *row, short *col)
{
short wall_width;
@ -413,16 +425,15 @@ put_door(rm, dir, row, col)
rm->doors[dir/2].door_col = *col;
}
void
draw_simple_passage(row1, col1, row2, col2, dir)
short row1, col1, row2, col2, dir;
static void
draw_simple_passage(short row1, short col1, short row2, short col2, short dir)
{
short i, middle, t;
if ((dir == LEFT) || (dir == RIGHT)) {
if (col1 > col2) {
swap(row1, row2);
swap(col1, col2);
SWAP(row1, row2);
SWAP(col1, col2);
}
middle = get_rand(col1+1, col2-1);
for (i = col1+1; i != middle; i++) {
@ -436,8 +447,8 @@ draw_simple_passage(row1, col1, row2, col2, dir)
}
} else {
if (row1 > row2) {
swap(row1, row2);
swap(col1, col2);
SWAP(row1, row2);
SWAP(col1, col2);
}
middle = get_rand(row1+1, row2-1);
for (i = row1+1; i != middle; i++) {
@ -455,22 +466,20 @@ draw_simple_passage(row1, col1, row2, col2, dir)
}
}
int
same_row(room1, room2)
int room1, room2;
static int
same_row(int room1, int room2)
{
return((room1 / 3) == (room2 / 3));
}
int
same_col(room1, room2)
int room1, room2;
static int
same_col(int room1, int room2)
{
return((room1 % 3) == (room2 % 3));
}
void
add_mazes()
static void
add_mazes(void)
{
short i, j;
short start;
@ -501,8 +510,8 @@ add_mazes()
}
}
void
fill_out_level()
static void
fill_out_level(void)
{
short i, rn;
@ -522,10 +531,8 @@ fill_out_level()
}
}
void
fill_it(rn, do_rec_de)
int rn;
boolean do_rec_de;
static void
fill_it(int rn, boolean do_rec_de)
{
short i, tunnel_dir, door_dir, drow, dcol;
short target_room, rooms_found = 0;
@ -584,11 +591,8 @@ fill_it(rn, do_rec_de)
}
}
void
recursive_deadend(rn, offsets, srow, scol)
short rn;
const short *offsets;
short srow, scol;
static void
recursive_deadend(short rn, const short *offsets, short srow, short scol)
{
short i, de;
short drow, dcol, tunnel_dir;
@ -620,11 +624,8 @@ recursive_deadend(rn, offsets, srow, scol)
}
}
boolean
mask_room(rn, row, col, mask)
short rn;
short *row, *col;
unsigned short mask;
static boolean
mask_room(short rn, short *row, short *col, unsigned short mask)
{
short i, j;
@ -640,9 +641,8 @@ mask_room(rn, row, col, mask)
return(0);
}
void
make_maze(r, c, tr, br, lc, rc)
short r, c, tr, br, lc, rc;
static void
make_maze(short r, short c, short tr, short br, short lc, short rc)
{
char dirs[4];
short i, t;
@ -661,7 +661,7 @@ make_maze(r, c, tr, br, lc, rc)
t1 = get_rand(0, 3);
t2 = get_rand(0, 3);
swap(dirs[t1], dirs[t2]);
SWAP(dirs[t1], dirs[t2]);
}
}
for (i = 0; i < 4; i++) {
@ -706,9 +706,8 @@ make_maze(r, c, tr, br, lc, rc)
}
}
void
hide_boxed_passage(row1, col1, row2, col2, n)
short row1, col1, row2, col2, n;
static void
hide_boxed_passage(short row1, short col1, short row2, short col2, short n)
{
short i, j, t;
short row, col, row_cut, col_cut;
@ -716,10 +715,10 @@ hide_boxed_passage(row1, col1, row2, col2, n)
if (cur_level > 2) {
if (row1 > row2) {
swap(row1, row2);
SWAP(row1, row2);
}
if (col1 > col2) {
swap(col1, col2);
SWAP(col1, col2);
}
h = row2 - row1;
w = col2 - col1;
@ -742,9 +741,11 @@ hide_boxed_passage(row1, col1, row2, col2, n)
}
}
/*
* try not to put in room NR
*/
void
put_player(nr)
short nr; /* try not to put in this room */
put_player(short nr)
{
short rn = nr, misses;
short row, col;
@ -776,7 +777,7 @@ put_player(nr)
}
int
drop_check()
drop_check(void)
{
if (wizard) {
return(1);
@ -793,7 +794,7 @@ drop_check()
}
int
check_up()
check_up(void)
{
if (!wizard) {
if (!(dungeon[rogue.row][rogue.col] & STAIRS)) {
@ -816,9 +817,7 @@ check_up()
}
void
add_exp(e, promotion)
int e;
boolean promotion;
add_exp(int e, boolean promotion)
{
short new_exp;
short i, hp;
@ -845,9 +844,8 @@ add_exp(e, promotion)
}
}
int
get_exp_level(e)
long e;
static int
get_exp_level(long e)
{
short i;
@ -860,7 +858,7 @@ get_exp_level(e)
}
int
hp_raise()
hp_raise(void)
{
int hp;
@ -869,7 +867,7 @@ hp_raise()
}
void
show_average_hp()
show_average_hp(void)
{
float real_average;
float effective_average;
@ -886,8 +884,8 @@ show_average_hp()
effective_average, extra_hp, less_hp);
}
void
mix_random_rooms()
static void
mix_random_rooms(void)
{
short i, t;
short x, y;
@ -897,6 +895,6 @@ mix_random_rooms()
x = get_rand(0, (MAXROOMS-1));
y = get_rand(0, (MAXROOMS-1));
} while (x == y);
swap(random_rooms[x], random_rooms[y]);
SWAP(random_rooms[x], random_rooms[y]);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.16 2008/01/14 00:23:52 dholland Exp $ */
/* $NetBSD: machdep.c,v 1.17 2008/01/14 03:50:01 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)machdep.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: machdep.c,v 1.16 2008/01/14 00:23:52 dholland Exp $");
__RCSID("$NetBSD: machdep.c,v 1.17 2008/01/14 03:50:01 dholland Exp $");
#endif
#endif /* not lint */
@ -128,7 +128,7 @@ __RCSID("$NetBSD: machdep.c,v 1.16 2008/01/14 00:23:52 dholland Exp $");
*/
void
md_slurp()
md_slurp(void)
{
(void)fpurge(stdin);
}
@ -150,7 +150,7 @@ md_slurp()
*/
void
md_heed_signals()
md_heed_signals(void)
{
signal(SIGINT, onintr);
signal(SIGQUIT, byebye);
@ -170,7 +170,7 @@ md_heed_signals()
*/
void
md_ignore_signals()
md_ignore_signals(void)
{
signal(SIGQUIT, SIG_IGN);
signal(SIGINT, SIG_IGN);
@ -187,8 +187,7 @@ md_ignore_signals()
*/
int
md_get_file_id(fname)
const char *fname;
md_get_file_id(const char *fname)
{
struct stat sbuf;
@ -207,8 +206,7 @@ md_get_file_id(fname)
*/
int
md_link_count(fname)
const char *fname;
md_link_count(const char *fname)
{
struct stat sbuf;
@ -231,8 +229,7 @@ md_link_count(fname)
*/
void
md_gct(rt_buf)
struct rogue_time *rt_buf;
md_gct(struct rogue_time *rt_buf)
{
struct tm *t;
time_t seconds;
@ -265,16 +262,14 @@ md_gct(rt_buf)
*/
void
md_gfmt(fname, rt_buf)
const char *fname;
struct rogue_time *rt_buf;
md_gfmt(const char *fname, struct rogue_time *rt_buf)
{
struct stat sbuf;
time_t seconds;
struct tm *t;
stat(fname, &sbuf);
seconds = (long)sbuf.st_mtime;
seconds = sbuf.st_mtime;
t = localtime(&seconds);
rt_buf->year = t->tm_year;
@ -297,8 +292,7 @@ md_gfmt(fname, rt_buf)
*/
boolean
md_df(fname)
const char *fname;
md_df(const char *fname)
{
if (unlink(fname)) {
return(0);
@ -316,13 +310,13 @@ md_df(fname)
*/
const char *
md_gln()
md_gln(void)
{
struct passwd *p;
if (!(p = getpwuid(getuid())))
return((char *)NULL);
return(p->pw_name);
return NULL;
return p->pw_name;
}
/* md_sleep:
@ -335,8 +329,7 @@ md_gln()
*/
void
md_sleep(nsecs)
int nsecs;
md_sleep(int nsecs)
{
(void)sleep(nsecs);
}
@ -365,8 +358,7 @@ md_sleep(nsecs)
*/
char *
md_getenv(name)
const char *name;
md_getenv(const char *name)
{
char *value;
@ -383,9 +375,8 @@ md_getenv(name)
* when no more memory can be allocated.
*/
char *
md_malloc(n)
int n;
void *
md_malloc(size_t n)
{
char *t;
@ -412,7 +403,7 @@ md_malloc(n)
*/
int
md_gseed()
md_gseed(void)
{
time_t seconds;
@ -428,8 +419,7 @@ md_gseed()
*/
void
md_exit(status)
int status;
md_exit(int status)
{
exit(status);
}
@ -446,10 +436,9 @@ md_exit(status)
*/
void
md_lock(l)
boolean l;
md_lock(boolean l)
{
static int fd;
static int fd = -1;
short tries;
if (l) {
@ -464,7 +453,7 @@ md_lock(l)
if (!flock(fd, LOCK_EX|LOCK_NB))
return;
} else {
(void)flock(fd, LOCK_NB);
(void)flock(fd, LOCK_UN|LOCK_NB);
(void)close(fd);
}
}
@ -482,8 +471,7 @@ md_lock(l)
*/
void
md_shell(shell)
const char *shell;
md_shell(const char *shell)
{
int w;
pid_t pid;
@ -493,7 +481,7 @@ md_shell(shell)
case -1:
break;
case 0:
execl(shell, shell, (char *)0);
execl(shell, shell, (char *)NULL);
_exit(255);
default:
waitpid(pid, &w, 0);
@ -501,4 +489,4 @@ md_shell(shell)
}
}
#endif
#endif /* UNIX */

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.7 2008/01/14 00:23:52 dholland Exp $ */
/* $NetBSD: main.c,v 1.8 2008/01/14 03:50:01 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993\n\
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: main.c,v 1.7 2008/01/14 00:23:52 dholland Exp $");
__RCSID("$NetBSD: main.c,v 1.8 2008/01/14 03:50:01 dholland Exp $");
#endif
#endif /* not lint */
@ -60,12 +60,8 @@ __RCSID("$NetBSD: main.c,v 1.7 2008/01/14 00:23:52 dholland Exp $");
#include "rogue.h"
int main(int, char **);
int
main(argc, argv)
int argc;
char *argv[];
main(int argc, char *argv[])
{
if (init(argc, argv)) { /* restored game */
goto PL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: message.c,v 1.12 2008/01/14 00:23:52 dholland Exp $ */
/* $NetBSD: message.c,v 1.13 2008/01/14 03:50:01 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)message.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: message.c,v 1.12 2008/01/14 00:23:52 dholland Exp $");
__RCSID("$NetBSD: message.c,v 1.13 2008/01/14 03:50:01 dholland Exp $");
#endif
#endif /* not lint */
@ -57,20 +57,19 @@ __RCSID("$NetBSD: message.c,v 1.12 2008/01/14 00:23:52 dholland Exp $");
#include <termios.h>
#include <stdarg.h>
#include "rogue.h"
#include "pathnames.h"
char msgs[NMESSAGES][DCOLS] = {"", "", "", "", ""};
short msg_col = 0, imsg = -1;
boolean msg_cleared = 1, rmsg = 0;
static char msgs[NMESSAGES][DCOLS] = {"", "", "", "", ""};
static short msg_col = 0, imsg = -1;
static boolean rmsg = 0;
boolean msg_cleared = 1;
char hunger_str[HUNGER_STR_LEN] = "";
const char *more = "-more-";
static void message __P((const char *, boolean));
static
void
message(msg, intrpt)
const char *msg;
boolean intrpt;
message(const char *msg, boolean intrpt)
{
cant_int = 1;
@ -120,8 +119,7 @@ messagef(boolean intrpt, const char *fmt, ...)
}
void
remessage(c)
short c;
remessage(short c)
{
if (imsg != -1) {
check_message();
@ -137,7 +135,7 @@ remessage(c)
}
void
check_message()
check_message(void)
{
if (msg_cleared) {
return;
@ -149,16 +147,13 @@ check_message()
}
int
get_input_line(prompt, insert, buf, buflen, if_cancelled, add_blank, do_echo)
const char *prompt, *insert;
char *buf;
size_t buflen;
const char *if_cancelled;
boolean add_blank;
boolean do_echo;
get_input_line(const char *prompt, const char *insert,
char *buf, size_t buflen,
const char *if_cancelled,
boolean add_blank, boolean do_echo)
{
short ch;
short i = 0, n;
size_t i = 0, n;
message(prompt, 0);
n = strlen(prompt);
@ -210,7 +205,7 @@ get_input_line(prompt, insert, buf, buflen, if_cancelled, add_blank, do_echo)
}
int
rgetchar()
rgetchar(void)
{
int ch;
@ -218,11 +213,11 @@ rgetchar()
ch = getchar();
switch(ch) {
case '\022':
case '\022': /* ^R */
wrefresh(curscr);
break;
#ifdef UNIX_BSD4_2
case '\032':
case '\032': /* ^Z */
printf("%s", CL);
fflush(stdout);
tstp();
@ -243,8 +238,7 @@ Level: 99 Gold: 999999 Hp: 999(999) Str: 99(99) Arm: 99 Exp: 21/10000000 Hungry
*/
void
print_stats(stat_mask)
int stat_mask;
print_stats(int stat_mask)
{
char buf[16];
boolean label;
@ -323,13 +317,13 @@ print_stats(stat_mask)
}
void
save_screen()
save_screen(void)
{
FILE *fp;
short i, j;
char buf[DCOLS+2];
if ((fp = fopen("rogue.screen", "w")) != NULL) {
if ((fp = fopen(_PATH_SCREENDUMP, "w")) != NULL) {
for (i = 0; i < DROWS; i++) {
for (j=0; j<DCOLS; j++) {
buf[j] = mvinch(i, j);
@ -348,24 +342,20 @@ save_screen()
}
void
sound_bell()
sound_bell(void)
{
putchar(7);
fflush(stdout);
}
boolean
is_digit(ch)
short ch;
is_digit(int ch)
{
return((ch >= '0') && (ch <= '9'));
}
int
r_index(str, ch, last)
const char *str;
int ch;
boolean last;
r_index(const char *str, int ch, boolean last)
{
int i = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: monster.c,v 1.13 2008/01/14 00:23:52 dholland Exp $ */
/* $NetBSD: monster.c,v 1.14 2008/01/14 03:50:01 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)monster.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: monster.c,v 1.13 2008/01/14 00:23:52 dholland Exp $");
__RCSID("$NetBSD: monster.c,v 1.14 2008/01/14 03:50:01 dholland Exp $");
#endif
#endif /* not lint */
@ -87,7 +87,7 @@ const char *const m_names[] = {
"zombie"
};
object mon_tab[MONSTERS] = {
static object mon_tab[MONSTERS] = {
{(ASLEEP|WAKENS|WANDERS|RUSTS),"0d0",25,'A',20,9,18,100,0,0,0,0,0},
{(ASLEEP|WANDERS|FLITS|FLIES),"1d3",10,'B',2,1,8,60,0,0,0,0,0},
{(ASLEEP|WANDERS),"3d3/2d5",32,'C',15,7,16,85,0,10,0,0,0},
@ -121,7 +121,7 @@ object mon_tab[MONSTERS] = {
};
void
put_mons()
put_mons(void)
{
short i;
short n;
@ -131,7 +131,7 @@ put_mons()
n = get_rand(4, 6);
for (i = 0; i < n; i++) {
monster = gr_monster((object *)0, 0);
monster = gr_monster(NULL, 0);
if ((monster->m_flags & WANDERS) && coin_toss()) {
wake_up(monster);
}
@ -141,9 +141,7 @@ put_mons()
}
object *
gr_monster(monster, mn)
object *monster;
int mn;
gr_monster(object *monster, int mn)
{
if (!monster) {
monster = alloc_object();
@ -168,7 +166,7 @@ gr_monster(monster, mn)
}
void
mv_mons()
mv_mons(void)
{
object *monster, *next_monster, *test_mons;
boolean flew;
@ -224,8 +222,7 @@ NM: test_mons = level_monsters.next_monster;
}
void
party_monsters(rn, n)
int rn, n;
party_monsters(int rn, int n)
{
short i, j;
short row, col;
@ -266,8 +263,7 @@ party_monsters(rn, n)
}
char
gmc_row_col(row, col)
int row, col;
gmc_row_col(int row, int col)
{
object *monster;
@ -286,8 +282,7 @@ gmc_row_col(row, col)
}
char
gmc(monster)
object *monster;
gmc(object *monster)
{
if ((!(detect_monster || see_invisible || r_see_invisible) &&
(monster->m_flags & INVISIBLE))
@ -301,9 +296,7 @@ gmc(monster)
}
void
mv_1_monster(monster, row, col)
object *monster;
short row, col;
mv_1_monster(object *monster, short row, short col)
{
short i, n;
boolean tried[6];
@ -441,9 +434,7 @@ O:
}
int
mtry(monster, row, col)
object *monster;
short row, col;
mtry(object *monster, short row, short col)
{
if (mon_can_go(monster, row, col)) {
move_mon_to(monster, row, col);
@ -453,9 +444,7 @@ mtry(monster, row, col)
}
void
move_mon_to(monster, row, col)
object *monster;
short row, col;
move_mon_to(object *monster, short row, short col)
{
short c;
int mrow, mcol;
@ -504,9 +493,7 @@ move_mon_to(monster, row, col)
}
int
mon_can_go(monster, row, col)
const object *monster;
short row, col;
mon_can_go(const object *monster, short row, short col)
{
object *obj;
short dr, dc;
@ -546,8 +533,7 @@ mon_can_go(monster, row, col)
}
void
wake_up(monster)
object *monster;
wake_up(object *monster)
{
if (!(monster->m_flags & NAPPING)) {
monster->m_flags &= (~(ASLEEP | IMITATES | WAKENS));
@ -555,10 +541,7 @@ wake_up(monster)
}
void
wake_room(rn, entering, row, col)
short rn;
boolean entering;
short row, col;
wake_room(short rn, boolean entering, short row, short col)
{
object *monster;
short wake_percent;
@ -592,8 +575,7 @@ wake_room(rn, entering, row, col)
}
const char *
mon_name(monster)
const object *monster;
mon_name(const object *monster)
{
short ch;
@ -610,8 +592,7 @@ mon_name(monster)
}
int
rogue_is_around(row, col)
int row, col;
rogue_is_around(int row, int col)
{
short rdif, cdif, retval;
@ -623,7 +604,7 @@ rogue_is_around(row, col)
}
void
wanderer()
wanderer(void)
{
object *monster;
short row, col, i;
@ -632,7 +613,7 @@ wanderer()
monster = NULL; /* XXXGCC -Wuninitialized [powerpc] */
for (i = 0; ((i < 15) && (!found)); i++) {
monster = gr_monster((object *)0, 0);
monster = gr_monster(NULL, 0);
if (!(monster->m_flags & (WAKENS | WANDERS))) {
free_object(monster);
} else {
@ -656,7 +637,7 @@ wanderer()
}
void
show_monsters()
show_monsters(void)
{
object *monster;
@ -678,7 +659,7 @@ show_monsters()
}
void
create_monster()
create_monster(void)
{
short row, col;
short i;
@ -714,9 +695,7 @@ create_monster()
}
void
put_m_at(row, col, monster)
short row, col;
object *monster;
put_m_at(short row, short col, object *monster)
{
monster->row = row;
monster->col = col;
@ -727,8 +706,7 @@ put_m_at(row, col, monster)
}
void
aim_monster(monster)
object *monster;
aim_monster(object *monster)
{
short i, rn, d, r;
@ -748,8 +726,7 @@ aim_monster(monster)
}
int
rogue_can_see(row, col)
int row, col;
rogue_can_see(int row, int col)
{
int retval;
@ -762,8 +739,7 @@ rogue_can_see(row, col)
}
int
move_confused(monster)
object *monster;
move_confused(object *monster)
{
short i, row, col;
@ -793,8 +769,7 @@ move_confused(monster)
}
int
flit(monster)
object *monster;
flit(object *monster)
{
short i, row, col;
@ -820,7 +795,7 @@ flit(monster)
}
char
gr_obj_char()
gr_obj_char(void)
{
short r;
const char *rs = "%!?]=/):*";
@ -831,8 +806,7 @@ gr_obj_char()
}
int
no_room_for_monster(rn)
int rn;
no_room_for_monster(int rn)
{
short i, j;
@ -847,7 +821,7 @@ no_room_for_monster(rn)
}
void
aggravate()
aggravate(void)
{
object *monster;
@ -866,9 +840,7 @@ aggravate()
}
boolean
mon_sees(monster, row, col)
const object *monster;
int row, col;
mon_sees(const object *monster, int row, int col)
{
short rn, rdif, cdif, retval;
@ -887,7 +859,7 @@ mon_sees(monster, row, col)
}
void
mv_aquatars()
mv_aquatars(void)
{
object *monster;

View File

@ -1,4 +1,4 @@
/* $NetBSD: move.c,v 1.10 2008/01/14 00:23:52 dholland Exp $ */
/* $NetBSD: move.c,v 1.11 2008/01/14 03:50:02 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: move.c,v 1.10 2008/01/14 00:23:52 dholland Exp $");
__RCSID("$NetBSD: move.c,v 1.11 2008/01/14 03:50:02 dholland Exp $");
#endif
#endif /* not lint */
@ -60,8 +60,7 @@ boolean jump = 0;
const char *you_can_move_again = "you can move again";
int
one_move_rogue(dirch, pickup)
short dirch, pickup;
one_move_rogue(short dirch, short pickup)
{
short row, col;
object *obj;
@ -172,8 +171,7 @@ MVED: if (reg_move()) { /* fainted from hunger */
}
void
multiple_move_rogue(dirch)
short dirch;
multiple_move_rogue(short dirch)
{
short row, col;
short m;
@ -221,8 +219,7 @@ multiple_move_rogue(dirch)
}
boolean
is_passable(row, col)
int row, col;
is_passable(int row, int col)
{
if ((row < MIN_ROW) || (row > (DROWS - 2)) || (col < 0) ||
(col > (DCOLS-1))) {
@ -235,8 +232,7 @@ is_passable(row, col)
}
boolean
next_to_something(drow, dcol)
int drow, dcol;
next_to_something(int drow, int dcol)
{
short i, j, i_end, j_end, row, col;
short pass_count = 0;
@ -297,8 +293,7 @@ next_to_something(drow, dcol)
}
boolean
can_move(row1, col1, row2, col2)
int row1, col1, row2, col2;
can_move(int row1, int col1, int row2, int col2)
{
if (!is_passable(row2, col2)) {
return(0);
@ -315,7 +310,7 @@ can_move(row1, col1, row2, col2)
}
void
move_onto()
move_onto(void)
{
short ch, d;
boolean first_miss = 1;
@ -334,9 +329,7 @@ move_onto()
}
boolean
is_direction(c, d)
short c;
short *d;
is_direction(short c, short *d)
{
switch(c) {
case 'h':
@ -372,8 +365,7 @@ is_direction(c, d)
}
boolean
check_hunger(msg_only)
boolean msg_only;
check_hunger(boolean msg_only)
{
short i, n;
boolean fainted = 0;
@ -413,7 +405,7 @@ check_hunger(msg_only)
return(fainted);
}
if (rogue.moves_left <= STARVE) {
killed_by((object *)0, STARVATION);
killed_by(NULL, STARVATION);
}
switch(e_rings) {
@ -441,7 +433,7 @@ check_hunger(msg_only)
}
boolean
reg_move()
reg_move(void)
{
boolean fainted;
@ -498,8 +490,7 @@ reg_move()
}
void
rest(count)
int count;
rest(int count)
{
int i;
@ -514,7 +505,7 @@ rest(count)
}
char
gr_dir()
gr_dir(void)
{
short d;
@ -550,7 +541,7 @@ gr_dir()
}
void
heal()
heal(void)
{
static short heal_exp = -1, n, c = 0;
static boolean alt;
@ -615,8 +606,7 @@ heal()
}
boolean
can_turn(nrow, ncol)
short nrow, ncol;
can_turn(short nrow, short ncol)
{
if ((dungeon[nrow][ncol] & TUNNEL) && is_passable(nrow, ncol)) {
return(1);
@ -625,9 +615,7 @@ can_turn(nrow, ncol)
}
void
turn_passage(dir, fast)
short dir;
boolean fast;
turn_passage(short dir, boolean fast)
{
short crow = rogue.row, ccol = rogue.col, turns = 0;
short ndir = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: object.c,v 1.12 2008/01/14 00:23:52 dholland Exp $ */
/* $NetBSD: object.c,v 1.13 2008/01/14 03:50:02 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)object.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: object.c,v 1.12 2008/01/14 00:23:52 dholland Exp $");
__RCSID("$NetBSD: object.c,v 1.13 2008/01/14 03:50:02 dholland Exp $");
#endif
#endif /* not lint */
@ -58,8 +58,9 @@ __RCSID("$NetBSD: object.c,v 1.12 2008/01/14 00:23:52 dholland Exp $");
object level_objects;
unsigned short dungeon[DROWS][DCOLS];
short foods = 0;
object *free_list = (object *)0;
char *fruit = (char *)0;
char *fruit = NULL;
static object *free_list = NULL;
fighter rogue = {
INIT_AW, /* armor */
@ -162,7 +163,7 @@ struct id id_rings[RINGS] = {
};
void
put_objects()
put_objects(void)
{
short i, n;
object *obj;
@ -185,7 +186,7 @@ put_objects()
}
void
put_gold()
put_gold(void)
{
short i, j;
short row,col;
@ -215,9 +216,7 @@ put_gold()
}
void
plant_gold(row, col, is_maze)
short row, col;
boolean is_maze;
plant_gold(short row, short col, boolean is_maze)
{
object *obj;
@ -233,9 +232,7 @@ plant_gold(row, col, is_maze)
}
void
place_at(obj, row, col)
object *obj;
int row, col;
place_at(object *obj, int row, int col)
{
obj->row = row;
obj->col = col;
@ -244,11 +241,9 @@ place_at(obj, row, col)
}
object *
object_at(pack, row, col)
object *pack;
short row, col;
object_at(object *pack, short row, short col)
{
object *obj = (object *)0;
object *obj = NULL;
if (dungeon[row][col] & (MONSTER | OBJECT)) {
obj = pack->next_object;
@ -264,8 +259,7 @@ object_at(pack, row, col)
}
object *
get_letter_object(ch)
int ch;
get_letter_object(int ch)
{
object *obj;
@ -278,8 +272,7 @@ get_letter_object(ch)
}
void
free_stuff(objlist)
object *objlist;
free_stuff(object *objlist)
{
object *obj;
@ -292,8 +285,7 @@ free_stuff(objlist)
}
const char *
name_of(obj)
const object *obj;
name_of(const object *obj)
{
const char *retstring;
@ -349,7 +341,7 @@ name_of(obj)
}
object *
gr_object()
gr_object(void)
{
object *obj;
@ -388,7 +380,7 @@ gr_object()
}
unsigned short
gr_what_is()
gr_what_is(void)
{
short percent;
unsigned short what_is;
@ -414,8 +406,7 @@ gr_what_is()
}
void
gr_scroll(obj)
object *obj;
gr_scroll(object *obj)
{
short percent;
@ -453,8 +444,7 @@ gr_scroll(obj)
}
void
gr_potion(obj)
object *obj;
gr_potion(object *obj)
{
short percent;
@ -494,9 +484,7 @@ gr_potion(obj)
}
void
gr_weapon(obj, assign_wk)
object *obj;
int assign_wk;
gr_weapon(object *obj, int assign_wk)
{
short percent;
short i;
@ -507,7 +495,7 @@ gr_weapon(obj, assign_wk)
obj->which_kind = get_rand(0, (WEAPONS - 1));
}
if ((obj->which_kind == ARROW) || (obj->which_kind == DAGGER) ||
(obj->which_kind == SHURIKEN) | (obj->which_kind == DART)) {
(obj->which_kind == SHURIKEN) || (obj->which_kind == DART)) {
obj->quantity = get_rand(3, 15);
obj->quiver = get_rand(0, 126);
} else {
@ -560,8 +548,7 @@ gr_weapon(obj, assign_wk)
}
void
gr_armor(obj)
object *obj;
gr_armor(object *obj)
{
short percent;
short blessing;
@ -587,8 +574,7 @@ gr_armor(obj)
}
void
gr_wand(obj)
object *obj;
gr_wand(object *obj)
{
obj->what_is = WAND;
obj->which_kind = get_rand(0, (WANDS - 1));
@ -596,9 +582,7 @@ gr_wand(obj)
}
void
get_food(obj, force_ration)
object *obj;
boolean force_ration;
get_food(object *obj, boolean force_ration)
{
obj->what_is = FOOD;
@ -610,7 +594,7 @@ get_food(obj, force_ration)
}
void
put_stairs()
put_stairs(void)
{
short row, col;
@ -619,8 +603,7 @@ put_stairs()
}
int
get_armor_class(obj)
const object *obj;
get_armor_class(const object *obj)
{
if (obj) {
return(obj->class + obj->d_enchant);
@ -629,14 +612,14 @@ get_armor_class(obj)
}
object *
alloc_object()
alloc_object(void)
{
object *obj;
if (free_list) {
obj = free_list;
free_list = free_list->next_object;
} else if (!(obj = (object *)md_malloc(sizeof(object)))) {
} else if (!(obj = md_malloc(sizeof(object)))) {
messagef(0, "cannot allocate object, saving game");
save_into_file(error_file);
clean_up("alloc_object: save failed");
@ -651,15 +634,14 @@ alloc_object()
}
void
free_object(obj)
object *obj;
free_object(object *obj)
{
obj->next_object = free_list;
free_list = obj;
}
void
make_party()
make_party(void)
{
short n;
@ -672,7 +654,7 @@ make_party()
}
void
show_objects()
show_objects(void)
{
object *obj;
short mc, rc, row, col;
@ -711,7 +693,7 @@ show_objects()
}
void
put_amulet()
put_amulet(void)
{
object *obj;
@ -721,8 +703,7 @@ put_amulet()
}
void
rand_place(obj)
object *obj;
rand_place(object *obj)
{
short row, col;
@ -731,14 +712,14 @@ rand_place(obj)
}
void
c_object_for_wizard()
c_object_for_wizard(void)
{
short ch, max, wk;
object *obj;
char buf[80];
max = 0;
if (pack_count((object *)0) >= MAX_PACK_COUNT) {
if (pack_count(NULL) >= MAX_PACK_COUNT) {
messagef(0, "pack full");
return;
}
@ -791,7 +772,7 @@ GIL:
if (get_input_line("which kind?", "", buf, sizeof(buf), "", 0, 1)) {
wk = get_number(buf);
if ((wk >= 0) && (wk <= max)) {
obj->which_kind = (unsigned short)wk;
obj->which_kind = wk;
if (obj->what_is == RING) {
gr_ring(obj, 0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: pack.c,v 1.9 2008/01/14 00:23:52 dholland Exp $ */
/* $NetBSD: pack.c,v 1.10 2008/01/14 03:50:02 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)pack.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: pack.c,v 1.9 2008/01/14 00:23:52 dholland Exp $");
__RCSID("$NetBSD: pack.c,v 1.10 2008/01/14 03:50:02 dholland Exp $");
#endif
#endif /* not lint */
@ -58,9 +58,7 @@ __RCSID("$NetBSD: pack.c,v 1.9 2008/01/14 00:23:52 dholland Exp $");
const char *curse_message = "you can't, it appears to be cursed";
object *
add_to_pack(obj, pack, condense)
object *obj, *pack;
int condense;
add_to_pack(object *obj, object *pack, int condense)
{
object *op;
@ -87,8 +85,7 @@ add_to_pack(obj, pack, condense)
}
void
take_from_pack(obj, pack)
object *obj, *pack;
take_from_pack(object *obj, object *pack)
{
while (pack->next_object != obj) {
pack = pack->next_object;
@ -101,9 +98,7 @@ take_from_pack(obj, pack)
*/
object *
pick_up(row, col, status)
short *status;
int row, col;
pick_up(int row, int col, short *status)
{
object *obj;
@ -111,7 +106,7 @@ pick_up(row, col, status)
if (levitate) {
messagef(0, "you're floating in the air!");
return((object *)0);
return NULL;
}
obj = object_at(&level_objects, row, col);
if (!obj) {
@ -128,7 +123,7 @@ pick_up(row, col, status)
if (id_scrolls[SCARE_MONSTER].id_status == UNIDENTIFIED) {
id_scrolls[SCARE_MONSTER].id_status = IDENTIFIED;
}
return((object *)0);
return NULL;
}
if (obj->what_is == GOLD) {
rogue.gold += obj->quantity;
@ -139,7 +134,7 @@ pick_up(row, col, status)
}
if (pack_count(obj) >= MAX_PACK_COUNT) {
messagef(1, "pack too full");
return((object *)0);
return NULL;
}
dungeon[row][col] &= ~(OBJECT);
take_from_pack(obj, &level_objects);
@ -149,7 +144,7 @@ pick_up(row, col, status)
}
void
drop()
drop(void)
{
object *obj, *new;
short ch;
@ -211,8 +206,7 @@ drop()
}
object *
check_duplicate(obj, pack)
object *obj, *pack;
check_duplicate(object *obj, object *pack)
{
object *op;
@ -245,7 +239,7 @@ check_duplicate(obj, pack)
}
short
next_avail_ichar()
next_avail_ichar(void)
{
object *obj;
int i;
@ -270,16 +264,14 @@ next_avail_ichar()
}
void
wait_for_ack()
wait_for_ack(void)
{
while (rgetchar() != ' ')
;
}
short
pack_letter(prompt, mask)
const char *prompt;
unsigned short mask;
pack_letter(const char *prompt, unsigned short mask)
{
short ch;
unsigned short tmask = mask;
@ -315,7 +307,7 @@ pack_letter(prompt, mask)
}
void
take_off()
take_off(void)
{
char desc[DCOLS];
object *obj;
@ -338,7 +330,7 @@ take_off()
}
void
wear()
wear(void)
{
short ch;
object *obj;
@ -370,18 +362,16 @@ wear()
}
void
unwear(obj)
object *obj;
unwear(object *obj)
{
if (obj) {
obj->in_use_flags &= (~BEING_WORN);
}
rogue.armor = (object *)0;
rogue.armor = NULL;
}
void
do_wear(obj)
object *obj;
do_wear(object *obj)
{
rogue.armor = obj;
obj->in_use_flags |= BEING_WORN;
@ -389,7 +379,7 @@ do_wear(obj)
}
void
wield()
wield(void)
{
short ch;
object *obj;
@ -425,25 +415,23 @@ wield()
}
void
do_wield(obj)
object *obj;
do_wield(object *obj)
{
rogue.weapon = obj;
obj->in_use_flags |= BEING_WIELDED;
}
void
unwield(obj)
object *obj;
unwield(object *obj)
{
if (obj) {
obj->in_use_flags &= (~BEING_WIELDED);
}
rogue.weapon = (object *)0;
rogue.weapon = NULL;
}
void
call_it()
call_it(void)
{
short ch;
object *obj;
@ -474,8 +462,7 @@ call_it()
}
short
pack_count(new_obj)
const object *new_obj;
pack_count(const object *new_obj)
{
object *obj;
short count = 0;
@ -502,9 +489,7 @@ pack_count(new_obj)
}
boolean
mask_pack(pack, mask)
const object *pack;
unsigned short mask;
mask_pack(const object *pack, unsigned short mask)
{
while (pack->next_object) {
pack = pack->next_object;
@ -516,9 +501,7 @@ mask_pack(pack, mask)
}
boolean
is_pack_letter(c, mask)
short *c;
unsigned short *mask;
is_pack_letter(short *c, unsigned short *mask)
{
if (((*c == '?') || (*c == '!') || (*c == ':') || (*c == '=') ||
(*c == ')') || (*c == ']') || (*c == '/') || (*c == ','))) {
@ -555,13 +538,13 @@ is_pack_letter(c, mask)
}
boolean
has_amulet()
has_amulet(void)
{
return(mask_pack(&rogue.pack, AMULET));
}
void
kick_into_pack()
kick_into_pack(void)
{
object *obj;
char desc[DCOLS];

View File

@ -1,4 +1,4 @@
/* $NetBSD: pathnames.h,v 1.4 2003/08/07 09:37:39 agc Exp $ */
/* $NetBSD: pathnames.h,v 1.5 2008/01/14 03:50:02 dholland Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -32,3 +32,4 @@
*/
#define _PATH_SCOREFILE "/var/games/rogue.scores"
#define _PATH_SCREENDUMP "rogue.screen"

View File

@ -1,4 +1,4 @@
/* $NetBSD: play.c,v 1.8 2008/01/14 00:23:52 dholland Exp $ */
/* $NetBSD: play.c,v 1.9 2008/01/14 03:50:02 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)play.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: play.c,v 1.8 2008/01/14 00:23:52 dholland Exp $");
__RCSID("$NetBSD: play.c,v 1.9 2008/01/14 03:50:02 dholland Exp $");
#endif
#endif /* not lint */
@ -56,10 +56,11 @@ __RCSID("$NetBSD: play.c,v 1.8 2008/01/14 00:23:52 dholland Exp $");
#include "rogue.h"
boolean interrupted = 0;
const char *unknown_command = "unknown command";
static const char unknown_command[] = "unknown command";
void
play_level()
play_level(void)
{
short ch;
int count;

View File

@ -1,4 +1,4 @@
/* $NetBSD: random.c,v 1.6 2008/01/14 00:23:52 dholland Exp $ */
/* $NetBSD: random.c,v 1.7 2008/01/14 03:50:02 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)random.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: random.c,v 1.6 2008/01/14 00:23:52 dholland Exp $");
__RCSID("$NetBSD: random.c,v 1.7 2008/01/14 03:50:02 dholland Exp $");
#endif
#endif /* not lint */
@ -74,12 +74,11 @@ static int rand_sep = 3;
static long *end_ptr = &rntb[32];
void
srrandom(x)
int x;
srrandom(int x)
{
int i;
state[0] = (long)x;
state[0] = x;
if (rand_type != 0) {
for (i = 1; i < rand_deg; i++) {
state[i] = 1103515245 * state[i - 1] + 12345;
@ -93,7 +92,7 @@ srrandom(x)
}
long
rrandom()
rrandom(void)
{
long i;
@ -115,8 +114,7 @@ rrandom()
}
int
get_rand(x, y)
int x, y;
get_rand(int x, int y)
{
int r, t;
long lr;
@ -127,21 +125,20 @@ get_rand(x, y)
x = t;
}
lr = rrandom();
lr &= (long)0x00003fff;
lr &= 0x00003fffL;
r = (int)lr;
r = (r % ((y - x) + 1)) + x;
return(r);
}
int
rand_percent(percentage)
int percentage;
rand_percent(int percentage)
{
return(get_rand(1, 100) <= percentage);
}
int
coin_toss()
coin_toss(void)
{
return(((rrandom() & 01) ? 1 : 0));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ring.c,v 1.8 2008/01/14 00:23:52 dholland Exp $ */
/* $NetBSD: ring.c,v 1.9 2008/01/14 03:50:02 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)ring.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: ring.c,v 1.8 2008/01/14 00:23:52 dholland Exp $");
__RCSID("$NetBSD: ring.c,v 1.9 2008/01/14 03:50:02 dholland Exp $");
#endif
#endif /* not lint */
@ -55,8 +55,9 @@ __RCSID("$NetBSD: ring.c,v 1.8 2008/01/14 00:23:52 dholland Exp $");
#include "rogue.h"
const char *left_or_right = "left or right hand?";
const char *no_ring = "there's no ring on that hand";
static const char left_or_right[] = "left or right hand?";
static const char no_ring[] = "there's no ring on that hand";
short stealthy;
short r_rings;
short add_strength;
@ -70,7 +71,7 @@ boolean sustain_strength;
boolean maintain_armor;
void
put_on_ring()
put_on_ring(void)
{
short ch;
char desc[DCOLS];
@ -131,9 +132,7 @@ put_on_ring()
*/
void
do_put_on(ring, on_left)
object *ring;
boolean on_left;
do_put_on(object *ring, boolean on_left)
{
if (on_left) {
ring->in_use_flags |= ON_LEFT_HAND;
@ -145,7 +144,7 @@ do_put_on(ring, on_left)
}
void
remove_ring()
remove_ring(void)
{
boolean left = 0, right = 0;
short ch;
@ -195,23 +194,20 @@ remove_ring()
}
void
un_put_on(ring)
object *ring;
un_put_on(object *ring)
{
if (ring && (ring->in_use_flags & ON_LEFT_HAND)) {
ring->in_use_flags &= (~ON_LEFT_HAND);
rogue.left_ring = 0;
rogue.left_ring = NULL;
} else if (ring && (ring->in_use_flags & ON_RIGHT_HAND)) {
ring->in_use_flags &= (~ON_RIGHT_HAND);
rogue.right_ring = 0;
rogue.right_ring = NULL;
}
ring_stats(1);
}
void
gr_ring(ring, assign_wk)
object *ring;
boolean assign_wk;
gr_ring(object *ring, boolean assign_wk)
{
ring->what_is = RING;
if (assign_wk) {
@ -252,7 +248,7 @@ gr_ring(ring, assign_wk)
}
void
inv_rings()
inv_rings(void)
{
char buf[DCOLS];
@ -277,8 +273,7 @@ inv_rings()
}
void
ring_stats(pr)
boolean pr;
ring_stats(boolean pr)
{
short i;
object *ring;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rogue.h,v 1.18 2007/12/27 23:53:00 dholland Exp $ */
/* $NetBSD: rogue.h,v 1.19 2008/01/14 03:50:02 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -242,8 +242,8 @@ struct obj { /* comment is monster meaning */
typedef struct obj object;
#define INIT_AW (object*)0
#define INIT_RINGS (object*)0
#define INIT_AW NULL
#define INIT_RINGS NULL
#define INIT_HP 12
#define INIT_STR 16
#define INIT_EXPLEVEL 1
@ -293,9 +293,9 @@ typedef struct rm room;
#define MAXROOMS 9
#define BIG_ROOM 10
#define NO_ROOM -1
#define NO_ROOM (-1)
#define PASSAGE -3 /* cur_room value */
#define PASSAGE (-3) /* cur_room value */
#define AMULET_LEVEL 26
@ -349,7 +349,6 @@ extern struct id id_rings[];
extern struct id id_weapons[];
extern struct id id_armors[];
extern object mon_tab[];
extern object level_monsters;
#define MONSTERS 26
@ -448,19 +447,17 @@ object *check_duplicate(object *, object *);
const char *get_ench_color(void);
object *get_letter_object(int);
object *get_thrown_at_monster(object *, short, short *, short *);
object *get_zapped_monster(short, short *, short *);
object *gr_monster(object *, int);
object *gr_object(void);
char *md_getenv(const char *);
const char *
md_gln(void);
char *md_malloc(int);
void *md_malloc(size_t);
const char *mon_name(const object *);
const char *name_of(const object *);
object *object_at(object *, short, short);
object *pick_up(int, int, short *);
void add_exp(int, boolean);
void add_mazes(void);
void add_traps(void);
void aggravate(void);
void aim_monster(object *);
@ -469,7 +466,7 @@ void byebye(int);
void c_object_for_wizard(void);
void call_it(void);
boolean can_move(int, int, int, int);
boolean can_turn(int, int);
boolean can_turn(short, short);
void center(short, const char *);
void check_gold_seeker(object *);
boolean check_hunger(boolean);
@ -480,46 +477,32 @@ void clean_up(const char *) __attribute__((__noreturn__));
void clear_level(void);
void cnfs(void);
int coin_toss(void);
int connect_rooms(short, short);
void cough_up(object *);
void create_monster(void);
int damage_for_strength(void);
void darken_room(short);
void disappear(object *);
void do_args(int, char **);
void do_opts(void);
void do_put_on(object *, boolean);
void do_shell(void);
void do_wear(object *);
void do_wield(object *);
void dr_course(object *, boolean, short, short);
void drain_life(void);
void draw_magic_map(void);
void draw_simple_passage(short, short, short, short, short);
void drop(void);
int drop_check(void);
void drop_level(void);
void eat(void);
void edit_opts(void);
void env_get_value(char **, char *, boolean);
void error_save(int) __attribute__((__noreturn__));
void fight(int);
void fill_it(int, boolean);
void fill_out_level(void);
void fight(boolean);
boolean flame_broil(object *);
int flit(object *);
void flop_weapon(object *, short, short);
void free_object(object *);
void free_stuff(object *);
void freeze(object *);
int get_armor_class(const object *);
int get_com_id(int *, short);
int get_damage(const char *, boolean);
void get_desc(const object *, char *, size_t);
int get_dir(short, short, short, short);
void get_dir_rc(short, short *, short *, short);
char get_dungeon_char(short, short);
int get_exp_level(long);
void get_food(object *, boolean);
int get_hit_chance(const object *);
int get_input_line(const char *, const char *, char *, size_t, const char *, boolean, boolean);
@ -529,13 +512,11 @@ boolean get_oth_room(short, short *, short *);
int get_rand(int, int);
short get_room_number(int, int);
int get_value(const object *);
int get_w_damage(const object *);
void get_wand_and_ring_materials(void);
int get_weapon_damage(const object *);
char gmc(object *);
char gmc_row_col(int, int);
void go_blind(void);
boolean gold_at(int, int);
void gr_armor(object *);
char gr_dir(void);
char gr_obj_char(void);
@ -548,9 +529,7 @@ void gr_wand(object *);
void gr_weapon(object *, int);
void hallucinate(void);
boolean has_amulet(void);
boolean has_been_touched(const struct rogue_time *, const struct rogue_time *);
void heal(void);
void hide_boxed_passage(int, int, int, int, int);
void hold_monster(void);
int hp_raise(void);
void id_all(void);
@ -558,9 +537,8 @@ void id_com(void);
void id_trap(void);
void id_type(void);
void idntfy(void);
boolean imitating(int, int);
boolean imitating(short, short);
int init(int, char **);
void init_str(char **, const char *);
void insert_score(char [][82], char [][30], const char *, short, short, const object *, int);
void inv_armor_weapon(boolean);
void inv_rings(void);
@ -578,12 +556,9 @@ void light_passage(int, int);
void light_up_room(int);
boolean m_confuse(object *);
void make_level(void);
void make_maze(short, short, short, short, short, short);
void make_party(void);
void make_room(short, short, short, short);
void make_scroll_titles(void);
boolean mask_pack(const object *, unsigned short);
boolean mask_room(short, short *, short *, unsigned short);
boolean md_df(const char *);
void md_exit(int) __attribute__((__noreturn__));
void md_gct(struct rogue_time *);
@ -601,17 +576,16 @@ void md_slurp(void);
void messagef(boolean, const char *, ...)
__attribute__((__format__(__printf__, 2, 3)));
void mix_colors(void);
void mix_random_rooms(void);
int mon_can_go(const object *, int, int);
int mon_can_go(const object *, short, short);
int mon_damage(object *, short);
void mon_hit(object *);
boolean mon_sees(const object *, int, int);
int move_confused(object *);
void move_mon_to(object *, int, int);
void move_mon_to(object *, short, short);
void move_onto(void);
int mtry(object *, int, int);
int mtry(object *, short, short);
void multiple_move_rogue(short);
void mv_1_monster(object *, int, int);
void mv_1_monster(object *, short, short);
void mv_aquatars(void);
void mv_mons(void);
int name_cmp(char *, const char *);
@ -630,17 +604,15 @@ void pad(const char *, short);
void party_monsters(int, int);
short party_objects(int);
void place_at(object *, int, int);
void plant_gold(int, int, boolean);
void plant_gold(short, short, boolean);
void play_level(void);
void player_init(void);
void potion_heal(int);
int pr_com_id(int);
int pr_motion_char(int);
void print_stats(int);
void put_amulet(void);
void put_door(room *, short, short *, short *);
void put_gold(void);
void put_m_at(int, int, object *);
void put_m_at(short, short, object *);
void put_mons(void);
void put_objects(void);
void put_on_ring(void);
@ -650,15 +622,10 @@ void put_stairs(void);
void quaff(void);
void quit(boolean);
int r_index(const char *, int, boolean);
void r_read(FILE *, char *, int);
void r_write(FILE *, const char *, int);
void rand_around(short, short *, short *);
int rand_percent(int);
void rand_place(object *);
void read_pack(object *, FILE *, boolean);
void read_scroll(void);
void read_string(char *, FILE *, size_t);
void recursive_deadend(short, const short *, short, short);
boolean reg_move(void);
void relight(void);
void remessage(short);
@ -673,12 +640,7 @@ void rogue_hit(object *, boolean);
int rogue_is_around(int, int);
long rrandom(void);
void rust(object *);
void rw_dungeon(FILE *, boolean);
void rw_id(struct id *, FILE *, int, boolean);
void rw_rooms(FILE *, boolean);
void s_con_mon(object *);
int same_col(int, int);
int same_row(int, int);
void save_game(void);
void save_into_file(const char *);
void save_screen(void);
@ -695,21 +657,15 @@ void sound_bell(void);
void special_hit(object *);
void srrandom(int);
void start_window(void);
void steal_gold(object *);
void steal_item(object *);
void sting(object *);
void stop_window(void);
void take_a_nap(void);
void take_from_pack(object *, object *);
void take_off(void);
void tele(void);
void tele_away(object *);
void throw(void);
boolean throw_at_monster(object *, object *);
int to_hit(const object *);
short trap_at(int, int);
void trap_player(int, int);
boolean try_to_cough(short, short, object *);
void trap_player(short, short);
void turn_passage(short, boolean);
void un_put_on(object *);
void unblind(void);
@ -724,16 +680,12 @@ void wait_for_ack(void);
void wake_room(short, boolean, short, short);
void wake_up(object *);
void wanderer(void);
void wdrain_life(object *);
void wear(void);
void wield(void);
void win(void) __attribute__((__noreturn__));
void wizardize(void);
void write_pack(const object *, FILE *);
void write_string(char *, FILE *);
long xxx(boolean);
void xxxx(char *, short);
void zap_monster(object *, unsigned short);
void zapp(void);
object *add_to_pack(object *, object *, int);
struct id *get_id_table(const object *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: room.c,v 1.11 2008/01/14 00:23:52 dholland Exp $ */
/* $NetBSD: room.c,v 1.12 2008/01/14 03:50:02 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)room.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: room.c,v 1.11 2008/01/14 00:23:52 dholland Exp $");
__RCSID("$NetBSD: room.c,v 1.12 2008/01/14 03:50:02 dholland Exp $");
#endif
#endif /* not lint */
@ -56,11 +56,11 @@ __RCSID("$NetBSD: room.c,v 1.11 2008/01/14 00:23:52 dholland Exp $");
#include "rogue.h"
room rooms[MAXROOMS];
boolean rooms_visited[MAXROOMS];
static boolean rooms_visited[MAXROOMS];
#define NOPTS 7
const struct option {
static const struct option {
const char *prompt;
boolean is_bool;
char **strval;
@ -68,37 +68,36 @@ const struct option {
} 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, (boolean *)0
0, &nick_name, NULL
},
{
"Fruit (\"fruit\"): ",
0, &fruit, (boolean *)0
0, &fruit, NULL
},
{
"Save file (\"file\"): ",
0, &save_file, (boolean *)0
0, &save_file, NULL
}
};
void
light_up_room(rn)
int rn;
light_up_room(int rn)
{
short i, j;
@ -126,8 +125,7 @@ light_up_room(rn)
}
void
light_passage(row, col)
int row, col;
light_passage(int row, int col)
{
short i, j, i_end, j_end;
@ -147,8 +145,7 @@ light_passage(row, col)
}
void
darken_room(rn)
short rn;
darken_room(short rn)
{
short i, j;
@ -172,8 +169,7 @@ darken_room(rn)
}
char
get_dungeon_char(row, col)
short row, col;
get_dungeon_char(short row, short col)
{
unsigned short mask = dungeon[row][col];
@ -221,8 +217,7 @@ get_dungeon_char(row, col)
}
char
get_mask_char(mask)
unsigned short mask;
get_mask_char(unsigned short mask)
{
switch(mask) {
case SCROL:
@ -249,9 +244,7 @@ get_mask_char(mask)
}
void
gr_row_col(row, col, mask)
short *row, *col;
unsigned short mask;
gr_row_col(short *row, short *col, unsigned short mask)
{
short rn;
short r, c;
@ -271,7 +264,7 @@ gr_row_col(row, col, mask)
}
short
gr_room()
gr_room(void)
{
short i;
@ -283,8 +276,7 @@ gr_room()
}
short
party_objects(rn)
int rn;
party_objects(int rn)
{
short i, j, nf = 0;
object *obj;
@ -318,8 +310,7 @@ party_objects(rn)
}
short
get_room_number(row, col)
int row, col;
get_room_number(int row, int col)
{
short i;
@ -333,7 +324,7 @@ get_room_number(row, col)
}
boolean
is_all_connected()
is_all_connected(void)
{
short i, starting_room;
@ -356,8 +347,7 @@ is_all_connected()
}
void
visit_rooms(rn)
int rn;
visit_rooms(int rn)
{
short i;
short oth_rn;
@ -373,7 +363,7 @@ visit_rooms(rn)
}
void
draw_magic_map()
draw_magic_map(void)
{
short i, j, ch, och;
unsigned short mask = (HORWALL | VERTWALL | DOOR | TUNNEL | TRAP | STAIRS |
@ -423,10 +413,7 @@ draw_magic_map()
}
void
dr_course(monster, entering, row, col)
object *monster;
boolean entering;
short row, col;
dr_course(object *monster, boolean entering, short row, short col)
{
short i, j, k, rn;
short r, rr;
@ -500,8 +487,7 @@ dr_course(monster, entering, row, col)
}
boolean
get_oth_room(rn, row, col)
short rn, *row, *col;
get_oth_room(short rn, short *row, short *col)
{
short d = -1;
@ -523,7 +509,7 @@ get_oth_room(rn, row, col)
}
void
edit_opts()
edit_opts(void)
{
char save[NOPTS+1][DCOLS];
short i, j;
@ -627,8 +613,7 @@ CH:
}
void
opt_show(i)
int i;
opt_show(int i)
{
const char *s;
const struct option *opt = &options[i];
@ -644,8 +629,7 @@ opt_show(i)
}
void
opt_erase(i)
int i;
opt_erase(int i)
{
const struct option *opt = &options[i];
@ -654,14 +638,13 @@ opt_erase(i)
}
void
opt_go(i)
int i;
opt_go(int i)
{
move(i, strlen(options[i].prompt));
}
void
do_shell()
do_shell(void)
{
#ifdef UNIX
const char *sh;

View File

@ -1,4 +1,4 @@
/* $NetBSD: save.c,v 1.12 2008/01/14 00:23:52 dholland Exp $ */
/* $NetBSD: save.c,v 1.13 2008/01/14 03:50:02 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: save.c,v 1.12 2008/01/14 00:23:52 dholland Exp $");
__RCSID("$NetBSD: save.c,v 1.13 2008/01/14 03:50:02 dholland Exp $");
#endif
#endif /* not lint */
@ -56,11 +56,24 @@ __RCSID("$NetBSD: save.c,v 1.12 2008/01/14 00:23:52 dholland Exp $");
#include <stdio.h>
#include "rogue.h"
short write_failed = 0;
char *save_file = (char *)0;
static boolean has_been_touched(const struct rogue_time *,
const struct rogue_time *);
static void r_read(FILE *, void *, size_t);
static void r_write(FILE *, const void *, size_t);
static void read_pack(object *, FILE *, boolean);
static void read_string(char *, FILE *, size_t);
static void rw_dungeon(FILE *, boolean);
static void rw_id(struct id *, FILE *, int, boolean);
static void rw_rooms(FILE *, boolean);
static void write_pack(const object *, FILE *);
static void write_string(char *, FILE *);
static short write_failed = 0;
char *save_file = NULL;
void
save_game()
save_game(void)
{
char fname[64];
@ -74,8 +87,7 @@ save_game()
}
void
save_into_file(sfile)
const char *sfile;
save_into_file(const char *sfile)
{
FILE *fp;
int file_id;
@ -113,42 +125,42 @@ save_into_file(sfile)
md_ignore_signals();
write_failed = 0;
(void)xxx(1);
r_write(fp, (char *) &detect_monster, sizeof(detect_monster));
r_write(fp, (char *) &cur_level, sizeof(cur_level));
r_write(fp, (char *) &max_level, sizeof(max_level));
r_write(fp, &detect_monster, sizeof(detect_monster));
r_write(fp, &cur_level, sizeof(cur_level));
r_write(fp, &max_level, sizeof(max_level));
write_string(hunger_str, fp);
write_string(login_name, fp);
r_write(fp, (char *) &party_room, sizeof(party_room));
r_write(fp, &party_room, sizeof(party_room));
write_pack(&level_monsters, fp);
write_pack(&level_objects, fp);
r_write(fp, (char *) &file_id, sizeof(file_id));
r_write(fp, &file_id, sizeof(file_id));
rw_dungeon(fp, 1);
r_write(fp, (char *) &foods, sizeof(foods));
r_write(fp, (char *) &rogue, sizeof(fighter));
r_write(fp, &foods, sizeof(foods));
r_write(fp, &rogue, sizeof(fighter));
write_pack(&rogue.pack, fp);
rw_id(id_potions, fp, POTIONS, 1);
rw_id(id_scrolls, fp, SCROLS, 1);
rw_id(id_wands, fp, WANDS, 1);
rw_id(id_rings, fp, RINGS, 1);
r_write(fp, (char *) traps, (MAX_TRAPS * sizeof(trap)));
r_write(fp, (char *) is_wood, (WANDS * sizeof(boolean)));
r_write(fp, (char *) &cur_room, sizeof(cur_room));
r_write(fp, traps, (MAX_TRAPS * sizeof(trap)));
r_write(fp, is_wood, (WANDS * sizeof(boolean)));
r_write(fp, &cur_room, sizeof(cur_room));
rw_rooms(fp, 1);
r_write(fp, (char *) &being_held, sizeof(being_held));
r_write(fp, (char *) &bear_trap, sizeof(bear_trap));
r_write(fp, (char *) &halluc, sizeof(halluc));
r_write(fp, (char *) &blind, sizeof(blind));
r_write(fp, (char *) &confused, sizeof(confused));
r_write(fp, (char *) &levitate, sizeof(levitate));
r_write(fp, (char *) &haste_self, sizeof(haste_self));
r_write(fp, (char *) &see_invisible, sizeof(see_invisible));
r_write(fp, (char *) &detect_monster, sizeof(detect_monster));
r_write(fp, (char *) &wizard, sizeof(wizard));
r_write(fp, (char *) &score_only, sizeof(score_only));
r_write(fp, (char *) &m_moves, sizeof(m_moves));
r_write(fp, &being_held, sizeof(being_held));
r_write(fp, &bear_trap, sizeof(bear_trap));
r_write(fp, &halluc, sizeof(halluc));
r_write(fp, &blind, sizeof(blind));
r_write(fp, &confused, sizeof(confused));
r_write(fp, &levitate, sizeof(levitate));
r_write(fp, &haste_self, sizeof(haste_self));
r_write(fp, &see_invisible, sizeof(see_invisible));
r_write(fp, &detect_monster, sizeof(detect_monster));
r_write(fp, &wizard, sizeof(wizard));
r_write(fp, &score_only, sizeof(score_only));
r_write(fp, &m_moves, sizeof(m_moves));
md_gct(&rt_buf);
rt_buf.second += 10; /* allow for some processing time */
r_write(fp, (char *) &rt_buf, sizeof(rt_buf));
r_write(fp, &rt_buf, sizeof(rt_buf));
fclose(fp);
if (write_failed) {
@ -159,8 +171,7 @@ save_into_file(sfile)
}
void
restore(fname)
const char *fname;
restore(const char *fname)
{
FILE *fp;
struct rogue_time saved_time, mod_time;
@ -177,9 +188,9 @@ restore(fname)
clean_up("file has link");
}
(void)xxx(1);
r_read(fp, (char *) &detect_monster, sizeof(detect_monster));
r_read(fp, (char *) &cur_level, sizeof(cur_level));
r_read(fp, (char *) &max_level, sizeof(max_level));
r_read(fp, &detect_monster, sizeof(detect_monster));
r_read(fp, &cur_level, sizeof(cur_level));
r_read(fp, &max_level, sizeof(max_level));
read_string(hunger_str, fp, sizeof hunger_str);
(void)strlcpy(tbuf, login_name, sizeof tbuf);
@ -188,40 +199,40 @@ restore(fname)
clean_up("you're not the original player");
}
r_read(fp, (char *) &party_room, sizeof(party_room));
r_read(fp, &party_room, sizeof(party_room));
read_pack(&level_monsters, fp, 0);
read_pack(&level_objects, fp, 0);
r_read(fp, (char *) &saved_file_id, sizeof(saved_file_id));
r_read(fp, &saved_file_id, sizeof(saved_file_id));
if (new_file_id != saved_file_id) {
clean_up("sorry, saved game is not in the same file");
}
rw_dungeon(fp, 0);
r_read(fp, (char *) &foods, sizeof(foods));
r_read(fp, (char *) &rogue, sizeof(fighter));
r_read(fp, &foods, sizeof(foods));
r_read(fp, &rogue, sizeof(fighter));
read_pack(&rogue.pack, fp, 1);
rw_id(id_potions, fp, POTIONS, 0);
rw_id(id_scrolls, fp, SCROLS, 0);
rw_id(id_wands, fp, WANDS, 0);
rw_id(id_rings, fp, RINGS, 0);
r_read(fp, (char *) traps, (MAX_TRAPS * sizeof(trap)));
r_read(fp, (char *) is_wood, (WANDS * sizeof(boolean)));
r_read(fp, (char *) &cur_room, sizeof(cur_room));
r_read(fp, traps, (MAX_TRAPS * sizeof(trap)));
r_read(fp, is_wood, (WANDS * sizeof(boolean)));
r_read(fp, &cur_room, sizeof(cur_room));
rw_rooms(fp, 0);
r_read(fp, (char *) &being_held, sizeof(being_held));
r_read(fp, (char *) &bear_trap, sizeof(bear_trap));
r_read(fp, (char *) &halluc, sizeof(halluc));
r_read(fp, (char *) &blind, sizeof(blind));
r_read(fp, (char *) &confused, sizeof(confused));
r_read(fp, (char *) &levitate, sizeof(levitate));
r_read(fp, (char *) &haste_self, sizeof(haste_self));
r_read(fp, (char *) &see_invisible, sizeof(see_invisible));
r_read(fp, (char *) &detect_monster, sizeof(detect_monster));
r_read(fp, (char *) &wizard, sizeof(wizard));
r_read(fp, (char *) &score_only, sizeof(score_only));
r_read(fp, (char *) &m_moves, sizeof(m_moves));
r_read(fp, (char *) &saved_time, sizeof(saved_time));
r_read(fp, &being_held, sizeof(being_held));
r_read(fp, &bear_trap, sizeof(bear_trap));
r_read(fp, &halluc, sizeof(halluc));
r_read(fp, &blind, sizeof(blind));
r_read(fp, &confused, sizeof(confused));
r_read(fp, &levitate, sizeof(levitate));
r_read(fp, &haste_self, sizeof(haste_self));
r_read(fp, &see_invisible, sizeof(see_invisible));
r_read(fp, &detect_monster, sizeof(detect_monster));
r_read(fp, &wizard, sizeof(wizard));
r_read(fp, &score_only, sizeof(score_only));
r_read(fp, &m_moves, sizeof(m_moves));
r_read(fp, &saved_time, sizeof(saved_time));
if (fread(buf, sizeof(char), 1, fp) > 0) {
if (fread(buf, 1, 1, fp) > 0) {
clear();
clean_up("extra characters in file");
}
@ -240,32 +251,27 @@ restore(fname)
fclose(fp);
}
void
write_pack(pack, fp)
const object *pack;
FILE *fp;
static void
write_pack(const object *pack, FILE *fp)
{
object t;
while ((pack = pack->next_object) != NULL) {
r_write(fp, (const char *) pack, sizeof(object));
r_write(fp, pack, sizeof(object));
}
t.ichar = t.what_is = 0;
r_write(fp, (const char *) &t, sizeof(object));
r_write(fp, &t, sizeof(object));
}
void
read_pack(pack, fp, is_rogue)
object *pack;
FILE *fp;
boolean is_rogue;
static void
read_pack(object *pack, FILE *fp, boolean is_rogue)
{
object read_obj, *new_obj;
for (;;) {
r_read(fp, (char *) &read_obj, sizeof(object));
r_read(fp, &read_obj, sizeof(object));
if (read_obj.ichar == 0) {
pack->next_object = (object *)0;
pack->next_object = NULL;
break;
}
new_obj = alloc_object();
@ -285,23 +291,21 @@ read_pack(pack, fp, is_rogue)
}
}
void
rw_dungeon(fp, rw)
FILE *fp;
boolean rw;
static void
rw_dungeon(FILE *fp, boolean rw)
{
short i, j;
char buf[DCOLS];
for (i = 0; i < DROWS; i++) {
if (rw) {
r_write(fp, (char *) dungeon[i], (DCOLS * sizeof(dungeon[0][0])));
r_write(fp, dungeon[i], (DCOLS * sizeof(dungeon[0][0])));
for (j = 0; j < DCOLS; j++) {
buf[j] = mvinch(i, j);
}
r_write(fp, buf, DCOLS);
} else {
r_read(fp, (char *) dungeon[i], (DCOLS * sizeof(dungeon[0][0])));
r_read(fp, dungeon[i], (DCOLS * sizeof(dungeon[0][0])));
r_read(fp, buf, DCOLS);
for (j = 0; j < DCOLS; j++) {
mvaddch(i, j, buf[j]);
@ -310,52 +314,43 @@ rw_dungeon(fp, rw)
}
}
void
rw_id(id_table, fp, n, wr)
struct id id_table[];
FILE *fp;
int n;
boolean wr;
static void
rw_id(struct id id_table[], FILE *fp, int n, boolean wr)
{
short i;
int i;
for (i = 0; i < n; i++) {
if (wr) {
r_write(fp, (const char *) &(id_table[i].value), sizeof(short));
r_write(fp, (const char *) &(id_table[i].id_status),
r_write(fp, &id_table[i].value, sizeof(short));
r_write(fp, &id_table[i].id_status,
sizeof(unsigned short));
write_string(id_table[i].title, fp);
} else {
r_read(fp, (char *) &(id_table[i].value), sizeof(short));
r_read(fp, (char *) &(id_table[i].id_status),
r_read(fp, &id_table[i].value, sizeof(short));
r_read(fp, &id_table[i].id_status,
sizeof(unsigned short));
read_string(id_table[i].title, fp, MAX_ID_TITLE_LEN);
}
}
}
void
write_string(s, fp)
char *s;
FILE *fp;
static void
write_string(char *s, FILE *fp)
{
short n;
n = strlen(s) + 1;
xxxx(s, n);
r_write(fp, (char *) &n, sizeof(short));
r_write(fp, &n, sizeof(short));
r_write(fp, s, n);
}
void
read_string(s, fp, len)
char *s;
FILE *fp;
size_t len;
static void
read_string(char *s, FILE *fp, size_t len)
{
short n;
r_read(fp, (char *) &n, sizeof(short));
r_read(fp, &n, sizeof(short));
if (n<=0 || (size_t)(unsigned short)n > len) {
clean_up("read_string: corrupt game file");
}
@ -365,38 +360,30 @@ read_string(s, fp, len)
s[n-1] = 0;
}
void
rw_rooms(fp, rw)
FILE *fp;
boolean rw;
static void
rw_rooms(FILE *fp, boolean rw)
{
short i;
for (i = 0; i < MAXROOMS; i++) {
rw ? r_write(fp, (char *) (rooms + i), sizeof(room)) :
r_read(fp, (char *) (rooms + i), sizeof(room));
rw ? r_write(fp, (rooms + i), sizeof(room)) :
r_read(fp, (rooms + i), sizeof(room));
}
}
void
r_read(fp, buf, n)
FILE *fp;
char *buf;
int n;
static void
r_read(FILE *fp, void *buf, size_t n)
{
if (fread(buf, sizeof(char), n, fp) != (size_t)n) {
clean_up("read() failed, don't know why");
if (fread(buf, 1, n, fp) != n) {
clean_up("fread() failed, don't know why");
}
}
void
r_write(fp, buf, n)
FILE *fp;
const char *buf;
int n;
static void
r_write(FILE *fp, const void *buf, size_t n)
{
if (!write_failed) {
if (fwrite(buf, sizeof(char), n, fp) != (size_t)n) {
if (fwrite(buf, 1, n, fp) != n) {
messagef(0, "write() failed, don't know why");
sound_bell();
write_failed = 1;
@ -404,9 +391,9 @@ r_write(fp, buf, n)
}
}
boolean
has_been_touched(saved_time, mod_time)
const struct rogue_time *saved_time, *mod_time;
static boolean
has_been_touched(const struct rogue_time *saved_time,
const struct rogue_time *mod_time)
{
if (saved_time->year < mod_time->year) {
return(1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: score.c,v 1.13 2008/01/14 00:23:53 dholland Exp $ */
/* $NetBSD: score.c,v 1.14 2008/01/14 03:50:02 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: score.c,v 1.13 2008/01/14 00:23:53 dholland Exp $");
__RCSID("$NetBSD: score.c,v 1.14 2008/01/14 03:50:02 dholland Exp $");
#endif
#endif /* not lint */
@ -58,9 +58,7 @@ __RCSID("$NetBSD: score.c,v 1.13 2008/01/14 00:23:53 dholland Exp $");
#include "pathnames.h"
void
killed_by(monster, other)
const object *monster;
short other;
killed_by(const object *monster, short other)
{
const char *mechanism = "killed by something unknown (?)";
char mechanism_buf[128];
@ -133,7 +131,7 @@ killed_by(monster, other)
}
void
win()
win(void)
{
unwield(rogue.weapon); /* disarm and relax */
unwear(rogue.armor);
@ -153,12 +151,11 @@ win()
messagef(0, "%s", ""); /* gcc objects to just "" */
id_all();
sell_pack();
put_scores((object *)0, WIN);
put_scores(NULL, WIN);
}
void
quit(from_intrpt)
boolean from_intrpt;
quit(boolean from_intrpt)
{
char buf[DCOLS];
short i, orow, ocol;
@ -197,7 +194,7 @@ quit(from_intrpt)
clean_up(byebye_string);
}
check_message();
killed_by((object *)0, QUIT);
killed_by(NULL, QUIT);
}
/*
@ -225,18 +222,11 @@ struct score_entry {
#define NUM_SCORE_ENTRIES 10
static void pad_spaces __P((char *, size_t));
static void unpad_spaces(char *);
static int read_score_entry __P((struct score_entry *, FILE *));
static void write_score_entry __P((const struct score_entry *, int, FILE *));
static void make_score __P((struct score_entry *, const object *, int));
static void make_score(struct score_entry *, const object *, int);
static
void
pad_spaces(str, len)
char *str;
size_t len;
pad_spaces(char *str, size_t len)
{
size_t x;
for (x=strlen(str); x<len-1; x++) {
@ -247,8 +237,7 @@ pad_spaces(str, len)
static
void
unpad_spaces(str)
char *str;
unpad_spaces(char *str)
{
size_t x;
for (x=strlen(str); x>0 && str[x-1]==' '; x--);
@ -257,9 +246,7 @@ unpad_spaces(str)
static
int
read_score_entry(se, fp)
struct score_entry *se;
FILE *fp;
read_score_entry(struct score_entry *se, FILE *fp)
{
char score_block[80];
char nickname_block[30];
@ -314,10 +301,7 @@ read_score_entry(se, fp)
static
void
write_score_entry(se, rank, fp)
const struct score_entry *se;
int rank;
FILE *fp;
write_score_entry(const struct score_entry *se, int rank, FILE *fp)
{
char score_block[80];
char nickname_block[30];
@ -343,9 +327,7 @@ write_score_entry(se, rank, fp)
}
void
put_scores(monster, other)
const object *monster;
short other;
put_scores(const object *monster, short other)
{
short i, rank=-1, found_player = -1, numscores = 0;
struct score_entry scores[NUM_SCORE_ENTRIES];
@ -467,10 +449,7 @@ put_scores(monster, other)
static
void
make_score(se, monster, other)
struct score_entry *se;
const object *monster;
int other;
make_score(struct score_entry *se, const object *monster, int other)
{
const char *death = "bolts from the blue (?)";
const char *hasamulet;
@ -528,8 +507,7 @@ make_score(se, monster, other)
}
boolean
is_vowel(ch)
short ch;
is_vowel(short ch)
{
return( (ch == 'a') ||
(ch == 'e') ||
@ -539,7 +517,7 @@ is_vowel(ch)
}
void
sell_pack()
sell_pack(void)
{
object *obj;
short row = 2, val;
@ -571,8 +549,7 @@ sell_pack()
}
int
get_value(obj)
const object *obj;
get_value(const object *obj)
{
short wc;
int val;
@ -620,7 +597,7 @@ get_value(obj)
}
void
id_all()
id_all(void)
{
short i;
@ -642,9 +619,7 @@ id_all()
}
void
xxxx(buf, n)
char *buf;
short n;
xxxx(char *buf, short n)
{
short i;
unsigned char c;
@ -659,8 +634,7 @@ xxxx(buf, n)
}
long
xxx(st)
boolean st;
xxx(boolean st)
{
static long f, s;
long r;
@ -677,9 +651,7 @@ xxx(st)
}
void
center(row, buf)
short row;
const char *buf;
center(short row, const char *buf)
{
short margin;
@ -688,7 +660,7 @@ center(row, buf)
}
void
sf_error()
sf_error(void)
{
md_lock(0);
messagef(1, "%s", ""); /* gcc objects to just "" */

View File

@ -1,4 +1,4 @@
/* $NetBSD: spec_hit.c,v 1.7 2008/01/14 00:23:53 dholland Exp $ */
/* $NetBSD: spec_hit.c,v 1.8 2008/01/14 03:50:02 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)spec_hit.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: spec_hit.c,v 1.7 2008/01/14 00:23:53 dholland Exp $");
__RCSID("$NetBSD: spec_hit.c,v 1.8 2008/01/14 03:50:02 dholland Exp $");
#endif
#endif /* not lint */
@ -55,12 +55,22 @@ __RCSID("$NetBSD: spec_hit.c,v 1.7 2008/01/14 00:23:53 dholland Exp $");
#include "rogue.h"
static void disappear(object *);
static void drain_life(void);
static void drop_level(void);
static void freeze(object *);
static int get_dir(short, short, short, short);
static boolean gold_at(short, short);
static void steal_gold(object *);
static void steal_item(object *);
static void sting(object *);
static boolean try_to_cough(short, short, object *);
short less_hp = 0;
boolean being_held;
void
special_hit(monster)
object *monster;
special_hit(object *monster)
{
if ((monster->m_flags & CONFUSED) && rand_percent(66)) {
return;
@ -91,8 +101,7 @@ special_hit(monster)
}
void
rust(monster)
object *monster;
rust(object *monster)
{
if ((!rogue.armor) || (get_armor_class(rogue.armor) <= 1) ||
(rogue.armor->which_kind == LEATHER)) {
@ -111,8 +120,7 @@ rust(monster)
}
void
freeze(monster)
object *monster;
freeze(object *monster)
{
short freeze_percent = 99;
short i, n;
@ -137,7 +145,7 @@ freeze(monster)
for (i = 0; i < 50; i++) {
mv_mons();
}
killed_by((object *)0, HYPOTHERMIA);
killed_by(NULL, HYPOTHERMIA);
}
messagef(1, you_can_move_again);
monster->m_flags &= (~FREEZING_ROGUE);
@ -145,8 +153,7 @@ freeze(monster)
}
void
steal_gold(monster)
object *monster;
steal_gold(object *monster)
{
int amount;
@ -166,8 +173,7 @@ steal_gold(monster)
}
void
steal_item(monster)
object *monster;
steal_item(object *monster)
{
object *obj;
short i, n, t = 0;
@ -219,9 +225,8 @@ DSPR:
disappear(monster);
}
void
disappear(monster)
object *monster;
static void
disappear(object *monster)
{
short row, col;
@ -238,8 +243,7 @@ disappear(monster)
}
void
cough_up(monster)
object *monster;
cough_up(object *monster)
{
object *obj;
short row, col, i, n;
@ -282,10 +286,8 @@ cough_up(monster)
free_object(obj);
}
boolean
try_to_cough(row, col, obj)
short row, col;
object *obj;
static boolean
try_to_cough(short row, short col, object *obj)
{
if ((row < MIN_ROW) ||
(row > (DROWS-2)) || (col < 0) || (col>(DCOLS-1))) {
@ -304,8 +306,7 @@ try_to_cough(row, col, obj)
}
boolean
seek_gold(monster)
object *monster;
seek_gold(object *monster)
{
short i, j, rn, s;
@ -336,9 +337,8 @@ seek_gold(monster)
return(0);
}
boolean
gold_at(row, col)
short row, col;
static boolean
gold_at(short row, short col)
{
if (dungeon[row][col] & OBJECT) {
object *obj;
@ -352,15 +352,13 @@ gold_at(row, col)
}
void
check_gold_seeker(monster)
object *monster;
check_gold_seeker(object *monster)
{
monster->m_flags &= (~SEEKS_GOLD);
}
boolean
check_imitator(monster)
object *monster;
check_imitator(object *monster)
{
if (monster->m_flags & IMITATES) {
wake_up(monster);
@ -376,8 +374,7 @@ check_imitator(monster)
}
boolean
imitating(row, col)
short row, col;
imitating(short row, short col)
{
if (dungeon[row][col] & MONSTER) {
object *monster;
@ -391,9 +388,8 @@ imitating(row, col)
return(0);
}
void
sting(monster)
object *monster;
static void
sting(object *monster)
{
short sting_chance = 35;
@ -413,8 +409,8 @@ sting(monster)
}
}
void
drop_level()
static void
drop_level(void)
{
int hp;
@ -434,7 +430,7 @@ drop_level()
}
void
drain_life()
drain_life(void)
{
short n;
@ -463,8 +459,7 @@ drain_life()
}
boolean
m_confuse(monster)
object *monster;
m_confuse(object *monster)
{
if (!rogue_can_see(monster->row, monster->col)) {
return(0);
@ -484,8 +479,7 @@ m_confuse(monster)
}
boolean
flame_broil(monster)
object *monster;
flame_broil(object *monster)
{
short row, col, dir;
@ -510,9 +504,8 @@ flame_broil(monster)
return(1);
}
int
get_dir(srow, scol, drow, dcol)
short srow, scol, drow, dcol;
static int
get_dir(short srow, short scol, short drow, short dcol)
{
if (srow == drow) {
if (scol < dcol) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: throw.c,v 1.9 2008/01/14 00:23:53 dholland Exp $ */
/* $NetBSD: throw.c,v 1.10 2008/01/14 03:50:03 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)throw.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: throw.c,v 1.9 2008/01/14 00:23:53 dholland Exp $");
__RCSID("$NetBSD: throw.c,v 1.10 2008/01/14 03:50:03 dholland Exp $");
#endif
#endif /* not lint */
@ -56,7 +56,7 @@ __RCSID("$NetBSD: throw.c,v 1.9 2008/01/14 00:23:53 dholland Exp $");
#include "rogue.h"
void
throw()
throw(void)
{
short wch, d;
boolean first_miss = 1;
@ -120,8 +120,7 @@ throw()
}
boolean
throw_at_monster(monster, weapon)
object *monster, *weapon;
throw_at_monster(object *monster, object *weapon)
{
short damage, hit_chance;
short t;
@ -156,10 +155,7 @@ throw_at_monster(monster, weapon)
}
object *
get_thrown_at_monster(obj, dir, row, col)
object *obj;
short dir;
short *row, *col;
get_thrown_at_monster(object *obj, short dir, short *row, short *col)
{
short orow, ocol;
short i, ch;
@ -201,9 +197,7 @@ get_thrown_at_monster(obj, dir, row, col)
}
void
flop_weapon(weapon, row, col)
object *weapon;
short row, col;
flop_weapon(object *weapon, short row, short col)
{
object *new_weapon, *monster;
short i = 0;
@ -263,8 +257,7 @@ flop_weapon(weapon, row, col)
}
void
rand_around(i, r, c)
short i, *r, *c;
rand_around(short i, short *r, short *c)
{
static char pos[] = "\010\007\001\003\004\005\002\006\0";
static short row, col;

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.8 2008/01/14 00:23:53 dholland Exp $ */
/* $NetBSD: trap.c,v 1.9 2008/01/14 03:50:03 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)trap.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: trap.c,v 1.8 2008/01/14 00:23:53 dholland Exp $");
__RCSID("$NetBSD: trap.c,v 1.9 2008/01/14 03:50:03 dholland Exp $");
#endif
#endif /* not lint */
@ -59,7 +59,7 @@ trap traps[MAX_TRAPS];
boolean trap_door = 0;
short bear_trap = 0;
const char *const trap_strings[TRAPS * 2] = {
static const char *const trap_strings[TRAPS * 2] = {
"trap door",
"you fell down a trap",
"bear trap",
@ -75,8 +75,7 @@ const char *const trap_strings[TRAPS * 2] = {
};
short
trap_at(row, col)
int row, col;
trap_at(int row, int col)
{
short i;
@ -89,8 +88,7 @@ trap_at(row, col)
}
void
trap_player(row, col)
short row, col;
trap_player(short row, short col)
{
short t;
@ -136,13 +134,13 @@ trap_player(row, col)
break;
case RUST_TRAP:
messagef(1, "%s", trap_strings[(t*2)+1]);
rust((object *)0);
rust(NULL);
break;
}
}
void
add_traps()
add_traps(void)
{
short i, n, tries = 0;
short row, col;
@ -187,7 +185,7 @@ add_traps()
}
void
id_trap()
id_trap(void)
{
short dir, row, col, d, t;
@ -215,7 +213,7 @@ id_trap()
}
void
show_traps()
show_traps(void)
{
short i, j;
@ -229,9 +227,7 @@ show_traps()
}
void
search(n, is_auto)
short n;
boolean is_auto;
search(short n, boolean is_auto)
{
short s, i, j, row, col, t;
short shown = 0, found = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: use.c,v 1.8 2008/01/14 00:23:53 dholland Exp $ */
/* $NetBSD: use.c,v 1.9 2008/01/14 03:50:03 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)use.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: use.c,v 1.8 2008/01/14 00:23:53 dholland Exp $");
__RCSID("$NetBSD: use.c,v 1.9 2008/01/14 03:50:03 dholland Exp $");
#endif
#endif /* not lint */
@ -64,10 +64,12 @@ boolean see_invisible = 0;
short extra_hp = 0;
boolean detect_monster = 0;
boolean con_mon = 0;
const char *strange_feeling = "you have a strange feeling for a moment, then it passes";
static const char strange_feeling[] =
"you have a strange feeling for a moment, then it passes";
void
quaff()
quaff(void)
{
short ch;
object *obj;
@ -179,7 +181,7 @@ quaff()
}
void
read_scroll()
read_scroll(void)
{
short ch;
object *obj;
@ -288,10 +290,7 @@ read_scroll()
*/
void
vanish(obj, rm, pack)
object *obj;
short rm;
object *pack;
vanish(object *obj, short rm, object *pack)
{
if (obj->quantity > 1) {
obj->quantity--;
@ -312,8 +311,7 @@ vanish(obj, rm, pack)
}
void
potion_heal(extra)
int extra;
potion_heal(int extra)
{
float ratio;
short add;
@ -337,7 +335,7 @@ potion_heal(extra)
if (extra) {
ratio += ratio;
}
add = (short)(ratio * ((float)rogue.hp_max - rogue.hp_current));
add = (short)(ratio * (rogue.hp_max - rogue.hp_current));
rogue.hp_current += add;
if (rogue.hp_current > rogue.hp_max) {
rogue.hp_current = rogue.hp_max;
@ -347,7 +345,7 @@ potion_heal(extra)
unblind();
}
if (confused && extra) {
unconfuse();
unconfuse();
} else if (confused) {
confused = (confused / 2) + 1;
}
@ -359,7 +357,7 @@ potion_heal(extra)
}
void
idntfy()
idntfy(void)
{
short ch;
object *obj;
@ -387,7 +385,7 @@ AGAIN:
}
void
eat()
eat(void)
{
short ch;
short moves;
@ -427,7 +425,7 @@ eat()
}
void
hold_monster()
hold_monster(void)
{
short i, j;
short mcount = 0;
@ -460,7 +458,7 @@ hold_monster()
}
void
tele()
tele(void)
{
mvaddch(rogue.row, rogue.col, get_dungeon_char(rogue.row, rogue.col));
@ -473,7 +471,7 @@ tele()
}
void
hallucinate()
hallucinate(void)
{
object *obj, *monster;
short ch;
@ -503,7 +501,7 @@ hallucinate()
}
void
unhallucinate()
unhallucinate(void)
{
halluc = 0;
relight();
@ -511,7 +509,7 @@ unhallucinate()
}
void
unblind()
unblind(void)
{
blind = 0;
messagef(1, "the veil of darkness lifts");
@ -525,7 +523,7 @@ unblind()
}
void
relight()
relight(void)
{
if (cur_room == PASSAGE) {
light_passage(rogue.row, rogue.col);
@ -536,7 +534,7 @@ relight()
}
void
take_a_nap()
take_a_nap(void)
{
short i;
@ -551,7 +549,7 @@ take_a_nap()
}
void
go_blind()
go_blind(void)
{
short i, j;
@ -583,7 +581,7 @@ go_blind()
}
const char *
get_ench_color()
get_ench_color(void)
{
if (halluc) {
return(id_potions[get_rand(0, POTIONS-1)].title);
@ -594,20 +592,20 @@ get_ench_color()
}
void
cnfs()
cnfs(void)
{
confused += get_rand(12, 22);
}
void
unconfuse()
unconfuse(void)
{
confused = 0;
messagef(1, "you feel less %s now", (halluc ? "trippy" : "confused"));
}
void
uncurse_all()
uncurse_all(void)
{
object *obj;

View File

@ -1,4 +1,4 @@
/* $NetBSD: zap.c,v 1.8 2008/01/14 00:23:53 dholland Exp $ */
/* $NetBSD: zap.c,v 1.9 2008/01/14 03:50:03 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)zap.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: zap.c,v 1.8 2008/01/14 00:23:53 dholland Exp $");
__RCSID("$NetBSD: zap.c,v 1.9 2008/01/14 03:50:03 dholland Exp $");
#endif
#endif /* not lint */
@ -55,10 +55,15 @@ __RCSID("$NetBSD: zap.c,v 1.8 2008/01/14 00:23:53 dholland Exp $");
#include "rogue.h"
static object *get_zapped_monster(short, short *, short *);
static void tele_away(object *);
static void wdrain_life(object *);
static void zap_monster(object *, unsigned short);
boolean wizard = 0;
void
zapp()
zapp(void)
{
short wch;
boolean first_miss = 1;
@ -112,10 +117,8 @@ zapp()
(void)reg_move();
}
object *
get_zapped_monster(dir, row, col)
short dir;
short *row, *col;
static object *
get_zapped_monster(short dir, short *row, short *col)
{
short orow, ocol;
@ -135,10 +138,8 @@ get_zapped_monster(dir, row, col)
}
}
void
zap_monster(monster, kind)
object *monster;
unsigned short kind;
static void
zap_monster(object *monster, unsigned short kind)
{
short row, col;
object *nm;
@ -203,9 +204,8 @@ zap_monster(monster, kind)
}
}
void
tele_away(monster)
object *monster;
static void
tele_away(object *monster)
{
short row, col;
@ -224,7 +224,7 @@ tele_away(monster)
}
void
wizardize()
wizardize(void)
{
char buf[100];
@ -247,9 +247,8 @@ wizardize()
}
}
void
wdrain_life(monster)
object *monster;
static void
wdrain_life(object *monster)
{
short hp;
object *lmon, *nm;
@ -278,8 +277,7 @@ wdrain_life(monster)
}
void
bounce(ball, dir, row, col, r)
short ball, dir, row, col, r;
bounce(short ball, short dir, short row, short col, short r)
{
short orow, ocol;
const char *s;
@ -383,7 +381,7 @@ bounce(ball, dir, row, col, r)
damage = (damage * 3) / 2;
damage -= get_armor_class(rogue.armor);
}
rogue_damage(damage, (object *)0,
rogue_damage(damage, NULL,
((ball == FIRE) ? KFIRE : HYPOTHERMIA));
messagef(0, "the %s hits", s);
}