Mercurial > hg > early-roguelike
diff arogue5/fight.c @ 218:56e748983fa8
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.
author | John "Elwin" Edwards |
---|---|
date | Sun, 07 Feb 2016 14:39:21 -0500 |
parents | 0ed67132cf10 |
children | 0990adf580ee |
line wrap: on
line diff
--- a/arogue5/fight.c Sun Jan 31 13:45:07 2016 -0500 +++ b/arogue5/fight.c Sun Feb 07 14:39:21 2016 -0500 @@ -13,10 +13,27 @@ */ #include "curses.h" +#include <stdlib.h> #include <ctype.h> #include <string.h> #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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ */ char * -prname(who, upper) -register char *who; -bool upper; +prname(char *who, bool upper) { static char tbuf[LINELEN]; @@ -1054,11 +1061,8 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * hung_dam: * Calculate damage depending on players hungry state */ -hung_dam() +int +hung_dam(void) { reg int howmuch = 0; @@ -1222,11 +1225,10 @@ * 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 @@ * 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 @@ * 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 @@ 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 @@ * 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 @@ * 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 @@ */ 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 @@ return(candidate); } -explode(tp) -register struct thing *tp; +void +explode(struct thing *tp) { register int x,y, damage;