changeset 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 94a0d9dd5ce1
children f9ef86cf22b2
files arogue5/chase.c arogue5/command.c arogue5/daemon.c arogue5/daemons.c arogue5/encumb.c arogue5/fight.c arogue5/init.c arogue5/io.c arogue5/list.c arogue5/main.c arogue5/maze.c arogue5/mdport.c arogue5/misc.c arogue5/monsters.c arogue5/move.c arogue5/new_level.c arogue5/options.c arogue5/outside.c arogue5/pack.c arogue5/passages.c arogue5/player.c arogue5/potions.c arogue5/rings.c arogue5/rip.c arogue5/rogue.h arogue5/rooms.c arogue5/save.c arogue5/scrolls.c arogue5/state.c arogue5/sticks.c arogue5/things.c arogue5/trader.c arogue5/util.c arogue5/weapons.c arogue5/wear.c arogue5/wizard.c arogue5/xcrypt.c
diffstat 37 files changed, 977 insertions(+), 733 deletions(-) [+]
line wrap: on
line diff
--- a/arogue5/chase.c	Sun Jan 31 13:45:07 2016 -0500
+++ b/arogue5/chase.c	Sun Feb 07 14:39:21 2016 -0500
@@ -12,6 +12,7 @@
  * See the file LICENSE.TXT for full copyright and licensing information.
  */
 
+#include <stdlib.h>
 #include <ctype.h>
 #include <limits.h>
 #include "curses.h"
@@ -21,8 +22,8 @@
 
 coord ch_ret;				/* Where chasing takes you */
 
-
-
+struct linked_list *get_hurl(struct thing *tp);
+bool straight_shot(int ery, int erx, int eey, int eex, coord *shooting);
 
 
 /*
@@ -31,8 +32,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 */
@@ -128,8 +128,7 @@
  */
 
 coord *
