From b28e2a8f12d638796f55866071d783deb3ee647a Mon Sep 17 00:00:00 2001 From: Peter Avalos Date: Sat, 2 Sep 2006 19:31:07 +0000 Subject: [PATCH 1/1] -WARNS6 cleanups (3953 warnings) -ANSI function declarations -staticize functions -use boolean from stdbool.h -remove unneeded termcap library -remove void casts for unchecked return values -rename local variable names that shadow globals -remove previously commented out code --- games/rogue/Makefile | 5 +- games/rogue/hit.c | 83 ++++++------ games/rogue/init.c | 70 +++++----- games/rogue/inventory.c | 236 +++++++++++++++++---------------- games/rogue/level.c | 122 ++++++++++------- games/rogue/machdep.c | 82 ++++++------ games/rogue/main.c | 9 +- games/rogue/message.c | 57 ++++---- games/rogue/monster.c | 172 ++++++++++++------------ games/rogue/move.c | 94 ++++++------- games/rogue/object.c | 116 ++++++++-------- games/rogue/pack.c | 112 ++++++++-------- games/rogue/play.c | 7 +- games/rogue/random.c | 73 +--------- games/rogue/ring.c | 53 +++----- games/rogue/rogue.h | 287 ++++++++++++++++++++++++++++++++++------ games/rogue/room.c | 95 +++++++------ games/rogue/save.c | 112 ++++++++-------- games/rogue/score.c | 146 ++++++++++---------- games/rogue/spec_hit.c | 96 ++++++++------ games/rogue/throw.c | 37 +++--- games/rogue/trap.c | 28 ++-- games/rogue/use.c | 71 ++++++---- games/rogue/zap.c | 50 +++---- 24 files changed, 1228 insertions(+), 985 deletions(-) diff --git a/games/rogue/Makefile b/games/rogue/Makefile index 56eb86fa5d..1d9532b78b 100644 --- a/games/rogue/Makefile +++ b/games/rogue/Makefile @@ -1,6 +1,6 @@ # @(#)Makefile 8.1 (Berkeley) 5/31/93 # $FreeBSD: src/games/rogue/Makefile,v 1.4.2.5 2002/08/07 16:31:42 ru Exp $ -# $DragonFly: src/games/rogue/Makefile,v 1.3 2005/05/07 18:33:25 corecode Exp $ +# $DragonFly: src/games/rogue/Makefile,v 1.4 2006/09/02 19:31:07 pavalos Exp $ PROG= rogue CFLAGS+=-DUNIX @@ -8,9 +8,10 @@ SRCS= hit.c init.c inventory.c level.c machdep.c main.c \ message.c monster.c move.c object.c pack.c play.c random.c ring.c \ room.c save.c score.c spec_hit.c throw.c trap.c use.c zap.c DPADD= ${LIBCURSES} ${LIBTERMCAP} -LDADD= -lcurses -ltermcap +LDADD= -lcurses HIDEGAME=hidegame MAN= rogue.6 +WARNS?= 6 beforeinstall: .if !exists(${DESTDIR}/var/games/rogue.scores) diff --git a/games/rogue/hit.c b/games/rogue/hit.c index 5a2482c9c1..61525c3dd5 100644 --- a/games/rogue/hit.c +++ b/games/rogue/hit.c @@ -35,7 +35,7 @@ * * @(#)hit.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/hit.c,v 1.6 1999/11/30 03:49:22 billf Exp $ - * $DragonFly: src/games/rogue/hit.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ + * $DragonFly: src/games/rogue/hit.c,v 1.3 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -59,8 +59,12 @@ extern short halluc, blind, cur_level; extern short add_strength, ring_exp, r_rings; extern boolean being_held, interrupted, wizard, con_mon; -mon_hit(monster) -object *monster; +static int get_w_damage(const object *); +static int to_hit(const object *); +static short damage_for_strength(void); + +void +mon_hit(object *monster) { short damage, hit_chance; const char *mn; @@ -120,9 +124,8 @@ object *monster; } } -rogue_hit(monster, force_hit) -object *monster; -boolean force_hit; +void +rogue_hit(object *monster, boolean force_hit) { short damage, hit_chance; @@ -137,7 +140,7 @@ boolean force_hit; } if (!rand_percent(hit_chance)) { if (!fight_monster) { - (void) strcpy(hit_message, "you miss "); + strcpy(hit_message, "you miss "); } goto RET; } @@ -150,7 +153,7 @@ boolean force_hit; } if (mon_damage(monster, damage)) { /* still alive? */ if (!fight_monster) { - (void) strcpy(hit_message, "you hit "); + strcpy(hit_message, "you hit "); } } RET: check_gold_seeker(monster); @@ -158,10 +161,8 @@ RET: check_gold_seeker(monster); } } -rogue_damage(d, monster, other) -short d; -object *monster; -short other; +void +rogue_damage(short d, object *monster, short other) { if (d >= rogue.hp_current) { rogue.hp_current = 0; @@ -174,9 +175,8 @@ short other; } } -get_damage(ds, r) -const char *ds; -boolean r; +int +get_damage(const char *ds, boolean r) { int i = 0, j, n, d, total = 0; @@ -200,27 +200,27 @@ boolean r; return(total); } -get_w_damage(obj) -const object *obj; +static int +get_w_damage(const object *obj) { char new_damage[12]; - int to_hit, damage; + int t_hit, damage; int i = 0; if ((!obj) || (obj->what_is != WEAPON)) { return(-1); } - to_hit = get_number(obj->damage) + obj->hit_enchant; + t_hit = get_number(obj->damage) + obj->hit_enchant; while (obj->damage[i++] != 'd') ; damage = get_number(obj->damage + i) + obj->d_enchant; - sprintf(new_damage, "%dd%d", to_hit, damage); + sprintf(new_damage, "%dd%d", t_hit, damage); return(get_damage(new_damage, 1)); } -get_number(s) -const char *s; +int +get_number(const char *s) { int i = 0; int total = 0; @@ -233,8 +233,7 @@ const char *s; } long -lget_number(s) -const char *s; +lget_number(const char *s) { short i = 0; long total = 0; @@ -246,8 +245,8 @@ const char *s; return(total); } -to_hit(obj) -const object *obj; +static int +to_hit(const object *obj) { if (!obj) { return(1); @@ -255,7 +254,8 @@ const object *obj; return(get_number(obj->damage) + obj->hit_enchant); } -damage_for_strength() +static short +damage_for_strength(void) { short strength; @@ -285,9 +285,8 @@ damage_for_strength() return(8); } -mon_damage(monster, damage) -object *monster; -short damage; +boolean +mon_damage(object *monster, short damage) { const char *mn; short row, col; @@ -318,8 +317,8 @@ short damage; return(1); } -fight(to_the_death) -boolean to_the_death; +void +fight(boolean to_the_death) { short ch, c, d; short row, col; @@ -356,7 +355,7 @@ boolean to_the_death; possible_damage = fight_monster->stationary_damage - 1; } while (fight_monster) { - (void) one_move_rogue(ch, 0); + one_move_rogue(ch, 0); if (((!to_the_death) && (rogue.hp_current <= possible_damage)) || interrupted || (!(dungeon[row][col] & MONSTER))) { fight_monster = 0; @@ -369,10 +368,8 @@ boolean to_the_death; } } -get_dir_rc(dir, row, col, allow_off_screen) -short dir; -short *row, *col; -short allow_off_screen; +void +get_dir_rc(short dir, short *row, short *col, short allow_off_screen) { switch(dir) { case LEFT: @@ -422,8 +419,8 @@ short allow_off_screen; } } -get_hit_chance(weapon) -const object *weapon; +short +get_hit_chance(const object *weapon) { short hit_chance; @@ -433,8 +430,8 @@ const object *weapon; return(hit_chance); } -get_weapon_damage(weapon) -const object *weapon; +short +get_weapon_damage(const object *weapon) { short damage; @@ -444,8 +441,8 @@ const object *weapon; return(damage); } -s_con_mon(monster) -object *monster; +void +s_con_mon(object *monster) { if (con_mon) { monster->m_flags |= CONFUSED; diff --git a/games/rogue/init.c b/games/rogue/init.c index 52bdf60429..c07e82afbd 100644 --- a/games/rogue/init.c +++ b/games/rogue/init.c @@ -35,7 +35,7 @@ * * @(#)init.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/init.c,v 1.4 1999/11/30 03:49:22 billf Exp $ - * $DragonFly: src/games/rogue/init.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ + * $DragonFly: src/games/rogue/init.c,v 1.3 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -73,9 +73,14 @@ extern char *save_file; extern short party_room; extern boolean jump; -init(argc, argv) -int argc; -char *argv[]; +static void player_init(void); +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 *); + +boolean +init(int argc, char *argv[]) { const char *pn; int seed; @@ -84,7 +89,7 @@ char *argv[]; if ((!pn) || (strlen(pn) >= MAX_OPT_LEN)) { clean_up("Hey! Who are you?"); } - (void) strcpy(login_name, pn); + strcpy(login_name, pn); do_args(argc, argv); do_opts(); @@ -108,7 +113,7 @@ char *argv[]; put_scores((object *) 0, 0); } seed = md_gseed(); - (void) srrandom(seed); + srrandom(seed); if (rest_file) { restore(rest_file); return(1); @@ -124,7 +129,8 @@ char *argv[]; return(0); } -player_init() +static void +player_init(void) { object *obj; @@ -132,7 +138,7 @@ player_init() obj = alloc_object(); get_food(obj, 1); - (void) add_to_pack(obj, &rogue.pack, 1); + add_to_pack(obj, &rogue.pack, 1); obj = alloc_object(); /* initial armor */ obj->what_is = ARMOR; @@ -140,7 +146,7 @@ player_init() obj->class = RINGMAIL+2; obj->is_protected = 0; obj->d_enchant = 1; - (void) add_to_pack(obj, &rogue.pack, 1); + add_to_pack(obj, &rogue.pack, 1); do_wear(obj); obj = alloc_object(); /* initial weapons */ @@ -149,7 +155,7 @@ player_init() obj->damage = "2d3"; obj->hit_enchant = obj->d_enchant = 1; obj->identified = 1; - (void) add_to_pack(obj, &rogue.pack, 1); + add_to_pack(obj, &rogue.pack, 1); do_wield(obj); obj = alloc_object(); @@ -159,7 +165,7 @@ player_init() obj->hit_enchant = 1; obj->d_enchant = 0; obj->identified = 1; - (void) add_to_pack(obj, &rogue.pack, 1); + add_to_pack(obj, &rogue.pack, 1); obj = alloc_object(); obj->what_is = WEAPON; @@ -169,11 +175,11 @@ player_init() obj->hit_enchant = 0; obj->d_enchant = 0; obj->identified = 1; - (void) add_to_pack(obj, &rogue.pack, 1); + add_to_pack(obj, &rogue.pack, 1); } -clean_up(estr) -const char *estr; +void +clean_up(const char *estr) { if (save_is_interactive) { if (init_curses) { @@ -186,7 +192,8 @@ const char *estr; md_exit(0); } -start_window() +void +start_window(void) { crmode(); noecho(); @@ -196,14 +203,15 @@ start_window() md_control_keybord(0); } -stop_window() +void +stop_window(void) { endwin(); md_control_keybord(1); } void -byebye() +byebye(void) { md_ignore_signals(); if (ask_quit) { @@ -215,7 +223,7 @@ byebye() } void -onintr() +onintr(void) { md_ignore_signals(); if (cant_int) { @@ -228,16 +236,15 @@ onintr() } void -error_save() +error_save(void) { save_is_interactive = 0; save_into_file(error_file); clean_up(""); } -do_args(argc, argv) -int argc; -char *argv[]; +static void +do_args(int argc, char *argv[]) { short i, j; @@ -256,11 +263,12 @@ char *argv[]; } } -do_opts() +static void +do_opts(void) { char *eptr; - if (eptr = md_getenv("ROGUEOPTS")) { + if ((eptr = md_getenv("ROGUEOPTS"))) { for (;;) { while ((*eptr) == ' ') { eptr++; @@ -305,9 +313,8 @@ do_opts() init_str(&fruit, "slime-mold"); } -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; @@ -324,19 +331,18 @@ boolean add_blank; } } *s = md_malloc(MAX_OPT_LEN + 2); - (void) strncpy(*s, t, i); + strncpy(*s, t, i); if (add_blank) { (*s)[i++] = ' '; } (*s)[i] = '\0'; } -init_str(str, dflt) -char **str; -const char *dflt; +static void +init_str(char **str, const char *dflt) { if (!(*str)) { *str = md_malloc(MAX_OPT_LEN + 2); - (void) strcpy(*str, dflt); + strcpy(*str, dflt); } } diff --git a/games/rogue/inventory.c b/games/rogue/inventory.c index dc559e783a..d339a5db20 100644 --- a/games/rogue/inventory.c +++ b/games/rogue/inventory.c @@ -35,7 +35,7 @@ * * @(#)inventory.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/inventory.c,v 1.4 1999/11/30 03:49:23 billf Exp $ - * $DragonFly: src/games/rogue/inventory.c,v 1.3 2003/08/26 23:52:50 drhodus Exp $ + * $DragonFly: src/games/rogue/inventory.c,v 1.4 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -52,6 +52,10 @@ #include "rogue.h" +static boolean pr_com_id(int); +static boolean get_com_id(int *, short); +static boolean pr_motion_char(int); + boolean is_wood[WANDS]; const char *press_space = " --press space to continue--"; @@ -71,7 +75,6 @@ const char *const wand_materials[WAND_MATERIALS] = { "platinum ", "silicon ", "titanium ", - "teak ", "oak ", "cherry ", @@ -157,62 +160,61 @@ struct id_com_s { }; const struct id_com_s com_id_tab[COMS] = { - '?', "? prints help", - 'r', "r read scroll", - '/', "/ identify object", - 'e', "e eat food", - 'h', "h left ", - 'w', "w wield a weapon", - 'j', "j down", - 'W', "W wear armor", - 'k', "k up", - 'T', "T take armor off", - 'l', "l right", - 'P', "P put on ring", - 'y', "y up & left", - 'R', "R remove ring", - 'u', "u up & right", - 'd', "d drop object", - 'b', "b down & left", - 'c', "c call object", - 'n', "n down & right", - '\0', ": run that way", - ')', ") print current weapon", - '\0', ": run till adjacent", - ']', "] print current armor", - 'f', "f fight till death or near death", - '=', "= print current rings", - 't', "t throw something", - '\001', "^A print Hp-raise average", - 'm', "m move onto without picking up", - 'z', "z zap a wand in a direction", - 'o', "o examine/set options", - '^', "^ identify trap type", - '\022', "^R redraw screen", - '&', "& save screen into 'rogue.screen'", - 's', "s search for trap/secret door", - '\020', "^P repeat last message", - '>', "> go down a staircase", - '\033', "^[ cancel command", - '<', "< go up a staircase", - 'S', "S save game", - '.', ". rest for a turn", - 'Q', "Q quit", - ',', ", pick something up", - '!', "! shell escape", - 'i', "i inventory", - 'F', "F fight till either of you dies", - 'I', "I inventory single item", - 'v', "v print version number", - 'q', "q quaff potion" + { '?', "? prints help" }, + { 'r', "r read scroll" }, + { '/', "/ identify object" }, + { 'e', "e eat food" }, + { 'h', "h left " }, + { 'w', "w wield a weapon" }, + { 'j', "j down" }, + { 'W', "W wear armor" }, + { 'k', "k up" }, + { 'T', "T take armor off" }, + { 'l', "l right" }, + { 'P', "P put on ring" }, + { 'y', "y up & left" }, + { 'R', "R remove ring" }, + { 'u', "u up & right" }, + { 'd', "d drop object" }, + { 'b', "b down & left" }, + { 'c', "c call object" }, + { 'n', "n down & right" }, + { '\0', ": run that way" }, + { ')', ") print current weapon" }, + { '\0', ": run till adjacent" }, + { ']', "] print current armor" }, + { 'f', "f fight till death or near death" }, + { '=', "= print current rings" }, + { 't', "t throw something" }, + { '\001', "^A print Hp-raise average" }, + { 'm', "m move onto without picking up" }, + { 'z', "z zap a wand in a direction" }, + { 'o', "o examine/set options" }, + { '^', "^ identify trap type" }, + { '\022', "^R redraw screen" }, + { '&', "& save screen into 'rogue.screen'" }, + { 's', "s search for trap/secret door" }, + { '\020', "^P repeat last message" }, + { '>', "> go down a staircase" }, + { '\033', "^[ cancel command" }, + { '<', "< go up a staircase" }, + { 'S', "S save game" }, + { '.', ". rest for a turn" }, + { 'Q', "Q quit" }, + { ',', ", pick something up" }, + { '!', "! shell escape" }, + { 'i', "i inventory" }, + { 'F', "F fight till either of you dies" }, + { 'I', "I inventory single item" }, + { 'v', "v print version number" }, + { 'q', "q quaff potion" } }; extern boolean wizard; extern char *m_names[], *more; -inventory(pack, mask) -const object *pack; -unsigned short mask; +void +inventory(const object *pack, unsigned short mask) { object *obj; short i = 0, j, maxlen = 0, n; @@ -240,7 +242,7 @@ unsigned short mask; } obj = obj->next_object; } - (void) strcpy(descs[i++], press_space); + strcpy(descs[i++], press_space); if (maxlen < 27) maxlen = 27; col = DCOLS - (maxlen + 2); @@ -265,7 +267,8 @@ unsigned short mask; } } -id_com() +void +id_com(void) { int ch = 0; short i, j, k; @@ -282,7 +285,7 @@ id_com() { char save[(((COMS / 2) + (COMS % 2)) + 1)][DCOLS]; short rows = (((COMS / 2) + (COMS % 2)) + 1); - boolean need_two_screens; + boolean need_two_screens = 0; if (rows > LINES) { need_two_screens = 1; @@ -341,8 +344,8 @@ MORE: } } -pr_com_id(ch) -int ch; +static boolean +pr_com_id(int ch) { int i; @@ -354,23 +357,22 @@ int ch; return(1); } -get_com_id(index, ch) -int *index; -short ch; +static boolean +get_com_id(int *idx, short ch) { short i; for (i = 0; i < COMS; i++) { if (com_id_tab[i].com_char == ch) { - *index = i; + *idx = i; return(1); } } return(0); } -pr_motion_char(ch) -int ch; +static boolean +pr_motion_char(int ch) { if ( (ch == 'J') || (ch == 'K') || @@ -393,12 +395,12 @@ int ch; if (ch <= '\031') { ch += 96; - (void) strcpy(until, "until adjascent"); + strcpy(until, "until adjascent"); } else { ch += 32; until[0] = '\0'; } - (void) get_com_id(&n, ch); + get_com_id(&n, ch); sprintf(buf, "run %s %s", com_id_tab[n].com_desc + 8, until); check_message(); message(buf, 0); @@ -408,7 +410,8 @@ int ch; } } -mix_colors() +void +mix_colors(void) { short i, j, k; char *t[MAX_ID_TITLE_LEN]; @@ -421,27 +424,27 @@ mix_colors() } } -make_scroll_titles() +void +make_scroll_titles(void) { short i, j, n; short sylls, s; for (i = 0; i < SCROLS; i++) { sylls = get_rand(2, 5); - (void) strcpy(id_scrolls[i].title, "'"); + strcpy(id_scrolls[i].title, "'"); for (j = 0; j < sylls; j++) { s = get_rand(1, (MAXSYLLABLES-1)); - (void) strcat(id_scrolls[i].title, syllables[s]); + strcat(id_scrolls[i].title, syllables[s]); } n = strlen(id_scrolls[i].title); - (void) strcpy(id_scrolls[i].title+(n-1), "' "); + strcpy(id_scrolls[i].title+(n-1), "' "); } } -get_desc(obj, desc) -const object *obj; -char *desc; +void +get_desc(const object *obj, char *desc) { const char *item_name; struct id *id_table; @@ -449,7 +452,7 @@ char *desc; short i; if (obj->what_is == AMULET) { - (void) strcpy(desc, "the amulet of Yendor "); + strcpy(desc, "the amulet of Yendor "); return; } item_name = name_of(obj); @@ -461,7 +464,7 @@ char *desc; if (obj->what_is != ARMOR) { if (obj->quantity == 1) { - (void) strcpy(desc, "a "); + strcpy(desc, "a "); } else { sprintf(desc, "%d ", obj->quantity); } @@ -471,12 +474,12 @@ char *desc; if (obj->quantity > 1) { sprintf(desc, "%d rations of ", obj->quantity); } else { - (void) strcpy(desc, "some "); + strcpy(desc, "some "); } } else { - (void) strcpy(desc, "a "); + strcpy(desc, "a "); } - (void) strcat(desc, item_name); + strcat(desc, item_name); goto ANA; } id_table = get_id_table(obj); @@ -493,13 +496,13 @@ char *desc; CHECK: switch(obj->what_is) { case SCROL: - (void) strcat(desc, item_name); - (void) strcat(desc, "entitled: "); - (void) strcat(desc, id_table[obj->which_kind].title); + strcat(desc, item_name); + strcat(desc, "entitled: "); + strcat(desc, id_table[obj->which_kind].title); break; case POTION: - (void) strcat(desc, id_table[obj->which_kind].title); - (void) strcat(desc, item_name); + strcat(desc, id_table[obj->which_kind].title); + strcat(desc, item_name); break; case WAND: case RING: @@ -510,20 +513,20 @@ CHECK: if (id_table[obj->which_kind].id_status == CALLED) { goto CALL; } - (void) strcat(desc, id_table[obj->which_kind].title); - (void) strcat(desc, item_name); + strcat(desc, id_table[obj->which_kind].title); + strcat(desc, item_name); break; case ARMOR: if (obj->identified) { goto ID; } - (void) strcpy(desc, id_table[obj->which_kind].title); + strcpy(desc, id_table[obj->which_kind].title); break; case WEAPON: if (obj->identified) { goto ID; } - (void) strcat(desc, name_of(obj)); + strcat(desc, name_of(obj)); break; } break; @@ -533,9 +536,9 @@ CALL: switch(obj->what_is) { case POTION: case WAND: case RING: - (void) strcat(desc, item_name); - (void) strcat(desc, "called "); - (void) strcat(desc, id_table[obj->which_kind].title); + strcat(desc, item_name); + strcat(desc, "called "); + strcat(desc, id_table[obj->which_kind].title); break; } break; @@ -543,8 +546,8 @@ CALL: switch(obj->what_is) { ID: switch(obj->what_is) { case SCROL: case POTION: - (void) strcat(desc, item_name); - (void) strcat(desc, id_table[obj->which_kind].real); + strcat(desc, item_name); + strcat(desc, id_table[obj->which_kind].real); break; case RING: if (wizard || obj->identified) { @@ -552,32 +555,32 @@ ID: switch(obj->what_is) { (obj->which_kind == ADD_STRENGTH)) { sprintf(more_info, "%s%d ", ((obj->class > 0) ? "+" : ""), obj->class); - (void) strcat(desc, more_info); + strcat(desc, more_info); } } - (void) strcat(desc, item_name); - (void) strcat(desc, id_table[obj->which_kind].real); + strcat(desc, item_name); + strcat(desc, id_table[obj->which_kind].real); break; case WAND: - (void) strcat(desc, item_name); - (void) strcat(desc, id_table[obj->which_kind].real); + strcat(desc, item_name); + strcat(desc, id_table[obj->which_kind].real); if (wizard || obj->identified) { sprintf(more_info, "[%d]", obj->class); - (void) strcat(desc, more_info); + strcat(desc, more_info); } break; case ARMOR: sprintf(desc, "%s%d ", ((obj->d_enchant >= 0) ? "+" : ""), obj->d_enchant); - (void) strcat(desc, id_table[obj->which_kind].title); + strcat(desc, id_table[obj->which_kind].title); sprintf(more_info, "[%d] ", get_armor_class(obj)); - (void) strcat(desc, more_info); + strcat(desc, more_info); break; case WEAPON: sprintf(desc+strlen(desc), "%s%d,%s%d ", ((obj->hit_enchant >= 0) ? "+" : ""), obj->hit_enchant, ((obj->d_enchant >= 0) ? "+" : ""), obj->d_enchant); - (void) strcat(desc, name_of(obj)); + strcat(desc, name_of(obj)); break; } break; @@ -592,17 +595,18 @@ ANA: } } if (obj->in_use_flags & BEING_WIELDED) { - (void) strcat(desc, "in hand"); + strcat(desc, "in hand"); } else if (obj->in_use_flags & BEING_WORN) { - (void) strcat(desc, "being worn"); + strcat(desc, "being worn"); } else if (obj->in_use_flags & ON_LEFT_HAND) { - (void) strcat(desc, "on left hand"); + strcat(desc, "on left hand"); } else if (obj->in_use_flags & ON_RIGHT_HAND) { - (void) strcat(desc, "on right hand"); + strcat(desc, "on right hand"); } } -get_wand_and_ring_materials() +void +get_wand_and_ring_materials(void) { short i, j; boolean used[WAND_MATERIALS]; @@ -615,7 +619,7 @@ get_wand_and_ring_materials() j = get_rand(0, WAND_MATERIALS-1); } while (used[j]); used[j] = 1; - (void) strcpy(id_wands[i].title, wand_materials[j]); + strcpy(id_wands[i].title, wand_materials[j]); is_wood[i] = (j > MAX_METAL); } for (i = 0; i < GEMS; i++) { @@ -626,12 +630,12 @@ get_wand_and_ring_materials() j = get_rand(0, GEMS-1); } while (used[j]); used[j] = 1; - (void) strcpy(id_rings[i].title, gems[j]); + strcpy(id_rings[i].title, gems[j]); } } -single_inv(ichar) -short ichar; +void +single_inv(short ichar) { short ch; char desc[DCOLS]; @@ -655,8 +659,7 @@ short ichar; } struct id * -get_id_table(obj) -const object *obj; +get_id_table(const object *obj) { switch(obj->what_is) { case SCROL: @@ -675,8 +678,8 @@ const object *obj; return((struct id *) 0); } -inv_armor_weapon(is_weapon) -boolean is_weapon; +void +inv_armor_weapon(boolean is_weapon) { if (is_weapon) { if (rogue.weapon) { @@ -693,7 +696,8 @@ boolean is_weapon; } } -id_type() +void +id_type(void) { const char *id; int ch; diff --git a/games/rogue/level.c b/games/rogue/level.c index 7a7fc3d321..a533167fe2 100644 --- a/games/rogue/level.c +++ b/games/rogue/level.c @@ -35,7 +35,7 @@ * * @(#)level.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/level.c,v 1.3 1999/11/30 03:49:23 billf Exp $ - * $DragonFly: src/games/rogue/level.c,v 1.3 2006/08/03 16:40:46 swildner Exp $ + * $DragonFly: src/games/rogue/level.c,v 1.4 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -89,12 +89,29 @@ short random_rooms[MAXROOMS] = {3, 7, 5, 2, 0, 6, 1, 4, 8}; extern boolean being_held, wizard, detect_monster; extern boolean see_invisible; -extern short bear_trap, levitate, extra_hp, less_hp, cur_room; - -make_level() +extern short bear_trap, levitate, extra_hp, less_hp; + +static void make_room(short, short, short, short); +static boolean connect_rooms(short, short); +static void put_door(room *, short, short *, short *); +static void draw_simple_passage(short, short, short, short, short); +static boolean same_row(short, short); +static boolean same_col(short, short); +static void add_mazes(void); +static void fill_out_level(void); +static void fill_it(int, boolean); +static void recursive_deadend(short, const short *, short, short); +static boolean mask_room(short, short *, short *, unsigned short); +static void make_maze(short, short, short, short, short, short); +static void hide_boxed_passage(short, short, short, short, short); +static short get_exp_level(long); +static void mix_random_rooms(void); + +void +make_level(void) { short i, j; - short must_1, must_2, must_3; + short must_1, must_2 = 0, must_3 = 0; boolean big_room; if (cur_level < LAST_DUNGEON) { @@ -158,10 +175,10 @@ make_level() i = random_rooms[j]; if (i < (MAXROOMS-1)) { - (void) connect_rooms(i, i+1); + connect_rooms(i, i+1); } if (i < (MAXROOMS-3)) { - (void) connect_rooms(i, i+3); + connect_rooms(i, i+3); } if (i < (MAXROOMS-2)) { if (rooms[i+1].is_room & R_NOTHING) { @@ -188,14 +205,16 @@ make_level() } } -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; short row_offset, col_offset; short i, j, ch; + left_col = right_col = top_row = bottom_row = 0; + switch(rn) { case 0: left_col = 0; @@ -297,8 +316,8 @@ END: rooms[rn].right_col = right_col; } -connect_rooms(room1, room2) -short room1, room2; +static boolean +connect_rooms(short room1, short room2) { short row1, col1, row2, col2, dir; @@ -344,7 +363,8 @@ short room1, room2; return(1); } -clear_level() +void +clear_level(void) { short i, j; @@ -364,16 +384,14 @@ clear_level() } } detect_monster = see_invisible = 0; - being_held = bear_trap = 0; + bear_trap = being_held = 0; party_room = NO_ROOM; rogue.row = rogue.col = -1; clear(); } -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; @@ -407,8 +425,8 @@ short *row, *col; rm->doors[dir/2].door_col = *col; } -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; @@ -448,17 +466,20 @@ short row1, col1, row2, col2, dir; } } -same_row(room1, room2) +static boolean +same_row(short room1, short room2) { return((room1 / 3) == (room2 / 3)); } -same_col(room1, room2) +static boolean +same_col(short room1, short room2) { return((room1 % 3) == (room2 % 3)); } -add_mazes() +static void +add_mazes(void) { short i, j; short start; @@ -489,7 +510,8 @@ add_mazes() } } -fill_out_level() +static void +fill_out_level(void) { short i, rn; @@ -509,9 +531,8 @@ fill_out_level() } } -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; @@ -570,10 +591,8 @@ boolean do_rec_de; } } -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; @@ -605,11 +624,8 @@ short 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; @@ -625,8 +641,8 @@ unsigned short mask; return(0); } -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; @@ -690,8 +706,8 @@ short r, c, tr, br, lc, rc; } } -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; @@ -725,8 +741,8 @@ short row1, col1, row2, col2, n; } } -put_player(nr) -short nr; /* try not to put in this room */ +void +put_player(short nr) /* try not to put in this room */ { short rn = nr, misses; short row, col; @@ -757,7 +773,8 @@ short nr; /* try not to put in this room */ mvaddch(rogue.row, rogue.col, rogue.fchar); } -drop_check() +boolean +drop_check(void) { if (wizard) { return(1); @@ -773,7 +790,8 @@ drop_check() return(0); } -check_up() +boolean +check_up(void) { if (!wizard) { if (!(dungeon[rogue.row][rogue.col] & STAIRS)) { @@ -795,9 +813,8 @@ check_up() return(0); } -add_exp(e, promotion) -int e; -boolean promotion; +void +add_exp(int e, boolean promotion) { char mbuf[40]; short new_exp; @@ -826,8 +843,8 @@ boolean promotion; } } -get_exp_level(e) -long e; +static short +get_exp_level(long e) { short i; @@ -839,7 +856,8 @@ long e; return(i+1); } -hp_raise() +int +hp_raise(void) { int hp; @@ -847,7 +865,8 @@ hp_raise() return(hp); } -show_average_hp() +void +show_average_hp(void) { char mbuf[80]; float real_average; @@ -866,7 +885,8 @@ show_average_hp() message(mbuf, 0); } -mix_random_rooms() +static void +mix_random_rooms(void) { short i, t; short x, y; diff --git a/games/rogue/machdep.c b/games/rogue/machdep.c index 468fcceb4e..a91f1f0287 100644 --- a/games/rogue/machdep.c +++ b/games/rogue/machdep.c @@ -35,7 +35,7 @@ * * @(#)machdep.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/machdep.c,v 1.6.2.1 2001/12/17 12:43:23 phantom Exp $ - * $DragonFly: src/games/rogue/machdep.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ + * $DragonFly: src/games/rogue/machdep.c,v 1.3 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -95,7 +95,9 @@ #include #include #include +#include #include +#include #ifdef UNIX_BSD4_2 #include @@ -125,12 +127,13 @@ * big deal. */ -md_slurp() +void +md_slurp(void) { - (void)fpurge(stdin); + fpurge(stdin); } -/* md_control_keyboard(): +/* md_control_keybord(): * * This routine is much like md_cbreak_no_echo_nonl() below. It sets up the * keyboard for appropriate input. Specifically, it prevents the tty driver @@ -148,8 +151,8 @@ md_slurp() * cause certain command characters to be unavailable. */ -md_control_keybord(mode) -boolean mode; +void +md_control_keybord(boolean mode) { static boolean called_before = 0; #ifdef UNIX_BSD4_2 @@ -217,11 +220,12 @@ boolean mode; * input, this is not usually critical. */ -md_heed_signals() +void +md_heed_signals(void) { - signal(SIGINT, onintr); - signal(SIGQUIT, byebye); - signal(SIGHUP, error_save); + signal(SIGINT, (sig_t)onintr); + signal(SIGQUIT, (sig_t)byebye); + signal(SIGHUP, (sig_t)error_save); } /* md_ignore_signals(): @@ -236,7 +240,8 @@ md_heed_signals() * file, corruption. */ -md_ignore_signals() +void +md_ignore_signals(void) { signal(SIGQUIT, SIG_IGN); signal(SIGINT, SIG_IGN); @@ -253,8 +258,7 @@ md_ignore_signals() */ int -md_get_file_id(fname) -const char *fname; +md_get_file_id(const char *fname) { struct stat sbuf; @@ -273,8 +277,7 @@ const char *fname; */ int -md_link_count(fname) -const char *fname; +md_link_count(const char *fname) { struct stat sbuf; @@ -296,10 +299,10 @@ const char *fname; * saved-game files and play them. */ -md_gct(rt_buf) -struct rogue_time *rt_buf; +void +md_gct(struct rogue_time *rt_buf) { - struct tm *t, *localtime(); + struct tm *t; time_t seconds; time(&seconds); @@ -329,9 +332,8 @@ struct rogue_time *rt_buf; * saved-games that have been modified. */ -md_gfmt(fname, rt_buf) -const char *fname; -struct rogue_time *rt_buf; +void +md_gfmt(const char *fname, struct rogue_time *rt_buf) { struct stat sbuf; time_t seconds; @@ -361,8 +363,7 @@ struct rogue_time *rt_buf; */ boolean -md_df(fname) -const char *fname; +md_df(const char *fname) { if (unlink(fname)) { return(0); @@ -380,7 +381,7 @@ const char *fname; */ const char * -md_gln() +md_gln(void) { struct passwd *p; char *s; @@ -401,10 +402,10 @@ md_gln() * delaying execution, which is useful to this program at some times. */ -md_sleep(nsecs) -int nsecs; +void +md_sleep(int nsecs) { - (void) sleep(nsecs); + sleep(nsecs); } /* md_getenv() @@ -426,8 +427,7 @@ int nsecs; */ char * -md_getenv(name) -const char *name; +md_getenv(const char *name) { char *value; @@ -445,8 +445,7 @@ const char *name; */ char * -md_malloc(n) -int n; +md_malloc(int n) { char *t; @@ -472,7 +471,8 @@ int n; * exactly the same way given the same input. */ -md_gseed() +int +md_gseed(void) { time_t seconds; @@ -487,8 +487,8 @@ md_gseed() * hang when it should quit. */ -md_exit(status) -int status; +void +md_exit(int status) { exit(status); } @@ -504,8 +504,8 @@ int status; * the lock is released. */ -md_lock(l) -boolean l; +void +md_lock(boolean l) { static int fd; short tries; @@ -519,8 +519,8 @@ boolean l; if (!flock(fd, LOCK_EX|LOCK_NB)) return; } else { - (void)flock(fd, LOCK_NB); - (void)close(fd); + flock(fd, LOCK_NB); + close(fd); } } @@ -533,8 +533,8 @@ boolean l; * The effective user id is restored after the shell completes. */ -md_shell(shell) -const char *shell; +void +md_shell(const char *shell) { long w[2]; @@ -543,7 +543,7 @@ const char *shell; setgid(getgid()); execl(shell, shell, 0); } - wait(w); + wait((int *)w); } #endif /* UNIX */ diff --git a/games/rogue/main.c b/games/rogue/main.c index fa12277df0..28ffa03df4 100644 --- a/games/rogue/main.c +++ b/games/rogue/main.c @@ -36,7 +36,7 @@ * @(#) Copyright (c) 1988, 1993 The Regents of the University of California. All rights reserved. * @(#)main.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/main.c,v 1.3 1999/11/30 03:49:23 billf Exp $ - * $DragonFly: src/games/rogue/main.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ + * $DragonFly: src/games/rogue/main.c,v 1.3 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -55,9 +55,8 @@ extern short party_room; -main(argc, argv) -int argc; -char *argv[]; +int +main(int argc, char *argv[]) { if (init(argc, argv)) { /* restored game */ goto PL; @@ -77,4 +76,6 @@ PL: free_stuff(&level_objects); free_stuff(&level_monsters); } + /* NOTREACHED */ + return(0); } diff --git a/games/rogue/message.c b/games/rogue/message.c index 58bb9eea79..7f63d09a46 100644 --- a/games/rogue/message.c +++ b/games/rogue/message.c @@ -35,7 +35,7 @@ * * @(#)message.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/message.c,v 1.7.2.1 2000/07/20 10:35:07 kris Exp $ - * $DragonFly: src/games/rogue/message.c,v 1.3 2003/08/26 23:52:50 drhodus Exp $ + * $DragonFly: src/games/rogue/message.c,v 1.4 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -63,9 +63,11 @@ extern boolean cant_int, did_int, interrupted, save_is_interactive, flush; extern short add_strength; extern short cur_level; -message(msg, intrpt) -const char *msg; -boolean intrpt; +static void pad(const char *, short); +static void save_screen(void); + +void +message(const char *msg, boolean intrpt) { cant_int = 1; @@ -86,7 +88,7 @@ boolean intrpt; } if (!rmsg) { imsg = (imsg + 1) % NMESSAGES; - (void) strcpy(msgs[imsg], msg); + strcpy(msgs[imsg], msg); } mvaddstr(MIN_ROW-1, 0, msg); addch(' '); @@ -102,8 +104,8 @@ boolean intrpt; } } -remessage(c) -short c; +void +remessage(short c) { if (imsg != -1) { check_message(); @@ -118,7 +120,8 @@ short c; } } -check_message() +void +check_message(void) { if (msg_cleared) { return; @@ -129,12 +132,9 @@ check_message() msg_cleared = 1; } -get_input_line(prompt, insert, buf, if_cancelled, add_blank, do_echo) -const char *prompt, *insert; -char *buf; -const char *if_cancelled; -boolean add_blank; -boolean do_echo; +short +get_input_line(const char *prompt, const char *insert, char *buf, + const char *if_cancelled, boolean add_blank, boolean do_echo) { short ch; short i = 0, n; @@ -144,7 +144,7 @@ boolean do_echo; if (insert[0]) { mvaddstr(0, n + 1, insert); - (void) strcpy(buf, insert); + strcpy(buf, insert); i = strlen(insert); move(0, (n + i + 1)); refresh(); @@ -188,7 +188,8 @@ boolean do_echo; return(i); } -rgetchar() +int +rgetchar(void) { int ch; @@ -219,8 +220,8 @@ Level: 99 Gold: 999999 Hp: 999(999) Str: 99(99) Arm: 99 Exp: 21/10000000 Hungry 0 5 1 5 2 5 3 5 4 5 5 5 6 5 7 5 */ -print_stats(stat_mask) -int stat_mask; +void +print_stats(int stat_mask) { char buf[16]; boolean label; @@ -305,9 +306,8 @@ int stat_mask; refresh(); } -pad(s, n) -const char *s; -short n; +static void +pad(const char *s, short n) { short i; @@ -316,7 +316,8 @@ short n; } } -save_screen() +static void +save_screen(void) { FILE *fp; short i, j; @@ -344,23 +345,21 @@ save_screen() } } -sound_bell() +void +sound_bell(void) { putchar(7); fflush(stdout); } boolean -is_digit(ch) -short ch; +is_digit(short ch) { return((ch >= '0') && (ch <= '9')); } -r_index(str, ch, last) -const char *str; -int ch; -boolean last; +int +r_index(const char *str, int ch, boolean last) { int i = 0; diff --git a/games/rogue/monster.c b/games/rogue/monster.c index 52958bdc2e..0e150755e2 100644 --- a/games/rogue/monster.c +++ b/games/rogue/monster.c @@ -35,7 +35,7 @@ * * @(#)monster.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/monster.c,v 1.6 1999/11/30 03:49:24 billf Exp $ - * $DragonFly: src/games/rogue/monster.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ + * $DragonFly: src/games/rogue/monster.c,v 1.3 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -52,6 +52,14 @@ #include "rogue.h" +static boolean mtry(object *, short, short); +static short rogue_is_around(int, int); +static void put_m_at(short, short, object *); +static void aim_monster(object *); +static boolean move_confused(object *); +static boolean flit(object *); +static boolean no_room_for_monster(int); + object level_monsters; boolean mon_disappeared; @@ -85,36 +93,36 @@ const char *const m_names[] = { }; 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}, - {(ASLEEP|WAKENS|FLAMES),"4d6/4d9",145,'D',5000,21,126,100,0,90,0,0,0}, - {(ASLEEP|WAKENS),"1d3",11,'E',2,1,7,65,0,0,0,0,0}, - {(HOLDS|STATIONARY),"5d5",73,'F',91,12,126,80,0,0,0,0,0}, + {(ASLEEP|WAKENS|WANDERS|RUSTS),"0d0",25,'A',20,9,18,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|WANDERS|FLITS|FLIES),"1d3",10,'B',2,1,8,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|WANDERS),"3d3/2d5",32,'C',15,7,16,85,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|WAKENS|FLAMES),"4d6/4d9",145,'D',5000,21,126,100,0,90,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|WAKENS),"1d3",11,'E',2,1,7,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(HOLDS|STATIONARY),"5d5",73,'F',91,12,126,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, {(ASLEEP|WAKENS|WANDERS|FLIES),"5d5/5d5",115,'G', - 2000,20,126,85,0,10,0,0,0}, - {(ASLEEP|WAKENS|WANDERS),"1d3/1d2",15,'H',3,1,10,67,0,0,0,0,0}, - {(ASLEEP|FREEZES),"0d0",15,'I',5,2,11,68,0,0,0,0,0}, - {(ASLEEP|WANDERS),"3d10/4d5",132,'J',3000,21,126,100,0,0,0,0,0}, - {(ASLEEP|WAKENS|WANDERS|FLIES),"1d4",10,'K',2,1,6,60,0,0,0,0,0}, - {(ASLEEP|STEALS_GOLD),"0d0",25,'L',21,6,16,75,0,0,0,0,0}, + 2000,20,126,85,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|WAKENS|WANDERS),"1d3/1d2",15,'H',3,1,10,67,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|FREEZES),"0d0",15,'I',5,2,11,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|WANDERS),"3d10/4d5",132,'J',3000,21,126,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|WAKENS|WANDERS|FLIES),"1d4",10,'K',2,1,6,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|STEALS_GOLD),"0d0",25,'L',21,6,16,75,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, {(ASLEEP|WAKENS|WANDERS|CONFUSES),"4d4/3d7",97,'M', - 250,18,126,85,0,25,0,0,0}, - {(ASLEEP|STEALS_ITEM),"0d0",25,'N',39,10,19,75,0,100,0,0,0}, - {(ASLEEP|WANDERS|WAKENS|SEEKS_GOLD),"1d6",25,'O',5,4,13,70,0,10,0,0,0}, - {(ASLEEP|INVISIBLE|WANDERS|FLITS),"5d4",76,'P',120,15,24,80,0,50,0,0,0}, - {(ASLEEP|WAKENS|WANDERS),"3d5",30,'Q',20,8,17,78,0,20,0,0,0}, - {(ASLEEP|WAKENS|WANDERS|STINGS),"2d5",19,'R',10,3,12,70,0,0,0,0,0}, - {(ASLEEP|WAKENS|WANDERS),"1d3",8,'S',2,1,9,50,0,0,0,0,0}, - {(ASLEEP|WAKENS|WANDERS),"4d6/1d4",75,'T',125,13,22,75,0,33,0,0,0}, + 250,18,126,85,0,25,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|STEALS_ITEM),"0d0",25,'N',39,10,19,75,0,100,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|WANDERS|WAKENS|SEEKS_GOLD),"1d6",25,'O',5,4,13,70,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|INVISIBLE|WANDERS|FLITS),"5d4",76,'P',120,15,24,80,0,50,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|WAKENS|WANDERS),"3d5",30,'Q',20,8,17,78,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|WAKENS|WANDERS|STINGS),"2d5",19,'R',10,3,12,70,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|WAKENS|WANDERS),"1d3",8,'S',2,1,9,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|WAKENS|WANDERS),"4d6/1d4",75,'T',125,13,22,75,0,33,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, {(ASLEEP|WAKENS|WANDERS),"4d10",90,'U', - 200,17,26,85,0,33,0,0,0}, + 200,17,26,85,0,33,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, {(ASLEEP|WAKENS|WANDERS|DRAINS_LIFE),"1d14/1d4",55,'V', - 350,19,126,85,0,18,0,0,0}, - {(ASLEEP|WANDERS|DROPS_LEVEL),"2d8",45,'W',55,14,23,75,0,0,0,0,0}, - {(ASLEEP|IMITATES),"4d6",42,'X',110,16,25,75,0,0,0,0,0}, - {(ASLEEP|WANDERS),"3d6",35,'Y',50,11,20,80,0,20,0,0,0}, - {(ASLEEP|WAKENS|WANDERS),"1d7",21,'Z',8,5,14,69,0,0,0,0,0} + 350,19,126,85,0,18,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|WANDERS|DROPS_LEVEL),"2d8",45,'W',55,14,23,75,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|IMITATES),"4d6",42,'X',110,16,25,75,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|WANDERS),"3d6",35,'Y',50,11,20,80,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}, + {(ASLEEP|WAKENS|WANDERS),"1d7",21,'Z',8,5,14,69,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL} }; extern short cur_level; @@ -123,7 +131,8 @@ extern short blind, halluc, haste_self; extern boolean detect_monster, see_invisible, r_see_invisible; extern short stealthy; -put_mons() +void +put_mons(void) { short i; short n; @@ -143,9 +152,7 @@ put_mons() } object * -gr_monster(monster, mn) -object *monster; -int mn; +gr_monster(object *monster, int mn) { if (!monster) { monster = alloc_object(); @@ -169,7 +176,8 @@ int mn; return(monster); } -mv_mons() +void +mv_mons(void) { object *monster, *next_monster, *test_mons; boolean flew; @@ -224,8 +232,8 @@ NM: test_mons = level_monsters.next_monster; } } -party_monsters(rn, n) -int rn, n; +void +party_monsters(int rn, int n) { short i, j; short row, col; @@ -264,12 +272,12 @@ int rn, n; } } -gmc_row_col(row, col) -int row, col; +short +gmc_row_col(int row, int col) { object *monster; - if (monster = object_at(&level_monsters, row, col)) { + if ((monster = object_at(&level_monsters, row, col))) { if ((!(detect_monster || see_invisible || r_see_invisible) && (monster->m_flags & INVISIBLE)) || blind) { return(monster->trail_char); @@ -283,8 +291,8 @@ int row, col; } } -gmc(monster) -object *monster; +short +gmc(object *monster) { if ((!(detect_monster || see_invisible || r_see_invisible) && (monster->m_flags & INVISIBLE)) @@ -297,9 +305,8 @@ object *monster; return(monster->m_char); } -mv_1_monster(monster, row, col) -object *monster; -short row, col; +void +mv_1_monster(object *monster, short row, short col) { short i, n; boolean tried[6]; @@ -436,9 +443,8 @@ O: } } -mtry(monster, row, col) -object *monster; -short row, col; +static boolean +mtry(object *monster, short row, short col) { if (mon_can_go(monster, row, col)) { move_mon_to(monster, row, col); @@ -447,9 +453,8 @@ short row, col; return(0); } -move_mon_to(monster, row, col) -object *monster; -short row, col; +void +move_mon_to(object *monster, short row, short col) { short c; int mrow, mcol; @@ -497,9 +502,8 @@ short row, col; } } -mon_can_go(monster, row, col) -const object *monster; -short row, col; +boolean +mon_can_go(const object *monster, short row, short col) { object *obj; short dr, dc; @@ -538,18 +542,16 @@ short row, col; return(1); } -wake_up(monster) -object *monster; +void +wake_up(object *monster) { if (!(monster->m_flags & NAPPING)) { monster->m_flags &= (~(ASLEEP | IMITATES | WAKENS)); } } -wake_room(rn, entering, row, col) -short rn; -boolean entering; -short row, col; +void +wake_room(short rn, boolean entering, short row, short col) { object *monster; short wake_percent; @@ -583,8 +585,7 @@ short row, col; } const char * -mon_name(monster) -const object *monster; +mon_name(const object *monster) { short ch; @@ -600,8 +601,8 @@ const object *monster; return(m_names[ch]); } -rogue_is_around(row, col) -int row, col; +static short +rogue_is_around(int row, int col) { short rdif, cdif, retval; @@ -612,7 +613,8 @@ int row, col; return(retval); } -wanderer() +void +wanderer(void) { object *monster; short row, col, i; @@ -642,7 +644,8 @@ wanderer() } } -show_monsters() +void +show_monsters(void) { object *monster; @@ -663,7 +666,8 @@ show_monsters() } } -create_monster() +void +create_monster(void) { short row, col; short i; @@ -698,20 +702,19 @@ create_monster() } } -put_m_at(row, col, monster) -short row, col; -object *monster; +static void +put_m_at(short row, short col, object *monster) { monster->row = row; monster->col = col; dungeon[row][col] |= MONSTER; monster->trail_char = mvinch(row, col); - (void) add_to_pack(monster, &level_monsters, 0); + add_to_pack(monster, &level_monsters, 0); aim_monster(monster); } -aim_monster(monster) -object *monster; +static void +aim_monster(object *monster) { short i, rn, d, r; @@ -728,8 +731,8 @@ object *monster; } } -rogue_can_see(row, col) -int row, col; +int +rogue_can_see(int row, int col) { int retval; @@ -741,8 +744,8 @@ int row, col; return(retval); } -move_confused(monster) -object *monster; +static boolean +move_confused(object *monster) { short i, row, col; @@ -771,8 +774,8 @@ object *monster; return(0); } -flit(monster) -object *monster; +static boolean +flit(object *monster) { short i, row, col; @@ -797,7 +800,8 @@ object *monster; return(1); } -gr_obj_char() +char +gr_obj_char(void) { short r; const char *rs = "%!?]=/):*"; @@ -807,8 +811,8 @@ gr_obj_char() return(rs[r]); } -no_room_for_monster(rn) -int rn; +static boolean +no_room_for_monster(int rn) { short i, j; @@ -822,7 +826,8 @@ int rn; return(1); } -aggravate() +void +aggravate(void) { object *monster; @@ -841,9 +846,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; @@ -861,7 +864,8 @@ int row, col; return(retval); } -mv_aquatars() +void +mv_aquatars(void) { object *monster; diff --git a/games/rogue/move.c b/games/rogue/move.c index 224142b269..757ab93ed9 100644 --- a/games/rogue/move.c +++ b/games/rogue/move.c @@ -35,7 +35,7 @@ * * @(#)move.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/move.c,v 1.7 1999/11/30 03:49:24 billf Exp $ - * $DragonFly: src/games/rogue/move.c,v 1.3 2003/08/26 23:52:50 drhodus Exp $ + * $DragonFly: src/games/rogue/move.c,v 1.4 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -62,8 +62,15 @@ extern short bear_trap, haste_self, confused; extern short e_rings, regeneration, auto_search; extern boolean being_held, interrupted, r_teleport, passgo; -one_move_rogue(dirch, pickup) -short dirch, pickup; +static boolean next_to_something(int, int); +static boolean check_hunger(boolean); +static short gr_dir(void); +static void heal(void); +static boolean can_turn(short, short); +static void turn_passage(short, boolean); + +short +one_move_rogue(short dirch, short pickup) { short row, col; object *obj; @@ -76,7 +83,7 @@ short dirch, pickup; if (confused) { dirch = gr_dir(); } - (void) is_direction(dirch, &d); + is_direction(dirch, &d); get_dir_rc(d, &row, &col, 1); if (!can_move(rogue.row, rogue.col, row, col)) { @@ -88,7 +95,7 @@ short dirch, pickup; message("you are being held", 1); } else { message("you are still stuck in the bear trap", 0); - (void) reg_move(); + reg_move(); } return(MOVE_FAILED); } @@ -101,7 +108,7 @@ short dirch, pickup; } if (dungeon[row][col] & MONSTER) { rogue_hit(object_at(&level_monsters, row, col), 0); - (void) reg_move(); + reg_move(); return(MOVE_FAILED); } if (dungeon[row][col] & DOOR) { @@ -134,7 +141,7 @@ short dirch, pickup; return(STOPPED_ON_SOMETHING); } if (pickup && !levitate) { - if (obj = pick_up(row, col, &status)) { + if ((obj = pick_up(row, col, &status))) { get_desc(obj, desc); if (obj->what_is == GOLD) { free_object(obj); @@ -148,7 +155,7 @@ short dirch, pickup; } else { MOVE_ON: obj = object_at(&level_objects, row, col); - (void) strcpy(desc, "moved onto "); + strcpy(desc, "moved onto "); get_desc(obj, desc+11); goto NOT_IN_PACK; } @@ -159,14 +166,14 @@ MOVE_ON: desc[n+3] = 0; NOT_IN_PACK: message(desc, 1); - (void) reg_move(); + reg_move(); return(STOPPED_ON_SOMETHING); } if (dungeon[row][col] & (DOOR | STAIRS | TRAP)) { if ((!levitate) && (dungeon[row][col] & TRAP)) { trap_player(row, col); } - (void) reg_move(); + reg_move(); return(STOPPED_ON_SOMETHING); } MVED: if (reg_move()) { /* fainted from hunger */ @@ -175,8 +182,8 @@ MVED: if (reg_move()) { /* fainted from hunger */ return((confused ? STOPPED_ON_SOMETHING : MOVED)); } -multiple_move_rogue(dirch) -short dirch; +void +multiple_move_rogue(short dirch) { short row, col; short m; @@ -222,8 +229,8 @@ short dirch; } } -is_passable(row, col) -int row, col; +boolean +is_passable(int row, int col) { if ((row < MIN_ROW) || (row > (DROWS - 2)) || (col < 0) || (col > (DCOLS-1))) { @@ -235,8 +242,8 @@ int row, col; return(dungeon[row][col] & (FLOOR | TUNNEL | DOOR | STAIRS | TRAP)); } -next_to_something(drow, dcol) -int drow, dcol; +static boolean +next_to_something(int drow, int dcol) { short i, j, i_end, j_end, row, col; short pass_count = 0; @@ -296,7 +303,8 @@ int drow, dcol; return(0); } -can_move(row1, col1, row2, col2) +boolean +can_move(short row1, short col1, short row2, short col2) { if (!is_passable(row2, col2)) { return(0); @@ -312,7 +320,8 @@ can_move(row1, col1, row2, col2) return(1); } -move_onto() +void +move_onto(void) { short ch, d; boolean first_miss = 1; @@ -326,14 +335,12 @@ move_onto() } check_message(); if (ch != CANCEL) { - (void) one_move_rogue(ch, 0); + one_move_rogue(ch, 0); } } boolean -is_direction(c, d) -short c; -short *d; +is_direction(short c, short *d) { switch(c) { case 'h': @@ -368,26 +375,25 @@ short *d; return(1); } -boolean -check_hunger(msg_only) -boolean msg_only; +static boolean +check_hunger(boolean msg_only) { short i, n; boolean fainted = 0; if (rogue.moves_left == HUNGRY) { - (void) strcpy(hunger_str, "hungry"); + strcpy(hunger_str, "hungry"); message(hunger_str, 0); print_stats(STAT_HUNGER); } if (rogue.moves_left == WEAK) { - (void) strcpy(hunger_str, "weak"); + strcpy(hunger_str, "weak"); message(hunger_str, 1); print_stats(STAT_HUNGER); } if (rogue.moves_left <= FAINT) { if (rogue.moves_left == FAINT) { - (void) strcpy(hunger_str, "faint"); + strcpy(hunger_str, "faint"); message(hunger_str, 1); print_stats(STAT_HUNGER); } @@ -414,9 +420,6 @@ boolean msg_only; } switch(e_rings) { - /*case -2: - Subtract 0, i.e. do nothing. - break;*/ case -1: rogue.moves_left -= (rogue.moves_left % 2); break; @@ -425,12 +428,12 @@ boolean msg_only; break; case 1: rogue.moves_left--; - (void) check_hunger(1); + check_hunger(1); rogue.moves_left -= (rogue.moves_left % 2); break; case 2: rogue.moves_left--; - (void) check_hunger(1); + check_hunger(1); rogue.moves_left--; break; } @@ -438,7 +441,7 @@ boolean msg_only; } boolean -reg_move() +reg_move(void) { boolean fainted; @@ -494,7 +497,8 @@ reg_move() return(fainted); } -rest(count) +void +rest(int count) { int i; @@ -504,11 +508,12 @@ rest(count) if (interrupted) { break; } - (void) reg_move(); + reg_move(); } } -gr_dir() +static short +gr_dir(void) { short d; @@ -543,7 +548,8 @@ gr_dir() return(d); } -heal() +static void +heal(void) { static short heal_exp = -1, n, c = 0; static boolean alt; @@ -597,7 +603,7 @@ heal() if (++c >= n) { c = 0; rogue.hp_current++; - if (alt = !alt) { + if ((alt = !alt)) { rogue.hp_current++; } if ((rogue.hp_current += regeneration) > rogue.hp_max) { @@ -608,8 +614,7 @@ heal() } static 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); @@ -617,12 +622,11 @@ short nrow, ncol; return(0); } -turn_passage(dir, fast) -short dir; -boolean fast; +static void +turn_passage(short dir, boolean fast) { short crow = rogue.row, ccol = rogue.col, turns = 0; - short ndir; + short ndir = 0; if ((dir != 'h') && can_turn(crow, ccol + 1)) { turns++; diff --git a/games/rogue/object.c b/games/rogue/object.c index 8d5f81d164..0946a3d95c 100644 --- a/games/rogue/object.c +++ b/games/rogue/object.c @@ -35,7 +35,7 @@ * * @(#)object.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/object.c,v 1.5 1999/11/30 03:49:25 billf Exp $ - * $DragonFly: src/games/rogue/object.c,v 1.3 2003/08/26 23:52:50 drhodus Exp $ + * $DragonFly: src/games/rogue/object.c,v 1.4 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -61,7 +61,7 @@ char *fruit = (char *) 0; fighter rogue = { INIT_AW, /* armor, weapon */ INIT_RINGS, /* rings */ - INIT_HP, /* Hp current,max */ + INIT_HP,INIT_HP,/* Hp current,max */ INIT_STR, /* Str current,max */ INIT_PACK, /* pack */ INIT_GOLD, /* gold */ @@ -157,7 +157,19 @@ extern short cur_level, max_level; extern short party_room; extern boolean is_wood[]; -put_objects() +static void put_gold(void); +static void plant_gold(short, short, boolean); +static unsigned short gr_what_is(void); +static void gr_scroll(object *); +static void gr_potion(object *); +static void gr_weapon(object *, int); +static void gr_armor(object *); +static void gr_wand(object *); +static void make_party(void); +static void rand_place(object *); + +void +put_objects(void) { short i, n; object *obj; @@ -179,7 +191,8 @@ put_objects() put_gold(); } -put_gold() +static void +put_gold(void) { short i, j; short row,col; @@ -208,9 +221,8 @@ put_gold() } } -plant_gold(row, col, is_maze) -short row, col; -boolean is_maze; +static void +plant_gold(short row, short col, boolean is_maze) { object *obj; @@ -222,23 +234,20 @@ boolean is_maze; obj->quantity += obj->quantity / 2; } dungeon[row][col] |= OBJECT; - (void) add_to_pack(obj, &level_objects, 0); + add_to_pack(obj, &level_objects, 0); } -place_at(obj, row, col) -object *obj; -int row, col; +void +place_at(object *obj, int row, int col) { obj->row = row; obj->col = col; dungeon[row][col] |= OBJECT; - (void) add_to_pack(obj, &level_objects, 0); + add_to_pack(obj, &level_objects, 0); } object * -object_at(pack, row, col) -object *pack; -short row, col; +object_at(object *pack, short row, short col) { object *obj = (object *) 0; @@ -256,8 +265,7 @@ short row, col; } object * -get_letter_object(ch) -int ch; +get_letter_object(int ch) { object *obj; @@ -269,8 +277,8 @@ int ch; return(obj); } -free_stuff(objlist) -object *objlist; +void +free_stuff(object *objlist) { object *obj; @@ -283,8 +291,7 @@ object *objlist; } const char * -name_of(obj) -const object *obj; +name_of(const object *obj) { const char *retstring; @@ -340,7 +347,7 @@ const object *obj; } object * -gr_object() +gr_object(void) { object *obj; @@ -378,8 +385,8 @@ gr_object() return(obj); } -unsigned short -gr_what_is() +static unsigned short +gr_what_is(void) { short percent; unsigned short what_is; @@ -404,8 +411,8 @@ gr_what_is() return(what_is); } -gr_scroll(obj) -object *obj; +static void +gr_scroll(object *obj) { short percent; @@ -442,8 +449,8 @@ object *obj; } } -gr_potion(obj) -object *obj; +static void +gr_potion(object *obj) { short percent; @@ -482,9 +489,8 @@ object *obj; } } -gr_weapon(obj, assign_wk) -object *obj; -int assign_wk; +static void +gr_weapon(object *obj, int assign_wk) { short percent; short i; @@ -547,8 +553,8 @@ int assign_wk; } } -gr_armor(obj) -object *obj; +static void +gr_armor(object *obj) { short percent; short blessing; @@ -573,17 +579,16 @@ object *obj; } } -gr_wand(obj) -object *obj; +static void +gr_wand(object *obj) { obj->what_is = WAND; obj->which_kind = get_rand(0, (WANDS - 1)); obj->class = get_rand(3, 7); } -get_food(obj, force_ration) -object *obj; -boolean force_ration; +void +get_food(object *obj, boolean force_ration) { obj->what_is = FOOD; @@ -594,7 +599,8 @@ boolean force_ration; } } -put_stairs() +void +put_stairs(void) { short row, col; @@ -602,8 +608,8 @@ put_stairs() dungeon[row][col] |= STAIRS; } -get_armor_class(obj) -const object *obj; +short +get_armor_class(const object *obj) { if (obj) { return(obj->class + obj->d_enchant); @@ -612,7 +618,7 @@ const object *obj; } object * -alloc_object() +alloc_object(void) { object *obj; @@ -632,14 +638,15 @@ alloc_object() return(obj); } -free_object(obj) -object *obj; +void +free_object(object *obj) { obj->next_object = free_list; free_list = obj; } -make_party() +static void +make_party(void) { short n; @@ -651,7 +658,8 @@ make_party() } } -show_objects() +void +show_objects(void) { object *obj; short mc, rc, row, col; @@ -666,7 +674,7 @@ show_objects() rc = get_mask_char(obj->what_is); if (dungeon[row][col] & MONSTER) { - if (monster = object_at(&level_monsters, row, col)) { + if ((monster = object_at(&level_monsters, row, col))) { monster->trail_char = rc; } } @@ -688,7 +696,8 @@ show_objects() } } -put_amulet() +void +put_amulet(void) { object *obj; @@ -697,8 +706,8 @@ put_amulet() rand_place(obj); } -rand_place(obj) -object *obj; +static void +rand_place(object *obj) { short row, col; @@ -706,9 +715,10 @@ object *obj; place_at(obj, row, col); } -c_object_for_wizard() +void +c_object_for_wizard(void) { - short ch, max, wk; + short ch, max = 0, wk; object *obj; char buf[80]; @@ -780,5 +790,5 @@ GIL: } get_desc(obj, buf); message(buf, 0); - (void) add_to_pack(obj, &rogue.pack, 1); + add_to_pack(obj, &rogue.pack, 1); } diff --git a/games/rogue/pack.c b/games/rogue/pack.c index e20e1d20b3..7d03069dd8 100644 --- a/games/rogue/pack.c +++ b/games/rogue/pack.c @@ -35,7 +35,7 @@ * * @(#)pack.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/pack.c,v 1.8 1999/11/30 03:49:25 billf Exp $ - * $DragonFly: src/games/rogue/pack.c,v 1.3 2003/08/26 23:52:50 drhodus Exp $ + * $DragonFly: src/games/rogue/pack.c,v 1.4 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -50,21 +50,25 @@ * */ +#include #include "rogue.h" const char *curse_message = "you can't, it appears to be cursed"; extern short levitate; +static object *check_duplicate(object *, object *); +static int next_avail_ichar(void); +static boolean mask_pack(const object *, unsigned short); +static boolean is_pack_letter(short *, unsigned short *); + object * -add_to_pack(obj, pack, condense) -object *obj, *pack; -int condense; +add_to_pack(object *obj, object *pack, int condense) { object *op; if (condense) { - if (op = check_duplicate(obj, pack)) { + if ((op = check_duplicate(obj, pack))) { free_object(obj); return(op); } else { @@ -85,8 +89,8 @@ int condense; return(obj); } -take_from_pack(obj, pack) -object *obj, *pack; +void +take_from_pack(object *obj, object *pack) { while (pack->next_object != obj) { pack = pack->next_object; @@ -99,9 +103,7 @@ object *obj, *pack; */ object * -pick_up(row, col, status) -int row, col; -short *status; +pick_up(int row, int col, short *status) { object *obj; @@ -146,7 +148,8 @@ short *status; return(obj); } -drop() +void +drop(void) { object *obj, *new; short ch; @@ -202,15 +205,14 @@ drop() take_from_pack(obj, &rogue.pack); } place_at(obj, rogue.row, rogue.col); - (void) strcpy(desc, "dropped "); + strcpy(desc, "dropped "); get_desc(obj, desc+8); message(desc, 0); - (void) reg_move(); + reg_move(); } -object * -check_duplicate(obj, pack) -object *obj, *pack; +static object * +check_duplicate(object *obj, object *pack) { object *op; @@ -242,7 +244,8 @@ object *obj, *pack; return(0); } -next_avail_ichar() +static int +next_avail_ichar(void) { object *obj; int i; @@ -264,16 +267,16 @@ next_avail_ichar() return('?'); } -wait_for_ack() +void +wait_for_ack(void) { if (!isatty(0) || !isatty(1)) return; while (rgetchar() != ' ') ; } -pack_letter(prompt, mask) -const char *prompt; -unsigned short mask; +short +pack_letter(const char *prompt, unsigned short mask) { short ch; unsigned short tmask = mask; @@ -308,7 +311,8 @@ unsigned short mask; return(ch); } -take_off() +void +take_off(void) { char desc[DCOLS]; object *obj; @@ -320,18 +324,19 @@ take_off() mv_aquatars(); obj = rogue.armor; unwear(rogue.armor); - (void) strcpy(desc, "was wearing "); + strcpy(desc, "was wearing "); get_desc(obj, desc+12); message(desc, 0); print_stats(STAT_ARMOR); - (void) reg_move(); + reg_move(); } } else { message("not wearing any", 0); } } -wear() +void +wear(void) { short ch; object *obj; @@ -355,16 +360,16 @@ wear() return; } obj->identified = 1; - (void) strcpy(desc, "wearing "); + strcpy(desc, "wearing "); get_desc(obj, desc + 8); message(desc, 0); do_wear(obj); print_stats(STAT_ARMOR); - (void) reg_move(); + reg_move(); } -unwear(obj) -object *obj; +void +unwear(object *obj) { if (obj) { obj->in_use_flags &= (~BEING_WORN); @@ -372,15 +377,16 @@ object *obj; rogue.armor = (object *) 0; } -do_wear(obj) -object *obj; +void +do_wear(object *obj) { rogue.armor = obj; obj->in_use_flags |= BEING_WORN; obj->identified = 1; } -wield() +void +wield(void) { short ch; object *obj; @@ -409,23 +415,23 @@ wield() message("in use", 0); } else { unwield(rogue.weapon); - (void) strcpy(desc, "wielding "); + strcpy(desc, "wielding "); get_desc(obj, desc + 9); message(desc, 0); do_wield(obj); - (void) reg_move(); + reg_move(); } } -do_wield(obj) -object *obj; +void +do_wield(object *obj) { rogue.weapon = obj; obj->in_use_flags |= BEING_WIELDED; } -unwield(obj) -object *obj; +void +unwield(object *obj) { if (obj) { obj->in_use_flags &= (~BEING_WIELDED); @@ -433,7 +439,8 @@ object *obj; rogue.weapon = (object *) 0; } -call_it() +void +call_it(void) { short ch; object *obj; @@ -457,12 +464,12 @@ call_it() if (get_input_line("call it:","",buf,id_table[obj->which_kind].title,1,1)) { id_table[obj->which_kind].id_status = CALLED; - (void) strcpy(id_table[obj->which_kind].title, buf); + strcpy(id_table[obj->which_kind].title, buf); } } -pack_count(new_obj) -const object *new_obj; +short +pack_count(const object *new_obj) { object *obj; short count = 0; @@ -488,10 +495,8 @@ const object *new_obj; return(count); } -boolean -mask_pack(pack, mask) -const object *pack; -unsigned short mask; +static boolean +mask_pack(const object *pack, unsigned short mask) { while (pack->next_object) { pack = pack->next_object; @@ -502,9 +507,8 @@ unsigned short mask; return(0); } -is_pack_letter(c, mask) -short *c; -unsigned short *mask; +static boolean +is_pack_letter(short *c, unsigned short *mask) { if (((*c == '?') || (*c == '!') || (*c == ':') || (*c == '=') || (*c == ')') || (*c == ']') || (*c == '/') || (*c == ','))) { @@ -540,12 +544,14 @@ unsigned short *mask; return(((*c >= 'a') && (*c <= 'z')) || (*c == CANCEL) || (*c == LIST)); } -has_amulet() +boolean +has_amulet(void) { return(mask_pack(&rogue.pack, AMULET)); } -kick_into_pack() +void +kick_into_pack(void) { object *obj; char desc[DCOLS]; @@ -554,7 +560,7 @@ kick_into_pack() if (!(dungeon[rogue.row][rogue.col] & OBJECT)) { message("nothing here", 0); } else { - if (obj = pick_up(rogue.row, rogue.col, &stat)) { + if ((obj = pick_up(rogue.row, rogue.col, &stat))) { get_desc(obj, desc); if (obj->what_is == GOLD) { message(desc, 0); @@ -569,7 +575,7 @@ kick_into_pack() } } if (obj || (!stat)) { - (void) reg_move(); + reg_move(); } } } diff --git a/games/rogue/play.c b/games/rogue/play.c index 77da4625d9..d3f743c717 100644 --- a/games/rogue/play.c +++ b/games/rogue/play.c @@ -35,7 +35,7 @@ * * @(#)play.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/play.c,v 1.3 1999/11/30 03:49:26 billf Exp $ - * $DragonFly: src/games/rogue/play.c,v 1.2 2003/06/17 04:25:25 dillon Exp $ + * $DragonFly: src/games/rogue/play.c,v 1.3 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -59,7 +59,8 @@ extern short party_room, bear_trap; extern char hit_message[]; extern boolean wizard, trap_door; -play_level() +void +play_level(void) { short ch; int count; @@ -106,7 +107,7 @@ CH: case 'u': case 'n': case 'b': - (void) one_move_rogue(ch, 1); + one_move_rogue(ch, 1); break; case 'H': case 'J': diff --git a/games/rogue/random.c b/games/rogue/random.c index 81052807bf..b71b65738a 100644 --- a/games/rogue/random.c +++ b/games/rogue/random.c @@ -35,12 +35,11 @@ * * @(#)random.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/random.c,v 1.6 1999/11/30 03:49:26 billf Exp $ - * $DragonFly: src/games/rogue/random.c,v 1.2 2003/06/17 04:25:25 dillon Exp $ + * $DragonFly: src/games/rogue/random.c,v 1.3 2006/09/02 19:31:07 pavalos Exp $ */ #include "rogue.h" -#if 0 /* * random.c * @@ -53,67 +52,8 @@ * */ -static long rntb[32] = { - 3, 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342, - 0xde3b81e0, 0xdf0a6fb5, 0xf103bc02, 0x48f340fb, 0x7449e56b, - 0xbeb1dbb0, 0xab5c5918, 0x946554fd, 0x8c2e680f, 0xeb3d799f, - 0xb11ee0b7, 0x2d436b86, 0xda672e2a, 0x1588ca88, 0xe369735d, - 0x904f35f7, 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc, - 0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b, 0xf5ad9d0e, - 0x8999220b, 0x27fb47b9 -}; - -static long *fptr = &rntb[4]; -static long *rptr = &rntb[1]; -static long *state = &rntb[1]; -static int rand_type = 3; -static int rand_deg = 31; -static int rand_sep = 3; -static long *end_ptr = &rntb[32]; - -srrandom(x) -int x; -{ - int i; - - state[0] = (long) x; - if (rand_type != 0) { - for (i = 1; i < rand_deg; i++) { - state[i] = 1103515245 * state[i - 1] + 12345; - } - fptr = &state[rand_sep]; - rptr = &state[0]; - for (i = 0; i < 10 * rand_deg; i++) { - (void) rrandom(); - } - } -} - -long -rrandom() -{ - long i; - - if (rand_type == 0) { - i = state[0] = (state[0]*1103515245 + 12345) & 0x7fffffff; - } else { - *fptr += *rptr; - i = (*fptr >> 1) & 0x7fffffff; - if (++fptr >= end_ptr) { - fptr = state; - ++rptr; - } else { - if (++rptr >= end_ptr) { - rptr = state; - } - } - } - return(i); -} -#endif - -get_rand(x, y) -int x, y; +int +get_rand(int x, int y) { int r, t; long lr; @@ -130,13 +70,14 @@ int x, y; return(r); } -rand_percent(percentage) -int percentage; +boolean +rand_percent(int percentage) { return(get_rand(1, 100) <= percentage); } -coin_toss() +boolean +coin_toss(void) { return(((rrandom() & 01) ? 1 : 0)); diff --git a/games/rogue/ring.c b/games/rogue/ring.c index a132959610..8527f75d2c 100644 --- a/games/rogue/ring.c +++ b/games/rogue/ring.c @@ -35,7 +35,7 @@ * * @(#)ring.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/ring.c,v 1.3 1999/11/30 03:49:26 billf Exp $ - * $DragonFly: src/games/rogue/ring.c,v 1.2 2003/06/17 04:25:25 dillon Exp $ + * $DragonFly: src/games/rogue/ring.c,v 1.3 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -69,7 +69,8 @@ boolean maintain_armor; extern char *curse_message; extern boolean wizard; -put_on_ring() +void +put_on_ring(void) { short ch; char desc[DCOLS]; @@ -121,7 +122,7 @@ put_on_ring() check_message(); get_desc(ring, desc); message(desc, 0); - (void) reg_move(); + reg_move(); } /* @@ -129,9 +130,8 @@ put_on_ring() * serious problems when do_put_on() is called from read_pack() in restore(). */ -do_put_on(ring, on_left) -object *ring; -boolean on_left; +void +do_put_on(object *ring, boolean on_left) { if (on_left) { ring->in_use_flags |= ON_LEFT_HAND; @@ -142,12 +142,13 @@ boolean on_left; } } -remove_ring() +void +remove_ring(void) { boolean left = 0, right = 0; short ch; char buf[DCOLS]; - object *ring; + object *ring = NULL; if (r_rings == 0) { inv_rings(); @@ -183,16 +184,16 @@ remove_ring() message(curse_message, 0); } else { un_put_on(ring); - (void) strcpy(buf, "removed "); + strcpy(buf, "removed "); get_desc(ring, buf + 8); message(buf, 0); - (void) reg_move(); + reg_move(); } } } -un_put_on(ring) -object *ring; +void +un_put_on(object *ring) { if (ring && (ring->in_use_flags & ON_LEFT_HAND)) { ring->in_use_flags &= (~ON_LEFT_HAND); @@ -204,9 +205,8 @@ object *ring; ring_stats(1); } -gr_ring(ring, assign_wk) -object *ring; -boolean assign_wk; +void +gr_ring(object *ring, boolean assign_wk) { ring->what_is = RING; if (assign_wk) { @@ -215,22 +215,6 @@ boolean assign_wk; ring->class = 0; switch(ring->which_kind) { - /* - case STEALTH: - break; - case SLOW_DIGEST: - break; - case REGENERATION: - break; - case R_SEE_INVISIBLE: - break; - case SUSTAIN_STRENGTH: - break; - case R_MAINTAIN_ARMOR: - break; - case SEARCHING: - break; - */ case R_TELEPORT: ring->is_cursed = 1; break; @@ -245,7 +229,8 @@ boolean assign_wk; } } -inv_rings() +void +inv_rings(void) { char buf[DCOLS]; @@ -270,8 +255,8 @@ inv_rings() } } -ring_stats(pr) -boolean pr; +void +ring_stats(boolean pr) { short i; object *ring; diff --git a/games/rogue/rogue.h b/games/rogue/rogue.h index 5d66c0b9e4..98ff79ce08 100644 --- a/games/rogue/rogue.h +++ b/games/rogue/rogue.h @@ -35,10 +35,12 @@ * * @(#)rogue.h 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/rogue.h,v 1.3.2.1 2001/12/17 12:43:23 phantom Exp $ - * $DragonFly: src/games/rogue/rogue.h,v 1.3 2003/08/26 23:52:50 drhodus Exp $ + * $DragonFly: src/games/rogue/rogue.h,v 1.4 2006/09/02 19:31:07 pavalos Exp $ */ #include +#include +#include #include /* @@ -52,7 +54,7 @@ * gain or profit. */ -#define boolean char +#define boolean bool #define NOTHING ((unsigned short) 0) #define OBJECT ((unsigned short) 01) @@ -202,7 +204,7 @@ struct id { short value; char title[MAX_ID_TITLE_LEN]; - char *real; + const char *real; unsigned short id_status; }; @@ -254,10 +256,10 @@ typedef struct obj object; #define INIT_AW (object*)0,(object*)0 #define INIT_RINGS (object*)0,(object*)0 -#define INIT_HP 12,12 +#define INIT_HP 12 #define INIT_STR 16,16 #define INIT_EXP 1,0 -#define INIT_PACK {0} +#define INIT_PACK {0,"",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL} #define INIT_GOLD 0 #define INIT_CHAR '@' #define INIT_MOVES 1250 @@ -433,41 +435,6 @@ extern object level_monsters; #define MIN_ROW 1 -/* external routine declarations. - */ -const char *mon_name(); -const char *get_ench_color(); -const char *name_of(); -const char *md_gln(); -char *md_getenv(); -char *md_malloc(); -boolean is_direction(); -boolean mon_sees(); -boolean mask_pack(); -boolean mask_room(); -boolean is_digit(); -boolean check_hunger(); -boolean reg_move(); -boolean md_df(); -boolean has_been_touched(); -object *add_to_pack(); -object *alloc_object(); -object *get_letter_object(); -object *gr_monster(); -object *get_thrown_at_monster(); -object *get_zapped_monster(); -object *check_duplicate(); -object *gr_object(); -object *object_at(); -object *pick_up(); -struct id *get_id_table(); -unsigned short gr_what_is(); -#define rrandom random -#define srrandom(x) srandomdev() -long lget_number(); -long xxx(); -void byebye(), onintr(), error_save(); - struct rogue_time { short year; /* >= 1987 */ short month; /* 1 - 12 */ @@ -476,6 +443,246 @@ struct rogue_time { short minute; /* 0 - 59 */ short second; /* 0 - 59 */ }; + +/* external routine declarations. + */ +#define rrandom random +#define srrandom(x) srandomdev() + +/* hit.c */ +void mon_hit(object *); +void rogue_hit(object *, boolean); +void rogue_damage(short, object *, short); +int get_damage(const char *, boolean); +int get_number(const char *); +long lget_number(const char *); +boolean mon_damage(object *, short); +void fight(boolean); +void get_dir_rc(short, short *, short *, short); +short get_hit_chance(const object *); +short get_weapon_damage(const object *); +void s_con_mon(object *); + +/* init.c */ +boolean init(int, char**); +void clean_up(const char *); +void start_window(void); +void stop_window(void); +void byebye(void); +void onintr(void); +void error_save(void); + +/* inventory.c */ +void inventory(const object *, unsigned short); +void id_com(void); +void mix_colors(void); +void make_scroll_titles(void); +void get_desc(const object *, char *); +void get_wand_and_ring_materials(void); +void single_inv(short); +struct id *get_id_table(const object *); +void inv_armor_weapon(boolean); +void id_type(void); + +/* level.c */ +void make_level(void); +void clear_level(void); +void put_player(short); +boolean drop_check(void); +boolean check_up(void); +void add_exp(int, boolean); +int hp_raise(void); +void show_average_hp(void); + +/* machdep.c */ +#ifdef UNIX +void md_slurp(void); +void md_control_keybord(boolean); +void md_heed_signals(void); +void md_ignore_signals(void); +int md_get_file_id(const char *); +int md_link_count(const char *); +void md_gct(struct rogue_time *); +void md_gfmt(const char *, struct rogue_time *); +boolean md_df(const char *); +const char *md_gln(void); +void md_sleep(int); +char *md_getenv(const char *); +char *md_malloc(int); +int md_gseed(void); +void md_exit(int); +void md_lock(boolean); +void md_shell(const char *); +#endif + +/* message.c */ +void message(const char *, boolean); +void remessage(short); +void check_message(void); +short get_input_line(const char *, const char *, char *, + const char *, boolean, boolean); +int rgetchar(void); +void print_stats(int); +void sound_bell(void); +boolean is_digit(short); +int r_index(const char *, int, boolean); + +/* monster.c */ +void put_mons(void); +object *gr_monster(object *, int); +void mv_mons(void); +void party_monsters(int, int); +short gmc_row_col(int, int); +short gmc(object *); +void mv_1_monster(object *, short, short); +void move_mon_to(object *, short, short); +boolean mon_can_go(const object *, short, short); +void wake_up(object *); +void wake_room(short, boolean, short, short); +const char *mon_name(const object *); +void wanderer(void); +void show_monsters(void); +void create_monster(void); +int rogue_can_see(int, int); +char gr_obj_char(void); +void aggravate(void); +boolean mon_sees(const object *, int, int); +void mv_aquatars(void); + +/* move.c */ +short one_move_rogue(short, short); +void multiple_move_rogue(short); +boolean is_passable(int, int); +boolean can_move(short, short, short, short); +void move_onto(void); +boolean is_direction(short, short *); +boolean reg_move(void); +void rest(int); + +/* object.c */ +void put_objects(void); +void place_at(object *, int, int); +object *object_at(object *, short, short); +object *get_letter_object(int); +void free_stuff(object *); +const char *name_of(const object *); +object *gr_object(void); +void get_food(object *, boolean); +void put_stairs(void); +short get_armor_class(const object *); +object *alloc_object(void); +void free_object(object *); +void show_objects(void); +void put_amulet(void); +void c_object_for_wizard(void); + +/* pack.c */ +object *add_to_pack(object *, object *, int); +void take_from_pack(object *, object *); +object *pick_up(int, int, short *); +void drop(void); +void wait_for_ack(void); +short pack_letter(const char *, unsigned short); +void take_off(void); +void wear(void); +void unwear(object *); +void do_wear(object *); +void wield(void); +void do_wield(object *); +void unwield(object *); +void call_it(void); +short pack_count(const object *); +boolean has_amulet(void); +void kick_into_pack(void); + +/* play.c */ +void play_level(void); + +/* random.c */ +int get_rand(int, int); +boolean rand_percent(int); +boolean coin_toss(void); + +/* ring.c */ +void put_on_ring(void); +void do_put_on(object *, boolean); +void remove_ring(void); +void un_put_on(object *); +void gr_ring(object *, boolean); +void inv_rings(void); +void ring_stats(boolean); + +/* room.c */ +void light_up_room(int); +void light_passage(int, int); +void darken_room(short); +char get_dungeon_char(int, int); +char get_mask_char(unsigned short); +void gr_row_col(short *, short *, unsigned short); +short gr_room(void); +short party_objects(short); +short get_room_number(int, int); +boolean is_all_connected(void); +void draw_magic_map(void); +void dr_course(object *, boolean, short, short); +void edit_opts(void); +void do_shell(void); + +/* save.c */ +void save_game(void); +void save_into_file(const char *); +void restore(const char *); + +/* score.c */ +void killed_by(const object *, short); +void win(void); +void quit(boolean); +void put_scores(const object *, short); +boolean is_vowel(short); +void xxxx(char *, short); +long xxx(boolean); + +/* spec_hit.c */ +void special_hit(object *); +void rust(object *); +void cough_up(object *); +boolean seek_gold(object *); +void check_gold_seeker(object *); +boolean check_imitator(object *); +boolean imitating(short, short); +boolean m_confuse(object *); +boolean flame_broil(object *); + +/* throw.c */ +void throw(void); +void rand_around(short, short *, short *); + +/* trap.c */ +void trap_player(short, short); +void add_traps(void); +void id_trap(void); +void show_traps(void); +void search(short, boolean); + +/* use.c */ +void quaff(void); +void read_scroll(void); +void vanish(object *, short, object *); +void eat(void); +void tele(void); +void hallucinate(void); +void unhallucinate(void); +void unblind(void); +void relight(void); +void take_a_nap(void); +void cnfs(void); +void unconfuse(void); + +/* zap.c */ +void zapp(void); +void wizardize(void); +void bounce(short, short, short, short, short); + /* * external variable declarations. */ diff --git a/games/rogue/room.c b/games/rogue/room.c index 3eb8812e83..047472aa61 100644 --- a/games/rogue/room.c +++ b/games/rogue/room.c @@ -35,7 +35,7 @@ * * @(#)room.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/room.c,v 1.7 1999/11/30 03:49:26 billf Exp $ - * $DragonFly: src/games/rogue/room.c,v 1.2 2003/06/17 04:25:25 dillon Exp $ + * $DragonFly: src/games/rogue/room.c,v 1.3 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -89,20 +89,26 @@ struct option { }, { "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 void visit_rooms(int); +static boolean get_oth_room(short, short *, short *); +static void opt_show(int); +static void opt_erase(int); +static void opt_go(int); + +void +light_up_room(int rn) { short i, j; @@ -114,7 +120,7 @@ int rn; if (dungeon[i][j] & MONSTER) { object *monster; - if (monster = object_at(&level_monsters, i, j)) { + if ((monster = object_at(&level_monsters, i, j))) { dungeon[monster->row][monster->col] &= (~MONSTER); monster->trail_char = get_dungeon_char(monster->row, monster->col); @@ -128,8 +134,8 @@ int rn; } } -light_passage(row, col) -int row, col; +void +light_passage(int row, int col) { short i, j, i_end, j_end; @@ -148,8 +154,8 @@ int row, col; } } -darken_room(rn) -short rn; +void +darken_room(short rn) { short i, j; @@ -172,8 +178,8 @@ short rn; } } -get_dungeon_char(row, col) -int row, col; +char +get_dungeon_char(int row, int col) { unsigned short mask = dungeon[row][col]; @@ -220,8 +226,8 @@ int row, col; return(' '); } -get_mask_char(mask) -unsigned short mask; +char +get_mask_char(unsigned short mask) { switch(mask) { case SCROL: @@ -247,9 +253,8 @@ unsigned short mask; } } -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; @@ -268,7 +273,8 @@ unsigned short mask; *col = c; } -gr_room() +short +gr_room(void) { short i; @@ -279,7 +285,8 @@ gr_room() return(i); } -party_objects(rn) +short +party_objects(short rn) { short i, j, nf = 0; object *obj; @@ -311,8 +318,8 @@ party_objects(rn) return(nf); } -get_room_number(row, col) -int row, col; +short +get_room_number(int row, int col) { short i; @@ -325,9 +332,10 @@ int row, col; return(NO_ROOM); } -is_all_connected() +boolean +is_all_connected(void) { - short i, starting_room; + short i, starting_room = 0; for (i = 0; i < MAXROOMS; i++) { rooms_visited[i] = 0; @@ -346,8 +354,8 @@ is_all_connected() return(1); } -visit_rooms(rn) -int rn; +static void +visit_rooms(int rn) { short i; short oth_rn; @@ -362,7 +370,8 @@ int rn; } } -draw_magic_map() +void +draw_magic_map(void) { short i, j, ch, och; unsigned short mask = (HORWALL | VERTWALL | DOOR | TUNNEL | TRAP | STAIRS | @@ -398,7 +407,7 @@ draw_magic_map() if (s & MONSTER) { object *monster; - if (monster = object_at(&level_monsters, i, j)) { + if ((monster = object_at(&level_monsters, i, j))) { monster->trail_char = ch; } } @@ -408,10 +417,8 @@ draw_magic_map() } } -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; @@ -482,8 +489,8 @@ short row, col; } } -get_oth_room(rn, row, col) -short rn, *row, *col; +static boolean +get_oth_room(short rn, short *row, short *col) { short d = -1; @@ -504,7 +511,8 @@ short rn, *row, *col; return(0); } -edit_opts() +void +edit_opts(void) { char save[NOPTS+1][DCOLS]; short i, j; @@ -583,7 +591,7 @@ CH: ch = rgetchar(); } while ((ch != '\012') && (ch != '\015') && (ch != '\033')); if (j != 0) { - (void) strcpy(*(options[i].strval), buf); + strcpy(*(options[i].strval), buf); } opt_show(i); goto CH; @@ -602,8 +610,8 @@ CH: } } -opt_show(i) -int i; +static void +opt_show(int i) { const char *s; struct option *opt = &options[i]; @@ -618,8 +626,8 @@ int i; addstr(s); } -opt_erase(i) -int i; +static void +opt_erase(int i) { struct option *opt = &options[i]; @@ -627,13 +635,14 @@ int i; 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 const char *sh; diff --git a/games/rogue/save.c b/games/rogue/save.c index 19b166fb42..6934b9101c 100644 --- a/games/rogue/save.c +++ b/games/rogue/save.c @@ -35,7 +35,7 @@ * * @(#)save.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/save.c,v 1.6 1999/11/30 03:49:27 billf Exp $ - * $DragonFly: src/games/rogue/save.c,v 1.3 2003/08/26 23:52:50 drhodus Exp $ + * $DragonFly: src/games/rogue/save.c,v 1.4 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -51,13 +51,13 @@ */ #include +#include #include "rogue.h" short write_failed = 0; char *save_file = (char *) 0; static char save_name[80]; -extern boolean detect_monster; extern short cur_level, max_level; extern short party_room; extern short foods; @@ -78,7 +78,21 @@ extern short m_moves; extern boolean msg_cleared; -save_game() +static void del_save_file(void); +static void write_pack(const object *, FILE *); +static void read_pack(object *, FILE *, boolean); +static void rw_dungeon(FILE *, boolean); +static void rw_id(struct id *, FILE *, int, boolean); +static void write_string(char *, FILE *); +static void read_string(char *, FILE *, size_t); +static void rw_rooms(FILE *, boolean); +static void r_read(FILE *, char *, int); +static void r_write(FILE *, const char *, int); +static boolean has_been_touched(const struct rogue_time *, + const struct rogue_time *); + +void +save_game(void) { char fname[64]; @@ -91,8 +105,8 @@ save_game() save_into_file(fname); } -save_into_file(sfile) -const char *sfile; +void +save_into_file(const char *sfile) { FILE *fp; int file_id; @@ -102,15 +116,15 @@ const char *sfile; struct rogue_time rt_buf; if (sfile[0] == '~') { - if (hptr = md_getenv("HOME")) { + if ((hptr = md_getenv("HOME"))) { len = strlen(hptr) + strlen(sfile); name_buffer = md_malloc(len); if (name_buffer == NULL) { message("out of memory for save file name", 0); sfile = error_file; } else { - (void) strcpy(name_buffer, hptr); - (void) strcat(name_buffer, sfile+1); + strcpy(name_buffer, hptr); + strcat(name_buffer, sfile+1); sfile = name_buffer; } @@ -125,7 +139,7 @@ const char *sfile; } md_ignore_signals(); write_failed = 0; - (void) xxx(1); + 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)); @@ -165,7 +179,7 @@ const char *sfile; fclose(fp); if (write_failed) { - (void) md_df(sfile); /* delete file */ + md_df(sfile); /* delete file */ } else { if (strcmp(sfile, save_name) == 0) save_name[0] = 0; @@ -173,7 +187,8 @@ const char *sfile; } } -static del_save_file() +static void +del_save_file(void) { if (!save_name[0]) return; @@ -182,10 +197,10 @@ static del_save_file() md_df(save_name); } -restore(fname) -const char *fname; +void +restore(const char *fname) { - FILE *fp; + FILE *fp = NULL; struct rogue_time saved_time, mod_time; char buf[4]; char tbuf[40]; @@ -198,13 +213,13 @@ const char *fname; if (md_link_count(fname) > 1) { clean_up("file has link"); } - (void) xxx(1); + 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)); read_string(hunger_str, fp, sizeof hunger_str); - (void) strlcpy(tbuf, login_name, sizeof tbuf); + strlcpy(tbuf, login_name, sizeof tbuf); read_string(login_name, fp, sizeof login_name); if (strcmp(tbuf, login_name)) { clean_up("you're not the original player"); @@ -263,23 +278,20 @@ const char *fname; fclose(fp); } -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) { + while ((pack = pack->next_object)) { r_write(fp, (const char *) pack, sizeof(object)); } t.ichar = t.what_is = 0; r_write(fp, (const char *) &t, sizeof(object)); } -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; @@ -306,9 +318,8 @@ boolean is_rogue; } } -rw_dungeon(fp, rw) -FILE *fp; -boolean rw; +static void +rw_dungeon(FILE *fp, boolean rw) { short i, j; char buf[DCOLS]; @@ -330,11 +341,8 @@ boolean rw; } } -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; @@ -353,9 +361,8 @@ boolean wr; } } -write_string(s, fp) -char *s; -FILE *fp; +static void +write_string(char *s, FILE *fp) { short n; @@ -365,23 +372,20 @@ FILE *fp; r_write(fp, s, n); } -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)); - if (n > len) + if (n > (short)len) clean_up("read_string: corrupt game file"); r_read(fp, s, n); xxxx(s, n); } -rw_rooms(fp, rw) -FILE *fp; -boolean rw; +static void +rw_rooms(FILE *fp, boolean rw) { short i; @@ -391,23 +395,19 @@ boolean rw; } } -r_read(fp, buf, n) -FILE *fp; -char *buf; -int n; +static void +r_read(FILE *fp, char *buf, int n) { - if (fread(buf, sizeof(char), n, fp) != n) { + if (fread(buf, sizeof(char), n, fp) != (unsigned)n) { clean_up("read() failed, don't know why"); } } -r_write(fp, buf, n) -FILE *fp; -const char *buf; -int n; +static void +r_write(FILE *fp, const char *buf, int n) { if (!write_failed) { - if (fwrite(buf, sizeof(char), n, fp) != n) { + if (fwrite(buf, sizeof(char), n, fp) != (unsigned)n) { message("write() failed, don't know why", 0); sound_bell(); write_failed = 1; @@ -415,9 +415,9 @@ int 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); diff --git a/games/rogue/score.c b/games/rogue/score.c index 06c693f02e..2cda7083da 100644 --- a/games/rogue/score.c +++ b/games/rogue/score.c @@ -35,7 +35,7 @@ * * @(#)score.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/score.c,v 1.4 1999/11/30 03:49:27 billf Exp $ - * $DragonFly: src/games/rogue/score.c,v 1.3 2003/08/26 23:52:50 drhodus Exp $ + * $DragonFly: src/games/rogue/score.c,v 1.4 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -59,9 +59,18 @@ extern short max_level; extern boolean score_only, no_skull, msg_cleared; extern char *byebye_string, *nick_name; -killed_by(monster, other) -const object *monster; -short other; +static void insert_score(char [][82], char [][30], const char *, short, short, + const object *, short); +static void sell_pack(void); +static int get_value(const object *); +static void id_all(void); +static int name_cmp(char *, const char *); +static void nickize(char *, const char *, const char *); +static void center(short, const char *); +static void sf_error(void); + +void +killed_by(const object *monster, short other) { char buf[128]; @@ -74,31 +83,31 @@ short other; if (other) { switch(other) { case HYPOTHERMIA: - (void) strcpy(buf, "died of hypothermia"); + strcpy(buf, "died of hypothermia"); break; case STARVATION: - (void) strcpy(buf, "died of starvation"); + strcpy(buf, "died of starvation"); break; case POISON_DART: - (void) strcpy(buf, "killed by a dart"); + strcpy(buf, "killed by a dart"); break; case QUIT: - (void) strcpy(buf, "quit"); + strcpy(buf, "quit"); break; case KFIRE: - (void) strcpy(buf, "killed by fire"); + strcpy(buf, "killed by fire"); break; } } else { - (void) strcpy(buf, "Killed by "); + strcpy(buf, "Killed by "); if (is_vowel(m_names[monster->m_char - 'A'][0])) { - (void) strcat(buf, "an "); + strcat(buf, "an "); } else { - (void) strcat(buf, "a "); + strcat(buf, "a "); } - (void) strcat(buf, m_names[monster->m_char - 'A']); + strcat(buf, m_names[monster->m_char - 'A']); } - (void) strcat(buf, " with "); + strcat(buf, " with "); sprintf(buf+strlen(buf), "%ld gold", rogue.gold); if ((!other) && (!no_skull)) { clear(); @@ -127,7 +136,8 @@ short other; put_scores(monster, other); } -win() +void +win(void) { unwield(rogue.weapon); /* disarm and relax */ unwear(rogue.armor); @@ -150,12 +160,14 @@ win() put_scores((object *) 0, WIN); } -quit(from_intrpt) -boolean from_intrpt; +void +quit(boolean from_intrpt) { char buf[128]; short i, orow, ocol; boolean mc; + + orow = ocol = mc = 0; md_ignore_signals(); @@ -191,9 +203,8 @@ boolean from_intrpt; killed_by((object *) 0, QUIT); } -put_scores(monster, other) -const object *monster; -short other; +void +put_scores(const object *monster, short other) { short i, n, rank = 10, x, ne = 0, found_player = -1; char scores[10][82]; @@ -211,7 +222,7 @@ short other; sf_error(); } rewind(fp); - (void) xxx(1); + xxx(1); for (i = 0; i < 10; i++) { if (((n = fread(scores[i], sizeof(char), 80, fp)) < 80) && (n != 0)) { @@ -244,8 +255,8 @@ short other; if (found_player != -1) { ne--; for (i = found_player; i < ne; i++) { - (void) strcpy(scores[i], scores[i+1]); - (void) strcpy(n_names[i], n_names[i+1]); + strcpy(scores[i], scores[i+1]); + strcpy(n_names[i], n_names[i+1]); } } if (!score_only) { @@ -282,7 +293,7 @@ short other; md_ignore_signals(); - (void) xxx(1); + xxx(1); for (i = 0; i < ne; i++) { if (i == rank) { @@ -317,12 +328,9 @@ short other; clean_up(""); } -insert_score(scores, n_names, n_name, rank, n, monster, other) -char scores[][82]; -char n_names[][30]; -const char *n_name; -short rank, n; -const object *monster; +static void +insert_score(char scores[][82], char n_names[][30], const char *n_name, + short rank, short n, const object *monster, short other) { short i; char buf[128]; @@ -330,8 +338,8 @@ const object *monster; if (n > 0) { for (i = n; i > rank; i--) { if ((i < 10) && (i > 0)) { - (void) strcpy(scores[i], scores[i-1]); - (void) strcpy(n_names[i], n_names[i-1]); + strcpy(scores[i], scores[i-1]); + strcpy(n_names[i], n_names[i-1]); } } } @@ -340,47 +348,47 @@ const object *monster; if (other) { switch(other) { case HYPOTHERMIA: - (void) strcat(buf, "died of hypothermia"); + strcat(buf, "died of hypothermia"); break; case STARVATION: - (void) strcat(buf, "died of starvation"); + strcat(buf, "died of starvation"); break; case POISON_DART: - (void) strcat(buf, "killed by a dart"); + strcat(buf, "killed by a dart"); break; case QUIT: - (void) strcat(buf, "quit"); + strcat(buf, "quit"); break; case WIN: - (void) strcat(buf, "a total winner"); + strcat(buf, "a total winner"); break; case KFIRE: - (void) strcpy(buf, "killed by fire"); + strcpy(buf, "killed by fire"); break; } } else { - (void) strcat(buf, "killed by "); + strcat(buf, "killed by "); if (is_vowel(m_names[monster->m_char - 'A'][0])) { - (void) strcat(buf, "an "); + strcat(buf, "an "); } else { - (void) strcat(buf, "a "); + strcat(buf, "a "); } - (void) strcat(buf, m_names[monster->m_char - 'A']); + strcat(buf, m_names[monster->m_char - 'A']); } sprintf(buf+strlen(buf), " on level %d ", max_level); if ((other != WIN) && has_amulet()) { - (void) strcat(buf, "with amulet"); + strcat(buf, "with amulet"); } for (i = strlen(buf); i < 79; i++) { buf[i] = ' '; } buf[79] = 0; - (void) strcpy(scores[rank], buf); - (void) strcpy(n_names[rank], n_name); + strcpy(scores[rank], buf); + strcpy(n_names[rank], n_name); } -is_vowel(ch) -short ch; +boolean +is_vowel(short ch) { return( (ch == 'a') || (ch == 'e') || @@ -389,7 +397,8 @@ short ch; (ch == 'u') ); } -sell_pack() +static void +sell_pack(void) { object *obj; short row = 2, val; @@ -421,11 +430,11 @@ sell_pack() message("", 0); } -get_value(obj) -const object *obj; +static int +get_value(const object *obj) { short wc; - int val; + int val = 0; wc = obj->which_kind; @@ -468,7 +477,8 @@ const object *obj; return(val); } -id_all() +static void +id_all(void) { short i; @@ -489,9 +499,8 @@ id_all() } } -name_cmp(s1, s2) -char *s1; -const char *s2; +static int +name_cmp(char *s1, const char *s2) { short i = 0; int r; @@ -505,9 +514,8 @@ const char *s2; return(r); } -xxxx(buf, n) -char *buf; -short n; +void +xxxx(char *buf, short n) { short i; unsigned char c; @@ -522,8 +530,7 @@ short n; } long -xxx(st) -boolean st; +xxx(boolean st) { static long f, s; long r; @@ -539,22 +546,21 @@ boolean st; return(r); } -nickize(buf, score, n_name) -char *buf; -const char *score, *n_name; +static void +nickize(char *buf, const char *score, const char *n_name) { short i = 15, j; if (!n_name[0]) { - (void) strcpy(buf, score); + strcpy(buf, score); } else { - (void) strncpy(buf, score, 16); + strncpy(buf, score, 16); while (score[i] != ':') { i++; } - (void) strcpy(buf+15, n_name); + strcpy(buf+15, n_name); j = strlen(buf); while (score[i]) { @@ -565,9 +571,8 @@ const char *score, *n_name; } } -center(row, buf) -short row; -const char *buf; +static void +center(short row, const char *buf) { short margin; @@ -575,7 +580,8 @@ const char *buf; mvaddstr(row, margin, buf); } -sf_error() +static void +sf_error(void) { md_lock(0); message("", 1); diff --git a/games/rogue/spec_hit.c b/games/rogue/spec_hit.c index 2694d2d8d4..7c12aeb49f 100644 --- a/games/rogue/spec_hit.c +++ b/games/rogue/spec_hit.c @@ -35,7 +35,7 @@ * * @(#)spec_hit.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/spec_hit.c,v 1.4 1999/11/30 03:49:28 billf Exp $ - * $DragonFly: src/games/rogue/spec_hit.c,v 1.2 2003/06/17 04:25:25 dillon Exp $ + * $DragonFly: src/games/rogue/spec_hit.c,v 1.3 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -61,8 +61,19 @@ extern boolean detect_monster, mon_disappeared; extern boolean sustain_strength, maintain_armor; extern char *you_can_move_again; -special_hit(monster) -object *monster; +static void freeze(object *); +static void steal_gold(object *); +static void steal_item(object *); +static void disappear(object *); +static boolean try_to_cough(short, short, object *); +static boolean gold_at(short, short); +static void sting(object *); +static void drop_level(void); +static void drain_life(void); +static short get_dir(short, short, short, short); + +void +special_hit(object *monster) { if ((monster->m_flags & CONFUSED) && rand_percent(66)) { return; @@ -92,8 +103,8 @@ object *monster; } } -rust(monster) -object *monster; +void +rust(object *monster) { if ((!rogue.armor) || (get_armor_class(rogue.armor) <= 1) || (rogue.armor->which_kind == LEATHER)) { @@ -111,8 +122,8 @@ object *monster; } } -freeze(monster) -object *monster; +static void +freeze(object *monster) { short freeze_percent = 99; short i, n; @@ -144,8 +155,8 @@ object *monster; } } -steal_gold(monster) -object *monster; +static void +steal_gold(object *monster) { int amount; @@ -164,11 +175,11 @@ object *monster; disappear(monster); } -steal_item(monster) -object *monster; +static void +steal_item(object *monster) { object *obj; - short i, n, t; + short i, n, t = 0; char desc[80]; boolean has_something = 0; @@ -203,7 +214,7 @@ object *monster; } } } - (void) strcpy(desc, "she stole "); + strcpy(desc, "she stole "); if (obj->what_is != WEAPON) { t = obj->quantity; obj->quantity = 1; @@ -218,8 +229,8 @@ DSPR: disappear(monster); } -disappear(monster) -object *monster; +static void +disappear(object *monster) { short row, col; @@ -235,8 +246,8 @@ object *monster; mon_disappeared = 1; } -cough_up(monster) -object *monster; +void +cough_up(object *monster) { object *obj; short row, col, i, n; @@ -279,9 +290,8 @@ object *monster; free_object(obj); } -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))) { return(0); @@ -298,8 +308,8 @@ object *obj; return(0); } -seek_gold(monster) -object *monster; +boolean +seek_gold(object *monster) { short i, j, rn, s; @@ -330,8 +340,8 @@ object *monster; return(0); } -gold_at(row, col) -short row, col; +static boolean +gold_at(short row, short col) { if (dungeon[row][col] & OBJECT) { object *obj; @@ -344,14 +354,14 @@ short row, col; return(0); } -check_gold_seeker(monster) -object *monster; +void +check_gold_seeker(object *monster) { monster->m_flags &= (~SEEKS_GOLD); } -check_imitator(monster) -object *monster; +boolean +check_imitator(object *monster) { char msg[80]; @@ -369,13 +379,13 @@ object *monster; return(0); } -imitating(row, col) -short row, col; +boolean +imitating(short row, short col) { if (dungeon[row][col] & MONSTER) { - object *object_at(), *monster; + object *monster; - if (monster = object_at(&level_monsters, row, col)) { + if ((monster = object_at(&level_monsters, row, col))) { if (monster->m_flags & IMITATES) { return(1); } @@ -384,8 +394,8 @@ short row, col; return(0); } -sting(monster) -object *monster; +static void +sting(object *monster) { short sting_chance = 35; char msg[80]; @@ -407,7 +417,8 @@ object *monster; } } -drop_level() +static void +drop_level(void) { int hp; @@ -426,7 +437,8 @@ drop_level() add_exp(1, 0); } -drain_life() +static void +drain_life(void) { short n; @@ -454,8 +466,8 @@ drain_life() print_stats((STAT_STRENGTH | STAT_HP)); } -m_confuse(monster) -object *monster; +boolean +m_confuse(object *monster) { char msg[80]; @@ -476,8 +488,8 @@ object *monster; return(0); } -flame_broil(monster) -object *monster; +boolean +flame_broil(object *monster) { short row, col, dir; @@ -502,8 +514,8 @@ object *monster; return(1); } -get_dir(srow, scol, drow, dcol) -short srow, scol, drow, dcol; +static short +get_dir(short srow, short scol, short drow, short dcol) { if (srow == drow) { if (scol < dcol) { diff --git a/games/rogue/throw.c b/games/rogue/throw.c index 87628fa329..37dc6ebe4f 100644 --- a/games/rogue/throw.c +++ b/games/rogue/throw.c @@ -35,7 +35,7 @@ * * @(#)throw.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/throw.c,v 1.3 1999/11/30 03:49:28 billf Exp $ - * $DragonFly: src/games/rogue/throw.c,v 1.2 2003/06/17 04:25:25 dillon Exp $ + * $DragonFly: src/games/rogue/throw.c,v 1.3 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -56,7 +56,12 @@ extern short cur_room; extern char *curse_message; extern char hit_message[]; -throw() +static boolean throw_at_monster(object *, object *); +static object *get_thrown_at_monster(object *, short, short *, short *); +static void flop_weapon(object *, short, short); + +void +throw(void) { short wch, d; boolean first_miss = 1; @@ -119,8 +124,8 @@ throw() vanish(weapon, 1, &rogue.pack); } -throw_at_monster(monster, weapon) -object *monster, *weapon; +static boolean +throw_at_monster(object *monster, object *weapon) { short damage, hit_chance; short t; @@ -145,20 +150,17 @@ object *monster, *weapon; weapon->quantity = t; if (!rand_percent(hit_chance)) { - (void) strcat(hit_message, "misses "); + strcat(hit_message, "misses "); return(0); } s_con_mon(monster); - (void) strcat(hit_message, "hit "); - (void) mon_damage(monster, damage); + strcat(hit_message, "hit "); + mon_damage(monster, damage); return(1); } -object * -get_thrown_at_monster(obj, dir, row, col) -object *obj; -short dir; -short *row, *col; +static object * +get_thrown_at_monster(object *obj, short dir, short *row, short *col) { short orow, ocol; short i, ch; @@ -199,9 +201,8 @@ short *row, *col; return(0); } -flop_weapon(weapon, row, col) -object *weapon; -short row, col; +static void +flop_weapon(object *weapon, short row, short col) { object *new_weapon, *monster; short i = 0; @@ -235,7 +236,7 @@ short row, col; dch = get_dungeon_char(row, col); if (mon) { mch = mvinch(row, col); - if (monster = object_at(&level_monsters, row, col)) { + if ((monster = object_at(&level_monsters, row, col))) { monster->trail_char = dch; } if ((mch < 'A') || (mch > 'Z')) { @@ -258,8 +259,8 @@ short row, col; } } -rand_around(i, r, c) -short i, *r, *c; +void +rand_around(short i, short *r, short *c) { static char pos[] = "\010\007\001\003\004\005\002\006\0"; static short row, col; diff --git a/games/rogue/trap.c b/games/rogue/trap.c index 81cbfea06c..89f32dc7fb 100644 --- a/games/rogue/trap.c +++ b/games/rogue/trap.c @@ -35,7 +35,7 @@ * * @(#)trap.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/trap.c,v 1.6 1999/11/30 03:49:28 billf Exp $ - * $DragonFly: src/games/rogue/trap.c,v 1.2 2003/06/17 04:25:25 dillon Exp $ + * $DragonFly: src/games/rogue/trap.c,v 1.3 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -78,8 +78,10 @@ extern short ring_exp; extern boolean sustain_strength; extern short blind; -trap_at(row, col) -int row, col; +static short trap_at(int, int); + +static short +trap_at(int row, int col) { short i; @@ -91,8 +93,8 @@ int row, col; return(NO_TRAP); } -trap_player(row, col) -short row, col; +void +trap_player(short row, short col) { short t; @@ -143,7 +145,8 @@ short row, col; } } -add_traps() +void +add_traps(void) { short i, n, tries = 0; short row, col; @@ -187,7 +190,8 @@ add_traps() } } -id_trap() +void +id_trap(void) { short dir, row, col, d, t; @@ -214,7 +218,8 @@ id_trap() } } -show_traps() +void +show_traps(void) { short i, j; @@ -227,9 +232,8 @@ show_traps() } } -search(n, is_auto) -short n; -boolean is_auto; +void +search(short n, boolean is_auto) { short s, i, j, row, col, t; short shown = 0, found = 0; @@ -277,7 +281,7 @@ boolean is_auto; } } if ((!is_auto) && (reg_search = !reg_search)) { - (void) reg_move(); + reg_move(); } } } diff --git a/games/rogue/use.c b/games/rogue/use.c index 45c61e91cb..22318e3a41 100644 --- a/games/rogue/use.c +++ b/games/rogue/use.c @@ -35,7 +35,7 @@ * * @(#)use.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/use.c,v 1.4 1999/11/30 03:49:29 billf Exp $ - * $DragonFly: src/games/rogue/use.c,v 1.3 2003/08/26 23:52:50 drhodus Exp $ + * $DragonFly: src/games/rogue/use.c,v 1.4 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -70,7 +70,15 @@ extern boolean being_held; extern char *fruit, *you_can_move_again; extern boolean sustain_strength; -quaff() +static void potion_heal(boolean); +static void idntfy(void); +static void hold_monster(void); +static void go_blind(void); +static const char *get_ench_color(void); +static void uncurse_all(void); + +void +quaff(void) { short ch; char buf[80]; @@ -157,7 +165,7 @@ quaff() case LEVITATION: message("you start to float in the air", 0); levitate += get_rand(15, 30); - being_held = bear_trap = 0; + bear_trap = being_held = 0; break; case HASTE_SELF: message("you feel yourself moving much faster", 0); @@ -183,7 +191,8 @@ quaff() vanish(obj, 1, &rogue.pack); } -read_scroll() +void +read_scroll(void) { short ch; object *obj; @@ -295,10 +304,8 @@ read_scroll() * arrow (or whatever) in the quiver. It will only decrement the count. */ -vanish(obj, rm, pack) -object *obj; -short rm; -object *pack; +void +vanish(object *obj, short rm, object *pack) { if (obj->quantity > 1) { obj->quantity--; @@ -314,11 +321,12 @@ object *pack; free_object(obj); } if (rm) { - (void) reg_move(); + reg_move(); } } -potion_heal(extra) +static void +potion_heal(boolean extra) { float ratio; short add; @@ -363,7 +371,8 @@ potion_heal(extra) } } -idntfy() +static void +idntfy(void) { short ch; object *obj; @@ -390,7 +399,8 @@ AGAIN: message(desc, 0); } -eat() +void +eat(void) { short ch; short moves; @@ -431,7 +441,8 @@ eat() vanish(obj, 1, &rogue.pack); } -hold_monster() +static void +hold_monster(void) { short i, j; short mcount = 0; @@ -463,7 +474,8 @@ hold_monster() } } -tele() +void +tele(void) { mvaddch(rogue.row, rogue.col, get_dungeon_char(rogue.row, rogue.col)); @@ -475,7 +487,8 @@ tele() bear_trap = 0; } -hallucinate() +void +hallucinate(void) { object *obj, *monster; short ch; @@ -504,14 +517,16 @@ hallucinate() } } -unhallucinate() +void +unhallucinate(void) { halluc = 0; relight(); message("everything looks SO boring now", 1); } -unblind() +void +unblind(void) { blind = 0; message("the veil of darkness lifts", 1); @@ -524,7 +539,8 @@ unblind() } } -relight() +void +relight(void) { if (cur_room == PASSAGE) { light_passage(rogue.row, rogue.col); @@ -534,7 +550,8 @@ relight() mvaddch(rogue.row, rogue.col, rogue.fchar); } -take_a_nap() +void +take_a_nap(void) { short i; @@ -548,7 +565,8 @@ take_a_nap() message(you_can_move_again, 0); } -go_blind() +static void +go_blind(void) { short i, j; @@ -579,8 +597,8 @@ go_blind() mvaddch(rogue.row, rogue.col, rogue.fchar); } -const char * -get_ench_color() +static const char * +get_ench_color(void) { if (halluc) { return(id_potions[get_rand(0, POTIONS-1)].title); @@ -590,12 +608,14 @@ get_ench_color() return("blue "); } -cnfs() +void +cnfs(void) { confused += get_rand(12, 22); } -unconfuse() +void +unconfuse(void) { char msg[80]; @@ -604,7 +624,8 @@ unconfuse() message(msg, 1); } -uncurse_all() +static void +uncurse_all(void) { object *obj; diff --git a/games/rogue/zap.c b/games/rogue/zap.c index 445ea2aefb..1b492d0956 100644 --- a/games/rogue/zap.c +++ b/games/rogue/zap.c @@ -35,7 +35,7 @@ * * @(#)zap.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/rogue/zap.c,v 1.3 1999/11/30 03:49:29 billf Exp $ - * $DragonFly: src/games/rogue/zap.c,v 1.2 2003/06/17 04:25:25 dillon Exp $ + * $DragonFly: src/games/rogue/zap.c,v 1.3 2006/09/02 19:31:07 pavalos Exp $ */ /* @@ -57,7 +57,13 @@ boolean wizard = 0; extern boolean being_held, score_only, detect_monster; extern short cur_room; -zapp() +static object *get_zapped_monster(short, short *, short *); +static void zap_monster(object *, unsigned short); +static void tele_away(object *); +static void wdrain_life(object *); + +void +zapp(void) { short wch; boolean first_miss = 1; @@ -108,13 +114,11 @@ zapp() } } } - (void) reg_move(); + 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; @@ -134,9 +138,8 @@ short *row, *col; } } -zap_monster(monster, kind) -object *monster; -unsigned short kind; +static void +zap_monster(object *monster, unsigned short kind) { short row, col; object *nm; @@ -173,7 +176,7 @@ unsigned short kind; } nm = monster->next_monster; tc = monster->trail_char; - (void) gr_monster(monster, get_rand(0, MONSTERS-1)); + gr_monster(monster, get_rand(0, MONSTERS-1)); monster->row = row; monster->col = col; monster->next_monster = nm; @@ -201,8 +204,8 @@ unsigned short kind; } } -tele_away(monster) -object *monster; +static void +tele_away(object *monster) { short row, col; @@ -220,7 +223,8 @@ object *monster; } } -wizardize() +void +wizardize(void) { char buf[100]; @@ -229,7 +233,7 @@ wizardize() message("not wizard anymore", 0); } else { if (get_input_line("wizard's password:", "", buf, "", 0, 0)) { - (void) xxx(1); + xxx(1); xxxx(buf, strlen(buf)); if (!strncmp(buf, "\247\104\126\272\115\243\027", 7)) { wizard = 1; @@ -242,8 +246,8 @@ wizardize() } } -wdrain_life(monster) -object *monster; +static void +wdrain_life(object *monster) { short hp; object *lmon, *nm; @@ -257,22 +261,22 @@ object *monster; nm = lmon->next_monster; if (get_room_number(lmon->row, lmon->col) == cur_room) { wake_up(lmon); - (void) mon_damage(lmon, hp); + mon_damage(lmon, hp); } lmon = nm; } } else { if (monster) { wake_up(monster); - (void) mon_damage(monster, hp); + mon_damage(monster, hp); } } print_stats(STAT_HP); relight(); } -bounce(ball, dir, row, col, r) -short ball, dir, row, col, r; +void +bounce(short ball, short dir, short row, short col, short r) { short orow, ocol; char buf[DCOLS]; @@ -348,7 +352,7 @@ short ball, dir, row, col, r; } sprintf(buf, "the %s hits the %s", s, mon_name(monster)); message(buf, 0); - (void) mon_damage(monster, damage); + mon_damage(monster, damage); } else { damage = -1; if (!(monster->m_flags & FREEZES)) { @@ -365,7 +369,7 @@ short ball, dir, row, col, r; if (damage != -1) { sprintf(buf, "the %s hits the %s", s, mon_name(monster)); message(buf, 0); - (void) mon_damage(monster, damage); + mon_damage(monster, damage); } } } else if ((row == rogue.row) && (col == rogue.col)) { -- 2.41.0