diff rogue4/fight.c @ 225:4f6e056438eb

Merge the GCC5 and build fix branches.
author John "Elwin" Edwards
date Wed, 02 Mar 2016 21:28:34 -0500
parents 1b73a8641b37
children 0990adf580ee
line wrap: on
line diff
--- a/rogue4/fight.c	Fri Feb 26 17:30:30 2016 -0500
+++ b/rogue4/fight.c	Wed Mar 02 21:28:34 2016 -0500
@@ -10,6 +10,7 @@
  * See the file LICENSE.TXT for full copyright and licensing information.
  */
 
+#include <stdlib.h>
 #include <curses.h>
 #include <ctype.h>
 #include <string.h>
@@ -20,15 +21,20 @@
     40920L, 81920L, 163840L, 327680L, 655360L, 1310720L, 2621440L, 0L
 };
 
+bool roll_em(THING *thatt, THING *thdef, THING *weap, bool hurl);
+void hit(char *er, char *ee);
+void miss(char *er, char *ee);
+int str_plus(str_t str);
+int add_dam(str_t str);
+void thunk(THING *weap, const char *mname);
+void bounce(THING *weap, const char *mname);
+
 /*
  * fight:
  *	The player attacks the monster.
  */
-fight(mp, mn, weap, thrown)
-register coord *mp;
-char mn;
-register THING *weap;
-bool thrown;
+bool
+fight(coord *mp, char mn, THING *weap, bool thrown)
 {
     register THING *tp;
     register bool did_hit = TRUE;
@@ -96,8 +102,8 @@
  * attack:
  *	The monster attacks the player
  */
-attack(mp)
-register THING *mp;
+int
+attack(THING *mp)
 {
     register const char *mname;
 
@@ -295,8 +301,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)
 {
     register int res = rnd(20);
     register int need = (20 - at_lvl) - op_arm;
@@ -308,7 +314,8 @@
  * check_level:
  *	Check to see if the guy has gone up a level.
  */
-check_level()
+void
+check_level(void)
 {
     register int i, add, olevel;
 
@@ -332,9 +339,8 @@
  * roll_em:
  *	Roll several attacks
  */
-roll_em(thatt, thdef, weap, hurl)
-THING *thatt, *thdef, *weap;
-bool hurl;
+bool
+roll_em(THING *thatt, THING *thdef, THING *weap, bool hurl)
 {
     register struct stats *att, *def;
     register char *cp;
@@ -440,9 +446,7 @@
  *	The print name of a combatant
  */
 char *
-prname(who, upper)
-register char *who;
-bool upper;
+prname(char *who, bool upper)
 {
     static char tbuf[MAXSTR];
 
@@ -465,8 +469,8 @@
  * hit:
  *	Print a message to indicate a succesful hit
  */
-hit(er, ee)
-register char *er, *ee;
+void
+hit(char *er, char *ee)
 {
     register char *s = "";
 
@@ -491,8 +495,8 @@
  * miss:
  *	Print a message to indicate a poor swing
  */
-miss(er, ee)
-register char *er, *ee;
+void
+miss(char *er, char *ee)
 {
     register char *s = "";
 
@@ -514,9 +518,8 @@
  * save_throw:
  *	See if a creature save against something
  */
-save_throw(which, tp)
-int which;
-THING *tp;
+bool
+save_throw(int which, THING *tp)
 {
     register int need;
 
@@ -528,8 +531,8 @@
  * save:
  *	See if he saves against various nasty things
  */
-save(which)
-register int which;
+bool
+save(int which)
 {
     if (which == VS_MAGIC)
     {
@@ -545,8 +548,8 @@
  * str_plus:
  *	Compute bonus/penalties for strength on the "to hit" roll
  */
-str_plus(str)
-register str_t str;
+int
+str_plus(str_t str)
 {
     if (str == 31)
 	return 3;
@@ -563,9 +566,9 @@
  * add_dam:
  *	Compute additional damage done for exceptionally high or low strength
  */
- add_dam(str)
- register str_t str;
- {
+int
+add_dam(str_t str)
+{
     if (str == 31)
 	return 6;
     if (str > 21)
@@ -587,7 +590,8 @@
  * raise_level:
  *	The guy just magically went up a level.
  */
-raise_level()
+void
+raise_level(void)
 {
     pstats.s_exp = e_levels[pstats.s_lvl-1] + 1L;
     check_level();
@@ -597,9 +601,8 @@
  * thunk:
  *	A missile hits a monster
  */
-thunk(weap, mname)
-register THING *weap;
-register const char *mname;
+void
+thunk(THING *weap, const char *mname)
 {
     if (weap->o_type == WEAPON)
 	addmsg("the %s hits ", w_names[weap->o_which]);
@@ -615,9 +618,8 @@
  * bounce:
  *	A missile misses a monster
  */
-bounce(weap, mname)
-register THING *weap;
-register const char *mname;
+void
+bounce(THING *weap, const char *mname)
 {
     if (weap->o_type == WEAPON)
 	addmsg("the %s misses ", w_names[weap->o_which]);
@@ -633,10 +635,8 @@
  * remove:
  *	Remove a monster from the screen
  */
-remove_monster(mp, tp, waskill)
-register coord *mp;
-register THING *tp;
-bool waskill;
+void
+remove_monster(coord *mp, THING *tp, bool waskill)
 {
     register THING *obj, *nexti;
 
@@ -660,8 +660,8 @@
  * is_magic:
  *	Returns true if an object radiates magic
  */
-is_magic(obj)
-register THING *obj;
+bool
+is_magic(THING *obj)
 {
     switch (obj->o_type)
     {
@@ -683,9 +683,8 @@
  * killed:
  *	Called to put a monster to death
  */
-killed(tp, pr)
-register THING *tp;
-bool pr;
+void
+killed(THING *tp, bool pr)
 {
     pstats.s_exp += tp->t_stats.s_exp;
     /*