From 384386d71c5afc5c40c2d8039a0ce1fa1437537b Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Sat, 23 Jan 2016 09:35:14 -0500 Subject: [PATCH 1/7] rogue3, rogue5: fix all GCC5 warnings. GCC5 enables more warnings by default, including pre-ANSI implicit function definitions. These two games now build cleanly, but the others will require more effort. --- rogue3/main.c | 5 ++--- rogue5/pack.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/rogue3/main.c b/rogue3/main.c index 33060d9..da50954 100644 --- a/rogue3/main.c +++ b/rogue3/main.c @@ -25,9 +25,8 @@ WINDOW *mw; /* Used to store mosnters */ FILE *scoreboard = NULL; FILE *logfi = NULL; -main(argc, argv, envp) -char **argv; -char **envp; +int +main(int argc, char *argv[], char *envp[]) { char *env; struct linked_list *item; diff --git a/rogue5/pack.c b/rogue5/pack.c index ced82d5..2a62d30 100644 --- a/rogue5/pack.c +++ b/rogue5/pack.c @@ -21,8 +21,8 @@ * If this was the object of something's desire, that monster will * get mad and run at the hero */ -update_mdest(obj) -register THING *obj; +void +update_mdest(THING *obj) { register THING *mp; From c1d6a6af6aeb01e42fe6a736efd19358dbf8eba4 Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Wed, 27 Jan 2016 19:41:05 -0500 Subject: [PATCH 2/7] rogue4: fix most GCC5 warnings. Converting all function definitions to ANSI style accounts for most of the change. This has exposed other problems, such as daemons not actually being their stated type, that will require more careful solutions. --- rogue4/armor.c | 9 ++- rogue4/chase.c | 40 ++++++------ rogue4/command.c | 41 +++++++++--- rogue4/daemon.c | 34 +++++----- rogue4/daemons.c | 24 ++++--- rogue4/extern.h | 12 +--- rogue4/fight.c | 91 +++++++++++++-------------- rogue4/init.c | 28 ++++++--- rogue4/io.c | 38 ++++++----- rogue4/list.c | 18 +++--- rogue4/mach_dep.c | 51 +++++++++------ rogue4/main.c | 28 +++++---- rogue4/mdport.c | 4 +- rogue4/misc.c | 52 ++++++++------- rogue4/monsters.c | 29 ++++----- rogue4/move.c | 25 ++++---- rogue4/new_level.c | 16 +++-- rogue4/options.c | 40 ++++++------ rogue4/pack.c | 35 +++++------ rogue4/passages.c | 28 ++++++--- rogue4/potions.c | 10 +-- rogue4/rings.c | 18 +++--- rogue4/rip.c | 18 +++--- rogue4/rogue.h | 153 ++++++++++++++++++++++++++++++++++++++++++++- rogue4/rooms.c | 34 +++++----- rogue4/save.c | 28 ++++----- rogue4/scrolls.c | 3 +- rogue4/state.c | 2 +- rogue4/sticks.c | 20 +++--- rogue4/things.c | 38 +++++------ rogue4/weapons.c | 36 +++++------ rogue4/wizard.c | 16 +++-- 32 files changed, 625 insertions(+), 394 deletions(-) diff --git a/rogue4/armor.c b/rogue4/armor.c index adfaa18..6955ecb 100644 --- a/rogue4/armor.c +++ b/rogue4/armor.c @@ -16,7 +16,8 @@ * wear: * The player wants to wear something, so let him/her put it on. */ -wear() +void +wear(void) { register THING *obj; register char *sp; @@ -50,7 +51,8 @@ wear() * take_off: * Get the armor off of the players back */ -take_off() +void +take_off(void) { register THING *obj; @@ -77,7 +79,8 @@ take_off() * waste_time: * Do nothing but let other things happen */ -waste_time() +void +waste_time(void) { do_daemons(BEFORE); do_fuses(BEFORE); diff --git a/rogue4/chase.c b/rogue4/chase.c index 956d5cb..4c3d43e 100644 --- a/rogue4/chase.c +++ b/rogue4/chase.c @@ -10,6 +10,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include #include #include "rogue.h" @@ -17,11 +18,16 @@ coord ch_ret; /* Where chasing takes you */ +bool chase(THING *tp, coord *ee); +int do_chase(THING *th); +coord *find_dest(THING *tp); + /* * runners: * Make all the running monsters move. */ -runners() +void +runners(void) { register THING *tp; register THING *ntp; @@ -46,8 +52,8 @@ runners() * do_chase: * Make one thing chase another. */ -do_chase(th) -register THING *th; +int +do_chase(THING *th) { register struct room *rer, *ree; /* room of chaser, room of chasee */ register int mindist = 32767, i, dist; @@ -184,8 +190,8 @@ over: * see_monst: * Return TRUE if the hero can see the monster */ -see_monst(mp) -register THING *mp; +bool +see_monst(THING *mp) { if (on(player, ISBLIND)) return FALSE; @@ -203,9 +209,8 @@ register THING *mp; * Set a mosnter running after something or stop it from running * (for when it dies) */ -runto(runner, spot) -register coord *runner; -coord *spot; +void +runto(coord *runner, coord *spot) { register THING *tp; @@ -234,9 +239,8 @@ coord *spot; * chasee(ee). Returns TRUE if we want to keep on chasing later * FALSE if we reach the goal. */ -chase(tp, ee) -THING *tp; -coord *ee; +bool +chase(THING *tp, coord *ee) { register int x, y; register int dist, thisdist; @@ -339,8 +343,7 @@ coord *ee; * in any room. */ struct room * -roomin(cp) -register coord *cp; +roomin(coord *cp) { register struct room *rp; register char *fp; @@ -360,8 +363,8 @@ register coord *cp; * diag_ok: * Check to see if the move is legal if it is diagonal */ -diag_ok(sp, ep) -register coord *sp, *ep; +bool +diag_ok(coord *sp, coord *ep) { if (ep->x == sp->x || ep->y == sp->y) return TRUE; @@ -372,8 +375,8 @@ register coord *sp, *ep; * cansee: * Returns true if the hero can see a certain coordinate. */ -cansee(y, x) -register int y, x; +bool +cansee(int y, int x) { register struct room *rer; coord tp; @@ -396,8 +399,7 @@ register int y, x; * find the proper destination for the monster */ coord * -find_dest(tp) -register THING *tp; +find_dest(THING *tp) { register THING *obj; register int prob; diff --git a/rogue4/command.c b/rogue4/command.c index a32f72f..15b9e69 100644 --- a/rogue4/command.c +++ b/rogue4/command.c @@ -19,15 +19,30 @@ char countch, direction, newcount = FALSE; +void call(void); +void d_level(void); +void help(void); +void identify(void); +void illcom(char ch); +void search(void); +void u_level(void); + +#ifdef WIZARD +extern void add_pass(void); +extern void create_obj(void); +extern bool passwd(void); +extern void show_map(void); +#endif + /* * command: * Process the user commands */ -command() +void +command(void) { register char ch; register int ntimes = 1; /* Number of player moves */ - char *unctrol(); if (on(player, ISHASTE)) ntimes++; @@ -344,8 +359,8 @@ command() * illcom: * What to do with an illegal command */ -illcom(ch) -char ch; +void +illcom(char ch) { save_msg = FALSE; count = 0; @@ -357,7 +372,8 @@ char ch; * search: * Player gropes about him to find hidden things. */ -search() +void +search(void) { register int y, x; register char *fp; @@ -400,7 +416,8 @@ search() * help: * Give single character help, or the whole mess if he wants it */ -help() +void +help(void) { register const struct h_list *strp = helpstr; register char helpch; @@ -457,7 +474,8 @@ help() * identify: * Tell the player what a certain thing is. */ -identify() +void +identify(void) { register char ch; register const char *str; @@ -502,7 +520,8 @@ identify() * d_level: * He wants to go down a level */ -d_level() +void +d_level(void) { if (chat(hero.y, hero.x) != STAIRS) msg("I see no way down"); @@ -517,7 +536,8 @@ d_level() * u_level: * He wants to go up a level */ -u_level() +void +u_level(void) { if (chat(hero.y, hero.x) == STAIRS) if (amulet) @@ -538,7 +558,8 @@ u_level() * call: * Allow a user to call a potion, scroll, or ring something */ -call() +void +call(void) { register THING *obj; register char **guess; diff --git a/rogue4/daemon.c b/rogue4/daemon.c index 00aad6c..fa02989 100644 --- a/rogue4/daemon.c +++ b/rogue4/daemon.c @@ -29,7 +29,7 @@ struct delayed_action d_list[MAXDAEMONS] = { * Find an empty slot in the daemon/fuse list */ struct delayed_action * -d_slot() +d_slot(void) { register int i; register struct delayed_action *dev; @@ -48,8 +48,7 @@ d_slot() * Find a particular slot in the table */ struct delayed_action * -find_slot(func) -register int (*func)(); +find_slot(int (*func)()) { register int i; register struct delayed_action *dev; @@ -64,8 +63,8 @@ register int (*func)(); * start_daemon: * Start a daemon, takes a function. */ -start_daemon(func, arg, type) -int (*func)(), arg, type; +void +start_daemon(int (*func)(), int arg, int type) { register struct delayed_action *dev; @@ -80,8 +79,8 @@ int (*func)(), arg, type; * kill_daemon: * Remove a daemon from the list */ -kill_daemon(func) -int (*func)(); +void +kill_daemon(int (*func)()) { register struct delayed_action *dev; @@ -98,8 +97,8 @@ int (*func)(); * Run all the daemons that are active with the current flag, * passing the argument to the function. */ -do_daemons(flag) -register int flag; +void +do_daemons(int flag) { register struct delayed_action *dev; @@ -118,8 +117,8 @@ register int flag; * fuse: * Start a fuse to go off in a certain number of turns */ -fuse(func, arg, time, type) -int (*func)(), arg, time, type; +void +fuse(int (*func)(), int arg, int time, int type) { register struct delayed_action *wire; @@ -134,9 +133,8 @@ int (*func)(), arg, time, type; * lengthen: * Increase the time until a fuse goes off */ -lengthen(func, xtime) -int (*func)(); -int xtime; +void +lengthen(int (*func)(), int xtime) { register struct delayed_action *wire; @@ -149,8 +147,8 @@ int xtime; * extinguish: * Put out a fuse */ -extinguish(func) -int (*func)(); +void +extinguish(int (*func)()) { register struct delayed_action *wire; @@ -163,8 +161,8 @@ int (*func)(); * do_fuses: * Decrement counters and start needed fuses */ -do_fuses(flag) -register int flag; +void +do_fuses(int flag) { register struct delayed_action *wire; diff --git a/rogue4/daemons.c b/rogue4/daemons.c index b88a313..2076096 100644 --- a/rogue4/daemons.c +++ b/rogue4/daemons.c @@ -19,7 +19,8 @@ int between = 0; * doctor: * A healing daemon that restors hit points after rest */ -doctor() +void +doctor(void) { register int lv, ohp; @@ -50,7 +51,8 @@ doctor() * Swander: * Called when it is time to start rolling for wandering monsters */ -swander() +void +swander(void) { start_daemon(rollwand, 0, BEFORE); } @@ -59,7 +61,8 @@ swander() * rollwand: * Called to roll to see if a wandering monster starts up */ -rollwand() +void +rollwand(void) { if (++between >= 4) { @@ -77,7 +80,8 @@ rollwand() * unconfuse: * Release the poor player from his confusion */ -unconfuse() +void +unconfuse(void) { player.t_flags &= ~ISHUH; msg("you feel less confused now"); @@ -87,7 +91,8 @@ unconfuse() * unsee: * Turn off the ability to see invisible */ -unsee() +void +unsee(void) { register THING *th; @@ -104,7 +109,8 @@ unsee() * sight: * He gets his sight back */ -sight() +void +sight(void) { if (on(player, ISBLIND)) { @@ -120,7 +126,8 @@ sight() * nohaste: * End the hasting */ -nohaste() +void +nohaste(void) { player.t_flags &= ~ISHASTE; msg("you feel yourself slowing down"); @@ -130,7 +137,8 @@ nohaste() * stomach: * Digest the hero's food */ -stomach() +void +stomach(void) { register int oldfood; diff --git a/rogue4/extern.h b/rogue4/extern.h index 198243c..c3a8f18 100644 --- a/rogue4/extern.h +++ b/rogue4/extern.h @@ -52,17 +52,9 @@ extern WINDOW *hw; * Function types */ -char *charge_str(), *ctime(), *getenv(), *inv_name(), - *killname(), *nothing(), *num(), *ring_num(), - *tr_name(), - *unctrol(), *vowelstr(); +char *ctime(), *getenv(); -void leave(int), quit(int), tstp(), auto_save(int), endit(int); -int doctor(), nohaste(), - rollwand(), runners(), sight(), stomach(), swander(), - turn_see(), unconfuse(), unsee(); - -void checkout(); +void tstp(), endit(int); long lseek(); diff --git a/rogue4/fight.c b/rogue4/fight.c index 14e22e5..2c0ae82 100644 --- a/rogue4/fight.c +++ b/rogue4/fight.c @@ -10,6 +10,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include #include #include #include @@ -20,15 +21,20 @@ long e_levels[] = { 40920L, 81920L, 163840L, 327680L, 655360L, 1310720L, 2621440L, 0L }; +bool roll_em(THING *thatt, THING *thdef, THING *weap, bool hurl); +void hit(char *er, char *ee); +void miss(char *er, char *ee); +int str_plus(str_t str); +int add_dam(str_t str); +void thunk(THING *weap, const char *mname); +void bounce(THING *weap, const char *mname); + /* * fight: * The player attacks the monster. */ -fight(mp, mn, weap, thrown) -register coord *mp; -char mn; -register THING *weap; -bool thrown; +bool +fight(coord *mp, char mn, THING *weap, bool thrown) { register THING *tp; register bool did_hit = TRUE; @@ -96,8 +102,8 @@ bool thrown; * attack: * The monster attacks the player */ -attack(mp) -register THING *mp; +int +attack(THING *mp) { register const char *mname; @@ -295,8 +301,8 @@ register THING *mp; * swing: * Returns true if the swing hits */ -swing(at_lvl, op_arm, wplus) -int at_lvl, op_arm, wplus; +bool +swing(int at_lvl, int op_arm, int wplus) { register int res = rnd(20); register int need = (20 - at_lvl) - op_arm; @@ -308,7 +314,8 @@ int at_lvl, op_arm, wplus; * check_level: * Check to see if the guy has gone up a level. */ -check_level() +void +check_level(void) { register int i, add, olevel; @@ -332,9 +339,8 @@ check_level() * roll_em: * Roll several attacks */ -roll_em(thatt, thdef, weap, hurl) -THING *thatt, *thdef, *weap; -bool hurl; +bool +roll_em(THING *thatt, THING *thdef, THING *weap, bool hurl) { register struct stats *att, *def; register char *cp; @@ -440,9 +446,7 @@ bool hurl; * The print name of a combatant */ char * -prname(who, upper) -register char *who; -bool upper; +prname(char *who, bool upper) { static char tbuf[MAXSTR]; @@ -465,8 +469,8 @@ bool upper; * hit: * Print a message to indicate a succesful hit */ -hit(er, ee) -register char *er, *ee; +void +hit(char *er, char *ee) { register char *s = ""; @@ -491,8 +495,8 @@ register char *er, *ee; * miss: * Print a message to indicate a poor swing */ -miss(er, ee) -register char *er, *ee; +void +miss(char *er, char *ee) { register char *s = ""; @@ -514,9 +518,8 @@ register char *er, *ee; * save_throw: * See if a creature save against something */ -save_throw(which, tp) -int which; -THING *tp; +bool +save_throw(int which, THING *tp) { register int need; @@ -528,8 +531,8 @@ THING *tp; * save: * See if he saves against various nasty things */ -save(which) -register int which; +bool +save(int which) { if (which == VS_MAGIC) { @@ -545,8 +548,8 @@ register int which; * str_plus: * Compute bonus/penalties for strength on the "to hit" roll */ -str_plus(str) -register str_t str; +int +str_plus(str_t str) { if (str == 31) return 3; @@ -563,9 +566,9 @@ register str_t str; * add_dam: * Compute additional damage done for exceptionally high or low strength */ - add_dam(str) - register str_t str; - { +int +add_dam(str_t str) +{ if (str == 31) return 6; if (str > 21) @@ -587,7 +590,8 @@ register str_t str; * raise_level: * The guy just magically went up a level. */ -raise_level() +void +raise_level(void) { pstats.s_exp = e_levels[pstats.s_lvl-1] + 1L; check_level(); @@ -597,9 +601,8 @@ raise_level() * thunk: * A missile hits a monster */ -thunk(weap, mname) -register THING *weap; -register const char *mname; +void +thunk(THING *weap, const char *mname) { if (weap->o_type == WEAPON) addmsg("the %s hits ", w_names[weap->o_which]); @@ -615,9 +618,8 @@ register const char *mname; * bounce: * A missile misses a monster */ -bounce(weap, mname) -register THING *weap; -register const char *mname; +void +bounce(THING *weap, const char *mname) { if (weap->o_type == WEAPON) addmsg("the %s misses ", w_names[weap->o_which]); @@ -633,10 +635,8 @@ register const char *mname; * remove: * Remove a monster from the screen */ -remove_monster(mp, tp, waskill) -register coord *mp; -register THING *tp; -bool waskill; +void +remove_monster(coord *mp, THING *tp, bool waskill) { register THING *obj, *nexti; @@ -660,8 +660,8 @@ bool waskill; * is_magic: * Returns true if an object radiates magic */ -is_magic(obj) -register THING *obj; +bool +is_magic(THING *obj) { switch (obj->o_type) { @@ -683,9 +683,8 @@ register THING *obj; * killed: * Called to put a monster to death */ -killed(tp, pr) -register THING *tp; -bool pr; +void +killed(THING *tp, bool pr) { pstats.s_exp += tp->t_stats.s_exp; /* diff --git a/rogue4/init.c b/rogue4/init.c index 62be503..4f1b83d 100644 --- a/rogue4/init.c +++ b/rogue4/init.c @@ -16,11 +16,16 @@ #include #include "rogue.h" +#ifdef WIZARD +void badcheck(char *name, struct magic_item *magic, int bound); +#endif + /* * init_player: * Roll up the rogue */ -init_player() +void +init_player(void) { register THING *obj; @@ -236,7 +241,8 @@ const char *metal[NMETAL] = { * init_things * Initialize the probabilities for types of things */ -init_things() +void +init_things(void) { register struct magic_item *mp; @@ -251,7 +257,8 @@ init_things() * init_colors: * Initialize the potion color scheme for this time */ -init_colors() +void +init_colors(void) { register int i, j; bool used[NCOLORS]; @@ -281,7 +288,8 @@ init_colors() */ #define MAXNAME 40 /* Max number of characters in a name */ -init_names() +void +init_names(void) { register int nsyl; register char *cp; @@ -322,7 +330,8 @@ init_names() * init_stones: * Initialize the ring stone setting scheme for this time */ -init_stones() +void +init_stones(void) { register int i, j; bool used[NSTONES]; @@ -351,7 +360,8 @@ init_stones() * init_materials: * Initialize the construction materials for wands and staffs */ -init_materials() +void +init_materials(void) { register int i, j; register const char *str; @@ -402,10 +412,8 @@ init_materials() * badcheck: * Check to see if a series of probabilities sums to 100 */ -badcheck(name, magic, bound) -char *name; -register struct magic_item *magic; -register int bound; +void +badcheck(char *name, struct magic_item *magic, int bound) { register struct magic_item *end; diff --git a/rogue4/io.c b/rogue4/io.c index 5d09970..768602c 100644 --- a/rogue4/io.c +++ b/rogue4/io.c @@ -16,6 +16,8 @@ #include "rogue.h" #include +void doadd(char *fmt, va_list ap); + /* * msg: * Display a message at the top of the screen. @@ -23,6 +25,7 @@ static char msgbuf[BUFSIZ]; static int newpos = 0; +void msg(char *fmt, ...) { va_list ap; @@ -50,6 +53,7 @@ msg(char *fmt, ...) * Add things to the current message */ +void addmsg(char *fmt, ...) { va_list ap; @@ -65,7 +69,8 @@ addmsg(char *fmt, ...) * if it is up there with the --More--) */ -endmsg() +void +endmsg(void) { if (save_msg) { @@ -99,6 +104,7 @@ endmsg() * Perform an add onto the message buffer */ +void doadd(char *fmt, va_list ap) { vsprintf(&msgbuf[newpos], fmt, ap); @@ -109,7 +115,8 @@ doadd(char *fmt, va_list ap) * step_ok: * Returns true if it is ok to step on ch */ -step_ok(ch) +bool +step_ok(char ch) { switch (ch) { @@ -127,8 +134,8 @@ step_ok(ch) * Flushes stdout so that screen is up to date and then returns * getchar(). */ -readcharw(win) -WINDOW *win; +int +readcharw(WINDOW *win) { int ch; @@ -143,14 +150,14 @@ WINDOW *win; return(ch); } -readchar() +int +readchar(void) { return( readcharw(stdscr) ); } char * -unctrol(ch) -char ch; +unctrol(char ch) { return( (char *) unctrl(ch) ); } @@ -159,7 +166,8 @@ char ch; * status: * Display the important stats line. Keep the cursor where it was. */ -status() +void +status(void) { register int oy, ox, temp; static int hpwidth = 0, s_hungry; @@ -215,15 +223,14 @@ status() -wait_for(ch) -register char ch; +void +wait_for(char ch) { w_wait_for(stdscr, ch); } -w_wait_for(win,ch) -WINDOW *win; -register char ch; +void +w_wait_for(WINDOW *win, char ch) { register char c; @@ -239,9 +246,8 @@ register char ch; * show_win: * Function used to display a window and wait before returning */ -show_win(scr, message) -register WINDOW *scr; -char *message; +void +show_win(WINDOW *scr, char *message) { mvwaddstr(scr, 0, 0, message); touchwin(scr); diff --git a/rogue4/list.c b/rogue4/list.c index 352e6fe..6d1f2c6 100644 --- a/rogue4/list.c +++ b/rogue4/list.c @@ -18,8 +18,8 @@ * detach: * Takes an item out of whatever linked list it might be in */ -_detach(list, item) -register THING **list, *item; +void +_detach(THING **list, THING *item) { if (*list == item) *list = next(item); @@ -33,8 +33,8 @@ register THING **list, *item; * _attach: * add an item to the head of a list */ -_attach(list, item) -register THING **list, *item; +void +_attach(THING **list, THING *item) { if (*list != NULL) { @@ -54,8 +54,8 @@ register THING **list, *item; * _free_list: * Throw the whole blamed thing away */ -_free_list(ptr) -register THING **ptr; +void +_free_list(THING **ptr) { register THING *item; @@ -71,8 +71,8 @@ register THING **ptr; * discard: * Free up an item */ -discard(item) -register THING *item; +void +discard(THING *item) { total--; free((char *) item); @@ -83,7 +83,7 @@ register THING *item; * Get a new item with a specified size */ THING * -new_item() +new_item(void) { register THING *item; diff --git a/rogue4/mach_dep.c b/rogue4/mach_dep.c index 87d73a0..313d620 100644 --- a/rogue4/mach_dep.c +++ b/rogue4/mach_dep.c @@ -47,11 +47,17 @@ static char *lockfile = LOCKFILE; #endif #endif +int too_much(void); +bool author(void); +void checkout(int s); +void chmsg(char *fmt, int arg); + /* * init_check: * Check out too see if it is proper to play the game now */ -init_check() +void +init_check(void) { if (too_much()) { @@ -70,7 +76,8 @@ init_check() * Open up the score file for future use, and then * setuid(getuid()) in case we are running setuid. */ -open_score() +void +open_score(void) { #ifdef SCOREFILE fd = open(SCOREFILE, O_RDWR | O_CREAT, 0666 ); @@ -82,7 +89,8 @@ open_score() return; } -void open_log(void) +void +open_log(void) { #ifdef LOGFILE lfd = open(LOGFILE, O_WRONLY | O_APPEND | O_CREAT, 0666); @@ -96,12 +104,10 @@ void open_log(void) * setup: * Get starting setup for all games */ -setup() +void +setup(void) { void auto_save(), quit(), endit(), tstp(); -#ifdef CHECKTIME - int checkout(); -#endif /* * make sure that large terminals don't overflow the bounds @@ -158,7 +164,8 @@ setup() * start_score: * Start the scoring sequence */ -start_score() +void +start_score(void) { #ifdef SIGALRM signal(SIGALRM, SIG_IGN); @@ -169,8 +176,8 @@ start_score() * issymlink: * See if the file has a symbolic link */ -issymlink(sp) -char *sp; +bool +issymlink(char *sp) { #ifdef S_IFLNK struct stat sbuf2; @@ -188,7 +195,8 @@ char *sp; * too_much: * See if the system is being used too much for this game */ -too_much() +int +too_much(void) { #ifdef MAXLOAD double avec[3]; @@ -208,7 +216,8 @@ too_much() * author: * See if a user is an author of the program */ -author() +bool +author(void) { #ifdef WIZARD if (wizard) @@ -246,7 +255,7 @@ checkout(int s) if (author()) { num_checks = 1; - chmsg("The load is rather high, O exaulted one"); + chmsg("The load is rather high, O exaulted one", 0); } else if (num_checks++ == 3) fatal("Sorry. You took to long. You are dead\n"); @@ -265,7 +274,7 @@ checkout(int s) if (num_checks) { num_checks = 0; - chmsg("The load has dropped back down. You have a reprieve"); + chmsg("The load has dropped back down. You have a reprieve", 0); } #ifdef CHECKTIME #ifdef SIGALRM @@ -280,9 +289,8 @@ checkout(int s) * checkout()'s version of msg. If we are in the middle of a * shell, do a printf instead of a msg to avoid the refresh. */ -chmsg(fmt, arg) -char *fmt; -int arg; +void +chmsg(char *fmt, int arg) { if (in_shell) { @@ -299,7 +307,8 @@ int arg; * lock the score file. If it takes too long, ask the user if * they care to wait. Return TRUE if the lock is successful. */ -lock_sc() +bool +lock_sc(void) { #ifdef SCOREFILE #ifdef LOCKFILE @@ -361,7 +370,8 @@ over: * unlock_sc: * Unlock the score file */ -unlock_sc() +void +unlock_sc(void) { #ifdef SCOREFILE #ifdef LOCKFILE @@ -374,7 +384,8 @@ unlock_sc() * flush_type: * Flush typeahead for traps, etc. */ -flush_type() +void +flush_type(void) { flushinp(); } diff --git a/rogue4/main.c b/rogue4/main.c index 404d623..d08bd9b 100644 --- a/rogue4/main.c +++ b/rogue4/main.c @@ -18,15 +18,15 @@ #include #include #include +#include #include "rogue.h" /* * main: * The main program, of course */ -main(argc, argv, envp) -char **argv; -char **envp; +int +main(int argc, char *argv[], char *envp[]) { register char *env; int lowtime; @@ -113,7 +113,7 @@ char **envp; if (argc == 2 && strcmp(argv[1], "-s") == 0) { noscore = TRUE; - score(0, -1); + score(0, -1, 0); exit(0); } init_check(); /* check for legal startup */ @@ -227,8 +227,8 @@ endit(int a) * fatal: * Exit the program, printing a message. */ -fatal(s) -char *s; +void +fatal(char *s) { clear(); move(LINES-2, 0); @@ -242,8 +242,8 @@ char *s; * rnd: * Pick a very random number. */ -rnd(range) -register int range; +int +rnd(int range) { return range == 0 ? 0 : abs((int) RN) % range; } @@ -252,8 +252,8 @@ register int range; * roll: * Roll a number of dice */ -roll(number, sides) -register int number, sides; +int +roll(int number, int sides) { register int dtotal = 0; @@ -299,7 +299,8 @@ tstp(int a) * The main loop of the program. Loop until the game is over, * refreshing things and looking at the proper times. */ -playit() +void +playit(void) { register char *opts; @@ -352,7 +353,7 @@ quit(int a) move(LINES - 1, 0); refresh(); writelog(purse, 1, 0); - score(purse, 1); + score(purse, 1, 0); printf("[Press return to exit]\n"); fflush(NULL); getchar(); @@ -391,7 +392,8 @@ leave(int sig) * shell: * Let him escape for a while */ -shell() +void +shell(void) { /* * Set the terminal back to original mode diff --git a/rogue4/mdport.c b/rogue4/mdport.c index 102bba4..5b27636 100644 --- a/rogue4/mdport.c +++ b/rogue4/mdport.c @@ -59,6 +59,7 @@ char *strdup(const char *s); #endif +#include #include #include #include @@ -465,7 +466,7 @@ md_getrealname(int uid) #endif } -extern char *xcrypt(char *key, char *salt); +extern char *xcrypt(const char *key, const char *setting); char * md_crypt(char *key, char *salt) @@ -1046,6 +1047,7 @@ md_readchar(WINDOW *win) int mode2 = M_NORMAL; int nodelayf = 0; int count = 0; + extern void auto_save(int sig); for(;;) { diff --git a/rogue4/misc.c b/rogue4/misc.c index 2b5dcb9..6fe845d 100644 --- a/rogue4/misc.c +++ b/rogue4/misc.c @@ -21,8 +21,7 @@ * Print the name of a trap */ char * -tr_name(type) -char type; +tr_name(char type) { switch (type) { @@ -47,8 +46,8 @@ char type; * look: * A quick glance all around the player */ -look(wakeup) -bool wakeup; +void +look(bool wakeup) { register int x, y; register unsigned char ch; @@ -204,8 +203,7 @@ bool wakeup; * Find the unclaimed object at y, x */ THING * -find_obj(y, x) -register int y, x; +find_obj(int y, int x) { register THING *op; @@ -225,7 +223,8 @@ register int y, x; * eat: * She wants to eat something, so let her try */ -eat() +void +eat(void) { register THING *obj; @@ -272,8 +271,8 @@ eat() * Used to modify the playes strength. It keeps track of the * highest it has been, just in case */ -chg_str(amt) -register int amt; +void +chg_str(int amt) { str_t comp; @@ -293,9 +292,8 @@ register int amt; * add_str: * Perform the actual add, checking upper and lower bound limits */ -add_str(sp, amt) -register str_t *sp; -int amt; +void +add_str(str_t *sp, int amt) { if ((*sp += amt) < 3) *sp = 3; @@ -307,8 +305,8 @@ int amt; * add_haste: * Add a haste to the player */ -add_haste(potion) -bool potion; +bool +add_haste(bool potion) { if (on(player, ISHASTE)) { @@ -332,7 +330,8 @@ bool potion; * aggravate: * Aggravate all the monsters on this level */ -aggravate() +void +aggravate(void) { register THING *mi; @@ -346,8 +345,7 @@ aggravate() * "an". */ char * -vowelstr(str) -register char *str; +vowelstr(char *str) { switch (*str) { @@ -366,8 +364,8 @@ register char *str; * is_current: * See if the object is one of the currently used items */ -is_current(obj) -register THING *obj; +bool +is_current(THING *obj) { if (obj == NULL) return FALSE; @@ -387,7 +385,8 @@ register THING *obj; * Set up the direction co_ordinate for use in varios "prefix" * commands */ -get_dir() +bool +get_dir(void) { register char *prompt; register bool gotit; @@ -430,8 +429,8 @@ get_dir() * sign: * Return the sign of the number */ -sign(nm) -register int nm; +int +sign(int nm) { if (nm < 0) return -1; @@ -443,8 +442,8 @@ register int nm; * spread: * Give a spread around a given number (+/- 10%) */ -spread(nm) -register int nm; +int +spread(int nm) { return nm - nm / 10 + rnd(nm / 5); } @@ -453,9 +452,8 @@ register int nm; * call_it: * Call an object something after use. */ -call_it(know, guess) -register bool know; -register char **guess; +void +call_it(bool know, char **guess) { if (know && *guess) { diff --git a/rogue4/monsters.c b/rogue4/monsters.c index a9aace9..b979fcb 100644 --- a/rogue4/monsters.c +++ b/rogue4/monsters.c @@ -15,6 +15,8 @@ #include #include "rogue.h" +int exp_add(THING *tp); + /* * List of monsters in rough order of vorpalness * @@ -39,8 +41,8 @@ char wand_mons[] = { * Pick a monster to show up. The lower the level, * the meaner the monster. */ -randmonster(wander) -bool wander; +char +randmonster(bool wander) { register int d; register char *mons; @@ -61,10 +63,8 @@ bool wander; * new_monster: * Pick a new monster and add it to the list */ -new_monster(tp, type, cp) -register THING *tp; -char type; -register coord *cp; +void +new_monster(THING *tp, char type, coord *cp) { register struct monster *mp; register int lev_add; @@ -109,8 +109,8 @@ register coord *cp; * expadd: * Experience to add for this monster's level/hit points */ -exp_add(tp) -register THING *tp; +int +exp_add(THING *tp) { register int mod; @@ -129,7 +129,8 @@ register THING *tp; * wanderer: * Create a new wandering monster and aim it at the player */ -wanderer() +void +wanderer(void) { register int i; register struct room *rp; @@ -166,8 +167,7 @@ wanderer() * What to do when the hero steps next to a monster */ THING * -wake_monster(y, x) -int y, x; +wake_monster(int y, int x) { register THING *tp; register struct room *rp; @@ -226,7 +226,8 @@ int y, x; * genocide: * Wipe one monster out of existence (for now...) */ -genocide() +void +genocide(void) { register THING *mp; register char c; @@ -270,8 +271,8 @@ genocide() * give_pack: * Give a pack to a monster if it deserves one */ -give_pack(tp) -register THING *tp; +void +give_pack(THING *tp) { if (rnd(100) < monsters[tp->t_type-'A'].m_carry) attach(tp->t_pack, new_thing()); diff --git a/rogue4/move.c b/rogue4/move.c index 106b5f1..9004c92 100644 --- a/rogue4/move.c +++ b/rogue4/move.c @@ -14,6 +14,9 @@ #include #include "rogue.h" +void turnref(void); +char be_trapped(coord *tc); + /* * Used to hold the new hero position */ @@ -24,8 +27,8 @@ coord nh; * do_run: * Start the hero running */ -do_run(ch) -char ch; +void +do_run(char ch) { running = TRUE; after = FALSE; @@ -37,8 +40,8 @@ char ch; * Check to see that a move is legal. If it is handle the * consequences (fighting, picking up, etc.) */ -do_move(dy, dx) -int dy, dx; +void +do_move(int dy, int dx) { register char ch, fl; @@ -189,7 +192,8 @@ move_stuff: * turnref: * Decide whether to refresh at a passage turning or not */ -turnref() +void +turnref(void) { register int index; @@ -211,8 +215,8 @@ turnref() * Called to illuminate a room. If it is dark, remove anything * that might move. */ -door_open(rp) -struct room *rp; +void +door_open(struct room *rp) { register int j, k; register char ch; @@ -238,8 +242,8 @@ struct room *rp; * be_trapped: * The guy stepped on a trap.... Make him pay. */ -be_trapped(tc) -register coord *tc; +char +be_trapped(coord *tc) { register char tr; register int index; @@ -316,8 +320,7 @@ register coord *tc; * Move in a random direction if the monster/person is confused */ coord * -rndmove(who) -THING *who; +rndmove(THING *who) { register int x, y; register char ch; diff --git a/rogue4/new_level.c b/rogue4/new_level.c index 2978f9f..6bacf6d 100644 --- a/rogue4/new_level.c +++ b/rogue4/new_level.c @@ -11,6 +11,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include #include #include #include @@ -20,7 +21,11 @@ #define MAXTREAS 10 /* maximum number of treasures in a treasure room */ #define MINTREAS 2 /* minimum number of treasures in a treasure room */ -new_level() +void put_things(void); +void treas_room(void); + +void +new_level(void) { register int rm, i; register THING *tp; @@ -112,7 +117,8 @@ new_level() * rnd_room: * Pick a room that is really there */ -rnd_room() +int +rnd_room(void) { register int rm; @@ -127,7 +133,8 @@ rnd_room() * put_things: * Put potions and scrolls on this level */ -put_things() +void +put_things(void) { register int i; register THING *cur; @@ -197,7 +204,8 @@ put_things() */ #define MAXTRIES 10 /* max number of tries to put down a monster */ -treas_room() +void +treas_room(void) { register int nm, index; register THING *tp; diff --git a/rogue4/options.c b/rogue4/options.c index cdba3d3..a4bc062 100644 --- a/rogue4/options.c +++ b/rogue4/options.c @@ -36,7 +36,10 @@ typedef struct optstruct OPTION; int allowchange(OPTION *opt); -int put_bool(), get_bool(), put_str(), get_str(); +void put_bool(bool *b); +void put_str(char *str); +int get_bool(bool *bp, WINDOW *win); +int get_str(char *opt, WINDOW *win); OPTION optlist[] = { {"terse", "Terse output: ", @@ -63,7 +66,8 @@ OPTION optlist[] = { * option: * Print and then set options from the terminal */ -option() +void +option(void) { register OPTION *op; register int retval; @@ -125,8 +129,8 @@ option() * put_bool * Put out a boolean */ -put_bool(b) -bool *b; +void +put_bool(bool *b) { waddstr(hw, *b ? "True" : "False"); } @@ -135,8 +139,8 @@ bool *b; * put_str: * Put out a string */ -put_str(str) -char *str; +void +put_str(char *str) { waddstr(hw, str); } @@ -145,9 +149,8 @@ char *str; * get_bool: * Allow changing a boolean option and print it out */ -get_bool(bp, win) -bool *bp; -WINDOW *win; +int +get_bool(bool *bp, WINDOW *win) { register int oy, ox; register bool op_bad; @@ -196,9 +199,8 @@ WINDOW *win; */ #define MAXINP 50 /* max string to read from terminal or environment */ -get_str(opt, win) -register char *opt; -WINDOW *win; +int +get_str(char *opt, WINDOW *win) { register char *sp; register int c, oy, ox; @@ -274,9 +276,8 @@ WINDOW *win; * get_num: * Get a numeric option */ -get_num(opt, win) -short *opt; -WINDOW *win; +int +get_num(short *opt, WINDOW *win) { register int i; char buf[MAXSTR]; @@ -295,8 +296,8 @@ WINDOW *win; * being "name=....", with the string being defined up to a comma * or the end of the entire option string. */ -parse_opts(str) -register char *str; +void +parse_opts(char *str) { register char *sp; register OPTION *op; @@ -373,9 +374,8 @@ register char *str; * strucpy: * Copy string using unctrol for things */ -strucpy(s1, s2, len) -register char *s1, *s2; -register int len; +void +strucpy(char *s1, char *s2, int len) { if (len > MAXINP) len = MAXINP; diff --git a/rogue4/pack.c b/rogue4/pack.c index cd5dba8..9f254a2 100644 --- a/rogue4/pack.c +++ b/rogue4/pack.c @@ -14,14 +14,16 @@ #include #include "rogue.h" +void money(int value); + /* * update_mdest: * Called after picking up an object, before discarding it. * If this was the object of something's desire, that monster will * get mad and run at the hero */ -update_mdest(obj) -register THING *obj; +void +update_mdest(THING *obj) { register THING *mp; @@ -36,9 +38,8 @@ register THING *obj; * non-null use it as the linked_list pointer instead of gettting * it off the ground. */ -add_pack(obj, silent) -register THING *obj; -bool silent; +void +add_pack(THING *obj, bool silent) { register THING *op, *lp = NULL; register bool exact, from_floor; @@ -216,9 +217,8 @@ picked_up: * inventory: * List what is in the pack */ -inventory(list, type) -THING *list; -int type; +bool +inventory(THING *list, int type) { register char ch; register int n_objs; @@ -253,8 +253,8 @@ int type; * pick_up: * Add something to characters pack. */ -pick_up(ch) -char ch; +void +pick_up(char ch) { register THING *obj, *mp; @@ -290,7 +290,8 @@ char ch; * picky_inven: * Allow player to inventory a single item */ -picky_inven() +void +picky_inven(void) { register THING *obj; register char ch, mch; @@ -325,9 +326,7 @@ picky_inven() * Pick something out of a pack for a purpose */ THING * -get_item(purpose, type) -char *purpose; -int type; +get_item(char *purpose, int type) { register THING *obj; register char ch, och; @@ -384,8 +383,8 @@ int type; * pack_char: * Return which character would address a pack object */ -pack_char(obj) -register THING *obj; +char +pack_char(THING *obj) { register THING *item; register char c; @@ -403,8 +402,8 @@ register THING *obj; * money: * Add or subtract gold from the pack */ -money(value) -register int value; +void +money(int value) { register char floor; diff --git a/rogue4/passages.c b/rogue4/passages.c index 51e1ec5..2857640 100644 --- a/rogue4/passages.c +++ b/rogue4/passages.c @@ -10,14 +10,21 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include #include #include "rogue.h" +void conn(int r1, int r2); +void door(struct room *rm, coord *cp); +void passnum(void); +void numpass(int y, int x); + /* * do_passages: * Draw all the passages on a level. */ -do_passages() +void +do_passages(void) { register struct rdes *r1, *r2 = NULL; register int i, j; @@ -125,8 +132,8 @@ do_passages() * conn: * Draw a corridor from a room in a certain direction. */ -conn(r1, r2) -int r1, r2; +void +conn(int r1, int r2) { register struct room *rpf, *rpt = NULL; register char rmt; @@ -269,9 +276,8 @@ int r1, r2; * Add a door or possibly a secret door. Also enters the door in * the exits array of the room. */ -door(rm, cp) -register struct room *rm; -register coord *cp; +void +door(struct room *rm, coord *cp) { register int index; @@ -291,7 +297,8 @@ register coord *cp; * add_pass: * Add the passages to the current window (wizard command) */ -add_pass() +void +add_pass(void) { register int y, x, ch; @@ -309,7 +316,8 @@ add_pass() static int pnum; static bool newpnum; -passnum() +void +passnum(void) { register struct room *rp; register int i; @@ -330,8 +338,8 @@ passnum() * numpass: * Number a passageway square and its brethren */ -numpass(y, x) -register int y, x; +void +numpass(int y, int x) { register char *fp; register struct room *rp; diff --git a/rogue4/potions.c b/rogue4/potions.c index 4c15cce..ed601b0 100644 --- a/rogue4/potions.c +++ b/rogue4/potions.c @@ -17,7 +17,8 @@ * quaff: * Quaff a potion from the pack */ -quaff() +void +quaff(void) { register THING *obj, *th; register bool discardit = FALSE; @@ -203,7 +204,8 @@ quaff() * invis_on: * Turn on the ability to see invisible */ -invis_on() +void +invis_on(void) { register THING *th; @@ -220,8 +222,8 @@ invis_on() * see_monst: * Put on or off seeing monsters on this level */ -turn_see(turn_off) -register bool turn_off; +bool +turn_see(bool turn_off) { register THING *mp; register bool can_see, add_new; diff --git a/rogue4/rings.c b/rogue4/rings.c index eb0a8d3..7266ddf 100644 --- a/rogue4/rings.c +++ b/rogue4/rings.c @@ -14,11 +14,14 @@ #include #include "rogue.h" +int gethand(void); + /* * ring_on: * Put a ring on a hand */ -ring_on() +void +ring_on(void) { register THING *obj; register int ring; @@ -88,7 +91,8 @@ ring_on() * ring_off: * Take off a ring */ -ring_off() +void +ring_off(void) { register int ring; register THING *obj; @@ -125,7 +129,8 @@ ring_off() * gethand: * Which hand is the hero interested in? */ -gethand() +int +gethand(void) { register int c; @@ -153,8 +158,8 @@ gethand() * ring_eat: * How much food does this ring use up? */ -ring_eat(hand) -register int hand; +int +ring_eat(int hand) { if (cur_ring[hand] == NULL) return 0; @@ -186,8 +191,7 @@ register int hand; * Print ring bonuses */ char * -ring_num(obj) -register THING *obj; +ring_num(THING *obj) { static char buf[5]; diff --git a/rogue4/rip.c b/rogue4/rip.c index 73d25be..9e70dde 100644 --- a/rogue4/rip.c +++ b/rogue4/rip.c @@ -19,6 +19,8 @@ #include #include "rogue.h" +char *killname(char monst, bool doart); + static char *rip[] = { " __________", " / \\", @@ -41,9 +43,8 @@ static char *rip[] = { * Figure score and post it. */ /* VARARGS2 */ -score(amount, flags, monst) -int amount, flags; -char monst; +void +score(int amount, int flags, char monst) { register struct sc_ent *scp; register int i; @@ -297,8 +298,8 @@ void writelog(int amount, int flags, char monst) * death: * Do something really fun when he dies */ -death(monst) -register char monst; +void +death(char monst) { register char **dp = rip, *killer; register struct tm *lt; @@ -341,7 +342,8 @@ register char monst; * total_winner: * Code for a winner */ -total_winner() +void +total_winner(void) { register THING *obj; register int worth = 0; @@ -461,9 +463,7 @@ total_winner() * Convert a code to a monster name */ char * -killname(monst, doart) -register char monst; -bool doart; +killname(char monst, bool doart) { register const char *sp; register bool article; diff --git a/rogue4/rogue.h b/rogue4/rogue.h index 1c975ec..165639b 100644 --- a/rogue4/rogue.h +++ b/rogue4/rogue.h @@ -107,6 +107,7 @@ extern const char *metal[]; #define STICK '/' #define CALLABLE -1 +int spread(int nm); /* * Various constants */ @@ -477,7 +478,157 @@ coord *find_dest(), *rndmove(); THING *find_mons(), *find_obj(), *get_item(), *new_item(), *new_thing(), *wake_monster(); -struct room *roomin(); +struct room *roomin(coord *cp); + +void _attach(THING **list, THING *item); +void _detach(THING **list, THING *item); +void _free_list(THING **ptr); +bool add_haste(bool potion); +void add_pack(THING *obj, bool silent); +void add_str(str_t *sp, int amt); +void addmsg(char *fmt, ...); +void aggravate(void); +int attack(THING *mp); +void auto_save(int sig); +void call_it(bool know, char **guess); +bool cansee(int y, int x); +char *charge_str(THING *obj); +void check_level(void); +void chg_str(int amt); +void command(void); +void death(char monst); +bool diag_ok(coord *sp, coord *ep); +void discard(THING *item); +void discovered(void); +void do_daemons(int flag); +void do_fuses(int flag); +void do_motion(THING *obj, int ydelta, int xdelta); +void do_move(int dy, int dx); +void do_passages(void); +void do_rooms(void); +void do_run(char ch); +void do_zap(void); +void doctor(void); +void door_open(struct room *rp); +void drop(void); +bool dropcheck(THING *op); +void eat(void); +int encread(void *starta, int size, int inf); +void encwrite(void *starta, int size, FILE *outf); +void endmsg(void); +void enter_room(coord *cp); +void extinguish(int (*func)()); +void fall(THING *obj, bool pr); +bool fallpos(coord *pos, coord *newpos, bool pass); +void fatal(char *s); +bool fight(coord *mp, char mn, THING *weap, bool thrown); +THING *find_obj(int y, int x); +void fire_bolt(coord *start, coord *dir, char *name); +void fix_stick(THING *cur); +void flush_type(void); +void fuse(int (*func)(), int arg, int time, int type); +void genocide(void); +bool get_dir(void); +THING *get_item(char *purpose, int type); +int get_str(char *opt, WINDOW *win); +void give_pack(THING *tp); +bool hit_monster(int y, int x, THING *obj); +void init_check(void); +void init_colors(void); +void init_materials(void); +void init_names(void); +void init_player(void); +void init_stones(void); +void init_things(void); +void init_weapon(THING *weap, char type); +char *inv_name(THING *obj, bool drop); +bool inventory(THING *list, int type); +void invis_on(void); +bool is_current(THING *obj); +bool is_magic(THING *obj); +bool issymlink(char *sp); +void kill_daemon(int (*func)()); +void killed(THING *tp, bool pr); +void leave(int sig); +void leave_room(coord *cp); +void lengthen(int (*func)(), int xtime); +bool lock_sc(void); +void look(bool wakeup); +void missile(int ydelta, int xdelta); +void msg(char *fmt, ...); +THING *new_item(void); +void new_level(void); +void new_monster(THING *tp, char type, coord *cp); +THING *new_thing(void); +void nohaste(void); +char *num(int n1, int n2, char type); +void open_log(void); +void open_score(void); +void option(void); +char pack_char(THING *obj); +void parse_opts(char *str); +void pick_up(char ch); +void picky_inven(void); +void playit(void); +void quaff(void); +void quit(int a); +void raise_level(void); +char randmonster(bool wander); +void read_scroll(void); +int readchar(void); +int readcharw(WINDOW *win); +void remove_monster(coord *mp, THING *tp, bool waskill); +bool restore(char *file, char **envp); +int ring_eat(int hand); +char *ring_num(THING *obj); +void ring_off(void); +void ring_on(void); +int rnd(int range); +void rnd_pos(struct room *rp, coord *cp); +int rnd_room(void); +coord *rndmove(THING *who); +int roll(int number, int sides); +void rollwand(void); +void runners(void); +void runto(coord *runner, coord *spot); +bool save(int which); +bool save_game(void); +bool save_throw(int which, THING *tp); +void score(int amount, int flags, char monst); +bool see_monst(THING *mp); +void setup(void); +void shell(void); +void show_win(WINDOW *scr, char *message); +void sight(void); +int sign(int nm); +void start_daemon(int (*func)(), int arg, int type); +void start_score(void); +void status(void); +bool step_ok(char ch); +void stomach(void); +void strucpy(char *s1, char *s2, int len); +void swander(void); +bool swing(int at_lvl, int op_arm, int wplus); +void take_off(void); +int teleport(void); +void total_winner(void); +char *tr_name(char type); +bool turn_see(bool turn_off); +void unconfuse(void); +char *unctrol(char ch); +void unlock_sc(void); +void unsee(void); +char *vowelstr(char *str); +char *xcrypt(const char *key, const char *setting); +void w_wait_for(WINDOW *win, char ch); +void wait_for(char ch); +THING *wake_monster(int y, int x); +void wanderer(void); +void waste_time(void); +void wear(void); +void whatis(bool insist); +void wield(void); +void writelog(int amount, int flags, char monst); #ifdef HAVE_CONFIG_H #include "config.h" diff --git a/rogue4/rooms.c b/rogue4/rooms.c index 63d76f9..5181a49 100644 --- a/rogue4/rooms.c +++ b/rogue4/rooms.c @@ -16,11 +16,16 @@ #define GOLDGRP 1 +void draw_room(struct room *rp); +void vert(struct room *rp, int startx); +void horiz(struct room *rp, int starty); + /* * do_rooms: * Create rooms and corridors with a connectivity graph */ -do_rooms() +void +do_rooms(void) { register int i; register struct room *rp; @@ -120,8 +125,8 @@ do_rooms() * draw_room: * Draw a box around a room and lay down the floor */ -draw_room(rp) -register struct room *rp; +void +draw_room(struct room *rp) { register int y, x; @@ -147,9 +152,8 @@ register struct room *rp; * vert: * Draw a vertical line */ -vert(rp, startx) -register struct room *rp; -register int startx; +void +vert(struct room *rp, int startx) { register int y; @@ -161,9 +165,8 @@ register int startx; * horiz: * Draw a horizontal line */ -horiz(rp, starty) -register struct room *rp; -int starty; +void +horiz(struct room *rp, int starty) { register int x; @@ -175,9 +178,8 @@ int starty; * rnd_pos: * Pick a random spot in a room */ -rnd_pos(rp, cp) -register struct room *rp; -register coord *cp; +void +rnd_pos(struct room *rp, coord *cp) { cp->x = rp->r_pos.x + rnd(rp->r_max.x - 2) + 1; cp->y = rp->r_pos.y + rnd(rp->r_max.y - 2) + 1; @@ -187,8 +189,8 @@ register coord *cp; * enter_room: * Code that is executed whenver you appear in a room */ -enter_room(cp) -register coord *cp; +void +enter_room(coord *cp) { register struct room *rp; register int y, x; @@ -220,8 +222,8 @@ register coord *cp; * leave_room: * Code for when we exit a room */ -leave_room(cp) -register coord *cp; +void +leave_room(coord *cp) { register int y, x; register struct room *rp; diff --git a/rogue4/save.c b/rogue4/save.c index ee95184..b4b2379 100644 --- a/rogue4/save.c +++ b/rogue4/save.c @@ -21,6 +21,10 @@ #undef KERNEL #include "rogue.h" +void save_file(FILE *savef); +extern int rs_save_file(FILE *savef); +extern int rs_restore_file(int inf); + typedef struct stat STAT; extern char version[], encstr[]; @@ -33,7 +37,8 @@ STAT sbuf; * Implement the "save game" command */ /* This has to be cleaned up, these goto's are annoying. */ -save_game() +bool +save_game(void) { register FILE *savef; register int c; @@ -151,8 +156,8 @@ auto_save(int sig) * save_file: * Write the saved game on the file */ -save_file(savef) -register FILE *savef; +void +save_file(FILE *savef) { int slines = LINES; int scols = COLS; @@ -189,9 +194,8 @@ register FILE *savef; * Restore a saved game from a file with elaborate checks for file * integrity from cheaters */ -restore(file, envp) -register char *file; -char **envp; +bool +restore(char *file, char **envp) { register int inf; register bool syml; @@ -324,10 +328,8 @@ char **envp; * encwrite: * Perform an encrypted write */ -encwrite(starta, size, outf) -void *starta; -unsigned int size; -register FILE *outf; +void +encwrite(void *starta, int size, FILE *outf) { register char *ep; register char *start = (char *) starta; @@ -345,10 +347,8 @@ register FILE *outf; * encread: * Perform an encrypted read */ -encread(starta, size, inf) -register void *starta; -unsigned int size; -register int inf; +int +encread(void *starta, int size, int inf) { register char *ep; register int read_size; diff --git a/rogue4/scrolls.c b/rogue4/scrolls.c index 51e0bd4..def132b 100644 --- a/rogue4/scrolls.c +++ b/rogue4/scrolls.c @@ -18,7 +18,8 @@ * read_scroll: * Read a scroll from the pack and do the appropriate thing */ -read_scroll() +void +read_scroll(void) { register THING *obj; register int y, x; diff --git a/rogue4/state.c b/rogue4/state.c index 294e613..7d7f254 100644 --- a/rogue4/state.c +++ b/rogue4/state.c @@ -1335,7 +1335,7 @@ rs_read_object_list(int inf, THING **list) { for (i = 0; i < cnt; i++) { - l = new_item(sizeof(THING)); + l = new_item(); memset(l,0,sizeof(THING)); l->l_prev = previous; if (previous != NULL) diff --git a/rogue4/sticks.c b/rogue4/sticks.c index 4af7e24..f94dc72 100644 --- a/rogue4/sticks.c +++ b/rogue4/sticks.c @@ -16,12 +16,14 @@ #include #include "rogue.h" +void drain(void); + /* * fix_stick: * Set up a new stick */ -fix_stick(cur) -register THING *cur; +void +fix_stick(THING *cur) { if (strcmp(ws_type[cur->o_which], "staff") == 0) strcpy(cur->o_damage,"2d3"); @@ -45,7 +47,8 @@ register THING *cur; * do_zap: * Perform a zap with a wand */ -do_zap() +void +do_zap(void) { register THING *obj, *tp; register int y, x; @@ -272,7 +275,8 @@ do_zap() * drain: * Do drain hit points from player shtick */ -drain() +void +drain(void) { register THING *mp; register int cnt; @@ -321,9 +325,8 @@ drain() * fire_bolt: * Fire a bolt in a given direction from a specific starting place */ -fire_bolt(start, dir, name) -coord *start, *dir; -char *name; +void +fire_bolt(coord *start, coord *dir, char *name) { register char dirch, ch; register THING *tp; @@ -446,8 +449,7 @@ def: * Return an appropriate string for a wand charge */ char * -charge_str(obj) -register THING *obj; +charge_str(THING *obj) { static char buf[20]; diff --git a/rogue4/things.c b/rogue4/things.c index 4decd2b..db6e161 100644 --- a/rogue4/things.c +++ b/rogue4/things.c @@ -16,6 +16,11 @@ #include #include "rogue.h" +int pick_one(struct magic_item *magic, int nitems); +void print_disc(char type); +void set_order(short *order, int numthings); +char *nothing(char type); + bool got_genocide = FALSE; /* @@ -24,9 +29,7 @@ bool got_genocide = FALSE; * inventory. */ char * -inv_name(obj, drop) -register THING *obj; -register bool drop; +inv_name(THING *obj, bool drop) { register char *pb; @@ -163,7 +166,8 @@ register bool drop; * drop: * Put something down */ -drop() +void +drop(void) { register char ch; register THING *nobj, *op; @@ -211,8 +215,8 @@ drop() * dropcheck: * Do special checks for dropping or unweilding|unwearing|unringing */ -dropcheck(op) -register THING *op; +bool +dropcheck(THING *op) { if (op == NULL) return TRUE; @@ -253,7 +257,7 @@ register THING *op; * Return a new thing */ THING * -new_thing() +new_thing(void) { register THING *cur; register int j, k; @@ -361,9 +365,8 @@ new_thing() * pick_one: * Pick an item out of a list of nitems possible magic items */ -pick_one(magic, nitems) -register struct magic_item *magic; -int nitems; +int +pick_one(struct magic_item *magic, int nitems) { register struct magic_item *end; register int i; @@ -398,7 +401,8 @@ static bool newpage = FALSE; static char *lastfmt, *lastarg; -discovered() +void +discovered(void) { register char ch; register bool disc_list; @@ -456,8 +460,8 @@ discovered() #define MAX(a,b,c,d) (a > b ? (a > c ? (a > d ? a : d) : (c > d ? c : d)) : (b > c ? (b > d ? b : d) : (c > d ? c : d))) -print_disc(type) -char type; +void +print_disc(char type) { register bool *know = NULL; register char **guess = NULL; @@ -508,9 +512,8 @@ char type; * set_order: * Set up order for list */ -set_order(order, numthings) -short *order; -int numthings; +void +set_order(short *order, int numthings) { register int i, r, t; @@ -591,8 +594,7 @@ end_line() * Set up prbuf so that message for "nothing found" is there */ char * -nothing(type) -register char type; +nothing(char type) { register char *sp, *tystr = NULL; diff --git a/rogue4/weapons.c b/rogue4/weapons.c index 395eb9c..7f6764a 100644 --- a/rogue4/weapons.c +++ b/rogue4/weapons.c @@ -39,8 +39,8 @@ static struct init_weps { * missile: * Fire a missile in a given direction */ -missile(ydelta, xdelta) -int ydelta, xdelta; +void +missile(int ydelta, int xdelta) { register THING *obj, *nitem; @@ -86,9 +86,8 @@ int ydelta, xdelta; * Do the actual motion on the screen done by an object traveling * across the room */ -do_motion(obj, ydelta, xdelta) -register THING *obj; -register int ydelta, xdelta; +void +do_motion(THING *obj, int ydelta, int xdelta) { /* * Come fly with us ... @@ -129,9 +128,8 @@ register int ydelta, xdelta; * fall: * Drop an item someplace around here. */ -fall(obj, pr) -register THING *obj; -register bool pr; +void +fall(THING *obj, bool pr) { static coord fpos; register int index; @@ -163,9 +161,8 @@ register bool pr; * init_weapon: * Set up the initial goodies for a weapon */ -init_weapon(weap, type) -register THING *weap; -char type; +void +init_weapon(THING *weap, char type) { register struct init_weps *iwp; @@ -187,9 +184,8 @@ char type; * hit_monster: * Does the missile hit the monster? */ -hit_monster(y, x, obj) -register int y, x; -THING *obj; +bool +hit_monster(int y, int x, THING *obj) { static coord mp; @@ -203,9 +199,7 @@ THING *obj; * Figure out the plus number for armor/weapons */ char * -num(n1, n2, type) -register int n1, n2; -register char type; +num(int n1, int n2, char type) { static char numbuf[10]; @@ -219,7 +213,8 @@ register char type; * wield: * Pull out a certain weapon */ -wield() +void +wield(void) { register THING *obj, *oweapon; register char *sp; @@ -257,9 +252,8 @@ bad: * fallpos: * Pick a random position around the give (y, x) coordinates */ -fallpos(pos, newpos, pass) -register coord *pos, *newpos; -register bool pass; +bool +fallpos(coord *pos, coord *newpos, bool pass) { register int y, x, cnt, ch; diff --git a/rogue4/wizard.c b/rogue4/wizard.c index c01a0ed..18827ae 100644 --- a/rogue4/wizard.c +++ b/rogue4/wizard.c @@ -16,8 +16,8 @@ * whatis: * What a certin object is */ -whatis(insist) -bool insist; +void +whatis(bool insist) { register THING *obj; @@ -80,7 +80,8 @@ bool insist; * create_obj: * Wizard command for getting anything he wants */ -create_obj() +void +create_obj(void) { register THING *obj; register char ch, bless; @@ -150,7 +151,8 @@ create_obj() * telport: * Bamf the hero someplace else */ -teleport() +int +teleport(void) { register int rm; coord c; @@ -194,7 +196,8 @@ teleport() * passwd: * See if user knows password */ -passwd() +bool +passwd(void) { register char *sp, c; char buf[MAXSTR], *xcrypt(); @@ -219,7 +222,8 @@ passwd() * show_map: * Print out the map for the wizard */ -show_map() +void +show_map(void) { register int y, x, real; From 0f87d5b4d81af5993d3b2d21bcdd867436f037cb Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Thu, 28 Jan 2016 18:55:47 -0500 Subject: [PATCH 3/7] rogue4: add more function declarations. --- rogue4/extern.h | 12 ++++++++++++ rogue4/mdport.c | 36 ++++++++++++++++++------------------ 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/rogue4/extern.h b/rogue4/extern.h index c3a8f18..db38d5e 100644 --- a/rogue4/extern.h +++ b/rogue4/extern.h @@ -78,6 +78,18 @@ extern bool got_genocide; #define O_BINARY 0 #endif +extern int md_erasechar(void); extern FILE *md_fdopen(int fd, char *mode); +extern int md_fileno(FILE *fp); extern char *md_getusername(int uid); extern char *md_gethomedir(); +extern int md_getuid(void); +extern void md_ignore_signals(void); +extern void md_init(void); +extern int md_killchar(void); +extern void md_normaluser(void); +extern int md_readchar(WINDOW *win); +extern int md_shellescape(void); +extern void md_sleep(int s); +extern int md_unlink(char *file); +extern int md_unlink_open_file(char *file, int inf); diff --git a/rogue4/mdport.c b/rogue4/mdport.c index 5b27636..412a288 100644 --- a/rogue4/mdport.c +++ b/rogue4/mdport.c @@ -86,7 +86,7 @@ char *strdup(const char *s); #define MOD_MOVE(c) (toupper(c) ) void -md_init() +md_init(void) { #ifdef __INTERIX char *term; @@ -105,7 +105,7 @@ md_init() } int -md_hasclreol() +md_hasclreol(void) { #ifdef CE return((CE != NULL) && (*CE != 0)); @@ -127,7 +127,7 @@ md_putchar(int c) static int md_standout_mode = 0; void -md_raw_standout() +md_raw_standout(void) { #ifdef _WIN32 CONSOLE_SCREEN_BUFFER_INFO csbiInfo; @@ -150,7 +150,7 @@ md_raw_standout() } void -md_raw_standend() +md_raw_standend(void) { #ifdef _WIN32 CONSOLE_SCREEN_BUFFER_INFO csbiInfo; @@ -231,7 +231,7 @@ md_creat(char *file, int mode) void -md_normaluser() +md_normaluser(void) { #ifndef _WIN32 setuid(getuid()); @@ -240,7 +240,7 @@ md_normaluser() } int -md_getuid() +md_getuid(void) { #ifndef _WIN32 return( getuid() ); @@ -297,7 +297,7 @@ md_getusername(int uid) } char * -md_gethomedir() +md_gethomedir(void) { static char homedir[PATH_MAX]; char *h = NULL; @@ -349,7 +349,7 @@ md_sleep(int s) } char * -md_getshell() +md_getshell(void) { static char shell[PATH_MAX]; char *s = NULL; @@ -379,7 +379,7 @@ md_getshell() } void -md_ignore_signals() +md_ignore_signals(void) { #ifndef _WIN32 int i; @@ -396,7 +396,7 @@ md_ignore_signals() } int -md_shellescape() +md_shellescape(void) { #if (!defined(_WIN32) && !defined(__DJGPP__)) int ret_status; @@ -570,7 +570,7 @@ md_htonl(unsigned long int x) } int -md_ucount() +md_ucount(void) { #ifdef __DJGPP__ return(1); @@ -607,7 +607,7 @@ md_getloadavg(double *avg) } long -md_random() +md_random(void) { #ifdef _WIN32 return(rand()); @@ -627,7 +627,7 @@ md_srandom(unsigned x) } int -md_rand() +md_rand(void) { #ifdef _WIN32 return(rand()); @@ -657,7 +657,7 @@ md_strdup(const char *s) } long -md_memused() +md_memused(void) { #ifdef _WIN32 MEMORYSTATUS stat; @@ -671,7 +671,7 @@ md_memused() } int -md_erasechar() +md_erasechar(void) { #ifdef BSD return(_tty.sg_erase); /* process erase character */ @@ -683,7 +683,7 @@ md_erasechar() } int -md_killchar() +md_killchar(void) { #ifdef BSD return(_tty.sg_kill); @@ -712,7 +712,7 @@ md_unctrl(char ch) } void -md_flushinp() +md_flushinp(void) { #ifdef BSD ioctl(0, TIOCFLUSH); @@ -1013,7 +1013,7 @@ int undo[5]; int uindex = -1; int -reread() +reread(void) { int redo; From 59f448e92ee426d9add8cf0b1183ef5e7368942b Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Sun, 31 Jan 2016 13:45:07 -0500 Subject: [PATCH 4/7] Super-Rogue: convert to ANSI-style function declarations. This fixes most of the build warnings. --- srogue/armor.c | 15 ++-- srogue/chase.c | 36 ++++---- srogue/command.c | 31 +++++-- srogue/daemon.c | 36 ++++---- srogue/daemons.c | 52 +++++------ srogue/disply.c | 42 +++++---- srogue/encumb.c | 36 +++++--- srogue/fight.c | 84 +++++++++-------- srogue/init.c | 58 +++++++----- srogue/io.c | 48 +++++----- srogue/list.c | 22 +++-- srogue/main.c | 33 +++---- srogue/misc.c | 37 ++++---- srogue/monsters.c | 36 ++++---- srogue/move.c | 39 ++++---- srogue/new_leve.c | 18 ++-- srogue/options.c | 21 +++-- srogue/pack.c | 35 ++++---- srogue/passages.c | 19 ++-- srogue/potions.c | 5 +- srogue/pstats.c | 54 ++++++----- srogue/rings.c | 48 +++++----- srogue/rip.c | 28 +++--- srogue/rogue.ext | 225 +++++++++++++++++++++++++++++++++++++++++++--- srogue/rooms.c | 31 +++---- srogue/save.c | 22 +++-- srogue/scrolls.c | 3 +- srogue/state.c | 22 ++--- srogue/sticks.c | 18 ++-- srogue/things.c | 31 ++++--- srogue/trader.c | 56 +++++++----- srogue/weapons.c | 36 ++++---- srogue/wizard.c | 24 ++--- 33 files changed, 783 insertions(+), 518 deletions(-) diff --git a/srogue/armor.c b/srogue/armor.c index 2fc3541..1a09131 100644 --- a/srogue/armor.c +++ b/srogue/armor.c @@ -21,7 +21,8 @@ * wear: * The player wants to wear something, so let the hero try */ -wear() +void +wear(void) { reg struct linked_list *item; reg struct object *obj; @@ -50,7 +51,8 @@ wear() * take_off: * Get the armor off of the players back */ -take_off() +void +take_off(void) { reg struct object *obj; @@ -69,9 +71,8 @@ take_off() * initarmor: * Initialize some armor. */ -initarmor(obj, what) -struct object *obj; -int what; +void +initarmor(struct object *obj, int what) { struct init_armor *iwa; struct magic_item *mi; @@ -90,8 +91,8 @@ int what; * hurt_armor: * Returns TRUE if armor is damaged */ -hurt_armor(obj) -struct object *obj; +bool +hurt_armor(struct object *obj) { reg int type, ac; diff --git a/srogue/chase.c b/srogue/chase.c index 92387df..6d7b660 100644 --- a/srogue/chase.c +++ b/srogue/chase.c @@ -14,19 +14,24 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include #include "rogue.h" #include "rogue.ext" #define FARAWAY 32767 #define RDIST(a, b) (DISTANCE((a)->y, (a)->x, (b).y, (b).x)) +int do_chase(struct linked_list *mon); +int chase(struct thing *tp, struct coord *ee, bool runaway, bool dofight); + struct coord ch_ret; /* Where chasing takes you */ /* * runners: * Make all the running monsters move. */ -runners() +void +runners(void) { reg struct thing *tp; reg struct linked_list *mon,*nextmon; @@ -54,8 +59,8 @@ runners() * do_chase: * Make one thing chase another. */ -do_chase(mon) -struct linked_list *mon; +int +do_chase(struct linked_list *mon) { reg struct thing *th; reg struct room *rer, *ree, *rxx; @@ -241,10 +246,8 @@ struct linked_list *mon; * chasee. Returns TRUE if we want to keep on chasing * later FALSE if we reach the goal. */ -chase(tp, ee, runaway, dofight) -struct thing *tp; -struct coord *ee; -bool runaway, dofight; +int +chase(struct thing *tp, struct coord *ee, bool runaway, bool dofight) { reg int x, y, ch; reg int dist, thisdist, closest; @@ -385,9 +388,8 @@ bool runaway, dofight; * runto: * Set a monster running after something */ -runto(runner, spot) -struct coord *runner; -struct coord *spot; +void +runto(struct coord *runner, struct coord *spot) { reg struct linked_list *item; reg struct thing *tp; @@ -409,8 +411,7 @@ struct coord *spot; * NULL means they aren't in any room. */ struct room * -roomin(cp) -struct coord *cp; +roomin(struct coord *cp) { reg struct room *rp; @@ -428,8 +429,7 @@ struct coord *cp; * Find the monster from his coordinates */ struct linked_list * -find_mons(y, x) -int y, x; +find_mons(int y, int x) { reg struct linked_list *item; reg struct thing *th; @@ -447,8 +447,8 @@ int y, x; * diag_ok: * Check to see if the move is legal if it is diagonal */ -diag_ok(sp, ep) -struct coord *sp, *ep; +bool +diag_ok(struct coord *sp, struct coord *ep) { if (ep->x == sp->x || ep->y == sp->y) return TRUE; @@ -462,8 +462,8 @@ struct coord *sp, *ep; * cansee: * returns true if the hero can see a certain coordinate. */ -cansee(y, x) -int y, x; +bool +cansee(int y, int x) { reg struct room *rer; struct coord tp; diff --git a/srogue/command.c b/srogue/command.c index bd7c641..c487644 100644 --- a/srogue/command.c +++ b/srogue/command.c @@ -29,11 +29,19 @@ #include #endif +void search(void); +void help(void); +void d_level(void); +void u_level(void); +void shell(void); +void call(void); + /* * command: * Process the user commands */ -command() +void +command(void) { reg char ch; reg int ntimes = 1; /* Number of player moves */ @@ -416,7 +424,8 @@ quit(int a) * Player gropes about him to find hidden things. */ -search() +void +search(void) { reg int x, y; reg char ch; @@ -461,7 +470,8 @@ search() * help: * Give single character help, or the whole mess if he wants it */ -help() +void +help(void) { extern struct h_list helpstr[]; reg struct h_list *strp; @@ -519,8 +529,7 @@ help() * Tell the player what a certain thing is. */ char * -identify(what) -int what; +identify(int what) { reg char ch, *str; @@ -581,7 +590,8 @@ int what; * d_level: * He wants to go down a level */ -d_level() +void +d_level(void) { if (winat(hero.y, hero.x) != STAIRS) msg("I see no way down."); @@ -599,7 +609,8 @@ d_level() * u_level: * He wants to go up a level */ -u_level() +void +u_level(void) { if (winat(hero.y, hero.x) == STAIRS) { if (pl_on(ISHELD)) { @@ -624,7 +635,8 @@ u_level() /* * Let him escape for a while */ -shell() +void +shell(void) { reg int pid; reg char *sh; @@ -659,7 +671,8 @@ shell() * call: * Allow a user to call a potion, scroll, or ring something */ -call() +void +call(void) { reg struct object *obj; reg struct linked_list *item; diff --git a/srogue/daemon.c b/srogue/daemon.c index 0888437..441f1e0 100644 --- a/srogue/daemon.c +++ b/srogue/daemon.c @@ -34,8 +34,7 @@ struct delayed_action d_list[MAXDAEMONS] = { * Insert a function in the daemon list. */ struct delayed_action * -d_insert(func, arg, type, time) -int arg, type, time, (*func)(); +d_insert(int (*func)(), int arg, int type, int time) { reg struct delayed_action *dev; @@ -51,8 +50,8 @@ int arg, type, time, (*func)(); return NULL; } -d_delete(wire) -struct delayed_action *wire; +void +d_delete(struct delayed_action *wire) { reg struct delayed_action *d1, *d2; @@ -73,8 +72,7 @@ struct delayed_action *wire; * Find a particular slot in the table */ struct delayed_action * -find_slot(func) -int (*func)(); +find_slot(int (*func)()) { reg struct delayed_action *dev; @@ -88,8 +86,8 @@ int (*func)(); * start_daemon: * Start a daemon, takes a function. */ -start_daemon(func, arg, type) -int arg, type, (*func)(); +void +start_daemon(int (*func)(), int arg, int type) { d_insert(func, arg, type, DAEMON); } @@ -99,8 +97,8 @@ int arg, type, (*func)(); * Run all the daemons that are active with the current * flag, passing the argument to the function. */ -do_daemons(flag) -int flag; +void +do_daemons(int flag) { reg struct delayed_action *dev; @@ -113,8 +111,8 @@ int flag; * fuse: * Start a fuse to go off in a certain number of turns */ -fuse(func, arg, time) -int (*func)(), arg, time; +void +fuse(int (*func)(), int arg, int time) { d_insert(func, arg, AFTER, time); } @@ -123,8 +121,8 @@ int (*func)(), arg, time; * lengthen: * Increase the time until a fuse goes off */ -lengthen(func, xtime) -int (*func)(), xtime; +void +lengthen(int (*func)(), int xtime) { reg struct delayed_action *wire; @@ -137,8 +135,8 @@ int (*func)(), xtime; * extinguish: * Put out a fuse. Find all such fuses and kill them. */ -extinguish(func) -int (*func)(); +void +extinguish(int (*func)()) { reg struct delayed_action *dev; @@ -151,7 +149,8 @@ int (*func)(); * do_fuses: * Decrement counters and start needed fuses */ -do_fuses() +void +do_fuses(void) { reg struct delayed_action *dev; @@ -170,7 +169,8 @@ do_fuses() * activity: * Show wizard number of demaons and memory blocks used */ -activity() +void +activity(void) { msg("Daemons = %d : Memory Items = %d : Memory Used = %d", demoncnt,total,md_memused()); diff --git a/srogue/daemons.c b/srogue/daemons.c index 6599ef9..aba22cb 100644 --- a/srogue/daemons.c +++ b/srogue/daemons.c @@ -23,8 +23,8 @@ int between = 0; * doctor: * A healing daemon that restores hit points after rest */ -doctor(fromfuse) -int fromfuse; +void +doctor(int fromfuse) { reg int *thp, lv, ohp, ccon; @@ -63,8 +63,8 @@ int fromfuse; * Swander: * Called when it is time to start rolling for wandering monsters */ -swander(fromfuse) -int fromfuse; +void +swander(int fromfuse) { start_daemon(rollwand, TRUE, AFTER); } @@ -74,8 +74,8 @@ int fromfuse; * rollwand: * Called to roll to see if a wandering monster starts up */ -rollwand(fromfuse) -int fromfuse; +void +rollwand(int fromfuse) { if (++between >= 4) { @@ -94,8 +94,8 @@ int fromfuse; * unconfuse: * Release the poor player from his confusion */ -unconfuse(fromfuse) -int fromfuse; +void +unconfuse(int fromfuse) { if (pl_on(ISHUH)) msg("You feel less confused now."); @@ -106,8 +106,8 @@ int fromfuse; * unsee: * He lost his see invisible power */ -unsee(fromfuse) -int fromfuse; +void +unsee(int fromfuse) { player.t_flags &= ~CANSEE; } @@ -116,8 +116,8 @@ int fromfuse; * sight: * He gets his sight back */ -sight(fromfuse) -int fromfuse; +void +sight(int fromfuse) { if (pl_on(ISBLIND)) msg("The veil of darkness lifts."); @@ -129,8 +129,8 @@ int fromfuse; * nohaste: * End the hasting */ -nohaste(fromfuse) -int fromfuse; +void +nohaste(int fromfuse) { if (pl_on(ISHASTE)) msg("You feel yourself slowing down."); @@ -142,8 +142,8 @@ int fromfuse; * stomach: * Digest the hero's food */ -stomach(fromfuse) -int fromfuse; +void +stomach(int fromfuse) { reg int oldfood, old_hunger; @@ -188,8 +188,8 @@ int fromfuse; * noteth: * Hero is no longer etherereal */ -noteth(fromfuse) -int fromfuse; +void +noteth(int fromfuse) { int ch; @@ -209,8 +209,8 @@ int fromfuse; * sapem: * Sap the hero's life away */ -sapem(fromfuse) -int fromfuse; +void +sapem(int fromfuse) { chg_abil(rnd(4) + 1, -1, TRUE); fuse(sapem, TRUE, 150); @@ -221,8 +221,8 @@ int fromfuse; * notslow: * Restore the hero's normal speed */ -notslow(fromfuse) -int fromfuse; +void +notslow(int fromfuse) { if (pl_on(ISSLOW)) msg("You no longer feel hindered."); @@ -233,8 +233,8 @@ int fromfuse; * notregen: * Hero is no longer regenerative */ -notregen(fromfuse) -int fromfuse; +void +notregen(int fromfuse) { if (pl_on(ISREGEN)) msg("You no longer feel bolstered."); @@ -245,8 +245,8 @@ int fromfuse; * notinvinc: * Hero not invincible any more */ -notinvinc(fromfuse) -int fromfuse; +void +notinvinc(int fromfuse) { if (pl_on(ISINVINC)) msg("You no longer feel invincible."); diff --git a/srogue/disply.c b/srogue/disply.c index 85960ba..70596a2 100644 --- a/srogue/disply.c +++ b/srogue/disply.c @@ -18,7 +18,8 @@ * displevl: * Display detailed level for wizard and scroll */ -displevl() +void +displevl(void) { reg char ch, mch; reg int i,j; @@ -73,7 +74,8 @@ displevl() * dispmons: * Show monsters for wizard and potion */ -dispmons() +void +dispmons(void) { reg int ch, y, x; reg struct thing *it; @@ -95,8 +97,8 @@ dispmons() * winat: * Get whatever character is at a location on the screen */ -winat(y, x) -int x, y; +char +winat(int y, int x) { reg char ch; @@ -111,8 +113,8 @@ int x, y; * cordok: * Returns TRUE if coordinate is on usable screen */ -cordok(y, x) -int y, x; +bool +cordok(int y, int x) { if (x < 0 || y < 0 || x >= COLS || y >= LINES - 1) return FALSE; @@ -123,8 +125,8 @@ int y, x; * pl_on: * Returns TRUE if the player's flag is set */ -pl_on(what) -long what; +bool +pl_on(long what) { return (player.t_flags & what); } @@ -134,8 +136,8 @@ long what; * pl_off: * Returns TRUE when player's flag is reset */ -pl_off(what) -long what; +bool +pl_off(long what) { return (!(player.t_flags & what)); } @@ -145,9 +147,8 @@ long what; * o_on: * Returns TRUE in the objects flag is set */ -o_on(what,bit) -struct object *what; -long bit; +bool +o_on(struct object *what, long bit) { reg int flag; @@ -162,9 +163,8 @@ long bit; * o_off: * Returns TRUE is the objects flag is reset */ -o_off(what,bit) -struct object *what; -long bit; +bool +o_off(struct object *what, long bit) { reg int flag; @@ -179,9 +179,8 @@ long bit; * setoflg: * Set the specified flag for the object */ -setoflg(what,bit) -struct object *what; -long bit; +void +setoflg(struct object *what, long bit) { what->o_flags |= bit; } @@ -191,9 +190,8 @@ long bit; * resoflg: * Reset the specified flag for the object */ -resoflg(what,bit) -struct object *what; -long bit; +void +resoflg(struct object *what, long bit) { what->o_flags &= ~bit; } diff --git a/srogue/encumb.c b/srogue/encumb.c index e577761..5bc879e 100644 --- a/srogue/encumb.c +++ b/srogue/encumb.c @@ -10,14 +10,19 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include #include "rogue.h" #include "rogue.ext" +int packweight(void); +int pack_vol(void); + /* * updpack: * Update his pack weight and adjust fooduse accordingly */ -updpack() +void +updpack(void) { reg int topcarry, curcarry; @@ -44,7 +49,8 @@ updpack() * packweight: * Get the total weight of the hero's pack */ -packweight() +int +packweight(void) { reg struct object *obj; reg struct linked_list *pc; @@ -72,8 +78,8 @@ packweight() * itemweight: * Get the weight of an object */ -itemweight(wh) -struct object *wh; +int +itemweight(struct object *wh) { reg int weight; @@ -97,7 +103,8 @@ struct object *wh; * pack_vol: * Get the total volume of the hero's pack */ -pack_vol() +int +pack_vol(void) { reg struct object *obj; reg struct linked_list *pc; @@ -115,8 +122,8 @@ pack_vol() * itemvol: * Get the volume of an object */ -itemvol(wh) -struct object *wh; +int +itemvol(struct object *wh) { reg int volume, what, extra; @@ -139,9 +146,10 @@ struct object *wh; * playenc: * Get hero's carrying ability above norm */ -playenc() +int +playenc(void) { - reg estr = him->s_ef.a_str; + reg int estr = him->s_ef.a_str; if (estr >= 24) return 3000; switch(him->s_ef.a_str) { @@ -174,7 +182,8 @@ playenc() * totalenc: * Get total weight that the hero can carry */ -totalenc() +int +totalenc(void) { reg int wtotal; @@ -192,8 +201,8 @@ totalenc() * whgtchk: * See if the hero can carry his pack */ -wghtchk(fromfuse) -int fromfuse; +void +wghtchk(int fromfuse) { reg int dropchk, err = TRUE; reg char ch; @@ -231,7 +240,8 @@ int fromfuse; * 0 hit for medium pack weight * -1 hit for heavy pack weight */ -hitweight() +int +hitweight(void) { return(2 - foodlev); } diff --git a/srogue/fight.c b/srogue/fight.c index 092739e..6f80372 100644 --- a/srogue/fight.c +++ b/srogue/fight.c @@ -14,19 +14,26 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include #include +#include #include "rogue.h" #include "rogue.ext" +bool roll_em(struct stats *att, struct stats *def, struct object *weap, bool hurl); +char *mindex(char *cp, char c); +char *prname(char *who, bool upper); +void hit(char *er); +void miss(char *er); +void thunk(struct object *weap, char *mname); +void bounce(struct object *weap, char *mname); /* * fight: * The player attacks the monster. */ -fight(mp, weap, thrown) -struct coord *mp; -struct object *weap; -bool thrown; +bool +fight(struct coord *mp, struct object *weap, bool thrown) { reg struct thing *tp; @@ -123,8 +130,8 @@ bool thrown; * attack: * The monster attacks the player */ -attack(mp) -struct thing *mp; +int +attack(struct thing *mp) { reg char *mname; @@ -349,8 +356,8 @@ struct thing *mp; * swing: * Returns true if the swing hits */ -swing(at_lvl, op_arm, wplus) -int at_lvl, op_arm, wplus; +bool +swing(int at_lvl, int op_arm, int wplus) { reg int res = rnd(20)+1; reg int need = (21 - at_lvl) - op_arm; @@ -363,7 +370,8 @@ int at_lvl, op_arm, wplus; * check_level: * Check to see if the guy has gone up a level. */ -check_level() +void +check_level(void) { reg int lev, add, dif; @@ -387,15 +395,12 @@ check_level() * roll_em: * Roll several attacks */ -roll_em(att, def, weap, hurl) -struct stats *att, *def; -struct object *weap; -bool hurl; +bool +roll_em(struct stats *att, struct stats *def, struct object *weap, bool hurl) { reg char *cp; reg int ndice, nsides, def_arm, prop_hplus, prop_dplus; reg bool did_hit = FALSE; - char *mindex(); prop_hplus = prop_dplus = 0; if (weap == NULL) { @@ -479,8 +484,7 @@ bool hurl; * Look for char 'c' in string pointed to by 'cp' */ char * -mindex(cp, c) -char *cp, c; +mindex(char *cp, char c) { reg int i; @@ -498,9 +502,7 @@ char *cp, c; * The print name of a combatant */ char * -prname(who, upper) -char *who; -bool upper; +prname(char *who, bool upper) { static char tbuf[LINLEN]; @@ -522,8 +524,8 @@ static char tbuf[LINLEN]; * hit: * Print a message to indicate a succesful hit */ -hit(er) -char *er; +void +hit(char *er) { msg("%s hit.",prname(er, TRUE)); } @@ -533,8 +535,8 @@ char *er; * miss: * Print a message to indicate a poor swing */ -miss(er) -char *er; +void +miss(char *er) { msg("%s miss%s.",prname(er, TRUE),(er == 0 ? "":"es")); } @@ -544,9 +546,8 @@ char *er; * save_throw: * See if a creature saves against something */ -save_throw(which, tp) -int which; -struct thing *tp; +bool +save_throw(int which, struct thing *tp) { reg int need; reg struct stats *st; @@ -561,8 +562,8 @@ struct thing *tp; * save: * See if he saves against various nasty things */ -save(which) -int which; +bool +save(int which) { return save_throw(which, &player); } @@ -571,7 +572,8 @@ int which; * raise_level: * The guy just magically went up a level. */ -raise_level() +void +raise_level(void) { him->s_exp = e_levels[him->s_lvl-1] + 1L; check_level(); @@ -582,9 +584,8 @@ raise_level() * thunk: * A missile hits a monster */ -thunk(weap, mname) -struct object *weap; -char *mname; +void +thunk(struct object *weap, char *mname) { if (weap->o_type == WEAPON) msg("The %s hits the %s.",w_magic[weap->o_which].mi_name,mname); @@ -597,9 +598,8 @@ char *mname; * bounce: * A missile misses a monster */ -bounce(weap, mname) -struct object *weap; -char *mname; +void +bounce(struct object *weap, char *mname) { if (weap->o_type == WEAPON) msg("The %s misses the %s.", w_magic[weap->o_which].mi_name,mname); @@ -612,9 +612,8 @@ char *mname; * remove: * Remove a monster from the screen */ -remove_monster(mp, item) -struct coord *mp; -struct linked_list *item; +void +remove_monster(struct coord *mp, struct linked_list *item) { reg char what; @@ -633,8 +632,8 @@ struct linked_list *item; * is_magic: * Returns true if an object radiates magic */ -is_magic(obj) -struct object *obj; +bool +is_magic(struct object *obj) { switch (obj->o_type) { case ARMOR: @@ -656,9 +655,8 @@ struct object *obj; * killed: * Called to put a monster to death */ -killed(item, pr) -struct linked_list *item; -bool pr; +void +killed(struct linked_list *item, bool pr) { reg struct thing *tp; reg struct object *obj; diff --git a/srogue/init.c b/srogue/init.c index 851886f..672c8db 100644 --- a/srogue/init.c +++ b/srogue/init.c @@ -19,6 +19,9 @@ #include "rogue.h" #include "rogue.ext" +int pinit(void); +void badcheck(char *name, struct magic_item *magic); + char *rainbow[NCOLORS] = { "Red", "Blue", "Green", "Yellow", "Black", "Brown", "Orange", "Pink", @@ -81,25 +84,12 @@ char *metal[NMETAL] = { "Tin", "Titanium", "Zinc", }; -/* - * init_everything: - * Set up all important stuff. - */ -init_everything() -{ - init_player(); /* Roll up the rogue */ - init_things(); /* Set up probabilities */ - init_names(); /* Set up names of scrolls */ - init_colors(); /* Set up colors of potions */ - init_stones(); /* Set up stones in rings */ - init_materials(); /* Set up materials of wands */ -} - /* * init_things: * Initialize the probabilities for types of things */ -init_things() +void +init_things(void) { struct magic_item *mi; @@ -128,7 +118,8 @@ init_things() * init_colors: * Initialize the potion color scheme for this time */ -init_colors() +void +init_colors(void) { reg int i, j; reg char *str; @@ -155,7 +146,8 @@ init_colors() * init_names: * Generate the names of the various scrolls */ -init_names() +void +init_names(void) { reg int nsyl; reg char *cp, *sp; @@ -189,7 +181,8 @@ init_names() * Initialize the ring stone setting scheme for this time */ -init_stones() +void +init_stones(void) { reg int i, j; reg char *str; @@ -217,7 +210,8 @@ init_stones() * Initialize the construction materials for wands and staffs */ -init_materials() +void +init_materials(void) { int i, j; char *str; @@ -264,9 +258,8 @@ init_materials() badcheck("sticks", ws_magic); } -badcheck(name, magic) -char *name; -struct magic_item *magic; +void +badcheck(char *name, struct magic_item *magic) { struct magic_item *mg; @@ -289,7 +282,8 @@ struct magic_item *magic; * roll up the rogue */ -init_player() +void +init_player(void) { player.t_nomove = 0; player.t_nocmd = 0; @@ -315,7 +309,8 @@ init_player() * pinit: * Returns the best 3 of 4 on a 6-sided die */ -pinit() +int +pinit(void) { int best[4]; reg int i, min, minind, dicetot; @@ -337,3 +332,18 @@ pinit() } return(dicetot); } + +/* + * init_everything: + * Set up all important stuff. + */ +void +init_everything(void) +{ + init_player(); /* Roll up the rogue */ + init_things(); /* Set up probabilities */ + init_names(); /* Set up names of scrolls */ + init_colors(); /* Set up colors of potions */ + init_stones(); /* Set up stones in rings */ + init_materials(); /* Set up materials of wands */ +} diff --git a/srogue/io.c b/srogue/io.c index 7caac01..e858e84 100644 --- a/srogue/io.c +++ b/srogue/io.c @@ -20,7 +20,7 @@ #include "rogue.h" #include "rogue.ext" -int md_readchar(WINDOW *win); +void doadd(char *fmt, va_list ap); /* * msg: @@ -29,6 +29,7 @@ int md_readchar(WINDOW *win); static char msgbuf[BUFSIZ]; static int newpos = 0; +void msg(char *fmt, ...) { va_list ap; @@ -54,6 +55,7 @@ msg(char *fmt, ...) * addmsg: * Add things to the current message */ +void addmsg(char *fmt, ...) { va_list ap; @@ -68,7 +70,8 @@ addmsg(char *fmt, ...) * Display a new msg, giving him a chance to see the * previous one if it is up there with the --More-- */ -endmsg() +void +endmsg(void) { strcpy(huh, msgbuf); if (mpos > 0) { @@ -88,6 +91,7 @@ endmsg() * doadd: * Perform a printf into a buffer */ +void doadd(char *fmt, va_list ap) { vsprintf(&msgbuf[newpos], fmt, ap); @@ -98,8 +102,8 @@ doadd(char *fmt, va_list ap) * step_ok: * Returns TRUE if it is ok to step on ch */ -step_ok(ch) -unsigned char ch; +bool +step_ok(unsigned char ch) { if (dead_end(ch)) return FALSE; @@ -113,8 +117,8 @@ unsigned char ch; * dead_end: * Returns TRUE if you cant walk through that character */ -dead_end(ch) -char ch; +bool +dead_end(char ch) { if (ch == '-' || ch == '|' || ch == ' ' || ch == SECRETDOOR) return TRUE; @@ -129,7 +133,8 @@ char ch; * getchar. */ -readchar() +int +readchar(void) { char c; @@ -148,8 +153,8 @@ char *hungstr[] = { * status: * Display the important stats line. Keep the cursor where it was. */ -status(fromfuse) -int fromfuse; +void +status(int fromfuse) { reg int totwght, carwght; reg struct real *stef, *stre, *stmx; @@ -220,7 +225,8 @@ int fromfuse; * dispmax: * Display the hero's maximum status */ -dispmax() +void +dispmax(void) { reg struct real *hmax; @@ -233,8 +239,8 @@ dispmax() * illeg_ch: * Returns TRUE if a char shouldn't show on the screen */ -illeg_ch(ch) -unsigned char ch; +bool +illeg_ch(unsigned char ch) { if (ch < 32 || ch > 127) return TRUE; @@ -247,9 +253,8 @@ unsigned char ch; * wait_for: * Sit around until the guy types the right key */ -wait_for(win,ch) -WINDOW *win; -char ch; +void +wait_for(WINDOW *win, char ch) { register char c; @@ -293,9 +298,8 @@ gettime() * dbotline: * Displays message on bottom line and waits for a space to return */ -dbotline(scr,message) -WINDOW *scr; -char *message; +void +dbotline(WINDOW *scr, char *message) { mvwaddstr(scr,LINES-1,0,message); draw(scr); @@ -307,8 +311,8 @@ char *message; * restscr: * Restores the screen to the terminal */ -restscr(scr) -WINDOW *scr; +void +restscr(WINDOW *scr) { clearok(scr,TRUE); touchwin(scr); @@ -318,8 +322,8 @@ WINDOW *scr; * npch: * Get the next char in line for inventories */ -npch(ch) -char ch; +char +npch(char ch) { reg char nch; if (ch >= 'z') diff --git a/srogue/list.c b/srogue/list.c index 473f38d..2ee3d05 100644 --- a/srogue/list.c +++ b/srogue/list.c @@ -23,8 +23,8 @@ * Takes an item out of whatever linked list it might be in */ -_detach(list, item) -struct linked_list **list, *item; +void +_detach(struct linked_list **list, struct linked_list *item) { if (*list == item) *list = next(item); @@ -39,8 +39,8 @@ struct linked_list **list, *item; /* * _attach: add an item to the head of a list */ -_attach(list, item) -struct linked_list **list, *item; +void +_attach(struct linked_list **list, struct linked_list *item) { if (*list != NULL) { item->l_next = *list; @@ -57,8 +57,8 @@ struct linked_list **list, *item; /* * _free_list: Throw the whole blamed thing away */ -_free_list(ptr) -struct linked_list **ptr; +void +_free_list(struct linked_list **ptr) { register struct linked_list *item; @@ -72,8 +72,8 @@ struct linked_list **ptr; /* * discard: free up an item */ -discard(item) -struct linked_list *item; +void +discard(struct linked_list *item) { total -= 2; FREE(item->l_data); @@ -84,8 +84,7 @@ struct linked_list *item; * new_item: get a new item with a specified size */ struct linked_list * -new_item(size) -int size; +new_item(int size) { register struct linked_list *item; @@ -96,8 +95,7 @@ int size; } char * -new(size) -int size; +new(int size) { register char *space = ALLOC(size); diff --git a/srogue/main.c b/srogue/main.c index 2c71585..1c42821 100644 --- a/srogue/main.c +++ b/srogue/main.c @@ -34,14 +34,14 @@ #include "rogue.ext" +char *roguehome(void); void open_records(void); extern int scorefd; extern FILE *logfile; -main(argc, argv, envp) -char **argv; -char **envp; +int +main(int argc, char *argv[], char *envp[]) { register char *env; register struct linked_list *item; @@ -50,7 +50,6 @@ char **envp; char *getpass(), *xcrypt(), *strrchr(); int lowtime; time_t now; - char *roguehome(); char *homedir = roguehome(); #ifdef __DJGPP__ @@ -322,8 +321,8 @@ endit(int a) * Exit the program, printing a message. */ -fatal(s) -char *s; +void +fatal(char *s) { clear(); refresh(); @@ -340,8 +339,7 @@ char *s; */ void -byebye(how) -int how; +byebye(int how) { if (!isendwin()) endwin(); @@ -354,8 +352,8 @@ int how; * rnd: * Pick a very random number. */ -rnd(range) -int range; +int +rnd(int range) { reg int wh; @@ -372,8 +370,8 @@ int range; * roll: * roll a number of dice */ -roll(number, sides) -int number, sides; +int +roll(int number, int sides) { reg int dtotal = 0; @@ -386,7 +384,8 @@ int number, sides; /* ** setup: Setup signal catching functions */ -setup() +void +setup(void) { md_onsignal_autosave(); @@ -400,7 +399,8 @@ setup() ** refreshing things and looking at the proper times. */ -playit() +void +playit(void) { reg char *opts; @@ -421,7 +421,8 @@ playit() /* ** author: See if a user is an author of the program */ -author() +bool +author(void) { switch (playuid) { case 100: @@ -444,7 +445,7 @@ directory_exists(char *dirname) } char * -roguehome() +roguehome(void) { static char path[LINLEN+16]; char *end,*home; diff --git a/srogue/misc.c b/srogue/misc.c index 37ad2fd..08b2086 100644 --- a/srogue/misc.c +++ b/srogue/misc.c @@ -22,7 +22,8 @@ * waste_time: * Do nothing but let other things happen */ -waste_time() +void +waste_time(void) { if (inwhgt) /* if from wghtchk, then done */ return; @@ -35,8 +36,8 @@ waste_time() * getindex: * Convert a type into an index for the things structures */ -getindex(what) -char what; +int +getindex(char what) { int index = -1; @@ -58,8 +59,7 @@ char what; * print the name of a trap */ char * -tr_name(ch) -char ch; +tr_name(char ch) { reg char *s; @@ -92,8 +92,8 @@ char ch; * Look: * A quick glance all around the player */ -look(wakeup) -bool wakeup; +void +look(bool wakeup) { reg char ch; reg int oldx, oldy, y, x; @@ -230,8 +230,7 @@ bool wakeup; * find the unclaimed object at y, x */ struct linked_list * -find_obj(y, x) -int y, x; +find_obj(int y, int x) { reg struct linked_list *obj; reg struct object *op; @@ -248,7 +247,8 @@ int y, x; * eat: * Let the hero eat some food. */ -eat() +void +eat(void) { reg struct linked_list *item; reg struct object *obj; @@ -297,7 +297,8 @@ eat() * aggravate: * aggravate all the monsters on this level */ -aggravate() +void +aggravate(void) { reg struct linked_list *mi; @@ -310,8 +311,7 @@ aggravate() * If string starts with a vowel, return "n" for an "an" */ char * -vowelstr(str) -char *str; +vowelstr(char *str) { switch (tolower(*str)) { case 'a': @@ -329,8 +329,8 @@ char *str; * is_current: * See if the object is one of the currently used items */ -is_current(obj) -struct object *obj; +bool +is_current(struct object *obj) { if (obj == NULL) return FALSE; @@ -346,7 +346,8 @@ struct object *obj; * get_dir: * Set up the direction coordinates */ -get_dir() +bool +get_dir(void) { reg char *prompt; reg bool gotit; @@ -384,8 +385,8 @@ get_dir() * initfood: * Set up stuff for a food-type object */ -initfood(what) -struct object *what; +void +initfood(struct object *what) { what->o_type = FOOD; what->o_group = NORMFOOD; diff --git a/srogue/monsters.c b/srogue/monsters.c index 1458274..1acccfb 100644 --- a/srogue/monsters.c +++ b/srogue/monsters.c @@ -14,6 +14,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include #include "rogue.h" #include #include "rogue.ext" @@ -23,10 +24,10 @@ * Pick a monster to show up. The lower the level, * the meaner the monster. */ -rnd_mon(wander,baddie) -bool wander; -bool baddie; /* TRUE when from a polymorph stick */ +char +rnd_mon(bool wander, bool baddie) { + /* baddie; TRUE when from a polymorph stick */ reg int i, ok, cnt; cnt = 0; @@ -60,7 +61,8 @@ bool baddie; /* TRUE when from a polymorph stick */ * lev_mon: * This gets all monsters possible on this level */ -lev_mon() +void +lev_mon(void) { reg int i; reg struct monster *mm; @@ -83,10 +85,7 @@ lev_mon() * Pick a new monster and add it to the list */ struct linked_list * -new_monster(type, cp, treas) -struct coord *cp; -bool treas; -char type; +new_monster(char type, struct coord *cp, bool treas) { reg struct linked_list *item; reg struct thing *tp; @@ -191,7 +190,8 @@ char type; * wanderer: * A wandering monster has awakened and is headed for the player */ -wanderer() +void +wanderer(void) { reg int ch = '-'; reg struct room *rp, *hr = player.t_room; @@ -217,8 +217,7 @@ wanderer() * What to do when the hero steps next to a monster */ struct linked_list * -wake_monster(y, x) -int y, x; +wake_monster(int y, int x) { reg struct thing *tp; reg struct linked_list *it; @@ -279,7 +278,8 @@ int y, x; * genocide: * Eradicate a monster forevermore */ -genocide() +void +genocide(void) { reg struct linked_list *ip, *nip; reg struct thing *mp; @@ -331,8 +331,8 @@ tryagain: * unhold: * Release the player from being held */ -unhold(whichmon) -char whichmon; +void +unhold(char whichmon) { switch (whichmon) { case 'F': @@ -347,8 +347,8 @@ char whichmon; * midx: * This returns an index to 'whichmon' */ -midx(whichmon) -char whichmon; +int +midx(char whichmon) { if (isupper(whichmon)) return(whichmon - 'A'); /* 0 to 25 for uppercase */ @@ -363,8 +363,8 @@ char whichmon; * See when monster should run or fight. Return * TRUE if hit points less than acceptable. */ -monhurt(th) -struct thing *th; +bool +monhurt(struct thing *th) { reg int ewis, crithp, f1, f2; reg struct stats *st; diff --git a/srogue/move.c b/srogue/move.c index 2a87f88..bc7ea7f 100644 --- a/srogue/move.c +++ b/srogue/move.c @@ -14,6 +14,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include #include #include "rogue.h" #include "rogue.ext" @@ -29,8 +30,8 @@ struct coord nh; * Start the hero running */ -do_run(ch) -char ch; +void +do_run(char ch) { running = TRUE; after = FALSE; @@ -43,8 +44,8 @@ char ch; * consequences (fighting, picking up, etc.) */ -do_move(dy, dx) -int dy, dx; +void +do_move(int dy, int dx) { reg int ch; reg struct room *rp; @@ -209,8 +210,8 @@ int dy, dx; * Called to illuminate a room. * If it is dark, remove anything that might move. */ -light(cp) -struct coord *cp; +void +light(struct coord *cp) { reg struct room *rp; reg int j, k, x, y; @@ -291,8 +292,8 @@ struct coord *cp; * show: * returns what a certain thing will display as to the un-initiated */ -show(y, x) -int y, x; +char +show(int y, int x) { reg char ch = winat(y, x); reg struct linked_list *it; @@ -330,9 +331,8 @@ int y, x; * be_trapped: * Hero or monster stepped on a trap. */ -be_trapped(tc, th) -struct thing *th; -struct coord *tc; +int +be_trapped(struct coord *tc, struct thing *th) { reg struct trap *trp; reg int ch, ishero; @@ -340,7 +340,7 @@ struct coord *tc; char stuckee[35], seeit, sayso; if ((trp = trap_at(tc->y, tc->x)) == NULL) - return; + return 0; ishero = (th == &player); if (ishero) { strcpy(stuckee, "You"); @@ -491,7 +491,7 @@ goner: if ((trp->tr_flags & ISGONE) && rnd(100) < 10) { nlmove = TRUE; if (rnd(100) < 15) - teleport(rndspot); /* teleport away */ + teleport(rndspot, th); /* teleport away */ else if(rnd(100) < 15 && level > 2) { level -= rnd(2) + 1; new_level(NORMLEV); @@ -519,7 +519,8 @@ goner: * dip_it: * Dip an object into a magic pool */ -dip_it() +void +dip_it(void) { reg struct linked_list *what; reg struct object *ob; @@ -654,8 +655,7 @@ dip_it() * Find the trap at (y,x) on screen. */ struct trap * -trap_at(y, x) -int y, x; +trap_at(int y, int x) { reg struct trap *tp, *ep; @@ -673,8 +673,7 @@ int y, x; * move in a random direction if the monster/person is confused */ struct coord * -rndmove(who) -struct thing *who; +rndmove(struct thing *who) { reg int x, y, ex, ey, ch; int nopen = 0; @@ -720,8 +719,8 @@ struct thing *who; * isatrap: * Returns TRUE if this character is some kind of trap */ -isatrap(ch) -char ch; +bool +isatrap(char ch) { switch(ch) { case POST: diff --git a/srogue/new_leve.c b/srogue/new_leve.c index 6edad35..5a3c106 100644 --- a/srogue/new_leve.c +++ b/srogue/new_leve.c @@ -17,14 +17,16 @@ #include "rogue.h" #include "rogue.ext" +void put_things(void); + /* * new_level: * Dig and draw a new level */ -new_level(ltype) -int ltype; +void +new_level(int ltype) { - register i; + register int i; register char ch; struct coord traploc; struct room *rp; @@ -145,9 +147,10 @@ again: * rnd_room: * Pick a room that is really there */ -rnd_room() +int +rnd_room(void) { - register rm; + register int rm; if (levtype != NORMLEV) rm = 0; @@ -166,9 +169,10 @@ rnd_room() * put potions and scrolls on this level */ -put_things() +void +put_things(void) { - register i, cnt, rm; + register int i, cnt, rm; struct linked_list *item; struct object *cur; struct coord tp; diff --git a/srogue/options.c b/srogue/options.c index 199bf57..ab8495a 100644 --- a/srogue/options.c +++ b/srogue/options.c @@ -30,7 +30,7 @@ struct optstruct { typedef struct optstruct OPTION; -int put_str(), get_str(); +int allowchange(OPTION *opt); OPTION optlist[] = { { "name", "Name: ", whoami }, @@ -46,7 +46,8 @@ OPTION safeoptlist[] = { /* * print and then set options from the terminal */ -option() +void +option(void) { reg OPTION *op; reg int wh; @@ -106,9 +107,8 @@ option() * Set a string option */ #define CTRLB 2 -get_str(opt, awin) -char *opt; -WINDOW *awin; +int +get_str(char *opt, WINDOW *awin) { reg char *sp; reg int c, oy, ox; @@ -119,7 +119,7 @@ WINDOW *awin; /* * loop reading in the string, and put it in a temporary buffer */ - for (sp = buf; (c=readchar(awin)) != '\n' && c != '\r' && c != ESCAPE; + for (sp = buf; (c=readchar()) != '\n' && c != '\r' && c != ESCAPE; wclrtoeol(awin), draw(awin)) { if (sp - buf >= 50) { *sp = '\0'; /* line was too long */ @@ -186,8 +186,8 @@ WINDOW *awin; * or the end of the entire option string. */ -parse_opts(str) -char *str; +void +parse_opts(char *str) { reg char *sp; reg OPTION *op; @@ -231,9 +231,8 @@ char *str; /* * copy string using unctrl for things */ -strucpy(s1, s2, len) -char *s1, *s2; -int len; +void +strucpy(char *s1, char *s2, int len) { reg char *sp; diff --git a/srogue/pack.c b/srogue/pack.c index 133046c..b7f3d7f 100644 --- a/srogue/pack.c +++ b/srogue/pack.c @@ -24,9 +24,8 @@ * is non-null use it as the linked_list pointer instead of * getting it off the ground. */ -add_pack(item, silent) -struct linked_list *item; -bool silent; +bool +add_pack(struct linked_list *item, bool silent) { reg struct linked_list *ip, *lp; reg struct object *obj, *op = NULL; @@ -191,9 +190,8 @@ picked_up: * inventory: * Show what items are in a specific list */ -inventory(list, type) -struct linked_list *list; -int type; +bool +inventory(struct linked_list *list, int type) { reg struct linked_list *pc; reg struct object *obj; @@ -229,8 +227,8 @@ int type; * pick_up: * Add something to characters pack. */ -pick_up(ch) -char ch; +void +pick_up(char ch) { nochange = FALSE; switch(ch) { @@ -254,7 +252,8 @@ char ch; * picky_inven: * Allow player to inventory a single item */ -picky_inven() +void +picky_inven(void) { reg struct linked_list *item; reg char ch, mch; @@ -288,9 +287,7 @@ picky_inven() * pick something out of a pack for a purpose */ struct linked_list * -get_item(purpose, type) -char *purpose; -int type; +get_item(char *purpose, int type) { reg struct linked_list *obj, *pit, *savepit = NULL; struct object *pob; @@ -408,8 +405,7 @@ int type; * Get the character of a particular item in the pack */ char -pack_char(obj) -struct object *obj; +pack_char(struct object *obj) { reg struct linked_list *item; reg char c; @@ -427,7 +423,8 @@ struct object *obj; * idenpack: * Identify all the items in the pack */ -idenpack() +void +idenpack(void) { reg struct linked_list *pc; @@ -440,8 +437,8 @@ idenpack() * del_pack: * Take something out of the hero's pack */ -del_pack(what) -struct linked_list *what; +void +del_pack(struct linked_list *what) { reg struct object *op; @@ -461,8 +458,8 @@ struct linked_list *what; * cur_null: * This updates cur_weapon etc for dropping things */ -cur_null(op) -struct object *op; +void +cur_null(struct object *op) { if (op == cur_weapon) cur_weapon = NULL; diff --git a/srogue/passages.c b/srogue/passages.c index 85a34b4..211547b 100644 --- a/srogue/passages.c +++ b/srogue/passages.c @@ -14,15 +14,20 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include #include "rogue.h" #include "rogue.ext" +void conn(int r1, int r2); +void door(struct room *rm, struct coord *cp); + /* * do_passages: * Draw all the passages on a level. */ -do_passages() +void +do_passages(void) { reg struct rdes *r1, *r2 = NULL; reg int i, j; @@ -123,8 +128,8 @@ do_passages() * Cconnect two rooms. */ -conn(r1, r2) -int r1, r2; +void +conn(int r1, int r2) { reg struct room *rpf, *rpt = NULL; reg char rmt, direc; @@ -255,9 +260,8 @@ int r1, r2; * also enters the door in the exits array of the room. */ -door(rm, cp) -struct room *rm; -struct coord *cp; +void +door(struct room *rm, struct coord *cp) { cmov(*cp); addch(rnd(10) < level - 1 && rnd(100) < 20 ? SECRETDOOR : DOOR); @@ -269,7 +273,8 @@ struct coord *cp; * add_pass: * add the passages to the current window (wizard command) */ -add_pass() +void +add_pass(void) { reg int y, x, ch; diff --git a/srogue/potions.c b/srogue/potions.c index 4fbbe0d..35ab448 100644 --- a/srogue/potions.c +++ b/srogue/potions.c @@ -23,7 +23,8 @@ * quaff: * Let the hero drink a potion */ -quaff() +void +quaff(void) { reg struct object *obj; reg struct linked_list *item, *titem; @@ -189,7 +190,7 @@ quaff() p_know[P_XHEAL] = TRUE; if (!iswearing(R_SLOW)) notslow(FALSE); - unconfuse(); + unconfuse(FALSE); extinguish(unconfuse); sight(FALSE); } diff --git a/srogue/pstats.c b/srogue/pstats.c index b7d4c01..f06b267 100644 --- a/srogue/pstats.c +++ b/srogue/pstats.c @@ -13,15 +13,15 @@ #include "rogue.h" #include "rogue.ext" +void updabil(int what, int amt, struct real *pst, int how); +int hungdam(void); /* * chg_hpt: * Changes players hit points */ -chg_hpt(howmany, alsomax, what) -int howmany; -bool alsomax; -char what; +void +chg_hpt(int howmany, bool alsomax, char what) { nochange = FALSE; if(alsomax) @@ -38,8 +38,8 @@ char what; * rchg_str: * Update the players real strength */ -rchg_str(amt) -int amt; +void +rchg_str(int amt) { chg_abil(STR,amt,TRUE); } @@ -48,8 +48,8 @@ int amt; * chg_abil: * Used to modify the hero's abilities */ -chg_abil(what,amt,how) -int amt, what, how; +void +chg_abil(int what, int amt, int how) { if (amt == 0) return; @@ -66,9 +66,8 @@ int amt, what, how; * updabil: * Do the actual abilities updating */ -updabil(what, amt, pst, how) -struct real *pst; -int what, amt, how; +void +updabil(int what, int amt, struct real *pst, int how) { register int *wh, *mx, *mr; struct real *mst, *msr; @@ -138,8 +137,8 @@ int what, amt, how; * add_haste: * add a haste to the player */ -add_haste(potion) -bool potion; +void +add_haste(bool potion) { if (pl_on(ISHASTE)) { msg("You faint from exhaustion."); @@ -160,9 +159,8 @@ bool potion; * getpdex: * Gets players added dexterity for fighting */ -getpdex(who, heave) -struct stats *who; -bool heave; +int +getpdex(struct stats *who, bool heave) { reg int edex; @@ -217,8 +215,8 @@ bool heave; * getpwis: * Get a players wisdom for fighting */ -getpwis(who) -struct stats *who; +int +getpwis(struct stats *who) { reg int ewis; @@ -249,8 +247,8 @@ struct stats *who; * getpcon: * Get added hit points from players constitution */ -getpcon(who) -struct stats *who; +int +getpcon(struct stats *who) { reg int econ; @@ -282,8 +280,8 @@ struct stats *who; * str_plus: * compute bonus/penalties for strength on the "to hit" roll */ -str_plus(who) -struct stats *who; +int +str_plus(struct stats *who) { reg int hitplus, str; @@ -315,8 +313,8 @@ struct stats *who; * add_dam: * Compute additional damage done depending on strength */ -add_dam(who) -struct stats *who; +int +add_dam(struct stats *who) { reg int exdam, str; @@ -350,7 +348,8 @@ struct stats *who; * hungdam: * Calculate damage depending on players hungry state */ -hungdam() +int +hungdam(void) { switch (hungry_state) { case F_OKAY: @@ -364,9 +363,8 @@ hungdam() * heal_self: * Heal the hero. */ -heal_self(factor, updmaxhp) -int factor; -bool updmaxhp; +void +heal_self(int factor, bool updmaxhp) { him->s_hpt += roll(him->s_lvl + getpcon(him), factor); if (updmaxhp) diff --git a/srogue/rings.c b/srogue/rings.c index 3155570..5549050 100644 --- a/srogue/rings.c +++ b/srogue/rings.c @@ -19,11 +19,15 @@ #include "rogue.h" #include "rogue.ext" +int gethand(bool isrmv); +int ring_eat(void); + /* * ring_on: * Put on a ring */ -ring_on() +void +ring_on(void) { reg struct object *obj; reg struct linked_list *item; @@ -144,7 +148,8 @@ ring_on() * ring_off: * Take off some ring */ -ring_off() +void +ring_off(void) { reg int ring; reg struct object *obj; @@ -178,8 +183,8 @@ ring_off() * toss_ring: * Remove a ring and stop its effects */ -toss_ring(what) -struct object *what; +void +toss_ring(struct object *what) { bool okring; @@ -228,8 +233,8 @@ struct object *what; * gethand: * Get a hand to wear a ring */ -gethand(isrmv) -bool isrmv; +int +gethand(bool isrmv) { reg int c; char *ptr; @@ -280,7 +285,8 @@ bool isrmv; * ring_eat: * How much food do the hero's rings use up? */ -ring_eat() +int +ring_eat(void) { reg struct object *lb; reg int hand, i, howmuch; @@ -335,8 +341,7 @@ ring_eat() * Print ring bonuses */ char * -ring_num(what) -struct object *what; +ring_num(struct object *what) { static char number[5]; @@ -355,8 +360,8 @@ struct object *what; * magring: * Returns TRUE if a ring has a number, i.e. +2 */ -magring(what) -struct object *what; +bool +magring(struct object *what) { switch(what->o_which) { case R_SPEED: @@ -379,7 +384,8 @@ struct object *what; * ringabil: * Compute effective abilities due to rings */ -ringabil() +void +ringabil(void) { reg struct object *rptr; reg int i; @@ -406,10 +412,10 @@ ringabil() * init_ring: * Initialize a ring */ -init_ring(what,fromwiz) -struct object *what; -bool fromwiz; /* TRUE when from wizards */ +void +init_ring(struct object *what, bool fromwiz) { + /* fromwiz: TRUE when from wizards */ reg int much; switch (what->o_which) { @@ -459,8 +465,8 @@ bool fromwiz; /* TRUE when from wizards */ * ringex: * Get extra gains from rings */ -ringex(rtype) -int rtype; +int +ringex(int rtype) { reg int howmuch = 0; @@ -475,8 +481,8 @@ int rtype; * iswearing: * Returns TRUE when the hero is wearing a certain type of ring */ -iswearing(ring) -int ring; +bool +iswearing(int ring) { return (isring(LEFT,ring) || isring(RIGHT,ring)); } @@ -485,8 +491,8 @@ int ring; * isring: * Returns TRUE if a ring is on a hand */ -isring(hand,ring) -int hand, ring; +bool +isring(int hand, int ring) { if (cur_ring[hand] != NULL && cur_ring[hand]->o_which == ring) return TRUE; diff --git a/srogue/rip.c b/srogue/rip.c index ce3b38c..a923572 100644 --- a/srogue/rip.c +++ b/srogue/rip.c @@ -50,8 +50,8 @@ static char *rip[] = { extern int scorefd; extern FILE *logfile; -char *killname(); -void writelog(int amount, int aflag, char monst); +char *killname(unsigned char monst); +void showpack(bool winner, char *howso); /* * death: @@ -59,8 +59,8 @@ void writelog(int amount, int aflag, char monst); */ #include -death(monst) -char monst; +void +death(char monst) { reg char dp, *killer; struct tm *lt; @@ -119,9 +119,8 @@ int oldpurse; * score: * Figure score and post it. */ -score(amount, aflag, monst) -char monst; -int amount, aflag; +void +score(int amount, int aflag, char monst) { reg struct sc_ent *scp, *sc2; reg int i, fd, prflags = 0; @@ -261,8 +260,8 @@ void writelog(int amount, int aflag, char monst) * showtop: * Display the top ten on the screen */ -showtop(showname) -int showname; +bool +showtop(int showname) { reg int fd, i; char *killer; @@ -310,7 +309,8 @@ int showname; * total_winner: * The hero made it back out alive */ -total_winner() +void +total_winner(void) { clear(); addstr(" \n"); @@ -345,9 +345,8 @@ addstr("a great profit and are admitted to the fighters guild.\n"); * showpack: * Display the contents of the hero's pack */ -showpack(winner, howso) -bool winner; -char *howso; +void +showpack(bool winner, char *howso) { reg char *iname; reg int cnt, worth, ch; @@ -392,8 +391,7 @@ char *howso; * Returns what the hero was killed by. */ char * -killname(monst) -unsigned char monst; +killname(unsigned char monst) { if (monst < MAXMONS + 1) return monsters[monst].m_name; diff --git a/srogue/rogue.ext b/srogue/rogue.ext index f44c6a9..6439723 100644 --- a/srogue/rogue.ext +++ b/srogue/rogue.ext @@ -2,11 +2,10 @@ EXTTHG player; EXTWEP weaps[]; EXTARM armors[]; EXTMON monsters[], *mtlev[]; -EXTTRAP *trap_at(), traps[]; -EXTROOM *roomin(), *oldrp, rooms[]; -EXTCORD *rndmove(), *rnd_pos(), delta, stairs, oldpos, rndspot; -EXTLKL *mlist, *lvl_obj, *new_item(), *new_thing(), *new_monster(); -EXTLKL *find_mons(), *wake_monster(), *find_obj(), *get_item(); +EXTTRAP traps[]; +EXTROOM *oldrp, rooms[]; +EXTCORD delta, stairs, oldpos, rndspot; +EXTLKL *mlist, *lvl_obj; EXTOBJ *cur_armor, *cur_weapon, *cur_ring[]; EXTMAG r_magic[], s_magic[], ws_magic[], p_magic[]; EXTMAG things[], a_magic[], w_magic[]; @@ -14,20 +13,16 @@ EXTINT max_hp, quiet, food_left, hungry_state, level, max_level; EXTINT foodlev, total, count, demoncnt, fung_hit, ntraps; EXTINT lastscore, purse, mpos, seed, dnum, no_food, packvol, playuid; EXTINT curprice, trader, group, levcount, levtype, ringfood, playgid; -EXTINT chkstairs(), rollwand(), swander(), notslow(), notfight(), rnd(); -EXTINT rchg_str(), wghtchk(), stomach(), doctor(), runners(), status(), sight(); -extern void quit(), auto_save(), endit(), byebye(), game_err(); -EXTINT prntfile(), unconfuse(), sapem(); -EXTINT noteth(), notregen(), notinvinc(), unsee(), nohaste(), npch(); +EXTINT chkstairs(), notfight(); +EXTINT prntfile(); EXTBOOL running, nochange, after, inwhgt, isfight, firstmove, nlmove; EXTBOOL wizard, waswizard, in_shell, amulet, door_stop, playing, use_savedir; EXTBOOL notify, ws_know[], p_know[], s_know[], r_know[], inpool; EXTCHAR home[], file_name[], whoami[], fruit[], curpurch[], scorefile[]; EXTCHAR *r_stones[], *p_colors[], *s_names[], *ws_type[], *ws_made[]; EXTCHAR *ws_guess[], *s_guess[], *r_guess[], *p_guess[];/*, *unctrl();*/ -EXTCHAR morestr[], prbuf[], huh[], *identify(), *vowelstr(); -EXTCHAR *new(), *strcpy(), *strcat(), *inv_name(), pack_char(), *prname(); -EXTCHAR *num(), *getenv(), *tr_name(), *release, take, runch; +EXTCHAR morestr[], prbuf[], huh[]; +EXTCHAR *release, take, runch; EXTCHAR retstr[], wizstr[], spacemsg[], illegal[], callit[], starlist[]; EXTSTAT max_stats, *him; extern struct magic_info thnginfo[]; @@ -46,3 +41,207 @@ extern char *stones[NSTONES]; extern char *wood[NWOOD]; extern char *metal[NMETAL]; +void _attach(struct linked_list **list, struct linked_list *item); +void _detach(struct linked_list **list, struct linked_list *item); +void _free_list(struct linked_list **ptr); +void activity(void); +int add_dam(struct stats *who); +void add_haste(bool potion); +void add_mon(struct room *rm, bool treas); +bool add_pack(struct linked_list *item, bool silent); +void add_pass(void); +void addmsg(char *fmt, ...); +void aggravate(void); +int attack(struct thing *mp); +bool author(void); +void auto_save(int a); +int be_trapped(struct coord *tc, struct thing *th); +void buy_it(void); +void byebye(int how); +bool cansee(int y, int x); +char *charge_str(struct object *obj); +void check_level(void); +void chg_abil(int what, int amt, int how); +void chg_hpt(int howmany, bool alsomax, char what); +void command(void); +bool cordok(int y, int x); +void create_obj(bool fscr); +void cur_null(struct object *op); +void dbotline(WINDOW *scr, char *message); +bool dead_end(char ch); +void death(char monst); +void del_pack(struct linked_list *what); +bool diag_ok(struct coord *sp, struct coord *ep); +void dip_it(void); +void discard(struct linked_list *item); +void displevl(void); +void dispmax(void); +void dispmons(void); +void do_daemons(int flag); +void do_fuses(void); +void do_maze(void); +void do_motion(struct object *obj, int ydelta, int xdelta); +void do_move(int dy, int dx); +void do_passages(void); +void do_post(void); +void do_rooms(void); +void do_run(char ch); +void do_zap(bool gotdir); +void doctor(int fromfuse); +void draw_room(struct room *rp); +int drop(struct linked_list *item); +bool dropcheck(struct object *op); +void eat(void); +int encread(void *starta, unsigned int size, int inf); +void encwrite(void *starta, unsigned int size, FILE *outf); +void endit(int a); +void endmsg(void); +void extinguish(int (*func)()); +int extras(void); +void fall(struct linked_list *item, bool pr); +bool fallpos(struct coord *pos, struct coord *newpos, bool passages); +void fatal(char *s); +bool fight(struct coord *mp, struct object *weap, bool thrown); +struct linked_list *find_mons(int y, int x); +struct linked_list *find_obj(int y, int x); +void fix_stick(struct object *cur); +void fuse(int (*func)(), int arg, int time); +void game_err(int a); +void genocide(void); +bool get_dir(void); +struct linked_list *get_item(char *purpose, int type); +int get_str(char *opt, WINDOW *awin); +int get_worth(struct object *obj); +int getbless(void); +int getindex(char what); +int getpcon(struct stats *who); +int getpdex(struct stats *who, bool heave); +int getpwis(struct stats *who); +void heal_self(int factor, bool updmaxhp); +bool hit_monster(struct coord *mp, struct object *obj); +int hitweight(void); +bool hurt_armor(struct object *obj); +void idenpack(void); +char *identify(int what); +void ignore(void); +bool illeg_ch(unsigned char ch); +void init_everything(void); +void init_ring(struct object *what, bool fromwiz); +void init_weapon(struct object *weap, int type); +void initarmor(struct object *obj, int what); +void initfood(struct object *what); +char *inv_name(struct object *obj, bool drop); +bool inventory(struct linked_list *list, int type); +int itemvol(struct object *wh); +int itemweight(struct object *wh); +bool is_current(struct object *obj); +bool is_magic(struct object *obj); +bool isatrap(char ch); +bool isring(int hand, int ring); +bool iswearing(int ring); +void killed(struct linked_list *item, bool pr); +void lengthen(int (*func)(), int xtime); +void lev_mon(void); +void light(struct coord *cp); +void look(bool wakeup); +bool magring(struct object *what); +bool makemons(int what); +int midx(char whichmon); +void missile(int ydelta, int xdelta); +void money(void); +bool monhurt(struct thing *th); +void msg(char *fmt, ...); +char *new(int size); +struct linked_list *new_item(int size); +void new_level(int ltype); +struct linked_list *new_monster(char type, struct coord *cp, bool treas); +struct linked_list *new_thing(bool treas, int type, int which); +void nohaste(int fromfuse); +void noteth(int fromfuse); +void notinvinc(int fromfuse); +void notregen(int fromfuse); +void notslow(int fromfuse); +char npch(char ch); +char *num(int n1, int n2); +bool o_off(struct object *what, long bit); +bool o_on(struct object *what, long bit); +void option(void); +char pack_char(struct object *obj); +void parse_opts(char *str); +bool passwd(void); +int pick_one(struct magic_item *mag); +void pick_up(char ch); +void picky_inven(void); +bool pl_off(long what); +bool pl_on(long what); +void playit(void); +bool price_it(void); +void quaff(void); +void quit(int a); +void raise_level(void); +void rchg_str(int amt); +void read_scroll(void); +int readchar(void); +void remove_monster(struct coord *mp, struct linked_list *item); +void resoflg(struct object *what, long bit); +bool restore(char *file, char **envp); +void restscr(WINDOW *scr); +bool rf_on(struct room *rm, long bit); +char *ring_num(struct object *what); +void ring_off(void); +void ring_on(void); +void ringabil(void); +int ringex(int rtype); +int rnd(int range); +char rnd_mon(bool wander, bool baddie); +struct coord *rnd_pos(struct room *rp); +int rnd_room(void); +struct coord *rndmove(struct thing *who); +int roll(int number, int sides); +void rollwand(int fromfuse); +struct room *roomin(struct coord *cp); +int rs_restore_file(int inf); +int rs_save_file(FILE *savef); +void runners(void); +void runto(struct coord *runner, struct coord *spot); +void sapem(int fromfuse); +bool save(int which); +bool save_game(void); +bool save_throw(int which, struct thing *tp); +void score(int amount, int aflag, char monst); +void sell_it(void); +void setoflg(struct object *what, long bit); +void setup(void); +char show(int y, int x); +bool showtop(int showname); +void sight(int fromfuse); +void start_daemon(int (*func)(), int arg, int type); +void status(int fromfuse); +bool step_ok(unsigned char ch); +void stomach(int fromfuse); +int str_plus(struct stats *who); +void strucpy(char *s1, char *s2, int len); +void swander(int fromfuse); +bool swing(int at_lvl, int op_arm, int wplus); +void take_off(void); +int teleport(struct coord spot, struct thing *th); +void toss_ring(struct object *what); +void total_winner(void); +int totalenc(void); +char *tr_name(char ch); +struct trap *trap_at(int y, int x); +void unconfuse(int fromfuse); +void unhold(char whichmon); +void unsee(int fromfuse); +void updpack(void); +char *vowelstr(char *str); +void wait_for(WINDOW *win, char ch); +struct linked_list *wake_monster(int y, int x); +void wanderer(void); +void waste_time(void); +void wear(void); +void wghtchk(int fromfuse); +void whatis(struct linked_list *what); +void wield(void); +char winat(int y, int x); +void writelog(int amount, int aflag, char monst); diff --git a/srogue/rooms.c b/srogue/rooms.c index 13c4239..eaec22e 100644 --- a/srogue/rooms.c +++ b/srogue/rooms.c @@ -17,11 +17,15 @@ #include "rogue.h" #include "rogue.ext" +void horiz(int cnt); +void vert(int cnt); + /* * do_rooms: * Place the rooms in the dungeon */ -do_rooms() +void +do_rooms(void) { int mloops, mchance, nummons, left_out, roomtries; bool treas = FALSE; @@ -131,9 +135,8 @@ do_rooms() * add_mon: * Add a monster to a room */ -add_mon(rm, treas) -struct room *rm; -bool treas; +void +add_mon(struct room *rm, bool treas) { reg struct thing *tp; reg struct linked_list *item; @@ -165,8 +168,8 @@ bool treas; * draw_room: * Draw a box around a room */ -draw_room(rp) -struct room *rp; +void +draw_room(struct room *rp) { reg int j, k; @@ -197,8 +200,8 @@ struct room *rp; * horiz: * draw a horizontal line */ -horiz(cnt) -int cnt; +void +horiz(int cnt) { while (cnt-- > 0) addch('-'); @@ -209,8 +212,8 @@ int cnt; * vert: * draw a vertical line */ -vert(cnt) -int cnt; +void +vert(int cnt) { reg int x, y; @@ -228,8 +231,7 @@ int cnt; * pick a random spot in a room */ struct coord * -rnd_pos(rp) -struct room *rp; +rnd_pos(struct room *rp) { reg int y, x, i; static struct coord spot; @@ -249,9 +251,8 @@ struct room *rp; * rf_on: * Returns TRUE if flag is set for room stuff */ -rf_on(rm, bit) -struct room *rm; -long bit; +bool +rf_on(struct room *rm, long bit) { return (rm->r_flags & bit); } diff --git a/srogue/save.c b/srogue/save.c index 778258a..b9780fb 100644 --- a/srogue/save.c +++ b/srogue/save.c @@ -32,6 +32,9 @@ EXTCHAR version[]; EXTCHAR *ctime(); +bool dosave(void); +void save_file(FILE *savef); + typedef struct stat STAT; STAT sbuf; @@ -39,7 +42,8 @@ STAT sbuf; * ignore: * Ignore ALL signals possible */ -ignore() +void +ignore(void) { md_ignoreallsignals(); } @@ -48,7 +52,8 @@ ignore() * save_game: * Save the current game */ -save_game() +bool +save_game(void) { reg FILE *savef; reg int c; @@ -136,7 +141,8 @@ game_err(int a) * dosave: * Save the game. UID/GID no longer get reset here. */ -dosave() +bool +dosave(void) { FILE *savef; @@ -157,8 +163,8 @@ dosave() * save_file: * Do the actual save of this game to a file */ -save_file(savef) -FILE *savef; +void +save_file(FILE *savef) { int slines = LINES; int scols = COLS; @@ -182,10 +188,10 @@ FILE *savef; * restore: * Restore a saved game from a file */ -restore(file, envp) -char *file, **envp; +bool +restore(char *file, char **envp) { - register inf, pid; + register int inf, pid; int ret_status; #ifndef _AIX extern char **environ; diff --git a/srogue/scrolls.c b/srogue/scrolls.c index af6dd49..e6f2714 100644 --- a/srogue/scrolls.c +++ b/srogue/scrolls.c @@ -24,7 +24,8 @@ * read_scroll: * Let the hero read a scroll */ -read_scroll() +void +read_scroll(void) { reg struct object *obj; reg struct linked_list *item; diff --git a/srogue/state.c b/srogue/state.c index d9bf35c..fd692ae 100644 --- a/srogue/state.c +++ b/srogue/state.c @@ -70,6 +70,9 @@ #define READSTAT ((format_error == 0) && (read_error == 0)) #define WRITESTAT (write_error == 0) +int rs_read_int(int inf, int *i); +int rs_write_int(FILE *savef, int c); + int read_error = FALSE; int write_error = FALSE; int format_error = FALSE; @@ -82,10 +85,8 @@ char encstr[] = "\354\251\243\332A\201|\301\321p\210\251\327\"\257\365t\341%3\27 /* * perform an encrypted write */ -encwrite(starta, size, outf) -register void *starta; -unsigned int size; -register FILE *outf; +void +encwrite(void *starta, unsigned int size, FILE *outf) { register char *ep; register char *start = starta; @@ -103,10 +104,8 @@ register FILE *outf; /* * perform an encrypted read */ -encread(starta, size, inf) -register void *starta; -unsigned int size; -register int inf; +int +encread(void *starta, unsigned int size, int inf) { register char *ep; register int read_size; @@ -1556,6 +1555,7 @@ rs_write_traps(FILE *savef, struct trap *trap,int count) } } +int rs_read_traps(int inf, struct trap *trap, int count) { int id = 0, value = 0, n = 0; @@ -1885,8 +1885,8 @@ rs_read_thing(int inf, struct thing *t) return(READSTAT); } -rs_fix_monster_list(list) -struct linked_list *list; +void +rs_fix_monster_list(struct linked_list *list) { struct linked_list *item; @@ -1970,6 +1970,7 @@ rs_write_object_reference(FILE *savef, struct linked_list *list, return(WRITESTAT); } +int rs_read_object_reference(int inf, struct linked_list *list, struct object **item) { @@ -2225,6 +2226,7 @@ rs_save_file(FILE *savef) return(WRITESTAT); } +int rs_restore_file(int inf) { bool junk; diff --git a/srogue/sticks.c b/srogue/sticks.c index 0998106..6543011 100644 --- a/srogue/sticks.c +++ b/srogue/sticks.c @@ -16,15 +16,18 @@ */ #include +#include #include "rogue.h" #include "rogue.ext" +void drain(int ymin, int ymax, int xmin, int xmax); + /* * fix_stick: * Init a stick for the hero */ -fix_stick(cur) -struct object *cur; +void +fix_stick(struct object *cur) { struct rod *rd; @@ -62,8 +65,8 @@ struct object *cur; * do_zap: * Zap a stick at something */ -do_zap(gotdir) -bool gotdir; +void +do_zap(bool gotdir) { reg struct linked_list *item; reg struct object *obj; @@ -537,8 +540,8 @@ bool gotdir; * drain: * Do drain hit points from player stick */ -drain(ymin, ymax, xmin, xmax) -int ymin, ymax, xmin, xmax; +void +drain(int ymin, int ymax, int xmin, int xmax) { reg int i, j, cnt; reg struct thing *ick; @@ -580,8 +583,7 @@ int ymin, ymax, xmin, xmax; * Return number of charges left in a stick */ char * -charge_str(obj) -struct object *obj; +charge_str(struct object *obj) { static char buf[20]; diff --git a/srogue/things.c b/srogue/things.c index 0333389..b10386f 100644 --- a/srogue/things.c +++ b/srogue/things.c @@ -20,15 +20,14 @@ #include "rogue.h" #include "rogue.ext" +void basic_init(struct object *cur); /* * inv_name: * Return the name of something as it would appear in an inventory. */ char * -inv_name(obj, drop) -struct object *obj; -bool drop; +inv_name(struct object *obj, bool drop) { reg char *pb, *tn, *pl; reg int wh, knowit; @@ -183,7 +182,8 @@ bool drop; * money: * Add to characters purse */ -money() +void +money(void) { reg struct room *rp; reg struct linked_list *item; @@ -215,8 +215,8 @@ money() * drop: * put something down */ -drop(item) -struct linked_list *item; +int +drop(struct linked_list *item) { reg char ch; reg struct linked_list *ll, *nll; @@ -281,8 +281,8 @@ struct linked_list *item; * dropcheck: * Do special checks for dropping or unweilding|unwearing|unringing */ -dropcheck(op) -struct object *op; +bool +dropcheck(struct object *op) { if (op == NULL) return TRUE; @@ -320,9 +320,7 @@ struct object *op; * Return a new thing */ struct linked_list * -new_thing(treas, type, which) -int type, which; -bool treas; +new_thing(bool treas, int type, int which) { struct linked_list *item; struct magic_item *mi; @@ -404,8 +402,8 @@ bool treas; * basic_init: * Set all params of an object to the basic values. */ -basic_init(cur) -struct object *cur; +void +basic_init(struct object *cur) { cur->o_ac = 11; cur->o_count = 1; @@ -423,7 +421,8 @@ struct object *cur; * extras: * Return the number of extra items to be created */ -extras() +int +extras(void) { reg int i; @@ -441,8 +440,8 @@ extras() * pick_one: * Pick an item out of a list of nitems possible magic items */ -pick_one(mag) -struct magic_item *mag; +int +pick_one(struct magic_item *mag) { reg struct magic_item *start; reg int i; diff --git a/srogue/trader.c b/srogue/trader.c index 98e1d12..2d8bf71 100644 --- a/srogue/trader.c +++ b/srogue/trader.c @@ -11,16 +11,25 @@ */ #include +#include #include "rogue.h" #include "rogue.ext" #define NOTPRICED -1 +bool open_market(void); +void trans_line(void); +void draw_maze(void); +int findcells(int y, int x); +void rmwall(int newy, int newx, int oldy, int oldx); +void crankout(void); + /* * do_post: * Put a trading post room and stuff on the screen */ -do_post() +void +do_post(void) { struct coord tp; reg int i; @@ -66,7 +75,8 @@ do_post() * price_it: * Price the object that the hero stands on */ -price_it() +bool +price_it(void) { static char *bargain[] = { "great bargain", @@ -100,7 +110,8 @@ price_it() * buy_it: * Buy the item on which the hero stands */ -buy_it() +void +buy_it(void) { reg int wh; @@ -151,7 +162,8 @@ buy_it() * sell_it: * Sell an item to the trading post */ -sell_it() +void +sell_it(void) { reg struct linked_list *item; reg struct object *obj; @@ -199,7 +211,8 @@ sell_it() * open_market: * Retruns TRUE when ok do to transacting */ -open_market() +bool +open_market(void) { if (trader >= MAXPURCH) { msg("The market is closed. The stairs are that-a-way."); @@ -213,8 +226,8 @@ open_market() * get_worth: * Calculate an objects worth in gold */ -get_worth(obj) -struct object *obj; +int +get_worth(struct object *obj) { reg int worth, wh; @@ -272,7 +285,8 @@ struct object *obj; * trans_line: * Show how many transactions the hero has left */ -trans_line() +void +trans_line(void) { sprintf(prbuf,"You have %d transactions remaining.",MAXPURCH-trader); mvwaddstr(cw, LINES - 4, 0, prbuf); @@ -282,7 +296,8 @@ trans_line() * domaze: * Draw the maze on this level. */ -do_maze() +void +do_maze(void) { struct coord tp; reg int i, least; @@ -328,14 +343,16 @@ struct bordercells { } mborder; char *frontier, *bits; -char *moffset(), *foffset(); +char *moffset(int y, int x); +char *foffset(int y, int x); int tlines, tcols; /* * draw_maze: * Generate and draw the maze on the screen */ -draw_maze() +void +draw_maze(void) { reg int i, j, more; reg char *ptr; @@ -372,8 +389,7 @@ draw_maze() * Calculate memory address for bits */ char * -moffset(y, x) -int y, x; +moffset(int y, int x) { char *ptr; @@ -386,8 +402,7 @@ int y, x; * Calculate memory address for frontier */ char * -foffset(y, x) -int y, x; +foffset(int y, int x) { char *ptr; @@ -399,8 +414,8 @@ int y, x; * findcells: * Figure out cells to open up */ -findcells(y,x) -int x, y; +int +findcells(int y, int x) { reg int rtpos, i; @@ -450,8 +465,8 @@ int x, y; * rmwall: * Removes appropriate walls from the maze */ -rmwall(newy, newx, oldy, oldx) -int newy, newx, oldy, oldx; +void +rmwall(int newy, int newx, int oldy, int oldx) { reg int xdif,ydif; @@ -467,7 +482,8 @@ int newy, newx, oldy, oldx; * crankout: * Does actual drawing of maze to window */ -crankout() +void +crankout(void) { reg int x, y, i; diff --git a/srogue/weapons.c b/srogue/weapons.c index 7102a1f..f2af17e 100644 --- a/srogue/weapons.c +++ b/srogue/weapons.c @@ -14,6 +14,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include #include #include "rogue.h" #include "rogue.ext" @@ -22,8 +23,8 @@ * missile: * Fire a missile in a given direction */ -missile(ydelta, xdelta) -int ydelta, xdelta; +void +missile(int ydelta, int xdelta) { reg struct object *obj, *nowwield; reg struct linked_list *item, *nitem; @@ -83,9 +84,8 @@ int ydelta, xdelta; * do the actual motion on the screen done by an object traveling * across the room */ -do_motion(obj, ydelta, xdelta) -struct object *obj; -int ydelta, xdelta; +void +do_motion(struct object *obj, int ydelta, int xdelta) { reg int ch, y, x; @@ -120,9 +120,8 @@ int ydelta, xdelta; * Drop an item someplace around here. */ -fall(item, pr) -struct linked_list *item; -bool pr; +void +fall(struct linked_list *item, bool pr) { reg struct object *obj; reg struct room *rp; @@ -155,9 +154,8 @@ bool pr; * Set up the initial goodies for a weapon */ -init_weapon(weap, type) -struct object *weap; -int type; +void +init_weapon(struct object *weap, int type) { reg struct init_weps *iwp; @@ -182,9 +180,8 @@ int type; * hit_monster: * Does the missile hit the monster */ -hit_monster(mp, obj) -struct coord *mp; -struct object *obj; +bool +hit_monster(struct coord *mp, struct object *obj) { return fight(mp, obj, TRUE); } @@ -194,8 +191,7 @@ struct object *obj; * Figure out the plus number for armor/weapons */ char * -num(n1, n2) -int n1, n2; +num(int n1, int n2) { static char numbuf[LINLEN]; @@ -212,7 +208,8 @@ int n1, n2; * wield: * Pull out a certain weapon */ -wield() +void +wield(void) { reg struct linked_list *item; reg struct object *obj, *oweapon; @@ -238,9 +235,8 @@ wield() * fallpos: * Pick a random position around the give (y, x) coordinates */ -fallpos(pos, newpos, passages) -struct coord *pos, *newpos; -bool passages; +bool +fallpos(struct coord *pos, struct coord *newpos, bool passages) { reg int y, x, ch; diff --git a/srogue/wizard.c b/srogue/wizard.c index 5b6be50..d8c0fbf 100644 --- a/srogue/wizard.c +++ b/srogue/wizard.c @@ -16,6 +16,7 @@ #include #include +#include #include "rogue.h" #include "rogue.ext" @@ -23,8 +24,8 @@ * whatis: * What a certain object is */ -whatis(what) -struct linked_list *what; +void +whatis(struct linked_list *what) { reg struct object *obj; reg struct linked_list *item; @@ -74,8 +75,8 @@ struct linked_list *what; * create_obj: * Create any object for wizard or scroll (almost) */ -create_obj(fscr) -bool fscr; +void +create_obj(bool fscr) { reg struct linked_list *item; reg struct object *obj; @@ -245,7 +246,8 @@ bool fscr; * getbless: * Get a blessing for a wizards object */ -getbless() +int +getbless(void) { int bless; @@ -263,8 +265,8 @@ getbless() * makemons: * Make a monster */ -makemons(what) -int what; +bool +makemons(int what) { reg int x, y, oktomake = FALSE, appear = 1; struct coord mp; @@ -293,9 +295,8 @@ int what; * telport: * Bamf the thing someplace else */ -teleport(spot, th) -struct coord spot; -struct thing *th; +int +teleport(struct coord spot, struct thing *th) { reg int rm, y, x; struct coord oldspot; @@ -345,7 +346,8 @@ struct thing *th; * passwd: * See if user knows password */ -passwd() +bool +passwd(void) { reg char *sp, c; bool passok; From f38b2223c86b3c46d47ce8aff114f2e4da95c4b2 Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Sun, 7 Feb 2016 14:39:21 -0500 Subject: [PATCH 5/7] Advanced Rogue 5: convert to ANSI function declarations. This still leaves over a thousand lines of warning messages, mostly related to the return types of daemons and fuses. --- arogue5/chase.c | 44 +++---- arogue5/command.c | 42 ++++--- arogue5/daemon.c | 32 ++--- arogue5/daemons.c | 83 ++++++++----- arogue5/encumb.c | 28 +++-- arogue5/fight.c | 122 +++++++++---------- arogue5/init.c | 27 +++-- arogue5/io.c | 61 +++++----- arogue5/list.c | 36 +++--- arogue5/main.c | 79 ++++++------ arogue5/maze.c | 38 +++--- arogue5/mdport.c | 42 ++++--- arogue5/misc.c | 36 +++--- arogue5/monsters.c | 38 +++--- arogue5/move.c | 55 ++++----- arogue5/new_level.c | 17 ++- arogue5/options.c | 72 +++++------ arogue5/outside.c | 19 ++- arogue5/pack.c | 79 ++++++------ arogue5/passages.c | 16 ++- arogue5/player.c | 18 ++- arogue5/potions.c | 49 ++++---- arogue5/rings.c | 14 +-- arogue5/rip.c | 52 ++++---- arogue5/rogue.h | 284 ++++++++++++++++++++++++++++++++++++++------ arogue5/rooms.c | 28 +++-- arogue5/save.c | 26 ++-- arogue5/scrolls.c | 11 +- arogue5/state.c | 10 +- arogue5/sticks.c | 25 ++-- arogue5/things.c | 37 +++--- arogue5/trader.c | 31 +++-- arogue5/util.c | 88 +++++++------- arogue5/weapons.c | 34 ++---- arogue5/wear.c | 6 +- arogue5/wizard.c | 28 +++-- arogue5/xcrypt.c | 3 + 37 files changed, 977 insertions(+), 733 deletions(-) diff --git a/arogue5/chase.c b/arogue5/chase.c index f4e107f..8106395 100644 --- a/arogue5/chase.c +++ b/arogue5/chase.c @@ -12,6 +12,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include #include #include #include "curses.h" @@ -21,8 +22,8 @@ coord ch_ret; /* Where chasing takes you */ - - +struct linked_list *get_hurl(struct thing *tp); +bool straight_shot(int ery, int erx, int eey, int eex, coord *shooting); /* @@ -31,8 +32,7 @@ coord ch_ret; /* Where chasing takes you */ */ bool -can_blink(tp) -register struct thing *tp; +can_blink(struct thing *tp) { register int y, x, index=9; coord tryp; /* To hold the coordinates for use in diag_ok */ @@ -128,8 +128,7 @@ register struct thing *tp; */ coord * -can_shoot(er, ee) -register coord *er, *ee; +can_shoot(coord *er, coord *ee) { static coord shoot_dir; @@ -154,13 +153,11 @@ register coord *er, *ee; * FALSE if we reach the goal. */ -chase(tp, ee, flee, mdead) -register struct thing *tp; -register coord *ee; -bool flee; /* True if destination (ee) is player and monster is running away - * or the player is in a wall and the monster can't get to it - */ -bool *mdead; +/* flee: True if destination (ee) is player and monster is running + * away or the player is in a wall and the monster can't get to it + */ +bool +chase(struct thing *tp, coord *ee, bool flee, bool *mdead) { int damage, dist, thisdist, monst_dist = MAXINT; struct linked_list *weapon; @@ -530,10 +527,10 @@ bool *mdead; * do_chase: * Make one thing chase another. */ +/* flee: True if running away or player is inaccessible in wall */ -do_chase(th, flee) -register struct thing *th; -register bool flee; /* True if running away or player is inaccessible in wall */ +void +do_chase(struct thing *th, bool flee) { register struct room *rer, *ree, /* room of chaser, room of chasee */ *orig_rer, /* Original room of chaser */ @@ -830,8 +827,7 @@ register bool flee; /* True if running away or player is inaccessible in wall */ */ struct linked_list * -get_hurl(tp) -register struct thing *tp; +get_hurl(struct thing *tp) { struct linked_list *arrow, *bolt, *rock; register struct linked_list *pitem; @@ -861,7 +857,8 @@ register struct thing *tp; * Make all the running monsters move. */ -runners() +void +runners(void) { register struct linked_list *item; register struct thing *tp = NULL; @@ -935,9 +932,8 @@ runners() * Set a monster running after something */ -runto(runner, spot) -register struct thing *runner; -coord *spot; +void +runto(struct thing *runner, coord *spot) { /* * Start the beastie running @@ -959,9 +955,7 @@ coord *spot; */ bool -straight_shot(ery, erx, eey, eex, shooting) -register int ery, erx, eey, eex; -register coord *shooting; +straight_shot(int ery, int erx, int eey, int eex, coord *shooting) { register int dy, dx; /* Deltas */ char ch; diff --git a/arogue5/command.c b/arogue5/command.c index 84504df..24b90f8 100644 --- a/arogue5/command.c +++ b/arogue5/command.c @@ -21,12 +21,20 @@ #include "rogue.h" #include "mach_dep.h" +void help(void); +void identify(void); +void d_level(void); +void u_level(void); +void shell(void); +void call(bool mark); + /* * command: * Process the user commands */ -command() +void +command(void) { register char ch; register int ntimes = 1; /* Number of player moves */ @@ -207,8 +215,8 @@ command() when 'I' : after = FALSE; picky_inven(); when 'd' : drop(NULL); when 'P' : grab(hero.y, hero.x); - when 'q' : quaff(-1, NULL, TRUE); - when 'r' : read_scroll(-1, NULL, TRUE); + when 'q' : quaff(-1, 0, TRUE); + when 'r' : read_scroll(-1, 0, TRUE); when 'e' : eat(); when 'w' : wield(); when 'W' : wear(); @@ -228,7 +236,7 @@ command() when 'G' : gsense(); when '^' : set_trap(&player, hero.y, hero.x); when 's' : search(FALSE, FALSE); - when 'z' : if (!do_zap(TRUE, NULL, FALSE)) + when 'z' : if (!do_zap(TRUE, 0, FALSE)) after=FALSE; when 'p' : pray(); when 'C' : cast(); @@ -475,8 +483,7 @@ quit(int sig) */ void -bugkill(sig) -int sig; +bugkill(int sig) { signal(sig, quit); /* If we get it again, give up */ death(D_SIGNAL); /* Killed by a bug */ @@ -488,8 +495,8 @@ int sig; * Player gropes about him to find hidden things. */ -search(is_thief, door_chime) -register bool is_thief, door_chime; +void +search(bool is_thief, bool door_chime) { register int x, y; register char ch, /* The trap or door character */ @@ -570,7 +577,8 @@ register bool is_thief, door_chime; * Give single character help, or the whole mess if he wants it */ -help() +void +help(void) { register struct h_list *strp = helpstr; #ifdef WIZARD @@ -664,7 +672,8 @@ help() * Tell the player what a certain thing is. */ -identify() +void +identify(void) { register char ch; const char *str; @@ -726,7 +735,8 @@ identify() * He wants to go down a level */ -d_level() +void +d_level(void) { bool no_phase=FALSE; @@ -770,7 +780,8 @@ d_level() * He wants to go up a level */ -u_level() +void +u_level(void) { bool no_phase = FALSE; register struct linked_list *item; @@ -828,7 +839,8 @@ u_level() * Let him escape for a while */ -shell() +void +shell(void) { /* * Set the terminal back to original mode @@ -859,8 +871,8 @@ shell() /* * allow a user to call a potion, scroll, or ring something */ -call(mark) -bool mark; +void +call(bool mark) { register struct object *obj; register struct linked_list *item; diff --git a/arogue5/daemon.c b/arogue5/daemon.c index 8c02822..59fc05d 100644 --- a/arogue5/daemon.c +++ b/arogue5/daemon.c @@ -36,7 +36,7 @@ int fusecnt = 0; * Find an empty slot in the daemon list */ struct delayed_action * -d_slot() +d_slot(void) { reg int i; reg struct delayed_action *dev; @@ -52,7 +52,7 @@ d_slot() * Find an empty slot in the fuses list */ struct delayed_action * -f_slot() +f_slot(void) { reg int i; reg struct delayed_action *dev; @@ -70,8 +70,7 @@ f_slot() * Find a particular slot in the table */ struct delayed_action * -find_slot(func) -reg int (*func)(); +find_slot(int (*func)()) { reg int i; reg struct delayed_action *dev; @@ -87,6 +86,7 @@ reg int (*func)(); * start_daemon: * Start a daemon, takes a function. */ +void start_daemon(int (*func)(), void *arg, int type) { reg struct delayed_action *dev; @@ -106,8 +106,8 @@ start_daemon(int (*func)(), void *arg, int type) * kill_daemon: * Remove a daemon from the list */ -kill_daemon(func) -reg int (*func)(); +void +kill_daemon(int (*func)()) { reg struct delayed_action *dev; reg int i; @@ -133,8 +133,8 @@ reg int (*func)(); * Run all the daemons that are active with the current flag, * passing the argument to the function. */ -do_daemons(flag) -reg int flag; +void +do_daemons(int flag) { reg struct delayed_action *dev; @@ -154,6 +154,7 @@ reg int flag; * fuse: * Start a fuse to go off in a certain number of turns */ +void fuse(int (*func)(), void *arg, int time, int type) { reg struct delayed_action *wire; @@ -173,8 +174,8 @@ fuse(int (*func)(), void *arg, int time, int type) * lengthen: * Increase the time until a fuse goes off */ -lengthen(func, xtime) -reg int (*func)(), xtime; +void +lengthen(int (*func)(), int xtime) { reg struct delayed_action *wire; @@ -188,8 +189,8 @@ reg int (*func)(), xtime; * extinguish: * Put out a fuse */ -extinguish(func) -reg int (*func)(); +void +extinguish(int (*func)()) { reg struct delayed_action *wire; @@ -207,8 +208,8 @@ reg int (*func)(); * do_fuses: * Decrement counters and start needed fuses */ -do_fuses(flag) -reg int flag; +void +do_fuses(int flag) { reg struct delayed_action *wire; @@ -234,7 +235,8 @@ reg int flag; * activity: * Show wizard number of demaons and memory blocks used */ -activity() +void +activity(void) { sprintf(outstring,"Daemons = %d : Fuses = %d : Memory Items = %d : Memory Used = %d", demoncnt,fusecnt,total,md_memused()); diff --git a/arogue5/daemons.c b/arogue5/daemons.c index 84b25d2..e4df67c 100644 --- a/arogue5/daemons.c +++ b/arogue5/daemons.c @@ -22,8 +22,8 @@ int between = 0; * A healing daemon that restors hit points after rest */ -doctor(tp) -register struct thing *tp; +void +doctor(struct thing *tp) { register int ohp; register int limit, new_points; @@ -100,7 +100,8 @@ register struct thing *tp; * Called when it is time to start rolling for wandering monsters */ -swander() +void +swander(void) { start_daemon(rollwand, 0, BEFORE); } @@ -110,7 +111,8 @@ swander() * Called to roll to see if a wandering monster starts up */ -rollwand() +void +rollwand(void) { if (++between >= 4) { @@ -128,7 +130,8 @@ rollwand() /* * this function is a daemon called each turn when the character is a thief */ -trap_look() +void +trap_look(void) { if (rnd(100) < (2*dex_compute() + 5*pstats.s_lvl)) search(TRUE, FALSE); @@ -139,7 +142,8 @@ trap_look() * Release the poor player from his confusion */ -unconfuse() +void +unconfuse(void) { turn_off(player, ISHUH); msg("You feel less confused now"); @@ -151,7 +155,8 @@ unconfuse() * He lost his see invisible power */ -unsee() +void +unsee(void) { if (!ISWEARING(R_SEEINVIS)) { turn_off(player, CANSEE); @@ -164,7 +169,8 @@ unsee() * Remove to-hit handicap from player */ -unstink() +void +unstink(void) { turn_off(player, HASSTINK); } @@ -174,7 +180,8 @@ unstink() * Player is no longer immune to confusion */ -unclrhead() +void +unclrhead(void) { turn_off(player, ISCLEAR); msg("The blue aura about your head fades away."); @@ -185,7 +192,8 @@ unclrhead() * Player can no longer walk through walls */ -unphase() +void +unphase(void) { turn_off(player, CANINWALL); msg("Your dizzy feeling leaves you."); @@ -197,7 +205,8 @@ unphase() * Player can no longer fly */ -land() +void +land(void) { turn_off(player, ISFLY); msg("You regain your normal weight"); @@ -209,7 +218,8 @@ land() * He gets his sight back */ -sight() +void +sight(void) { if (on(player, ISBLIND)) { @@ -225,7 +235,8 @@ sight() * Restore player's strength */ -res_strength() +void +res_strength(void) { /* If lost_str is non-zero, restore that amount of strength, @@ -249,7 +260,8 @@ res_strength() * End the hasting */ -nohaste() +void +nohaste(void) { turn_off(player, ISHASTE); msg("You feel yourself slowing down."); @@ -260,7 +272,8 @@ nohaste() * End the slowing */ -noslow() +void +noslow(void) { turn_off(player, ISSLOW); msg("You feel yourself speeding up."); @@ -271,7 +284,8 @@ noslow() * If this gets called, the player has suffocated */ -suffocate() +void +suffocate(void) { death(D_SUFFOCATION); } @@ -279,7 +293,8 @@ suffocate() /* * digest the hero's food */ -stomach() +void +stomach(void) { register int oldfood, old_hunger, food_use, i; @@ -335,7 +350,8 @@ stomach() /* * daemon for curing the diseased */ -cure_disease() +void +cure_disease(void) { turn_off(player, HASDISEASE); if (off (player, HASINFEST)) @@ -346,7 +362,8 @@ cure_disease() /* * daemon for adding back dexterity */ -un_itch() +void +un_itch(void) { if (--lost_dext < 1) { lost_dext = 0; @@ -358,7 +375,8 @@ un_itch() * appear: * Become visible again */ -appear() +void +appear(void) { turn_off(player, ISINVIS); PLAYER = VPLAYER; @@ -369,7 +387,8 @@ appear() * dust_appear: * dust of disappearance wears off */ -dust_appear() +void +dust_appear(void) { turn_off(player, ISINVIS); PLAYER = VPLAYER; @@ -380,7 +399,8 @@ dust_appear() * unchoke: * the effects of "dust of choking and sneezing" wear off */ -unchoke() +void +unchoke(void) { if (!find_slot(unconfuse)) turn_off(player, ISHUH); @@ -392,8 +412,8 @@ unchoke() /* * make some potion for the guy in the Alchemy jug */ -alchemy(obj) -register struct object *obj; +void +alchemy(struct object *obj) { register struct object *tobj = NULL; register struct linked_list *item; @@ -440,7 +460,8 @@ register struct object *obj; * otto's irresistable dance wears off */ -undance() +void +undance(void) { turn_off(player, ISDANCE); msg ("Your feet take a break.....whew!"); @@ -449,14 +470,16 @@ undance() /* * if he has our favorite necklace of strangulation then take damage every turn */ -strangle() +void +strangle(void) { if ((pstats.s_hpt -= 6) <= 0) death(D_STRANGLE); } /* * if he has on the gauntlets of fumbling he might drop his weapon each turn */ -fumble() +void +fumble(void) { register struct linked_list *item; @@ -474,14 +497,16 @@ fumble() /* * this is called each turn the hero has the ring of searching on */ -ring_search() +void +ring_search(void) { search(FALSE, FALSE); } /* * this is called each turn the hero has the ring of teleportation on */ -ring_teleport() +void +ring_teleport(void) { if (rnd(100) < 2) teleport(); } diff --git a/arogue5/encumb.c b/arogue5/encumb.c index e2c1844..abb8bef 100644 --- a/arogue5/encumb.c +++ b/arogue5/encumb.c @@ -15,12 +15,14 @@ #include "curses.h" #include "rogue.h" +int packweight(void); + /* * updpack: * Update his pack weight and adjust fooduse accordingly */ -updpack(getmax) -int getmax; +void +updpack(bool getmax) { reg int topcarry, curcarry; @@ -45,7 +47,8 @@ int getmax; * packweight: * Get the total weight of the hero's pack */ -packweight() +int +packweight(void) { reg struct object *obj; reg struct linked_list *pc; @@ -68,8 +71,8 @@ packweight() * itemweight: * Get the weight of an object */ -itemweight(wh) -reg struct object *wh; +int +itemweight(struct object *wh) { reg int weight; reg int ac; @@ -99,7 +102,8 @@ reg struct object *wh; * playenc: * Get hero's carrying ability above norm */ -playenc() +int +playenc(void) { return ((str_compute()-8)*50); } @@ -109,7 +113,8 @@ playenc() * totalenc: * Get total weight that the hero can carry */ -totalenc() +int +totalenc(void) { reg int wtotal; @@ -130,18 +135,18 @@ totalenc() * See if the hero can carry his pack */ -wghtchk() +void +wghtchk(void) { reg int dropchk, err = TRUE; reg char ch; - int wghtchk(); inwhgt = TRUE; if (pstats.s_pack > pstats.s_carry) { ch = CCHAR( mvwinch(stdscr, hero.y, hero.x) ); if((ch != FLOOR && ch != PASSAGE)) { extinguish(wghtchk); - fuse(wghtchk,TRUE,1,AFTER); + fuse(wghtchk,NULL,1,AFTER); inwhgt = FALSE; return; } @@ -169,7 +174,8 @@ wghtchk() * -1 hit for heavy pack weight */ -hitweight() +int +hitweight(void) { return(2 - foodlev); } diff --git a/arogue5/fight.c b/arogue5/fight.c index 19ee000..7735b56 100644 --- a/arogue5/fight.c +++ b/arogue5/fight.c @@ -13,10 +13,27 @@ */ #include "curses.h" +#include #include #include #include "rogue.h" +bool roll_em(struct thing *att_er, struct thing *def_er, struct object *weap, + bool hurl, struct object *cur_weapon, bool back_stab); +void hit(struct object *weapon, struct thing *tp, char *er, char *ee, + bool back_stab); +void miss(struct object *weapon, struct thing *tp, char *er, char *ee); +int dext_plus(int dexterity); +int str_plus(short str); +int add_dam(short str); +int hung_dam(void); +void thunk(struct object *weap, struct thing *tp, char *mname); +void m_thunk(struct object *weap, struct thing *tp, char *mname); +void bounce(struct object *weap, struct thing *tp, char *mname); +void m_bounce(struct object *weap, struct thing *tp, char *mname); +struct object *wield_weap(struct object *thrown, struct thing *mp); +void explode(struct thing *tp); + #define CONF_DAMAGE -1 #define PARAL_DAMAGE -2 #define DEST_DAMAGE -3 @@ -35,10 +52,8 @@ static const struct matrix att_mat[5] = { * The player attacks the monster. */ -fight(mp, weap, thrown) -register coord *mp; -struct object *weap; -bool thrown; +bool +fight(coord *mp, struct object *weap, bool thrown) { register struct thing *tp; register struct linked_list *item; @@ -204,10 +219,8 @@ bool thrown; * The monster attacks the player */ -attack(mp, weapon, thrown) -register struct thing *mp; -register struct object *weapon; -bool thrown; +bool +attack(struct thing *mp, struct object *weapon, bool thrown) { register const char *mname; register bool did_hit = FALSE; @@ -708,9 +721,8 @@ bool thrown; * returns true if the swing hits */ -swing(class, at_lvl, op_arm, wplus) -short class; -int at_lvl, op_arm, wplus; +bool +swing(short class, int at_lvl, int op_arm, int wplus) { register int res = rnd(20)+1; register int need; @@ -730,12 +742,9 @@ int at_lvl, op_arm, wplus; * Roll several attacks */ -roll_em(att_er, def_er, weap, hurl, cur_weapon, back_stab) -struct thing *att_er, *def_er; -struct object *weap; -bool hurl; -struct object *cur_weapon; -bool back_stab; +bool +roll_em(struct thing *att_er, struct thing *def_er, struct object *weap, + bool hurl, struct object *cur_weapon, bool back_stab) { register struct stats *att, *def; register char *cp = NULL; @@ -1028,9 +1037,7 @@ bool back_stab; */ char * -prname(who, upper) -register char *who; -bool upper; +prname(char *who, bool upper) { static char tbuf[LINELEN]; @@ -1054,11 +1061,8 @@ bool upper; * Print a message to indicate a succesful hit */ -hit(weapon, tp, er, ee, back_stab) -register struct object *weapon; -register struct thing *tp; -register char *er, *ee; -bool back_stab; +void +hit(struct object *weapon, struct thing *tp, char *er, char *ee, bool back_stab) { register char *s = NULL; char @@ -1114,10 +1118,8 @@ bool back_stab; * Print a message to indicate a poor swing */ -miss(weapon, tp, er, ee) -register struct object *weapon; -register struct thing *tp; -register char *er, *ee; +void +miss(struct object *weapon, struct thing *tp, char *er, char *ee) { register char *s = NULL; char @@ -1161,8 +1163,8 @@ register char *er, *ee; * compute to-hit bonus for dexterity */ -dext_plus(dexterity) -register int dexterity; +int +dext_plus(int dexterity) { return (dexterity > 10 ? (dexterity-13)/3 : (dexterity-10)/3); } @@ -1173,8 +1175,8 @@ register int dexterity; * compute armor class bonus for dexterity */ -dext_prot(dexterity) -register int dexterity; +int +dext_prot(int dexterity) { return ((dexterity-10)/2); } @@ -1183,8 +1185,8 @@ register int dexterity; * compute bonus/penalties for strength on the "to hit" roll */ -str_plus(str) -register short str; +int +str_plus(short str) { return((str-10)/3); } @@ -1194,8 +1196,8 @@ register short str; * compute additional damage done for exceptionally high or low strength */ -add_dam(str) -register short str; +int +add_dam(short str) { return((str-9)/2); } @@ -1204,7 +1206,8 @@ register short str; * hung_dam: * Calculate damage depending on players hungry state */ -hung_dam() +int +hung_dam(void) { reg int howmuch = 0; @@ -1222,11 +1225,10 @@ hung_dam() * A missile hits a monster */ -thunk(weap, tp, mname) -register struct object *weap; -register struct thing *tp; /* Defender */ -register char *mname; +void +thunk(struct object *weap, struct thing *tp, char *mname) { + /* tp: Defender */ char *def_name; /* Name of defender */ /* What do we call the defender? */ @@ -1251,10 +1253,8 @@ register char *mname; * A missile from a monster hits the player */ -m_thunk(weap, tp, mname) -register struct object *weap; -register struct thing *tp; -register char *mname; +void +m_thunk(struct object *weap, struct thing *tp, char *mname) { char *att_name; /* Name of attacker */ @@ -1280,11 +1280,10 @@ register char *mname; * A missile misses a monster */ -bounce(weap, tp, mname) -register struct object *weap; -register struct thing *tp; /* Defender */ -register char *mname; +void +bounce(struct object *weap, struct thing *tp, char *mname) { + /* tp: Defender */ char *def_name; /* Name of defender */ /* What do we call the defender? */ @@ -1309,10 +1308,8 @@ register char *mname; A missle from a monster misses the player */ -m_bounce(weap, tp, mname) -register struct object *weap; -register struct thing *tp; -register char *mname; +void +m_bounce(struct object *weap, struct thing *tp, char *mname) { char *att_name; /* Name of attacker */ @@ -1339,8 +1336,8 @@ register char *mname; * Returns true if an object radiates magic */ -is_magic(obj) -register struct object *obj; +bool +is_magic(struct object *obj) { switch (obj->o_type) { @@ -1364,9 +1361,8 @@ register struct object *obj; * Called to put a monster to death */ -killed(item, pr, points) -register struct linked_list *item; -bool pr, points; +void +killed(struct linked_list *item, bool pr, bool points) { register struct thing *tp; register struct linked_list *pitem, *nexti; @@ -1447,9 +1443,7 @@ bool pr, points; */ struct object * -wield_weap(thrown, mp) -struct object *thrown; -struct thing *mp; +wield_weap(struct object *thrown, struct thing *mp) { int look_for = 0, /* The projectile weapon we are looking for */ new_rate, /* The rating of a prospective weapon */ @@ -1529,8 +1523,8 @@ struct thing *mp; return(candidate); } -explode(tp) -register struct thing *tp; +void +explode(struct thing *tp) { register int x,y, damage; diff --git a/arogue5/init.c b/arogue5/init.c index f846731..cb17efe 100644 --- a/arogue5/init.c +++ b/arogue5/init.c @@ -97,10 +97,8 @@ char *metal[NMETAL] = { * make sure all the percentages specified in the tables add up to the * right amounts */ -badcheck(name, magic, bound) -char *name; -register struct magic_item *magic; -register int bound; +void +badcheck(char *name, struct magic_item *magic, int bound) { register struct magic_item *end; @@ -120,7 +118,8 @@ register int bound; * Initialize the potion color scheme for this time */ -init_colors() +void +init_colors(void) { register int i, j; bool used[NCOLORS]; @@ -148,7 +147,8 @@ init_colors() * Initialize the construction materials for wands and staffs */ -init_materials() +void +init_materials(void) { register int i, j; register char *str; @@ -201,7 +201,8 @@ init_materials() * do any initialization for miscellaneous magic */ -init_misc() +void +init_misc(void) { register int i; @@ -221,7 +222,8 @@ init_misc() * Generate the names of the various scrolls */ -init_names() +void +init_names(void) { register int nsyl; register char *cp, *sp; @@ -258,7 +260,8 @@ init_names() * roll up the rogue */ -init_player() +void +init_player(void) { int stat_total, ch = 0, wpt = 0, i, j; struct linked_list *weap_item, *armor_item, *food_item; @@ -459,7 +462,8 @@ init_player() * Initialize the ring stone setting scheme for this time */ -init_stones() +void +init_stones(void) { register int i, j; bool used[NSTONES]; @@ -487,7 +491,8 @@ init_stones() * init_things * Initialize the probabilities for types of things */ -init_things() +void +init_things(void) { register struct magic_item *mp; diff --git a/arogue5/io.c b/arogue5/io.c index b494a4d..9b834a1 100644 --- a/arogue5/io.c +++ b/arogue5/io.c @@ -18,6 +18,9 @@ #include #include "rogue.h" +void doadd(char *fmt, va_list ap); +void ministat(void); + /* * msg: * Display a message at the top of the screen. @@ -27,6 +30,7 @@ static char msgbuf[BUFSIZ]; static int newpos = 0; /*VARARGS1*/ +void msg(char *fmt, ...) { va_list ap; @@ -54,6 +58,7 @@ msg(char *fmt, ...) /* * add things to the current message */ +void addmsg(char *fmt, ...) { va_list ap; @@ -66,7 +71,8 @@ addmsg(char *fmt, ...) * Display a new msg (giving him a chance to see the previous one if it * is up there with the --More--) */ -endmsg() +void +endmsg(void) { strncpy(huh, msgbuf, sizeof(huh)); @@ -96,6 +102,7 @@ endmsg() draw(msgw); } +void doadd(char *fmt, va_list ap) { /* @@ -113,9 +120,8 @@ doadd(char *fmt, va_list ap) * flgptr will be NULL if we don't know what the monster is yet! */ -step_ok(y, x, can_on_monst, flgptr) -register int y, x, can_on_monst; -register struct thing *flgptr; +bool +step_ok(int y, int x, int can_on_monst, struct thing *flgptr) { /* can_on_monst = MONSTOK if all we care about are physical obstacles */ register struct linked_list *item; @@ -156,7 +162,8 @@ register struct thing *flgptr; * returns true if it is ok for type to shoot over ch */ -shoot_ok(ch) +bool +shoot_ok(char ch) { switch (ch) { @@ -177,7 +184,8 @@ shoot_ok(ch) * getchar. */ -readchar() +int +readchar(void) { int ch; @@ -195,10 +203,11 @@ readchar() /* * status: * Display the important stats line. Keep the cursor where it was. + * If display is TRUE, display unconditionally */ -status(display) -bool display; /* is TRUE, display unconditionally */ +void +status(bool display) { register struct stats *stat_ptr, *max_ptr; register int oy = 0, ox = 0, temp; @@ -327,7 +336,8 @@ line_two: wmove(cw, oy, ox); } -ministat() +void +ministat(void) { register int oy, ox, temp; static char buf[LINELEN]; @@ -367,9 +377,8 @@ ministat() * Sit around until the guy types the right key */ -wait_for(win,ch) -WINDOW *win; -register char ch; +void +wait_for(WINDOW *win, char ch) { register char c; @@ -386,9 +395,8 @@ register char ch; * function used to display a window and wait before returning */ -show_win(scr, message) -register WINDOW *scr; -char *message; +void +show_win(WINDOW *scr, char *message) { mvwaddstr(scr, 0, 0, message); touchwin(scr); @@ -403,9 +411,8 @@ char *message; * dbotline: * Displays message on bottom line and waits for a space to return */ -dbotline(scr,message) -WINDOW *scr; -char *message; +void +dbotline(WINDOW *scr, char *message) { mvwaddstr(scr,LINES-1,0,message); draw(scr); @@ -417,8 +424,8 @@ char *message; * restscr: * Restores the screen to the terminal */ -restscr(scr) -WINDOW *scr; +void +restscr(WINDOW *scr) { clearok(scr,TRUE); touchwin(scr); @@ -431,10 +438,7 @@ WINDOW *scr; */ unsigned long -netread(error, size, stream) -int *error; -int size; -FILE *stream; +netread(int *error, int size, FILE *stream) { unsigned long result = 0L, /* What we read in */ partial; /* Partial value */ @@ -469,12 +473,13 @@ FILE *stream; /* * netwrite: * Write out a byte, short, or long machine independently. + * value: What to write + * size: How much to write out + * stream: Where to write it */ -netwrite(value, size, stream) -unsigned long value; /* What to write */ -int size; /* How much to write out */ -FILE *stream; /* Where to write it */ +int +netwrite(unsigned long value, int size, FILE *stream) { int i; /* Goes through value one byte at a time */ char outc; /* The next character to be written */ diff --git a/arogue5/list.c b/arogue5/list.c index 2e2a000..d147b88 100644 --- a/arogue5/list.c +++ b/arogue5/list.c @@ -21,8 +21,8 @@ * Takes an item out of whatever linked list it might be in */ -_detach(list, item) -register struct linked_list **list, *item; +void +_detach(struct linked_list **list, struct linked_list *item) { if (*list == item) *list = next(item); @@ -37,8 +37,8 @@ register struct linked_list **list, *item; * add an item to the head of a list */ -_attach(list, item) -register struct linked_list **list, *item; +void +_attach(struct linked_list **list, struct linked_list *item) { if (*list != NULL) { @@ -60,8 +60,8 @@ register struct linked_list **list, *item; * Throw the whole object list away */ -_o_free_list(ptr) -register struct linked_list **ptr; +void +_o_free_list(struct linked_list **ptr) { register struct linked_list *item; @@ -78,8 +78,8 @@ register struct linked_list **ptr; * free up an item and its object(and maybe contents) */ -o_discard(item) -register struct linked_list *item; +void +o_discard(struct linked_list *item) { register struct object *obj; obj = OBJPTR(item); @@ -95,8 +95,8 @@ register struct linked_list *item; * Throw the whole thing list away */ -_t_free_list(ptr) -register struct linked_list **ptr; +void +_t_free_list(struct linked_list **ptr) { register struct linked_list *item; @@ -113,8 +113,8 @@ register struct linked_list **ptr; * free up an item and its thing */ -t_discard(item) -struct linked_list *item; +void +t_discard(struct linked_list *item) { total -= 2; FREE(item->l_data); @@ -126,8 +126,8 @@ struct linked_list *item; * get rid of an item structure -- don't worry about contents */ -destroy_item(item) -register struct linked_list *item; +void +destroy_item(struct linked_list *item) { total--; FREE(item); @@ -139,8 +139,7 @@ register struct linked_list *item; */ struct linked_list * -new_item(size) -int size; +new_item(int size) { register struct linked_list *item; @@ -158,7 +157,7 @@ int size; */ struct linked_list * -creat_item() +creat_item(void) { register struct linked_list *item; @@ -169,8 +168,7 @@ creat_item() } char * -new(size) -int size; +new(int size) { register char *space = ALLOC(size); static char errbuf[LINELEN]; diff --git a/arogue5/main.c b/arogue5/main.c index 39b3b9b..7935eb7 100644 --- a/arogue5/main.c +++ b/arogue5/main.c @@ -43,10 +43,10 @@ static char *funfruit[] = { #define NFRUIT (sizeof(funfruit) / sizeof (char *)) void open_records(void); +bool holiday(void); -main(argc, argv, envp) -char **argv; -char **envp; +int +main(int argc, char *argv[], char *envp[]) { register char *env; int lowtime; @@ -123,7 +123,6 @@ char **envp; * Check for a network update */ if (argc == 2 && strcmp(argv[1], "-u") == 0) { - unsigned long netread(); int errcheck, errors = 0; unsigned long amount; short monster; @@ -277,8 +276,8 @@ endit(int sig) * Exit the program, printing a message. */ -fatal(s) -char *s; +void +fatal(char *s) { clear(); move(LINES-2, 0); @@ -294,8 +293,8 @@ char *s; * Pick a very random number. */ -rnd(range) -register int range; +int +rnd(int range) { return(range == 0 ? 0 : md_rand() % range); } @@ -305,8 +304,8 @@ register int range; * roll a number of dice */ -roll(number, sides) -register int number, sides; +int +roll(int number, int sides) { register int dtotal = 0; @@ -336,10 +335,11 @@ tstp(int a) } # endif -setup() +void +setup(void) { #ifdef CHECKTIME - int checkout(); + void checkout(); #endif #ifndef DUMP @@ -392,7 +392,8 @@ setup() * refreshing things and looking at the proper times. */ -playit() +void +playit(void) { register char *opts; @@ -416,7 +417,8 @@ playit() /* * see if the system is being used too much for this game */ -too_much() +bool +too_much(void) { #ifdef MAXLOAD double avec[3]; @@ -435,7 +437,8 @@ too_much() * author: * See if a user is an author of the program */ -author() +bool +author(void) { switch (md_getuid()) { #if AUTHOR @@ -450,7 +453,24 @@ author() #ifdef CHECKTIME -checkout() +/* + * checkout()'s version of msg. If we are in the middle of a shell, do a + * printf instead of a msg to avoid the refresh. + */ +void +chmsg(char *fmt, int arg) +{ + if (in_shell) { + printf(fmt, arg); + putchar('\n'); + fflush(stdout); + } + else + msg(fmt, arg); +} + +void +checkout(void) { static char *msgs[] = { "The system is too loaded for games. Please leave in %d minutes", @@ -482,23 +502,6 @@ checkout() alarm(CHECKTIME * 60); } } - -/* - * checkout()'s version of msg. If we are in the middle of a shell, do a - * printf instead of a msg to avoid the refresh. - */ -chmsg(fmt, arg) -char *fmt; -int arg; -{ - if (in_shell) { - printf(fmt, arg); - putchar('\n'); - fflush(stdout); - } - else - msg(fmt, arg); -} #endif #ifdef LOADAV @@ -510,8 +513,8 @@ struct nlist avenrun = "_avenrun" }; -loadav(avg) -reg double *avg; +void +loadav(double *avg) { reg int kmem; @@ -536,7 +539,8 @@ bad: #include #include struct utmp buf; -ucount() +int +ucount(void) { reg struct utmp *up; reg FILE *utmp; @@ -559,7 +563,8 @@ ucount() * holiday: * Returns TRUE when it is a good time to play rogue */ -holiday() +bool +holiday(void) { time_t now; struct tm *localtime(); diff --git a/arogue5/maze.c b/arogue5/maze.c index 75dc2c9..6d310f2 100644 --- a/arogue5/maze.c +++ b/arogue5/maze.c @@ -30,15 +30,20 @@ static char *frontier, *bits; static int maze_lines, maze_cols; -char *moffset(), - *foffset(); + +void draw_maze(void); +int findcells(int y, int x); +char *foffset(int y, int x); +char *moffset(int y, int x); +void rmwall(int newy, int newx, int oldy, int oldx); /* * crankout: * Does actual drawing of maze to window */ -crankout() +void +crankout(void) { reg int x, y; @@ -71,7 +76,8 @@ crankout() * domaze: * Draw the maze on this level. */ -do_maze() +void +do_maze(void) { reg int least; reg struct room *rp; @@ -95,7 +101,7 @@ do_maze() /* * add some gold to make it worth looking for */ - item = spec_item(GOLD, NULL, NULL, NULL); + item = spec_item(GOLD, 0, 0, 0); obj = OBJPTR(item); obj->o_count *= (rnd(10) + 1); /* add in one large hunk */ attach(lvl_obj, item); @@ -108,7 +114,7 @@ do_maze() /* * add in some food to make sure he has enough */ - item = spec_item(FOOD, NULL, NULL, NULL); + item = spec_item(FOOD, 0, 0, 0); obj = OBJPTR(item); attach(lvl_obj, item); do { @@ -133,7 +139,8 @@ do_maze() * draw_maze: * Generate and draw the maze on the screen */ -draw_maze() +void +draw_maze(void) { reg int i, j, more; reg char *ptr; @@ -169,8 +176,8 @@ draw_maze() * findcells: * Figure out cells to open up */ -findcells(y,x) -reg int x, y; +int +findcells(int y, int x) { reg int rtpos, i; @@ -221,8 +228,7 @@ reg int x, y; * Calculate memory address for frontier */ char * -foffset(y, x) -int y, x; +foffset(int y, int x) { return (frontier + (y * maze_cols) + x); @@ -236,8 +242,7 @@ int y, x; */ bool -maze_view(y, x) -int y, x; +maze_view(int y, int x) { register int start, goal, delta, ycheck = 0, xcheck = 0, absy, absx, see_radius; register bool row; @@ -342,8 +347,7 @@ int y, x; * Calculate memory address for bits */ char * -moffset(y, x) -int y, x; +moffset(int y, int x) { return (bits + (y * (COLS - 1)) + x); @@ -356,8 +360,8 @@ int y, x; * rmwall: * Removes appropriate walls from the maze */ -rmwall(newy, newx, oldy, oldx) -int newy, newx, oldy, oldx; +void +rmwall(int newy, int newx, int oldy, int oldx) { reg int xdif,ydif; diff --git a/arogue5/mdport.c b/arogue5/mdport.c index 7901e48..bee8097 100644 --- a/arogue5/mdport.c +++ b/arogue5/mdport.c @@ -55,6 +55,7 @@ #include #include +#include #if defined(_WIN32) && !defined(__MINGW32__) #define PATH_MAX MAX_PATH @@ -81,7 +82,7 @@ #define MOD_MOVE(c) (toupper(c) ) void -md_init() +md_init(void) { #ifdef __INTERIX char *term; @@ -132,7 +133,7 @@ md_putchar(int c) static int md_standout_mode = 0; int -md_raw_standout() +md_raw_standout(void) { #ifdef _WIN32 CONSOLE_SCREEN_BUFFER_INFO csbiInfo; @@ -155,7 +156,7 @@ md_raw_standout() } int -md_raw_standend() +md_raw_standend(void) { #ifdef _WIN32 CONSOLE_SCREEN_BUFFER_INFO csbiInfo; @@ -223,7 +224,7 @@ md_fdopen(int fd, char *mode) } int -md_normaluser() +md_normaluser(void) { #ifndef _WIN32 setuid(getuid()); @@ -232,7 +233,7 @@ md_normaluser() } int -md_getuid() +md_getuid(void) { #ifndef _WIN32 return( getuid() ); @@ -242,7 +243,7 @@ md_getuid() } char * -md_getusername() +md_getusername(void) { static char login[80]; char *l = NULL; @@ -279,7 +280,7 @@ md_getusername() } char * -md_gethomedir() +md_gethomedir(void) { static char homedir[PATH_MAX]; char *h = NULL; @@ -335,7 +336,7 @@ md_gethomedir() } char * -md_getshell() +md_getshell(void) { static char shell[PATH_MAX]; char *s = NULL; @@ -365,7 +366,7 @@ md_getshell() } int -md_shellescape() +md_shellescape(void) { #if (!defined(_WIN32) && !defined(__DJGPP__)) int ret_status; @@ -427,7 +428,7 @@ directory_exists(char *dirname) } char * -md_getroguedir() +md_getroguedir(void) { static char path[1024]; char *end,*home; @@ -491,8 +492,7 @@ md_crypt(char *key, char *salt) } char * -md_getpass(prompt) -char *prompt; +md_getpass(char *prompt) { #ifdef _WIN32 static char password_buffer[9]; @@ -587,7 +587,7 @@ md_htonl(unsigned long int x) } int -md_rand() +md_rand(void) { #ifdef _WIN32 return(rand()); @@ -597,8 +597,7 @@ md_rand() } int -md_srand(seed) -register int seed; +md_srand(int seed) { #ifdef _WIN32 srand(seed); @@ -608,7 +607,7 @@ register int seed; } long -md_memused() +md_memused(void) { #ifdef _WIN32 MEMORYSTATUS stat; @@ -622,7 +621,7 @@ md_memused() } char * -md_gethostname() +md_gethostname(void) { static char nodename[80]; char *n = NULL; @@ -644,7 +643,7 @@ md_gethostname() } int -md_erasechar() +md_erasechar(void) { #ifdef BSD return(_tty.sg_erase); /* process erase character */ @@ -656,7 +655,7 @@ md_erasechar() } int -md_killchar() +md_killchar(void) { #ifdef BSD return(_tty.sg_kill); @@ -673,8 +672,7 @@ md_killchar() */ char * -md_unctrl(ch) -char ch; +md_unctrl(char ch) { #if USG5_0 extern char *_unctrl[]; /* Defined in curses library */ @@ -686,7 +684,7 @@ char ch; } void -md_flushinp() +md_flushinp(void) { #ifdef BSD ioctl(0, TIOCFLUSH); diff --git a/arogue5/misc.c b/arogue5/misc.c index b13785f..a48f4f6 100644 --- a/arogue5/misc.c +++ b/arogue5/misc.c @@ -18,9 +18,7 @@ * See if a monster has some magic it can use. Use it and return TRUE if so. */ bool -m_use_item(monster, monst_pos, defend_pos) -register struct thing *monster; -register coord *monst_pos, *defend_pos; +m_use_item(struct thing *monster, coord *monst_pos, coord *defend_pos) { register struct linked_list *pitem; register struct object *obj; @@ -95,10 +93,11 @@ register coord *monst_pos, *defend_pos; /* * add something to the contents of something else + * bag: the holder of the items + * item: the item to put inside */ -put_contents(bag, item) -register struct object *bag; /* the holder of the items */ -register struct linked_list *item; /* the item to put inside */ +void +put_contents(struct object *bag, struct linked_list *item) { register struct linked_list *titem; register struct object *tobj; @@ -123,10 +122,10 @@ register struct linked_list *item; /* the item to put inside */ /* * remove something from something else + * bag: the holder of the items */ -take_contents(bag, item) -register struct object *bag; /* the holder of the items */ -register struct linked_list *item; +void +take_contents(struct object *bag, struct linked_list *item) { if (bag->o_ac <= 0) { @@ -140,8 +139,8 @@ register struct linked_list *item; } -do_bag(item) -register struct linked_list *item; +void +do_bag(struct linked_list *item) { register struct linked_list *titem = NULL; @@ -233,7 +232,8 @@ register struct linked_list *item; } } -do_panic() +void +do_panic(void) { register int x,y; register struct linked_list *mon; @@ -272,8 +272,7 @@ do_panic() * print miscellaneous magic bonuses */ char * -misc_name(obj) -register struct object *obj; +misc_name(struct object *obj) { static char buf[LINELEN]; char buf1[LINELEN]; @@ -340,7 +339,8 @@ register struct object *obj; return buf; } -use_emori() +void +use_emori(void) { char selection; /* Cloak function */ int state = 0; /* Menu state */ @@ -442,8 +442,8 @@ use_emori() } } -use_mm(which) -int which; +void +use_mm(int which) { register struct object *obj = NULL; register struct linked_list *item = NULL; @@ -496,7 +496,7 @@ int which; msg("The jug is empty"); break; } - quaff (obj->o_ac, NULL, FALSE); + quaff (obj->o_ac, 0, FALSE); obj->o_ac = JUG_EMPTY; fuse (alchemy, obj, ALCHEMYTIME, AFTER); if (!(obj->o_flags & ISKNOW)) diff --git a/arogue5/monsters.c b/arogue5/monsters.c index 61f6eda..65279c0 100644 --- a/arogue5/monsters.c +++ b/arogue5/monsters.c @@ -14,6 +14,7 @@ #include "curses.h" #include "rogue.h" +#include #include #include @@ -21,8 +22,8 @@ /* * Check_residue takes care of any effect of the monster */ -check_residue(tp) -register struct thing *tp; +void +check_residue(struct thing *tp) { /* * Take care of special abilities @@ -63,13 +64,11 @@ register struct thing *tp; /* * Creat_mons creates the specified monster -- any if 0 + * person: Where to create next to */ bool -creat_mons(person, monster, report) -struct thing *person; /* Where to create next to */ -short monster; -bool report; +creat_mons(struct thing *person, short monster, bool report) { struct linked_list *nitem; register struct thing *tp; @@ -121,9 +120,7 @@ bool report; */ void -genmonsters(least, treas) -register int least; -bool treas; +genmonsters(int least, bool treas) { reg int i; reg struct room *rp = &rooms[0]; @@ -166,8 +163,7 @@ bool treas; */ short -id_monst(monster) -register char monster; +id_monst(char monster) { register short result; @@ -187,11 +183,8 @@ register char monster; * Pick a new monster and add it to the list */ -new_monster(item, type, cp, max_monster) -struct linked_list *item; -short type; -register coord *cp; -bool max_monster; +void +new_monster(struct linked_list *item, short type, coord *cp, bool max_monster) { register struct thing *tp; register struct monster *mp; @@ -379,8 +372,7 @@ bool max_monster; */ short -randmonster(wander, no_unique) -register bool wander, no_unique; +randmonster(bool wander, bool no_unique) { register int d, cur_level, range, i; @@ -418,8 +410,8 @@ register bool wander, no_unique; * to purchase something. */ -sell(tp) -register struct thing *tp; +void +sell(struct thing *tp) { register struct linked_list *item; register struct object *obj; @@ -731,8 +723,7 @@ register struct thing *tp; * what to do when the hero steps next to a monster */ struct linked_list * -wake_monster(y, x) -int y, x; +wake_monster(int y, int x) { register struct thing *tp; register struct linked_list *it; @@ -957,7 +948,8 @@ int y, x; * A wandering monster has awakened and is headed for the player */ -wanderer() +void +wanderer(void) { register int i; register struct room *hr = roomin(&hero); diff --git a/arogue5/move.c b/arogue5/move.c index 7813e14..0c31c4f 100644 --- a/arogue5/move.c +++ b/arogue5/move.c @@ -37,9 +37,8 @@ static const char Moves[3][3] = { * The guy stepped on a trap.... Make him pay. */ -be_trapped(th, tc) -register struct thing *th; -register coord *tc; +char +be_trapped(struct thing *th, coord *tc) { register struct trap *tp; register char ch; @@ -353,8 +352,7 @@ register coord *tc; */ bool -blue_light(blessed, cursed) -bool blessed, cursed; +blue_light(bool blessed, bool cursed) { register struct room *rp; bool ret_val=FALSE; /* Whether or not affect is known */ @@ -413,8 +411,8 @@ bool blessed, cursed; * If not, if player came from a legal place, then try to turn him. */ -corr_move(dy, dx) -int dy, dx; +void +corr_move(int dy, int dx) { int legal=0; /* Number of legal alternatives */ register int y, x, /* Indexes though possible positions */ @@ -491,7 +489,8 @@ int dy, dx; * dip_it: * Dip an object into a magic pool */ -dip_it() +void +dip_it(void) { reg struct linked_list *what; reg struct object *ob; @@ -667,8 +666,8 @@ dip_it() * consequences (fighting, picking up, etc.) */ -do_move(dy, dx) -int dy, dx; +void +do_move(int dy, int dx) { register struct room *rp, *orp; register char ch; @@ -878,8 +877,8 @@ int dy, dx; * Start the hero running */ -do_run(ch) -char ch; +void +do_run(char ch) { firstmove = TRUE; running = TRUE; @@ -894,11 +893,9 @@ char ch; * Returns TRUE if it could find it, FALSE otherwise. */ bool -getdelta(match, dy, dx) -char match; -int *dy, *dx; +getdelta(char match, int *dy, int *dx) { - register y, x; + int y, x; for (y = 0; y < 3; y++) for (x = 0; x < 3; x++) @@ -915,8 +912,8 @@ int *dy, *dx; * isatrap: * Returns TRUE if this character is some kind of trap */ -isatrap(ch) -reg char ch; +bool +isatrap(char ch) { switch(ch) { case DARTTRAP: @@ -936,8 +933,8 @@ reg char ch; * If it is dark, remove anything that might move. */ -light(cp) -coord *cp; +void +light(coord *cp) { register struct room *rp; register int j, k, x, y; @@ -1113,8 +1110,7 @@ coord *cp; */ bool -lit_room(rp) -register struct room *rp; +lit_room(struct room *rp) { register struct linked_list *fire_item; register struct thing *fire_creature; @@ -1150,8 +1146,7 @@ register struct room *rp; */ coord * -rndmove(who) -struct thing *who; +rndmove(struct thing *who) { register int x, y; register int ex, ey, nopen = 0; @@ -1192,9 +1187,8 @@ struct thing *who; * set a trap at (y, x) on screen. */ -set_trap(tp, y, x) -register struct thing *tp; -register int y, x; +void +set_trap(struct thing *tp, int y, int x) { register bool is_player = (tp == &player); register char selection = rnd(7) + '1'; @@ -1330,8 +1324,8 @@ register int y, x; * returns what a certain thing will display as to the un-initiated */ -show(y, x) -register int y, x; +char +show(int y, int x) { register char ch = CCHAR( winat(y, x) ); register struct linked_list *it; @@ -1371,8 +1365,7 @@ register int y, x; */ struct trap * -trap_at(y, x) -register int y, x; +trap_at(int y, int x) { register struct trap *tp, *ep; diff --git a/arogue5/new_level.c b/arogue5/new_level.c index 214f61e..44131b3 100644 --- a/arogue5/new_level.c +++ b/arogue5/new_level.c @@ -16,8 +16,11 @@ #include "rogue.h" #define TERRASAVE 3 -new_level(ltype) -LEVTYPE ltype; /* designates type of level to create */ +void put_things(LEVTYPE ltype); + +/* ltype designates type of level to create */ +void +new_level(LEVTYPE ltype) { register int rm = 0, i, cnt; register char ch; @@ -409,7 +412,8 @@ LEVTYPE ltype; /* designates type of level to create */ * Pick a room that is really there */ -rnd_room() +int +rnd_room(void) { register int rm; @@ -425,10 +429,11 @@ rnd_room() /* * put_things: * put potions and scrolls on this level + * ltype: designates type of level to create */ -put_things(ltype) -LEVTYPE ltype; /* designates type of level to create */ +void +put_things(LEVTYPE ltype) { register int i, rm, cnt; register struct object *cur; @@ -448,7 +453,7 @@ LEVTYPE ltype; /* designates type of level to create */ * Increasing chance after level 9 */ if (ltype != MAZELEV && rnd(HARDER) < level - 8) { - register j; + register int j; register struct room *rp; /* Count the number of free spaces */ diff --git a/arogue5/options.c b/arogue5/options.c index 93bcaae..f7e4c99 100644 --- a/arogue5/options.c +++ b/arogue5/options.c @@ -35,16 +35,16 @@ struct optstruct { typedef struct optstruct OPTION; -int put_bool(), - get_bool(), - put_str(), - get_str(), - get_restr(), - get_score(), - put_abil(), - get_abil(), - get_quest(), - put_quest(); +int get_ro(WINDOW *win, int oy, int ox); +int get_restr(char *optstr, WINDOW *win); +int get_score(char *optstr, WINDOW *win); +void put_abil(int *ability, WINDOW *win); +void get_abil(int *abil, WINDOW *win); +void put_quest(int *quest, WINDOW *win); +void get_quest(int *quest, WINDOW *win); +void put_bool(bool *b, WINDOW *win); +int get_bool(bool *bp, WINDOW *win); +void put_str(char *str, WINDOW *win); OPTION optlist[] = { {"terse", "Terse output: ", @@ -111,9 +111,8 @@ int get_score(char *optstr, WINDOW *win) /* * The ability field is read-only */ -get_abil(abil, win) -int *abil; -WINDOW *win; +void +get_abil(int *abil, WINDOW *win) { register int oy, ox; @@ -125,9 +124,8 @@ WINDOW *win; /* * The quest field is read-only */ -get_quest(quest, win) -int *quest; -WINDOW *win; +void +get_quest(int *quest, WINDOW *win) { register int oy, ox; @@ -141,9 +139,8 @@ WINDOW *win; * "Get" a read-only value. */ -get_ro(win, oy, ox) -WINDOW *win; -register int oy, ox; +int +get_ro(WINDOW *win, int oy, int ox) { register int ny, nx; register bool op_bad; @@ -180,9 +177,8 @@ register int oy, ox; * allow changing a boolean option and print it out */ -get_bool(bp, win) -bool *bp; -WINDOW *win; +int +get_bool(bool *bp, WINDOW *win) { register int oy, ox; register bool op_bad; @@ -230,9 +226,8 @@ WINDOW *win; /* * set a string option */ -get_str(opt, win) -register char *opt; -WINDOW *win; +int +get_str(char *opt, WINDOW *win) { register char *sp; register int c, oy, ox; @@ -306,7 +301,8 @@ WINDOW *win; /* * print and then set options from the terminal */ -option() +void +option(void) { register OPTION *op; register int retval; @@ -362,8 +358,8 @@ option() * or the end of the entire option string. */ -parse_opts(str) -register char *str; +void +parse_opts(char *str) { register char *sp; register OPTION *op; @@ -459,9 +455,8 @@ register char *str; /* * print the character type */ -put_abil(ability, win) -int *ability; -WINDOW *win; +void +put_abil(int *ability, WINDOW *win) { char *abil; @@ -480,9 +475,8 @@ WINDOW *win; * print out the quest */ -put_quest(quest, win) -int *quest; -WINDOW *win; +void +put_quest(int *quest, WINDOW *win) { waddstr(win, rel_magic[*quest].mi_name); } @@ -491,9 +485,8 @@ WINDOW *win; /* * put out a boolean */ -put_bool(b, win) -bool *b; -WINDOW *win; +void +put_bool(bool *b, WINDOW *win) { waddstr(win, *b ? "True" : "False"); } @@ -504,9 +497,8 @@ WINDOW *win; /* * put out a string */ -put_str(str, win) -char *str; -WINDOW *win; +void +put_str(char *str, WINDOW *win) { waddstr(win, str); } diff --git a/arogue5/outside.c b/arogue5/outside.c index 9ceb749..82bed8c 100644 --- a/arogue5/outside.c +++ b/arogue5/outside.c @@ -11,7 +11,8 @@ #include "curses.h" #include "rogue.h" -extern char rnd_terrain(), get_terrain(); +char rnd_terrain(void); +char get_terrain(char one, char two, char three, char four); /* * init_terrain: @@ -19,7 +20,7 @@ extern char rnd_terrain(), get_terrain(); */ void -init_terrain() +init_terrain(void) { register struct room *rp; @@ -38,11 +39,9 @@ init_terrain() void -do_terrain(basey, basex, deltay, deltax, fresh) -int basey, basex, deltay, deltax; -bool fresh; +do_terrain(int basey, int basex, int deltay, int deltax, bool fresh) { - register cury, curx; /* Current y and x positions */ + int cury, curx; /* Current y and x positions */ /* Lay out the boundary */ for (cury=1; curyo_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYCLOAK)) { - item = spec_item(RELIC, EMORI_CLOAK, NULL, NULL); + item = spec_item(RELIC, EMORI_CLOAK, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYANKH)) { - item = spec_item(RELIC, HEIL_ANKH, NULL, NULL); + item = spec_item(RELIC, HEIL_ANKH, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYSTAFF)) { - item = spec_item(RELIC, MING_STAFF, NULL, NULL); + item = spec_item(RELIC, MING_STAFF, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYWAND)) { - item = spec_item(RELIC, ORCUS_WAND, NULL, NULL); + item = spec_item(RELIC, ORCUS_WAND, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYROD)) { - item = spec_item(RELIC, ASMO_ROD, NULL, NULL); + item = spec_item(RELIC, ASMO_ROD, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYAMULET)) { - item = spec_item(RELIC, YENDOR_AMULET, NULL, NULL); + item = spec_item(RELIC, YENDOR_AMULET, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYMANDOLIN)) { - item = spec_item(RELIC, BRIAN_MANDOLIN, NULL, NULL); + item = spec_item(RELIC, BRIAN_MANDOLIN, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYMSTAR)) { - item = spec_item(RELIC, HRUGGEK_MSTAR, NULL, NULL); + item = spec_item(RELIC, HRUGGEK_MSTAR, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYFLAIL)) { - item = spec_item(RELIC, YEENOGHU_FLAIL, NULL, NULL); + item = spec_item(RELIC, YEENOGHU_FLAIL, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYHORN)) { - item = spec_item(RELIC, GERYON_HORN, NULL, NULL); + item = spec_item(RELIC, GERYON_HORN, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); @@ -927,7 +922,7 @@ int chance; * If it carries gold, give it some */ if (on(*mp, CARRYGOLD) && rnd(100) < chance) { - item = spec_item(GOLD, NULL, NULL, NULL); + item = spec_item(GOLD, 0, 0, 0); obj = OBJPTR(item); obj->o_count = GOLDCALC + GOLDCALC; obj->o_pos = mp->t_pos; @@ -938,7 +933,7 @@ int chance; * If it carries food, give it some */ if (on(*mp, CARRYFOOD) && rnd(100) < chance) { - item = spec_item(FOOD, NULL, NULL, NULL); + item = spec_item(FOOD, 0, 0, 0); obj = OBJPTR(item); obj->o_weight = things[TYP_FOOD].mi_wght; obj->o_pos = mp->t_pos; @@ -1041,8 +1036,8 @@ int chance; * he wants (* means everything). */ -grab(y, x) -register y, x; +int +grab(int y, int x) { register struct linked_list *next_item, *item; register struct object *obj; diff --git a/arogue5/passages.c b/arogue5/passages.c index 2c40089..cf31d3c 100644 --- a/arogue5/passages.c +++ b/arogue5/passages.c @@ -14,15 +14,20 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include #include "curses.h" #include "rogue.h" +void conn(int r1, int r2); +void door(struct room *rm, coord *cp); + /* * do_passages: * Draw all the passages on a level. */ -do_passages() +void +do_passages(void) { register struct rdes *r1, *r2 = NULL; register int i, j; @@ -130,8 +135,8 @@ do_passages() * Draw a corridor from a room in a certain direction. */ -conn(r1, r2) -int r1, r2; +void +conn(int r1, int r2) { register struct room *rpf, *rpt = NULL; register char rmt; @@ -266,9 +271,8 @@ int r1, r2; * also enters the door in the exits array of the room. */ -door(rm, cp) -register struct room *rm; -register coord *cp; +void +door(struct room *rm, coord *cp) { struct linked_list *newroom; coord *exit; diff --git a/arogue5/player.c b/arogue5/player.c index 71c34df..adcead6 100644 --- a/arogue5/player.c +++ b/arogue5/player.c @@ -17,7 +17,8 @@ * cleric affecting undead */ -affect() +void +affect(void) { register struct linked_list *item; register struct thing *tp; @@ -121,7 +122,8 @@ annoy: /* * the magic user is going to try and cast a spell */ -cast() +void +cast(void) { register int i, num_spells, spell_ability; int which_spell; @@ -271,7 +273,8 @@ cast() /* Constitution bonus */ -const_bonus() /* Hit point adjustment for changing levels */ +int +const_bonus(void) /* Hit point adjustment for changing levels */ { if (pstats.s_const > 6 && pstats.s_const <= 14) return(0); @@ -290,7 +293,8 @@ const_bonus() /* Hit point adjustment for changing levels */ * Sense gold */ -gsense() +void +gsense(void) { /* Only thieves can do this */ if (player.t_ctype != C_THIEF) { @@ -324,7 +328,8 @@ gsense() /* * the cleric asks his deity for a spell */ -pray() +void +pray(void) { register int i, num_prayers, prayer_ability; int which_prayer; @@ -488,7 +493,8 @@ pray() * Steal in direction given in delta */ -steal() +void +steal(void) { register struct linked_list *item; register struct thing *tp; diff --git a/arogue5/potions.c b/arogue5/potions.c index 208a3f8..968de4b 100644 --- a/arogue5/potions.c +++ b/arogue5/potions.c @@ -17,14 +17,16 @@ #include #include +void res_intelligence(void); +void res_wisdom(void); /* * Increase player's constitution */ -add_const(cursed) -bool cursed; +void +add_const(bool cursed) { /* Do the potion */ if (cursed) { @@ -47,8 +49,8 @@ bool cursed; * Increase player's dexterity */ -add_dexterity(cursed) -bool cursed; +void +add_dexterity(bool cursed) { int ring_str; /* Value of ring strengths */ @@ -80,8 +82,8 @@ bool cursed; * add a haste to the player */ -add_haste(blessed) -bool blessed; +void +add_haste(bool blessed) { int hasttime; @@ -110,8 +112,8 @@ bool blessed; /* * Increase player's intelligence */ -add_intelligence(cursed) -bool cursed; +void +add_intelligence(bool cursed) { int ring_str; /* Value of ring strengths */ @@ -141,7 +143,8 @@ bool cursed; /* * this routine makes the hero move slower */ -add_slow() +void +add_slow(void) { if (on(player, ISHASTE)) { /* Already sped up */ extinguish(nohaste); @@ -164,8 +167,8 @@ add_slow() * Increase player's strength */ -add_strength(cursed) -bool cursed; +void +add_strength(bool cursed) { if (cursed) { @@ -182,8 +185,8 @@ bool cursed; * Increase player's wisdom */ -add_wisdom(cursed) -bool cursed; +void +add_wisdom(bool cursed) { int ring_str; /* Value of ring strengths */ @@ -215,8 +218,8 @@ bool cursed; * Lower a level of experience */ -lower_level(who) -short who; +void +lower_level(short who) { int fewer, nsides = 0; @@ -239,10 +242,8 @@ short who; death(who); } -quaff(which, flag, is_potion) -int which; -int flag; -bool is_potion; +void +quaff(int which, int flag, bool is_potion) { register struct object *obj = NULL; register struct linked_list *item, *titem; @@ -625,8 +626,8 @@ bool is_potion; * if called with zero the restore fully */ -res_dexterity(howmuch) -int howmuch; +void +res_dexterity(int howmuch) { short save_max; int ring_str; @@ -656,7 +657,8 @@ int howmuch; * Restore player's intelligence */ -res_intelligence() +void +res_intelligence(void) { short save_max; int ring_str; @@ -680,7 +682,8 @@ res_intelligence() * Restore player's wisdom */ -res_wisdom() +void +res_wisdom(void) { short save_max; int ring_str; diff --git a/arogue5/rings.c b/arogue5/rings.c index ab54732..f0af8b3 100644 --- a/arogue5/rings.c +++ b/arogue5/rings.c @@ -20,8 +20,8 @@ /* * how much food does this ring use up? */ -ring_eat(hand) -register int hand; +int +ring_eat(int hand) { if (cur_ring[hand] == NULL) return 0; @@ -45,8 +45,8 @@ register int hand; return 0; } -ring_on(obj) -register struct object *obj; +void +ring_on(struct object *obj) { register int save_max; char buf[LINELEN]; @@ -112,8 +112,7 @@ register struct object *obj; * print ring bonuses */ char * -ring_num(obj) -register struct object *obj; +ring_num(struct object *obj) { static char buf[5]; @@ -147,7 +146,8 @@ register struct object *obj; /* * Return the effect of the specified ring */ -ring_value(type) +int +ring_value(int type) { int result = 0; diff --git a/arogue5/rip.c b/arogue5/rip.c index 5b3dc52..2344b3a 100644 --- a/arogue5/rip.c +++ b/arogue5/rip.c @@ -71,15 +71,17 @@ static char *rip[] = { 0 }; -char *killname(); - - - +char *killname(short monst); +void scorein(struct sc_ent scores[], int fd); +void scoreout(struct sc_ent scores[], FILE *outf); +void showpack(char *howso); +int update(struct sc_ent top_ten[], unsigned long amount, short quest, + char *whoami, short flags, short level, short monst, short ctype, + char *system, char *login); void -byebye(sig) -int sig; +byebye(int sig) { NOOP(sig); if (!isendwin()) { @@ -96,8 +98,8 @@ int sig; * Do something really fun when he dies */ -death(monst) -register short monst; +void +death(short monst) { register char **dp = rip, *killer; register struct tm *lt; @@ -125,8 +127,7 @@ register short monst; } char * -killname(monst) -register short monst; +killname(short monst) { static char mons_name[LINELEN]; int i; @@ -162,9 +163,8 @@ register short monst; */ /* VARARGS2 */ -score(amount, flags, monst) -unsigned long amount; -short monst; +void +score(unsigned long amount, int flags, short monst) { static struct sc_ent top_ten[NUMSCORE]; register struct sc_ent *scp; @@ -626,9 +626,8 @@ void writelog(unsigned long amount, int flags, short monst) { * Convert a character string that has been translated from a * score file by scoreout() back to a score file structure. */ -scorein(scores, fd) -struct sc_ent scores[]; -int fd; +void +scorein(struct sc_ent scores[], int fd) { int i; char scoreline[100]; @@ -652,9 +651,8 @@ int fd; * this for compatibility sake since some machines write out fields in * different orders. */ -scoreout(scores, outf) -struct sc_ent scores[]; -FILE *outf; +void +scoreout(struct sc_ent scores[], FILE *outf) { int i; char scoreline[100]; @@ -676,8 +674,8 @@ FILE *outf; * showpack: * Display the contents of the hero's pack */ -showpack(howso) -char *howso; +void +showpack(char *howso) { reg char *iname; reg int cnt, packnum; @@ -706,7 +704,8 @@ char *howso; refresh(); } -total_winner() +void +total_winner(void) { register struct linked_list *item; register struct object *obj; @@ -760,11 +759,10 @@ total_winner() exit(0); } -update(top_ten, amount, quest, whoami, flags, level, monst, ctype, system, login) -struct sc_ent top_ten[]; -unsigned long amount; -short quest, flags, level, monst, ctype; -char *whoami, *system, *login; +int +update(struct sc_ent top_ten[], unsigned long amount, short quest, + char *whoami, short flags, short level, short monst, short ctype, + char *system, char *login) { register struct sc_ent *scp, *sc2; int retval=0; /* 1 if a change, 0 otherwise */ diff --git a/arogue5/rogue.h b/arogue5/rogue.h index ad0cbcf..8bb1936 100644 --- a/arogue5/rogue.h +++ b/arogue5/rogue.h @@ -943,48 +943,260 @@ struct spells { int s_flag; /* is the spell blessed/cursed? */ }; -struct linked_list *find_mons(), *find_obj(), *get_item(), *new_item(), - *new_thing(), *wake_monster(), *get_hurl(), - *spec_item(), *creat_item(); -struct object *wield_weap(); -struct room *roomin(); -struct trap *trap_at(); - -char *tr_name(), *new(), - *vowelstr(), *inv_name(), - *ctime(), *num(), *ring_num(), *misc_num(), *blesscurse(), *typ_name(), - *weap_name(), *misc_name(); -coord *rndmove(), *can_shoot(), *fallpos(); -short randmonster(), id_monst(); -void quit(int sig), tstp(int sig), auto_save(int sig), bugkill(int sig), endit(int sig); -int rnd(), wghtchk(), nohaste(), res_strength(), - doctor(), runners(), swander(), unconfuse(), unsee(), fumble(), - unclrhead(), unphase(), noslow(), rollwand(), stomach(), sight(), - unstink(), suffocate(), cure_disease(), un_itch(), shoot_bolt(), - appear(), dust_appear(), unchoke(), alchemy(), trap_look(), strangle(), - ring_teleport(), ring_search(), grab(); -bool blue_light(), can_blink(), creat_mons(), add_pack(), - straight_shot(), maze_view(), lit_room(), getdelta(), save_file(), - save_game(); -long check_level(); -void byebye(int sig), genmonsters(); -int land(), undance(); +void _attach(struct linked_list **list, struct linked_list *item); +void _detach(struct linked_list **list, struct linked_list *item); +void _o_free_list(struct linked_list **ptr); +void _t_free_list(struct linked_list **ptr); +int ac_compute(void); +void activity(void); +void add_dexterity(bool cursed); +void add_intelligence(bool cursed); +bool add_pack(struct linked_list *item, bool silent, + struct linked_list **packret); +void add_slow(void); +void add_wisdom(bool cursed); +void addmsg(char *fmt, ...); +void affect(void); +void aggravate(void); +void alchemy(struct object *obj); +void appear(void); +bool attack(struct thing *mp, struct object *weapon, bool thrown); +void auto_save(int sig); +char be_trapped(struct thing *th, coord *tc); +char *blesscurse(int flags); +bool blue_light(bool blessed, bool cursed); +void bugkill(int sig); +void buy_it(void); +void byebye(int sig); +void cast(void); +bool can_blink(struct thing *tp); +coord *can_shoot(coord *er, coord *ee); +bool cansee(int y, int x); +void carry_obj(struct thing *mp, int chance); +long check_level(bool get_spells); +void check_residue(struct thing *tp); +void chg_str(int amt); +void command(void); +int const_bonus(void); +void corr_move(int dy, int dx); +struct linked_list *creat_item(void); +bool creat_mons(struct thing *person, short monster, bool report); +void create_obj(bool prompt, int which_item, int which_type); +void cur_null(struct object *op); +void cure_disease(void); +void dbotline(WINDOW *scr, char *message); +void death(short monst); +void del_pack(struct linked_list *item); +void destroy_item(struct linked_list *item); +int dex_compute(void); +int dext_prot(int dexterity); +bool diag_ok(coord *sp, coord *ep, struct thing *flgptr); +void dip_it(void); +void do_daemons(int flag); +void do_fuses(int flag); +void do_maze(void); +void do_motion(struct object *obj, int ydelta, int xdelta, struct thing *tp); +void do_move(int dy, int dx); +void do_passages(void); +void do_post(void); +void do_rooms(void); +void do_run(char ch); +void do_terrain(int basey, int basex, int deltay, int deltax, bool fresh); +bool do_zap(bool gotdir, int which, int flag); +void doctor(struct thing *tp); +void draw_room(struct room *rp); +bool drop(struct linked_list *item); +bool dropcheck(struct object *op); +void dust_appear(void); +void eat(void); +int encread(char *start, unsigned int size, int inf); +int encwrite(char *start, unsigned int size, FILE *outf); +void endit(int sig); +void endmsg(void); +void extinguish(int (*func)()); +void fall(struct linked_list *item, bool pr); +coord *fallpos(coord *pos, bool be_clear, int range); +void fatal(char *s); +bool fight(coord *mp, struct object *weap, bool thrown); +struct linked_list *find_mons(int y, int x); +struct linked_list *find_obj(int y, int x); +struct delayed_action *find_slot(int (*func)()); +void fix_stick(struct object *cur); +void fumble(void); +void fuse(int (*func)(), void *arg, int time, int type); +void genmonsters(int least, bool treas); +bool get_dir(void); +struct linked_list *get_item(struct linked_list *list, char *purpose, int type); +int get_str(char *opt, WINDOW *win); +int get_worth(struct object *obj); +int getbless(void); +int getdeath(void); +bool getdelta(char match, int *dy, int *dx); +int grab(int y, int x); +void gsense(void); +bool hit_monster(int y, int x, struct object *obj, struct thing *tp); +int hitweight(void); +short id_monst(char monster); +void idenpack(void); +void init_colors(void); +void init_materials(void); +void init_misc(void); +void init_names(void); +void init_player(void); +void init_stones(void); +void init_terrain(void); +void init_things(void); +void init_weapon(struct object *weap, char type); +char *inv_name(struct object *obj, bool drop); +bool inventory(struct linked_list *list, int type); +bool is_current(struct object *obj); +bool is_magic(struct object *obj); +bool isatrap(char ch); +int itemweight(struct object *wh); +void kill_daemon(int (*func)()); +void killed(struct linked_list *item, bool pr, bool points); +void lake_check(coord *place); +void land(void); +void lengthen(int (*func)(), int xtime); +void light(coord *cp); +bool lit_room(struct room *rp); +void look(bool wakeup, bool runend); +void lower_level(short who); +bool m_use_item(struct thing *monster, coord *monst_pos, coord *defend_pos); +short makemonster(bool create); +bool maze_view(int y, int x); +char *misc_name(struct object *obj); +void missile(int ydelta, int xdelta, struct linked_list *item, + struct thing *tp); +void msg(char *fmt, ...); +unsigned long netread(int *error, int size, FILE *stream); +int netwrite(unsigned long value, int size, FILE *stream); +char *new(int size); +struct linked_list *new_item(int size); +void new_level(LEVTYPE ltype); +void new_monster(struct linked_list *item, short type, coord *cp, + bool max_monster); +struct linked_list *new_thing(int thing_type); +void nohaste(void); +void noslow(void); +char *num(int n1, int n2); +void o_discard(struct linked_list *item); +void option(void); +char pack_char(struct linked_list *list, struct object *obj); +void parse_opts(char *str); +bool passwd(void); +int pick_one(struct magic_item *magic, int nitems); +void pick_up(char ch); +void picky_inven(void); +void playit(void); +void pray(void); +bool price_it(void); +void quaff(int which, int flag, bool is_potion); +void quit(int sig); +void raise_level(bool get_spells); +short randmonster(bool wander, bool no_unique); +void read_scroll(int which, int flag, bool is_scroll); +int readchar(void); +void res_dexterity(int howmuch); +void res_strength(void); +bool restore(char *file, char **envp); +void restscr(WINDOW *scr); +int ring_eat(int hand); +char *ring_num(struct object *obj); +void ring_on(struct object *obj); +void ring_search(void); +void ring_teleport(void); +int ring_value(int type); +int rnd(int range); +void rnd_pos(struct room *rp, coord *cp); +int rnd_room(void); +coord *rndmove(struct thing *who); +int roll(int number, int sides); +void rollwand(void); +struct room *roomin(coord *cp); +int rs_restore_file(int inf); +int rs_save_file(FILE *savef); +void runners(void); +void runto(struct thing *runner, coord *spot); +bool save(int which, struct thing *who, int adj); +bool save_game(void); +void score(unsigned long amount, int flags, short monst); +void search(bool is_thief, bool door_chime); +char secretdoor(int y, int x); +void sell(struct thing *tp); +void sell_it(void); +void set_trap(struct thing *tp, int y, int x); +void setup(void); +bool shoot_bolt(struct thing *shooter, coord start, coord dir, + bool get_points, short reason, char *name, int damage); +bool shoot_ok(char ch); +char show(int y, int x); +void sight(void); +struct linked_list *spec_item(int type, int which, int hit, int damage); +void start_daemon(int (*func)(), void *arg, int type); +void status(bool display); +void steal(void); +bool step_ok(int y, int x, int can_on_monst, struct thing *flgptr); +void stomach(void); +int str_compute(void); +void strangle(void); +void strucpy(char *s1, char *s2, int len); +void suffocate(void); +void swander(void); +bool swing(short class, int at_lvl, int op_arm, int wplus); +void t_discard(struct linked_list *item); +void take_off(void); +int teleport(void); +void total_winner(void); +int totalenc(void); +char *tr_name(char ch); +struct trap *trap_at(int y, int x); +void trap_look(void); +void un_itch(void); +void unchoke(void); +void unclrhead(void); +void unconfuse(void); +void undance(void); +void unphase(void); +void unsee(void); +void unstink(void); +void updpack(bool getmax); +void use_mm(int which); +char *vowelstr(char *str); +void wait_for(WINDOW *win, char ch); +struct linked_list *wake_monster(int y, int x); +void waste_time(void); +char *weap_name(struct object *obj); +void wear(void); +void wghtchk(void); +void whatis(struct linked_list *what); +void wield(void); void writelog(unsigned long amount, int flags, short monst); + #ifdef CHECKTIME int checkout(); #endif -extern char *md_getusername(); -extern char *md_gethomedir(); -extern void md_flushinp(); -extern char *md_getshell(); -extern char *md_gethostname(); -extern void md_dobinaryio(); -extern char *md_getpass(); -extern char *md_crypt(); -extern char *md_getroguedir(); -extern void md_init(); +extern char *md_getusername(void); +extern char *md_gethomedir(void); +extern void md_flushinp(void); +extern char *md_getshell(void); +extern char *md_gethostname(void); +extern char *md_getpass(char *prompt); +extern char *md_crypt(char *key, char *salt); +extern char *md_getroguedir(void); +extern void md_init(void); extern FILE * md_fdopen(int fd, char *mode); extern int md_unlink(char *file); +extern int md_normaluser(void); +extern int md_getuid(void); +extern long md_memused(void); +extern void md_reopen_score(void); +extern int md_readchar(WINDOW *win); +extern int md_shellescape(void); +extern int md_srand(int seed); +extern int md_rand(void); +extern int md_erasechar(void); +extern int md_killchar(void); /* * Now all the global variables diff --git a/arogue5/rooms.c b/arogue5/rooms.c index e5ef76d..1932d1d 100644 --- a/arogue5/rooms.c +++ b/arogue5/rooms.c @@ -16,7 +16,11 @@ #include "rogue.h" #include -do_rooms() +void horiz(int cnt); +void vert(int cnt); + +void +do_rooms(void) { register int i; register struct room *rp; @@ -99,7 +103,7 @@ do_rooms() has_gold = TRUE; /* This room has gold in it */ - item = spec_item(GOLD, NULL, NULL, NULL); + item = spec_item(GOLD, 0, 0, 0); cur = OBJPTR(item); /* Put the gold into the level list of items */ @@ -153,8 +157,8 @@ do_rooms() * Draw a box around a room */ -draw_room(rp) -register struct room *rp; +void +draw_room(struct room *rp) { register int j, k; @@ -181,8 +185,8 @@ register struct room *rp; * draw a horizontal line */ -horiz(cnt) -register int cnt; +void +horiz(int cnt) { while (cnt--) addch('-'); @@ -193,9 +197,8 @@ register int cnt; * pick a random spot in a room */ -rnd_pos(rp, cp) -register struct room *rp; -register coord *cp; +void +rnd_pos(struct room *rp, coord *cp) { cp->x = rp->r_pos.x + rnd(rp->r_max.x-2) + 1; cp->y = rp->r_pos.y + rnd(rp->r_max.y-2) + 1; @@ -210,8 +213,7 @@ register coord *cp; */ struct room * -roomin(cp) -register coord *cp; +roomin(coord *cp) { register struct room *rp; @@ -226,8 +228,8 @@ register coord *cp; * draw a vertical line */ -vert(cnt) -register int cnt; +void +vert(int cnt) { register int x, y; diff --git a/arogue5/save.c b/arogue5/save.c index 0da3c9e..d85a127 100644 --- a/arogue5/save.c +++ b/arogue5/save.c @@ -23,6 +23,8 @@ #include #include "rogue.h" +bool save_file(FILE *savef); + typedef struct stat STAT; extern char version[], encstr[]; @@ -31,7 +33,7 @@ extern char version[], encstr[]; STAT sbuf; bool -save_game() +save_game(void) { register FILE *savef; register int c; @@ -122,8 +124,7 @@ auto_save(int sig) * write the saved game on the file */ bool -save_file(savef) -register FILE *savef; +save_file(FILE *savef) { int ret; int slines = LINES; @@ -147,9 +148,8 @@ register FILE *savef; return(ret); } -restore(file, envp) -register char *file; -char **envp; +bool +restore(char *file, char **envp) { register int inf; #ifndef _AIX @@ -264,13 +264,11 @@ char **envp; /* * perform an encrypted write */ -encwrite(start, size, outf) -register char *start; -register unsigned size; -register FILE *outf; +int +encwrite(char *start, unsigned int size, FILE *outf) { register char *ep; - register num_written = 0; + register int num_written = 0; ep = encstr; @@ -288,10 +286,8 @@ register FILE *outf; /* * perform an encrypted read */ -encread(start, size, inf) -register char *start; -register unsigned size; -register int inf; +int +encread(char *start, unsigned int size, int inf) { register char *ep; register int read_size; diff --git a/arogue5/scrolls.c b/arogue5/scrolls.c index fae7039..897b314 100644 --- a/arogue5/scrolls.c +++ b/arogue5/scrolls.c @@ -23,7 +23,8 @@ /* * let the hero get rid of some type of monster (but not a UNIQUE!) */ -genocide() +void +genocide(void) { register struct linked_list *ip; register struct thing *mp; @@ -37,7 +38,7 @@ genocide() /* Print out the monsters */ while (num_monst > 0) { - register left_limit; + int left_limit; if (num_monst < num_lines) left_limit = (num_monst+1)/2; else left_limit = num_lines/2; @@ -112,10 +113,8 @@ get_monst: msg("You have wiped out the %s.", monsters[which_monst].m_name); } -read_scroll(which, flag, is_scroll) -register int which; -int flag; -bool is_scroll; +void +read_scroll(int which, int flag, bool is_scroll) { register struct object *obj = NULL, *nobj; register struct linked_list *item, *nitem; diff --git a/arogue5/state.c b/arogue5/state.c index d26c42c..7255c8a 100644 --- a/arogue5/state.c +++ b/arogue5/state.c @@ -64,6 +64,12 @@ #include #include "rogue.h" +int rs_read_int(int inf, int *i); +int rs_write_int(FILE *savef, int c); +int list_size(struct linked_list *l); +int rs_write_object_list(FILE *savef, struct linked_list *l); +int rs_read_object_list(int inf, struct linked_list **list); + #define READSTAT (format_error || read_error ) #define WRITESTAT (write_error) @@ -1712,6 +1718,7 @@ rs_read_rooms(int inf, struct room *r, int count) return(READSTAT); } +int rs_write_room_reference(FILE *savef, struct room *rp) { int i, room = -1; @@ -2224,7 +2231,7 @@ rs_read_thing(int inf, struct thing *t) return(READSTAT); } -int +void rs_fix_thing(struct thing *t) { struct thing *tp; @@ -2434,6 +2441,7 @@ rs_save_file(FILE *savef) return(WRITESTAT); } +int rs_restore_file(int inf) { int i; diff --git a/arogue5/sticks.c b/arogue5/sticks.c index 3f36ec4..36a0e86 100644 --- a/arogue5/sticks.c +++ b/arogue5/sticks.c @@ -18,14 +18,13 @@ #include #include "rogue.h" +void drain(int ymin, int ymax, int xmin, int xmax); /* * zap a stick and see what happens */ -do_zap(gotdir, which, flag) -bool gotdir; -int which; -int flag; +bool +do_zap(bool gotdir, int which, int flag) { register struct linked_list *item; register struct object *obj = NULL; @@ -683,8 +682,8 @@ int flag; * Do drain hit points from player shtick */ -drain(ymin, ymax, xmin, xmax) -int ymin, ymax, xmin, xmax; +void +drain(int ymin, int ymax, int xmin, int xmax) { register int i, j, count; register struct thing *ick; @@ -745,8 +744,8 @@ int ymin, ymax, xmin, xmax; /* * initialize a stick */ -fix_stick(cur) -register struct object *cur; +void +fix_stick(struct object *cur) { if (EQUAL(ws_type[cur->o_which], "staff")) { cur->o_weight = 100; @@ -787,13 +786,9 @@ register struct object *cur; * given direction */ -shoot_bolt(shooter, start, dir, get_points, reason, name, damage) -struct thing *shooter; -coord start, dir; -bool get_points; -short reason; -char *name; -int damage; +bool +shoot_bolt(struct thing *shooter, coord start, coord dir, bool get_points, + short reason, char *name, int damage) { register char dirch = 0, ch; register bool used, change; diff --git a/arogue5/things.c b/arogue5/things.c index a8abe19..28a30ab 100644 --- a/arogue5/things.c +++ b/arogue5/things.c @@ -18,12 +18,13 @@ #include #include "rogue.h" +int extras(void); + /* * print out the number of charges on a stick */ char * -charge_str(obj) -register struct object *obj; +charge_str(struct object *obj) { static char buf[20]; @@ -41,9 +42,7 @@ register struct object *obj; * inventory. */ char * -inv_name(obj, drop) -register struct object *obj; -bool drop; +inv_name(struct object *obj, bool drop) { register char *pb; @@ -296,8 +295,7 @@ bool drop; * Return the name of a weapon. */ char * -weap_name(obj) -register struct object *obj; +weap_name(struct object *obj) { switch (obj->o_type) { case WEAPON: @@ -325,8 +323,8 @@ register struct object *obj; * drop: * put something down */ -drop(item) -struct linked_list *item; +bool +drop(struct linked_list *item) { register char ch = 0; register struct linked_list *obj, *nobj; @@ -413,8 +411,8 @@ struct linked_list *item; /* * do special checks for dropping or unweilding|unwearing|unringing */ -dropcheck(op) -register struct object *op; +bool +dropcheck(struct object *op) { int save_max; @@ -514,8 +512,7 @@ register struct object *op; * return a new thing */ struct linked_list * -new_thing(thing_type) -int thing_type; +new_thing(int thing_type) { register struct linked_list *item; register struct object *cur; @@ -710,8 +707,7 @@ int thing_type; * provide a new item tailored to specification */ struct linked_list * -spec_item(type, which, hit, damage) -int type, which, hit, damage; +spec_item(int type, int which, int hit, int damage) { register struct linked_list *item; register struct object *obj; @@ -787,9 +783,8 @@ int type, which, hit, damage; /* * pick an item out of a list of nitems possible magic items */ -pick_one(magic, nitems) -register struct magic_item *magic; -int nitems; +int +pick_one(struct magic_item *magic, int nitems) { register struct magic_item *end; register int i; @@ -821,8 +816,7 @@ int nitems; */ char * -blesscurse(flags) -int flags; +blesscurse(int flags) { if (flags & ISKNOW) { if (flags & ISCURSED) return("cursed "); @@ -836,7 +830,8 @@ int flags; * extras: * Return the number of extra items to be created */ -extras() +int +extras(void) { reg int i; diff --git a/arogue5/trader.c b/arogue5/trader.c index d4e3792..17d8e44 100644 --- a/arogue5/trader.c +++ b/arogue5/trader.c @@ -14,17 +14,20 @@ #include "curses.h" #include "rogue.h" +#include #include - - +bool open_market(void); +void trans_line(void); +char *typ_name(struct object *obj); /* * buy_it: * Buy the item on which the hero stands */ -buy_it() +void +buy_it(void) { reg int wh; struct linked_list *item; @@ -77,7 +80,8 @@ buy_it() * do_post: * Put a trading post room and stuff on the screen */ -do_post() +void +do_post(void) { coord tp; reg int i; @@ -124,8 +128,8 @@ do_post() * get_worth: * Calculate an objects worth in gold */ -get_worth(obj) -reg struct object *obj; +int +get_worth(struct object *obj) { reg int worth, wh; @@ -195,7 +199,8 @@ reg struct object *obj; * open_market: * Retruns TRUE when ok do to transacting */ -open_market() +bool +open_market(void) { if (trader >= MAXPURCH && !wizard) { msg("The market is closed. The stairs are that-a-way."); @@ -210,7 +215,8 @@ open_market() * price_it: * Price the object that the hero stands on */ -price_it() +bool +price_it(void) { reg struct linked_list *item; reg struct object *obj; @@ -244,7 +250,8 @@ price_it() * sell_it: * Sell an item to the trading post */ -sell_it() +void +sell_it(void) { reg struct linked_list *item; reg struct object *obj; @@ -291,7 +298,8 @@ sell_it() * trans_line: * Show how many transactions the hero has left */ -trans_line() +void +trans_line(void) { if (!wizard) sprintf(prbuf,"You have %d transactions remaining.", @@ -309,8 +317,7 @@ trans_line() * Return the name for this type of object */ char * -typ_name(obj) -reg struct object *obj; +typ_name(struct object *obj) { static char buff[20]; reg int wh; diff --git a/arogue5/util.c b/arogue5/util.c index 445ee3b..70bd834 100644 --- a/arogue5/util.c +++ b/arogue5/util.c @@ -22,7 +22,8 @@ * aggravate all the monsters on this level */ -aggravate() +void +aggravate(void) { register struct linked_list *mi; @@ -35,8 +36,8 @@ aggravate() * returns true if the hero can see a certain coordinate. */ -cansee(y, x) -register int y, x; +bool +cansee(int y, int x) { register struct room *rer; register int radius; @@ -93,8 +94,7 @@ static struct { }; long -check_level(get_spells) -bool get_spells; +check_level(bool get_spells) { register int i, j, add = 0; register unsigned long exp; @@ -148,8 +148,8 @@ bool get_spells; * it keeps track of the highest it has been, just in case */ -chg_str(amt) -register int amt; +void +chg_str(int amt) { register int ring_str; /* ring strengths */ register struct stats *ptr; /* for speed */ @@ -172,7 +172,7 @@ register int amt; * this routine computes the players current AC without dex bonus's */ int -ac_compute() +ac_compute(void) { register int ac; @@ -194,7 +194,8 @@ ac_compute() /* * this routine computes the players current strength */ -str_compute() +int +str_compute(void) { if (cur_misc[WEAR_GAUNTLET] != NULL && cur_misc[WEAR_GAUNTLET]->o_which == MM_G_OGRE) { @@ -210,7 +211,8 @@ str_compute() /* * this routine computes the players current dexterity */ -dex_compute() +int +dex_compute(void) { if (cur_misc[WEAR_GAUNTLET] != NULL && cur_misc[WEAR_GAUNTLET]->o_which == MM_G_DEXTERITY) { @@ -229,9 +231,8 @@ dex_compute() * Check to see if the move is legal if it is diagonal */ -diag_ok(sp, ep, flgptr) -register coord *sp, *ep; -struct thing *flgptr; +bool +diag_ok(coord *sp, coord *ep, struct thing *flgptr) { register int numpaths = 0; @@ -252,7 +253,8 @@ struct thing *flgptr; * He wants to eat something, so let him try */ -eat() +void +eat(void) { register struct linked_list *item; @@ -282,10 +284,7 @@ eat() * pick a random position around the give (y, x) coordinates */ coord * -fallpos(pos, be_clear, range) -register coord *pos; -bool be_clear; -int range; +fallpos(coord *pos, bool be_clear, int range) { register int tried, i, j; register char ch; @@ -364,9 +363,7 @@ int range; */ struct linked_list * -find_mons(y, x) -register int y; -register int x; +find_mons(int y, int x) { register struct linked_list *item; register struct thing *th; @@ -386,9 +383,7 @@ register int x; */ struct linked_list * -find_obj(y, x) -register int y; -register int x; +find_obj(int y, int x) { register struct linked_list *obj; register struct object *op; @@ -406,7 +401,8 @@ register int x; /* * set up the direction co_ordinate for use in varios "prefix" commands */ -get_dir() +bool +get_dir(void) { register char *prompt; register bool gotit; @@ -446,8 +442,8 @@ get_dir() /* * see if the object is one of the currently used items */ -is_current(obj) -register struct object *obj; +bool +is_current(struct object *obj) { if (obj == NULL) return FALSE; @@ -483,11 +479,12 @@ register struct object *obj; /* * Look: * A quick glance all around the player + * wakeup: Should we wake up monsters + * runend: At end of a run -- for mazes */ -look(wakeup, runend) -bool wakeup; /* Should we wake up monsters */ -bool runend; /* At end of a run -- for mazes */ +void +look(bool wakeup, bool runend) { register int x, y, radius; register char ch, och; @@ -738,8 +735,8 @@ bool runend; /* At end of a run -- for mazes */ * The guy just magically went up a level. */ -raise_level(get_spells) -bool get_spells; +void +raise_level(bool get_spells) { unsigned long test; /* Next level -- be sure it is not an overflow */ @@ -766,11 +763,12 @@ static int st_matrix[5][5] = { /* * save: * See if a creature saves against something + * which: which type of save + * who: who is saving + * adj: saving throw adjustment */ -save(which, who, adj) -int which; /* which type of save */ -struct thing *who; /* who is saving */ -int adj; /* saving throw adjustment */ +bool +save(int which, struct thing *who, int adj) { register int need, level; @@ -814,8 +812,8 @@ int adj; /* saving throw adjustment */ * Figure out what a secret door looks like. */ -secretdoor(y, x) -register int y, x; +char +secretdoor(int y, int x) { register int i; register struct room *rp; @@ -838,9 +836,8 @@ register int y, x; /* * copy string using unctrl for things */ -strucpy(s1, s2, len) -register char *s1, *s2; -register int len; +void +strucpy(char *s1, char *s2, int len) { register char *sp; @@ -859,8 +856,7 @@ register int len; */ char * -tr_name(ch) -char ch; +tr_name(char ch) { register char *s = NULL; @@ -890,8 +886,7 @@ char ch; * for printfs: if string starts with a vowel, return "n" for an "an" */ char * -vowelstr(str) -register char *str; +vowelstr(char *str) { switch (*str) { @@ -911,7 +906,8 @@ register char *str; * Do nothing but let other things happen */ -waste_time() +void +waste_time(void) { if (inwhgt) /* if from wghtchk then done */ return; diff --git a/arogue5/weapons.c b/arogue5/weapons.c index 35115ff..706cd1a 100644 --- a/arogue5/weapons.c +++ b/arogue5/weapons.c @@ -23,10 +23,8 @@ * do the actual motion on the screen done by an object traveling * across the room */ -do_motion(obj, ydelta, xdelta, tp) -register struct object *obj; -register int ydelta, xdelta; -register struct thing *tp; +void +do_motion(struct object *obj, int ydelta, int xdelta, struct thing *tp) { /* @@ -70,9 +68,8 @@ register struct thing *tp; * Drop an item someplace around here. */ -fall(item, pr) -register struct linked_list *item; -bool pr; +void +fall(struct linked_list *item, bool pr) { register struct object *obj; register struct room *rp; @@ -116,10 +113,8 @@ bool pr; * Does the missile hit the monster */ -hit_monster(y, x, obj, tp) -register int y, x; -struct object *obj; -register struct thing *tp; +bool +hit_monster(int y, int x, struct object *obj, struct thing *tp) { static coord mp; @@ -144,9 +139,8 @@ register struct thing *tp; * Set up the initial goodies for a weapon */ -init_weapon(weap, type) -register struct object *weap; -char type; +void +init_weapon(struct object *weap, char type) { register struct init_weps *iwp; @@ -169,10 +163,8 @@ char type; * Fire a missile in a given direction */ -missile(ydelta, xdelta, item, tp) -int ydelta, xdelta; -register struct linked_list *item; -register struct thing *tp; +void +missile(int ydelta, int xdelta, struct linked_list *item, struct thing *tp) { register struct object *obj; register struct linked_list *nitem; @@ -247,8 +239,7 @@ register struct thing *tp; */ char * -num(n1, n2) -register int n1, n2; +num(int n1, int n2) { static char numbuf[LINELEN]; @@ -268,7 +259,8 @@ register int n1, n2; * Pull out a certain weapon */ -wield() +void +wield(void) { register struct linked_list *item; register struct object *obj, *oweapon; diff --git a/arogue5/wear.c b/arogue5/wear.c index 19866e9..f1515fd 100644 --- a/arogue5/wear.c +++ b/arogue5/wear.c @@ -23,7 +23,8 @@ * Get the armor off of the players back */ -take_off() +void +take_off(void) { register struct object *obj; register struct linked_list *item; @@ -52,7 +53,8 @@ take_off() * The player wants to wear something, so let him/her put it on. */ -wear() +void +wear(void) { register struct linked_list *item; register struct object *obj; diff --git a/arogue5/wizard.c b/arogue5/wizard.c index f5ca45b..789548e 100644 --- a/arogue5/wizard.c +++ b/arogue5/wizard.c @@ -15,6 +15,7 @@ #include "curses.h" #include +#include #include #include "rogue.h" @@ -23,9 +24,8 @@ * create_obj: * Create any object for wizard, scroll, magician, or cleric */ -create_obj(prompt, which_item, which_type) -bool prompt; -int which_item, which_type; +void +create_obj(bool prompt, int which_item, int which_type) { reg struct linked_list *item; reg struct object *obj; @@ -311,7 +311,8 @@ int which_item, which_type; * getbless: * Get a blessing for a wizards object */ -getbless() +int +getbless(void) { reg char bless; @@ -328,7 +329,8 @@ getbless() /* * get a non-monster death type */ -getdeath() +int +getdeath(void) { register int i; int which_death; @@ -358,8 +360,8 @@ getdeath() /* * make a monster for the wizard */ -makemonster(create) -bool create; +short +makemonster(bool create) { register int i; register short which_monst; @@ -368,7 +370,7 @@ bool create; /* Print out the monsters */ while (num_monst > 0) { - register left_limit; + register int left_limit; if (num_monst < num_lines) left_limit = (num_monst+1)/2; else left_limit = num_lines/2; @@ -430,7 +432,8 @@ get_monst: * see if user knows password */ -passwd() +bool +passwd(void) { register char *sp, c; char buf[LINELEN]; @@ -457,7 +460,8 @@ passwd() * Bamf the hero someplace else */ -teleport() +int +teleport(void) { register struct room *new_rp, *old_rp = roomin(&hero); register int rm; @@ -525,8 +529,8 @@ teleport() * What a certin object is */ -whatis(what) -struct linked_list *what; +void +whatis(struct linked_list *what) { register struct object *obj; register struct linked_list *item; diff --git a/arogue5/xcrypt.c b/arogue5/xcrypt.c index e6e6b90..d840ea6 100644 --- a/arogue5/xcrypt.c +++ b/arogue5/xcrypt.c @@ -52,6 +52,9 @@ #include #include +unsigned long int md_htonl(unsigned long int x); +unsigned long int md_ntohl(unsigned long int x); + #ifdef DEBUG # include #endif From e8e6e604c371c249e855a1f654c2aa1919c2c20e Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Fri, 19 Feb 2016 21:02:28 -0500 Subject: [PATCH 6/7] Advanced Rogue 7: convert to ANSI-style function declarations. Almost 1500 lines of compiler warnings remain, and the GCC developers are already working on a new version with even more warnings turned on by default. --- arogue7/actions.c | 65 +++++---- arogue7/chase.c | 38 +++-- arogue7/command.c | 62 +++++--- arogue7/daemon.c | 40 +++--- arogue7/daemons.c | 118 +++++++++------ arogue7/eat.c | 3 +- arogue7/effects.c | 8 +- arogue7/encumb.c | 30 ++-- arogue7/fight.c | 132 ++++++++--------- arogue7/init.c | 30 ++-- arogue7/io.c | 63 ++++---- arogue7/list.c | 47 +++--- arogue7/main.c | 60 +++++--- arogue7/maze.c | 38 ++--- arogue7/mdport.c | 42 +++--- arogue7/misc.c | 60 ++++---- arogue7/monsters.c | 38 ++--- arogue7/move.c | 70 +++++---- arogue7/new_level.c | 20 +-- arogue7/options.c | 69 ++++----- arogue7/outside.c | 19 ++- arogue7/pack.c | 97 ++++++------- arogue7/passages.c | 16 ++- arogue7/player.c | 52 ++++--- arogue7/potions.c | 47 +++--- arogue7/rings.c | 15 +- arogue7/rip.c | 55 ++++--- arogue7/rogue.h | 342 +++++++++++++++++++++++++++++++++++++++----- arogue7/rooms.c | 32 ++--- arogue7/save.c | 27 ++-- arogue7/scrolls.c | 10 +- arogue7/state.c | 8 +- arogue7/sticks.c | 49 +++---- arogue7/things.c | 45 +++--- arogue7/trader.c | 34 +++-- arogue7/util.c | 108 +++++++------- arogue7/weapons.c | 40 ++---- arogue7/wear.c | 10 +- arogue7/wizard.c | 31 ++-- 39 files changed, 1181 insertions(+), 889 deletions(-) diff --git a/arogue7/actions.c b/arogue7/actions.c index 21d0eda..cf34f51 100644 --- a/arogue7/actions.c +++ b/arogue7/actions.c @@ -18,12 +18,21 @@ #include "rogue.h" #define MAXINT INT_MAX #define MININT INT_MIN + +void m_breathe(struct thing *tp); +void m_select(struct thing *th, bool flee); +void m_sonic(struct thing *tp); +void m_spell(struct thing *tp); +void m_summon(struct thing *tp); +bool m_use_it(struct thing *tp, bool flee, struct room *rer, struct room *ree); +bool m_use_pack(struct thing *monster, coord *monst_pos, coord *defend_pos, + int dist, coord *shoot_dir); + /* * Did we disrupt a spell? */ -dsrpt_monster(tp, always, see_him) -register struct thing *tp; -bool always, see_him; +void +dsrpt_monster(struct thing *tp, bool always, bool see_him) { switch (tp->t_action) { case A_SUMMON: @@ -52,7 +61,8 @@ bool always, see_him; } } -dsrpt_player() +void +dsrpt_player(void) { int which, action; struct linked_list *item; @@ -81,7 +91,7 @@ dsrpt_player() if (purse > 0) { msg("Your gold goes flying everywhere!"); do { - item = spec_item(GOLD, NULL, NULL, NULL); + item = spec_item(GOLD, 0, 0, 0); obj = OBJPTR(item); obj->o_count = min(purse, rnd(10)+1); purse -= obj->o_count; @@ -120,8 +130,8 @@ dsrpt_player() * Otherwise, let it perform its chosen action. */ -m_act(tp) -register struct thing *tp; +void +m_act(struct thing *tp) { struct object *obj; bool flee; /* Are we scared? */ @@ -235,8 +245,8 @@ register struct thing *tp; * Breathe in the chosen direction. */ -m_breathe(tp) -register struct thing *tp; +void +m_breathe(struct thing *tp) { register int damage; register char *breath = ""; @@ -344,11 +354,11 @@ register struct thing *tp; /* * m_select: * Select an action for the monster. + * flee: True if running away or player is inaccessible in wall */ -m_select(th, flee) -register struct thing *th; -register bool flee; /* True if running away or player is inaccessible in wall */ +void +m_select(struct thing *th, bool flee) { register struct room *rer, *ree; /* room of chaser, room of chasee */ int dist = MININT; @@ -486,8 +496,8 @@ register bool flee; /* True if running away or player is inaccessible in wall */ * The monster is sounding a sonic blast. */ -m_sonic(tp) -register struct thing *tp; +void +m_sonic(struct thing *tp) { register int damage; static struct object blast = @@ -515,8 +525,8 @@ register struct thing *tp; * The monster casts a spell. Currently this is limited to * magic missile. */ -m_spell(tp) -register struct thing *tp; +void +m_spell(struct thing *tp) { static struct object missile = { @@ -538,8 +548,8 @@ register struct thing *tp; * Summon aid. */ -m_summon(tp) -register struct thing *tp; +void +m_summon(struct thing *tp) { register char *helpname, *mname; int fail, numsum; @@ -612,10 +622,7 @@ register struct thing *tp; */ bool -m_use_it(tp, flee, rer, ree) -register struct thing *tp; -bool flee; -register struct room *rer, *ree; +m_use_it(struct thing *tp, bool flee, struct room *rer, struct room *ree) { int dist; register coord *ee = tp->t_dest, *er = &tp->t_pos; @@ -777,14 +784,15 @@ register struct room *rer, *ree; /* * runners: * Make all the awake monsters try to do something. + * segments: Number of segments since last called */ -runners(segments) -int segments; /* Number of segments since last called */ +int +runners(int segments) { register struct linked_list *item; register struct thing *tp = NULL; - register min_time = 20; /* Minimum time until a monster can act */ + register int min_time = 20; /* Minimum time until a monster can act */ /* * loop thru the list of running (wandering) monsters and see what @@ -870,11 +878,8 @@ int segments; /* Number of segments since last called */ * Only care about relics and wands for now. */ bool -m_use_pack(monster, monst_pos, defend_pos, dist, shoot_dir) -register struct thing *monster; -register coord *monst_pos, *defend_pos; -register int dist; -register coord *shoot_dir; +m_use_pack(struct thing *monster, coord *monst_pos, coord *defend_pos, + int dist, coord *shoot_dir) { register struct object *obj; register struct linked_list *pitem, *relic, *stick; diff --git a/arogue7/chase.c b/arogue7/chase.c index 260d600..295667d 100644 --- a/arogue7/chase.c +++ b/arogue7/chase.c @@ -19,11 +19,13 @@ #include #include +#include #include "curses.h" #include "rogue.h" #define MAXINT INT_MAX #define MININT INT_MIN +bool straight_shot(int ery, int erx, int eey, int eex, coord *shooting); /* * Canblink checks if the monster can teleport (blink). If so, it will @@ -31,8 +33,7 @@ */ bool -can_blink(tp) -register struct thing *tp; +can_blink(struct thing *tp) { register int y, x, index=9; coord tryp; /* To hold the coordinates for use in diag_ok */ @@ -127,8 +128,7 @@ register struct thing *tp; */ coord * -can_shoot(er, ee) -register coord *er, *ee; +can_shoot(coord *er, coord *ee) { static coord shoot_dir; @@ -147,16 +147,14 @@ register coord *er, *ee; * chase: * Find the spot for the chaser(er) to move closer to the * chasee(ee). Rer is the room of the chaser, and ree is the - * room of the creature being chased (chasee). + * room of the creature being chased (chasee). Flee is true if + * destination (ee) is player and monster is running away + * or the player is in a wall and the monster can't get to it */ -chase(tp, ee, rer, ree, flee) -register struct thing *tp; -register coord *ee; -register struct room *rer, *ree; -bool flee; /* True if destination (ee) is player and monster is running away - * or the player is in a wall and the monster can't get to it - */ +void +chase(struct thing *tp, coord *ee, struct room *rer, struct room *ree, + bool flee) { int dist, thisdist, monst_dist = MAXINT; register coord *er = &tp->t_pos; @@ -494,8 +492,8 @@ bool flee; /* True if destination (ee) is player and monster is running away * Make one thing chase another. */ -do_chase(th) -register struct thing *th; +void +do_chase(struct thing *th) { register struct room *orig_rer, /* Original room of chaser */ *new_room; /* new room of monster */ @@ -803,8 +801,7 @@ register struct thing *th; */ struct linked_list * -get_hurl(tp) -register struct thing *tp; +get_hurl(struct thing *tp) { struct linked_list *arrow=NULL, *bolt=NULL, *rock=NULL, *spear = NULL, *dagger=NULL, *dart=NULL, *aklad=NULL; @@ -851,9 +848,8 @@ register struct thing *tp; * Set a monster running after something */ -runto(runner, spot) -register struct thing *runner; -coord *spot; +void +runto(struct thing *runner, coord *spot) { if (on(*runner, ISSTONE)) return; @@ -881,9 +877,7 @@ coord *spot; */ bool -straight_shot(ery, erx, eey, eex, shooting) -register int ery, erx, eey, eex; -register coord *shooting; +straight_shot(int ery, int erx, int eey, int eex, coord *shooting) { register int dy, dx; /* Deltas */ char ch; diff --git a/arogue7/command.c b/arogue7/command.c index 86e7526..3aa73bd 100644 --- a/arogue7/command.c +++ b/arogue7/command.c @@ -29,12 +29,23 @@ extern struct uwdata wdata; #endif +void display(void); +void help(void); +void identify(char ch); +void d_level(void); +void u_level(void); +void shell(void); +void nameit(void); +void namemonst(void); +void count_gold(void); + /* * command: * Process the user commands */ -command() +void +command(void) { unsigned char ch; struct linked_list *item; @@ -267,8 +278,8 @@ command() after = FALSE; } when C_COUNT : count_gold(); - when C_QUAFF : quaff(-1, NULL, NULL, TRUE); - when C_READ : read_scroll(-1, NULL, TRUE); + when C_QUAFF : quaff(-1, 0, 0, TRUE); + when C_READ : read_scroll(-1, 0, TRUE); when C_EAT : eat(); when C_WIELD : wield(); when C_WEAR : wear(); @@ -280,7 +291,7 @@ command() when '>' : after = FALSE; d_level(); when '<' : after = FALSE; u_level(); when '?' : after = FALSE; help(); - when '/' : after = FALSE; identify(NULL); + when '/' : after = FALSE; identify(0); when C_USE : use_mm(-1); when CTRL('T') : if (player.t_action == A_NIL) { @@ -315,7 +326,7 @@ command() search(FALSE, FALSE); player.t_action = A_NIL; } - when C_ZAP : if (!player_zap(NULL, FALSE)) + when C_ZAP : if (!player_zap(0, FALSE)) after=FALSE; when C_PRAY : pray(); when C_CHANT : chant(); @@ -553,7 +564,8 @@ command() * tell the player what is at a certain coordinates assuming * it can be seen. */ -display() +void +display(void) { coord c; struct linked_list *item; @@ -587,8 +599,7 @@ display() */ void -quit(sig) -int sig; +quit(int sig) { /* * Reset the signal in case we got here via an interrupt @@ -628,8 +639,7 @@ int sig; */ void -bugkill(sig) -int sig; +bugkill(int sig) { signal(sig, quit); /* If we get it again, give up */ death(D_SIGNAL); /* Killed by a bug */ @@ -641,8 +651,8 @@ int sig; * Player gropes about him to find hidden things. */ -search(is_thief, door_chime) -register bool is_thief, door_chime; +void +search(bool is_thief, bool door_chime) { register int x, y; register char ch, /* The trap or door character */ @@ -752,7 +762,8 @@ register bool is_thief, door_chime; * Give single character help, or the whole mess if he wants it */ -help() +void +help(void) { register struct h_list *strp = helpstr; #ifdef WIZARD @@ -844,8 +855,8 @@ help() * Tell the player what a certain thing is. */ -identify(ch) -register char ch; +void +identify(char ch) { register char *str; @@ -907,6 +918,7 @@ register char ch; * He wants to go down a level */ +void d_level() { bool no_phase=FALSE; @@ -958,7 +970,8 @@ d_level() * He wants to go up a level */ -u_level() +void +u_level(void) { bool no_phase = FALSE; register struct linked_list *item; @@ -1016,7 +1029,8 @@ u_level() * Let him escape for a while */ -shell() +void +shell(void) { register char *sh; @@ -1050,7 +1064,8 @@ shell() /* * see what we want to name -- an item or a monster. */ -nameit() +void +nameit(void) { char answer; @@ -1073,9 +1088,8 @@ nameit() /* * allow a user to call a potion, scroll, or ring something */ -nameitem(item, mark) -struct linked_list *item; -bool mark; +void +nameitem(struct linked_list *item, bool mark) { register struct object *obj; register char **guess = NULL, *elsewise = NULL; @@ -1161,7 +1175,8 @@ bool mark; /* Name a monster */ -namemonst() +void +namemonst(void) { register struct thing *tp; struct linked_list *item; @@ -1206,7 +1221,8 @@ namemonst() msg("There is no monster there to name."); } -count_gold() +void +count_gold(void) { if (player.t_action != C_COUNT) { msg("You take a break to count your money..."); diff --git a/arogue7/daemon.c b/arogue7/daemon.c index 287242a..5addb22 100644 --- a/arogue7/daemon.c +++ b/arogue7/daemon.c @@ -44,7 +44,7 @@ int fusecnt = 0; * Find an empty slot in the daemon list */ struct delayed_action * -d_slot() +d_slot(void) { reg int i; reg struct delayed_action *dev; @@ -60,7 +60,7 @@ d_slot() * Find an empty slot in the fuses list */ struct delayed_action * -f_slot() +f_slot(void) { reg int i; reg struct delayed_action *dev; @@ -78,8 +78,7 @@ f_slot() * Find a particular slot in the table */ struct delayed_action * -find_slot(func) -reg int (*func)(); +find_slot(int (*func)()) { reg int i; reg struct delayed_action *dev; @@ -95,8 +94,8 @@ reg int (*func)(); * start_daemon: * Start a daemon, takes a function. */ -start_daemon(func, arg, type) -reg int arg, type, (*func)(); +void +start_daemon(int (*func)(), int arg, int type) { reg struct delayed_action *dev; @@ -115,8 +114,8 @@ reg int arg, type, (*func)(); * kill_daemon: * Remove a daemon from the list */ -kill_daemon(func) -reg int (*func)(); +void +kill_daemon(int (*func)()) { reg struct delayed_action *dev; reg int i; @@ -142,8 +141,8 @@ reg int (*func)(); * Run all the daemons that are active with the current flag, * passing the argument to the function. */ -do_daemons(flag) -reg int flag; +void +do_daemons(int flag) { reg struct delayed_action *dev; @@ -163,8 +162,8 @@ reg int flag; * fuse: * Start a fuse to go off in a certain number of turns */ -fuse(func, arg, time, type) -reg int (*func)(), arg, time, type; +void +fuse(int (*func)(), int arg, int time, int type) { reg struct delayed_action *wire; @@ -183,8 +182,8 @@ reg int (*func)(), arg, time, type; * lengthen: * Increase the time until a fuse goes off */ -lengthen(func, xtime) -reg int (*func)(), xtime; +void +lengthen(int (*func)(), int xtime) { reg struct delayed_action *wire; @@ -198,8 +197,8 @@ reg int (*func)(), xtime; * extinguish: * Put out a fuse */ -extinguish(func) -reg int (*func)(); +void +extinguish(int (*func)()) { reg struct delayed_action *wire; @@ -217,8 +216,8 @@ reg int (*func)(); * do_fuses: * Decrement counters and start needed fuses */ -do_fuses(flag) -reg int flag; +void +do_fuses(int flag) { reg struct delayed_action *wire; @@ -245,8 +244,9 @@ reg int flag; * activity: * Show wizard number of demaons and memory blocks used */ -activity() +void +activity(void) { msg("Daemons = %d : Fuses = %d : Memory Items = %d : Memory Used = %d", - demoncnt,fusecnt,total,md_memused(0)); + demoncnt,fusecnt,total,md_memused()); } diff --git a/arogue7/daemons.c b/arogue7/daemons.c index 54eeebe..da5d976 100644 --- a/arogue7/daemons.c +++ b/arogue7/daemons.c @@ -25,8 +25,8 @@ * A healing daemon that restors hit points after rest */ -doctor(tp) -register struct thing *tp; +void +doctor(struct thing *tp) { register int ohp; register int limit, new_points; @@ -108,7 +108,8 @@ register struct thing *tp; * Called when it is time to start rolling for wandering monsters */ -swander() +void +swander(void) { start_daemon(rollwand, 0, BEFORE); } @@ -120,7 +121,8 @@ swander() int between = 0; -rollwand() +void +rollwand(void) { if (++between >= 4) @@ -140,7 +142,8 @@ rollwand() /* * this function is a daemon called each turn when the character is a thief */ -trap_look() +void +trap_look(void) { if (rnd(100) < (2*dex_compute() + 5*pstats.s_lvl)) search(TRUE, FALSE); @@ -151,7 +154,8 @@ trap_look() * Release the poor player from his confusion */ -unconfuse() +void +unconfuse(void) { turn_off(player, ISHUH); msg("You feel less confused now"); @@ -162,7 +166,8 @@ unconfuse() * unsee: * He lost his see invisible power */ -unsee() +void +unsee(void) { if (!ISWEARING(R_SEEINVIS)) { turn_off(player, CANSEE); @@ -175,7 +180,8 @@ unsee() * Remove to-hit handicap from player */ -unstink() +void +unstink(void) { turn_off(player, HASSTINK); } @@ -185,7 +191,8 @@ unstink() * Player is no longer immune to confusion */ -unclrhead() +void +unclrhead(void) { turn_off(player, ISCLEAR); msg("The blue aura about your head fades away."); @@ -196,7 +203,8 @@ unclrhead() * Player can no longer walk through walls */ -unphase() +void +unphase(void) { turn_off(player, CANINWALL); msg("Your dizzy feeling leaves you."); @@ -208,7 +216,8 @@ unphase() * Player can no longer fly */ -land() +void +land(void) { turn_off(player, ISFLY); msg("You regain your normal weight"); @@ -220,7 +229,8 @@ land() * He gets his sight back */ -sight() +void +sight(void) { if (on(player, ISBLIND)) { @@ -237,8 +247,7 @@ sight() */ void -res_strength(howmuch) -int howmuch; +res_strength(int howmuch) { /* If lost_str is non-zero, restore that amount of strength, @@ -262,7 +271,8 @@ int howmuch; * End the hasting */ -nohaste() +void +nohaste(void) { turn_off(player, ISHASTE); msg("You feel yourself slowing down."); @@ -273,7 +283,8 @@ nohaste() * End the slowing */ -noslow() +void +noslow(void) { turn_off(player, ISSLOW); msg("You feel yourself speeding up."); @@ -284,7 +295,8 @@ noslow() * If this gets called, the player has suffocated */ -suffocate() +void +suffocate(void) { death(D_SUFFOCATION); } @@ -292,7 +304,8 @@ suffocate() /* * digest the hero's food */ -stomach() +void +stomach(void) { register int oldfood, old_hunger, food_use, i; @@ -368,7 +381,8 @@ stomach() /* * daemon for curing the diseased */ -cure_disease() +void +cure_disease(void) { turn_off(player, HASDISEASE); if (off (player, HASINFEST)) @@ -380,7 +394,8 @@ cure_disease() * appear: * Become visible again */ -appear() +void +appear(void) { turn_off(player, ISINVIS); PLAYER = VPLAYER; @@ -391,7 +406,8 @@ appear() * dust_appear: * dust of disappearance wears off */ -dust_appear() +void +dust_appear(void) { turn_off(player, ISINVIS); PLAYER = VPLAYER; @@ -402,7 +418,8 @@ dust_appear() * unchoke: * the effects of "dust of choking and sneezing" wear off */ -unchoke() +void +unchoke(void) { if (!find_slot(unconfuse)) turn_off(player, ISHUH); @@ -414,8 +431,8 @@ unchoke() /* * make some potion for the guy in the Alchemy jug */ -alchemy(obj) -register struct object *obj; +void +alchemy(struct object *obj) { register struct object *tobj = NULL; register struct linked_list *item; @@ -464,7 +481,8 @@ register struct object *obj; * otto's irresistable dance wears off */ -undance() +void +undance(void) { turn_off(player, ISDANCE); msg ("Your feet take a break.....whew!"); @@ -473,14 +491,16 @@ undance() /* * if he has our favorite necklace of strangulation then take damage every turn */ -strangle() +void +strangle(void) { if ((pstats.s_hpt -= 6) <= 0) death(D_STRANGLE); } /* * if he has on the gauntlets of fumbling he might drop his weapon each turn */ -fumble() +void +fumble(void) { register struct linked_list *item; @@ -519,21 +539,24 @@ fumble() /* * this is called each turn the hero has the ring of searching on */ -ring_search() +void +ring_search(void) { search(FALSE, FALSE); } /* * this is called each turn the hero has the ring of teleportation on */ -ring_teleport() +void +ring_teleport(void) { if (rnd(100) < 2) teleport(); } /* * this is called to charge up the quill of Nagrom */ -quill_charge() +void +quill_charge(void) { register struct object *tobj = NULL; register struct linked_list *item; @@ -556,7 +579,8 @@ quill_charge() /* * take the skills away gained (or lost) by the potion of skills */ -unskill() +void +unskill(void) { if (pstats.s_lvladj != 0) { pstats.s_lvl -= pstats.s_lvladj; @@ -569,8 +593,8 @@ unskill() * charge up the cloak of Emori */ -cloak_charge(obj) -register struct object *obj; +void +cloak_charge(struct object *obj) { if (obj->o_charges < 1) obj->o_charges = 1; @@ -580,7 +604,8 @@ register struct object *obj; * nofire: * He lost his fire resistance */ -nofire() +void +nofire(void) { if (!ISWEARING(R_FIRE)) { turn_off(player, NOFIRE); @@ -592,7 +617,8 @@ nofire() * nocold: * He lost his cold resistance */ -nocold() +void +nocold(void) { if (!ISWEARING(R_WARMTH)) { turn_off(player, NOCOLD); @@ -604,7 +630,8 @@ nocold() * nobolt: * He lost his protection from lightning */ -nobolt() +void +nobolt(void) { turn_off(player, NOBOLT); msg("Your skin looses its bluish tint"); @@ -613,8 +640,8 @@ nobolt() * eat_gold: * an artifact eats gold */ -eat_gold(obj) -register struct object *obj; +void +eat_gold(struct object *obj) { if (purse == 1) msg("%s demand you find more gold", inv_name(obj, FALSE)); @@ -628,36 +655,39 @@ register struct object *obj; /* * give the hero back some spell points */ -spell_recovery() +void +spell_recovery(void) { int time; time = SPELLTIME - max(17-pstats.s_intel, 0); time = max(time, 5); if (spell_power > 0) spell_power--; - fuse(spell_recovery, NULL, time, AFTER); + fuse(spell_recovery, 0, time, AFTER); } /* * give the hero back some prayer points */ -prayer_recovery() +void +prayer_recovery(void) { int time; time = SPELLTIME - max(17-pstats.s_wisdom, 0); time = max(time, 5); if (pray_time > 0) pray_time--; - fuse(prayer_recovery, NULL, time, AFTER); + fuse(prayer_recovery, 0, time, AFTER); } /* * give the hero back some chant points */ -chant_recovery() +void +chant_recovery(void) { int time; time = SPELLTIME - max(17-pstats.s_wisdom, 0); time = max(time, 5); if (chant_time > 0) chant_time--; - fuse(chant_recovery, NULL, time, AFTER); + fuse(chant_recovery, 0, time, AFTER); } diff --git a/arogue7/eat.c b/arogue7/eat.c index 8cf827b..d75e9d1 100644 --- a/arogue7/eat.c +++ b/arogue7/eat.c @@ -20,7 +20,8 @@ * He wants to eat something, so let him try */ -eat() +void +eat(void) { register struct linked_list *item; int which; diff --git a/arogue7/effects.c b/arogue7/effects.c index 3074de6..082026c 100644 --- a/arogue7/effects.c +++ b/arogue7/effects.c @@ -21,11 +21,9 @@ * Check for effects of one thing hitting another thing. Return * the reason code if the defender is killed. Otherwise return 0. */ -effect(att, def, weap, thrown, see_att, see_def) -register struct thing *att, *def; -struct object *weap; -bool thrown; -register bool see_att, see_def; +int +effect(struct thing *att, struct thing *def, struct object *weap, bool thrown, + bool see_att, bool see_def) { register bool att_player, def_player; char attname[LINELEN+1], defname[LINELEN+1]; diff --git a/arogue7/encumb.c b/arogue7/encumb.c index f7333df..c703379 100644 --- a/arogue7/encumb.c +++ b/arogue7/encumb.c @@ -20,13 +20,14 @@ #include "curses.h" #include "rogue.h" +int packweight(struct thing *tp); + /* * updpack: * Update his pack weight and adjust fooduse accordingly */ -updpack(getmax, tp) -int getmax; -struct thing *tp; +void +updpack(int getmax, struct thing *tp) { reg int topcarry, curcarry; @@ -55,8 +56,8 @@ struct thing *tp; * packweight: * Get the total weight of the hero's pack */ -packweight(tp) -register struct thing *tp; +int +packweight(struct thing *tp) { reg struct object *obj; reg struct linked_list *pc; @@ -92,8 +93,8 @@ register struct thing *tp; * itemweight: * Get the weight of an object */ -itemweight(wh) -reg struct object *wh; +int +itemweight(struct object *wh) { reg int weight; reg int ac; @@ -123,8 +124,8 @@ reg struct object *wh; * playenc: * Get hero's carrying ability above norm */ -playenc(tp) -register struct thing *tp; +int +playenc(struct thing *tp) { register int strength; @@ -139,8 +140,8 @@ register struct thing *tp; * totalenc: * Get total weight that the hero can carry */ -totalenc(tp) -register struct thing *tp; +int +totalenc(struct thing *tp) { reg int wtotal; @@ -162,11 +163,11 @@ register struct thing *tp; * See if the hero can carry his pack */ -wghtchk() +void +wghtchk(void) { reg int dropchk, err = TRUE; reg char ch; - int wghtchk(); inwhgt = TRUE; if (pstats.s_pack > pstats.s_carry) { @@ -201,7 +202,8 @@ wghtchk() * -1 hit for heavy pack weight */ -hitweight() +int +hitweight(void) { return(2 - foodlev); } diff --git a/arogue7/fight.c b/arogue7/fight.c index 946d06c..a94e2f2 100644 --- a/arogue7/fight.c +++ b/arogue7/fight.c @@ -20,9 +20,18 @@ #include "curses.h" #include #include +#include #include "rogue.h" -int hit(struct object *weapon, bool see_att, bool see_def, char *er, char *ee, bool back_stab, bool thrown, bool short_msg); +bool roll_em(struct thing *att_er, struct thing *def_er, struct object *weap, + bool hurl, struct object *cur_weapon, bool back_stab); +void hit(struct object *weapon, bool see_att, bool see_def, char *er, char *ee, + bool back_stab, bool thrown, bool short_msg); +void miss(struct object *weapon, bool see_att, bool see_def, char *er, char *ee, + bool thrown, bool short_msg); +int add_dam(short str); +int hung_dam(void); + #define CONF_DAMAGE -1 #define PARAL_DAMAGE -2 #define DEST_DAMAGE -3 @@ -31,9 +40,8 @@ int hit(struct object *weapon, bool see_att, bool see_def, char *er, char *ee, b /* * returns true if player has a any chance to hit the monster */ -player_can_hit(tp, weap) -register struct thing *tp; -register struct object *weap; +bool +player_can_hit(struct thing *tp, struct object *weap) { if (off(*tp, CMAGICHIT) && off(*tp, BMAGICHIT) && off(*tp, MAGICHIT)) return(TRUE); @@ -61,10 +69,8 @@ register struct object *weap; * The player attacks the monster. */ -fight(mp, weap, thrown) -register coord *mp; -struct object *weap; -bool thrown; +bool +fight(coord *mp, struct object *weap, bool thrown) { register struct thing *tp; register struct linked_list *item; @@ -225,10 +231,8 @@ bool thrown; * The monster attacks the player */ -attack(mp, weapon, thrown) -register struct thing *mp; -register struct object *weapon; -bool thrown; +bool +attack(struct thing *mp, struct object *weapon, bool thrown) { register char *mname; register bool see_att, did_hit = FALSE; @@ -301,9 +305,8 @@ bool thrown; * returns true if the swing hits */ -swing(class, at_lvl, op_arm, wplus) -short class; -int at_lvl, op_arm, wplus; +bool +swing(short class, int at_lvl, int op_arm, int wplus) { register int res = rnd(20)+1; register int need; @@ -323,12 +326,9 @@ int at_lvl, op_arm, wplus; * Roll several attacks */ -roll_em(att_er, def_er, weap, hurl, cur_weapon, back_stab) -struct thing *att_er, *def_er; -struct object *weap; -bool hurl; -struct object *cur_weapon; -bool back_stab; +bool +roll_em(struct thing *att_er, struct thing *def_er, struct object *weap, + bool hurl, struct object *cur_weapon, bool back_stab) { register struct stats *att, *def; register char *cp = NULL; @@ -700,9 +700,7 @@ bool back_stab; */ char * -prname(who, upper) -register char *who; -bool upper; +prname(char *who, bool upper) { static char tbuf[LINELEN]; @@ -727,11 +725,9 @@ bool upper; * Print a message to indicate a succesful hit */ -hit(weapon, see_att, see_def, er, ee, back_stab, thrown, short_msg) -register struct object *weapon; -bool see_att, see_def; -register char *er, *ee; -bool back_stab, thrown, short_msg; +void +hit(struct object *weapon, bool see_att, bool see_def, char *er, char *ee, + bool back_stab, bool thrown, bool short_msg) { register char *s = ""; char att_name[LINELEN], /* Name of attacker */ @@ -791,11 +787,9 @@ bool back_stab, thrown, short_msg; * Print a message to indicate a poor swing */ -miss(weapon, see_att, see_def, er, ee, thrown, short_msg) -register struct object *weapon; -bool see_att, see_def; -register char *er, *ee; -bool thrown, short_msg; +void +miss(struct object *weapon, bool see_att, bool see_def, char *er, char *ee, + bool thrown, bool short_msg) { register char *s = ""; char @@ -836,8 +830,8 @@ bool thrown, short_msg; * compute to-hit bonus for dexterity */ -dext_plus(dexterity) -register int dexterity; +int +dext_plus(int dexterity) { return (dexterity > 10 ? (dexterity-13)/3 : (dexterity-10)/3); } @@ -848,8 +842,8 @@ register int dexterity; * compute armor class bonus for dexterity */ -dext_prot(dexterity) -register int dexterity; +int +dext_prot(int dexterity) { return ((dexterity-10)/2); } @@ -858,8 +852,8 @@ register int dexterity; * compute bonus/penalties for strength on the "to hit" roll */ -str_plus(str) -register short str; +int +str_plus(short str) { return((str-10)/3); } @@ -869,8 +863,8 @@ register short str; * compute additional damage done for exceptionally high or low strength */ -add_dam(str) -register short str; +int +add_dam(short str) { return((str-9)/2); } @@ -879,7 +873,8 @@ register short str; * hung_dam: * Calculate damage depending on players hungry state */ -hung_dam() +int +hung_dam(void) { reg int howmuch; @@ -897,12 +892,11 @@ hung_dam() /* * thunk: * A missile hits a monster + * tp: defender */ -thunk(weap, tp, mname) -register struct object *weap; -register struct thing *tp; /* Defender */ -register char *mname; +void +thunk(struct object *weap, struct thing *tp, char *mname) { char *def_name; /* Name of defender */ @@ -924,10 +918,8 @@ register char *mname; * A missile from a monster hits the player */ -m_thunk(weap, tp, mname) -register struct object *weap; -register struct thing *tp; -register char *mname; +void +m_thunk(struct object *weap, struct thing *tp, char *mname) { char *att_name; /* Name of attacker */ @@ -947,12 +939,11 @@ register char *mname; /* * bounce: * A missile misses a monster + * tp: defender */ -bounce(weap, tp, mname) -register struct object *weap; -register struct thing *tp; /* Defender */ -register char *mname; +void +bounce(struct object *weap, struct thing *tp, char *mname) { char *def_name; /* Name of defender */ @@ -974,10 +965,8 @@ register char *mname; * A missle from a monster misses the player */ -m_bounce(weap, tp, mname) -register struct object *weap; -register struct thing *tp; -register char *mname; +void +m_bounce(struct object *weap, struct thing *tp, char *mname) { char *att_name; /* Name of attacker */ @@ -1001,8 +990,8 @@ register char *mname; * Returns true if an object radiates magic */ -is_magic(obj) -register struct object *obj; +bool +is_magic(struct object *obj) { switch (obj->o_type) { @@ -1028,9 +1017,8 @@ register struct object *obj; int chance = 0;/* cumulative chance for goodies to loose it */ -killed(item, pr, points, treasure) -register struct linked_list *item; -bool pr, points, treasure; +void +killed(struct linked_list *item, bool pr, bool points, bool treasure) { register struct thing *tp, *mp; register struct linked_list *pitem, *nexti, *mitem; @@ -1137,9 +1125,7 @@ bool pr, points, treasure; */ struct linked_list * -wield_weap(thrown, mp) -struct object *thrown; -struct thing *mp; +wield_weap(struct object *thrown, struct thing *mp) { int look_for, /* The projectile weapon we are looking for */ new_rate, /* The rating of a prospective weapon */ @@ -1220,8 +1206,9 @@ struct thing *mp; return(candidate); } -explode(tp) -register struct thing *tp; + +void +explode(struct thing *tp) { register int x,y, damage; @@ -1275,11 +1262,8 @@ register struct thing *tp; * Called when one monster attacks another monster. */ -skirmish(attacker, mp, weap, thrown) -register struct thing *attacker; -register coord *mp; -struct object *weap; -bool thrown; +bool +skirmish(struct thing *attacker, coord *mp, struct object *weap, bool thrown) { register struct thing *defender; register struct linked_list *item; diff --git a/arogue7/init.c b/arogue7/init.c index 71269ab..a19eafd 100644 --- a/arogue7/init.c +++ b/arogue7/init.c @@ -117,10 +117,8 @@ static bool used[MAX3(NCOLORS, NSTONES, NWOOD)]; * make sure all the percentages specified in the tables add up to the * right amounts */ -badcheck(name, magic, bound) -char *name; -register struct magic_item *magic; -register int bound; +void +badcheck(char *name, struct magic_item *magic, int bound) { register struct magic_item *end; @@ -140,7 +138,8 @@ register int bound; * Initialize the potion color scheme for this time */ -init_colors() +void +init_colors(void) { register int i, j; @@ -166,7 +165,8 @@ init_colors() * do any initialization for food */ -init_foods() +void +init_foods(void) { register int i; @@ -182,7 +182,8 @@ init_foods() * Initialize the construction materials for wands and staffs */ -init_materials() +void +init_materials(void) { register int i, j; register char *str; @@ -232,7 +233,8 @@ init_materials() * do any initialization for miscellaneous magic */ -init_misc() +void +init_misc(void) { register int i; @@ -250,7 +252,8 @@ init_misc() * Generate the names of the various scrolls */ -init_names() +void +init_names(void) { register int nsyl; register char *cp, *sp; @@ -287,7 +290,8 @@ init_names() * roll up the rogue */ -init_player() +void +init_player(void) { int stat_total, round, minimum, maximum, ch, i, j; short do_escape, *our_stats[NUMABILITIES-1]; @@ -587,7 +591,8 @@ init_player() * Initialize the ring stone setting scheme for this time */ -init_stones() +void +init_stones(void) { register int i, j; @@ -613,7 +618,8 @@ init_stones() * init_things * Initialize the probabilities for types of things */ -init_things() +void +init_things(void) { register struct magic_item *mp; diff --git a/arogue7/io.c b/arogue7/io.c index 0230498..900862a 100644 --- a/arogue7/io.c +++ b/arogue7/io.c @@ -30,7 +30,10 @@ static char msgbuf[BUFSIZ]; static int newpos = 0; +void doadd(char *fmt, va_list ap); + /*VARARGS1*/ +void msg(char *fmt, ...) { va_list ap; @@ -58,6 +61,7 @@ msg(char *fmt, ...) /* * add things to the current message */ +void addmsg(char *fmt, ...) { va_list ap; @@ -71,7 +75,8 @@ addmsg(char *fmt, ...) * Display a new msg (giving him a chance to see the previous one if it * is up there with the --More--) */ -endmsg() +void +endmsg(void) { /* Needed to track where we are for 5.0 (PC) curses */ register int x, y; @@ -111,6 +116,7 @@ endmsg() draw(msgw); } +void doadd(char *fmt, va_list ap) { @@ -127,9 +133,8 @@ doadd(char *fmt, va_list ap) * flgptr will be NULL if we don't know what the monster is yet! */ -step_ok(y, x, can_on_monst, flgptr) -register int y, x, can_on_monst; -register struct thing *flgptr; +bool +step_ok(int y, int x, int can_on_monst, struct thing *flgptr) { /* can_on_monst = MONSTOK if all we care about are physical obstacles */ register struct linked_list *item; @@ -188,7 +193,8 @@ register struct thing *flgptr; * returns true if it is ok for type to shoot over ch */ -shoot_ok(ch) +bool +shoot_ok(char ch) { switch (ch) { @@ -209,7 +215,8 @@ shoot_ok(ch) * getchar. */ -readchar() +int +readchar(void) { int ch; @@ -227,10 +234,11 @@ readchar() /* * status: * Display the important stats line. Keep the cursor where it was. + * display: if TRUE, display unconditionally */ -status(display) -bool display; /* is TRUE, display unconditionally */ +void +status(bool display) { register struct stats *stat_ptr, *max_ptr; register int oy, ox, temp; @@ -358,8 +366,8 @@ line_two: * wait_for * Sit around until the guy types the right key */ -wait_for(ch) -register char ch; +void +wait_for(char ch) { register char c; @@ -383,10 +391,9 @@ register char ch; * typed and then redraw the starting screen. */ -over_win(oldwin, newin, maxy, maxx, cursory, cursorx, redraw) -WINDOW *oldwin, *newin; -int maxy, maxx, cursory, cursorx; -char redraw; +void +over_win(WINDOW *oldwin, WINDOW *newin, int maxy, int maxx, int cursory, + int cursorx, char redraw) { static char blanks[LINELEN+1]; register int line, i; @@ -436,9 +443,8 @@ char redraw; * function used to display a window and wait before returning */ -show_win(scr, message) -register WINDOW *scr; -char *message; +void +show_win(WINDOW *scr, char *message) { mvwaddstr(scr, 0, 0, message); touchwin(scr); @@ -453,9 +459,8 @@ char *message; * dbotline: * Displays message on bottom line and waits for a space to return */ -dbotline(scr,message) -WINDOW *scr; -char *message; +void +dbotline(WINDOW *scr, char *message) { mvwaddstr(scr,lines-1,0,message); draw(scr); @@ -467,8 +472,8 @@ char *message; * restscr: * Restores the screen to the terminal */ -restscr(scr) -WINDOW *scr; +void +restscr(WINDOW *scr) { clearok(scr,TRUE); touchwin(scr); @@ -481,10 +486,7 @@ WINDOW *scr; */ unsigned long -netread(error, size, stream) -int *error; -int size; -FILE *stream; +netread(int *error, int size, FILE *stream) { unsigned long result = 0L, /* What we read in */ partial; /* Partial value */ @@ -519,12 +521,13 @@ FILE *stream; /* * netwrite: * Write out a byte, short, or long machine independently. + * value: What to write + * size: How much to write out + * stream: Where to write it */ -netwrite(value, size, stream) -unsigned long value; /* What to write */ -int size; /* How much to write out */ -FILE *stream; /* Where to write it */ +int +netwrite(unsigned long value, int size, FILE *stream) { int i; /* Goes through value one byte at a time */ char outc; /* The next character to be written */ diff --git a/arogue7/list.c b/arogue7/list.c index 80789c7..7e478d9 100644 --- a/arogue7/list.c +++ b/arogue7/list.c @@ -21,13 +21,16 @@ #include #include "rogue.h" +void r_discard(struct linked_list *item); +void t_discard(struct linked_list *item); + /* * detach: * Takes an item out of whatever linked list it might be in */ -_detach(list, item) -register struct linked_list **list, *item; +void +_detach(struct linked_list **list, struct linked_list *item) { if (*list == item) *list = next(item); @@ -42,8 +45,8 @@ register struct linked_list **list, *item; * add an item to the head of a list */ -_attach(list, item) -register struct linked_list **list, *item; +void +_attach(struct linked_list **list, struct linked_list *item) { if (*list != NULL) { @@ -65,8 +68,8 @@ register struct linked_list **list, *item; * Throw the whole object list away */ -_o_free_list(ptr) -register struct linked_list **ptr; +void +_o_free_list(struct linked_list **ptr) { register struct linked_list *item; @@ -83,8 +86,8 @@ register struct linked_list **ptr; * free up an item and its object(and maybe contents) */ -o_discard(item) -register struct linked_list *item; +void +o_discard(struct linked_list *item) { register struct object *obj; @@ -101,8 +104,8 @@ register struct linked_list *item; * Throw the whole list of room exits away */ -_r_free_list(ptr) -register struct linked_list **ptr; +void +_r_free_list(struct linked_list **ptr) { register struct linked_list *item; @@ -119,8 +122,8 @@ register struct linked_list **ptr; * free up an item and its room */ -r_discard(item) -register struct linked_list *item; +void +r_discard(struct linked_list *item) { total -= 2; FREE(DOORPTR(item)); @@ -132,8 +135,8 @@ register struct linked_list *item; * Throw the whole thing list away */ -_t_free_list(ptr) -register struct linked_list **ptr; +void +_t_free_list(struct linked_list **ptr) { register struct linked_list *item; @@ -150,8 +153,8 @@ register struct linked_list **ptr; * free up an item and its thing */ -t_discard(item) -register struct linked_list *item; +void +t_discard(struct linked_list *item) { register struct thing *tp; @@ -167,8 +170,8 @@ register struct linked_list *item; * get rid of an item structure -- don't worry about contents */ -destroy_item(item) -register struct linked_list *item; +void +destroy_item(struct linked_list *item) { total--; FREE(item); @@ -180,8 +183,7 @@ register struct linked_list *item; */ struct linked_list * -new_item(size) -int size; +new_item(int size) { register struct linked_list *item; @@ -199,7 +201,7 @@ int size; */ struct linked_list * -creat_item() +creat_item(void) { register struct linked_list *item; @@ -210,8 +212,7 @@ creat_item() } char * -new(size) -int size; +new(int size) { register char *space = ALLOC(size); static char errbuf[LINELEN]; diff --git a/arogue7/main.c b/arogue7/main.c index 744de5e..55fbadb 100644 --- a/arogue7/main.c +++ b/arogue7/main.c @@ -32,10 +32,19 @@ extern char oldtext[WTXTNUM][WTXTLEN]; #endif void open_records(void); +bool too_much(void); +bool author(void); +void chmsg(char *fmt, int arg); +#ifdef MAXPROCESSES +int loadav(void); +#endif +#ifdef MAXUSERS +int ucount(void); +#endif +bool holiday(void); -main(argc, argv, envp) -char **argv; -char **envp; +int +main(int argc, char *argv[], char *envp[]) { register char *env; int lowtime; @@ -419,8 +428,7 @@ char **envp; */ void -endit(sig) -int sig; +endit(int sig) { fatal("Ok, if you want to exit that badly, I'll have to allow it\n"); } @@ -430,8 +438,8 @@ int sig; * Exit the program, printing a message. */ -fatal(s) -char *s; +void +fatal(char *s) { clear(); move(lines-2, 0); @@ -449,8 +457,8 @@ char *s; * rnd: * Pick a very random number. */ -rnd(range) -register int range; +int +rnd(int range) { return(range <= 0 ? 0 : md_rand() % range); } @@ -460,8 +468,8 @@ register int range; * roll a number of dice */ -roll(number, sides) -register int number, sides; +int +roll(int number, int sides) { register int dtotal = 0; @@ -474,8 +482,7 @@ register int number, sides; * handle stop and start signals */ void -tstp(sig) -int sig; +tstp(int sig) { mvcur(0, cols - 1, lines - 1, 0); endwin(); @@ -493,7 +500,8 @@ int sig; } # endif -setup() +void +setup(void) { #ifdef CHECKTIME int checkout(); @@ -563,7 +571,8 @@ open_records(void) * refreshing things and looking at the proper times. */ -playit() +void +playit(void) { register char *opts; @@ -585,7 +594,8 @@ playit() /* * see if the system is being used too much for this game */ -too_much() +bool +too_much(void) { #if MAXPROCESSES if (loadav() > MAXPROCESSES) @@ -602,7 +612,8 @@ too_much() * author: * See if a user is an author of the program */ -author() +bool +author(void) { switch (md_getuid()) { #if AUTHOR @@ -653,9 +664,8 @@ checkout() * checkout()'s version of msg. If we are in the middle of a shell, do a * printf instead of a msg to avoid the refresh. */ -chmsg(fmt, arg) -char *fmt; -int arg; +void +chmsg(char *fmt, int arg) { if (in_shell) { printf(fmt, arg); @@ -671,7 +681,8 @@ int arg; #include -loadav() +int +loadav(void) { char *sarcmd = "sar -v | cut -c17-20 | tail -2"; char *gettycmd = "grep getty /etc/inittab | wc -l"; @@ -724,7 +735,9 @@ loadav() #include #include struct utmp buf; -ucount() + +int +ucount(void) { reg struct utmp *up; reg FILE *utmp; @@ -751,7 +764,8 @@ ucount() * holiday: * Returns TRUE when it is a good time to play rogue */ -holiday() +bool +holiday(void) { #ifdef CHECKTIME long now; diff --git a/arogue7/maze.c b/arogue7/maze.c index 8dc3c64..bc6bbdb 100644 --- a/arogue7/maze.c +++ b/arogue7/maze.c @@ -30,15 +30,20 @@ static char *frontier, *bits; static int maze_lines, maze_cols; -char *moffset(), - *foffset(); + +void draw_maze(void); +int findcells(int y, int x); +char *foffset(int y, int x); +char *moffset(int y, int x); +void rmwall(int newy, int newx, int oldy, int oldx); /* * crankout: * Does actual drawing of maze to window */ -crankout() +void +crankout(void) { reg int x, y; @@ -71,7 +76,8 @@ crankout() * domaze: * Draw the maze on this level. */ -do_maze() +void +do_maze(void) { reg int least; reg struct room *rp; @@ -95,7 +101,7 @@ do_maze() /* * add some gold to make it worth looking for */ - item = spec_item(GOLD, NULL, NULL, NULL); + item = spec_item(GOLD, 0, 0, 0); obj = OBJPTR(item); obj->o_count *= (rnd(5) + 5); /* add in one large hunk */ attach(lvl_obj, item); @@ -108,7 +114,7 @@ do_maze() /* * add in some food to make sure he has enough */ - item = spec_item(FOOD, NULL, NULL, NULL); + item = spec_item(FOOD, 0, 0, 0); obj = OBJPTR(item); attach(lvl_obj, item); do { @@ -133,7 +139,8 @@ do_maze() * draw_maze: * Generate and draw the maze on the screen */ -draw_maze() +void +draw_maze(void) { reg int i, j, more; reg char *ptr; @@ -169,8 +176,8 @@ draw_maze() * findcells: * Figure out cells to open up */ -findcells(y,x) -reg int x, y; +int +findcells(int y, int x) { reg int rtpos, i; @@ -221,8 +228,7 @@ reg int x, y; * Calculate memory address for frontier */ char * -foffset(y, x) -int y, x; +foffset(int y, int x) { return (frontier + (y * maze_cols) + x); @@ -236,8 +242,7 @@ int y, x; */ bool -maze_view(y, x) -int y, x; +maze_view(int y, int x) { register int start, goal, delta, ycheck, xcheck, absy, absx, see_radius; register bool row; @@ -341,8 +346,7 @@ int y, x; * Calculate memory address for bits */ char * -moffset(y, x) -int y, x; +moffset(int y, int x) { return (bits + (y * (cols - 1)) + x); @@ -355,8 +359,8 @@ int y, x; * rmwall: * Removes appropriate walls from the maze */ -rmwall(newy, newx, oldy, oldx) -int newy, newx, oldy, oldx; +void +rmwall(int newy, int newx, int oldy, int oldx) { reg int xdif,ydif; diff --git a/arogue7/mdport.c b/arogue7/mdport.c index 71e3c2f..67cf17e 100644 --- a/arogue7/mdport.c +++ b/arogue7/mdport.c @@ -65,6 +65,7 @@ #endif #include +#include #include #include #include @@ -74,7 +75,7 @@ #define MOD_MOVE(c) (toupper(c) ) void -md_init() +md_init(void) { #ifdef __INTERIX char *term; @@ -107,7 +108,7 @@ md_putchar(int c) static int md_standout_mode = 0; int -md_raw_standout() +md_raw_standout(void) { #ifdef _WIN32 CONSOLE_SCREEN_BUFFER_INFO csbiInfo; @@ -130,7 +131,7 @@ md_raw_standout() } int -md_raw_standend() +md_raw_standend(void) { #ifdef _WIN32 CONSOLE_SCREEN_BUFFER_INFO csbiInfo; @@ -209,7 +210,7 @@ md_creat(char *file, int mode) int -md_normaluser() +md_normaluser(void) { #ifndef _WIN32 setuid(getuid()); @@ -218,7 +219,7 @@ md_normaluser() } int -md_getuid() +md_getuid(void) { #ifndef _WIN32 return( getuid() ); @@ -228,7 +229,7 @@ md_getuid() } char * -md_getusername() +md_getusername(void) { static char login[80]; char *l = NULL; @@ -263,7 +264,7 @@ md_getusername() } char * -md_gethomedir() +md_gethomedir(void) { static char homedir[PATH_MAX]; char *h = NULL; @@ -318,7 +319,7 @@ md_gethomedir() } char * -md_getshell() +md_getshell(void) { static char shell[PATH_MAX]; char *s = NULL; @@ -346,7 +347,7 @@ md_getshell() } int -md_shellescape() +md_shellescape(void) { #if (!defined(_WIN32) && !defined(__DJGPP__)) int ret_status; @@ -408,7 +409,7 @@ directory_exists(char *dirname) } char * -md_getroguedir() +md_getroguedir(void) { static char path[1024]; char *end,*home; @@ -472,8 +473,7 @@ md_crypt(char *key, char *salt) } char * -md_getpass(prompt) -char *prompt; +md_getpass(char *prompt) { #ifdef _WIN32 static char password_buffer[9]; @@ -568,7 +568,7 @@ md_htonl(unsigned long int x) } int -md_rand() +md_rand(void) { #ifdef _WIN32 return(rand()); @@ -578,8 +578,7 @@ md_rand() } int -md_srand(seed) -register int seed; +md_srand(int seed) { #ifdef _WIN32 srand(seed); @@ -589,7 +588,7 @@ register int seed; } long -md_memused() +md_memused(void) { #ifdef _WIN32 MEMORYSTATUS stat; @@ -603,7 +602,7 @@ md_memused() } char * -md_gethostname() +md_gethostname(void) { static char nodename[80]; char *n = NULL; @@ -625,7 +624,7 @@ md_gethostname() } int -md_erasechar() +md_erasechar(void) { #ifdef BSD return(_tty.sg_erase); /* process erase character */ @@ -637,7 +636,7 @@ md_erasechar() } int -md_killchar() +md_killchar(void) { #ifdef BSD return(_tty.sg_kill); @@ -654,8 +653,7 @@ md_killchar() */ char * -md_unctrl(ch) -char ch; +md_unctrl(char ch) { #if USG5_0 extern char *_unctrl[]; /* Defined in curses library */ @@ -667,7 +665,7 @@ char ch; } void -md_flushinp() +md_flushinp(void) { #ifdef BSD ioctl(0, TIOCFLUSH); diff --git a/arogue7/misc.c b/arogue7/misc.c index ebfc086..536124c 100644 --- a/arogue7/misc.c +++ b/arogue7/misc.c @@ -15,6 +15,7 @@ #include "curses.h" #include #include +#include #include "rogue.h" #ifdef PC7300 #include "menu.h" @@ -29,8 +30,8 @@ * Change the player's class to the specified one. */ -changeclass(newclass) -int newclass; +void +changeclass(int newclass) { if (newclass == player.t_ctype) { msg("You feel more skillful."); @@ -132,8 +133,8 @@ int newclass; /* * Use the relic that our monster is wielding. */ -m_use_relic(monster) -register struct thing *monster; +void +m_use_relic(struct thing *monster) { register struct object *obj; @@ -161,7 +162,7 @@ register struct thing *monster; } when EMORI_CLOAK: debug("stunning with Emori's cloak"); - do_zap(monster, obj, &monster->t_newpos, WS_PARALYZE, NULL); + do_zap(monster, obj, &monster->t_newpos, WS_PARALYZE, 0); obj->o_charges = 0; when ASMO_ROD: { @@ -228,10 +229,11 @@ register struct thing *monster; /* * add something to the contents of something else + * bag: the holder of the items + * item: the item to put inside */ -put_contents(bag, item) -register struct object *bag; /* the holder of the items */ -register struct linked_list *item; /* the item to put inside */ +void +put_contents(struct object *bag, struct linked_list *item) { register struct linked_list *titem; register struct object *tobj; @@ -256,10 +258,10 @@ register struct linked_list *item; /* the item to put inside */ /* * remove something from something else + * bag: the holder of the items */ -take_contents(bag, item) -register struct object *bag; /* the holder of the items */ -register struct linked_list *item; +void +take_contents(struct object *bag, struct linked_list *item) { if (bag->o_ac <= 0) { @@ -273,8 +275,8 @@ register struct linked_list *item; } -do_bag(item) -register struct linked_list *item; +void +do_bag(struct linked_list *item) { register struct linked_list *titem = NULL; @@ -395,8 +397,9 @@ register struct linked_list *item; } } -do_panic(who) -int who; /* Kind of monster to panic (all if who is NULL) */ +/* who: Kind of monster to panic (all if who is NULL) */ +void +do_panic(int who) { register int x,y; register struct linked_list *mon, *item; @@ -460,8 +463,7 @@ int who; /* Kind of monster to panic (all if who is NULL) */ * print miscellaneous magic bonuses */ char * -misc_name(obj) -register struct object *obj; +misc_name(struct object *obj) { static char buf[LINELEN]; char buf1[LINELEN]; @@ -523,7 +525,8 @@ register struct object *obj; return buf; } -use_emori() +void +use_emori(void) { char selection; /* Cloak function */ int state = 0; /* Menu state */ @@ -633,8 +636,8 @@ static char Displines[MAXQUILL+1][LINELEN+1]; /* The lines themselves */ /* * try to write a scroll with the quill of Nagrom */ -use_quill(obj) -struct object *obj; +void +use_quill(struct object *obj) { struct linked_list *item; register int i, @@ -766,7 +769,7 @@ struct object *obj; #endif /* Should we overlay? */ if (menu_overlay && MAXQUILL + 3 < lines / 2) { - over_win(cw, hw, MAXQUILL + 5, maxlen + 3, 0, curlen, NULL); + over_win(cw, hw, MAXQUILL + 5, maxlen + 3, 0, curlen, '\0'); } else draw(hw); } @@ -795,7 +798,7 @@ struct object *obj; /* Should we overlay? */ if (menu_overlay && MAXQUILL + 3 < lines / 2) { over_win(cw, hw, MAXQUILL + 5, maxlen + 3, - 0, curlen, NULL); + 0, curlen, '\0'); } else draw(hw); @@ -835,8 +838,8 @@ got_scroll: } } -use_mm(which) -int which; +void +use_mm(int which) { register struct object *obj = NULL; register struct linked_list *item = NULL; @@ -915,7 +918,7 @@ int which; when GERYON_HORN: /* Chase close monsters away */ msg("The horn blasts a shrill tone."); - do_panic(NULL); + do_panic(0); when HEIL_ANKH: case YENDOR_AMULET: case STONEBONES_AMULET: @@ -938,7 +941,7 @@ int which; msg("The jug is empty"); break; } - quaff (obj->o_ac, NULL, NULL, FALSE); + quaff (obj->o_ac, 0, 0, FALSE); obj->o_ac = JUG_EMPTY; fuse (alchemy, obj, ALCHEMYTIME, AFTER); if (!(obj->o_flags & ISKNOW)) @@ -1008,7 +1011,7 @@ int which; break; } obj->o_charges--; - do_panic(NULL); + do_panic(0); /* * dust of disappearance makes the player invisible for a while */ @@ -1124,8 +1127,7 @@ int which; */ int -usage_time(item) -struct linked_list *item; +usage_time(struct linked_list *item) { register struct object *obj; register int units = -1; diff --git a/arogue7/monsters.c b/arogue7/monsters.c index 94e3c0e..65a775d 100644 --- a/arogue7/monsters.c +++ b/arogue7/monsters.c @@ -21,13 +21,14 @@ #include "rogue.h" #include #include +#include /* * Check_residue takes care of any effect of the monster */ -check_residue(tp) -register struct thing *tp; +void +check_residue(struct thing *tp) { /* * Take care of special abilities @@ -71,13 +72,11 @@ register struct thing *tp; /* * Creat_mons creates the specified monster -- any if 0 + * person: Where to create next to */ bool -creat_mons(person, monster, report) -struct thing *person; /* Where to create next to */ -short monster; -bool report; +creat_mons(struct thing *person, short monster, bool report) { struct linked_list *nitem; register struct thing *tp; @@ -132,9 +131,7 @@ bool report; */ void -genmonsters(least, treas) -register int least; -bool treas; +genmonsters(int least, bool treas) { reg int i; reg struct room *rp = &rooms[0]; @@ -180,8 +177,7 @@ bool treas; */ short -id_monst(monster) -register char monster; +id_monst(char monster) { register short result; @@ -201,11 +197,8 @@ register char monster; * Pick a new monster and add it to the list */ -new_monster(item, type, cp, max_monster) -struct linked_list *item; -short type; -coord *cp; -bool max_monster; +void +new_monster(struct linked_list *item, short type, coord *cp, bool max_monster) { register struct thing *tp; register struct monster *mp; @@ -415,8 +408,7 @@ bool max_monster; */ short -randmonster(wander, no_unique) -register bool wander, no_unique; +randmonster(bool wander, bool no_unique) { register int d, cur_level, range, i; @@ -455,8 +447,8 @@ register bool wander, no_unique; * to purchase something. */ -sell(tp) -register struct thing *tp; +void +sell(struct thing *tp) { register struct linked_list *item, *seller; register struct linked_list *sellpack; @@ -551,8 +543,7 @@ register struct thing *tp; * what to do when the hero steps next to a monster */ struct linked_list * -wake_monster(y, x) -int y, x; +wake_monster(int y, int x) { register struct thing *tp; register struct linked_list *it; @@ -749,7 +740,8 @@ int y, x; * A wandering monster has awakened and is headed for the player */ -wanderer() +void +wanderer(void) { register int i; register struct room *hr = roomin(&hero); diff --git a/arogue7/move.c b/arogue7/move.c index 7a844f8..20d97d2 100644 --- a/arogue7/move.c +++ b/arogue7/move.c @@ -19,6 +19,7 @@ #include "curses.h" #include +#include #include "rogue.h" #ifdef PC7300 #include "menu.h" @@ -41,9 +42,8 @@ static char Moves[3][3] = { * The guy stepped on a trap.... Make him pay. */ -be_trapped(th, tc) -register struct thing *th; -register coord *tc; +char +be_trapped(struct thing *th, coord *tc) { register struct trap *tp; register char ch, *mname = ""; @@ -426,8 +426,7 @@ register coord *tc; */ bool -blue_light(blessed, cursed) -bool blessed, cursed; +blue_light(bool blessed, bool cursed) { register struct room *rp; bool ret_val=FALSE; /* Whether or not affect is known */ @@ -486,8 +485,8 @@ bool blessed, cursed; * If not, if player came from a legal place, then try to turn him. */ -corr_move(dy, dx) -int dy, dx; +void +corr_move(int dy, int dx) { int legal=0; /* Number of legal alternatives */ register int y, x, /* Indexes though possible positions */ @@ -564,7 +563,8 @@ int dy, dx; * dip_it: * Dip an object into a magic pool */ -dip_it() +void +dip_it(void) { reg struct linked_list *what; reg struct object *ob; @@ -758,8 +758,8 @@ dip_it() * consequences (fighting, picking up, etc.) */ -do_move(dy, dx) -int dy, dx; +void +do_move(int dy, int dx) { register struct room *rp, *orp; register char ch; @@ -1103,8 +1103,8 @@ int dy, dx; * Start the hero running */ -do_run(ch) -char ch; +void +do_run(char ch) { firstmove = TRUE; running = TRUE; @@ -1119,11 +1119,9 @@ char ch; * Returns TRUE if it could find it, FALSE otherwise. */ bool -getdelta(match, dy, dx) -char match; -int *dy, *dx; +getdelta(char match, int *dy, int *dx) { - register y, x; + int y, x; for (y = 0; y < 3; y++) for (x = 0; x < 3; x++) @@ -1140,8 +1138,8 @@ int *dy, *dx; * isatrap: * Returns TRUE if this character is some kind of trap */ -isatrap(ch) -reg char ch; +bool +isatrap(char ch) { switch(ch) { case DARTTRAP: @@ -1161,8 +1159,8 @@ reg char ch; * If it is dark, remove anything that might move. */ -light(cp) -coord *cp; +void +light(coord *cp) { register struct room *rp; register int j, k, x, y; @@ -1338,8 +1336,7 @@ coord *cp; */ bool -lit_room(rp) -register struct room *rp; +lit_room(struct room *rp) { register struct linked_list *fire_item; register struct thing *fire_creature; @@ -1376,8 +1373,7 @@ register struct room *rp; */ short -movement(tp) -register struct thing *tp; +movement(struct thing *tp) { register int result; register int carry; /* Percentage carried */ @@ -1441,8 +1437,7 @@ register struct thing *tp; */ coord * -rndmove(who) -struct thing *who; +rndmove(struct thing *who) { register int x, y; register int ex, ey, nopen = 0; @@ -1506,9 +1501,8 @@ static char Displines[TRAPTYPES+1][TRAPWIDTH+TRAPPREFIX+1]; * set a trap at (y, x) on screen. */ -set_trap(tp, y, x) -register struct thing *tp; -register int y, x; +void +set_trap(struct thing *tp, int y, int x) { register bool is_player = (tp == &player); register int selection = rnd(TRAPTYPES-WIZARDTRAPS) + '1'; @@ -1613,7 +1607,7 @@ register int y, x; * Put out the selection. The longest line is * the prompt line (39 characters long). */ - over_win(cw, hw, num_traps + 3, 41, 0, 39, NULL); + over_win(cw, hw, num_traps + 3, 41, 0, 39, '\0'); else draw(hw); state = 1; /* Now in prompt window */ @@ -1673,7 +1667,7 @@ register int y, x; * Put out the selection. The longest line is * the prompt line (43 characters long). */ - over_win(cw, hw, num_traps+3, 45, 0, 43, NULL); + over_win(cw, hw, num_traps+3, 45, 0, 43, '\0'); else draw(hw); } @@ -1743,8 +1737,8 @@ register int y, x; * returns what a certain thing will display as to the un-initiated */ -show(y, x) -register int y, x; +char +show(int y, int x) { register char ch = CCHAR( winat(y, x) ); register struct linked_list *it; @@ -1784,8 +1778,7 @@ register int y, x; */ struct trap * -trap_at(y, x) -register int y, x; +trap_at(int y, int x) { register struct trap *tp, *ep; @@ -1803,11 +1796,12 @@ register int y, x; * Calculate how many segments it will take to swing the given * weapon (note that the weapon may actually be a stick or * even something else). + * wielder: Who's wielding the weapon + * weap: The weapon */ -weap_move(wielder, weap) -register struct thing *wielder; /* Who's wielding the weapon */ -register struct object *weap; /* The weapon */ +int +weap_move(struct thing *wielder, struct object *weap) { register int weap_rate; int dexterity; diff --git a/arogue7/new_level.c b/arogue7/new_level.c index 6e28ea3..bf1f15e 100644 --- a/arogue7/new_level.c +++ b/arogue7/new_level.c @@ -16,14 +16,16 @@ #include "rogue.h" #define TERRASAVE 3 +void put_things(LEVTYPE ltype); + /* * new_level: * Dig and draw a new level - * + * ltype: designates type of level to create */ -new_level(ltype) -LEVTYPE ltype; /* designates type of level to create */ +void +new_level(LEVTYPE ltype) { register int rm, i, cnt; register char ch; @@ -434,14 +436,15 @@ LEVTYPE ltype; /* designates type of level to create */ status(TRUE); /* Do we sense any food on this level? */ - if (cur_relic[SURTUR_RING]) quaff(P_FFIND, NULL, NULL, FALSE); + if (cur_relic[SURTUR_RING]) quaff(P_FFIND, 0, 0, FALSE); } /* * Pick a room that is really there */ -rnd_room() +int +rnd_room(void) { register int rm; @@ -457,10 +460,11 @@ rnd_room() /* * put_things: * put potions and scrolls on this level + * ltype: designates type of level to create */ -put_things(ltype) -LEVTYPE ltype; /* designates type of level to create */ +void +put_things(LEVTYPE ltype) { register int i, rm, cnt; register struct object *cur; @@ -478,7 +482,7 @@ LEVTYPE ltype; /* designates type of level to create */ * There is a chance that there is a treasure room on this level */ if (ltype != MAZELEV && rnd(HARDER) < level - 10) { - register j; + int j; register struct room *rp; /* Count the number of free spaces */ diff --git a/arogue7/options.c b/arogue7/options.c index a3f6df6..488da76 100644 --- a/arogue7/options.c +++ b/arogue7/options.c @@ -40,14 +40,15 @@ struct optstruct { typedef struct optstruct OPTION; -int put_bool(), - get_bool(), - put_str(), - get_str(), - put_abil(), - get_abil(), - get_quest(), - put_quest(); +void put_bool(bool *b, WINDOW *win); +int get_bool(bool *bp, WINDOW *win); +void put_str(char *str, WINDOW *win); +int get_str(char *opt, WINDOW *win); +void put_abil(int *ability, WINDOW *win); +void get_abil(int *abil, WINDOW *win); +void put_quest(int *quest, WINDOW *win); +void get_quest(int *quest, WINDOW *win); +int get_ro(WINDOW *win, int oy, int ox); int get_str_prot(char *opt, WINDOW *win); int get_score(char *opt, WINDOW *win); @@ -83,9 +84,8 @@ OPTION optlist[] = { /* * The ability field is read-only */ -get_abil(abil, win) -int *abil; -WINDOW *win; +void +get_abil(int *abil, WINDOW *win) { register int oy, ox; @@ -97,9 +97,8 @@ WINDOW *win; /* * The quest field is read-only */ -get_quest(quest, win) -int *quest; -WINDOW *win; +void +get_quest(int *quest, WINDOW *win) { register int oy, ox; @@ -113,9 +112,8 @@ WINDOW *win; * "Get" a read-only value. */ -get_ro(win, oy, ox) -WINDOW *win; -register int oy, ox; +int +get_ro(WINDOW *win, int oy, int ox) { register int ny, nx; register bool op_bad; @@ -152,9 +150,8 @@ register int oy, ox; * allow changing a boolean option and print it out */ -get_bool(bp, win) -bool *bp; -WINDOW *win; +int +get_bool(bool *bp, WINDOW *win) { register int oy, ox; register bool op_bad; @@ -202,9 +199,8 @@ WINDOW *win; /* * set a string option */ -get_str(opt, win) -register char *opt; -WINDOW *win; +int +get_str(char *opt, WINDOW *win) { register char *sp; register int c, oy, ox; @@ -278,7 +274,8 @@ WINDOW *win; /* * print and then set options from the terminal */ -option() +void +option(void) { register OPTION *op; register int retval; @@ -334,8 +331,8 @@ option() * or the end of the entire option string. */ -parse_opts(str) -register char *str; +void +parse_opts(char *str) { register char *sp; register OPTION *op; @@ -428,9 +425,8 @@ register char *str; /* * print the character type */ -put_abil(ability, win) -int *ability; -WINDOW *win; +void +put_abil(int *ability, WINDOW *win) { waddstr(win, char_class[*ability].name); } @@ -440,9 +436,8 @@ WINDOW *win; * print out the quest */ -put_quest(quest, win) -int *quest; -WINDOW *win; +void +put_quest(int *quest, WINDOW *win) { waddstr(win, rel_magic[*quest].mi_name); } @@ -451,9 +446,8 @@ WINDOW *win; /* * put out a boolean */ -put_bool(b, win) -bool *b; -WINDOW *win; +void +put_bool(bool *b, WINDOW *win) { waddstr(win, *b ? "True" : "False"); } @@ -464,9 +458,8 @@ WINDOW *win; /* * put out a string */ -put_str(str, win) -char *str; -WINDOW *win; +void +put_str(char *str, WINDOW *win) { waddstr(win, str); } diff --git a/arogue7/outside.c b/arogue7/outside.c index 1a74852..0e00b0a 100644 --- a/arogue7/outside.c +++ b/arogue7/outside.c @@ -15,7 +15,8 @@ #include "curses.h" #include "rogue.h" -extern char rnd_terrain(), get_terrain(); +char rnd_terrain(void); +char get_terrain(char one, char two, char three, char four); /* * init_terrain: @@ -23,7 +24,7 @@ extern char rnd_terrain(), get_terrain(); */ void -init_terrain() +init_terrain(void) { register struct room *rp; @@ -42,11 +43,9 @@ init_terrain() void -do_terrain(basey, basex, deltay, deltax, fresh) -int basey, basex, deltay, deltax; -bool fresh; +do_terrain(int basey, int basex, int deltay, int deltax, bool fresh) { - register cury, curx; /* Current y and x positions */ + register int cury, curx; /* Current y and x positions */ /* Lay out the boundary */ for (cury=1; curyo_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYCLOAK)) { - item = spec_item(RELIC, EMORI_CLOAK, NULL, NULL); + item = spec_item(RELIC, EMORI_CLOAK, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYANKH)) { - item = spec_item(RELIC, HEIL_ANKH, NULL, NULL); + item = spec_item(RELIC, HEIL_ANKH, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYSTAFF)) { - item = spec_item(RELIC, MING_STAFF, NULL, NULL); + item = spec_item(RELIC, MING_STAFF, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYWAND)) { - item = spec_item(RELIC, ORCUS_WAND, NULL, NULL); + item = spec_item(RELIC, ORCUS_WAND, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYROD)) { - item = spec_item(RELIC, ASMO_ROD, NULL, NULL); + item = spec_item(RELIC, ASMO_ROD, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYYAMULET)) { - item = spec_item(RELIC, YENDOR_AMULET, NULL, NULL); + item = spec_item(RELIC, YENDOR_AMULET, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYBAMULET)) { - item = spec_item(RELIC, STONEBONES_AMULET, NULL, NULL); + item = spec_item(RELIC, STONEBONES_AMULET, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYMANDOLIN)) { - item = spec_item(RELIC, BRIAN_MANDOLIN, NULL, NULL); + item = spec_item(RELIC, BRIAN_MANDOLIN, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYEYE)) { - item = spec_item(RELIC, EYE_VECNA, NULL, NULL); + item = spec_item(RELIC, EYE_VECNA, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYAXE)) { - item = spec_item(RELIC, AXE_AKLAD, NULL, NULL); + item = spec_item(RELIC, AXE_AKLAD, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); @@ -1148,7 +1143,7 @@ int chance; if (on(*mp, CARRYQUILL)) { register int i, howmany; - item = spec_item(RELIC, QUILL_NAGROM, NULL, NULL); + item = spec_item(RELIC, QUILL_NAGROM, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; obj->o_charges = rnd(QUILLCHARGES); @@ -1165,25 +1160,25 @@ int chance; } } if (on(*mp, CARRYMSTAR)) { - item = spec_item(RELIC, HRUGGEK_MSTAR, NULL, NULL); + item = spec_item(RELIC, HRUGGEK_MSTAR, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYFLAIL)) { - item = spec_item(RELIC, YEENOGHU_FLAIL, NULL, NULL); + item = spec_item(RELIC, YEENOGHU_FLAIL, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYHORN)) { - item = spec_item(RELIC, GERYON_HORN, NULL, NULL); + item = spec_item(RELIC, GERYON_HORN, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYSURTURRING)) { - item = spec_item(RELIC, SURTUR_RING, NULL, NULL); + item = spec_item(RELIC, SURTUR_RING, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); @@ -1193,7 +1188,7 @@ int chance; * If it carries gold, give it some */ if (on(*mp, CARRYGOLD) && rnd(100) < chance) { - item = spec_item(GOLD, NULL, NULL, NULL); + item = spec_item(GOLD, 0, 0, 0); obj = OBJPTR(item); obj->o_count = GOLDCALC + GOLDCALC; obj->o_pos = mp->t_pos; @@ -1204,7 +1199,7 @@ int chance; * If it carries food, give it some */ if (on(*mp, CARRYFOOD) && rnd(100) < chance) { - item = spec_item(FOOD, NULL, NULL, NULL); + item = spec_item(FOOD, 0, 0, 0); obj = OBJPTR(item); obj->o_weight = things[TYP_FOOD].mi_wght; obj->o_pos = mp->t_pos; @@ -1328,8 +1323,8 @@ int chance; * he wants (* means everything). */ -grab(y, x) -register y, x; +int +grab(int y, int x) { register struct linked_list *next_item, *item; register struct object *obj; @@ -1398,7 +1393,7 @@ register y, x; * to he right. */ if (menu_overlay && num_there < lines / 2 + 2) { - over_win(cw, hw, num_there + 2, maxlen + 3, num_there, curlen, NULL); + over_win(cw, hw, num_there + 2, maxlen + 3, num_there, curlen, '\0'); pagecnt = -1; /* Indicate we used over_win */ } else draw(hw); /* write screen */ @@ -1446,7 +1441,7 @@ register y, x; */ if (menu_overlay && num_there < lines / 2 + 2) { over_win(cw, hw, num_there + 2, maxlen + 3, - num_there, 49, NULL); + num_there, 49, '\0'); cnt = -1; /* Indicate we used over_win */ } else draw(hw); /* write screen */ @@ -1485,8 +1480,8 @@ register y, x; * Create a pack for sellers (a la quartermaster) */ -make_sell_pack(tp) -struct thing *tp; +void +make_sell_pack(struct thing *tp) { reg struct linked_list *item; reg struct object *obj; diff --git a/arogue7/passages.c b/arogue7/passages.c index c432ece..ad98001 100644 --- a/arogue7/passages.c +++ b/arogue7/passages.c @@ -18,15 +18,20 @@ * @(#)passages.c 3.4 (Berkeley) 6/15/81 */ +#include #include "curses.h" #include "rogue.h" +void conn(int r1, int r2); +void door(struct room *rm, coord *cp); + /* * do_passages: * Draw all the passages on a level. */ -do_passages() +void +do_passages(void) { register struct rdes *r1, *r2 = NULL; register int i, j; @@ -134,8 +139,8 @@ do_passages() * Draw a corridor from a room in a certain direction. */ -conn(r1, r2) -int r1, r2; +void +conn(int r1, int r2) { register struct room *rpf, *rpt = NULL; register char rmt; @@ -348,9 +353,8 @@ int r1, r2; * also enters the door in the exits array of the room. */ -door(rm, cp) -register struct room *rm; -register coord *cp; +void +door(struct room *rm, coord *cp) { struct linked_list *newroom; coord *exit; diff --git a/arogue7/player.c b/arogue7/player.c index 457c389..c47c1c0 100644 --- a/arogue7/player.c +++ b/arogue7/player.c @@ -18,19 +18,23 @@ */ #include +#include #include "curses.h" #include "rogue.h" #ifdef PC7300 #include "menu.h" #endif +bool pick_spell(struct spells spells[], int ability, int num_spells, int power, + char *prompt, char *type); /* * affect: * cleric affecting undead */ -affect() +void +affect(void) { register struct linked_list *item; register struct thing *tp; @@ -147,7 +151,8 @@ annoy: /* * the magic user is going to try and cast a spell */ -cast() +void +cast(void) { int spell_ability, which_spell, @@ -202,7 +207,7 @@ cast() if (magic_spells[which_spell].s_type == TYP_POTION) quaff( magic_spells[which_spell].s_which, - NULL, + 0, magic_spells[which_spell].s_flag, FALSE); else if (magic_spells[which_spell].s_type == TYP_SCROLL) @@ -222,7 +227,8 @@ cast() /* * the druid asks his deity for a spell */ -chant() +void +chant(void) { register int num_chants, chant_ability, @@ -290,7 +296,7 @@ chant() if (druid_spells[which_chant].s_type == TYP_POTION) quaff( druid_spells[which_chant].s_which, - NULL, + 0, druid_spells[which_chant].s_flag, FALSE); else if (druid_spells[which_chant].s_type == TYP_SCROLL) @@ -309,7 +315,8 @@ chant() /* Constitution bonus */ -const_bonus() /* Hit point adjustment for changing levels */ +int +const_bonus(void) /* Hit point adjustment for changing levels */ { register int bonus; if (pstats.s_const > 6 && pstats.s_const <= 14) @@ -343,7 +350,8 @@ const_bonus() /* Hit point adjustment for changing levels */ * Sense gold */ -gsense() +void +gsense(void) { /* Only thieves can do this */ if (player.t_ctype != C_THIEF && player.t_ctype != C_ASSASIN) { @@ -351,13 +359,14 @@ gsense() return; } - read_scroll(S_GFIND, NULL, FALSE); + read_scroll(S_GFIND, 0, FALSE); } /* * the cleric asks his deity for a spell */ -pray() +void +pray(void) { register int num_prayers, prayer_ability, @@ -430,7 +439,7 @@ pray() if (cleric_spells[which_prayer].s_type == TYP_POTION) quaff( cleric_spells[which_prayer].s_which, - NULL, + 0, cleric_spells[which_prayer].s_flag, FALSE); else if (cleric_spells[which_prayer].s_type == TYP_SCROLL) @@ -454,7 +463,8 @@ pray() * Steal in direction given in delta */ -steal() +void +steal(void) { register struct linked_list *item; register struct thing *tp; @@ -586,14 +596,16 @@ static char Displines[MAXSPELLS+1][LINELEN+1]; /* The lines themselves */ /* * this routine lets the player pick the spell that they * want to cast regardless of character class + * spells: spell list + * ability: spell ability + * num_spells: number of spells that can be cast + * power: spell power + * prompt: prompt for spell list + * type: type of thing--> spell, prayer, chant */ -pick_spell(spells, ability, num_spells, power, prompt, type) -struct spells spells[]; /* spell list */ -int ability; /* spell ability */ -int num_spells; /* number of spells that can be cast */ -int power; /* spell power */ -char *prompt; /* prompt for spell list */ -char *type; /* type of thing--> spell, prayer, chant */ +bool +pick_spell(struct spells spells[], int ability, int num_spells, int power, + char *prompt, char *type) { bool nohw = FALSE; register int i; @@ -754,7 +766,7 @@ char *type; /* type of thing--> spell, prayer, chant */ #endif /* Should we overlay? */ if (menu_overlay && num_spells + 3 < lines / 2) { - over_win(cw, hw, num_spells + 5, maxlen + 3, 0, curlen, NULL); + over_win(cw, hw, num_spells + 5, maxlen + 3, 0, curlen, '\0'); } else draw(hw); } @@ -780,7 +792,7 @@ char *type; /* type of thing--> spell, prayer, chant */ /* Should we overlay? */ if (menu_overlay && num_spells + 3 < lines / 2) { over_win(cw, hw, num_spells + 5, maxlen + 3, - 0, curlen, NULL); + 0, curlen, '\0'); } else draw(hw); diff --git a/arogue7/potions.c b/arogue7/potions.c index 79982b0..a22fab5 100644 --- a/arogue7/potions.c +++ b/arogue7/potions.c @@ -46,8 +46,7 @@ void (*res_abil[NUMABILITIES])() = { */ void -add_constitution(change) -int change; +add_constitution(int change) { /* Do the potion */ if (change < 0) { @@ -71,8 +70,7 @@ int change; */ void -add_charisma(change) -int change; +add_charisma(int change) { /* Do the potion */ if (change < 0) msg("You feel less attractive now."); @@ -92,8 +90,7 @@ int change; */ void -add_dexterity(change) -int change; +add_dexterity(int change) { int ring_str; /* Value of ring strengths */ @@ -123,8 +120,8 @@ int change; * add a haste to the player */ -add_haste(blessed) -bool blessed; +void +add_haste(bool blessed) { int hasttime; @@ -161,8 +158,7 @@ bool blessed; * Increase player's intelligence */ void -add_intelligence(change) -int change; +add_intelligence(int change) { int ring_str; /* Value of ring strengths */ @@ -190,7 +186,8 @@ int change; /* * this routine makes the hero move slower */ -add_slow() +void +add_slow(void) { /* monks cannot be slowed or hasted */ if (player.t_ctype == C_MONK || ISWEARING(R_FREEDOM)) { @@ -219,8 +216,7 @@ add_slow() */ void -add_strength(change) -int change; +add_strength(int change) { if (change < 0) { @@ -238,8 +234,7 @@ int change; */ void -add_wisdom(change) -int change; +add_wisdom(int change) { int ring_str; /* Value of ring strengths */ @@ -264,11 +259,8 @@ int change; pstats.s_wisdom += ring_str; } -quaff(which, kind, flags, is_potion) -int which; -int kind; -int flags; -bool is_potion; +void +quaff(int which, int kind, int flags, bool is_potion) { register struct object *obj; register struct linked_list *item, *titem; @@ -869,8 +861,7 @@ bool is_potion; */ void -res_dexterity(howmuch) -int howmuch; +res_dexterity(int howmuch) { short save_max; int ring_str; @@ -903,8 +894,7 @@ int howmuch; */ void -res_intelligence(howmuch) -int howmuch; +res_intelligence(int howmuch) { short save_max; int ring_str; @@ -931,8 +921,7 @@ int howmuch; */ void -res_wisdom(howmuch) -int howmuch; +res_wisdom(int howmuch) { short save_max; int ring_str; @@ -959,8 +948,7 @@ int howmuch; */ void -res_constitution(howmuch) -int howmuch; +res_constitution(int howmuch) { if (howmuch > 0) pstats.s_const = min(pstats.s_const + howmuch, max_stats.s_const); @@ -972,8 +960,7 @@ int howmuch; */ void -res_charisma(howmuch) -int howmuch; +res_charisma(int howmuch) { if (howmuch > 0) pstats.s_charisma = diff --git a/arogue7/rings.c b/arogue7/rings.c index 5ef2c46..1c87346 100644 --- a/arogue7/rings.c +++ b/arogue7/rings.c @@ -12,6 +12,7 @@ */ #include +#include #include "curses.h" #include "rogue.h" @@ -23,8 +24,8 @@ /* * how much food does this ring use up? */ -ring_eat(hand) -register int hand; +int +ring_eat(int hand) { if (cur_ring[hand] == NULL) return 0; @@ -48,8 +49,8 @@ register int hand; return 0; } -ring_on(item) -register struct linked_list *item; +void +ring_on(struct linked_list *item) { register struct object *obj; register int save_max; @@ -111,8 +112,7 @@ register struct linked_list *item; * print ring bonuses */ char * -ring_num(obj) -register struct object *obj; +ring_num(struct object *obj) { static char buf[5]; @@ -146,7 +146,8 @@ register struct object *obj; /* * Return the effect of the specified ring */ -ring_value(type) +int +ring_value(int type) { int result = 0; diff --git a/arogue7/rip.c b/arogue7/rip.c index 320683b..b2659bd 100644 --- a/arogue7/rip.c +++ b/arogue7/rip.c @@ -91,15 +91,15 @@ static char *rip[] = { 0 }; -char *killname(); - - - +char *killname(short monst); +void showpack(char *howso); +int update(struct sc_ent top_ten[], unsigned long amount, short quest, + char *whoami, short flags, short level, short monst, short ctype, + char *system, char *login); void -byebye(sig) -int sig; +byebye(int sig) { if (!isendwin()) { clear(); @@ -118,8 +118,8 @@ int sig; * Do something really fun when he dies */ -death(monst) -register short monst; +void +death(short monst) { register char **dp = rip, *killer; register struct tm *lt; @@ -154,7 +154,8 @@ register short monst; /* * Restore window characteristics on a hard window terminal (PC7300). */ -endhardwin() +void +endhardwin(void) { register int i; struct utdata labelbuf; @@ -172,8 +173,7 @@ endhardwin() #endif char * -killname(monst) -register short monst; +killname(short monst) { static char mons_name[LINELEN]; int i; @@ -249,9 +249,8 @@ writelog(unsigned long amount, int flags, short monst) */ /* VARARGS2 */ -score(amount, flags, monst) -unsigned long amount; -short monst; +void +score(unsigned long amount, int flags, short monst) { static struct sc_ent top_ten[NUMSCORE]; register struct sc_ent *scp; @@ -672,11 +671,10 @@ short monst; * scorein: * Convert a character string that has been translated from a * score file by scoreout() back to a score file structure. + * num_bytes: Number of bytes of input that we want to convert */ -scorein(input, scores, num_bytes) -unsigned char *input; -struct sc_ent scores[]; -int num_bytes; /* Number of bytes of input that we want to convert */ +void +scorein(unsigned char *input, struct sc_ent scores[], int num_bytes) { register int i, j; unsigned long *lptr; @@ -731,9 +729,8 @@ int num_bytes; /* Number of bytes of input that we want to convert */ * this for compatibility sake since some machines write out fields in * different orders. */ -scoreout(scores, output) -struct sc_ent scores[]; -unsigned char *output; +void +scoreout(struct sc_ent scores[], unsigned char *output) { register int i, j; unsigned long *lptr; @@ -783,8 +780,8 @@ unsigned char *output; * showpack: * Display the contents of the hero's pack */ -showpack(howso) -char *howso; +void +showpack(char *howso) { reg char *iname; reg int cnt, packnum; @@ -813,7 +810,8 @@ char *howso; refresh(); } -total_winner() +void +total_winner(void) { register struct linked_list *item; register struct object *obj; @@ -876,11 +874,10 @@ total_winner() exit(0); } -update(top_ten, amount, quest, whoami, flags, level, monst, ctype, system, login) -struct sc_ent top_ten[]; -unsigned long amount; -short quest, flags, level, monst, ctype; -char *whoami, *system, *login; +int +update(struct sc_ent top_ten[], unsigned long amount, short quest, char *whoami, + short flags, short level, short monst, short ctype, char *system, + char *login) { register struct sc_ent *scp, *sc2; int retval=0; /* 1 if a change, 0 otherwise */ diff --git a/arogue7/rogue.h b/arogue7/rogue.h index 152e2aa..0544bea 100644 --- a/arogue7/rogue.h +++ b/arogue7/rogue.h @@ -1121,45 +1121,317 @@ struct delayed_action { int d_time; } ; -struct linked_list *find_mons(), *find_obj(), *get_item(), *new_item(), - *new_thing(), *wake_monster(), *get_hurl(), - *spec_item(), *creat_item(), *wield_weap(); -struct room *roomin(); -struct trap *trap_at(); +void _attach(struct linked_list **list, struct linked_list *item); +void _detach(struct linked_list **list, struct linked_list *item); +void _o_free_list(struct linked_list **ptr); +void _r_free_list(struct linked_list **ptr); +void _t_free_list(struct linked_list **ptr); +int ac_compute(bool ignoremetal); +void activity(void); +void add_charisma(int change); +void add_constitution(int change); +void add_dexterity(int change); +void add_haste(bool blessed); +void add_intelligence(int change); +bool add_pack(struct linked_list *item, bool silent, + struct linked_list **packret); +void add_slow(void); +void add_strength(int change); +void add_wisdom(int change); +void addmsg(char *fmt, ...); +void affect(void); +void aggravate(bool do_uniques, bool do_good); +void alchemy(struct object *obj); +void appear(void); +bool attack(struct thing *mp, struct object *weapon, bool thrown); +void auto_save(int sig); +char be_trapped(struct thing *th, coord *tc); +bool blue_light(bool blessed, bool cursed); +void bugkill(int sig); +void buy_it(void); +void byebye(int sig); +bool can_blink(struct thing *tp); +coord *can_shoot(coord *er, coord *ee); +bool cansee(int y, int x); +void carry_obj(struct thing *mp, int chance); +void cast(void); +void changeclass(int newclass); +void chant(void); +void chant_recovery(void); +void chase(struct thing *tp, coord *ee, struct room *rer, struct room *ree, + bool flee); +long check_level(void); +void check_residue(struct thing *tp); +void chg_str(int amt); +void cloak_charge(struct object *obj); +void command(void); +void confus_player(void); +int const_bonus(void); +void corr_move(int dy, int dx); +struct linked_list *creat_item(void); +bool creat_mons(struct thing *person, short monster, bool report); +void create_obj(bool prompt, int which_item, int which_type); +void cur_null(struct object *op); +void cure_disease(void); +void dbotline(WINDOW *scr, char *message); +void death(short monst); +void del_pack(struct linked_list *item); +void destroy_item(struct linked_list *item); +int dex_compute(void); +int dext_plus(int dexterity); +int dext_prot(int dexterity); +bool diag_ok(coord *sp, coord *ep, struct thing *flgptr); +void dip_it(void); +void do_chase(struct thing *th); +void do_daemons(int flag); +void do_fuses(int flag); +void do_maze(void); +void do_motion(struct object *obj, int ydelta, int xdelta, struct thing *tp); +void do_move(int dy, int dx); +void do_passages(void); +void do_post(bool startup); +void do_rooms(void); +void do_run(char ch); +void do_terrain(int basey, int basex, int deltay, int deltax, bool fresh); +void do_zap(struct thing *zapper, struct object *obj, coord *direction, + int which, int flags); +void doctor(struct thing *tp); +coord *doorway(struct room *rp, coord *door); +void draw_room(struct room *rp); +int dress_units(struct linked_list *item); +bool drop(struct linked_list *item); +bool dropcheck(struct object *op); +void dsrpt_monster(struct thing *tp, bool always, bool see_him); +void dsrpt_player(void); +void dust_appear(void); +void eat(void); +void eat_gold(struct object *obj); +int effect(struct thing *att, struct thing *def, struct object *weap, + bool thrown, bool see_att, bool see_def); +int encread(char *start, unsigned int size, int inf); +int encwrite(char *start, unsigned int size, int outf); +void endmsg(void); +void explode(struct thing *tp); +void extinguish(int (*func)()); +void fall(struct linked_list *item, bool pr); +coord *fallpos(coord *pos, bool be_clear, int range); +void fatal(char *s); +bool fight(coord *mp, struct object *weap, bool thrown); +struct linked_list *find_mons(int y, int x); +struct linked_list *find_obj(int y, int x); +struct delayed_action *find_slot(int (*func)()); +int findmindex(char *name); +void fix_stick(struct object *cur); +void fumble(void); +void fuse(int (*func)(), int arg, int time, int type); +void genmonsters(int least, bool treas); +coord get_coordinates(void); +bool get_dir(coord *direction); +struct linked_list *get_hurl(struct thing *tp); +struct linked_list *get_item(struct linked_list *list, char *purpose, int type, + bool askfirst, bool showcost); +int get_str(char *opt, WINDOW *win); +int get_worth(struct object *obj); +int getdeath(void); +bool getdelta(char match, int *dy, int *dx); +int grab(int y, int x); +void gsense(void); +bool hit_monster(int y, int x, struct object *obj, struct thing *tp); +int hitweight(void); +short id_monst(char monster); +void idenpack(void); +void init_colors(void); +void init_foods(void); +void init_materials(void); +void init_misc(void); +void init_names(void); +void init_player(void); +void init_stones(void); +void init_terrain(void); +void init_things(void); +void init_weapon(struct object *weap, char type); +char *inv_name(struct object *obj, bool drop); +bool inventory(struct linked_list *list, int type); +bool is_current(struct object *obj); +bool is_magic(struct object *obj); +bool isatrap(char ch); +int itemweight(struct object *wh); +void kill_daemon(int (*func)()); +void killed(struct linked_list *item, bool pr, bool points, bool treasure); +void lake_check(coord *place); +void land(void); +void lengthen(int (*func)(), int xtime); +void light(coord *cp); +bool lit_room(struct room *rp); +void look(bool wakeup, bool runend); +void lower_level(short who); +void m_use_relic(struct thing *monster); +void m_use_wand(struct thing *monster); +void make_sell_pack(struct thing *tp); +short makemonster(bool showall, char *label, char *action) ; +bool maze_view(int y, int x); +char *misc_name(struct object *obj); +void missile(int ydelta, int xdelta, struct linked_list *item, + struct thing *tp); +char *monster_name(struct thing *tp); +bool move_hero(int why); +short movement(struct thing *tp); +void msg(char *fmt, ...); +void nameitem(struct linked_list *item, bool mark); +bool need_dir(int type, int which); +unsigned long netread(int *error, int size, FILE *stream); +int netwrite(unsigned long value, int size, FILE *stream); +char *new(int size); +struct linked_list *new_item(int size); +void new_level(LEVTYPE ltype); +void new_monster(struct linked_list *item, short type, coord *cp, + bool max_monster); +struct linked_list *new_thing(int thing_type, bool allow_curse); +void nobolt(void); +void nocold(void); +void nofire(void); +void nohaste(void); +void noslow(void); +char *num(int n1, int n2); +void o_discard(struct linked_list *item); +void option(void); +void over_win(WINDOW *oldwin, WINDOW *newin, int maxy, int maxx, int cursory, + int cursorx, char redraw); +char pack_char(struct linked_list *list, struct object *obj); +void parse_opts(char *str); +bool passwd(void); +void picky_inven(void); +bool player_zap(int which, int flag); +void playit(void); +void pray(void); +void prayer_recovery(void); +bool price_it(void); +char *prname(char *who, bool upper); +void quaff(int which, int kind, int flags, bool is_potion); +void quill_charge(void); +void quit(int sig); +void raise_level(void); +short randmonster(bool wander, bool no_unique); +void read_scroll(int which, int flag, bool is_scroll); +int readchar(void); +void res_charisma(int howmuch); +void res_constitution(int howmuch); +void res_dexterity(int howmuch); +void res_intelligence(int howmuch); +void res_strength(int howmuch); +void res_wisdom(int howmuch); +bool restore(char *file, char *envp[]); +void restscr(WINDOW *scr); +int ring_eat(int hand); +char *ring_num(struct object *obj); +int ring_value(int type); +void ring_on(struct linked_list *item); +void ring_search(void); +void ring_teleport(void); +int rnd(int range); +void rnd_pos(struct room *rp, coord *cp); +int rnd_room(void); +coord *rndmove(struct thing *who); +int roll(int number, int sides); +void rollwand(void); +struct room *roomin(coord *cp); +int rs_restore_file(int inf); +int rs_save_file(FILE *savef); +int runners(int segments); +void runto(struct thing *runner, coord *spot); +bool save(int which, struct thing *who, int adj); +bool save_game(void); +void score(unsigned long amount, int flags, short monst); +void search(bool is_thief, bool door_chime); +char secretdoor(int y, int x); +void sell(struct thing *tp); +void sell_it(void); +void set_trap(struct thing *tp, int y, int x); +void setup(void); +void shoot_bolt(struct thing *shooter, coord start, coord dir, + bool get_points, short reason, char *name, int damage); +bool shoot_ok(char ch); +char show(int y, int x); +void sight(void); +bool skirmish(struct thing *attacker, coord *mp, struct object *weap, + bool thrown); +struct linked_list *spec_item(int type, int which, int hit, int damage); +void spell_recovery(void); +void start_daemon(int (*func)(), int arg, int type); +void status(bool display); +void steal(void); +bool step_ok(int y, int x, int can_on_monst, struct thing *flgptr); +void stomach(void); +int str_compute(void); +int str_plus(short str); +void strangle(void); +void strucpy(char *s1, char *s2, int len); +void suffocate(void); +void swander(void); +bool swing(short class, int at_lvl, int op_arm, int wplus); +void take_off(void); +int teleport(void); +void total_winner(void); +int totalenc(struct thing *tp); +char *tr_name(char ch); +struct trap *trap_at(int y, int x); +void trap_look(void); +void updpack(int getmax, struct thing *tp); +void unclrhead(void); +void unchoke(void); +void unconfuse(void); +void undance(void); +void unphase(void); +void unsee(void); +void unskill(void); +void unstink(void); +int usage_time(struct linked_list *item); +void use_mm(int which); +char *vowelstr(char *str); +void wait_for(char ch); +struct linked_list *wake_monster(int y, int x); +void wake_room(struct room *rp); +void wanderer(void); +void waste_time(void); +int weap_move(struct thing *wielder, struct object *weap); +char *weap_name(struct object *obj); +void wear(void); +void wghtchk(void); +void whatis(struct linked_list *what); +void wield(void); +struct linked_list *wield_weap(struct object *thrown, struct thing *mp); +void writelog(unsigned long amount, int flags, short monst); -/* char *malloc(), *getenv(), *tr_name(), *new(), *sprintf(), */ -char *getenv(), *tr_name(), *new(), - *vowelstr(), *inv_name(), *strcpy(), *strcat(); -char *num(), *ring_num(), *misc_num(), *blesscurse(), *p_kind(), - *typ_name(), *prname(), *monster_name(), *weap_name(), *misc_name(); -coord *rndmove(), *can_shoot(), *fallpos(), *doorway(), get_coordinates(); -short randmonster(), id_monst(), movement(); -void quit(int), auto_save(int), bugkill(int), endit(int), tstp(int), - byebye(int); -int nohaste(), spell_recovery(), - doctor(), runners(), swander(), unconfuse(), unsee(), fumble(), - unclrhead(), unphase(), noslow(), rollwand(), stomach(), sight(), - unstink(), suffocate(), cure_disease(), shoot_bolt(), changeclass(), - appear(), dust_appear(), unchoke(), alchemy(), trap_look(), strangle(), - ring_teleport(), ring_search(), grab(), dsrpt_player(), quill_charge(), - make_sell_pack(), unskill(), findmindex(), nobolt(), nofire(), nocold(), - usage_time(), eat_gold(), chant_recovery(), prayer_recovery(), - dsrpt_monster(); -bool blue_light(), can_blink(), creat_mons(), add_pack(), - straight_shot(), maze_view(), lit_room(), getdelta(), save_file(), - save_game(), m_use_it(), m_use_pack(), get_dir(), need_dir(); -long lseek(), check_level(); -void genmonsters(), - add_intelligence(), add_strength(), add_wisdom(), add_dexterity(), - add_constitution(), add_charisma(), res_intelligence(), res_strength(int), - res_wisdom(), res_dexterity(), res_constitution(), res_charisma(); - -void writelog(unsigned long amount, int flags, short monst); +char *md_crypt(char *key, char *salt); +int md_erasechar(void); +FILE *md_fdopen(int fd, char *mode); +int md_fileno(FILE *fp); +void md_flushinp(void); +char *md_gethomedir(void); +char *md_gethostname(void); +char *md_getpass(char *prompt); +char *md_getroguedir(void); +int md_getuid(void); +char *md_getusername(void); +void md_init(void); +int md_killchar(void); +long md_memused(void); +int md_normaluser(void); +int md_rand(void); +void md_reopen_score(void); +int md_readchar(WINDOW *win); +int md_shellescape(void); +int md_srand(int seed); +int md_unlink(char *file); +int md_unlink_open_file(char *file, int inf); #ifdef CHECKTIME int checkout(); #endif +#ifdef PC7300 +void endhardwin(void); +#endif /* * Now all the global variables @@ -1297,11 +1569,7 @@ extern void (*add_abil[NUMABILITIES])(); /* Functions to change abilities */ extern void (*res_abil[NUMABILITIES])(); /* Functions to change abilities */ extern int cNCOLORS, cNWOOD, cNMETAL, cNSTONES; extern char *rainbow[], *stones[], *wood[], *metal[]; -extern int land(), wghtchk(), undance(), cloak_charge(struct object *); extern struct delayed_action d_list[MAXDAEMONS]; extern struct delayed_action f_list[MAXFUSES]; extern int demoncnt, fusecnt, between, chance; #define CCHAR(x) ( (char) (x & A_CHARTEXT) ) -extern char *md_gethostname(), *md_getusername(), *md_gethomedir(), *md_getroguedir(), *md_crypt(); -extern FILE * md_fdopen(int fd, char *mode); -extern int md_fileno(FILE *fp); diff --git a/arogue7/rooms.c b/arogue7/rooms.c index d915db7..9a116f0 100644 --- a/arogue7/rooms.c +++ b/arogue7/rooms.c @@ -21,7 +21,11 @@ #include "curses.h" #include "rogue.h" -do_rooms() +void horiz(int cnt); +void vert(int cnt); + +void +do_rooms(void) { register int i; register struct room *rp; @@ -108,7 +112,7 @@ do_rooms() has_gold = TRUE; /* This room has gold in it */ - item = spec_item(GOLD, NULL, NULL, NULL); + item = spec_item(GOLD, 0, 0, 0); cur = OBJPTR(item); /* Put the gold into the level list of items */ @@ -178,9 +182,7 @@ do_rooms() */ coord * -doorway(rp, door) -register struct room *rp; -register coord *door; +doorway(struct room *rp, coord *door) { register int misses = 0; static coord answer; @@ -209,8 +211,8 @@ register coord *door; * Draw a box around a room */ -draw_room(rp) -register struct room *rp; +void +draw_room(struct room *rp) { register int j, k; @@ -237,8 +239,8 @@ register struct room *rp; * draw a horizontal line */ -horiz(cnt) -register int cnt; +void +horiz(int cnt) { while (cnt--) addch('-'); @@ -249,9 +251,8 @@ register int cnt; * pick a random spot in a room */ -rnd_pos(rp, cp) -register struct room *rp; -register coord *cp; +void +rnd_pos(struct room *rp, coord *cp) { cp->x = rp->r_pos.x + rnd(rp->r_max.x-2) + 1; cp->y = rp->r_pos.y + rnd(rp->r_max.y-2) + 1; @@ -266,8 +267,7 @@ register coord *cp; */ struct room * -roomin(cp) -register coord *cp; +roomin(coord *cp) { register struct room *rp; @@ -282,8 +282,8 @@ register coord *cp; * draw a vertical line */ -vert(cnt) -register int cnt; +void +vert(int cnt) { register int x, y; diff --git a/arogue7/save.c b/arogue7/save.c index 545e4d1..17eddbf 100644 --- a/arogue7/save.c +++ b/arogue7/save.c @@ -42,6 +42,8 @@ extern struct uwdata wdata; #define ENCWRITE encwrite #endif +bool save_file(int savefd); + typedef struct stat STAT; extern char version[], encstr[]; @@ -51,7 +53,7 @@ extern int errno; STAT sbuf; bool -save_game() +save_game(void) { register int savefd; register int c; @@ -122,8 +124,7 @@ gotfile: * recieved */ void -auto_save(sig) -int sig; +auto_save(int sig) { register int savefd; register int i; @@ -145,8 +146,7 @@ int sig; * write the saved game on the file */ bool -save_file(savefd) -register int savefd; +save_file(int savefd) { register unsigned num_to_write, num_written; FILE *savef; @@ -167,9 +167,8 @@ register int savefd; else return(FALSE); } -restore(file, envp) -register char *file; -char **envp; +bool +restore(char *file, char *envp[]) { register int inf; extern char **environ; @@ -265,10 +264,8 @@ char **envp; /* * perform an encrypted write */ -encwrite(start, size, outf) -register char *start; -register unsigned size; -register int outf; +int +encwrite(char *start, unsigned int size, int outf) { register char *ep; register int i = 0; @@ -298,10 +295,8 @@ register int outf; /* * perform an encrypted read */ -encread(start, size, inf) -register char *start; -register unsigned size; -register int inf; +int +encread(char *start, unsigned int size, int inf) { register char *ep; register int read_size; diff --git a/arogue7/scrolls.c b/arogue7/scrolls.c index 480c6e2..2b7b4d6 100644 --- a/arogue7/scrolls.c +++ b/arogue7/scrolls.c @@ -20,12 +20,14 @@ #include "curses.h" #include #include +#include #include "rogue.h" /* * let the hero get rid of some type of monster (but not a UNIQUE!) */ -genocide() +void +genocide(void) { register struct linked_list *ip; register struct thing *mp; @@ -57,10 +59,8 @@ genocide() msg("You have wiped out the %s.", monsters[which_monst].m_name); } -read_scroll(which, flag, is_scroll) -register int which; -int flag; -bool is_scroll; +void +read_scroll(int which, int flag, bool is_scroll) { register struct object *obj = NULL, *nobj; register struct linked_list *item, *nitem; diff --git a/arogue7/state.c b/arogue7/state.c index b30bd35..98fe107 100644 --- a/arogue7/state.c +++ b/arogue7/state.c @@ -73,6 +73,12 @@ static int format_error = FALSE; static int endian = 0x01020304; #define big_endian ( *((char *)&endian) == 0x01 ) +int list_size(struct linked_list *l); +int rs_write_int(FILE *savef, int c); +int rs_read_int(int inf, int *i); +int rs_write_object_list(FILE *savef, struct linked_list *l); +int rs_read_object_list(int inf, struct linked_list **list); + int rs_write(FILE *savef, void *ptr, size_t size) { @@ -2346,7 +2352,7 @@ rs_read_thing(int inf, struct thing *t) return(READSTAT); } -int +void rs_fix_thing(struct thing *t) { struct thing *tp; diff --git a/arogue7/sticks.c b/arogue7/sticks.c index 7498f16..12002f2 100644 --- a/arogue7/sticks.c +++ b/arogue7/sticks.c @@ -22,16 +22,14 @@ #include #include "rogue.h" +void drain(int ymin, int ymax, int xmin, int xmax); /* * zap a stick and see what happens */ -do_zap(zapper, obj, direction, which, flags) -struct thing *zapper; -struct object *obj; -coord *direction; -int which; -int flags; +void +do_zap(struct thing *zapper, struct object *obj, coord *direction, int which, + int flags) { register struct linked_list *item = NULL; register struct thing *tp; @@ -499,7 +497,7 @@ int flags; if (pstats.s_hpt <= 0) { msg("Your life has been sucked from you -- More --"); wait_for(' '); - death(zapper); + death(zapper->t_index); } else msg("You feel a great drain on your system"); @@ -625,8 +623,8 @@ int flags; * Do drain hit points from player shtick */ -drain(ymin, ymax, xmin, xmax) -int ymin, ymax, xmin, xmax; +void +drain(int ymin, int ymax, int xmin, int xmax) { register int i, j, count; register struct thing *ick; @@ -698,8 +696,8 @@ int ymin, ymax, xmin, xmax; /* * initialize a stick */ -fix_stick(cur) -register struct object *cur; +void +fix_stick(struct object *cur) { if (EQUAL(ws_type[cur->o_which], "staff")) { cur->o_weight = 100; @@ -738,8 +736,8 @@ register struct object *cur; /* * Use the wand that our monster is wielding. */ -m_use_wand(monster) -register struct thing *monster; +void +m_use_wand(struct thing *monster) { register struct object *obj; @@ -764,14 +762,16 @@ register struct thing *monster; */ msg("%s points a %s at you!", prname(monster_name(monster), TRUE), ws_type[obj->o_which]); - do_zap(monster, obj, &monster->t_newpos, obj->o_which, NULL); + do_zap(monster, obj, &monster->t_newpos, obj->o_which, 0); monster->t_wand /= 2; /* chance lowers with each use */ } +/* + * type: type of item, NULL means stick + * which: which item + */ bool -need_dir(type, which) -int type, /* type of item, NULL means stick */ - which; /* which item */ +need_dir(int type, int which) { if (type == STICK || type == 0) { switch (which) { @@ -799,9 +799,8 @@ return (FALSE); /* hope we don't get here */ /* * let the player zap a stick and see what happens */ -player_zap(which, flag) -int which; -int flag; +bool +player_zap(int which, int flag) { register struct linked_list *item; register struct object *obj; @@ -868,13 +867,9 @@ int flag; * given direction */ -shoot_bolt(shooter, start, dir, get_points, reason, name, damage) -struct thing *shooter; -coord start, dir; -bool get_points; -short reason; -char *name; -int damage; +void +shoot_bolt(struct thing *shooter, coord start, coord dir, bool get_points, + short reason, char *name, int damage) { register char dirch, ch; register bool used, change; diff --git a/arogue7/things.c b/arogue7/things.c index 105d81f..d01257c 100644 --- a/arogue7/things.c +++ b/arogue7/things.c @@ -23,12 +23,16 @@ #include #include "rogue.h" +int pick_one(struct magic_item *magic, int nitems); +char *blesscurse(int flags); +char *p_kind(struct object *obj); +int extras(void); + /* * print out the number of charges on a stick */ char * -charge_str(obj) -register struct object *obj; +charge_str(struct object *obj) { static char buf[20]; @@ -46,9 +50,7 @@ register struct object *obj; * inventory. */ char * -inv_name(obj, drop) -register struct object *obj; -bool drop; +inv_name(struct object *obj, bool drop) { register char *pb; @@ -324,8 +326,7 @@ bool drop; * Return the name of a weapon. */ char * -weap_name(obj) -register struct object *obj; +weap_name(struct object *obj) { switch (obj->o_type) { case WEAPON: @@ -357,8 +358,8 @@ register struct object *obj; * drop: * put something down */ -drop(item) -struct linked_list *item; +bool +drop(struct linked_list *item) { register char ch; register struct linked_list *obj, *nobj; @@ -464,8 +465,8 @@ struct linked_list *item; /* * do special checks for dropping or unweilding|unwearing|unringing */ -dropcheck(op) -register struct object *op; +bool +dropcheck(struct object *op) { int save_max; @@ -566,9 +567,7 @@ register struct object *op; * return a new thing */ struct linked_list * -new_thing(thing_type, allow_curse) -int thing_type; -bool allow_curse; +new_thing(int thing_type, bool allow_curse) { register struct linked_list *item; register struct object *cur; @@ -779,8 +778,7 @@ bool allow_curse; * provide a new item tailored to specification */ struct linked_list * -spec_item(type, which, hit, damage) -int type, which, hit, damage; +spec_item(int type, int which, int hit, int damage) { register struct linked_list *item; register struct object *obj; @@ -858,9 +856,8 @@ int type, which, hit, damage; /* * pick an item out of a list of nitems possible magic items */ -pick_one(magic, nitems) -register struct magic_item *magic; -int nitems; +int +pick_one(struct magic_item *magic, int nitems) { register struct magic_item *end; register int i; @@ -889,8 +886,7 @@ int nitems; */ char * -blesscurse(flags) -int flags; +blesscurse(int flags) { if (flags & ISKNOW) { if (flags & ISCURSED) return("cursed "); @@ -903,11 +899,11 @@ int flags; /* * p_kind returns the type of potion for some types of identified potions; * otherwise, it returns the color. + * We assume that obj points to a potion */ char * -p_kind(obj) -struct object *obj; /* We assume that obj points to a potion */ +p_kind(struct object *obj) { if (obj->o_which == P_ABIL) return(abilities[obj->o_kind]); else return(p_colors[obj->o_which]); @@ -917,7 +913,8 @@ struct object *obj; /* We assume that obj points to a potion */ * extras: * Return the number of extra items to be created */ -extras() +int +extras(void) { reg int i; diff --git a/arogue7/trader.c b/arogue7/trader.c index a4c0ce9..32914c5 100644 --- a/arogue7/trader.c +++ b/arogue7/trader.c @@ -16,18 +16,22 @@ * Anything to do with trading posts */ +#include +#include #include "curses.h" #include "rogue.h" - - +bool open_market(void); +void trans_line(void); +char *typ_name(struct object *obj); /* * buy_it: * Buy the item on which the hero stands */ -buy_it() +void +buy_it(void) { reg int wh; struct linked_list *item; @@ -79,9 +83,10 @@ buy_it() /* * do_post: * Put a trading post room and stuff on the screen + * startup: True if equipping the player at the beginning of the game */ -do_post(startup) -bool startup; /* True if equipping the player at the beginning of the game */ +void +do_post(bool startup) { coord tp; reg int i, j, k; @@ -322,8 +327,8 @@ bool startup; /* True if equipping the player at the beginning of the game */ * get_worth: * Calculate an objects worth in gold */ -get_worth(obj) -reg struct object *obj; +int +get_worth(struct object *obj) { reg int worth, wh; @@ -393,7 +398,8 @@ reg struct object *obj; * open_market: * Retruns TRUE when ok do to transacting */ -open_market() +bool +open_market(void) { if (trader >= MAXPURCH && !wizard && level != 0) { msg("The market is closed. The stairs are that-a-way."); @@ -408,7 +414,8 @@ open_market() * price_it: * Price the object that the hero stands on */ -price_it() +bool +price_it(void) { reg struct linked_list *item; reg struct object *obj; @@ -445,7 +452,8 @@ price_it() * sell_it: * Sell an item to the trading post */ -sell_it() +void +sell_it(void) { reg struct linked_list *item; reg struct object *obj; @@ -491,7 +499,8 @@ sell_it() * trans_line: * Show how many transactions the hero has left */ -trans_line() +void +trans_line(void) { if (level == 0) sprintf(prbuf, "You are welcome to spend whatever you have."); @@ -511,8 +520,7 @@ trans_line() * Return the name for this type of object */ char * -typ_name(obj) -reg struct object *obj; +typ_name(struct object *obj) { static char buff[20]; reg int wh; diff --git a/arogue7/util.c b/arogue7/util.c index 9120b38..cde6869 100644 --- a/arogue7/util.c +++ b/arogue7/util.c @@ -35,8 +35,7 @@ extern struct uwdata wdata; * this routine computes the players current AC without dex bonus's */ int -ac_compute(ignoremetal) -bool ignoremetal; +ac_compute(bool ignoremetal) { register int ac; @@ -69,8 +68,8 @@ bool ignoremetal; * aggravate all the monsters on this level */ -aggravate(do_uniques, do_good) -bool do_uniques, do_good; +void +aggravate(bool do_uniques, bool do_good) { register struct linked_list *mi; register struct thing *thingptr; @@ -87,8 +86,8 @@ bool do_uniques, do_good; * returns true if the hero can see a certain coordinate. */ -cansee(y, x) -register int y, x; +bool +cansee(int y, int x) { register struct room *rer; register int radius; @@ -134,7 +133,7 @@ register int y, x; * further levels */ long -check_level() +check_level(void) { register int i, j, add = 0; register unsigned long exp; @@ -178,8 +177,8 @@ check_level() * it keeps track of the highest it has been, just in case */ -chg_str(amt) -register int amt; +void +chg_str(int amt) { register int ring_str; /* ring strengths */ register struct stats *ptr; /* for speed */ @@ -201,7 +200,8 @@ register int amt; /* * let's confuse the player */ -confus_player() +void +confus_player(void) { if (off(player, ISCLEAR)) { @@ -218,7 +218,8 @@ confus_player() /* * this routine computes the players current dexterity */ -dex_compute() +int +dex_compute(void) { if (cur_misc[WEAR_GAUNTLET] != NULL && cur_misc[WEAR_GAUNTLET]->o_which == MM_G_DEXTERITY) { @@ -236,9 +237,8 @@ dex_compute() * Check to see if the move is legal if it is diagonal */ -diag_ok(sp, ep, flgptr) -register coord *sp, *ep; -struct thing *flgptr; +bool +diag_ok(coord *sp, coord *ep, struct thing *flgptr) { register int numpaths = 0; @@ -258,10 +258,7 @@ struct thing *flgptr; * pick a random position around the give (y, x) coordinates */ coord * -fallpos(pos, be_clear, range) -register coord *pos; -bool be_clear; -int range; +fallpos(coord *pos, bool be_clear, int range) { register int tried, i, j; register char ch; @@ -339,8 +336,8 @@ int range; * Find the index into the monster table of a monster given its name. */ -findmindex(name) -char *name; +int +findmindex(char *name) { int which; @@ -361,9 +358,7 @@ char *name; */ struct linked_list * -find_mons(y, x) -register int y; -register int x; +find_mons(int y, int x) { register struct linked_list *item; register struct thing *th; @@ -383,9 +378,7 @@ register int x; */ struct linked_list * -find_obj(y, x) -register int y; -register int x; +find_obj(int y, int x) { register struct linked_list *obj; register struct object *op; @@ -403,7 +396,7 @@ register int x; * get coordinates from the player using the cursor keys (or mouse) */ coord -get_coordinates() +get_coordinates(void) { register int which; coord c; @@ -550,8 +543,7 @@ get_coordinates() * set up the direction co_ordinate for use in various "prefix" commands */ bool -get_dir(direction) -coord *direction; +get_dir(coord *direction) { register char *prompt; register bool gotit; @@ -610,8 +602,8 @@ coord *direction; /* * see if the object is one of the currently used items */ -is_current(obj) -register struct object *obj; +bool +is_current(struct object *obj) { if (obj == NULL) return FALSE; @@ -650,11 +642,12 @@ register struct object *obj; /* * Look: * A quick glance all around the player + * wakeup: Should we wake up monsters + * runend: At end of a run -- for mazes */ -look(wakeup, runend) -bool wakeup; /* Should we wake up monsters */ -bool runend; /* At end of a run -- for mazes */ +void +look(bool wakeup, bool runend) { register int x, y, radius; register char ch, och; @@ -938,8 +931,8 @@ bool runend; /* At end of a run -- for mazes */ * Lower a level of experience */ -lower_level(who) -short who; +void +lower_level(short who) { int fewer, nsides; unsigned int exp; @@ -971,8 +964,7 @@ short who; * print out the name of a monster */ char * -monster_name(tp) -register struct thing *tp; +monster_name(struct thing *tp) { prbuf[0] = '\0'; if (on(*tp, ISFLEE) || on(*tp, WASTURNED)) @@ -1003,8 +995,7 @@ register struct thing *tp; */ bool -move_hero(why) -int why; +move_hero(int why) { char *action = ""; char which; @@ -1049,7 +1040,8 @@ int why; * The guy just magically went up a level. */ -raise_level() +void +raise_level(void) { unsigned long test; /* Next level -- be sure it is not an overflow */ @@ -1081,11 +1073,12 @@ static int st_matrix[NUM_CHARTYPES][5] = { /* * save: * See if a creature saves against something + * which: which type of save + * who: who is saving + * adj: saving throw adjustment */ -save(which, who, adj) -int which; /* which type of save */ -struct thing *who; /* who is saving */ -int adj; /* saving throw adjustment */ +bool +save(int which, struct thing *who, int adj) { register int need, level, protect; @@ -1144,8 +1137,8 @@ int adj; /* saving throw adjustment */ * Figure out what a secret door looks like. */ -secretdoor(y, x) -register int y, x; +char +secretdoor(int y, int x) { register int i; register struct room *rp; @@ -1168,7 +1161,8 @@ register int y, x; /* * this routine computes the players current strength */ -str_compute() +int +str_compute(void) { if (cur_misc[WEAR_GAUNTLET] != NULL && cur_misc[WEAR_GAUNTLET]->o_which == MM_G_OGRE) { @@ -1184,9 +1178,8 @@ str_compute() /* * copy string using unctrl for things */ -strucpy(s1, s2, len) -register char *s1, *s2; -register int len; +void +strucpy(char *s1, char *s2, int len) { register char *sp; @@ -1204,8 +1197,7 @@ register int len; */ char * -tr_name(ch) -char ch; +tr_name(char ch) { register char *s = ""; @@ -1235,8 +1227,7 @@ char ch; * for printfs: if string starts with a vowel, return "n" for an "an" */ char * -vowelstr(str) -register char *str; +vowelstr(char *str) { switch (*str) { @@ -1254,8 +1245,8 @@ register char *str; /* * wake up a room full (hopefully) of creatures */ -wake_room(rp) -register struct room *rp; +void +wake_room(struct room *rp) { register struct linked_list *item; register struct thing *tp; @@ -1273,7 +1264,8 @@ register struct room *rp; * Do nothing but let other things happen */ -waste_time() +void +waste_time(void) { if (inwhgt) /* if from wghtchk then done */ return; diff --git a/arogue7/weapons.c b/arogue7/weapons.c index 9958211..4bb21ba 100644 --- a/arogue7/weapons.c +++ b/arogue7/weapons.c @@ -22,10 +22,8 @@ #include #include "rogue.h" -boomerang(ydelta, xdelta, item, tp) -int ydelta, xdelta; -register struct linked_list *item; -register struct thing *tp; +void +boomerang(int ydelta, int xdelta, struct linked_list *item, struct thing *tp) { register struct object *obj; struct thing midpoint; @@ -56,10 +54,8 @@ register struct thing *tp; * across the room. Note that we should not look at any field in * tp other than t_pos unless we change boomerang(). */ -do_motion(obj, ydelta, xdelta, tp) -register struct object *obj; -register int ydelta, xdelta; -register struct thing *tp; +void +do_motion(struct object *obj, int ydelta, int xdelta, struct thing *tp) { /* @@ -115,9 +111,8 @@ register struct thing *tp; * Drop an item someplace around here. */ -fall(item, pr) -register struct linked_list *item; -bool pr; +void +fall(struct linked_list *item, bool pr) { register struct object *obj; register struct room *rp; @@ -170,10 +165,8 @@ bool pr; * Does the missile hit the monster */ -hit_monster(y, x, obj, tp) -register int y, x; -struct object *obj; -register struct thing *tp; +bool +hit_monster(int y, int x, struct object *obj, struct thing *tp) { static coord mp; @@ -203,9 +196,8 @@ register struct thing *tp; * Set up the initial goodies for a weapon */ -init_weapon(weap, type) -register struct object *weap; -char type; +void +init_weapon(struct object *weap, char type) { register struct init_weps *iwp; @@ -228,10 +220,8 @@ char type; * Fire a missile in a given direction */ -missile(ydelta, xdelta, item, tp) -int ydelta, xdelta; -register struct linked_list *item; -register struct thing *tp; +void +missile(int ydelta, int xdelta, struct linked_list *item, struct thing *tp) { register struct object *obj; register struct linked_list *nitem; @@ -303,8 +293,7 @@ register struct thing *tp; */ char * -num(n1, n2) -register int n1, n2; +num(int n1, int n2) { static char numbuf[LINELEN]; @@ -324,7 +313,8 @@ register int n1, n2; * Pull out a certain weapon */ -wield() +void +wield(void) { register struct linked_list *item; register struct object *obj, *oweapon; diff --git a/arogue7/wear.c b/arogue7/wear.c index f5acca4..9a7a8cb 100644 --- a/arogue7/wear.c +++ b/arogue7/wear.c @@ -26,7 +26,8 @@ * Get the armor off of the players back */ -take_off() +void +take_off(void) { register struct object *obj; register struct linked_list *item; @@ -75,7 +76,8 @@ take_off() * The player wants to wear something, so let him/her put it on. */ -wear() +void +wear(void) { register struct linked_list *item; register struct object *obj; @@ -389,8 +391,8 @@ wear() * How many movements periods does it take to put on or remove the * given item of "clothing"? */ -dress_units(item) -struct linked_list *item; +int +dress_units(struct linked_list *item) { register struct object *obj; diff --git a/arogue7/wizard.c b/arogue7/wizard.c index b5a2bb8..ebed23a 100644 --- a/arogue7/wizard.c +++ b/arogue7/wizard.c @@ -19,20 +19,21 @@ #include "curses.h" #include +#include #include #include "rogue.h" #ifdef PC7300 #include "menu.h" #endif +int getbless(void); /* * create_obj: * Create any object for wizard, scroll, magician, or cleric */ -create_obj(prompt, which_item, which_type) -bool prompt; -int which_item, which_type; +void +create_obj(bool prompt, int which_item, int which_type) { reg struct linked_list *item; reg struct object *obj; @@ -329,7 +330,8 @@ int which_item, which_type; * getbless: * Get a blessing for a wizards object */ -getbless() +int +getbless(void) { reg char bless; @@ -346,7 +348,8 @@ getbless() /* * get a non-monster death type */ -getdeath() +int +getdeath(void) { register int i; int which_death; @@ -381,10 +384,10 @@ static char Displines[NUMMONST+1][LINELEN+1]; /* The lines themselves */ /* * make a monster for the wizard + * showall -> show uniques and genocided creatures */ -makemonster(showall, label, action) -bool showall; /* showall -> show uniques and genocided creatures */ -char *label, *action; +short +makemonster(bool showall, char *label, char *action) { #ifdef PC7300 register int nextmonst; @@ -439,7 +442,7 @@ char *label, *action; /* Print out the monsters */ while (num_monst > 0) { - register left_limit; + int left_limit; if (num_monst < num_lines) left_limit = (num_monst+1)/2; else left_limit = num_lines/2; @@ -508,7 +511,8 @@ get_monst: * see if user knows password */ -passwd() +bool +passwd(void) { register char *sp, c; char buf[LINELEN], *crypt(); @@ -535,7 +539,8 @@ passwd() * Bamf the hero someplace else */ -teleport() +int +teleport(void) { register struct room *new_rp = NULL, *old_rp = roomin(&hero); register int rm, which; @@ -636,8 +641,8 @@ teleport() * What a certin object is */ -whatis(what) -struct linked_list *what; +void +whatis(struct linked_list *what) { register struct object *obj; register struct linked_list *item; From 285312038714b35d87d931e6b021f9ab5652d848 Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Wed, 2 Mar 2016 21:13:26 -0500 Subject: [PATCH 7/7] XRogue: convert to ANSI-style function declarations. --- xrogue/actions.c | 64 ++++----- xrogue/bolt.c | 11 +- xrogue/chase.c | 37 +++--- xrogue/command.c | 63 +++++---- xrogue/daemon.c | 40 +++--- xrogue/daemons.c | 109 +++++++++------ xrogue/eat.c | 3 +- xrogue/effects.c | 8 +- xrogue/encumb.c | 30 +++-- xrogue/fight.c | 105 +++++++-------- xrogue/help.c | 10 +- xrogue/init.c | 30 +++-- xrogue/io.c | 59 +++++---- xrogue/list.c | 51 +++---- xrogue/main.c | 47 ++++--- xrogue/maze.c | 37 +++--- xrogue/misc.c | 62 ++++----- xrogue/monsters.c | 38 +++--- xrogue/move.c | 68 +++++----- xrogue/n_level.c | 17 ++- xrogue/network.h | 4 +- xrogue/options.c | 77 +++++------ xrogue/outside.c | 14 +- xrogue/pack.c | 99 +++++++------- xrogue/passages.c | 16 ++- xrogue/player.c | 74 ++++++----- xrogue/potions.c | 62 ++++----- xrogue/rings.c | 14 +- xrogue/rip.c | 72 +++++----- xrogue/rogue.h | 330 +++++++++++++++++++++++++++++++++++++++------- xrogue/rooms.c | 32 ++--- xrogue/save.c | 28 ++-- xrogue/scrolls.c | 12 +- xrogue/state.c | 157 ++++++++++++++++++---- xrogue/sticks.c | 40 +++--- xrogue/things.c | 45 +++---- xrogue/trader.c | 27 ++-- xrogue/util.c | 114 ++++++++-------- xrogue/weapons.c | 40 +++--- xrogue/wear.c | 12 +- xrogue/wizard.c | 31 +++-- 41 files changed, 1281 insertions(+), 908 deletions(-) diff --git a/xrogue/actions.c b/xrogue/actions.c index 693a8ac..917638b 100644 --- a/xrogue/actions.c +++ b/xrogue/actions.c @@ -24,12 +24,20 @@ int mf_count = 0; /* move_free counter - see actions.c(m_act()) */ int mf_jmpcnt = 0; /* move_free counter for # of jumps */ +void m_breathe(struct thing *tp); +void m_select(struct thing *th, bool flee); +void m_sonic(struct thing *tp); +void m_spell(struct thing *tp); +void m_summon(struct thing *tp); +bool m_use_it(struct thing *tp, bool flee, struct room *rer, struct room *ree); +bool m_use_pack(struct thing *monster, coord *defend_pos, int dist, + coord *shoot_dir); + /* * Did we disrupt a spell? */ -dsrpt_monster(tp, always, see_him) -register struct thing *tp; -bool always, see_him; +void +dsrpt_monster(struct thing *tp, bool always, bool see_him) { switch (tp->t_action) { case A_SUMMON: @@ -58,7 +66,8 @@ bool always, see_him; } } -dsrpt_player() +void +dsrpt_player(void) { int which, action; struct linked_list *item; @@ -87,7 +96,7 @@ dsrpt_player() if (purse > 0) { msg("Your gold goes flying everywhere!"); do { - item = spec_item(GOLD, NULL, NULL, NULL); + item = spec_item(GOLD, 0, 0, 0); obj = OBJPTR(item); obj->o_count = min(purse, rnd(20)+1); purse -= obj->o_count; @@ -125,8 +134,8 @@ dsrpt_player() * Otherwise, let it perform its chosen action. */ -m_act(tp) -register struct thing *tp; +void +m_act(struct thing *tp) { struct object *obj; bool flee; /* Are we scared? */ @@ -290,8 +299,8 @@ register struct thing *tp; * Breathe in the chosen direction. */ -m_breathe(tp) -register struct thing *tp; +void +m_breathe(struct thing *tp) { register int damage; register char *breath = NULL; @@ -399,11 +408,11 @@ register struct thing *tp; /* * m_select: * Select an action for the monster. + * flee: True if running away or player is inaccessible in wall */ -m_select(th, flee) -register struct thing *th; -register bool flee; /* True if running away or player is inaccessible in wall */ +void +m_select(struct thing *th, bool flee) { register struct room *rer, *ree; /* room of chaser, room of chasee */ int dist = INT_MIN; @@ -541,8 +550,8 @@ register bool flee; /* True if running away or player is inaccessible in wall */ * The monster is sounding a sonic blast. */ -m_sonic(tp) -register struct thing *tp; +void +m_sonic(struct thing *tp) { register int damage; struct object blast = @@ -571,8 +580,8 @@ register struct thing *tp; * The monster casts a spell. Currently this is limited to * magic missile. */ -m_spell(tp) -register struct thing *tp; +void +m_spell(struct thing *tp) { struct object missile = { @@ -594,8 +603,8 @@ register struct thing *tp; * Summon aid. */ -m_summon(tp) -register struct thing *tp; +void +m_summon(struct thing *tp) { register char *helpname, *mname; int fail, numsum; @@ -668,10 +677,7 @@ register struct thing *tp; */ bool -m_use_it(tp, flee, rer, ree) -register struct thing *tp; -bool flee; -register struct room *rer, *ree; +m_use_it(struct thing *tp, bool flee, struct room *rer, struct room *ree) { int dist; register coord *ee = tp->t_dest, *er = &tp->t_pos; @@ -836,7 +842,8 @@ register struct room *rer, *ree; } -reap() +void +reap(void) { _t_free_list(&rlist); } @@ -844,10 +851,11 @@ reap() /* * runners: * Make all the awake monsters try to do something. + * segments: Number of segments since last called */ -runners(segments) -int segments; /* Number of segments since last called */ +int +runners(int segments) { register struct linked_list *item; register struct thing *tp = NULL; @@ -961,11 +969,7 @@ int segments; /* Number of segments since last called */ * Only care about relics and wands for now. */ bool -m_use_pack(monster, defend_pos, dist, shoot_dir) -register struct thing *monster; -coord *defend_pos; -register int dist; -register coord *shoot_dir; +m_use_pack(struct thing *monster, coord *defend_pos, int dist, coord *shoot_dir) { register struct object *obj; register struct linked_list *pitem, *relic, *stick; diff --git a/xrogue/bolt.c b/xrogue/bolt.c index 2d79971..a41e26c 100644 --- a/xrogue/bolt.c +++ b/xrogue/bolt.c @@ -18,6 +18,7 @@ #include #include +#include #include "rogue.h" /* @@ -25,13 +26,9 @@ * given direction */ -shoot_bolt(shooter, start, dir, get_points, reason, name, damage) -struct thing *shooter; -coord start, dir; -bool get_points; -short reason; -char *name; -int damage; +void +shoot_bolt(struct thing *shooter, coord start, coord dir, bool get_points, + short reason, char *name, int damage) { unsigned char dirch = 0, ch; bool used, change, see_him; diff --git a/xrogue/chase.c b/xrogue/chase.c index bd99a03..5047f50 100644 --- a/xrogue/chase.c +++ b/xrogue/chase.c @@ -19,16 +19,18 @@ #include #include #include +#include #include "rogue.h" +bool straight_shot(int ery, int erx, int eey, int eex, coord *shooting); + /* * Canblink checks if the monster can teleport (blink). If so, it will * try to blink the monster next to the player. */ bool -can_blink(tp) -register struct thing *tp; +can_blink(struct thing *tp) { register int y, x, index=9; coord tryp; /* To hold the coordinates for use in diag_ok */ @@ -123,8 +125,7 @@ register struct thing *tp; */ int -can_shoot(er, ee, shoot_dir) -register coord *er, *ee, *shoot_dir; +can_shoot(coord *er, coord *ee, coord *shoot_dir) { /* * They must be in the same room or very close (at door) @@ -150,15 +151,13 @@ register coord *er, *ee, *shoot_dir; * Find the spot for the chaser(er) to move closer to the * chasee(ee). Rer is the room of the chaser, and ree is the * room of the creature being chased (chasee). + * flee: True if destination (ee) is player and monster is running away + * or the player is in a wall and the monster can't get to it */ -chase(tp, ee, rer, ree, flee) -register struct thing *tp; -register coord *ee; -register struct room *rer, *ree; -bool flee; /* True if destination (ee) is player and monster is running away - * or the player is in a wall and the monster can't get to it - */ +void +chase(struct thing *tp, coord *ee, struct room *rer, struct room *ree, + bool flee) { int dist, thisdist, monst_dist = INT_MAX; register coord *er = &tp->t_pos; @@ -495,8 +494,8 @@ bool flee; /* True if destination (ee) is player and monster is running away * Make one thing chase another. */ -do_chase(th) -register struct thing *th; +void +do_chase(struct thing *th) { register struct room *orig_rer, /* Original room of chaser */ *new_room; /* new room of monster */ @@ -812,8 +811,7 @@ register struct thing *th; */ struct linked_list * -get_hurl(tp) -register struct thing *tp; +get_hurl(struct thing *tp) { struct linked_list *arrow=NULL, *bolt=NULL, *rock=NULL, *spear = NULL, *dagger=NULL, *dart=NULL, *aklad=NULL; @@ -860,9 +858,8 @@ register struct thing *tp; * Set a monster running after something */ -runto(runner, spot) -register struct thing *runner; -coord *spot; +void +runto(struct thing *runner, coord *spot) { if (on(*runner, ISSTONE)) return; @@ -888,9 +885,7 @@ coord *spot; */ bool -straight_shot(ery, erx, eey, eex, shooting) -register int ery, erx, eey, eex; -register coord *shooting; +straight_shot(int ery, int erx, int eey, int eex, coord *shooting) { register int dy, dx; /* Deltas */ unsigned char ch; diff --git a/xrogue/command.c b/xrogue/command.c index 37eb8a1..5226eb6 100644 --- a/xrogue/command.c +++ b/xrogue/command.c @@ -24,12 +24,21 @@ #include "mach_dep.h" #include "rogue.h" +void display(void); +void d_level(void); +void u_level(void); +void shell(void); +void nameit(void); +void namemonst(void); +void count_gold(void); + /* * command: * Process the user commands */ -command() +void +command(void) { unsigned int ch; struct linked_list *item; @@ -288,7 +297,7 @@ command() else { after = FALSE; player.t_action = A_NIL; - fright(); + fright(NULL); } when 'g' : /* Give command: give slime-molds to monsters */ if (player.t_action == A_NIL) { @@ -298,7 +307,7 @@ command() else { after = FALSE; player.t_action = A_NIL; - give(); + give(NULL); } when 'G' : if (player.t_action == A_NIL) { @@ -357,14 +366,14 @@ command() /* when '\\' : after = FALSE; ident_hero(); */ when '\\' : msg("Charon (the Boatman) looks at you... "); - when '/' : after = FALSE; identify(NULL); + when '/' : after = FALSE; identify('\0'); when C_COUNT : count_gold(); when C_DIP : dip_it(); when C_DROP : player.t_action = C_DROP; drop((struct linked_list *)NULL); when C_EAT : eat(); - when C_QUAFF : quaff(-1, NULL, NULL, TRUE); - when C_READ : read_scroll(-1, NULL, TRUE); + when C_QUAFF : quaff(-1, 0, 0, TRUE); + when C_READ : read_scroll(-1, 0, TRUE); when C_SETTRAP : set_trap(&player, hero.y, hero.x); when C_SEARCH : if (player.t_action == A_NIL) { @@ -379,7 +388,7 @@ command() when C_USE : use_mm(-1); when C_WEAR : wear(); when C_WIELD : wield(); - when C_ZAP : if (!player_zap(NULL, FALSE)) after=FALSE; + when C_ZAP : if (!player_zap(0, FALSE)) after=FALSE; when C_CAST : cast(); when C_CHANT : chant(); when C_PRAY : pray(); @@ -638,7 +647,8 @@ command() * tell the player what is at a certain coordinates assuming * it can be seen. */ -display() +void +display(void) { coord c; struct linked_list *item; @@ -673,8 +683,7 @@ display() /*UNUSED*/ void -quit(sig) -int sig; +quit(int sig) { register int oy, ox; @@ -727,8 +736,8 @@ int sig; * killed by a program bug instead of voluntarily. */ -bugkill(sig) -int sig; +void +bugkill(int sig) { signal(sig, quit); /* If we get it again, give up */ if (levtype == OUTSIDE) { @@ -748,8 +757,8 @@ int sig; * Player gropes about him to find hidden things. */ -search(is_thief, door_chime) -register bool is_thief, door_chime; +void +search(bool is_thief, bool door_chime) { register int x, y; register char ch, /* The trap or door character */ @@ -861,7 +870,8 @@ register bool is_thief, door_chime; * He wants to go down a level */ -d_level() +void +d_level(void) { bool no_phase=FALSE; char position = winat(hero.y, hero.x); @@ -962,7 +972,8 @@ d_level() * He wants to go up a level */ -u_level() +void +u_level(void) { bool no_phase = FALSE; register struct linked_list *item; @@ -1053,7 +1064,8 @@ u_level() * Let him escape for a while */ -shell() +void +shell(void) { /* * Set the terminal back to original mode @@ -1079,7 +1091,8 @@ shell() /* * see what we want to name -- an item or a monster. */ -nameit() +void +nameit(void) { char answer; @@ -1103,9 +1116,8 @@ nameit() * allow a user to call a potion, scroll, or ring something */ -nameitem(item, mark) -struct linked_list *item; -bool mark; +void +nameitem(struct linked_list *item, bool mark) { register struct object *obj; register char **guess = NULL, *elsewise = NULL; @@ -1191,7 +1203,8 @@ bool mark; /* Name a monster */ -namemonst() +void +namemonst(void) { register struct thing *tp; struct linked_list *item; @@ -1236,7 +1249,8 @@ namemonst() msg("There is no monster there to name."); } -count_gold() +void +count_gold(void) { if (player.t_action != C_COUNT) { msg("You take a break to count your money.. "); @@ -1259,7 +1273,8 @@ count_gold() * Teleport somewhere, anywhere... */ -do_teleport() +void +do_teleport(void) { int tlev; prbuf[0] = '\0'; diff --git a/xrogue/daemon.c b/xrogue/daemon.c index f64fe63..8d36bc7 100644 --- a/xrogue/daemon.c +++ b/xrogue/daemon.c @@ -41,7 +41,7 @@ int fusecnt = 0; * Find an empty slot in the daemon list */ struct delayed_action * -d_slot() +d_slot(void) { reg int i; reg struct delayed_action *dev; @@ -57,7 +57,7 @@ d_slot() * Find an empty slot in the fuses list */ struct delayed_action * -f_slot() +f_slot(void) { reg int i; reg struct delayed_action *dev; @@ -74,8 +74,7 @@ f_slot() */ struct delayed_action * -find_slot(func) -reg int (*func)(); +find_slot(int (*func)()) { reg int i; reg struct delayed_action *dev; @@ -91,9 +90,8 @@ reg int (*func)(); * Start a daemon, takes a function. */ -start_daemon(dfunc, arg, type) -reg VOID *arg; -reg int type, (*dfunc)(); +void +start_daemon(int (*dfunc)(), VOID *arg, int type) { reg struct delayed_action *dev; @@ -112,8 +110,8 @@ reg int type, (*dfunc)(); * Remove a daemon from the list */ -kill_daemon(dfunc) -reg int (*dfunc)(); +void +kill_daemon(int (*dfunc)()) { reg struct delayed_action *dev; reg int i; @@ -140,8 +138,8 @@ reg int (*dfunc)(); * passing the argument to the function. */ -do_daemons(flag) -reg int flag; +void +do_daemons(int flag) { struct delayed_action *dev; int i; @@ -165,9 +163,8 @@ reg int flag; * Start a fuse to go off in a certain number of turns */ -fuse(dfunc, arg, time, type) -VOID *arg; -reg int (*dfunc)(), time, type; +void +fuse(int (*dfunc)(), VOID *arg, int time, int type) { reg struct delayed_action *wire; @@ -186,8 +183,8 @@ reg int (*dfunc)(), time, type; * Increase the time until a fuse goes off */ -lengthen(dfunc, xtime) -reg int (*dfunc)(), xtime; +void +lengthen(int (*dfunc)(), int xtime) { reg struct delayed_action *wire; @@ -201,8 +198,8 @@ reg int (*dfunc)(), xtime; * Put out a fuse */ -extinguish(dfunc) -reg int (*dfunc)(); +void +extinguish(int (*dfunc)()) { reg struct delayed_action *wire; @@ -220,8 +217,8 @@ reg int (*dfunc)(); * Decrement counters and start needed fuses */ -do_fuses(flag) -reg int flag; +void +do_fuses(int flag) { struct delayed_action *wire; int i; @@ -250,7 +247,8 @@ reg int flag; * Show wizard number of demaons and memory blocks used */ -activity() +void +activity(void) { msg("Daemons = %d : Fuses = %d : Memory Items = %d : Memory Used = %d", demoncnt,fusecnt,total,md_memused()); diff --git a/xrogue/daemons.c b/xrogue/daemons.c index dc19d2a..82e431d 100644 --- a/xrogue/daemons.c +++ b/xrogue/daemons.c @@ -24,8 +24,8 @@ * A healing daemon that restors hit points after rest */ -doctor(tp) -register struct thing *tp; +void +doctor(struct thing *tp) { register int ohp; register int limit, new_points; @@ -111,7 +111,8 @@ register struct thing *tp; * Called when it is time to start rolling for wandering monsters */ -swander() +void +swander(void) { start_daemon(rollwand, (VOID *)NULL, BEFORE); } @@ -123,7 +124,8 @@ swander() int between = 0; -rollwand() +void +rollwand(void) { if (++between >= 4) @@ -145,7 +147,8 @@ rollwand() * this function is a daemon called each turn when the character is a thief */ -trap_look() +void +trap_look(void) { if (rnd(100) < (2*dex_compute() + 5*pstats.s_lvl)) search(TRUE, FALSE); @@ -156,7 +159,8 @@ trap_look() * Release the poor player from his confusion */ -unconfuse() +void +unconfuse(void) { turn_off(player, ISHUH); msg("You feel less confused now"); @@ -167,7 +171,8 @@ unconfuse() * He lost his see invisible power */ -unsee() +void +unsee(void) { if (!ISWEARING(R_SEEINVIS)) { turn_off(player, CANSEE); @@ -180,7 +185,8 @@ unsee() * Remove to-hit handicap from player */ -unstink() +void +unstink(void) { turn_off(player, HASSTINK); } @@ -190,7 +196,8 @@ unstink() * Player is no longer immune to confusion */ -unclrhead() +void +unclrhead(void) { turn_off(player, ISCLEAR); msg("The blue aura about your head fades away."); @@ -201,7 +208,8 @@ unclrhead() * Player can no longer walk through walls */ -unphase() +void +unphase(void) { turn_off(player, CANINWALL); msg("Your dizzy feeling leaves you."); @@ -215,7 +223,7 @@ unphase() */ int -land() +land(void) { turn_off(player, ISFLY); msg("You regain your normal weight"); @@ -228,7 +236,8 @@ land() * He gets his sight back */ -sight() +void +sight(void) { if (on(player, ISBLIND)) { @@ -245,8 +254,7 @@ sight() */ int -res_strength(howmuch) -long howmuch; +res_strength(long howmuch) { /* If lost_str is non-zero, restore that amount of strength, @@ -271,7 +279,8 @@ long howmuch; * End the hasting */ -nohaste() +void +nohaste(void) { turn_off(player, ISHASTE); msg("You feel yourself slowing down."); @@ -282,7 +291,8 @@ nohaste() * End the slowing */ -noslow() +void +noslow(void) { turn_off(player, ISSLOW); msg("You feel yourself speeding up."); @@ -293,7 +303,8 @@ noslow() * If this gets called, the player has suffocated */ -suffocate() +void +suffocate(void) { pstats.s_hpt = -1; death(D_SUFFOCATION); @@ -303,7 +314,8 @@ suffocate() * digest the hero's food */ -stomach() +void +stomach(void) { register int oldfood, old_hunger, food_use, i; @@ -387,7 +399,8 @@ stomach() * daemon for curing the diseased */ -cure_disease() +void +cure_disease(void) { turn_off(player, HASDISEASE); if (off (player, HASINFEST)) @@ -400,7 +413,8 @@ cure_disease() * Become visible again */ -appear() +void +appear(void) { turn_off(player, ISINVIS); PLAYER = VPLAYER; @@ -413,7 +427,8 @@ appear() * dust of disappearance wears off */ -dust_appear() +void +dust_appear(void) { turn_off(player, ISINVIS); PLAYER = VPLAYER; @@ -426,7 +441,8 @@ dust_appear() * the effects of "dust of choking and sneezing" wear off */ -unchoke() +void +unchoke(void) { if (!find_slot(unconfuse)) turn_off(player, ISHUH); @@ -440,8 +456,8 @@ unchoke() * make some potion for the guy in the Alchemy jug */ -alchemy(obj) -register struct object *obj; +void +alchemy(struct object *obj) { register struct object *tobj = NULL; register struct linked_list *item; @@ -492,7 +508,7 @@ register struct object *obj; */ int -undance() +undance(void) { turn_off(player, ISDANCE); msg ("Your feet take a break.....whew!"); @@ -503,7 +519,8 @@ undance() * if he has our favorite necklace of strangulation then take damage every turn */ -strangle() +void +strangle(void) { if ((pstats.s_hpt -= 6) <= 0) { pstats.s_hpt = -1; @@ -515,7 +532,8 @@ strangle() * if he has on the gauntlets of fumbling he might drop his weapon each turn */ -fumble() +void +fumble(void) { register struct linked_list *item; @@ -557,7 +575,8 @@ fumble() * it's a lot like trap_look() */ -ring_search() +void +ring_search(void) { if (rnd(75) < (2*dex_compute() + 5*pstats.s_lvl)) search(TRUE, FALSE); else search(FALSE, FALSE); @@ -567,7 +586,8 @@ ring_search() * this is called each turn the hero has the ring of teleportation on */ -ring_teleport() +void +ring_teleport(void) { if (rnd(100) < 3) teleport(); } @@ -576,7 +596,8 @@ ring_teleport() * this is called to charge up the quill of Nagrom */ -quill_charge() +void +quill_charge(void) { register struct object *tobj = NULL; register struct linked_list *item; @@ -601,7 +622,8 @@ quill_charge() * take the skills away gained (or lost) by the potion of skills */ -unskill() +void +unskill(void) { if (pstats.s_lvladj != 0) { pstats.s_lvl -= pstats.s_lvladj; @@ -616,8 +638,7 @@ unskill() */ int -cloak_charge(obj) -register struct object *obj; +cloak_charge(struct object *obj) { if (obj->o_charges < 1) obj->o_charges = 1; @@ -629,7 +650,8 @@ register struct object *obj; * He lost his fire resistance */ -nofire() +void +nofire(void) { if (!ISWEARING(R_FIRE)) { turn_off(player, NOFIRE); @@ -642,7 +664,8 @@ nofire() * He lost his cold resistance */ -nocold() +void +nocold(void) { if (!ISWEARING(R_WARMTH)) { turn_off(player, NOCOLD); @@ -655,7 +678,8 @@ nocold() * He lost his protection from lightning */ -nobolt() +void +nobolt(void) { turn_off(player, NOBOLT); msg("Your skin loses its bluish tint"); @@ -666,8 +690,8 @@ nobolt() * an artifact eats gold */ -eat_gold(obj) -register struct object *obj; +void +eat_gold(struct object *obj) { if (purse == 250) msg("%s.. Bids you to find some more gold. ", inv_name(obj, FALSE)); @@ -691,7 +715,8 @@ register struct object *obj; * give the hero back some spell points */ -spell_recovery() +void +spell_recovery(void) { int time; @@ -705,7 +730,8 @@ spell_recovery() * give the hero back some prayer points */ -prayer_recovery() +void +prayer_recovery(void) { int time; @@ -719,7 +745,8 @@ prayer_recovery() * give the hero back some chant points */ -chant_recovery() +void +chant_recovery(void) { int time; diff --git a/xrogue/eat.c b/xrogue/eat.c index 2cf8f82..b48f43d 100644 --- a/xrogue/eat.c +++ b/xrogue/eat.c @@ -24,7 +24,8 @@ * He wants to eat something, so let him try */ -eat() +void +eat(void) { register struct linked_list *item; int which; diff --git a/xrogue/effects.c b/xrogue/effects.c index 0c68ab3..b6ce3a8 100644 --- a/xrogue/effects.c +++ b/xrogue/effects.c @@ -26,11 +26,9 @@ * the reason code if the defender is killed. Otherwise return 0. */ -effect(att, def, weap, thrown, see_att, see_def) -register struct thing *att, *def; -struct object *weap; -bool thrown; -register bool see_att, see_def; +int +effect(struct thing *att, struct thing *def, struct object *weap, bool thrown, + bool see_att, bool see_def) { register bool att_player, def_player; char attname[LINELEN+1], defname[LINELEN+1]; diff --git a/xrogue/encumb.c b/xrogue/encumb.c index 4388d02..8aa9063 100644 --- a/xrogue/encumb.c +++ b/xrogue/encumb.c @@ -15,14 +15,15 @@ #include #include "rogue.h" +int packweight(struct thing *tp); + /* * updpack: * Update his pack weight and adjust fooduse accordingly */ -updpack(getmax, tp) -int getmax; -struct thing *tp; +void +updpack(int getmax, struct thing *tp) { reg int topcarry, curcarry; @@ -52,8 +53,8 @@ struct thing *tp; * Get the total weight of the hero's pack */ -packweight(tp) -register struct thing *tp; +int +packweight(struct thing *tp) { reg struct object *obj; reg struct linked_list *pc; @@ -89,8 +90,8 @@ register struct thing *tp; * Get the weight of an object */ -itemweight(wh) -reg struct object *wh; +int +itemweight(struct object *wh) { reg int weight; reg int ac; @@ -120,8 +121,8 @@ reg struct object *wh; * Get hero's carrying ability above norm */ -playenc(tp) -register struct thing *tp; +int +playenc(struct thing *tp) { register int strength; @@ -136,8 +137,8 @@ register struct thing *tp; * Get total weight that the hero can carry */ -totalenc(tp) -register struct thing *tp; +int +totalenc(struct thing *tp) { reg int wtotal; @@ -157,11 +158,11 @@ register struct thing *tp; * See if the hero can carry his pack */ -wghtchk() +void +wghtchk(void) { reg int dropchk, err = TRUE; reg char ch; - int wghtchk(); inwhgt = TRUE; if (pstats.s_pack > pstats.s_carry) { @@ -195,7 +196,8 @@ wghtchk() * -1 hit for heavy pack weight */ -hitweight() +int +hitweight(void) { return(2 - foodlev); } diff --git a/xrogue/fight.c b/xrogue/fight.c index 8ddbba7..724603d 100644 --- a/xrogue/fight.c +++ b/xrogue/fight.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "rogue.h" #define CONF_DAMAGE -1 @@ -26,15 +27,23 @@ #define DEST_DAMAGE -3 #define DRAIN_DAMAGE -4 +bool roll_em(struct thing *att_er, struct thing *def_er, struct object *weap, + bool hurl, struct object *cur_weapon, bool back_stab); +void hit(struct object *weapon, bool see_att, bool see_def, char *er, char *ee, + bool back_stab, bool thrown, bool short_msg); +void miss(struct object *weapon, bool see_att, bool see_def, char *er, char *ee, + bool thrown, bool short_msg); +int add_dam(short str); +int hung_dam(void); + int killed_chance = 0; /* cumulative chance for goodies to loose it */ /* * returns true if player has a any chance to hit the monster */ -player_can_hit(tp, weap) -register struct thing *tp; -register struct object *weap; +bool +player_can_hit(struct thing *tp, struct object *weap) { if (off(*tp, CMAGICHIT) && off(*tp, BMAGICHIT) && off(*tp, MAGICHIT)) return(TRUE); @@ -62,10 +71,8 @@ register struct object *weap; * The player attacks the monster. */ -fight(mp, weap, thrown) -register coord *mp; -struct object *weap; -bool thrown; +bool +fight(coord *mp, struct object *weap, bool thrown) { register struct thing *tp; register struct linked_list *item; @@ -226,10 +233,8 @@ bool thrown; * The monster attacks the player */ -attack(mp, weapon, thrown) -register struct thing *mp; -register struct object *weapon; -bool thrown; +bool +attack(struct thing *mp, struct object *weapon, bool thrown) { register char *mname; register bool see_att, did_hit = FALSE; @@ -305,9 +310,8 @@ bool thrown; * returns true if the swing hits */ -swing(class, at_lvl, op_arm, wplus) -short class; -int at_lvl, op_arm, wplus; +bool +swing(short class, int at_lvl, int op_arm, int wplus) { register int res = rnd(20)+1; register int need; @@ -327,12 +331,9 @@ int at_lvl, op_arm, wplus; * Roll several attacks */ -roll_em(att_er, def_er, weap, hurl, cur_weapon, back_stab) -struct thing *att_er, *def_er; -struct object *weap; -bool hurl; -struct object *cur_weapon; -bool back_stab; +bool +roll_em(struct thing *att_er, struct thing *def_er, struct object *weap, + bool hurl, struct object *cur_weapon, bool back_stab) { register struct stats *att, *def; register char *cp = NULL; @@ -739,9 +740,7 @@ bool back_stab; */ char * -prname(who, upper) -register char *who; -bool upper; +prname(char *who, bool upper) { static char tbuf[LINELEN]; @@ -766,11 +765,9 @@ bool upper; * Print a message to indicate a succesful hit */ -hit(weapon, see_att, see_def, er, ee, back_stab, thrown, short_msg) -register struct object *weapon; -bool see_att, see_def; -register char *er, *ee; -bool back_stab, thrown, short_msg; +void +hit(struct object *weapon, bool see_att, bool see_def, char *er, char *ee, + bool back_stab, bool thrown, bool short_msg) { register char *s = NULL; char att_name[LINELEN], /* Name of attacker */ @@ -830,11 +827,9 @@ bool back_stab, thrown, short_msg; * Print a message to indicate a poor swing */ -miss(weapon, see_att, see_def, er, ee, thrown, short_msg) -register struct object *weapon; -bool see_att, see_def; -register char *er, *ee; -bool thrown, short_msg; +void +miss(struct object *weapon, bool see_att, bool see_def, char *er, char *ee, + bool thrown, bool short_msg) { register char *s = NULL; char att_name[LINELEN], /* Name of attacker */ @@ -874,8 +869,8 @@ bool thrown, short_msg; * compute to-hit bonus for dexterity */ -dext_plus(dexterity) -register int dexterity; +int +dext_plus(int dexterity) { return (dexterity > 10 ? (dexterity-13)/3 : (dexterity-10)/3); } @@ -886,8 +881,8 @@ register int dexterity; * compute armor class bonus for dexterity */ -dext_prot(dexterity) -register int dexterity; +int +dext_prot(int dexterity) { return ((dexterity-10)/2); } @@ -897,8 +892,8 @@ register int dexterity; * compute bonus/penalties for strength on the "to hit" roll */ -str_plus(str) -register short str; +int +str_plus(short str) { return((str-10)/3); } @@ -908,8 +903,8 @@ register short str; * compute additional damage done for exceptionally high or low strength */ -add_dam(str) -register short str; +int +add_dam(short str) { return((str-9)/2); } @@ -919,7 +914,8 @@ register short str; * Calculate damage depending on players hungry state */ -hung_dam() +int +hung_dam(void) { reg int howmuch = 0; @@ -938,8 +934,8 @@ hung_dam() * Returns true if an object radiates magic */ -is_magic(obj) -register struct object *obj; +bool +is_magic(struct object *obj) { switch (obj->o_type) { @@ -963,9 +959,8 @@ register struct object *obj; * Called to put a monster to death */ -killed(item, pr, points, treasure) -register struct linked_list *item; -bool pr, points, treasure; +void +killed(struct linked_list *item, bool pr, bool points, bool treasure) { register struct thing *tp, *mp; register struct linked_list *pitem, *nexti, *mitem; @@ -1115,9 +1110,7 @@ bool pr, points, treasure; */ struct linked_list * -wield_weap(thrown, mp) -struct object *thrown; -struct thing *mp; +wield_weap(struct object *thrown, struct thing *mp) { int look_for = 0, /* The projectile weapon we are looking for */ new_rate, /* The rating of a prospective weapon */ @@ -1198,8 +1191,9 @@ struct thing *mp; return(candidate); } -explode(tp) -register struct thing *tp; + +void +explode(struct thing *tp) { register int x,y, damage; @@ -1253,11 +1247,8 @@ register struct thing *tp; * Called when one monster attacks another monster. */ -skirmish(attacker, mp, weap, thrown) -register struct thing *attacker; -register coord *mp; -struct object *weap; -bool thrown; +bool +skirmish(struct thing *attacker, coord *mp, struct object *weap, bool thrown) { register struct thing *defender; register struct linked_list *item; diff --git a/xrogue/help.c b/xrogue/help.c index 4110e60..5603ba1 100644 --- a/xrogue/help.c +++ b/xrogue/help.c @@ -299,7 +299,8 @@ static struct item_list item_help[] = { 0, 0 }; -ident_hero() +void +ident_hero(void) { bool doit = TRUE; @@ -475,7 +476,8 @@ ident_hero() * Real Help */ -help() +void +help(void) { register struct h_list *strp = helpstr; register struct item_list *itemp = item_help; @@ -587,8 +589,8 @@ help() * Tell the player what a certain thing is. */ -identify(ch) -register unsigned char ch; +void +identify(unsigned char ch) { register char *str = NULL; diff --git a/xrogue/init.c b/xrogue/init.c index 921b35b..374ffce 100644 --- a/xrogue/init.c +++ b/xrogue/init.c @@ -105,10 +105,8 @@ struct words metal[NMETAL] = { * right amounts */ -badcheck(name, magic, bound) -char *name; -register struct magic_item *magic; -register int bound; +void +badcheck(char *name, struct magic_item *magic, int bound) { register struct magic_item *end; @@ -128,7 +126,8 @@ register int bound; * Initialize the potion color scheme for this time */ -init_colors() +void +init_colors(void) { register int i; register char *str; @@ -152,7 +151,8 @@ init_colors() * do any initialization for food */ -init_foods() +void +init_foods(void) { register int i; @@ -168,7 +168,8 @@ init_foods() * Initialize the construction materials for wands and staffs */ -init_materials() +void +init_materials(void) { register int i; register char *str; @@ -203,7 +204,8 @@ init_materials() * do any initialization for miscellaneous magic */ -init_misc() +void +init_misc(void) { register int i; @@ -221,7 +223,8 @@ init_misc() * Generate the names of the various scrolls */ -init_names() +void +init_names(void) { register int nsyl; register char *cp, *sp; @@ -258,7 +261,8 @@ init_names() * roll up the rogue */ -init_player() +void +init_player(void) { int stat_total, round = 0, minimum, maximum, ch, i, j = 0; short do_escape, *our_stats[NUMABILITIES-1]; @@ -790,7 +794,8 @@ init_player() * Initialize the ring stone setting scheme for this time */ -init_stones() +void +init_stones(void) { register int i; register char *str; @@ -815,7 +820,8 @@ init_stones() * Initialize the probabilities for types of things */ -init_things() +void +init_things(void) { register struct magic_item *mp; diff --git a/xrogue/io.c b/xrogue/io.c index 8e7102e..2c8399a 100644 --- a/xrogue/io.c +++ b/xrogue/io.c @@ -22,6 +22,8 @@ #include #include "rogue.h" +void doadd(char *fmt, va_list ap); + /* * msg: * Display a message at the top of the screen. @@ -77,7 +79,8 @@ addmsg(char *fmt, ...) * player with the --More-- string. Then erase the message. */ -rmmsg() +void +rmmsg(void) { if (mpos) { wclear(msgw); @@ -96,7 +99,8 @@ rmmsg() * is up there with the --More--) */ -endmsg() +void +endmsg(void) { /* Needed to track where we are for 5.0 (PC) curses */ register int x, y; @@ -141,6 +145,7 @@ endmsg() draw(msgw); } +void doadd(char *fmt, va_list ap) { vsprintf((char *) &msgbuf[newpos], fmt, ap); @@ -153,9 +158,8 @@ doadd(char *fmt, va_list ap) * flgptr will be NULL if we don't know what the monster is yet! */ -step_ok(y, x, can_on_monst, flgptr) -register int y, x, can_on_monst; -register struct thing *flgptr; +bool +step_ok(int y, int x, int can_on_monst, struct thing *flgptr) { /* can_on_monst = MONSTOK if all we care about are physical obstacles */ register struct linked_list *item; @@ -222,6 +226,7 @@ register struct thing *flgptr; * returns true if it is ok for type to shoot over ch */ +bool shoot_ok(int ch) { switch (ch) @@ -240,10 +245,11 @@ shoot_ok(int ch) /* * status: * Display the important stats line. Keep the cursor where it was. + * display: is TRUE, display unconditionally */ -status(display) -bool display; /* is TRUE, display unconditionally */ +void +status(bool display) { register struct stats *stat_ptr, *max_ptr; register int oy = 0, ox = 0, temp; @@ -377,8 +383,8 @@ line_two: * Sit around until the guy types the right key */ -wait_for(ch) -register char ch; +void +wait_for(char ch) { register char c; @@ -407,10 +413,9 @@ register char ch; * typed and then redraw the starting screen. */ -over_win(oldwin, newin, maxy, maxx, cursory, cursorx, redraw) -WINDOW *oldwin, *newin; -int maxy, maxx, cursory, cursorx; -char redraw; +void +over_win(WINDOW *oldwin, WINDOW *newin, int maxy, int maxx, int cursory, + int cursorx, char redraw) { char blanks[LINELEN+1]; register int line, i; @@ -460,9 +465,8 @@ char redraw; * function used to display a window and wait before returning */ -show_win(scr, message) -register WINDOW *scr; -char *message; +void +show_win(WINDOW *scr, char *message) { mvwaddstr(scr, 0, 0, message); touchwin(scr); @@ -477,9 +481,8 @@ char *message; * Displays message on bottom line and waits for a space to return */ -dbotline(scr,message) -WINDOW *scr; -char *message; +void +dbotline(WINDOW *scr, char *message) { mvwaddstr(scr,lines-1,0,message); draw(scr); @@ -491,8 +494,8 @@ char *message; * Restores the screen to the terminal */ -restscr(scr) -WINDOW *scr; +void +restscr(WINDOW *scr) { clearok(scr,TRUE); touchwin(scr); @@ -506,10 +509,7 @@ WINDOW *scr; */ unsigned long -netread(error, size, stream) -int *error; -int size; -FILE *stream; +netread(int *error, int size, FILE *stream) { unsigned long result = 0L, /* What we read in */ partial; /* Partial value */ @@ -542,12 +542,13 @@ FILE *stream; /* * netwrite: * Write out a byte, short, or long machine independently. + * value: What to write + * size: How much to write out + * stream: Where to write it */ -netwrite(value, size, stream) -unsigned long value; /* What to write */ -int size; /* How much to write out */ -FILE *stream; /* Where to write it */ +int +netwrite(unsigned long value, int size, FILE *stream) { int i; /* Goes through value one byte at a time */ char outc; /* The next character to be written */ diff --git a/xrogue/list.c b/xrogue/list.c index 4c3868b..7022e48 100644 --- a/xrogue/list.c +++ b/xrogue/list.c @@ -21,13 +21,16 @@ #include #include "rogue.h" +void r_discard(struct linked_list *item); +void t_discard(struct linked_list *item); + /* * detach: * Takes an item out of whatever linked list it might be in */ -_detach(list, item) -register struct linked_list **list, *item; +void +_detach(struct linked_list **list, struct linked_list *item) { if (*list == item) *list = next(item); @@ -42,8 +45,8 @@ register struct linked_list **list, *item; * add an item to the head of a list */ -_attach(list, item) -register struct linked_list **list, *item; +void +_attach(struct linked_list **list, struct linked_list *item) { if (*list != NULL) { @@ -65,8 +68,8 @@ register struct linked_list **list, *item; * Throw the whole object list away */ -_o_free_list(ptr) -register struct linked_list **ptr; +void +_o_free_list(struct linked_list **ptr) { register struct linked_list *item; @@ -83,8 +86,8 @@ register struct linked_list **ptr; * free up an item and its object(and maybe contents) */ -o_discard(item) -register struct linked_list *item; +void +o_discard(struct linked_list *item) { register struct object *obj; @@ -102,8 +105,8 @@ register struct linked_list *item; discard the item (monster) itself as that belong to mlist. */ -_r_free_fire_list(ptr) -register struct linked_list **ptr; +void +_r_free_fire_list(struct linked_list **ptr) { register struct linked_list *item; @@ -119,8 +122,8 @@ register struct linked_list **ptr; * Throw the whole list of room exits away */ -_r_free_list(ptr) -register struct linked_list **ptr; +void +_r_free_list(struct linked_list **ptr) { register struct linked_list *item; @@ -137,8 +140,8 @@ register struct linked_list **ptr; * free up an item and its room */ -r_discard(item) -register struct linked_list *item; +void +r_discard(struct linked_list *item) { total -= 2; FREE(DOORPTR(item)); @@ -150,8 +153,8 @@ register struct linked_list *item; * Throw the whole thing list away */ -_t_free_list(ptr) -register struct linked_list **ptr; +void +_t_free_list(struct linked_list **ptr) { register struct linked_list *item; @@ -168,8 +171,8 @@ register struct linked_list **ptr; * free up an item and its thing */ -t_discard(item) -register struct linked_list *item; +void +t_discard(struct linked_list *item) { register struct thing *tp; @@ -187,8 +190,8 @@ register struct linked_list *item; * get rid of an item structure -- don't worry about contents */ -destroy_item(item) -register struct linked_list *item; +void +destroy_item(struct linked_list *item) { total--; FREE(item); @@ -200,8 +203,7 @@ register struct linked_list *item; */ struct linked_list * -new_item(size) -int size; +new_item(int size) { register struct linked_list *item; @@ -220,7 +222,7 @@ int size; */ struct linked_list * -creat_item() +creat_item(void) { register struct linked_list *item; @@ -231,8 +233,7 @@ creat_item() } char * -new(size) -int size; +new(int size) { register char *space = ALLOC(size); diff --git a/xrogue/main.c b/xrogue/main.c index e39669f..8ffb759 100644 --- a/xrogue/main.c +++ b/xrogue/main.c @@ -27,10 +27,13 @@ #include "rogue.h" void open_records(void); +bool too_much(void); +bool author(void); +bool playtime(void); +bool betaover(void); -main(argc, argv, envp) -char **argv; -char **envp; +int +main(int argc, char *argv[], char *envp[]) { register char *env; time_t now; @@ -283,10 +286,8 @@ char **envp; * Exit the program abnormally. */ -/*UNUSED*/ void -endit(sig) -int sig; +endit(int sig) { NOOP(sig); fatal("Ok, if you want to exit that badly, I'll have to allow it\n"); @@ -297,8 +298,8 @@ int sig; * Exit the program, printing a message. */ -fatal(s) -char *s; +void +fatal(char *s) { clear(); move(lines-2, 0); @@ -313,8 +314,8 @@ char *s; * Pick a very random number. */ -rnd(range) -register int range; +int +rnd(int range) { return( md_rand(range) ); } @@ -324,8 +325,8 @@ register int range; * roll a number of dice */ -roll(number, sides) -register int number, sides; +int +roll(int number, int sides) { register int dtotal = 0; @@ -334,7 +335,8 @@ register int number, sides; return dtotal; } -setup() +void +setup(void) { md_setup(); } @@ -345,7 +347,8 @@ setup() * refreshing things and looking at the proper times. */ -playit() +void +playit(void) { register char *opts; @@ -366,7 +369,8 @@ playit() * see if the system is being used too much for this game */ -too_much() +bool +too_much(void) { /* we no longer do load checking or user counts */ return(FALSE); @@ -377,7 +381,8 @@ too_much() * See if a user is an author of the program */ -author() +bool +author(void) { switch (md_getuid()) { case 0: /* always OK for root to play */ @@ -392,7 +397,8 @@ author() * Returns TRUE when it is a good time to play rogue */ -playtime() +bool +playtime(void) { /* we no longer do playtime checking */ @@ -404,14 +410,15 @@ playtime() * Returns TRUE if the test period of this version of the game is over */ -betaover() +bool +betaover(void) { return(FALSE); } -exit_game(flag) -int flag; +void +exit_game(int flag) { int i; diff --git a/xrogue/maze.c b/xrogue/maze.c index 3052df9..01e8895 100644 --- a/xrogue/maze.c +++ b/xrogue/maze.c @@ -27,8 +27,11 @@ struct b_cellscells { static char *maze_frontier, *maze_bits; static int maze_lines, maze_cols; -static char *moffset(), *foffset(); -static int rmwall(),findcells(),crankout(),draw_maze(); +static char *moffset(int y, int x); +static char *foffset(int y, int x); +static void rmwall(int newy, int newx, int oldy, int oldx); +static void draw_maze(void); +static int findcells(int y, int x); /* * crankout: @@ -36,7 +39,8 @@ static int rmwall(),findcells(),crankout(),draw_maze(); */ static -crankout() +void +crankout(void) { reg int x, y; @@ -70,7 +74,8 @@ crankout() * Draw the maze on this level. */ -do_maze() +void +do_maze(void) { reg int least; reg struct room *rp; @@ -94,7 +99,7 @@ do_maze() /* * add some gold to make it worth looking for */ - item = spec_item(GOLD, NULL, NULL, NULL); + item = spec_item(GOLD, 0, 0, 0); obj = OBJPTR(item); obj->o_count *= (rnd(50) + 50); /* add in one large hunk */ attach(lvl_obj, item); @@ -107,7 +112,7 @@ do_maze() /* * add in some food to make sure he has enough */ - item = spec_item(FOOD, NULL, NULL, NULL); + item = spec_item(FOOD, 0, 0, 0); obj = OBJPTR(item); attach(lvl_obj, item); do { @@ -146,7 +151,8 @@ do_maze() */ static -draw_maze() +void +draw_maze(void) { reg int i, j, more; reg char *ptr; @@ -183,8 +189,8 @@ draw_maze() * Figure out cells to open up */ -static findcells(y,x) -reg int x, y; +static int +findcells(int y, int x) { reg int rtpos, i; @@ -236,8 +242,7 @@ reg int x, y; */ static char * -foffset(y, x) -int y, x; +foffset(int y, int x) { return (maze_frontier + (y * maze_cols) + x); @@ -251,8 +256,7 @@ int y, x; */ bool -maze_view(y, x) -int y, x; +maze_view(int y, int x) { register int start, goal, delta, ycheck = 0, xcheck = 0, absy, absx, see_radius; register bool row; @@ -360,8 +364,7 @@ int y, x; */ static char * -moffset(y, x) -int y, x; +moffset(int y, int x) { return (maze_bits + (y * (cols - 1)) + x); } @@ -371,8 +374,8 @@ int y, x; * Removes appropriate walls from the maze */ static -rmwall(newy, newx, oldy, oldx) -int newy, newx, oldy, oldx; +void +rmwall(int newy, int newx, int oldy, int oldx) { reg int xdif,ydif; diff --git a/xrogue/misc.c b/xrogue/misc.c index a893d81..1ffaffc 100644 --- a/xrogue/misc.c +++ b/xrogue/misc.c @@ -23,8 +23,8 @@ * Change the player's class to the specified one. */ -changeclass(newclass) -long *newclass; +void +changeclass(long *newclass) { if (*newclass == player.t_ctype) { msg("You feel more skillful."); @@ -152,8 +152,8 @@ long *newclass; * Use the relic that our monster is wielding. */ -m_use_relic(monster) -register struct thing *monster; +void +m_use_relic(struct thing *monster) { register struct object *obj; @@ -181,7 +181,7 @@ register struct thing *monster; } when EMORI_CLOAK: debug("stunning with Emori's cloak"); - do_zap(monster, obj, &monster->t_newpos, WS_PARALYZE, NULL); + do_zap(monster, obj, &monster->t_newpos, WS_PARALYZE, 0); obj->o_charges = 0; when ASMO_ROD: { @@ -248,11 +248,12 @@ register struct thing *monster; /* * add something to the contents of something else + * bag: the holder of the items + * item: the item to put inside */ -put_contents(bag, item) -register struct object *bag; /* the holder of the items */ -register struct linked_list *item; /* the item to put inside */ +void +put_contents(struct object *bag, struct linked_list *item) { register struct linked_list *titem; register struct object *tobj; @@ -277,11 +278,11 @@ register struct linked_list *item; /* the item to put inside */ /* * remove something from something else + * bag: the holder of the items */ -take_contents(bag, item) -register struct object *bag; /* the holder of the items */ -register struct linked_list *item; +void +take_contents(struct object *bag, struct linked_list *item) { if (bag->o_ac <= 0) { @@ -295,8 +296,8 @@ register struct linked_list *item; } -do_bag(item) -register struct linked_list *item; +void +do_bag(struct linked_list *item) { register struct linked_list *titem = NULL; @@ -417,9 +418,10 @@ register struct linked_list *item; } } -do_panic(who) -int who; /* Kind of monster to panic (all if who is NULL) */ +void +do_panic(int who) { + /* who: kind of monster to panic (all if who is 0) */ register int x,y; register struct linked_list *mon, *item; register struct thing *th; @@ -485,9 +487,7 @@ int who; /* Kind of monster to panic (all if who is NULL) */ */ int -misc_name(str,obj) -char *str; -register struct object *obj; +misc_name(char *str, struct object *obj) { char buf1[LINELEN]; @@ -565,7 +565,8 @@ register struct object *obj; return(0); } -use_emori() +void +use_emori(void) { char selection; /* Cloak function */ int state = 0; /* Menu state */ @@ -669,8 +670,8 @@ use_emori() * try to write a scroll with the quill of Nagrom */ -use_quill(obj) -struct object *obj; +void +use_quill(struct object *obj) { struct linked_list *item; register int i, @@ -761,7 +762,7 @@ struct object *obj; /* Should we overlay? */ if (menu_overlay && MAXQUILL + 3 < lines - 3) { - over_win(cw, hw, MAXQUILL + 5, maxlen + 3, 0, curlen, NULL); + over_win(cw, hw, MAXQUILL + 5, maxlen + 3, 0, curlen, '\0'); } else draw(hw); } @@ -789,7 +790,7 @@ struct object *obj; /* Should we overlay? */ if (menu_overlay && MAXQUILL + 3 < lines - 3) { over_win(cw, hw, MAXQUILL + 5, maxlen + 3, - 0, curlen, NULL); + 0, curlen, '\0'); } else draw(hw); @@ -830,8 +831,8 @@ struct object *obj; * Use something */ -use_mm(which) -int which; +void +use_mm(int which) { register struct object *obj = NULL; register struct linked_list *item = NULL; @@ -907,7 +908,7 @@ int which; when GERYON_HORN: /* Chase close monsters away */ msg("The horn blasts a shrill tone."); - do_panic(NULL); + do_panic(0); when EYE_VECNA: msg("The pain slowly subsides.. "); when HEIL_ANKH: @@ -934,7 +935,7 @@ int which; msg("The jug is empty"); break; } - quaff (obj->o_ac, NULL, NULL, FALSE); + quaff (obj->o_ac, 0, 0, FALSE); obj->o_ac = JUG_EMPTY; fuse (alchemy, obj, ALCHEMYTIME, AFTER); if (!(obj->o_flags & ISKNOW)) @@ -1012,7 +1013,7 @@ int which; break; } obj->o_charges--; - do_panic(NULL); + do_panic(0); return; /* * dust of disappearance makes the player invisible for a while @@ -1140,7 +1141,7 @@ int which; str = "vibrates softly"; msg("You rub the crystal and it %s... ", str); /* cure him */ - read_scroll(S_CURING, NULL, FALSE); + read_scroll(S_CURING, 0, FALSE); /* give him weird hands */ turn_on(player, CANHUH); msg("Your fingertips turn blue. "); @@ -1218,8 +1219,7 @@ int which; */ int -usage_time(item) -struct linked_list *item; +usage_time(struct linked_list *item) { register struct object *obj; register int units = -1; diff --git a/xrogue/monsters.c b/xrogue/monsters.c index 72660c5..db3c9d6 100644 --- a/xrogue/monsters.c +++ b/xrogue/monsters.c @@ -19,14 +19,15 @@ #include #include #include +#include #include "rogue.h" /* * Check_residue takes care of any effect of the monster */ -check_residue(tp) -register struct thing *tp; +void +check_residue(struct thing *tp) { /* * Take care of special abilities @@ -70,13 +71,11 @@ register struct thing *tp; /* * Creat_mons creates the specified monster -- any if 0 + * person: where to create next to */ bool -creat_mons(person, monster, report) -struct thing *person; /* Where to create next to */ -short monster; -bool report; +creat_mons(struct thing *person, short monster, bool report) { struct linked_list *nitem; register struct thing *tp; @@ -131,9 +130,7 @@ bool report; */ void -genmonsters(least, treas) -register int least; -bool treas; +genmonsters(int least, bool treas) { reg int i; reg struct room *rp = &rooms[0]; @@ -180,8 +177,7 @@ bool treas; */ short -id_monst(monster) -register char monster; +id_monst(char monster) { register short result; @@ -215,11 +211,8 @@ register char monster; * Pick a new monster and add it to the list */ -new_monster(item, type, cp, max_monster) -struct linked_list *item; -short type; -coord *cp; -bool max_monster; +void +new_monster(struct linked_list *item, short type, coord *cp, bool max_monster) { register struct thing *tp; register struct monster *mp; @@ -428,8 +421,7 @@ bool max_monster; */ short -randmonster(wander, no_unique) -register bool wander, no_unique; +randmonster(bool wander, bool no_unique) { register int d, cur_level, range, i; @@ -491,8 +483,8 @@ register bool wander, no_unique; * to purchase something. */ -sell(tp) -register struct thing *tp; +void +sell(struct thing *tp) { register struct linked_list *item, *seller; register struct linked_list *sellpack; @@ -588,8 +580,7 @@ register struct thing *tp; */ struct linked_list * -wake_monster(y, x) -int y, x; +wake_monster(int y, int x) { register struct thing *tp; register struct linked_list *it; @@ -786,7 +777,8 @@ int y, x; * A wandering monster has awakened and is headed for the player */ -wanderer() +void +wanderer(void) { register int i; register struct room *hr = roomin(&hero); diff --git a/xrogue/move.c b/xrogue/move.c index 0b8d164..8bd4296 100644 --- a/xrogue/move.c +++ b/xrogue/move.c @@ -18,6 +18,7 @@ #include #include +#include #include "rogue.h" /* @@ -37,9 +38,8 @@ static char Moves[3][3] = { * The guy stepped on a trap.... Make him pay. */ -be_trapped(th, tc) -register struct thing *th; -register coord *tc; +char +be_trapped(struct thing *th, coord *tc) { register struct trap *tp; register char ch, *mname = NULL; @@ -504,8 +504,7 @@ register coord *tc; */ bool -blue_light(blessed, cursed) -bool blessed, cursed; +blue_light(bool blessed, bool cursed) { register struct room *rp; bool ret_val=FALSE; /* Whether or not affect is known */ @@ -563,8 +562,8 @@ bool blessed, cursed; * If not, if player came from a legal place, then try to turn him. */ -corr_move(dy, dx) -int dy, dx; +void +corr_move(int dy, int dx) { int legal=0; /* Number of legal alternatives */ register int y, x, /* Indexes though possible positions */ @@ -642,7 +641,8 @@ int dy, dx; * Dip an object into a magic pool */ -dip_it() +void +dip_it(void) { reg struct linked_list *what; reg struct object *ob; @@ -839,8 +839,8 @@ dip_it() * consequences (fighting, picking up, etc.) */ -do_move(dy, dx) -int dy, dx; +void +do_move(int dy, int dx) { register struct room *rp, *orp; register unsigned char ch; @@ -1189,8 +1189,8 @@ int dy, dx; * Start the hero running */ -do_run(ch) -char ch; +void +do_run(char ch) { firstmove = TRUE; running = TRUE; @@ -1206,9 +1206,7 @@ char ch; */ bool -getdelta(match, dy, dx) -char match; -int *dy, *dx; +getdelta(char match, int *dy, int *dx) { register int y, x; @@ -1228,8 +1226,8 @@ int *dy, *dx; * Returns TRUE if this character is some kind of trap */ -isatrap(ch) -reg char ch; +bool +isatrap(char ch) { switch(ch) { case WORMHOLE: @@ -1250,8 +1248,8 @@ reg char ch; * If it is dark, remove anything that might move. */ -light(cp) -coord *cp; +void +light(coord *cp) { register struct room *rp; register int j, k, x, y; @@ -1428,8 +1426,7 @@ coord *cp; */ bool -lit_room(rp) -register struct room *rp; +lit_room(struct room *rp) { register struct linked_list *fire_item; register struct thing *fire_creature; @@ -1466,8 +1463,7 @@ register struct room *rp; */ short -movement(tp) -register struct thing *tp; +movement(struct thing *tp) { register int result; register int carry; /* Percentage carried */ @@ -1531,8 +1527,7 @@ register struct thing *tp; */ coord -rndmove(who) -struct thing *who; +rndmove(struct thing *who) { register int x, y; register int ex, ey, nopen = 0; @@ -1586,9 +1581,8 @@ static const char *trap_types[TRAPTYPES] = { * set a trap at (y, x) on screen. */ -set_trap(tp, y, x) -register struct thing *tp; -register int y, x; +void +set_trap(struct thing *tp, int y, int x) { register bool is_player = (tp == &player); register int selection = rnd(TRAPTYPES-WIZARDTRAPS) + '1'; @@ -1645,7 +1639,7 @@ register int y, x; * Put out the selection. The longest line is * the prompt line (39 characters long). */ - over_win(cw, hw, num_traps + 3, 41, 0, 39, NULL); + over_win(cw, hw, num_traps + 3, 41, 0, 39, '\0'); else draw(hw); state = 1; /* Now in prompt window */ @@ -1705,7 +1699,7 @@ register int y, x; * Put out the selection. The longest line is * the prompt line (43 characters long). */ - over_win(cw, hw, num_traps+3, 45, 0, 43, NULL); + over_win(cw, hw, num_traps+3, 45, 0, 43, '\0'); else draw(hw); } @@ -1778,8 +1772,8 @@ register int y, x; * returns what a certain thing will display as to the un-initiated */ -show(y, x) -register int y, x; +char +show(int y, int x) { register unsigned char ch = winat(y, x); register struct linked_list *it; @@ -1819,8 +1813,7 @@ register int y, x; */ struct trap * -trap_at(y, x) -register int y, x; +trap_at(int y, int x) { register struct trap *tp, *ep; @@ -1838,11 +1831,12 @@ register int y, x; * Calculate how many segments it will take to swing the given * weapon (note that the weapon may actually be a stick or * even something else). + * wielder: Who's wielding the weapon + * weap: The weapon */ -weap_move(wielder, weap) -register struct thing *wielder; /* Who's wielding the weapon */ -register struct object *weap; /* The weapon */ +int +weap_move(struct thing *wielder, struct object *weap) { register int weap_rate; int dexterity; diff --git a/xrogue/n_level.c b/xrogue/n_level.c index 48c3c0f..63ee6b9 100644 --- a/xrogue/n_level.c +++ b/xrogue/n_level.c @@ -20,13 +20,16 @@ #include "rogue.h" #define TERRASAVE 3 +void put_things(LEVTYPE ltype); + /* * new_level: * Dig and draw a new level + * ltype: designates type of level to create */ -new_level(ltype) -LEVTYPE ltype; /* designates type of level to create */ +void +new_level(LEVTYPE ltype) { register int rm = 0, i, cnt; register unsigned char ch; @@ -464,14 +467,15 @@ LEVTYPE ltype; /* designates type of level to create */ /* Do we sense any food on this level? */ if (cur_relic[SURTUR_RING]) - quaff(P_FFIND, NULL, NULL, FALSE); + quaff(P_FFIND, 0, 0, FALSE); } /* * Pick a room that is really there */ -rnd_room() +int +rnd_room(void) { register int rm; @@ -487,10 +491,11 @@ rnd_room() /* * put_things: * put potions and scrolls on this level + * ltype: designates type of level to create */ -put_things(ltype) -LEVTYPE ltype; /* designates type of level to create */ +void +put_things(LEVTYPE ltype) { register int i, rm, cnt; register struct object *cur; diff --git a/xrogue/network.h b/xrogue/network.h index d8bdedc..53eaa18 100644 --- a/xrogue/network.h +++ b/xrogue/network.h @@ -30,6 +30,6 @@ struct network { char *rogue; }; extern struct network Network[]; -extern unsigned long netread(); -extern unsigned long netwrite(); +extern unsigned long netread(int *error, int size, FILE *stream); +extern int netwrite(unsigned long value, int size, FILE *stream); diff --git a/xrogue/options.c b/xrogue/options.c index b93ae01..91497e9 100644 --- a/xrogue/options.c +++ b/xrogue/options.c @@ -41,16 +41,16 @@ struct optstruct { typedef struct optstruct OPTION; -int put_bool(), - get_bool(), - put_str(), - get_str(), - put_abil(), - get_abil(), - get_quest(), - put_quest(), - get_default(); - +int get_ro(WINDOW *win, int oy, int ox); +void put_bool(bool *b, WINDOW *win); +int get_bool(bool *bp, WINDOW *win); +void put_str(char *str, WINDOW *win); +int get_str(char *opt, WINDOW *win); +void put_abil(int *ability, WINDOW *win); +void get_abil(int *abil, WINDOW *win); +void put_quest(int *quest, WINDOW *win); +void get_quest(int *quest, WINDOW *win); +void get_default(bool *bp, WINDOW *win); int get_str_prot(char *opt, WINDOW *win); int get_score(char *opt, WINDOW *win); bool allowchange(OPTION *op); @@ -88,9 +88,8 @@ OPTION optlist[] = { * The default attribute field is read-only */ -get_default(bp, win) -bool *bp; -WINDOW *win; +void +get_default(bool *bp, WINDOW *win) { register int oy, ox; @@ -103,9 +102,8 @@ WINDOW *win; * The ability (class) field is read-only */ -get_abil(abil, win) -int *abil; -WINDOW *win; +void +get_abil(int *abil, WINDOW *win) { register int oy, ox; @@ -118,9 +116,8 @@ WINDOW *win; * The quest field is read-only */ -get_quest(quest, win) -int *quest; -WINDOW *win; +void +get_quest(int *quest, WINDOW *win) { register int oy, ox; @@ -134,9 +131,8 @@ WINDOW *win; * "Get" a read-only value. */ -get_ro(win, oy, ox) -WINDOW *win; -register int oy, ox; +int +get_ro(WINDOW *win, int oy, int ox) { register int ny, nx; register bool op_bad; @@ -173,9 +169,8 @@ register int oy, ox; * allow changing a boolean option and print it out */ -get_bool(bp, win) -bool *bp; -WINDOW *win; +int +get_bool(bool *bp, WINDOW *win) { register int oy, ox; register bool op_bad; @@ -223,9 +218,8 @@ WINDOW *win; * set a string option */ -get_str(opt, win) -register char *opt; -WINDOW *win; +int +get_str(char *opt, WINDOW *win) { register char *sp; register int c, oy, ox; @@ -298,7 +292,8 @@ WINDOW *win; * print and then set options from the terminal */ -option() +void +option(void) { register OPTION *op; register int retval; @@ -356,8 +351,8 @@ option() * or the end of the entire option string. */ -parse_opts(str) -register char *str; +void +parse_opts(char *str) { register char *sp; register OPTION *op; @@ -466,9 +461,8 @@ register char *str; * print the character type */ -put_abil(ability, win) -int *ability; -WINDOW *win; +void +put_abil(int *ability, WINDOW *win) { waddstr(win, char_class[*ability].name); } @@ -477,9 +471,8 @@ WINDOW *win; * print out the quest */ -put_quest(quest, win) -int *quest; -WINDOW *win; +void +put_quest(int *quest, WINDOW *win) { waddstr(win, rel_magic[*quest].mi_name); } @@ -488,9 +481,8 @@ WINDOW *win; * put out a boolean */ -put_bool(b, win) -bool *b; -WINDOW *win; +void +put_bool(bool *b, WINDOW *win) { waddstr(win, *b ? "True" : "False"); } @@ -499,9 +491,8 @@ WINDOW *win; * put out a string */ -put_str(str, win) -char *str; -WINDOW *win; +void +put_str(char *str, WINDOW *win) { waddstr(win, str); } diff --git a/xrogue/outside.c b/xrogue/outside.c index 93478e4..f3c2721 100644 --- a/xrogue/outside.c +++ b/xrogue/outside.c @@ -15,7 +15,8 @@ #include #include "rogue.h" -extern char rnd_terrain(), get_terrain(); +char rnd_terrain(void); +char get_terrain(char one, char two, char three, char four); /* * init_terrain: @@ -23,7 +24,7 @@ extern char rnd_terrain(), get_terrain(); */ void -init_terrain() +init_terrain(void) { register struct room *rp; @@ -40,9 +41,7 @@ init_terrain() } void -do_terrain(basey, basex, deltay, deltax, fresh) -int basey, basex, deltay, deltax; -bool fresh; +do_terrain(int basey, int basex, int deltay, int deltax, bool fresh) { register int cury, curx; /* Current y and x positions */ @@ -140,7 +139,7 @@ bool fresh; */ char -rnd_terrain() +rnd_terrain(void) { int chance = rnd(100); @@ -164,8 +163,7 @@ rnd_terrain() */ char -get_terrain(one, two, three, four) -char one, two, three, four; +get_terrain(char one, char two, char three, char four) { register int i; int forest = 0, mountain = 0, lake = 0, meadow = 0, total = 0; diff --git a/xrogue/pack.c b/xrogue/pack.c index 0f70e5a..0129c73 100644 --- a/xrogue/pack.c +++ b/xrogue/pack.c @@ -21,6 +21,8 @@ #include #include "rogue.h" +bool is_type(struct object *obj, int type); + /* * add_pack: * Pick up an object and add it to the pack. If the argument is non-null @@ -28,9 +30,7 @@ */ bool -add_pack(item, silent) -register struct linked_list *item; -bool silent; +add_pack(struct linked_list *item, bool silent) { register struct linked_list *ip, *lp = NULL, *ap; register struct object *obj, *op = NULL; @@ -462,9 +462,8 @@ picked_up: * list what is in the pack */ -inventory(list, type) -register struct linked_list *list; -register int type; +bool +inventory(struct linked_list *list, int type) { register struct object *obj; register char ch; @@ -563,7 +562,7 @@ register int type; */ void -picky_inven() +picky_inven(void) { register struct linked_list *item; register char ch, mch; @@ -616,14 +615,12 @@ picky_inven() /* * get_item: * pick something out of a pack for a purpose + * purpose: NULL if we should be silent (no prompts) */ struct linked_list * -get_item(list, purpose, type, askfirst, showcost) -reg struct linked_list *list; -char *purpose; /* NULL if we should be silent (no prompts) */ -int type; -bool askfirst, showcost; +get_item(struct linked_list *list, char *purpose, int type, bool askfirst, + bool showcost) { reg struct linked_list *item; reg struct object *obj; @@ -755,7 +752,7 @@ bool askfirst, showcost; /* Write the screen */ if ((menu_overlay && cnt < lines - 3) || cnt == 1) { - over_win(cw, hw, cnt + 2, maxx + 3, cnt, curx, NULL); + over_win(cw, hw, cnt + 2, maxx + 3, cnt, curx, '\0'); cnt = -1; /* Indicate we used over_win */ } else draw(hw); @@ -814,9 +811,8 @@ bool askfirst, showcost; } } -pack_char(list, obj) -register struct object *obj; -struct linked_list *list; +char +pack_char(struct linked_list *list, struct object *obj) { register struct linked_list *item; register char c; @@ -838,8 +834,8 @@ struct linked_list *list; * This updates cur_weapon etc for dropping things */ -cur_null(op) -reg struct object *op; +void +cur_null(struct object *op) { if (op == cur_weapon) cur_weapon = NULL; else if (op == cur_armor) cur_armor = NULL; @@ -864,7 +860,8 @@ reg struct object *op; * Identify all the items in the pack */ -idenpack() +void +idenpack(void) { reg struct linked_list *pc; @@ -872,9 +869,8 @@ idenpack() whatis(pc); } -is_type (obj, type) -register struct object *obj; -register int type; +bool +is_type(struct object *obj, int type) { register bool current; @@ -1029,8 +1025,8 @@ register int type; return(FALSE); } -del_pack(item) -register struct linked_list *item; +void +del_pack(struct linked_list *item) { register struct object *obj; @@ -1052,9 +1048,8 @@ register struct linked_list *item; * it to him. */ -carry_obj(mp, chance) -register struct thing *mp; -int chance; +void +carry_obj(struct thing *mp, int chance) { reg struct linked_list *item; reg struct object *obj; @@ -1077,75 +1072,75 @@ int chance; */ if (on(*mp, ISUNIQUE)) { if (on(*mp, CARRYMDAGGER)) { - item = spec_item(RELIC, MUSTY_DAGGER, NULL, NULL); + item = spec_item(RELIC, MUSTY_DAGGER, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYCLOAK)) { - item = spec_item(RELIC, EMORI_CLOAK, NULL, NULL); + item = spec_item(RELIC, EMORI_CLOAK, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYANKH)) { - item = spec_item(RELIC, HEIL_ANKH, NULL, NULL); + item = spec_item(RELIC, HEIL_ANKH, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYSTAFF)) { - item = spec_item(RELIC, MING_STAFF, NULL, NULL); + item = spec_item(RELIC, MING_STAFF, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYWAND)) { - item = spec_item(RELIC, ORCUS_WAND, NULL, NULL); + item = spec_item(RELIC, ORCUS_WAND, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYROD)) { - item = spec_item(RELIC, ASMO_ROD, NULL, NULL); + item = spec_item(RELIC, ASMO_ROD, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYYAMULET)) { - item = spec_item(RELIC, YENDOR_AMULET, NULL, NULL); + item = spec_item(RELIC, YENDOR_AMULET, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYBAMULET)) { - item = spec_item(RELIC, STONEBONES_AMULET, NULL, NULL); + item = spec_item(RELIC, STONEBONES_AMULET, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYMANDOLIN)) { - item = spec_item(RELIC, BRIAN_MANDOLIN, NULL, NULL); + item = spec_item(RELIC, BRIAN_MANDOLIN, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYEYE)) { - item = spec_item(RELIC, EYE_VECNA, NULL, NULL); + item = spec_item(RELIC, EYE_VECNA, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYAXE)) { - item = spec_item(RELIC, AXE_AKLAD, NULL, NULL); + item = spec_item(RELIC, AXE_AKLAD, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); @@ -1153,7 +1148,7 @@ int chance; if (on(*mp, CARRYQUILL)) { register int i, howmany; - item = spec_item(RELIC, QUILL_NAGROM, NULL, NULL); + item = spec_item(RELIC, QUILL_NAGROM, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; obj->o_charges = rnd(QUILLCHARGES); @@ -1170,31 +1165,31 @@ int chance; } } if (on(*mp, CARRYMSTAR)) { - item = spec_item(RELIC, HRUGGEK_MSTAR, NULL, NULL); + item = spec_item(RELIC, HRUGGEK_MSTAR, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYFLAIL)) { - item = spec_item(RELIC, YEENOGHU_FLAIL, NULL, NULL); + item = spec_item(RELIC, YEENOGHU_FLAIL, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYHORN)) { - item = spec_item(RELIC, GERYON_HORN, NULL, NULL); + item = spec_item(RELIC, GERYON_HORN, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYSURTURRING)) { - item = spec_item(RELIC, SURTUR_RING, NULL, NULL); + item = spec_item(RELIC, SURTUR_RING, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); } if (on(*mp, CARRYCARD)) { - item = spec_item(RELIC, ALTERAN_CARD, NULL, NULL); + item = spec_item(RELIC, ALTERAN_CARD, 0, 0); obj = OBJPTR(item); obj->o_pos = mp->t_pos; attach(mp->t_pack, item); @@ -1204,7 +1199,7 @@ int chance; * If it carries gold, give it some */ if (on(*mp, CARRYGOLD) && rnd(100) < chance) { - item = spec_item(GOLD, NULL, NULL, NULL); + item = spec_item(GOLD, 0, 0, 0); obj = OBJPTR(item); obj->o_count = GOLDCALC + GOLDCALC; obj->o_pos = mp->t_pos; @@ -1232,7 +1227,7 @@ int chance; when 40: type = E_SLIMEMOLD; /* monster food */ otherwise: type = E_RATION; } - item = spec_item(FOOD, type, NULL, NULL); + item = spec_item(FOOD, type, 0, 0); obj = OBJPTR(item); obj->o_weight = things[TYP_FOOD].mi_wght; obj->o_pos = mp->t_pos; @@ -1356,8 +1351,8 @@ int chance; * he wants (* means everything). */ -grab(y, x) -register int y, x; +int +grab(int y, int x) { register struct linked_list *next_item, *item; register struct object *obj; @@ -1425,7 +1420,7 @@ register int y, x; * Leave 3 blank lines at the bottom and 3 blank columns to he right. */ if (menu_overlay && num_there < lines - 3) { - over_win(cw, hw, num_there + 2, maxlen + 3, num_there, curlen, NULL); + over_win(cw, hw, num_there + 2, maxlen + 3, num_there, curlen, '\0'); pagecnt = -1; /* Indicate we used over_win */ } else draw(hw); /* write screen */ @@ -1474,7 +1469,7 @@ register int y, x; */ if (menu_overlay && num_there < lines - 3) { over_win(cw, hw, num_there + 2, maxlen + 3, - num_there, 49, NULL); + num_there, 49, '\0'); cnt = -1; /* Indicate we used over_win */ } else draw(hw); /* write screen */ @@ -1513,8 +1508,8 @@ register int y, x; * Create a pack for sellers (a la quartermaster) */ -make_sell_pack(tp) -struct thing *tp; +void +make_sell_pack(struct thing *tp) { reg struct linked_list *item; reg struct object *obj; diff --git a/xrogue/passages.c b/xrogue/passages.c index d7ef63a..26e7812 100644 --- a/xrogue/passages.c +++ b/xrogue/passages.c @@ -16,15 +16,20 @@ See the file LICENSE.TXT for full copyright and licensing information. */ +#include #include #include "rogue.h" +void conn(int r1, int r2); +void door(struct room *rm, coord *cp); + /* * do_passages: * Draw all the passages on a level. */ -do_passages() +void +do_passages(void) { register struct rdes *r1, *r2 = NULL; register int i, j; @@ -133,8 +138,8 @@ do_passages() * Draw a corridor from a room in a certain direction. */ -conn(r1, r2) -int r1, r2; +void +conn(int r1, int r2) { register struct room *rpf, *rpt = NULL; register char rmt; @@ -347,9 +352,8 @@ int r1, r2; * also enters the door in the exits array of the room. */ -door(rm, cp) -register struct room *rm; -register coord *cp; +void +door(struct room *rm, coord *cp) { struct linked_list *newroom; coord *exit; diff --git a/xrogue/player.c b/xrogue/player.c index 51ea7f0..5045ac2 100644 --- a/xrogue/player.c +++ b/xrogue/player.c @@ -17,12 +17,15 @@ #include #include "rogue.h" +bool pick_spell(struct spells spells[], int ability, int num_spells, int power, + const char *prompt, const char *type); /* * affect: * cleric affecting undead */ -affect() +void +affect(void) { register struct linked_list *item; register struct thing *tp; @@ -140,7 +143,8 @@ annoy: * the cleric asks his deity for a spell */ -pray() +void +pray(void) { register int num_prayers, prayer_ability, which_prayer; @@ -210,7 +214,7 @@ pray() if (cleric_spells[which_prayer].s_type == TYP_POTION) quaff( cleric_spells[which_prayer].s_which, - NULL, + 0, cleric_spells[which_prayer].s_flag, FALSE); else if (cleric_spells[which_prayer].s_type == TYP_SCROLL) @@ -231,7 +235,8 @@ pray() * the magician is going to try and cast a spell */ -cast() +void +cast(void) { register int spell_ability, which_spell, num_spells; @@ -291,7 +296,7 @@ cast() if (magic_spells[which_spell].s_type == TYP_POTION) quaff( magic_spells[which_spell].s_which, - NULL, + 0, magic_spells[which_spell].s_flag, FALSE); else if (magic_spells[which_spell].s_type == TYP_SCROLL) @@ -312,7 +317,8 @@ cast() * the druid asks his deity for a spell */ -chant() +void +chant(void) { register int num_chants, chant_ability, which_chant; @@ -377,7 +383,7 @@ chant() if (druid_spells[which_chant].s_type == TYP_POTION) quaff( druid_spells[which_chant].s_which, - NULL, + 0, druid_spells[which_chant].s_flag, FALSE); else if (druid_spells[which_chant].s_type == TYP_SCROLL) @@ -396,7 +402,8 @@ chant() /* Constitution bonus */ -const_bonus() /* Hit point adjustment for changing levels */ +int +const_bonus(void) /* Hit point adjustment for changing levels */ { register int bonus; if (pstats.s_const > 9 && pstats.s_const < 18) @@ -436,8 +443,8 @@ const_bonus() /* Hit point adjustment for changing levels */ * way to get this artifact and remain alive. */ -give(th) -register struct thing *th; +void +give(struct thing *th) { /* * Find any monster within one space of you @@ -571,8 +578,8 @@ register struct thing *th; * Frighten a monster. Useful for the 'good' characters. */ -fright(th) -register struct thing *th; +void +fright(struct thing *th) { /* * Find any monster within one space of you @@ -682,13 +689,14 @@ register struct thing *th; * gsense: Sense gold */ -gsense() +void +gsense(void) { /* Thief & assassin can do this, but fighter & ranger can later */ if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN || ((player.t_ctype == C_FIGHTER || player.t_ctype == C_RANGER) && pstats.s_lvl >= 12)) { - read_scroll(S_GFIND, NULL, FALSE); + read_scroll(S_GFIND, 0, FALSE); } else msg("You seem to have no gold sense."); return; @@ -698,13 +706,14 @@ gsense() * xsense: Sense traps */ -xsense() +void +xsense(void) { /* Only thief can do this, but assassin, fighter, & monk can later */ if (player.t_ctype == C_THIEF || ((player.t_ctype == C_ASSASSIN || player.t_ctype == C_FIGHTER || player.t_ctype == C_MONK) && pstats.s_lvl >= 14)) { - read_scroll(S_FINDTRAPS, NULL, FALSE); + read_scroll(S_FINDTRAPS, 0, FALSE); } else msg("You seem not to be able to sense traps."); return; @@ -715,7 +724,8 @@ xsense() * Steal in direction given in delta */ -steal() +void +steal(void) { register struct linked_list *item; register struct thing *tp; @@ -857,7 +867,8 @@ steal() * Take charmed monsters with you via up or down commands. */ -take_with() +void +take_with(void) { register struct thing *tp; register struct linked_list *item; @@ -884,15 +895,17 @@ take_with() /* * this routine lets the player pick the spell that they * want to cast regardless of character class + * spells: spell list + * ability: spell ability + * num_spells: number of spells that can be cast + * power: spell power + * prompt: prompt for spell list + * type: type of thing--> spell, prayer, chant */ -pick_spell(spells, ability, num_spells, power, prompt, type) -struct spells spells[]; /* spell list */ -int ability; /* spell ability */ -int num_spells; /* number of spells that can be cast */ -int power; /* spell power */ -const char *prompt; /* prompt for spell list */ -const char *type; /* type of thing--> spell, prayer, chant */ +bool +pick_spell(struct spells spells[], int ability, int num_spells, int power, + const char *prompt, const char *type) { bool nohw = FALSE; register int i; @@ -1001,7 +1014,7 @@ const char *type; /* type of thing--> spell, prayer, chant */ /* Should we overlay? */ if (menu_overlay && num_spells + 3 < lines - 3) { - over_win(cw, hw, num_spells + 5, maxlen + 3, 0, curlen, NULL); + over_win(cw, hw, num_spells + 5, maxlen + 3, 0, curlen, '\0'); } else draw(hw); } @@ -1029,7 +1042,7 @@ const char *type; /* type of thing--> spell, prayer, chant */ /* Should we overlay? */ if (menu_overlay && num_spells + 3 < lines - 3) { over_win(cw, hw, num_spells + 5, maxlen + 3, - 0, curlen, NULL); + 0, curlen, '\0'); } else draw(hw); @@ -1068,7 +1081,8 @@ const char *type; /* type of thing--> spell, prayer, chant */ * Let the player know what's happening with himself */ -opt_player() +void +opt_player(void) { int i = 1; /* initialize counters */ int j = 2; @@ -1446,7 +1460,7 @@ opt_player() if (menu_overlay) { /* Print the list. */ wmove(hw, i+2, 0); wprintw(hw, spacemsg); - over_win(cw, hw, i+3, j, i+2, 27, NULL); + over_win(cw, hw, i+3, j, i+2, 27, '\0'); } else { wmove(hw, i+2, 0); @@ -1461,7 +1475,7 @@ opt_player() wprintw(hw, spacemsg); if (j > 2) j = 78; else j = 39; - over_win(cw, hw, i+3, j, i+2, 27, NULL); + over_win(cw, hw, i+3, j, i+2, 27, '\0'); } else { wmove(hw, i+2, 0); diff --git a/xrogue/potions.c b/xrogue/potions.c index b27b281..7c0d197 100644 --- a/xrogue/potions.c +++ b/xrogue/potions.c @@ -20,6 +20,19 @@ #include #include "rogue.h" +int add_charisma(int change); +int add_constitution(int change); +int add_dexterity(int change); +int add_intelligence(int change); +int add_strength(int change); +int add_wisdom(int change); + +int res_charisma(int howmuch); +int res_constitution(int howmuch); +int res_dexterity(int howmuch); +int res_intelligence(int howmuch); +int res_wisdom(int howmuch); + /* * add_abil is an array of functions used to change attributes. It must be * ordered according to the attribute definitions in rogue.h. @@ -45,8 +58,7 @@ int (*res_abil[NUMABILITIES])() = { */ int -add_constitution(change) -int change; +add_constitution(int change) { /* Do the potion */ if (change < 0) { @@ -76,8 +88,7 @@ int change; */ int -add_charisma(change) -int change; +add_charisma(int change) { /* Do the potion */ if (change < 0) msg("You feel less attractive now."); @@ -99,8 +110,7 @@ int change; */ int -add_dexterity(change) -int change; +add_dexterity(int change) { int ring_str; /* Value of ring strengths */ @@ -132,8 +142,8 @@ int change; * add a haste to the player */ -add_haste(blessed) -bool blessed; +void +add_haste(bool blessed) { int hasttime; @@ -171,8 +181,7 @@ bool blessed; */ int -add_intelligence(change) -int change; +add_intelligence(int change) { int ring_str; /* Value of ring strengths */ @@ -203,7 +212,8 @@ int change; * this routine makes the hero move slower */ -add_slow() +void +add_slow(void) { /* monks cannot be slowed or hasted */ if (player.t_ctype == C_MONK || ISWEARING(R_FREEDOM)) { @@ -232,8 +242,7 @@ add_slow() */ int -add_strength(change) -int change; +add_strength(int change) { if (change < 0) { @@ -252,8 +261,7 @@ int change; */ int -add_wisdom(change) -int change; +add_wisdom(int change) { int ring_str; /* Value of ring strengths */ @@ -280,11 +288,8 @@ int change; return(0); } -quaff(which, kind, flags, is_potion) -int which; -int kind; -int flags; -bool is_potion; +void +quaff(int which, int kind, int flags, bool is_potion) { register struct object *obj; register struct linked_list *item, *titem; @@ -587,7 +592,7 @@ bool is_potion; blessed ? "much " : ""); p_know[P_RAISE] = TRUE; raise_level(); - do_panic(NULL); /* this startles them */ + do_panic(0); /* this startles them */ if (blessed) raise_level(); } when P_HASTE: @@ -941,8 +946,7 @@ bool is_potion; */ int -res_dexterity(howmuch) -int howmuch; +res_dexterity(int howmuch) { short save_max; int ring_str; @@ -975,8 +979,7 @@ int howmuch; */ int -res_intelligence(howmuch) -int howmuch; +res_intelligence(int howmuch) { short save_max; int ring_str; @@ -1004,8 +1007,7 @@ int howmuch; */ int -res_wisdom(howmuch) -int howmuch; +res_wisdom(int howmuch) { short save_max; int ring_str; @@ -1033,8 +1035,7 @@ int howmuch; */ int -res_constitution(howmuch) -int howmuch; +res_constitution(int howmuch) { if (howmuch > 0) pstats.s_const = min(pstats.s_const + howmuch, max_stats.s_const); @@ -1048,8 +1049,7 @@ int howmuch; */ int -res_charisma(howmuch) -int howmuch; +res_charisma(int howmuch) { if (howmuch > 0) pstats.s_charisma = diff --git a/xrogue/rings.c b/xrogue/rings.c index d262c28..ee61bfd 100644 --- a/xrogue/rings.c +++ b/xrogue/rings.c @@ -29,8 +29,8 @@ * how much food does this ring use up? */ -ring_eat(hand) -register int hand; +int +ring_eat(int hand) { if (cur_ring[hand] == NULL) return 0; @@ -54,8 +54,8 @@ register int hand; return 0; } -ring_on(item) -register struct linked_list *item; +void +ring_on(struct linked_list *item) { register struct object *obj; register int save_max; @@ -122,8 +122,7 @@ register struct linked_list *item; */ char * -ring_num(obj) -register struct object *obj; +ring_num(struct object *obj) { static char buf[5]; @@ -158,7 +157,8 @@ register struct object *obj; * Return the effect of the specified ring */ -ring_value(type) +int +ring_value(int type) { int result = 0; diff --git a/xrogue/rip.c b/xrogue/rip.c index cede11c..1c69d8f 100644 --- a/xrogue/rip.c +++ b/xrogue/rip.c @@ -20,6 +20,7 @@ #define EDITSCORE 2 /* Edit the current score file */ #define ADDSCORE 3 /* Add a new score */ +#include #include #include #include @@ -54,14 +55,20 @@ static char *rip[] = { NULL }; -char *killname(); +int rs_read_scorefile(FILE *savef, struct sc_ent *entries, int count); +void rs_write_scorefile(FILE *savef, struct sc_ent *entries, int count); + +char *killname(short monst); +void showpack(char *howso); +int update(struct sc_ent top_ten[], unsigned long amount, short quest, + char *whoami, short flags, short level, short monst, short ctype, + char *system, char *login); extern FILE *scorefi, *logfile; /*UNUSED*/ void -byebye(sig) -int sig; +byebye(int sig) { NOOP(sig); exit_game(EXIT_ENDWIN); @@ -73,8 +80,8 @@ int sig; * Do something really fun when he dies */ -death(monst) -register short monst; +void +death(short monst) { register char **dp = rip, *killer; register struct tm *lt; @@ -102,8 +109,7 @@ register short monst; } char * -killname(monst) -register short monst; +killname(short monst) { static char mons_name[LINELEN/2]; int i; @@ -187,10 +193,8 @@ writelog(unsigned long amount, int flags, short monst) */ /* VARARGS2 */ -score(amount, flags, monst) -unsigned long amount; -int flags; -short monst; +void +score(unsigned long amount, int flags, short monst) { struct sc_ent top_ten[NUMSCORE]; register struct sc_ent *scp; @@ -574,8 +578,8 @@ short monst; * Display the contents of the hero's pack */ -showpack(howso) -char *howso; +void +showpack(char *howso) { reg char *iname; reg int cnt, packnum; @@ -604,7 +608,8 @@ char *howso; refresh(); } -total_winner() +void +total_winner(void) { register struct linked_list *item; register struct object *obj; @@ -665,9 +670,7 @@ total_winner() void -delete_score(top_ten, idx) -struct sc_ent top_ten[NUMSCORE]; -int idx; +delete_score(struct sc_ent top_ten[NUMSCORE], int idx) { for(;idx < NUMSCORE-1;idx++) top_ten[idx] = top_ten[idx+1]; @@ -676,9 +679,7 @@ int idx; } int -insert_score(top_ten, sc) -struct sc_ent top_ten[NUMSCORE]; -struct sc_ent *sc; +insert_score(struct sc_ent top_ten[NUMSCORE], struct sc_ent *sc) { int i,j; @@ -699,10 +700,8 @@ struct sc_ent *sc; /* PCS = player-class-system (used to determines uniqueness of player) */ -int -is_pcs_match(sc1,sc2) -struct sc_ent *sc1; -struct sc_ent *sc2; +bool +is_pcs_match(struct sc_ent *sc1, struct sc_ent *sc2) { return( (strcmp(sc1->sc_name,sc2->sc_name) == 0) && (sc1->sc_ctype == sc2->sc_ctype) && @@ -710,10 +709,8 @@ struct sc_ent *sc2; } int -count_pcs_matches(top_ten,sc,lowest) -struct sc_ent top_ten[NUMSCORE]; -struct sc_ent *sc; -int *lowest; +count_pcs_matches(struct sc_ent top_ten[NUMSCORE], struct sc_ent *sc, + int *lowest) { int i, matches = 0; @@ -729,10 +726,8 @@ int *lowest; } int -find_most_pcs_matches(top_ten,sc,num,idx) -struct sc_ent top_ten[NUMSCORE]; -struct sc_ent *sc; -int *num, *idx; +find_most_pcs_matches(struct sc_ent top_ten[NUMSCORE], struct sc_ent *sc, + int *num, int *idx) { int i, matches, max_match=0, max_match_idx=-1, lowest; @@ -761,9 +756,7 @@ int *num, *idx; int -add_score(top_ten,sc) -struct sc_ent top_ten[NUMSCORE]; -struct sc_ent *sc; +add_score(struct sc_ent top_ten[NUMSCORE], struct sc_ent *sc) { int idx, count; @@ -797,11 +790,10 @@ struct sc_ent *sc; } } -update(top_ten, amount, quest, whoami, flags, level, monst, ctype, system, login) -struct sc_ent top_ten[]; -unsigned long amount; -short quest, flags, level, monst, ctype; -char *whoami, *system, *login; +int +update(struct sc_ent top_ten[], unsigned long amount, short quest, char *whoami, + short flags, short level, short monst, short ctype, char *system, + char *login) { struct sc_ent sc; diff --git a/xrogue/rogue.h b/xrogue/rogue.h index 58b25e6..547cb80 100644 --- a/xrogue/rogue.h +++ b/xrogue/rogue.h @@ -1222,54 +1222,296 @@ struct sc_ent { /* * Other structures */ - -struct linked_list *find_mons(), *find_obj(), *get_item(), *new_item(), - *new_thing(), *wake_monster(), *get_hurl(), *spec_item(), - *creat_item(), *wield_weap(); -struct room *roomin(); -struct trap *trap_at(); +void _attach(struct linked_list **list, struct linked_list *item); +void _detach(struct linked_list **list, struct linked_list *item); +void _o_free_list(struct linked_list **ptr); +void _r_free_fire_list(struct linked_list **ptr); +void _r_free_list(struct linked_list **ptr); +void _t_free_list(struct linked_list **ptr); +int ac_compute(bool ignoremetal); +void activity(void); +bool add_pack(struct linked_list *item, bool silent); +void add_slow(void); +void addmsg(char *fmt, ...); +void affect(void); +void aggravate(bool do_uniques, bool do_good); +void alchemy(struct object *obj); +void appear(void); +bool attack(struct thing *mp, struct object *weapon, bool thrown); +void auto_save(int sig); +char be_trapped(struct thing *th, coord *tc); +bool blue_light(bool blessed, bool cursed); +void buy_it(void); +void byebye(int sig); +bool can_blink(struct thing *tp); +int can_shoot(coord *er, coord *ee, coord *shoot_dir); +bool cansee(int y, int x); +void carry_obj(struct thing *mp, int chance); +void cast(void); +void changeclass(long *newclass); +void chant(void); +void chant_recovery(void); +void chase(struct thing *tp, coord *ee, struct room *rer, struct room *ree, + bool flee); +long check_level(void); +void check_residue(struct thing *tp); +void chg_str(int amt); +void choose_qst(void); +int cloak_charge(struct object *obj); +void command(void); +void confus_player(void); +int const_bonus(void); +void corr_move(int dy, int dx); +struct linked_list *creat_item(void); +bool creat_mons(struct thing *person, short monster, bool report); +void create_obj(bool prompt, int which_item, int which_type); +void cur_null(struct object *op); +void cure_disease(void); +void dbotline(WINDOW *scr, char *message); +void death(short monst); +void del_pack(struct linked_list *item); +void destroy_item(struct linked_list *item); +int dex_compute(void); +int dext_plus(int dexterity); +int dext_prot(int dexterity); +bool diag_ok(coord *sp, coord *ep, struct thing *flgptr); +void dip_it(void); +void do_chase(struct thing *th); +void do_daemons(int flag); +void do_fuses(int flag); +void do_maze(void); +void do_motion(struct object *obj, int ydelta, int xdelta, struct thing *tp); +void do_move(int dy, int dx); +void do_panic(int who); +void do_passages(void); +void do_post(bool startup); +void do_rooms(void); +void do_run(char ch); +void do_teleport(void); +void do_terrain(int basey, int basex, int deltay, int deltax, bool fresh); +void do_zap(struct thing *zapper, struct object *obj, coord *direction, + int which, int flags); +void doctor(struct thing *tp); +coord *doorway(struct room *rp, coord *door); +void draw_room(struct room *rp); +bool drop(struct linked_list *item); +bool dropcheck(struct object *op); +void dsrpt_monster(struct thing *tp, bool always, bool see_him); +void dsrpt_player(void); +void dust_appear(void); +void eat(void); +void eat_gold(struct object *obj); +int effect(struct thing *att, struct thing *def, struct object *weap, + bool thrown, bool see_att, bool see_def); +long encread(char *start, unsigned long size, int inf); +long encwrite(char *start, unsigned long size, FILE *outf); +void endit(int sig); +void endmsg(void); +void exit_game(int flag); +void explode(struct thing *tp); +void extinguish(int (*dfunc)()); +void fall(struct linked_list *item, bool pr); +coord *fallpos(coord *pos, bool be_clear, int range); +void fatal(char *s); +bool fight(coord *mp, struct object *weap, bool thrown); +struct linked_list *find_mons(int y, int x); +struct linked_list *find_obj(int y, int x); +struct delayed_action *find_slot(int (*func)()); +int findmindex(char *name); +void fix_stick(struct object *cur); +void fright(struct thing *th); +void fumble(void); +void fuse(int (*dfunc)(), VOID *arg, int time, int type); +void genmonsters(int least, bool treas); +coord get_coordinates(void); +bool get_dir(coord *direction); +struct linked_list *get_hurl(struct thing *tp); +struct linked_list *get_item(struct linked_list *list, char *purpose, int type, + bool askfirst, bool showcost); +int get_str(char *opt, WINDOW *win); +long get_worth(struct object *obj); +int getdeath(void); +bool getdelta(char match, int *dy, int *dx); +void give(struct thing *th); +int grab(int y, int x); +void gsense(void); +void help(void); +bool hit_monster(int y, int x, struct object *obj, struct thing *tp); +int hitweight(void); +void idenpack(void); +void ident_hero(void); +void identify(unsigned char ch); +void init_colors(void); +void init_foods(void); +void init_materials(void); +void init_misc(void); +void init_names(void); +void init_player(void); +void init_stones(void); +void init_terrain(void); +void init_things(void); +void init_weapon(struct object *weap, char type); +char *inv_name(struct object *obj, bool drop); +bool inventory(struct linked_list *list, int type); +bool invisible(struct thing *monst); +bool is_current(struct object *obj); +bool is_magic(struct object *obj); +bool isatrap(char ch); +int itemweight(struct object *wh); +void kill_daemon(int (*dfunc)()); +void killed(struct linked_list *item, bool pr, bool points, bool treasure); +int land(void); +void lengthen(int (*dfunc)(), int xtime); +void light(coord *cp); +bool lit_room(struct room *rp); +void look(bool wakeup, bool runend); +void lower_level(short who); +void m_use_relic(struct thing *monster); +void m_use_wand(struct thing *monster); +void make_sell_pack(struct thing *tp); +short makemonster(bool showall, char *action); +bool maze_view(int y, int x); +int misc_name(char *str, struct object *obj); +void missile(int ydelta, int xdelta, struct linked_list *item, + struct thing *tp); +char *monster_name(struct thing *tp); +bool move_hero(int why); +short movement(struct thing *tp); +void msg(char *fmt, ...); +void nameitem(struct linked_list *item, bool mark); +bool need_dir(int type, int which); +char *new(int size); +struct linked_list *new_item(int size); +void new_level(LEVTYPE ltype); +void new_monster(struct linked_list *item, short type, coord *cp, + bool max_monster); +struct linked_list *new_thing(int thing_type, bool allow_curse); +void nobolt(void); +void nocold(void); +void nofire(void); +void nohaste(void); +void noslow(void); +char *num(int n1, int n2); +void o_discard(struct linked_list *item); +void opt_player(void); +void option(void); +void over_win(WINDOW *oldwin, WINDOW *newin, int maxy, int maxx, int cursory, + int cursorx, char redraw); +char pack_char(struct linked_list *list, struct object *obj); +void parse_opts(char *str); +bool passwd(void); +void picky_inven(void); +bool player_zap(int which, int flag); +void playit(void); +void pray(void); +void prayer_recovery(void); +bool price_it(void); +char *prname(char *who, bool upper); +void quaff(int which, int kind, int flags, bool is_potion); +void quill_charge(void); +void quit(int sig); +void raise_level(void); +short randmonster(bool wander, bool no_unique); +void read_scroll(int which, int flag, bool is_scroll); +void reap(void); +int res_strength(long howmuch); +bool restore(char *file, char *envp[]); +void restscr(WINDOW *scr); +int ring_eat(int hand); +char *ring_num(struct object *obj); +void ring_on(struct linked_list *item); +void ring_search(void); +void ring_teleport(void); +int ring_value(int type); +void rmmsg(void); +int rnd(int range); +void rnd_pos(struct room *rp, coord *cp); +int rnd_room(void); +coord rndmove(struct thing *who); +int roll(int number, int sides); +void rollwand(void); +struct room *roomin(coord *cp); +int runners(int segments); +void runto(struct thing *runner, coord *spot); +bool save(int which, struct thing *who, int adj); +bool save_game(void); +char secretdoor(int y, int x); +void score(unsigned long amount, int flags, short monst); +void search(bool is_thief, bool door_chime); +void sell(struct thing *tp); +void sell_it(void); +void set_trap(struct thing *tp, int y, int x); +void setup(void); +void shoot_bolt(struct thing *shooter, coord start, coord dir, + bool get_points, short reason, char *name, int damage); +bool shoot_ok(int ch); +char show(int y, int x); +void sight(void); +bool skirmish(struct thing *attacker, coord *mp, struct object *weap, + bool thrown); +struct linked_list *spec_item(int type, int which, int hit, int damage); +void spell_recovery(void); +void start_daemon(int (*dfunc)(), VOID *arg, int type); +void status(bool display); +void steal(void); +bool step_ok(int y, int x, int can_on_monst, struct thing *flgptr); +void stomach(void); +int str_compute(void); +int str_plus(short str); +void strangle(void); +void strucpy(char *s1, char *s2, int len); +void suffocate(void); +void swander(void); +bool swing(short class, int at_lvl, int op_arm, int wplus); +void take_off(void); +void take_with(void); +void teleport(void); +void total_winner(void); +int totalenc(struct thing *tp); +char *tr_name(char ch); +struct trap *trap_at(int y, int x); +void trap_look(void); +void unchoke(void); +void unclrhead(void); +void unconfuse(void); +int undance(void); +void unphase(void); +void unsee(void); +void unskill(void); +void unstink(void); +void updpack(int getmax, struct thing *tp); +int usage_time(struct linked_list *item); +void use_mm(int which); +char *vowelstr(char *str); +void wait_for(char ch); +struct linked_list *wake_monster(int y, int x); +void wake_room(struct room *rp); +void wanderer(void); +void waste_time(void); +int weap_move(struct thing *wielder, struct object *weap); +char *weap_name(struct object *obj); +void wear(void); +void wghtchk(void); +void whatis(struct linked_list *what); +void wield(void); +struct linked_list *wield_weap(struct object *thrown, struct thing *mp); +void writelog(unsigned long amount, int flags, short monst); +void xsense(void); -char *getenv(), *tr_name(), *new(), *vowelstr(), - *inv_name(), *num(), - *ring_num(), *misc_num(), *blesscurse(), *p_kind(), *typ_name(), - *prname(), *monster_name(), *weap_name(); +char *getenv(), *misc_num(); -coord rndmove(), *fallpos(), *doorway(), get_coordinates(); -int can_shoot(),misc_name(); +int usage_time(); -short randmonster(), id_monst(), movement(); +void tstp(); -int bugkill(), nohaste(), spell_recovery(), doctor(), runners(), swander(), - unconfuse(), unsee(), fumble(), unclrhead(), unphase(), noslow(), - rollwand(), stomach(), sight(), unstink(), suffocate(), cure_disease(), - shoot_bolt(), changeclass(), appear(), dust_appear(), unchoke(), - alchemy(), trap_look(), strangle(), ring_teleport(), ring_search(), - grab(), dsrpt_player(), quill_charge(), make_sell_pack(), unskill(), - findmindex(), nobolt(), nofire(), nocold(), usage_time(), eat_gold(), - chant_recovery(), prayer_recovery(), dsrpt_monster(), opt_player(); - -bool blue_light(), can_blink(), creat_mons(), add_pack(), invisible(), - straight_shot(), maze_view(), lit_room(), getdelta(), save_file(), - save_game(), m_use_it(), m_use_pack(), get_dir(), need_dir(),passwd(); - -long check_level(); -long encread(); -long get_worth(); -long encwrite(); - -void byebye(int sig), genmonsters(), quit(int sig), - auto_save(int sig), endit(int sig), tstp(); - -void teleport(); - -void writelog(unsigned long amount, int flags, short monst); - -int undance(), land(), cloak_charge(), wghtchk(); - -int add_intelligence(), add_strength(), add_wisdom(), add_dexterity(), - add_constitution(), add_charisma(), res_intelligence(), res_strength(), - res_wisdom(), res_dexterity(), res_constitution(), res_charisma(); +int md_getuid(void); +long md_memused(void); +int md_normaluser(void); +int md_rand(int range); +void md_setup(void); +int md_shellescape(void); +int md_srand(int seed); /* * Now all the global variables @@ -1405,7 +1647,7 @@ extern char *retstr; extern FILE *scorefi; extern FILE *logfile; extern LEVTYPE levtype; -extern int (*add_abil[NUMABILITIES])(); /* Functions to change abilities */ +extern int (*add_abil[NUMABILITIES])(int); /* Functions to change abilities */ extern int (*res_abil[NUMABILITIES])(); /* Functions to change abilities */ extern int mf_count; /* move_free counter - see actions.c(m_act()) */ extern int mf_jmpcnt; /* move_free counter for # of jumps */ diff --git a/xrogue/rooms.c b/xrogue/rooms.c index fafa16f..404099e 100644 --- a/xrogue/rooms.c +++ b/xrogue/rooms.c @@ -20,7 +20,11 @@ #include #include "rogue.h" -do_rooms() +void horiz(int cnt); +void vert(int cnt); + +void +do_rooms(void) { register int i; register struct room *rp; @@ -107,7 +111,7 @@ do_rooms() has_gold = TRUE; /* This room has gold in it */ - item = spec_item(GOLD, NULL, NULL, NULL); + item = spec_item(GOLD, 0, 0, 0); cur = OBJPTR(item); /* Put the gold into the level list of items */ @@ -177,9 +181,7 @@ do_rooms() */ coord * -doorway(rp, door) -register struct room *rp; -register coord *door; +doorway(struct room *rp, coord *door) { register int misses = 0; static coord answer; @@ -208,8 +210,8 @@ register coord *door; * Draw a box around a room */ -draw_room(rp) -register struct room *rp; +void +draw_room(struct room *rp) { register int j, k; @@ -236,8 +238,8 @@ register struct room *rp; * draw a horizontal line */ -horiz(cnt) -register int cnt; +void +horiz(int cnt) { while (cnt--) addch(HORZWALL); @@ -248,9 +250,8 @@ register int cnt; * pick a random spot in a room */ -rnd_pos(rp, cp) -register struct room *rp; -register coord *cp; +void +rnd_pos(struct room *rp, coord *cp) { cp->x = rp->r_pos.x + rnd(rp->r_max.x-2) + 1; cp->y = rp->r_pos.y + rnd(rp->r_max.y-2) + 1; @@ -265,8 +266,7 @@ register coord *cp; */ struct room * -roomin(cp) -register coord *cp; +roomin(coord *cp) { register struct room *rp; @@ -281,8 +281,8 @@ register coord *cp; * draw a vertical line */ -vert(cnt) -register int cnt; +void +vert(int cnt) { register int x, y; diff --git a/xrogue/save.c b/xrogue/save.c index a026ae6..9b3b30d 100644 --- a/xrogue/save.c +++ b/xrogue/save.c @@ -31,10 +31,16 @@ extern char version[]; extern unsigned char encstr[]; extern int big_endian; +bool rs_write_int(FILE *savef, int c); +bool rs_read_int(int inf, int *i); +bool rs_save_file(FILE *savef); +bool rs_restore_file(int inf); + int md_unlink(char *file); +bool save_file(FILE *savef); bool -save_game() +save_game(void) { register FILE *savef; register int c; @@ -129,12 +135,11 @@ auto_save(int sig) */ bool -save_file(savef) -register FILE *savef; +save_file(FILE *savef) { int slines = LINES; int scols = COLS; - int ret = FALSE; + bool ret = FALSE; int endian = 0x01020304; big_endian = ( *((char *)&endian) == 0x01 ); @@ -150,9 +155,8 @@ register FILE *savef; return(ret); } -restore(file, envp) -register char *file; -char **envp; +bool +restore(char *file, char *envp[]) { register int inf; extern char **environ; @@ -251,10 +255,7 @@ char **envp; */ long -encwrite(start, size, outf) -register char *start; -register unsigned long size; -register FILE *outf; +encwrite(char *start, unsigned long size, FILE *outf) { register unsigned char *ep; register int i = 0; @@ -292,10 +293,7 @@ register FILE *outf; */ long -encread(start, size, inf) -register char *start; -register unsigned long size; -int inf; +encread(char *start, unsigned long size, int inf) { register unsigned char *ep; register int rd_siz; diff --git a/xrogue/scrolls.c b/xrogue/scrolls.c index aefa351..7fd1376 100644 --- a/xrogue/scrolls.c +++ b/xrogue/scrolls.c @@ -17,6 +17,7 @@ */ #include +#include #include #include #include "rogue.h" @@ -25,7 +26,8 @@ * let the hero get rid of some type of monster */ -genocide() +void +genocide(void) { register struct linked_list *ip; register struct thing *mp; @@ -56,10 +58,8 @@ genocide() msg("You have wiped out the %s.", monsters[which_monst].m_name); } -read_scroll(which, flag, is_scroll) -register int which; -int flag; -bool is_scroll; +void +read_scroll(int which, int flag, bool is_scroll) { register struct object *obj = NULL, *nobj; register struct linked_list *item, *nitem; @@ -499,7 +499,7 @@ bool is_scroll; nobj->o_flags &= ~ISCURSED; } msg("Your pack glistens brightly!"); - do_panic(NULL); /* this startles them */ + do_panic(0); /* this startles them */ /* return; leaks item, go through end of function */ } else { diff --git a/xrogue/state.c b/xrogue/state.c index d30d73b..610bc6d 100644 --- a/xrogue/state.c +++ b/xrogue/state.c @@ -97,6 +97,14 @@ int format_error = FALSE; int save_debug = FALSE; #define DBG(x) {if (save_debug) rsPrintf x;} +bool rs_read_new_string(int inf, char **s); +int find_list_ptr(struct linked_list *l, void *ptr); +bool rs_write_coord_list(FILE *savef, struct linked_list *l); +bool rs_read_coord_list(int inf, struct linked_list **list); +int list_size(struct linked_list *l); +bool rs_write_object_list(FILE *savef, struct linked_list *l); +bool rs_read_object_list(int inf, struct linked_list **list); + int rsPrintf(char *fmt, ...) { @@ -128,6 +136,7 @@ get_list_item(struct linked_list *l, int i) return(NULL); } +bool rs_write(FILE *savef, void *ptr, size_t size) { size_t i = 0; @@ -143,6 +152,7 @@ rs_write(FILE *savef, void *ptr, size_t size) int end_of_file = FALSE; +bool rs_read(int inf, void *ptr, size_t size) { int actual; @@ -165,6 +175,7 @@ rs_read(int inf, void *ptr, size_t size) int big_endian = 0; +bool rs_write_uint(FILE *savef, unsigned int c) { char bytes[4]; @@ -184,6 +195,7 @@ rs_write_uint(FILE *savef, unsigned int c) return(WRITESTAT); } +bool rs_write_int(FILE *savef, int c) { char bytes[4]; @@ -203,6 +215,7 @@ rs_write_int(FILE *savef, int c) return(WRITESTAT); } +bool rs_write_ulong(FILE *savef, unsigned long c) { unsigned int c2; @@ -229,6 +242,7 @@ rs_write_ulong(FILE *savef, unsigned long c) return(WRITESTAT); } +bool rs_write_long(FILE *savef, long c) { int c2; @@ -255,6 +269,7 @@ rs_write_long(FILE *savef, long c) return(WRITESTAT); } +bool rs_write_boolean(FILE *savef, bool c) { char buf; @@ -269,6 +284,7 @@ rs_write_boolean(FILE *savef, bool c) return(WRITESTAT); } +bool rs_read_int(int inf, int *i) { char bytes[4]; @@ -291,6 +307,7 @@ rs_read_int(int inf, int *i) return(READSTAT); } +bool rs_read_uint(int inf, unsigned int *i) { char bytes[4]; @@ -313,6 +330,7 @@ rs_read_uint(int inf, unsigned int *i) return(READSTAT); } +bool rs_read_ulong(int inf, unsigned long *i) { char bytes[4]; @@ -337,6 +355,7 @@ rs_read_ulong(int inf, unsigned long *i) return(READSTAT); } +bool rs_read_long(int inf, long *i) { char bytes[4]; @@ -361,6 +380,7 @@ rs_read_long(int inf, long *i) return(READSTAT); } +bool rs_read_boolean(int inf, bool *i) { char buf; @@ -372,6 +392,7 @@ rs_read_boolean(int inf, bool *i) return(READSTAT); } +bool rs_write_ints(FILE *savef, int *c, int count) { int n=0; @@ -384,6 +405,7 @@ rs_write_ints(FILE *savef, int *c, int count) return(WRITESTAT); } +bool rs_write_short(FILE *savef, short c) { char bytes[2]; @@ -401,6 +423,7 @@ rs_write_short(FILE *savef, short c) return(WRITESTAT); } +bool rs_read_short(int inf, short *s) { char bytes[2]; @@ -421,6 +444,7 @@ rs_read_short(int inf, short *s) } +bool rs_write_shorts(FILE *savef, short *c, int count) { int n=0; @@ -433,6 +457,7 @@ rs_write_shorts(FILE *savef, short *c, int count) return(WRITESTAT); } +bool rs_write_longs(FILE *savef, long *c, int count) { int n=0; @@ -445,6 +470,7 @@ rs_write_longs(FILE *savef, long *c, int count) return(WRITESTAT); } +bool rs_write_ulongs(FILE *savef, unsigned long *c, int count) { int n=0; @@ -457,6 +483,7 @@ rs_write_ulongs(FILE *savef, unsigned long *c, int count) return(WRITESTAT); } +bool rs_write_booleans(FILE *savef, bool *c, int count) { int n=0; @@ -469,6 +496,7 @@ rs_write_booleans(FILE *savef, bool *c, int count) return(WRITESTAT); } +bool rs_read_ints(int inf, int *i, int count) { int n=0,value=0; @@ -487,6 +515,7 @@ rs_read_ints(int inf, int *i, int count) return(READSTAT); } +bool rs_read_shorts(int inf, short *i, int count) { int n=0,value=0; @@ -505,6 +534,7 @@ rs_read_shorts(int inf, short *i, int count) return(READSTAT); } +bool rs_read_longs(int inf, long *i, int count) { int n=0,value=0; @@ -523,6 +553,7 @@ rs_read_longs(int inf, long *i, int count) return(READSTAT); } +bool rs_read_ulongs(int inf, unsigned long *i, int count) { int n=0,value=0; @@ -541,6 +572,7 @@ rs_read_ulongs(int inf, unsigned long *i, int count) return(READSTAT); } +bool rs_read_booleans(int inf, bool *i, int count) { int n=0,value=0; @@ -559,6 +591,7 @@ rs_read_booleans(int inf, bool *i, int count) return(READSTAT); } +bool rs_write_levtype(FILE *savef, LEVTYPE c) { int lt; @@ -578,6 +611,7 @@ rs_write_levtype(FILE *savef, LEVTYPE c) return(WRITESTAT); } +bool rs_read_levtype(int inf, LEVTYPE *l) { int lt; @@ -597,6 +631,7 @@ rs_read_levtype(int inf, LEVTYPE *l) return(READSTAT); } +bool rs_write_char(FILE *savef, char c) { rs_write(savef, &c, 1); @@ -605,6 +640,7 @@ rs_write_char(FILE *savef, char c) return(WRITESTAT); } +bool rs_read_char(int inf, char *c) { rs_read(inf, c, 1); @@ -612,6 +648,7 @@ rs_read_char(int inf, char *c) return(READSTAT); } +bool rs_write_uchar(FILE *savef, unsigned char c) { rs_write(savef, &c, 1); @@ -620,6 +657,7 @@ rs_write_uchar(FILE *savef, unsigned char c) return(WRITESTAT); } +bool rs_read_uchar(int inf, unsigned char *c) { rs_read(inf, c, 1); @@ -627,6 +665,7 @@ rs_read_uchar(int inf, unsigned char *c) return(READSTAT); } +bool rs_write_string(FILE *savef, char *s) { int len = 0; @@ -639,6 +678,7 @@ rs_write_string(FILE *savef, char *s) return(WRITESTAT); } +bool rs_read_string_index(int inf, struct words master[], int maxindex, char **str) { int i; @@ -660,6 +700,7 @@ rs_read_string_index(int inf, struct words master[], int maxindex, char **str) return(READSTAT); } +bool rs_write_string_index(FILE *savef, struct words master[], int maxindex, char *str) { int i; @@ -677,6 +718,7 @@ rs_write_string_index(FILE *savef, struct words master[], int maxindex, char *st return(WRITESTAT); } +bool rs_read_scrolls(int inf) { int i; @@ -691,6 +733,7 @@ rs_read_scrolls(int inf) return(READSTAT); } +bool rs_write_scrolls(FILE *savef) { int i; @@ -701,9 +744,10 @@ rs_write_scrolls(FILE *savef) rs_write_boolean(savef,s_know[i]); rs_write_string(savef,s_guess[i]); } - return(READSTAT); + return(WRITESTAT); } +bool rs_read_potions(int inf) { int i; @@ -718,6 +762,7 @@ rs_read_potions(int inf) return(READSTAT); } +bool rs_write_potions(FILE *savef) { int i; @@ -732,6 +777,7 @@ rs_write_potions(FILE *savef) return(WRITESTAT); } +bool rs_read_rings(int inf) { int i; @@ -746,6 +792,7 @@ rs_read_rings(int inf) return(READSTAT); } +bool rs_write_rings(FILE *savef) { int i; @@ -760,6 +807,7 @@ rs_write_rings(FILE *savef) return(WRITESTAT); } +bool rs_read_misc(int inf) { int i; @@ -773,6 +821,7 @@ rs_read_misc(int inf) return(READSTAT); } +bool rs_write_misc(FILE *savef) { int i; @@ -786,6 +835,7 @@ rs_write_misc(FILE *savef) return(WRITESTAT); } +bool rs_write_sticks(FILE *savef) { int i; @@ -809,6 +859,7 @@ rs_write_sticks(FILE *savef) return(WRITESTAT); } +bool rs_read_sticks(int inf) { int i = 0, list = 0; @@ -833,6 +884,7 @@ rs_read_sticks(int inf) return(READSTAT); } +bool rs_read_string(int inf, char *s, int max) { int len = 0; @@ -852,6 +904,7 @@ rs_read_string(int inf, char *s, int max) return(READSTAT); } +bool rs_read_new_string(int inf, char **s) { int len=0; @@ -878,6 +931,7 @@ rs_read_new_string(int inf, char **s) return(READSTAT); } +bool rs_write_strings(FILE *savef, char *s[], int count) { int len = 0; @@ -896,6 +950,7 @@ rs_write_strings(FILE *savef, char *s[], int count) return(WRITESTAT); } +bool rs_write_words(FILE *savef, struct words *w, int count) { int n = 0; @@ -911,6 +966,7 @@ rs_write_words(FILE *savef, struct words *w, int count) return(WRITESTAT); } +bool rs_read_words(int inf, struct words *w, int count) { int n = 0; @@ -933,6 +989,7 @@ rs_read_words(int inf, struct words *w, int count) return(READSTAT); } +bool rs_read_new_strings(int inf, char **s, int count) { int len = 0; @@ -966,6 +1023,7 @@ rs_read_new_strings(int inf, char **s, int count) return(READSTAT); } +bool rs_write_coord(FILE *savef, coord *c) { DBG(("X =")); @@ -976,6 +1034,7 @@ rs_write_coord(FILE *savef, coord *c) return(WRITESTAT); } +bool rs_read_coord(int inf, coord *c) { rs_read_int(inf,&c->x); @@ -1047,6 +1106,7 @@ struct object *find_alchemy_jug(int n) { return tobj; } +bool rs_write_daemons(FILE *savef, struct delayed_action *d_list,int count) { int i = 0; @@ -1173,6 +1233,7 @@ rs_write_daemons(FILE *savef, struct delayed_action *d_list,int count) return(WRITESTAT); } +bool rs_read_daemons(int inf, struct delayed_action *d_list, int count) { int i = 0; @@ -1344,6 +1405,7 @@ rs_read_daemons(int inf, struct delayed_action *d_list, int count) return(READSTAT); } +bool rs_write_rooms(FILE *savef, struct room r[], int count) { int n = 0,i = -1; @@ -1376,6 +1438,7 @@ rs_write_rooms(FILE *savef, struct room r[], int count) return(WRITESTAT); } +bool rs_read_rooms(int inf, struct room *r, int count) { int value = 0, n = 0, i = 0, index = 0, id = 0; @@ -1436,6 +1499,7 @@ rs_read_rooms(int inf, struct room *r, int count) return(READSTAT); } +bool rs_write_object(FILE *savef, struct object *o) { rs_write_int(savef, RSXR_OBJECT); @@ -1487,6 +1551,7 @@ rs_write_object(FILE *savef, struct object *o) return(WRITESTAT); } +bool rs_read_object(int inf, struct object *o) { int id; @@ -1523,6 +1588,7 @@ rs_read_object(int inf, struct object *o) return(READSTAT); } +bool rs_write_stats(FILE *savef, struct stats *s) { DBG(("Stats\n")); @@ -1546,6 +1612,7 @@ rs_write_stats(FILE *savef, struct stats *s) return(WRITESTAT); } +bool rs_read_stats(int inf, struct stats *s) { int id; @@ -1580,6 +1647,7 @@ rs_read_stats(int inf, struct stats *s) return(READSTAT); } +bool rs_write_mstats(FILE *savef, struct mstats *s) { DBG(("M-Stats\n")); @@ -1598,6 +1666,7 @@ rs_write_mstats(FILE *savef, struct mstats *s) return(WRITESTAT); } +bool rs_read_mstats(int inf, struct mstats *s) { int id; @@ -1634,6 +1703,7 @@ rs_read_mstats(int inf, struct mstats *s) return(READSTAT); } +bool rs_write_init_weps(FILE *savef, struct init_weps *w, int count) { int i; @@ -1656,6 +1726,7 @@ rs_write_init_weps(FILE *savef, struct init_weps *w, int count) return(WRITESTAT); } +bool rs_read_init_weps(int inf, struct init_weps *w,int count) { int id,value,i; @@ -1684,6 +1755,7 @@ rs_read_init_weps(int inf, struct init_weps *w,int count) return(READSTAT); } +bool rs_write_init_armor(FILE *savef, struct init_armor *a, int count) { int i; @@ -1701,6 +1773,7 @@ rs_write_init_armor(FILE *savef, struct init_armor *a, int count) return(WRITESTAT); } +bool rs_read_init_armor(int inf, struct init_armor *a,int count) { int id,value,i; @@ -1720,6 +1793,7 @@ rs_read_init_armor(int inf, struct init_armor *a,int count) return(READSTAT); } +bool rs_write_spells(FILE *savef, struct spells *s, int count) { int i; @@ -1736,6 +1810,7 @@ rs_write_spells(FILE *savef, struct spells *s, int count) return(WRITESTAT); } +bool rs_read_spells(int inf, struct spells *s,int count) { int id,value,i; @@ -1753,6 +1828,7 @@ rs_read_spells(int inf, struct spells *s,int count) return(READSTAT); } +bool rs_write_item_list(FILE *savef, struct item_list *i) { DBG(("Item List\n")); @@ -1761,6 +1837,8 @@ rs_write_item_list(FILE *savef, struct item_list *i) rs_write(savef, i->item_desc, sizeof(i->item_desc)); return(WRITESTAT); } + +bool rs_read_item_list(int inf, struct item_list *i) { int id; @@ -1772,6 +1850,7 @@ rs_read_item_list(int inf, struct item_list *i) return(READSTAT); } +bool rs_write_h_list(FILE *savef, struct h_list *h) { DBG(("H List\n")); @@ -1781,6 +1860,7 @@ rs_write_h_list(FILE *savef, struct h_list *h) return(WRITESTAT); } +bool rs_read_h_list(int inf, struct h_list *h) { int id; @@ -1792,6 +1872,7 @@ rs_read_h_list(int inf, struct h_list *h) return(READSTAT); } +bool rs_write_death_types(FILE *savef, struct death_type *d,int count) { int i; @@ -1807,6 +1888,8 @@ rs_write_death_types(FILE *savef, struct death_type *d,int count) } return(WRITESTAT); } + +bool rs_read_death_types(int inf, struct death_type *d, int count) { int id,value,i; @@ -1828,6 +1911,7 @@ rs_read_death_types(int inf, struct death_type *d, int count) return(READSTAT); } +bool rs_write_character_types(FILE *savef, struct character_types *c, int count) { int i; @@ -1851,6 +1935,7 @@ rs_write_character_types(FILE *savef, struct character_types *c, int count) return(WRITESTAT); } +bool rs_read_character_types(int inf, struct character_types *c,int count) { int id,value,i; @@ -1880,6 +1965,7 @@ rs_read_character_types(int inf, struct character_types *c,int count) return(READSTAT); } +bool rs_write_traps(FILE *savef, struct trap *trap,int count) { int n; @@ -1895,8 +1981,10 @@ rs_write_traps(FILE *savef, struct trap *trap,int count) rs_write_coord(savef, &trap[n].tr_pos); rs_write_long(savef, trap[n].tr_flags); } + return(WRITESTAT); } +bool rs_read_traps(int inf, struct trap *trap, int count) { int id = 0, value = 0, n = 0; @@ -1937,6 +2025,7 @@ rs_read_traps(int inf, struct trap *trap, int count) return(READSTAT); } +bool rs_write_monsters(FILE * savef, struct monster * m, int count) { int n; @@ -1965,6 +2054,7 @@ rs_write_monsters(FILE * savef, struct monster * m, int count) return(WRITESTAT); } +bool rs_read_monsters(int inf, struct monster *m, int count) { int id = 0, value = 0, n = 0; @@ -2024,6 +2114,7 @@ rs_read_monsters(int inf, struct monster *m, int count) /*****************************************************************************/ +bool rs_write_coord_list(FILE *savef, struct linked_list *l) { DBG(("Coordinate List\n")); @@ -2039,6 +2130,7 @@ rs_write_coord_list(FILE *savef, struct linked_list *l) return(WRITESTAT); } +bool rs_read_coord_list(int inf, struct linked_list **list) { int id; @@ -2082,6 +2174,7 @@ rs_read_coord_list(int inf, struct linked_list **list) return(READSTAT); } +bool rs_write_object_list(FILE *savef, struct linked_list *l) { DBG(("Object List\n")); @@ -2097,6 +2190,7 @@ rs_write_object_list(FILE *savef, struct linked_list *l) return(WRITESTAT); } +bool rs_read_object_list(int inf, struct linked_list **list) { int id; @@ -2175,6 +2269,7 @@ coord *c; return(-1); } +bool rs_write_thing(FILE *savef, struct thing *t) { int i = -1; @@ -2285,6 +2380,7 @@ rs_write_thing(FILE *savef, struct thing *t) return(WRITESTAT); } +void rs_fix_thing(struct thing *t) { struct linked_list *item; @@ -2302,6 +2398,7 @@ rs_fix_thing(struct thing *t) } } +bool rs_read_thing(int inf, struct thing *t) { int id; @@ -2413,6 +2510,7 @@ list_size(struct linked_list *l) } +bool rs_write_monster_list(FILE *savef, struct linked_list *l) { int cnt = 0; @@ -2435,8 +2533,8 @@ rs_write_monster_list(FILE *savef, struct linked_list *l) return(WRITESTAT); } -rs_fix_monster_list(list) -struct linked_list *list; +void +rs_fix_monster_list(struct linked_list *list) { struct linked_list *item; @@ -2444,6 +2542,7 @@ struct linked_list *list; rs_fix_thing(THINGPTR(item)); } +bool rs_read_monster_list(int inf, struct linked_list **list) { int id; @@ -2485,6 +2584,7 @@ rs_read_monster_list(int inf, struct linked_list **list) return(READSTAT); } +bool rs_write_magic_items(FILE *savef, struct magic_item *i, int count) { int n; @@ -2505,6 +2605,7 @@ rs_write_magic_items(FILE *savef, struct magic_item *i, int count) return(WRITESTAT); } +bool rs_read_magic_items(int inf, struct magic_item *mi, int count) { int id; @@ -2546,6 +2647,7 @@ rs_read_magic_items(int inf, struct magic_item *mi, int count) return(READSTAT); } +bool rs_write_window(FILE *savef, WINDOW *win) { int row,col,height,width; @@ -2558,8 +2660,11 @@ rs_write_window(FILE *savef, WINDOW *win) for(row=0;rowt_reserved); } +void rs_print_game_state(FILE *outf) { fprintf(outf, "Player\n"); @@ -3025,8 +3136,7 @@ rs_print_game_state(FILE *outf) ****/ int -md_rand(range) -register int range; +md_rand(int range) { #ifdef _WIN32 return(range <= 0 ? 0 : rand() % range); @@ -3036,8 +3146,7 @@ register int range; } int -md_srand(seed) -register int seed; +md_srand(int seed) { #ifdef _WIN32 srand(seed); @@ -3047,7 +3156,7 @@ register int seed; } void -md_flushinp() +md_flushinp(void) { /* ioctl(0,TIOCFLUSH) */ /* ioctl(_tty_ch,TCFLSH,0) */ @@ -3055,7 +3164,7 @@ md_flushinp() } int -md_getuid() +md_getuid(void) { #ifdef _WIN32 return(42); @@ -3065,7 +3174,7 @@ md_getuid() } long -md_memused() +md_memused(void) { #ifdef _WIN32 MEMORYSTATUS stat; @@ -3079,7 +3188,7 @@ md_memused() } char * -md_getusername() +md_getusername(void) { static char login[80]; char *l = NULL; @@ -3114,7 +3223,7 @@ md_getusername() } char * -md_gethomedir() +md_gethomedir(void) { static char homedir[PATH_MAX]; char *h = NULL; @@ -3181,7 +3290,7 @@ directory_exists(char *dirname) } char * -md_getroguedir() +md_getroguedir(void) { static char path[1024]; char *end,*home; @@ -3218,7 +3327,7 @@ md_getroguedir() } char * -md_getshell() +md_getshell(void) { static char shell[PATH_MAX]; char *s = NULL; @@ -3246,7 +3355,7 @@ md_getshell() } char * -md_gethostname() +md_gethostname(void) { static char nodename[80]; char *n = NULL; @@ -3268,7 +3377,7 @@ md_gethostname() } int -md_shellescape() +md_shellescape(void) { #if (!defined(_WIN32) && !defined(__DJGPP__)) int ret_status; @@ -3308,7 +3417,7 @@ md_shellescape() } int -md_erasechar() +md_erasechar(void) { /* return(_tty.sg_erase); @@ -3318,7 +3427,7 @@ md_erasechar() } int -md_killchar() +md_killchar(void) { /* return(_tty.sg_kill); @@ -3362,7 +3471,7 @@ md_htonl(unsigned long int x) } void -md_init() +md_init(void) { #ifdef __INTERIX char *term; @@ -3378,8 +3487,7 @@ md_init() } char * -md_getpass(prompt) -char *prompt; +md_getpass(char *prompt) { #ifdef _WIN32 static char password_buffer[9]; @@ -3446,8 +3554,7 @@ char *prompt; /*UNUSED*/ void -tstp(a) -int a; +tstp(int a) { mvcur(0, cols - 1, lines - 1, 0); fflush(stdout); @@ -3462,8 +3569,8 @@ int a; } #endif -int -md_setup() +void +md_setup(void) { #ifdef SIGTSTP signal(SIGTSTP, tstp); diff --git a/xrogue/sticks.c b/xrogue/sticks.c index 32edb15..4332647 100644 --- a/xrogue/sticks.c +++ b/xrogue/sticks.c @@ -21,16 +21,15 @@ #include #include "rogue.h" +void drain(int ymin, int ymax, int xmin, int xmax); + /* * zap a stick and see what happens */ -do_zap(zapper, obj, direction, which, flags) -struct thing *zapper; -struct object *obj; -coord *direction; -int which; -int flags; +void +do_zap(struct thing *zapper, struct object *obj, coord *direction, int which, + int flags) { register struct linked_list *item = NULL; register struct thing *tp; @@ -647,8 +646,8 @@ int flags; * Do drain hit points from player shtick */ -drain(ymin, ymax, xmin, xmax) -int ymin, ymax, xmin, xmax; +void +drain(int ymin, int ymax, int xmin, int xmax) { register int i, j, count; register struct thing *ick; @@ -727,8 +726,8 @@ int ymin, ymax, xmin, xmax; * initialize a stick */ -fix_stick(cur) -register struct object *cur; +void +fix_stick(struct object *cur) { if (EQUAL(ws_type[cur->o_which], "staff")) { cur->o_weight = 100; @@ -768,8 +767,8 @@ register struct object *cur; * Use the wand that our monster is wielding. */ -m_use_wand(monster) -register struct thing *monster; +void +m_use_wand(struct thing *monster) { register struct object *obj; @@ -794,14 +793,16 @@ register struct thing *monster; */ msg("%s points a %s at you!", prname(monster_name(monster), TRUE), ws_type[obj->o_which]); - do_zap(monster, obj, &monster->t_newpos, obj->o_which, NULL); + do_zap(monster, obj, &monster->t_newpos, obj->o_which, 0); monster->t_wand /= 2; /* chance lowers with each use */ } +/* + * type: type of item, NULL means stick + * which: which item + */ bool -need_dir(type, which) -int type, /* type of item, NULL means stick */ - which; /* which item */ +need_dir(int type, int which) { if (type == STICK || type == 0) { switch (which) { @@ -831,9 +832,8 @@ return (FALSE); /* hope we don't get here */ * let the player zap a stick and see what happens */ -player_zap(which, flag) -int which; -int flag; +bool +player_zap(int which, int flag) { register struct linked_list *item; register struct object *obj; @@ -869,7 +869,7 @@ int flag; switch (obj->o_which) { case ORCUS_WAND: /* msg(nothing); */ - read_scroll(S_PETRIFY, NULL, FALSE); + read_scroll(S_PETRIFY, 0, FALSE); return(TRUE); when MING_STAFF: which = WS_MISSILE; diff --git a/xrogue/things.c b/xrogue/things.c index d4d3100..4288d55 100644 --- a/xrogue/things.c +++ b/xrogue/things.c @@ -21,13 +21,17 @@ #include #include "rogue.h" +int pick_one(struct magic_item *magic, int nitems); +char *blesscurse(int flags); +char *p_kind(struct object *obj); +int extras(void); + /* * print out the number of charges on a stick */ char * -charge_str(obj) -register struct object *obj; +charge_str(struct object *obj) { static char buf[20]; @@ -47,9 +51,7 @@ register struct object *obj; */ char * -inv_name(obj, drop) -register struct object *obj; -bool drop; +inv_name(struct object *obj, bool drop) { register char *pb; @@ -331,8 +333,7 @@ bool drop; */ char * -weap_name(obj) -register struct object *obj; +weap_name(struct object *obj) { switch (obj->o_type) { case WEAPON: @@ -365,8 +366,8 @@ register struct object *obj; * put something down */ -drop(item) -struct linked_list *item; +bool +drop(struct linked_list *item) { register char ch = 0; register struct linked_list *obj, *nobj; @@ -473,8 +474,8 @@ struct linked_list *item; * do special checks for dropping or unweilding|unwearing|unringing */ -dropcheck(op) -register struct object *op; +bool +dropcheck(struct object *op) { int save_max; @@ -583,9 +584,7 @@ register struct object *op; */ struct linked_list * -new_thing(thing_type, allow_curse) -int thing_type; -bool allow_curse; +new_thing(int thing_type, bool allow_curse) { register struct linked_list *item; register struct object *cur; @@ -801,8 +800,7 @@ bool allow_curse; */ struct linked_list * -spec_item(type, which, hit, damage) -int type, which, hit, damage; +spec_item(int type, int which, int hit, int damage) { register struct linked_list *item; register struct object *obj; @@ -877,9 +875,8 @@ int type, which, hit, damage; * pick an item out of a list of nitems possible magic items */ -pick_one(magic, nitems) -register struct magic_item *magic; -int nitems; +int +pick_one(struct magic_item *magic, int nitems) { register struct magic_item *end; register int i; @@ -908,8 +905,7 @@ int nitems; */ char * -blesscurse(flags) -int flags; +blesscurse(int flags) { if (flags & ISKNOW) { if (flags & ISCURSED) return("cursed "); @@ -922,11 +918,11 @@ int flags; /* * p_kind returns the type of potion for some types of identified potions; * otherwise, it returns the color. + * We assume that obj points to a potion. */ char * -p_kind(obj) -struct object *obj; /* We assume that obj points to a potion */ +p_kind(struct object *obj) { if (obj->o_which == P_ABIL) return(abilities[obj->o_kind].w_string); else return(p_colors[obj->o_which]); @@ -937,7 +933,8 @@ struct object *obj; /* We assume that obj points to a potion */ * Return the number of extra items to be created */ -extras() +int +extras(void) { reg int i; diff --git a/xrogue/trader.c b/xrogue/trader.c index 9c060ae..3e8d7ae 100644 --- a/xrogue/trader.c +++ b/xrogue/trader.c @@ -16,12 +16,17 @@ #include #include "rogue.h" +bool open_market(void); +void trans_line(void); +char *typ_name(struct object *obj); + /* * buy_it: * Buy the item on which the hero stands */ -buy_it() +void +buy_it(void) { reg int wh; struct linked_list *item = NULL; @@ -84,10 +89,11 @@ buy_it() /* * do_post: * Put a trading post room and stuff on the screen + * startup: True if equipping the player at the beginning of the game */ -do_post(startup) -bool startup; /* True if equipping the player at the beginning of the game */ +void +do_post(bool startup) { coord tp; reg int i, j = 0, k; @@ -348,7 +354,8 @@ bool startup; /* True if equipping the player at the beginning of the game */ * Retruns TRUE when ok do to transacting */ -open_market() +bool +open_market(void) { if (trader >= MAXPURCH && !wizard && level != 0) { msg("The market is closed. The stairs are that-a-way! "); @@ -364,7 +371,8 @@ open_market() * Price the object that the hero stands on */ -price_it() +bool +price_it(void) { reg struct linked_list *item; reg struct object *obj; @@ -404,7 +412,8 @@ price_it() * Sell an item to the trading post */ -sell_it() +void +sell_it(void) { reg struct linked_list *item; reg struct object *obj; @@ -451,7 +460,8 @@ sell_it() * Show how many transactions the hero has left */ -trans_line() +void +trans_line(void) { if (level == 0) sprintf(prbuf, "You are welcome to spend whatever gold you have."); @@ -472,8 +482,7 @@ trans_line() */ char * -typ_name(obj) -reg struct object *obj; +typ_name(struct object *obj) { static char buff[20]; reg int wh; diff --git a/xrogue/util.c b/xrogue/util.c index b794926..fc0472d 100644 --- a/xrogue/util.c +++ b/xrogue/util.c @@ -26,8 +26,7 @@ */ int -ac_compute(ignoremetal) -bool ignoremetal; +ac_compute(bool ignoremetal) { register int ac; @@ -60,8 +59,8 @@ bool ignoremetal; * aggravate all the monsters on this level */ -aggravate(do_uniques, do_good) -bool do_uniques, do_good; +void +aggravate(bool do_uniques, bool do_good) { register struct linked_list *mi; register struct thing *thingptr; @@ -78,8 +77,8 @@ bool do_uniques, do_good; * returns true if the hero can see a certain coordinate. */ -cansee(y, x) -register int y, x; +bool +cansee(int y, int x) { register struct room *rer; register int radius; @@ -126,7 +125,7 @@ register int y, x; */ long -check_level() +check_level(void) { register int i, j, add = 0; register unsigned long exp; @@ -170,8 +169,8 @@ check_level() * it keeps track of the highest it has been, just in case */ -chg_str(amt) -register int amt; +void +chg_str(int amt) { register int ring_str; /* ring strengths */ register struct stats *ptr; /* for speed */ @@ -195,7 +194,8 @@ register int amt; * let's confuse the player */ -confus_player() +void +confus_player(void) { if (off(player, ISCLEAR)) { @@ -213,7 +213,8 @@ confus_player() * this routine computes the players current dexterity */ -dex_compute() +int +dex_compute(void) { if (cur_misc[WEAR_GAUNTLET] != NULL && cur_misc[WEAR_GAUNTLET]->o_which == MM_G_DEXTERITY) { @@ -231,9 +232,8 @@ dex_compute() * Check to see if the move is legal if it is diagonal */ -diag_ok(sp, ep, flgptr) -register coord *sp, *ep; -struct thing *flgptr; +bool +diag_ok(coord *sp, coord *ep, struct thing *flgptr) { register int numpaths = 0; @@ -254,10 +254,7 @@ struct thing *flgptr; */ coord * -fallpos(pos, be_clear, range) -register coord *pos; -bool be_clear; -int range; +fallpos(coord *pos, bool be_clear, int range) { register int tried, i, j; register char ch; @@ -333,8 +330,8 @@ int range; * Find the index into the monster table of a monster given its name. */ -findmindex(name) -char *name; +int +findmindex(char *name) { int which; @@ -355,9 +352,7 @@ char *name; */ struct linked_list * -find_mons(y, x) -register int y; -register int x; +find_mons(int y, int x) { register struct linked_list *item; register struct thing *th; @@ -377,9 +372,7 @@ register int x; */ struct linked_list * -find_obj(y, x) -register int y; -register int x; +find_obj(int y, int x) { register struct linked_list *obj; register struct object *op; @@ -398,7 +391,7 @@ register int x; */ coord -get_coordinates() +get_coordinates(void) { register int which; coord c; @@ -458,8 +451,7 @@ get_coordinates() */ bool -get_dir(direction) -coord *direction; +get_dir(coord *direction) { register char *prompt; register bool gotit; @@ -519,8 +511,7 @@ coord *direction; */ long -get_worth(obj) -reg struct object *obj; +get_worth(struct object *obj) { reg long worth, wh; @@ -591,8 +582,7 @@ reg struct object *obj; */ bool -invisible(monst) -register struct thing *monst; +invisible(struct thing *monst) { register bool ret_code; @@ -608,8 +598,8 @@ register struct thing *monst; * see if the object is one of the currently used items */ -is_current(obj) -register struct object *obj; +bool +is_current(struct object *obj) { if (obj == NULL) return FALSE; @@ -648,11 +638,12 @@ register struct object *obj; /* * Look: * A quick glance all around the player + * wakeup: Should we wake up monsters + * runend: At end of a run -- for mazes */ -look(wakeup, runend) -bool wakeup; /* Should we wake up monsters */ -bool runend; /* At end of a run -- for mazes */ +void +look(bool wakeup, bool runend) { register int x, y, radius; register unsigned char ch, och; @@ -937,8 +928,8 @@ bool runend; /* At end of a run -- for mazes */ * Lower a level of experience */ -lower_level(who) -short who; +void +lower_level(short who) { int fewer, nsides; unsigned long exp; @@ -975,8 +966,7 @@ short who; */ char * -monster_name(tp) -register struct thing *tp; +monster_name(struct thing *tp) { prbuf[0] = '\0'; if (on(*tp, ISFLEE) || on(*tp, WASTURNED)) @@ -1007,8 +997,7 @@ register struct thing *tp; */ bool -move_hero(why) -int why; +move_hero(int why) { char *action = NULL; unsigned char which; @@ -1053,7 +1042,8 @@ int why; * The guy just magically went up a level. */ -raise_level() +void +raise_level(void) { unsigned long test; /* Next level -- be sure it is not an overflow */ @@ -1105,12 +1095,13 @@ static const char st_matrix[NUM_CHARTYPES][5] = { /* * save: * See if a creature saves against something + * which: which type of save + * who: who is saving + * adj: saving throw adjustment */ -save(which, who, adj) -int which; /* which type of save */ -struct thing *who; /* who is saving */ -int adj; /* saving throw adjustment */ +bool +save(int which, struct thing *who, int adj) { register int need, level, protect; @@ -1167,8 +1158,8 @@ int adj; /* saving throw adjustment */ * Figure out what a secret door looks like. */ -secretdoor(y, x) -register int y, x; +char +secretdoor(int y, int x) { register int i; register struct room *rp; @@ -1192,7 +1183,8 @@ register int y, x; * this routine computes the players current strength */ -str_compute() +int +str_compute(void) { if (cur_misc[WEAR_GAUNTLET] != NULL && cur_misc[WEAR_GAUNTLET]->o_which == MM_G_OGRE) { @@ -1209,9 +1201,8 @@ str_compute() * copy string using unctrl for things */ -strucpy(s1, s2, len) -register char *s1, *s2; -register int len; +void +strucpy(char *s1, char *s2, int len) { register char *sp; while (len--) @@ -1229,8 +1220,7 @@ register int len; */ char * -tr_name(ch) -char ch; +tr_name(char ch) { register char *s = NULL; @@ -1263,8 +1253,7 @@ char ch; */ char * -vowelstr(str) -register char *str; +vowelstr(char *str) { switch (*str) { @@ -1283,8 +1272,8 @@ register char *str; * wake up a room full (hopefully) of creatures */ -wake_room(rp) -register struct room *rp; +void +wake_room(struct room *rp) { register struct linked_list *item; register struct thing *tp; @@ -1302,7 +1291,8 @@ register struct room *rp; * Do nothing but let other things happen */ -waste_time() +void +waste_time(void) { if (inwhgt) /* if from wghtchk then done */ return; diff --git a/xrogue/weapons.c b/xrogue/weapons.c index 6ba07c8..ef54db1 100644 --- a/xrogue/weapons.c +++ b/xrogue/weapons.c @@ -21,10 +21,8 @@ #include #include "rogue.h" -boomerang(ydelta, xdelta, item, tp) -int ydelta, xdelta; -register struct linked_list *item; -register struct thing *tp; +void +boomerang(int ydelta, int xdelta, struct linked_list *item, struct thing *tp) { register struct object *obj; struct thing midpoint; @@ -56,10 +54,8 @@ register struct thing *tp; * tp other than t_pos unless we change boomerang(). */ -do_motion(obj, ydelta, xdelta, tp) -register struct object *obj; -register int ydelta, xdelta; -register struct thing *tp; +void +do_motion(struct object *obj, int ydelta, int xdelta, struct thing *tp) { /* @@ -117,9 +113,8 @@ register struct thing *tp; * Drop an item someplace around here. */ -fall(item, pr) -register struct linked_list *item; -bool pr; +void +fall(struct linked_list *item, bool pr) { register struct object *obj; register struct room *rp; @@ -171,10 +166,8 @@ bool pr; * Does the missile hit the monster */ -hit_monster(y, x, obj, tp) -register int y, x; -struct object *obj; -register struct thing *tp; +bool +hit_monster(int y, int x, struct object *obj, struct thing *tp) { static coord mp; @@ -204,9 +197,8 @@ register struct thing *tp; * Set up the initial goodies for a weapon */ -init_weapon(weap, type) -register struct object *weap; -char type; +void +init_weapon(struct object *weap, char type) { register struct init_weps *iwp; @@ -229,10 +221,8 @@ char type; * Fire a missile in a given direction */ -missile(ydelta, xdelta, item, tp) -int ydelta, xdelta; -register struct linked_list *item; -register struct thing *tp; +void +missile(int ydelta, int xdelta, struct linked_list *item, struct thing *tp) { register struct object *obj; register struct linked_list *nitem; @@ -308,8 +298,7 @@ register struct thing *tp; */ char * -num(n1, n2) -register int n1, n2; +num(int n1, int n2) { static char numbuf[LINELEN/2]; @@ -329,7 +318,8 @@ register int n1, n2; * Pull out a certain weapon */ -wield() +void +wield(void) { register struct linked_list *item; register struct object *obj, *oweapon; diff --git a/xrogue/wear.c b/xrogue/wear.c index 0b06b5c..bc092cb 100644 --- a/xrogue/wear.c +++ b/xrogue/wear.c @@ -20,12 +20,15 @@ #include #include "rogue.h" +int dress_units(struct linked_list *item); + /* * take_off: * Get the armor off of the players back */ -take_off() +void +take_off(void) { register struct object *obj; register struct linked_list *item; @@ -74,7 +77,8 @@ take_off() * The player wants to wear something, so let him/her put it on. */ -wear() +void +wear(void) { register struct linked_list *item; register struct object *obj; @@ -395,8 +399,8 @@ wear() * given item of "clothing"? */ -dress_units(item) -struct linked_list *item; +int +dress_units(struct linked_list *item) { register struct object *obj; diff --git a/xrogue/wizard.c b/xrogue/wizard.c index 4483f80..a9a7dae 100644 --- a/xrogue/wizard.c +++ b/xrogue/wizard.c @@ -21,6 +21,8 @@ * under strange circumstances) */ +int getbless(void); + #include #include #include @@ -33,9 +35,8 @@ * Create any object for wizard, scroll, magician, or cleric */ -create_obj(prompt, which_item, which_type) -bool prompt; -int which_item, which_type; +void +create_obj(bool prompt, int which_item, int which_type) { reg struct linked_list *item; reg struct object *obj; @@ -338,7 +339,7 @@ int which_item, which_type; */ int -getbless() +getbless(void) { reg char bless; @@ -356,7 +357,8 @@ getbless() * get a non-monster death type */ -getdeath() +int +getdeath(void) { register int i; int which_death; @@ -385,11 +387,11 @@ getdeath() /* * make a monster for the wizard + * showall -> show uniques and genocided creatures */ -makemonster(showall, action) -bool showall; /* showall -> show uniques and genocided creatures */ -char *action; +short +makemonster(bool showall, char *action) { register int i; register short which_monst; @@ -485,7 +487,7 @@ get_monst: */ bool -passwd() +passwd(void) { register char *sp, c; char buf[LINELEN]; @@ -522,7 +524,7 @@ passwd() */ void -teleport() +teleport(void) { register struct room *new_rp = NULL, *old_rp = roomin(&hero); register int rm, which; @@ -622,8 +624,8 @@ teleport() * What a certin object is */ -whatis(what) -struct linked_list *what; +void +whatis(struct linked_list *what) { register struct object *obj; register struct linked_list *item; @@ -686,7 +688,8 @@ struct linked_list *what; * (if on STARTLEV equipage level = 0) */ -choose_qst() +void +choose_qst(void) { bool doit = TRUE; bool escp = TRUE; @@ -718,7 +721,7 @@ choose_qst() if (menu_overlay) /* Print the selections. The longest line is * Hruggek (26 characters). The prompt is 21. */ - over_win(cw, hw, 20, 29, 0, 21, NULL); + over_win(cw, hw, 20, 29, 0, 21, '\0'); else draw(hw);