diff srogue/fight.c @ 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 2128c7dc8a40
children e7aab31362af
line wrap: on
line diff
--- a/srogue/fight.c	Thu Jan 28 18:55:47 2016 -0500
+++ b/srogue/fight.c	Sun Jan 31 13:45:07 2016 -0500
@@ -14,19 +14,26 @@
  * See the file LICENSE.TXT for full copyright and licensing information.
  */
 
+#include <stdlib.h>
 #include <ctype.h>
+#include <string.h>
 #include "rogue.h"
 #include "rogue.ext"
 
+bool roll_em(struct stats *att, struct stats *def, struct object *weap, bool hurl);
+char *mindex(char *cp, char c);
+char *prname(char *who, bool upper);
+void hit(char *er);
+void miss(char *er);
+void thunk(struct object *weap, char *mname);
+void bounce(struct object *weap, char *mname);
 
 /*
  * fight:
  *	The player attacks the monster.
  */
-fight(mp, weap, thrown)
-struct coord *mp;
-struct object *weap;
-bool thrown;
+bool
+fight(struct coord *mp, struct object *weap, bool thrown)
 {
 
 	reg struct thing *tp;
@@ -123,8 +130,8 @@
  * attack:
  *	The monster attacks the player
  */
-attack(mp)
-struct thing *mp;
+int
+attack(struct thing *mp)
 {
 	reg char *mname;
 
@@ -349,8 +356,8 @@
  * swing:
  *	Returns true if the swing hits
  */
-swing(at_lvl, op_arm, wplus)
-int at_lvl, op_arm, wplus;
+bool
+swing(int at_lvl, int op_arm, int wplus)
 {
 	reg int res = rnd(20)+1;
 	reg int need = (21 - at_lvl) - op_arm;
@@ -363,7 +370,8 @@
  * check_level:
  *	Check to see if the guy has gone up a level.
  */
-check_level()
+void
+check_level(void)
 {
 	reg int lev, add, dif;
 
@@ -387,15 +395,12 @@
  * roll_em:
  *	Roll several attacks
  */
-roll_em(att, def, weap, hurl)
-struct stats *att, *def;
-struct object *weap;
-bool hurl;
+bool
+roll_em(struct stats *att, struct stats *def, struct object *weap, bool hurl)
 {
 	reg char *cp;
 	reg int ndice, nsides, def_arm, prop_hplus, prop_dplus;
 	reg bool did_hit = FALSE;
-	char *mindex();
 
 	prop_hplus = prop_dplus = 0;
 	if (weap == NULL) {
@@ -479,8 +484,7 @@
  *	Look for char 'c' in string pointed to by 'cp'
  */
 char *
-mindex(cp, c)
-char *cp, c;
+mindex(char *cp, char c)
 {
 	reg int i;
 
@@ -498,9 +502,7 @@
  *	The print name of a combatant
  */
 char *
-prname(who, upper)
-char *who;
-bool upper;
+prname(char *who, bool upper)
 {
 static char tbuf[LINLEN];
 
@@ -522,8 +524,8 @@
  * hit:
  *	Print a message to indicate a succesful hit
  */
-hit(er)
-char *er;
+void
+hit(char *er)
 {
 	msg("%s hit.",prname(er, TRUE));
 }
@@ -533,8 +535,8 @@
  * miss:
  *	Print a message to indicate a poor swing
  */
-miss(er)
-char *er;
+void
+miss(char *er)
 {
 	msg("%s miss%s.",prname(er, TRUE),(er == 0 ? "":"es"));
 }
@@ -544,9 +546,8 @@
  * save_throw:
  *	See if a creature saves against something
  */
-save_throw(which, tp)
-int which;
-struct thing *tp;
+bool
+save_throw(int which, struct thing *tp)
 {
 	reg int need;
 	reg struct stats *st;
@@ -561,8 +562,8 @@
  * save:
  *	See if he saves against various nasty things
  */
-save(which)
-int which;
+bool
+save(int which)
 {
 	return save_throw(which, &player);
 }
@@ -571,7 +572,8 @@
  * raise_level:
  *	The guy just magically went up a level.
  */
-raise_level()
+void
+raise_level(void)
 {
 	him->s_exp = e_levels[him->s_lvl-1] + 1L;
 	check_level();
@@ -582,9 +584,8 @@
  * thunk:
  *	A missile hits a monster
  */
-thunk(weap, mname)
-struct object *weap;
-char *mname;
+void
+thunk(struct object *weap, char *mname)
 {
 	if (weap->o_type == WEAPON)
 		msg("The %s hits the %s.",w_magic[weap->o_which].mi_name,mname);
@@ -597,9 +598,8 @@
  * bounce:
  *	A missile misses a monster
  */
-bounce(weap, mname)
-struct object *weap;
-char *mname;
+void
+bounce(struct object *weap, char *mname)
 {
 	if (weap->o_type == WEAPON)
 		msg("The %s misses the %s.", w_magic[weap->o_which].mi_name,mname);
@@ -612,9 +612,8 @@
  * remove:
  *	Remove a monster from the screen
  */
-remove_monster(mp, item)
-struct coord *mp;
-struct linked_list *item;
+void
+remove_monster(struct coord *mp, struct linked_list *item)
 {
 	reg char what;
 
@@ -633,8 +632,8 @@
  * is_magic:
  *	Returns true if an object radiates magic
  */
-is_magic(obj)
-struct object *obj;
+bool
+is_magic(struct object *obj)
 {
 	switch (obj->o_type) {
 		case ARMOR:
@@ -656,9 +655,8 @@
  * killed:
  *	Called to put a monster to death
  */
-killed(item, pr)
-struct linked_list *item;
-bool pr;
+void
+killed(struct linked_list *item, bool pr)
 {
 	reg struct thing *tp;
 	reg struct object *obj;