-can_shoot(er, ee)
-register coord *er, *ee;
+can_shoot(coord *er, coord *ee)
 {
     static coord shoot_dir;
 
@@ -154,13 +153,11 @@
  *	FALSE if we reach the goal.
  */
 
-chase(tp, ee, flee, mdead)
-register struct thing *tp;
-register coord *ee;
-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
-	    */
-bool *mdead;
+/* 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
+ */
+bool
+chase(struct thing *tp, coord *ee, bool flee, bool *mdead)
 {
     int damage, dist, thisdist, monst_dist = MAXINT; 
     struct linked_list *weapon;
@@ -530,10 +527,10 @@
  * do_chase:
  *	Make one thing chase another.
  */
+/* flee: True if running away or player is inaccessible in wall */
 
-do_chase(th, flee)
-register struct thing *th;
-register bool flee; /* True if running away or player is inaccessible in wall */
+void
+do_chase(struct thing *th, bool flee)
 {
     register struct room *rer, *ree,	/* room of chaser, room of chasee */
 			 *orig_rer,	/* Original room of chaser */
@@ -830,8 +827,7 @@
  */
 
 struct linked_list *
-get_hurl(tp)
-register struct thing *tp;
+get_hurl(struct thing *tp)
 {
     struct linked_list *arrow, *bolt, *rock;
     register struct linked_list *pitem;
@@ -861,7 +857,8 @@
  *	Make all the running monsters move.
  */
 
-runners()
+void
+runners(void)
 {
     register struct linked_list *item;
     register struct thing *tp = NULL;
@@ -935,9 +932,8 @@
  *	Set a monster running after something
  */
 
-runto(runner, spot)
-register struct thing *runner;
-coord *spot;
+void
+runto(struct thing *runner, coord *spot)
 {
     /*
      * Start the beastie running
@@ -959,9 +955,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/arogue5/command.c	Sun Jan 31 13:45:07 2016 -0500
+++ b/arogue5/command.c	Sun Feb 07 14:39:21 2016 -0500
@@ -21,12 +21,20 @@
 #include "rogue.h"
 #include "mach_dep.h"
 
+void help(void);
+void identify(void);
+void d_level(void);
+void u_level(void);
+void shell(void);
+void call(bool mark);
+
 /*
  * command:
  *	Process the user commands
  */
 
-command()
+void
+command(void)
 {
     register char ch;
     register int ntimes = 1;			/* Number of player moves */
@@ -207,8 +215,8 @@
 		when 'I' : after = FALSE; picky_inven();
 		when 'd' : drop(NULL);
 		when 'P' : grab(hero.y, hero.x);
-		when 'q' : quaff(-1, NULL, TRUE);
-		when 'r' : read_scroll(-1, NULL, TRUE);
+		when 'q' : quaff(-1, 0, TRUE);
+		when 'r' : read_scroll(-1, 0, TRUE);
 		when 'e' : eat();
 		when 'w' : wield();
 		when 'W' : wear();
@@ -228,7 +236,7 @@
 		when 'G' : gsense();
 		when '^' : set_trap(&player, hero.y, hero.x);
 		when 's' : search(FALSE, FALSE);
-		when 'z' : if (!do_zap(TRUE, NULL, FALSE))
+		when 'z' : if (!do_zap(TRUE, 0, FALSE))
 				after=FALSE;
 		when 'p' : pray();
 		when 'C' : cast();
@@ -475,8 +483,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 */
@@ -488,8 +495,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 */
@@ -570,7 +577,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
@@ -664,7 +672,8 @@
  *	Tell the player what a certain thing is.
  */
 
-identify()
+void
+identify(void)
 {
     register char ch;
     const char *str;
@@ -726,7 +735,8 @@
  *	He wants to go down a level
  */
 
-d_level()
+void
+d_level(void)
 {
     bool no_phase=FALSE;
 
@@ -770,7 +780,8 @@
  *	He wants to go up a level
  */
 
-u_level()
+void
+u_level(void)
 {
     bool no_phase = FALSE;
     register struct linked_list *item;
@@ -828,7 +839,8 @@
  * Let him escape for a while
  */
 
-shell()
+void
+shell(void)
 {
     /*
      * Set the terminal back to original mode
@@ -859,8 +871,8 @@
 /*
  * allow a user to call a potion, scroll, or ring something
  */
-call(mark)
-bool mark;
+void
+call(bool mark)
 {
     register struct object *obj;
     register struct linked_list *item;
--- a/arogue5/daemon.c	Sun Jan 31 13:45:07 2016 -0500
+++ b/arogue5/daemon.c	Sun Feb 07 14:39:21 2016 -0500
@@ -36,7 +36,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;
@@ -52,7 +52,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;
@@ -70,8 +70,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;
@@ -87,6 +86,7 @@
  * start_daemon:
  *	Start a daemon, takes a function.
  */
+void
 start_daemon(int (*func)(), void *arg, int type)
 {
 	reg struct delayed_action *dev;
@@ -106,8 +106,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;
@@ -133,8 +133,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;
 
@@ -154,6 +154,7 @@
  * fuse:
  *	Start a fuse to go off in a certain number of turns
  */
+void
 fuse(int (*func)(), void *arg, int time, int type)
 {
 	reg struct delayed_action *wire;
@@ -173,8 +174,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;
 
@@ -188,8 +189,8 @@
  * extinguish:
  *	Put out a fuse
  */
-extinguish(func)
-reg int (*func)();
+void
+extinguish(int (*func)())
 {
 	reg struct delayed_action *wire;
 
@@ -207,8 +208,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;
 
@@ -234,7 +235,8 @@
  * activity:
  *	Show wizard number of demaons and memory blocks used
  */
-activity()
+void
+activity(void)
 {
 	sprintf(outstring,"Daemons = %d : Fuses = %d : Memory Items = %d : Memory Used = %d",
 	    demoncnt,fusecnt,total,md_memused());
--- a/arogue5/daemons.c	Sun Jan 31 13:45:07 2016 -0500
+++ b/arogue5/daemons.c	Sun Feb 07 14:39:21 2016 -0500
@@ -22,8 +22,8 @@
  *	A healing daemon that restors hit points after rest
  */
 
-doctor(tp)
-register struct thing *tp;
+void
+doctor(struct thing *tp)
 {
     register int ohp;
     register int limit, new_points;
@@ -100,7 +100,8 @@
  *	Called when it is time to start rolling for wandering monsters
  */
 
-swander()
+void
+swander(void)
 {
     start_daemon(rollwand, 0, BEFORE);
 }
@@ -110,7 +111,8 @@
  *	Called to roll to see if a wandering monster starts up
  */
 
-rollwand()
+void
+rollwand(void)
 {
     if (++between >= 4)
     {
@@ -128,7 +130,8 @@
 /*
  * this function is a daemon called each turn when the character is a thief
  */
-trap_look()
+void
+trap_look(void)
 {
     if (rnd(100) < (2*dex_compute() + 5*pstats.s_lvl))
 	search(TRUE, FALSE);
@@ -139,7 +142,8 @@
  *	Release the poor player from his confusion
  */
 
-unconfuse()
+void
+unconfuse(void)
 {
     turn_off(player, ISHUH);
     msg("You feel less confused now");
@@ -151,7 +155,8 @@
  *	He lost his see invisible power
  */
 
-unsee()
+void
+unsee(void)
 {
     if (!ISWEARING(R_SEEINVIS)) {
 	turn_off(player, CANSEE);
@@ -164,7 +169,8 @@
  *	Remove to-hit handicap from player
  */
 
-unstink()
+void
+unstink(void)
 {
     turn_off(player, HASSTINK);
 }
@@ -174,7 +180,8 @@
  *	Player is no longer immune to confusion
  */
 
-unclrhead()
+void
+unclrhead(void)
 {
     turn_off(player, ISCLEAR);
     msg("The blue aura about your head fades away.");
@@ -185,7 +192,8 @@
  *	Player can no longer walk through walls
  */
 
-unphase()
+void
+unphase(void)
 {
     turn_off(player, CANINWALL);
     msg("Your dizzy feeling leaves you.");
@@ -197,7 +205,8 @@
  *	Player can no longer fly
  */
 
-land()
+void
+land(void)
 {
     turn_off(player, ISFLY);
     msg("You regain your normal weight");
@@ -209,7 +218,8 @@
  *	He gets his sight back
  */
 
-sight()
+void
+sight(void)
 {
     if (on(player, ISBLIND))
     {
@@ -225,7 +235,8 @@
  *	Restore player's strength
  */
 
-res_strength()
+void
+res_strength(void)
 {
 
     /* If lost_str is non-zero, restore that amount of strength,
@@ -249,7 +260,8 @@
  *	End the hasting
  */
 
-nohaste()
+void
+nohaste(void)
 {
     turn_off(player, ISHASTE);
     msg("You feel yourself slowing down.");
@@ -260,7 +272,8 @@
  *	End the slowing
  */
 
-noslow()
+void
+noslow(void)
 {
     turn_off(player, ISSLOW);
     msg("You feel yourself speeding up.");
@@ -271,7 +284,8 @@
  *	If this gets called, the player has suffocated
  */
 
-suffocate()
+void
+suffocate(void)
 {
     death(D_SUFFOCATION);
 }
@@ -279,7 +293,8 @@
 /*
  * digest the hero's food
  */
-stomach()
+void
+stomach(void)
 {
     register int oldfood, old_hunger, food_use, i;
 
@@ -335,7 +350,8 @@
 /*
  * daemon for curing the diseased
  */
-cure_disease()
+void
+cure_disease(void)
 {
     turn_off(player, HASDISEASE);
     if (off (player, HASINFEST))
@@ -346,7 +362,8 @@
 /*
  * daemon for adding back dexterity
  */
-un_itch()
+void
+un_itch(void)
 {
     if (--lost_dext < 1) {
 	lost_dext = 0;
@@ -358,7 +375,8 @@
  * appear:
  *	Become visible again
  */
-appear()
+void
+appear(void)
 {
     turn_off(player, ISINVIS);
     PLAYER = VPLAYER;
@@ -369,7 +387,8 @@
  * dust_appear:
  *	dust of disappearance wears off
  */
-dust_appear()
+void
+dust_appear(void)
 {
     turn_off(player, ISINVIS);
     PLAYER = VPLAYER;
@@ -380,7 +399,8 @@
  * unchoke:
  * 	the effects of "dust of choking and sneezing" wear off
  */
-unchoke()
+void
+unchoke(void)
 {
     if (!find_slot(unconfuse))
 	turn_off(player, ISHUH);
@@ -392,8 +412,8 @@
 /*
  * make some potion for the guy in the Alchemy jug
  */
-alchemy(obj)
-register struct object *obj;
+void
+alchemy(struct object *obj)
 {
     register struct object *tobj = NULL;
     register struct linked_list *item;
@@ -440,7 +460,8 @@
  * otto's irresistable dance wears off 
  */
 
-undance()
+void
+undance(void)
 {
     turn_off(player, ISDANCE);
     msg ("Your feet take a break.....whew!");
@@ -449,14 +470,16 @@
 /* 
  * if he has our favorite necklace of strangulation then take damage every turn
  */
-strangle()
+void
+strangle(void)
 {
      if ((pstats.s_hpt -= 6) <= 0) death(D_STRANGLE);
 }
 /*
  * if he has on the gauntlets of fumbling he might drop his weapon each turn
  */
-fumble()
+void
+fumble(void)
 {
     register struct linked_list *item;
 
@@ -474,14 +497,16 @@
 /*
  * this is called each turn the hero has the ring of searching on
  */
-ring_search()
+void
+ring_search(void)
 {
     search(FALSE, FALSE);
 }
 /*
  * this is called each turn the hero has the ring of teleportation on
  */
-ring_teleport()
+void