diff xrogue/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 f54901b9c39b
children 7c1cb43f346e
line wrap: on
line diff
--- a/xrogue/fight.c	Fri Feb 26 17:30:30 2016 -0500
+++ b/xrogue/fight.c	Wed Mar 02 21:28:34 2016 -0500
@@ -19,6 +19,7 @@
 #include <curses.h>
 #include <ctype.h>
 #include <string.h>
+#include <stdlib.h>
 #include "rogue.h"
 
 #define CONF_DAMAGE     -1
@@ -26,15 +27,23 @@
 #define DEST_DAMAGE     -3
 #define DRAIN_DAMAGE    -4
 
+bool roll_em(struct thing *att_er, struct thing *def_er, struct object *weap, 
+             bool hurl, struct object *cur_weapon, bool back_stab);
+void hit(struct object *weapon, bool see_att, bool see_def, char *er, char *ee, 
+         bool back_stab, bool thrown, bool short_msg);
+void miss(struct object *weapon, bool see_att, bool see_def, char *er, char *ee,
+          bool thrown, bool short_msg);
+int add_dam(short str);
+int hung_dam(void);
+
 int killed_chance = 0;  /* cumulative chance for goodies to loose it */
 
 /*
  * returns true if player has a any chance to hit the monster
  */
 
-player_can_hit(tp, weap)
-register struct thing *tp;
-register struct object *weap;
+bool
+player_can_hit(struct thing *tp, struct object *weap)
 {
     if (off(*tp, CMAGICHIT) && off(*tp, BMAGICHIT) && off(*tp, MAGICHIT))
         return(TRUE);
@@ -62,10 +71,8 @@
  *      The player attacks the monster.
  */
 
-fight(mp, weap, thrown)
-register coord *mp;
-struct object *weap;
-bool thrown;
+bool
+fight(coord *mp, struct object *weap, bool thrown)
 {
     register struct thing *tp;
     register struct linked_list *item;
@@ -226,10 +233,8 @@
  *      The monster attacks the player
  */
 
-attack(mp, weapon, thrown)
-register struct thing *mp;
-register struct object *weapon;
-bool thrown;
+bool
+attack(struct thing *mp, struct object *weapon, bool thrown)
 {
     register char *mname;
     register bool see_att, did_hit = FALSE;
@@ -305,9 +310,8 @@
  *      returns true if the swing hits
  */
 
-swing(class, at_lvl, op_arm, wplus)
-short class;
-int at_lvl, op_arm, wplus;
+bool
+swing(short class, int at_lvl, int op_arm, int wplus)
 {
     register int res = rnd(20)+1;
     register int need;
@@ -327,12 +331,9 @@
  *      Roll several attacks
  */
 
-roll_em(att_er, def_er, weap, hurl, cur_weapon, back_stab)
-struct thing *att_er, *def_er;
-struct object *weap;
-bool hurl;
-struct object *cur_weapon;
-bool back_stab;
+bool
+roll_em(struct thing *att_er, struct thing *def_er, struct object *weap, 
+        bool hurl, struct object *cur_weapon, bool back_stab)
 {
     register struct stats *att, *def;
     register char *cp = NULL;
@@ -739,9 +740,7 @@
  */
 
 char *
-prname(who, upper)
-register char *who;
-bool upper;
+prname(char *who, bool upper)
 {
     static char tbuf[LINELEN];
 
@@ -766,11 +765,9 @@
  *      Print a message to indicate a succesful hit
  */
 
-hit(weapon, see_att, see_def, er, ee, back_stab, thrown, short_msg)
-register struct object *weapon;
-bool see_att, see_def;
-register char *er, *ee;
-bool back_stab, thrown, short_msg;
+void
+hit(struct object *weapon, bool see_att, bool see_def, char *er, char *ee, 
+    bool back_stab, bool thrown, bool short_msg)
 {
     register char *s = NULL;
     char          att_name[LINELEN],    /* Name of attacker */
@@ -830,11 +827,9 @@
  *      Print a message to indicate a poor swing
  */
 
-miss(weapon, see_att, see_def, er, ee, thrown, short_msg)
-register struct object *weapon;
-bool see_att, see_def;
-register char *er, *ee;
-bool thrown, short_msg;
+void
+miss(struct object *weapon, bool see_att, bool see_def, char *er, char *ee, 
+     bool thrown, bool short_msg)
 {
     register char *s = NULL;
     char          att_name[LINELEN],    /* Name of attacker */
@@ -874,8 +869,8 @@
  *      compute to-hit bonus for dexterity
  */
 
-dext_plus(dexterity)
-register int dexterity;
+int
+dext_plus(int dexterity)
 {
         return (dexterity > 10 ? (dexterity-13)/3 : (dexterity-10)/3);
 }
@@ -886,8 +881,8 @@
  *      compute armor class bonus for dexterity
  */
 
-dext_prot(dexterity)
-register int dexterity;
+int
+dext_prot(int dexterity)
 {
     return ((dexterity-10)/2);
 }
@@ -897,8 +892,8 @@
  *      compute bonus/penalties for strength on the "to hit" roll
  */
 
-str_plus(str)
-register short str;
+int
+str_plus(short str)
 {
     return((str-10)/3);
 }
@@ -908,8 +903,8 @@
  *      compute additional damage done for exceptionally high or low strength
  */
 
-add_dam(str)
-register short str;
+int
+add_dam(short str)
 {
     return((str-9)/2);
 }
@@ -919,7 +914,8 @@
  *      Calculate damage depending on players hungry state
  */
 
-hung_dam()
+int
+hung_dam(void)
 {
         reg int howmuch = 0;
 
@@ -938,8 +934,8 @@
  *      Returns true if an object radiates magic
  */
 
-is_magic(obj)
-register struct object *obj;
+bool
+is_magic(struct object *obj)
 {
     switch (obj->o_type)
     {
@@ -963,9 +959,8 @@
  *      Called to put a monster to death
  */
 
-killed(item, pr, points, treasure)
-register struct linked_list *item;
-bool pr, points, treasure;
+void
+killed(struct linked_list *item, bool pr, bool points, bool treasure)
 {
     register struct thing *tp, *mp;
     register struct linked_list *pitem, *nexti, *mitem;
@@ -1115,9 +1110,7 @@
  */
 
 struct linked_list *
-wield_weap(thrown, mp)
-struct object *thrown;
-struct thing *mp;
+wield_weap(struct object *thrown, struct thing *mp)
 {
     int look_for = 0,   /* The projectile weapon we are looking for */
         new_rate,       /* The rating of a prospective weapon */
@@ -1198,8 +1191,9 @@
 
     return(candidate);
 }
-explode(tp)
-register struct thing *tp;
+
+void
+explode(struct thing *tp)
 {
 
     register int x,y, damage;
@@ -1253,11 +1247,8 @@
  *      Called when one monster attacks another monster.
  */
 
-skirmish(attacker, mp, weap, thrown)
-register struct thing *attacker;
-register coord *mp;
-struct object *weap;
-bool thrown;
+bool
+skirmish(struct thing *attacker, coord *mp, struct object *weap, bool thrown)
 {
     register struct thing *defender;
     register struct linked_list *item;