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;