changeset 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 56e748983fa8
children f54901b9c39b
files arogue7/actions.c arogue7/chase.c arogue7/command.c arogue7/daemon.c arogue7/daemons.c arogue7/eat.c arogue7/effects.c arogue7/encumb.c arogue7/fight.c arogue7/init.c arogue7/io.c arogue7/list.c arogue7/main.c arogue7/maze.c arogue7/mdport.c arogue7/misc.c arogue7/monsters.c arogue7/move.c arogue7/new_level.c arogue7/options.c arogue7/outside.c arogue7/pack.c arogue7/passages.c arogue7/player.c arogue7/potions.c arogue7/rings.c arogue7/rip.c arogue7/rogue.h arogue7/rooms.c arogue7/save.c arogue7/scrolls.c arogue7/state.c arogue7/sticks.c arogue7/things.c arogue7/trader.c arogue7/util.c arogue7/weapons.c arogue7/wear.c arogue7/wizard.c
diffstat 39 files changed, 1181 insertions(+), 889 deletions(-) [+]
line wrap: on
line diff
--- a/arogue7/actions.c	Sun Feb 07 14:39:21 2016 -0500
+++ b/arogue7/actions.c	Fri Feb 19 21:02:28 2016 -0500
@@ -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 @@
     }
 }
 
-dsrpt_player()
+void
+dsrpt_player(void)
 {
     int which, action;
     struct linked_list *item;
@@ -81,7 +91,7 @@
 	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 @@
  *	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 @@
  *	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 @@
 /*
  * 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 @@
  *	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 @@
  *	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 @@
  *	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 @@
  */
 
 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 @@
 /*
  * 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 @@
  * 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;
--- a/arogue7/chase.c	Sun Feb 07 14:39:21 2016 -0500
+++ b/arogue7/chase.c	Fri Feb 19 21:02:28 2016 -0500
@@ -19,11 +19,13 @@
 
 #include <ctype.h>
 #include <limits.h>
+#include <stdlib.h>
 #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 @@
  */
 
 coord *
-can_shoot(er, ee)
-register coord *er, *ee;
+can_shoot(coord *er, coord *ee)
 {
     static coord shoot_dir;
 
@@ -147,16 +147,14 @@
  * 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 @@
  *	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 @@
  */
 
 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 @@
  *	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 @@
  */
 
 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;
--- a/arogue7/command.c	Sun Feb 07 14:39:21 2016 -0500
+++ b/arogue7/command.c	Fri Feb 19 21:02:28 2016 -0500
@@ -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 @@
 			    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 @@
 		    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 @@
 			    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 @@
  * 	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 @@
  */
 
 void
-quit(sig)
-int sig;
+quit(int sig)
 {
     /*
      * Reset the signal in case we got here via an interrupt
@@ -628,8 +639,7 @@
  */
 
 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 @@
  *	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 @@
  *	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 @@
  *	Tell the player what a certain thing is.
  */
 
-identify(ch)
-register char ch;
+void
+identify(char ch)
 {
     register char *str;
 
@@ -907,6 +918,7 @@
  *	He wants to go down a level
  */
 
+void
 d_level()
 {
     bool no_phase=FALSE;
@@ -958,7 +970,8 @@
  *	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 @@
  * Let him escape for a while
  */
 
-shell()
+void
+shell(void)
 {
     register char *sh;
 
@@ -1050,7 +1064,8 @@
 /*
  * see what we want to name -- an item or a monster.
  */
-nameit()
+void
+nameit(void)
 {
     char answer;
 
@@ -1073,9 +1088,8 @@
 /*
  * 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 @@
 
 /* Name a monster */
 
-namemonst()
+void
+namemonst(void)
 {
     register struct thing *tp;
     struct linked_list *item;
@@ -1206,7 +1221,8 @@
     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...");
--- a/arogue7/daemon.c	Sun Feb 07 14:39:21 2016 -0500
+++ b/arogue7/daemon.c	Fri Feb 19 21:02:28 2016 -0500
@@ -44,7 +44,7 @@
  *	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 @@
  *	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 @@
  *	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 @@
  * 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 @@
  * 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 @@
  *	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 @@
  * 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 @@
  * 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 @@
  * extinguish:
  *	Put out a fuse
  */
-extinguish(func)
-reg int (*func)();
+void
+extinguish(int (*func)())
 {
 	reg struct delayed_action *wire;
 
@@ -217,8 +216,8 @@
  * 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 @@
  * 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());
 }
--- a/arogue7/daemons.c	Sun Feb 07 14:39:21 2016 -0500
+++ b/arogue7/daemons.c	Fri Feb 19 21:02:28 2016 -0500
@@ -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;