changeset 217:94a0d9dd5ce1

Super-Rogue: convert to ANSI-style function declarations. This fixes most of the build warnings.
author John "Elwin" Edwards
date Sun, 31 Jan 2016 13:45:07 -0500
parents b24545357d2e
children 56e748983fa8
files srogue/armor.c srogue/chase.c srogue/command.c srogue/daemon.c srogue/daemons.c srogue/disply.c srogue/encumb.c srogue/fight.c srogue/init.c srogue/io.c srogue/list.c srogue/main.c srogue/misc.c srogue/monsters.c srogue/move.c srogue/new_leve.c srogue/options.c srogue/pack.c srogue/passages.c srogue/potions.c srogue/pstats.c srogue/rings.c srogue/rip.c srogue/rogue.ext srogue/rooms.c srogue/save.c srogue/scrolls.c srogue/state.c srogue/sticks.c srogue/things.c srogue/trader.c srogue/weapons.c srogue/wizard.c
diffstat 33 files changed, 783 insertions(+), 518 deletions(-) [+]
line wrap: on
line diff
--- a/srogue/armor.c	Thu Jan 28 18:55:47 2016 -0500
+++ b/srogue/armor.c	Sun Jan 31 13:45:07 2016 -0500
@@ -21,7 +21,8 @@
  * wear:
  *	The player wants to wear something, so let the hero try
  */
