diff arogue7/util.c @ 219:f9ef86cf22b2

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.
author John "Elwin" Edwards
date Fri, 19 Feb 2016 21:02:28 -0500
parents 1cd604c827a3
children e1cd27c5464f
line wrap: on
line diff
--- a/arogue7/util.c	Sun Feb 07 14:39:21 2016 -0500
+++ b/arogue7/util.c	Fri Feb 19 21:02:28 2016 -0500
@@ -35,8 +35,7 @@
  * 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 @@
  *	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 @@
  *	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 @@
  * further levels
  */
 long
-check_level()
+check_level(void)
 {
     register int i, j, add = 0;
     register unsigned long exp;
@@ -178,8 +177,8 @@
  * 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 @@
 /*
  * let's confuse the player
  */
-confus_player()
+void
+confus_player(void)
 {
     if (off(player, ISCLEAR))
     {
@@ -218,7 +218,8 @@
 /*
  * 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 @@
  *	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 @@
  * 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 @@
  *	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 @@
  */
 
 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 @@
  */
 
 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 @@
  * 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 @@
  * 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 @@
 /* 
  * 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 @@
 /*
  * 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 @@
  * 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 @@
  * 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 @@
  */
 
 bool
-move_hero(why)
-int why;
+move_hero(int why)
 {
     char *action = "";
     char which;
@@ -1049,7 +1040,8 @@
  *	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 @@
 /*
  * 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 @@
  *	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 @@
 /*
  * 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 @@
 /*
  * 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 @@
  */
 
 char *
-tr_name(ch)
-char ch;
+tr_name(char ch)
 {
     register char *s = "";
 
@@ -1235,8 +1227,7 @@
  * 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 @@
 /*
  * 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 @@
  *	Do nothing but let other things happen
  */
 
-waste_time()
+void
+waste_time(void)
 {
     if (inwhgt)			/* if from wghtchk then done */
 	return;