Mercurial > hg > early-roguelike
changeset 215:1b73a8641b37
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.
author | John "Elwin" Edwards |
---|---|
date | Wed, 27 Jan 2016 19:41:05 -0500 |
parents | e5a15b09ce1d |
children | b24545357d2e |
files | rogue4/armor.c rogue4/chase.c rogue4/command.c rogue4/daemon.c rogue4/daemons.c rogue4/extern.h rogue4/fight.c rogue4/init.c rogue4/io.c rogue4/list.c rogue4/mach_dep.c rogue4/main.c rogue4/mdport.c rogue4/misc.c rogue4/monsters.c rogue4/move.c rogue4/new_level.c rogue4/options.c rogue4/pack.c rogue4/passages.c rogue4/potions.c rogue4/rings.c rogue4/rip.c rogue4/rogue.h rogue4/rooms.c rogue4/save.c rogue4/scrolls.c rogue4/state.c rogue4/sticks.c rogue4/things.c rogue4/weapons.c rogue4/wizard.c |
diffstat | 32 files changed, 625 insertions(+), 394 deletions(-) [+] |
line wrap: on
line diff
--- a/rogue4/armor.c Sat Jan 23 09:35:14 2016 -0500 +++ b/rogue4/armor.c Wed Jan 27 19:41:05 2016 -0500 @@ -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 @@ * take_off: * Get the armor off of the players back */ -take_off() +void +take_off(void) { register THING *obj; @@ -77,7 +79,8 @@ * waste_time: * Do nothing but let other things happen */ -waste_time() +void +waste_time(void) { do_daemons(BEFORE); do_fuses(BEFORE);
--- a/rogue4/chase.c Sat Jan 23 09:35:14 2016 -0500 +++ b/rogue4/chase.c Wed Jan 27 19:41:05 2016 -0500 @@ -10,6 +10,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include <stdlib.h> #include <curses.h> #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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * in any room. */ struct room * -roomin(cp) -register coord *cp; +roomin(coord *cp) { register struct room *rp; register char *fp; @@ -360,8 +363,8 @@ * 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 @@ * 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 @@ * find the proper destination for the monster */ coord * -find_dest(tp) -register THING *tp; +find_dest(THING *tp) { register THING *obj; register int prob;
--- a/rogue4/command.c Sat Jan 23 09:35:14 2016 -0500 +++ b/rogue4/command.c Wed Jan 27 19:41:05 2016 -0500 @@ -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 @@ * 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 @@ * search: * Player gropes about him to find hidden things. */ -search() +void +search(void) { register int y, x; register char *fp; @@ -400,7 +416,8 @@ * 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 @@ * identify: * Tell the player what a certain thing is. */ -identify() +void +identify(void) { register char ch; register const char *str; @@ -502,7 +520,8 @@ * 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 @@ * 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 @@ * call: * Allow a user to call a potion, scroll, or ring something */ -call() +void +call(void) { register THING *obj; register char **guess;
--- a/rogue4/daemon.c Sat Jan 23 09:35:14 2016 -0500 +++ b/rogue4/daemon.c Wed Jan 27 19:41:05 2016 -0500 @@ -29,7 +29,7 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * extinguish: * Put out a fuse */ -extinguish(func) -int (*func)(); +void +extinguish(int (*func)()) { register struct delayed_action *wire; @@ -163,8 +161,8 @@ * do_fuses: * Decrement counters and start needed fuses */ -do_fuses(flag) -register int flag; +void +do_fuses(int flag) { register struct delayed_action *wire;
--- a/rogue4/daemons.c Sat Jan 23 09:35:14 2016 -0500 +++ b/rogue4/daemons.c Wed Jan 27 19:41:05 2016 -0500 @@ -19,7 +19,8 @@ * doctor: * A healing daemon that restors hit points after rest */ -doctor() +void +doctor(void) { register int lv, ohp; @@ -50,7 +51,8 @@ * 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 @@ * rollwand: * Called to roll to see if a wandering monster starts up */ -rollwand() +void +rollwand(void) { if (++between >= 4) { @@ -77,7 +80,8 @@ * 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 @@ * unsee: * Turn off the ability to see invisible */ -unsee() +void +unsee(void) { register THING *th; @@ -104,7 +109,8 @@ * sight: * He gets his sight back */ -sight() +void +sight(void) { if (on(player, ISBLIND)) { @@ -120,7 +126,8 @@ * nohaste: * End the hasting */ -nohaste() +void +nohaste(void) { player.t_flags &= ~ISHASTE; msg("you feel yourself slowing down"); @@ -130,7 +137,8 @@ * stomach: * Digest the hero's food */ -stomach() +void +stomach(void) { register int oldfood;
--- a/rogue4/extern.h Sat Jan 23 09:35:14 2016 -0500 +++ b/rogue4/extern.h Wed Jan 27 19:41:05 2016 -0500 @@ -52,17 +52,9 @@ * 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();
--- a/rogue4/fight.c Sat Jan 23 09:35:14 2016 -0500 +++ b/rogue4/fight.c Wed Jan 27 19:41:05 2016 -0500 @@ -10,6 +10,7 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include <stdlib.h> #include <curses.h> #include <ctype.h> #include <string.h> @@ -20,15 +21,20 @@ 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 @@ * attack: * The monster attacks the player */ -attack(mp) -register THING *mp; +int +attack(THING *mp) { register const char *mname; @@ -295,8 +301,8 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * bounce: * A missile misses a monster */ -bounce(weap, mname) -register THING *weap; -register const char *mname; +void