-wear()
+void
+wear(void)
 {
 	reg struct linked_list *item;
 	reg struct object *obj;
@@ -50,7 +51,8 @@
  * take_off:
  *	Get the armor off of the players back
  */
-take_off()
+void
+take_off(void)
 {
 	reg struct object *obj;
 
@@ -69,9 +71,8 @@
  * initarmor:
  *		Initialize some armor.
  */
-initarmor(obj, what)
-struct object *obj;
-int what;
+void
+initarmor(struct object *obj, int what)
 {
 	struct init_armor *iwa;
 	struct magic_item *mi;
@@ -90,8 +91,8 @@
  * hurt_armor:
  *	Returns TRUE if armor is damaged
  */
-hurt_armor(obj)
-struct object *obj;
+bool
+hurt_armor(struct object *obj)
 {
 	reg int type, ac;
 
--- a/srogue/chase.c	Thu Jan 28 18:55:47 2016 -0500
+++ b/srogue/chase.c	Sun Jan 31 13:45:07 2016 -0500
@@ -14,19 +14,24 @@
  * See the file LICENSE.TXT for full copyright and licensing information.
  */
 
+#include <stdlib.h>
 #include "rogue.h"
 #include "rogue.ext"
 
 #define FARAWAY	32767
 #define RDIST(a, b)	(DISTANCE((a)->y, (a)->x, (b).y, (b).x))
 
+int do_chase(struct linked_list *mon);
+int chase(struct thing *tp, struct coord *ee, bool runaway, bool dofight);
+
 struct coord ch_ret;	/* Where chasing takes you */
 
 /*
  * runners:
  *	Make all the running monsters move.
  */
-runners()
+void
+runners(void)
 {
 	reg struct thing *tp;
 	reg struct linked_list *mon,*nextmon;
@@ -54,8 +59,8 @@
  * do_chase:
  *	Make one thing chase another.
  */
-do_chase(mon)
-struct linked_list *mon;
+int
+do_chase(struct linked_list *mon)
 {
 	reg struct thing *th;
 	reg struct room *rer, *ree, *rxx;
@@ -241,10 +246,8 @@
  *	chasee.  Returns TRUE if we want to keep on chasing
  *	later FALSE if we reach the goal.
  */
-chase(tp, ee, runaway, dofight)
-struct thing *tp;
-struct coord *ee;
-bool runaway, dofight;
+int
+chase(struct thing *tp, struct coord *ee, bool runaway, bool dofight)
 {
 	reg int x, y, ch;
 	reg int dist, thisdist, closest;
@@ -385,9 +388,8 @@
  * runto:
  *	Set a monster running after something
  */
-runto(runner, spot)
-struct coord *runner;
-struct coord *spot;
+void
+runto(struct coord *runner, struct coord *spot)
 {
 	reg struct linked_list *item;
 	reg struct thing *tp;
@@ -409,8 +411,7 @@
  *	NULL means they aren't in any room.
  */
 struct room *
-roomin(cp)
-struct coord *cp;
+roomin(struct coord *cp)
 {
 	reg struct room *rp;
 
@@ -428,8 +429,7 @@
  *	Find the monster from his coordinates
  */
 struct linked_list *
-find_mons(y, x)
-int y, x;
+find_mons(int y, int x)
 {
 	reg struct linked_list *item;
 	reg struct thing *th;
@@ -447,8 +447,8 @@
  * diag_ok:
  *	Check to see if the move is legal if it is diagonal
  */
-diag_ok(sp, ep)
-struct coord *sp, *ep;
+bool
+diag_ok(struct coord *sp, struct coord *ep)
 {
 	if (ep->x == sp->x || ep->y == sp->y)
 		return TRUE;
@@ -462,8 +462,8 @@
  * cansee:
  *	returns true if the hero can see a certain coordinate.
  */
-cansee(y, x)
-int y, x;
+bool
+cansee(int y, int x)
 {
 	reg struct room *rer;
 	struct coord tp;
--- a/srogue/command.c	Thu Jan 28 18:55:47 2016 -0500
+++ b/srogue/command.c	Sun Jan 31 13:45:07 2016 -0500
@@ -29,11 +29,19 @@
 #include <unistd.h>
 #endif
 
+void search(void);
+void help(void);
+void d_level(void);
+void u_level(void);
+void shell(void);
+void call(void);
+
 /*
  * command:
  *	Process the user commands
  */
-command()
+void
+command(void)
 {
 	reg char ch;
 	reg int ntimes = 1;		/* Number of player moves */
@@ -416,7 +424,8 @@
  *	Player gropes about him to find hidden things.
  */
 
-search()
+void
+search(void)
 {
 	reg int x, y;
 	reg char ch;
@@ -461,7 +470,8 @@
  * help:
  *	Give single character help, or the whole mess if he wants it
  */
-help()
+void
+help(void)
 {
 	extern struct h_list helpstr[];
 	reg struct h_list *strp;
@@ -519,8 +529,7 @@
  *	Tell the player what a certain thing is.
  */
 char *
-identify(what)
-int what;
+identify(int what)
 {
 	reg char ch, *str;
 
@@ -581,7 +590,8 @@
  * d_level:
  *	He wants to go down a level
  */
-d_level()
+void
+d_level(void)
 {
 	if (winat(hero.y, hero.x) != STAIRS)
 		msg("I see no way down.");
@@ -599,7 +609,8 @@
  * u_level:
  *	He wants to go up a level
  */
-u_level()
+void
+u_level(void)
 {
 	if (winat(hero.y, hero.x) == STAIRS)  {
 		if (pl_on(ISHELD)) {
@@ -624,7 +635,8 @@
 /*
  * Let him escape for a while
  */
-shell()
+void
+shell(void)
 {
 	reg int pid;
 	reg char *sh;
@@ -659,7 +671,8 @@
  * call:
  *	Allow a user to call a potion, scroll, or ring something
  */
-call()
+void
+call(void)
 {
 	reg struct object *obj;
 	reg struct linked_list *item;
--- a/srogue/daemon.c	Thu Jan 28 18:55:47 2016 -0500
+++ b/srogue/daemon.c	Sun Jan 31 13:45:07 2016 -0500
@@ -34,8 +34,7 @@
  *	Insert a function in the daemon list.
  */
 struct delayed_action *
-d_insert(func, arg, type, time)
-int arg, type, time, (*func)();
+d_insert(int (*func)(), int arg, int type, int time)
 {
 	reg struct delayed_action *dev;
 
@@ -51,8 +50,8 @@
 	return NULL;
 }
 
-d_delete(wire)
-struct delayed_action *wire;
+void
+d_delete(struct delayed_action *wire)
 {
 	reg struct delayed_action *d1, *d2;
 
@@ -73,8 +72,7 @@
  *	Find a particular slot in the table
  */
 struct delayed_action *
-find_slot(func)
-int (*func)();
+find_slot(int (*func)())
 {
 	reg struct delayed_action *dev;
 
@@ -88,8 +86,8 @@
  * start_daemon:
  *	Start a daemon, takes a function.
  */
-start_daemon(func, arg, type)
-int arg, type, (*func)();
+void
+start_daemon(int (*func)(), int arg, int type)
 {
 	d_insert(func, arg, type, DAEMON);
 }
@@ -99,8 +97,8 @@
  *	Run all the daemons that are active with the current
  *	flag, passing the argument to the function.
  */
-do_daemons(flag)
-int flag;
+void
+do_daemons(int flag)
 {
 	reg struct delayed_action *dev;
 
@@ -113,8 +111,8 @@
  * fuse:
  *	Start a fuse to go off in a certain number of turns
  */
-fuse(func, arg, time)
-int (*func)(), arg, time;
+void
+fuse(int (*func)(), int arg, int time)
 {
 	d_insert(func, arg, AFTER, time);
 }
@@ -123,8 +121,8 @@
  * lengthen:
  *	Increase the time until a fuse goes off
  */
-lengthen(func, xtime)
-int (*func)(), xtime;
+void
+lengthen(int (*func)(), int xtime)
 {
 	reg struct delayed_action *wire;
 
@@ -137,8 +135,8 @@
  * extinguish:
  *	Put out a fuse. Find all such fuses and kill them.
  */
-extinguish(func)
-int (*func)();
+void
+extinguish(int (*func)())
 {
 	reg struct delayed_action *dev;
 
@@ -151,7 +149,8 @@
  * do_fuses:
  *	Decrement counters and start needed fuses
  */
-do_fuses()
+void
+do_fuses(void)
 {
 	reg struct delayed_action *dev;
 
@@ -170,7 +169,8 @@
  * activity:
  *	Show wizard number of demaons and memory blocks used
  */
-activity()
+void
+activity(void)
 {
 	msg("Daemons = %d : Memory Items = %d : Memory Used = %d",
 	    demoncnt,total,md_memused());
--- a/srogue/daemons.c	Thu Jan 28 18:55:47 2016 -0500
+++ b/srogue/daemons.c	Sun Jan 31 13:45:07 2016 -0500
@@ -23,8 +23,8 @@
  * doctor:
  *	A healing daemon that restores hit points after rest
  */
-doctor(fromfuse)
-int fromfuse;
+void
+doctor(int fromfuse)
 {
 	reg int *thp, lv, ohp, ccon;
 
@@ -63,8 +63,8 @@
  * Swander:
  *	Called when it is time to start rolling for wandering monsters
  */
-swander(fromfuse)
-int fromfuse;
+void
+swander(int fromfuse)
 {
 	start_daemon(rollwand, TRUE, AFTER);
 }
@@ -74,8 +74,8 @@
  * rollwand:
  *	Called to roll to see if a wandering monster starts up
  */
-rollwand(fromfuse)
-int fromfuse;
+void
+rollwand(int fromfuse)
 {
 
 	if (++between >= 4) {
@@ -94,8 +94,8 @@
  * unconfuse:
  *	Release the poor player from his confusion
  */
-unconfuse(fromfuse)
-int fromfuse;
+void
+unconfuse(int fromfuse)
 {
 	if (pl_on(ISHUH))
 		msg("You feel less confused now.");
@@ -106,8 +106,8 @@
  * unsee:
  *	He lost his see invisible power
  */
-unsee(fromfuse)
-int fromfuse;
+void
+unsee(int fromfuse)
 {
 	player.t_flags &= ~CANSEE;
 }
@@ -116,8 +116,8 @@
  * sight:
  *	He gets his sight back
  */
-sight(fromfuse)
-int fromfuse;
+void
+sight(int fromfuse)
 {
 	if (pl_on(ISBLIND))
 		msg("The veil of darkness lifts.");
@@ -129,8 +129,8 @@
  * nohaste:
  *	End the hasting
  */
-nohaste(fromfuse)
-int fromfuse;
+void
+nohaste(int fromfuse)
 {
 	if (pl_on(ISHASTE))
 		msg("You feel yourself slowing down.");
@@ -142,8 +142,8 @@
  * stomach:
  *	Digest the hero's food
  */
-stomach(fromfuse)
-int fromfuse;
+void
+stomach(int fromfuse)
 {
 	reg int oldfood, old_hunger;
 
@@ -188,8 +188,8 @@
  * noteth:
  *	Hero is no longer etherereal
  */
-noteth(fromfuse)
-int fromfuse;
+void
+noteth(int fromfuse)
 {
 	int ch;
 
@@ -209,8 +209,8 @@
  * sapem:
  *	Sap the hero's life away
  */
-sapem(fromfuse)
-int fromfuse;
+void
+sapem(int fromfuse)
 {
 	chg_abil(rnd(4) + 1, -1, TRUE);
 	fuse(sapem, TRUE, 150);
@@ -221,8 +221,8 @@
  * notslow:
  *	Restore the hero's normal speed
  */
-notslow(fromfuse)
-int fromfuse;
+void
+notslow(int fromfuse)
 {
 	if (pl_on(ISSLOW))
 		msg("You no longer feel hindered.");
@@ -233,8 +233,8 @@
  * notregen:
  *	Hero is no longer regenerative
  */
-notregen(fromfuse)
-int fromfuse;
+void
+notregen(int fromfuse)
 {
 	if (pl_on(ISREGEN))
 		msg("You no longer feel bolstered.");
@@ -245,8 +245,8 @@
  * notinvinc:
  *	Hero not invincible any more
  */
-notinvinc(fromfuse)
-int fromfuse;
+void
+notinvinc(int fromfuse)
 {
 	if (pl_on(ISINVINC))
 		msg("You no longer feel invincible.");
--- a/srogue/disply.c	Thu Jan 28 18:55:47 2016 -0500
+++ b/srogue/disply.c	Sun Jan 31 13:45:07 2016 -0500
@@ -18,7 +18,8 @@
  * displevl:
  *	Display detailed level for wizard and scroll
  */
-displevl()
+void
+displevl(void)
 {
 	reg char ch, mch;
 	reg int i,j;
@@ -73,7 +74,8 @@
  * dispmons:
  *	Show monsters for wizard and potion
  */
-dispmons()
+void
+dispmons(void)
 {
 	reg int ch, y, x;
 	reg struct thing *it;
@@ -95,8 +97,8 @@
  * winat:
  *	Get whatever character is at a location on the screen
  */
-winat(y, x)
-int x, y;
+char
+winat(int y, int x)
 {
 	reg char ch;
 
@@ -111,8 +113,8 @@
  * cordok:
  *	Returns TRUE if coordinate is on usable screen
  */
-cordok(y, x)
-int y, x;
+bool
+cordok(int y, int x)
 {
 	if (x < 0 || y < 0 || x >= COLS || y >= LINES - 1)
 		return FALSE;
@@ -123,8 +125,8 @@
  * pl_on:
  *	Returns TRUE if the player's flag is set
  */
-pl_on(what)
-long what;
+bool
+pl_on(long what)
 {
 	return (player.t_flags & what);
 }
@@ -134,8 +136,8 @@
  * pl_off:
  *	Returns TRUE when player's flag is reset
  */
-pl_off(what)
-long what;
+bool
+pl_off(long what)
 {
 	return (!(player.t_flags & what));
 }
@@ -145,9 +147,8 @@
  * o_on:
  *	Returns TRUE in the objects flag is set
  */
-o_on(what,bit)
-struct object *what;
-long bit;
+bool
+o_on(struct object *what, long bit)
 {
 	reg int flag;
 
@@ -162,9 +163,8 @@
  * o_off:
  *	Returns TRUE is the objects flag is reset
  */
-o_off(what,bit)
-struct object *what;
-long bit;
+bool
+o_off(struct object *what, long bit)
 {
 	reg int flag;
 
@@ -179,9 +179,8 @@
  * setoflg:
  *	Set the specified flag for the object
  */
-setoflg(what,bit)
-struct object *what;
-long bit;
+void
+setoflg(struct object *what, long bit)
 {
 	what->o_flags |= bit;
 }
@@ -191,9 +190,8 @@
  * resoflg:
  *	Reset the specified flag for the object
  */
-resoflg(what,bit)
-struct object *what;
-long bit;
+void
+resoflg(struct object *what, long bit)
 {
 	what->o_flags &= ~bit;
 }
--- a/srogue/encumb.c	Thu Jan 28 18:55:47 2016 -0500
+++ b/srogue/encumb.c	Sun Jan 31 13:45:07 2016 -0500
@@ -10,14 +10,19 @@
  * See the file LICENSE.TXT for full copyright and licensing information.
  */
 
+#include <string.h>
 #include "rogue.h"
 #include "rogue.ext"
 
+int packweight(void);
+int pack_vol(void);
+
 /*
  * updpack:
  *	Update his pack weight and adjust fooduse accordingly
  */
-updpack()
+void
+updpack(void)
 {
 	reg int topcarry, curcarry;
 
@@ -44,7 +49,8 @@
  * packweight:
  *	Get the total weight of the hero's pack
  */
-packweight()
+int
+packweight(void)
 {
 	reg struct object *obj;
 	reg struct linked_list *pc;
@@ -72,8 +78,8 @@
  * itemweight:
  *	Get the weight of an object
  */
-itemweight(wh)
-struct object *wh;
+int
+itemweight(struct object *wh)
 {
 	reg int weight;